Skip to content

Commit

Permalink
new: ops-helper/apiImpl/* to involve bluesky lib during ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
itaru2622 committed Apr 18, 2024
1 parent 17ca94d commit 63bfbb4
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ data/**
certs/**
config/**secret**
**/__pycache__
**/node_modules/**
**/package-lock.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ this hask uses the result(/tmp/envs.txt) of [the above](#hack-EnvVars-Sources) a

```bash
# create table showing { env x container => value } with ops-helper script.
cat ./docker-compose-builder.yaml | ./ops-helper/compose2envtable.py -l /tmp/envs.txt -o ./docs/env-container-val.xlsx
cat ./docker-compose-builder.yaml | ./ops-helper/compose2envtable/main.py -l /tmp/envs.txt -o ./docs/env-container-val.xlsx
```

[back to top](#top)
Expand Down
38 changes: 38 additions & 0 deletions ops-helper/apiImpl/createDidOnPlc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env ts-node

import * as plc_ from '@did-plc/lib'
import { Secp256k1Keypair } from '@atproto/crypto'
import yargs from 'yargs'

// based on atproto/packages/dev-env/util.ts
const createDidOnPlc = async (opts: any): Promise<any> =>
{
const { handle, pds, plc, signingKeyHex } = opts
const key = await Secp256k1Keypair.import(signingKeyHex)

const did = await new plc_.Client(plc).createDid({
signingKey: key.did(),
rotationKeys: [key.did()],
handle,
signer: key,
pds
})

return { handle, did }
}

const main = async (ops: any) => {
const rtn = await createDidOnPlc(opt)
console.log(JSON.stringify(rtn))
}

const opt = yargs(process.argv.slice(2)).options({
plc: { type: 'string', description: 'PLC URL'},
handle: { type: 'string', description: 'handle name'},
signingKeyHex: { type: 'string', description: 'signing key in hex string'},
pds: { type: 'string', description: 'PDS URL', default: 'pds.invalid' },
tls: { type: 'string', description: 'ignore TLS verification(NODE_TLS_REJECT_UNAUTHORIZED)', default: '0'}
}).parseSync()

process.env['NODE_TLS_REJECT_UNAUTHORIZED']=opt.tls
main(opt)
29 changes: 29 additions & 0 deletions ops-helper/apiImpl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "bluesky-ops",
"version": "1.0.0",
"description": "implementing ops aginst bluesky, including self-hosting blusky",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"ops",
"actuation",
"bluesky",
"self-hosting"
],
"author": "[email protected]",
"license": "MIT",
"homepage": "https://github.com/itaru2622/bluesky-selfhost-env#readme",
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"@atproto/api": "*",
"@atproto/crypto": "*",
"@did-plc/lib": "*",
"@types/yargs": "*",
"ts-node": "*",
"yargs": "*"
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit 63bfbb4

Please sign in to comment.