this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add bin executable

futur 75e93c65 0758428d

+122 -6
+4 -1
package.json
··· 5 5 "version": "0.0.1", 6 6 "main": "dist/index.js", 7 7 "types": "dist/index.d.ts", 8 + "bin": "dist/bin.js", 8 9 "license": "MPL-2.0", 9 10 "repository": "https://github.com/skyware-js/labeler", 10 11 "homepage": "https://skyware.js.org/docs/labeler", ··· 25 26 "./scripts": "./dist/scripts/index.js" 26 27 }, 27 28 "devDependencies": { 28 - "@atproto/api": "^0.13.1", 29 29 "@types/better-sqlite3": "^7.6.11", 30 30 "@types/express": "^4.17.21", 31 31 "@types/express-ws": "^3.0.4", 32 32 "@types/node": "^20.11.19", 33 + "@types/prompts": "^2.4.9", 33 34 "@types/ws": "^8.5.12", 34 35 "@typescript-eslint/eslint-plugin": "^6.7.4", 35 36 "@typescript-eslint/parser": "^6.7.4", ··· 39 40 }, 40 41 "dependencies": { 41 42 "@atcute/cbor": "^1.0.0", 43 + "@atproto/api": "^0.13.1", 42 44 "@atproto/crypto": "^0.4.0", 43 45 "@atproto/identity": "^0.4.0", 44 46 "@atproto/xrpc-server": "^0.6.2", 45 47 "better-sqlite3": "^11.1.2", 46 48 "express": "^4.19.2", 47 49 "express-ws": "^5.0.2", 50 + "prompts": "^2.4.2", 48 51 "uint8arrays": "^5.1.0" 49 52 }, 50 53 "files": [
+43 -5
pnpm-lock.yaml
··· 11 11 '@atcute/cbor': 12 12 specifier: ^1.0.0 13 13 version: 1.0.0 14 + '@atproto/api': 15 + specifier: ^0.13.1 16 + version: 0.13.1 14 17 '@atproto/crypto': 15 18 specifier: ^0.4.0 16 19 version: 0.4.0 ··· 29 32 express-ws: 30 33 specifier: ^5.0.2 31 34 version: 5.0.2(express@4.19.2) 35 + prompts: 36 + specifier: ^2.4.2 37 + version: 2.4.2 32 38 uint8arrays: 33 39 specifier: ^5.1.0 34 40 version: 5.1.0 35 41 devDependencies: 36 - '@atproto/api': 37 - specifier: ^0.13.1 38 - version: 0.13.1 39 42 '@types/better-sqlite3': 40 43 specifier: ^7.6.11 41 44 version: 7.6.11 ··· 48 51 '@types/node': 49 52 specifier: ^20.11.19 50 53 version: 20.11.19 54 + '@types/prompts': 55 + specifier: ^2.4.9 56 + version: 2.4.9 51 57 '@types/ws': 52 58 specifier: ^8.5.12 53 59 version: 8.5.12 54 60 '@typescript-eslint/eslint-plugin': 55 61 specifier: ^6.7.4 56 - version: 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.50.0)(typescript@5.5.4) 62 + version: 6.7.4(@typescript-eslint/parser@6.7.4(eslint@8.50.0)(typescript@5.5.4))(eslint@8.50.0)(typescript@5.5.4) 57 63 '@typescript-eslint/parser': 58 64 specifier: ^6.7.4 59 65 version: 6.7.4(eslint@8.50.0)(typescript@5.5.4) ··· 252 258 253 259 '@types/node@20.11.19': 254 260 resolution: {integrity: sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==} 261 + 262 + '@types/prompts@2.4.9': 263 + resolution: {integrity: sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA==} 255 264 256 265 '@types/qs@6.9.15': 257 266 resolution: {integrity: sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==} ··· 824 833 keyv@4.5.4: 825 834 resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} 826 835 836 + kleur@3.0.3: 837 + resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} 838 + engines: {node: '>=6'} 839 + 827 840 levn@0.4.1: 828 841 resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} 829 842 engines: {node: '>= 0.8.0'} ··· 1001 1014 resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} 1002 1015 engines: {node: '>= 0.6.0'} 1003 1016 1017 + prompts@2.4.2: 1018 + resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} 1019 + engines: {node: '>= 6'} 1020 + 1004 1021 proxy-addr@2.0.7: 1005 1022 resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} 1006 1023 engines: {node: '>= 0.10'} ··· 1111 1128 1112 1129 simple-get@4.0.1: 1113 1130 resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} 1131 + 1132 + sisteransi@1.0.5: 1133 + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} 1114 1134 1115 1135 slash@3.0.0: 1116 1136 resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} ··· 1496 1516 dependencies: 1497 1517 undici-types: 5.26.5 1498 1518 1519 + '@types/prompts@2.4.9': 1520 + dependencies: 1521 + '@types/node': 20.11.19 1522 + kleur: 3.0.3 1523 + 1499 1524 '@types/qs@6.9.15': {} 1500 1525 1501 1526 '@types/range-parser@1.2.7': {} ··· 1517 1542 dependencies: 1518 1543 '@types/node': 20.11.19 1519 1544 1520 - '@typescript-eslint/eslint-plugin@6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.50.0)(typescript@5.5.4)': 1545 + '@typescript-eslint/eslint-plugin@6.7.4(@typescript-eslint/parser@6.7.4(eslint@8.50.0)(typescript@5.5.4))(eslint@8.50.0)(typescript@5.5.4)': 1521 1546 dependencies: 1522 1547 '@eslint-community/regexpp': 4.10.0 1523 1548 '@typescript-eslint/parser': 6.7.4(eslint@8.50.0)(typescript@5.5.4) ··· 1532 1557 natural-compare: 1.4.0 1533 1558 semver: 7.6.0 1534 1559 ts-api-utils: 1.2.1(typescript@5.5.4) 1560 + optionalDependencies: 1535 1561 typescript: 5.5.4 1536 1562 transitivePeerDependencies: 1537 1563 - supports-color ··· 1544 1570 '@typescript-eslint/visitor-keys': 6.7.4 1545 1571 debug: 4.3.4 1546 1572 eslint: 8.50.0 1573 + optionalDependencies: 1547 1574 typescript: 5.5.4 1548 1575 transitivePeerDependencies: 1549 1576 - supports-color ··· 1560 1587 debug: 4.3.4 1561 1588 eslint: 8.50.0 1562 1589 ts-api-utils: 1.2.1(typescript@5.5.4) 1590 + optionalDependencies: 1563 1591 typescript: 5.5.4 1564 1592 transitivePeerDependencies: 1565 1593 - supports-color ··· 1575 1603 is-glob: 4.0.3 1576 1604 semver: 7.6.0 1577 1605 ts-api-utils: 1.2.1(typescript@5.5.4) 1606 + optionalDependencies: 1578 1607 typescript: 5.5.4 1579 1608 transitivePeerDependencies: 1580 1609 - supports-color ··· 2146 2175 dependencies: 2147 2176 json-buffer: 3.0.1 2148 2177 2178 + kleur@3.0.3: {} 2179 + 2149 2180 levn@0.4.1: 2150 2181 dependencies: 2151 2182 prelude-ls: 1.2.1 ··· 2306 2337 2307 2338 process@0.11.10: {} 2308 2339 2340 + prompts@2.4.2: 2341 + dependencies: 2342 + kleur: 3.0.3 2343 + sisteransi: 1.0.5 2344 + 2309 2345 proxy-addr@2.0.7: 2310 2346 dependencies: 2311 2347 forwarded: 0.2.0 ··· 2440 2476 decompress-response: 6.0.0 2441 2477 once: 1.4.0 2442 2478 simple-concat: 1.0.1 2479 + 2480 + sisteransi@1.0.5: {} 2443 2481 2444 2482 slash@3.0.0: {} 2445 2483
+75
src/bin.ts
··· 1 + #!/usr/bin/env node 2 + import { IdResolver } from "@atproto/identity"; 3 + import prompt from "prompts"; 4 + import { plcClearLabeler, plcRequestToken, plcSetupLabeler } from "./scripts/index.js"; 5 + 6 + const args = process.argv.slice(2); 7 + const [command] = args; 8 + 9 + const idResolver = new IdResolver(); 10 + 11 + if (command === "create" || command === "delete") { 12 + const did = await promptAndResolveDidOrHandle(); 13 + 14 + const { password, pds, endpoint } = await prompt([{ 15 + type: "password", 16 + name: "password", 17 + message: "Account password (cannot be an app password):", 18 + }, { 19 + type: "text", 20 + name: "pds", 21 + message: "URL of the PDS where the account is located:", 22 + initial: "https://bsky.social", 23 + }, { 24 + type: "text", 25 + name: "endpoint", 26 + message: "URL where the labeler will be hosted:", 27 + validate: (value) => value.startsWith("https://") || "Must be a valid HTTPS URL.", 28 + }]); 29 + 30 + await plcRequestToken({ identifier: did, password, pds }); 31 + 32 + const { plcToken } = await prompt({ 33 + type: "text", 34 + name: "plcToken", 35 + message: "You will receive a login token via email. Token:", 36 + }); 37 + 38 + try { 39 + if (command === "create") { 40 + await plcSetupLabeler({ did, password, pds, plcToken, endpoint }); 41 + console.log("Labeler setup complete!"); 42 + } else { 43 + await plcClearLabeler({ did, password, pds, plcToken }); 44 + console.log("Labeler account restored to normal."); 45 + } 46 + } catch (error) { 47 + console.error("Error setting up labeler:", error); 48 + } 49 + } else { 50 + console.log("Usage: npx @skyware/labeler [command]"); 51 + console.log("Commands:"); 52 + console.log(" create - Initialize an account as a labeler."); 53 + console.log(" delete - Restore a labeler account to normal."); 54 + } 55 + 56 + async function promptAndResolveDidOrHandle() { 57 + let did: string | undefined; 58 + while (!did) { 59 + const { did: didOrHandle } = await prompt({ 60 + type: "text", 61 + name: "did", 62 + message: "DID or handle of the account to use:", 63 + validate: (value) => 64 + value.startsWith("did:") || value.includes(".") || "Invalid DID or handle.", 65 + format: (value) => value.startsWith("@") ? value.slice(1) : value, 66 + }); 67 + did = didOrHandle.startsWith("did:") 68 + ? didOrHandle 69 + : await idResolver.handle.resolve(didOrHandle); 70 + if (!did) { 71 + console.log(`Could not resolve "${didOrHandle}" to a valid account. Please try again.`); 72 + } 73 + } 74 + return did; 75 + }