-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: import space from base64 string #122
Conversation
tweak w3cli to make it easier to use in CI where you want to provide state via env vars... aka what if this flow could all be done from w3cli https://gist.github.com/alanshaw/e949abfcf6728f590ac9fa083dba5648 Service suggestion: 1. Create a keypair for the server ```sh npx ucan-key ed --json ``` Note down `did` and `key` values! 1. Install the w3cli: ```sh npm i -g @web3-storage/w3cli ``` 1. Authorize your agent to use spaces owned by your email address: ```sh w3 authorize [email protected] ``` 1. Create a space for where the uploads will be registered: ```sh w3 space create myspacename w3 space register ``` 1. Delegate from your local machine to the server: ```sh w3 delegation create <did_from_ucan-key_command_above> --can 'store/add' --can 'upload/add' | base64 ``` 1. Set up environment variables `W3_PRINCIPAL` with the output of `key` from step 1 and `SPACE_PROOF_BASE64` with the output of step 4. 1. Install w3cli in your CI workflow, import the space from `SPACE_PROOF_BASE64` and upload your files ```sh w3cli space add --base64 $SPACE_PROOF_BASE64 w3cli up <./path to your file> ``` DONE! by setting `W3_PRINCIPAL` you w3cli in ci will use the key you generated, and the new w3cli space add --base64 <proof string> flag lets you import and use a space proof from a string. License: MIT Signed-off-by: Oli Evans <[email protected]>
? await proofFromString(opts.base64) | ||
: await proofFromPath(proofPath) | ||
const space = await client.addSpace(proof) | ||
await client.setCurrentSpace(space.did()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reckon space add should set the current space. It was annoying to have to do that manually after calling space add. This is what space create does, so this would be consistent.
License: MIT Signed-off-by: Oli Evans <[email protected]>
@@ -121,7 +121,8 @@ cli | |||
.action(registerSpace) | |||
|
|||
cli | |||
.command('space add <proof>') | |||
.command('space add [proof]') | |||
.option('--base64', 'provide proof as base64 encoded string') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it would be helpful for noobs to know more about what is expected as the bytes that are base64d. iirc the idea is we accept any UCAN serialization? but esp car files?
(e.g. do you want base64(cidOfProofCar) or base64(proofCarWithDagUcanCbor)) ?
Superceeded by #158 |
tweak w3cli to make it easier to use in CI where you want to provide state via env vars... aka what if this flow could all be done from w3cli https://gist.github.com/alanshaw/e949abfcf6728f590ac9fa083dba5648
tl;dr what if instead of custom code, the server side of this dance looked like
by setting
W3_PRINCIPAL
you w3cli in ci will use the key you generated, and the neww3cli space add --base64 <proof string>
flag lets you import and use a space proof from a string.Serving suggestion:
on your local machine
Create a keypair for the server
Note down
did
andkey
values!Install the w3cli:
Authorize your agent to use spaces owned by your email address:
Create a space for where the uploads will be registered:
Delegate from your local machine to the server:
in CI or ephemeral server
W3_PRINCIPAL
with the output ofkey
from step 1 andSPACE_PROOF_BASE64
with the output of step 5 above.SPACE_PROOF_BASE64
and upload your filesDONE!
License: MIT