New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@storacha/cli

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storacha/cli - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

31

bin.js

@@ -135,4 +135,33 @@ #!/usr/bin/env node

.option('-a, --account <email>', 'Managing account email')
.action(Space.create)
.option(
'-ag, --authorize-gateway-services <json>',
'Authorize Gateways to serve the content uploaded to this space, e.g: \'[{"id":"did:key:z6Mki...","serviceEndpoint":"https://gateway.example.com"}]\''
)
.option('-nga, --no-gateway-authorization', 'Skip Gateway Authorization')
.action((name, options) => {
let authorizeGatewayServices = []
if (options['authorize-gateway-services']) {
try {
authorizeGatewayServices = JSON.parse(
options['authorize-gateway-services']
)
} catch (err) {
console.error('Invalid JSON format for --authorize-gateway-services')
process.exit(1)
}
}
const parsedOptions = {
...options,
// if defined it means we want to skip gateway authorization, so the client will not validate the gateway services
skipGatewayAuthorization:
options['gateway-authorization'] === false ||
options['gateway-authorization'] === undefined,
// default to empty array if not set, so the client will validate the gateway services
authorizeGatewayServices: authorizeGatewayServices || [],
}
return Space.create(name, parsedOptions)
})
cli

@@ -139,0 +168,0 @@ .command('space provision [name]')

# Changelog
## [1.1.0](https://github.com/storacha/upload-service/compare/cli-v1.0.1...cli-v1.1.0) (2024-12-19)
### Features
* content serve authorization ([#1590](https://github.com/storacha/upload-service/issues/1590)) + set default gateway ([#99](https://github.com/storacha/upload-service/issues/99)) ([6cbb202](https://github.com/storacha/upload-service/commit/6cbb2027c829189937363b374e258bb1a2b07722))
### Other Changes
* **main:** release client 1.0.6 ([27cb383](https://github.com/storacha/upload-service/commit/27cb383ea5aae32ca44cc2986f781458130fbffb))
* **main:** release client 1.0.6 ([#104](https://github.com/storacha/upload-service/issues/104)) ([07f27a2](https://github.com/storacha/upload-service/commit/07f27a22a942bde67b55e785b2e3785906d63422))
* **main:** release upload-api 1.1.8 ([aec53e7](https://github.com/storacha/upload-service/commit/aec53e714ea581421e1c55a6e282b765f5badaaa))
* **main:** release upload-api 1.1.8 ([#103](https://github.com/storacha/upload-service/issues/103)) ([e71494a](https://github.com/storacha/upload-service/commit/e71494a12fbd6a93bf2871eec1b101d4b02af38f))
## [1.0.1](https://github.com/storacha/upload-service/compare/cli-v1.0.0...cli-v1.0.1) (2024-11-13)

@@ -4,0 +19,0 @@

4

index.js

@@ -268,3 +268,5 @@ import fs from 'node:fs'

const client = await getClient()
const space = await client.createSpace(name)
const space = await client.createSpace(name, {
skipGatewayAuthorization: true,
})
await client.setCurrentSpace(space.did())

@@ -271,0 +273,0 @@ console.log(space.did())

{
"name": "@storacha/cli",
"type": "module",
"version": "1.0.1",
"version": "1.1.0",
"license": "Apache-2.0 OR MIT",

@@ -38,5 +38,5 @@ "description": "Command Line Interface to the Storacha Network",

"typescript": "^5.2.2",
"@storacha/capabilities": "^1.1.1",
"@storacha/upload-api": "^1.1.3",
"@storacha/eslint-config": "^0.0.0"
"@storacha/capabilities": "^1.2.0",
"@storacha/eslint-config": "^0.0.0",
"@storacha/upload-api": "^1.2.0"
},

@@ -65,5 +65,5 @@ "dependencies": {

"update-notifier": "^7.0.0",
"@storacha/access": "^0.0.0",
"@storacha/client": "^1.0.1",
"@storacha/did-mailto": "^1.0.0"
"@storacha/access": "^1.0.0",
"@storacha/client": "^1.1.0",
"@storacha/did-mailto": "^1.0.1"
},

@@ -70,0 +70,0 @@ "eslintConfig": {

@@ -281,3 +281,3 @@ # CLI

`storacha` CLI will use the w3up `did:web:upload.storacha.network` as the service did. If you would like
`storacha` CLI will use the w3up `did:web:upload.storacha.network` as the service DID. If you would like
to use a different w3up-compatible service, set `STORACHA_SERVICE_DID` and `STORACHA_SERVICE_URL` environment variables to set the service DID and URL endpoint.

@@ -287,2 +287,8 @@

### `STORACHA_RECEIPTS_URL`
The URL at which UCAN receipts issued by the service may be fetched.
Default `https://upload.storacha.network/receipt/`
## FAQ

@@ -289,0 +295,0 @@

import * as W3Space from '@storacha/client/space'
import * as W3Account from '@storacha/client/account'
import * as UcantoClient from '@ucanto/client'
import { HTTP } from '@ucanto/transport'
import * as CAR from '@ucanto/transport/car'
import { getClient } from './lib.js'

@@ -20,2 +23,4 @@ import process from 'node:process'

* @property {string|false} [account]
* @property {Array<{id: import('@ucanto/interface').DID, serviceEndpoint: string}>} [authorizeGatewayServices] - The DID Key or DID Web and URL of the Gateway to authorize to serve content from the created space.
* @property {boolean} [skipGatewayAuthorization] - Whether to skip the Gateway authorization. It means that the content of the space will not be served by any Gateway.
*

@@ -29,3 +34,24 @@ * @param {string|undefined} name

const space = await client.createSpace(await chooseName(name ?? '', spaces))
let space
if (options.skipGatewayAuthorization === true) {
space = await client.createSpace(await chooseName(name ?? '', spaces), {
skipGatewayAuthorization: true,
})
} else {
const gateways = options.authorizeGatewayServices ?? []
const connections = gateways.map(({ id, serviceEndpoint }) => {
/** @type {UcantoClient.ConnectionView<import('@storacha/client/types').ContentServeService>} */
const connection = UcantoClient.connect({
id: {
did: () => id,
},
codec: CAR.outbound,
channel: HTTP.open({ url: new URL(serviceEndpoint) }),
})
return connection
})
space = await client.createSpace(await chooseName(name ?? '', spaces), {
authorizeGatewayServices: connections,
})
}

@@ -32,0 +58,0 @@ // Unless use opted-out from paper key recovery, we go through the flow

@@ -105,3 +105,3 @@ import fs from 'fs'

const command = storacha
.args(['space', 'create'])
.args(['space', 'create', '--no-gateway-authorization'])
.env(context.env.alice)

@@ -119,3 +119,3 @@ .fork()

const create = storacha
.args(['space', 'create', 'home'])
.args(['space', 'create', 'home', '--no-gateway-authorization'])
.env(context.env.alice)

@@ -141,3 +141,9 @@ .fork()

const create = storacha
.args(['space', 'create', 'home', '--no-caution'])
.args([
'space',
'create',
'home',
'--no-caution',
'--no-gateway-authorization',
])
.env(context.env.alice)

@@ -166,3 +172,9 @@ .fork()

const create = storacha
.args(['space', 'create', 'home', '--no-recovery'])
.args([
'space',
'create',
'home',
'--no-recovery',
'--no-gateway-authorization',
])
.env(context.env.alice)

@@ -186,3 +198,9 @@ .fork()

const create = storacha
.args(['space', 'create', 'home', '--no-recovery'])
.args([
'space',
'create',
'home',
'--no-recovery',
'--no-gateway-authorization',
])
.env(context.env.alice)

@@ -205,3 +223,9 @@ .fork()

const create = storacha
.args(['space', 'create', 'my-space', '--no-recovery'])
.args([
'space',
'create',
'my-space',
'--no-recovery',
'--no-gateway-authorization',
])
.env(context.env.alice)

@@ -237,2 +261,3 @@ .fork()

'--no-account',
'--no-gateway-authorization',
])

@@ -250,4 +275,2 @@ .join()

await login(context, { email: 'alice@web.mail' })
await login(context, { email: 'alice@email.me' })
await selectPlan(context)

@@ -261,2 +284,3 @@

'--no-recovery',
'--no-gateway-authorization',
'--customer',

@@ -291,2 +315,3 @@ 'alice@web.mail',

'--no-recovery',
'--no-gateway-authorization',
'--customer',

@@ -325,3 +350,9 @@ email,

.env(context.env.alice)
.args(['space', 'create', 'home', '--no-recovery'])
.args([
'space',
'create',
'home',
'--no-recovery',
'--no-gateway-authorization',
])
.join()

@@ -333,2 +364,39 @@

'storacha space create home --no-recovery --customer alice@web.mail --account alice@web.mail --authorize-gateway-services':
test(async (assert, context) => {
const email = 'alice@web.mail'
await login(context, { email })
await selectPlan(context, { email })
const serverId = context.connection.id
const serverURL = context.serverURL
const { output } = await storacha
.args([
'space',
'create',
'home',
'--no-recovery',
'--customer',
email,
'--account',
email,
'--authorize-gateway-services',
`[{"id":"${serverId}","serviceEndpoint":"${serverURL}"}]`,
])
.env(context.env.alice)
.join()
assert.match(output, /account is authorized/i)
const result = await context.delegationsStorage.find({
audience: DIDMailto.fromEmail(email),
})
assert.ok(
result.ok?.find((d) => d.capabilities[0].can === '*'),
'account has been delegated access to the space'
)
}),
'storacha space add': test(async (assert, context) => {

@@ -657,2 +725,3 @@ const { env } = context

'--no-account',
'--no-gateway-authorization',
'--customer',

@@ -690,2 +759,3 @@ email,

'--no-account',
'--no-gateway-authorization',
'--customer',

@@ -723,2 +793,3 @@ email,

'--no-account',
'--no-gateway-authorization',
'--customer',

@@ -755,2 +826,3 @@ email,

'--no-account',
'--no-gateway-authorization',
'--customer',

@@ -1390,2 +1462,3 @@ email,

'--no-account',
'--no-gateway-authorization',
...(customer ? ['--customer', customer] : ['--no-customer']),

@@ -1392,0 +1465,0 @@ ])

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc