Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web3-storage/capabilities

Package Overview
Dependencies
Maintainers
5
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3-storage/capabilities - npm Package Compare versions

Comparing version 10.1.0 to 10.2.0

15

dist/src/store.d.ts

@@ -26,2 +26,17 @@ /**

/**
* Capability to get store metadata by shard CID.
* Use to check for inclusion, or get shard size and origin
*
* `nb.link` is optional to allow delegation of `store/get`
* capability for any shard CID. If link is specified, then the
* capability only allows a get for that specific CID.
*
* When used as as an invocation, `nb.link` must be specified.
*/
export const get: import("@ucanto/interface").TheCapabilityParser<import("@ucanto/interface").CapabilityMatch<"store/get", `did:key:${string}` & `did:${string}` & import("@ucanto/interface").Phantom<{
protocol: "did:";
}>, Schema.InferStruct<{
link: Schema.Schema<import("@ucanto/interface").Link<unknown, number, number, 0 | 1> | undefined, unknown>;
}>>>;
/**
* Capability can be used to remove the stored CAR file from the (memory)

@@ -28,0 +43,0 @@ * space identified by `with` field.

29

dist/src/types.d.ts

@@ -10,3 +10,3 @@ import type { TupleToUnion } from 'type-fest';

import { top } from './top.js';
import { add, list, remove, store } from './store.js';
import * as StoreCaps from './store.js';
import * as UploadCaps from './upload.js';

@@ -164,8 +164,14 @@ import * as AccessCaps from './access.js';

export type UploadAdd = InferInvokedCapability<typeof UploadCaps.add>;
export type UploadGet = InferInvokedCapability<typeof UploadCaps.get>;
export type UploadRemove = InferInvokedCapability<typeof UploadCaps.remove>;
export type UploadList = InferInvokedCapability<typeof UploadCaps.list>;
export type Store = InferInvokedCapability<typeof store>;
export type StoreAdd = InferInvokedCapability<typeof add>;
export type StoreRemove = InferInvokedCapability<typeof remove>;
export type StoreList = InferInvokedCapability<typeof list>;
export interface UploadNotFound extends Ucanto.Failure {
name: 'UploadNotFound';
}
export type UploadGetFailure = UploadNotFound | Ucanto.Failure;
export type Store = InferInvokedCapability<typeof StoreCaps.store>;
export type StoreAdd = InferInvokedCapability<typeof StoreCaps.add>;
export type StoreGet = InferInvokedCapability<typeof StoreCaps.get>;
export type StoreRemove = InferInvokedCapability<typeof StoreCaps.remove>;
export type StoreList = InferInvokedCapability<typeof StoreCaps.list>;
export type StoreAddSuccess = StoreAddSuccessDone | StoreAddSuccessUpload;

@@ -193,2 +199,4 @@ export interface StoreAddSuccessDone {

export type StoreRemoveFailure = StoreItemNotFound | Ucanto.Failure;
export type StoreGetSuccess = StoreListItem;
export type StoreGetFailure = StoreItemNotFound | Ucanto.Failure;
export interface StoreListSuccess extends ListResponse<StoreListItem> {

@@ -207,7 +215,12 @@ }

origin?: UnknownLink;
insertedAt: string;
}
export interface UploadAddSuccess {
export interface UploadListItem {
root: UnknownLink;
shards?: CARLink[];
insertedAt: string;
updatedAt: string;
}
export type UploadAddSuccess = Omit<UploadListItem, 'insertedAt' | 'updatedAt'>;
export type UploadGetSuccess = UploadListItem;
export type UploadRemoveSuccess = UploadDidRemove | UploadDidNotRemove;

@@ -222,4 +235,2 @@ export interface UploadDidRemove extends UploadAddSuccess {

}
export interface UploadListItem extends UploadAddSuccess {
}
export type UCANRevoke = InferInvokedCapability<typeof UCANCaps.revoke>;

@@ -293,2 +304,3 @@ export interface Timestamp {

UploadAdd['can'],
UploadGet['can'],
UploadRemove['can'],

@@ -298,2 +310,3 @@ UploadList['can'],

StoreAdd['can'],
StoreGet['can'],
StoreRemove['can'],

@@ -300,0 +313,0 @@ StoreList['can'],

@@ -35,2 +35,17 @@ /**

/**
* Capability to get upload metadata by root CID.
* Use to check for inclusion, or find the shards for a root.
*
* `nb.root` is optional to allow delegation of `upload/get`
* capability for any root. If root is specified, then the
* capability only allows a get for that single cid.
*
* When used as as an invocation, `nb.root` must be specified.
*/
export const get: import("@ucanto/interface").TheCapabilityParser<import("@ucanto/interface").CapabilityMatch<"upload/get", `did:key:${string}` & `did:${string}` & import("@ucanto/interface").Phantom<{
protocol: "did:";
}>, Schema.InferStruct<{
root: Schema.Schema<import("@ucanto/interface").Link<unknown, number, number, 0 | 1> | undefined, unknown>;
}>>>;
/**
* Capability removes an upload (identified by it's root CID) from the upload

@@ -37,0 +52,0 @@ * list. Please note that removing an upload does not delete corresponding shards

@@ -54,3 +54,3 @@ /**

}>, any>;
export function equalLink<T extends Types.ParsedCapability<"store/add" | "store/remove", Types.URI<"did:">, {
export function equalLink<T extends Types.ParsedCapability<"store/add" | "store/get" | "store/remove", Types.URI<"did:">, {
link?: Types.Link<unknown, number, number, 0 | 1> | undefined;

@@ -57,0 +57,0 @@ }>>(claimed: T, delegated: T): Types.Result<{}, Types.Failure>;

{
"name": "@web3-storage/capabilities",
"version": "10.1.0",
"version": "10.2.0",
"description": "Capabilities provided by web3.storage",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/web3-storage/w3protocol/tree/main/packages/capabilities",

@@ -43,2 +43,3 @@ import * as Provider from './provider.js'

Upload.add.can,
Upload.get.can,
Upload.remove.can,

@@ -48,2 +49,3 @@ Upload.list.can,

Store.add.can,
Store.get.can,
Store.remove.can,

@@ -50,0 +52,0 @@ Store.list.can,

@@ -81,2 +81,24 @@ /**

/**
* Capability to get store metadata by shard CID.
* Use to check for inclusion, or get shard size and origin
*
* `nb.link` is optional to allow delegation of `store/get`
* capability for any shard CID. If link is specified, then the
* capability only allows a get for that specific CID.
*
* When used as as an invocation, `nb.link` must be specified.
*/
export const get = capability({
can: 'store/get',
with: SpaceDID,
nb: Schema.struct({
/**
* shard CID to fetch info about.
*/
link: Link.optional(),
}),
derives: equalLink,
})
/**
* Capability can be used to remove the stored CAR file from the (memory)

@@ -83,0 +105,0 @@ * space identified by `with` field.

@@ -18,3 +18,3 @@ import type { TupleToUnion } from 'type-fest'

import { top } from './top.js'
import { add, list, remove, store } from './store.js'
import * as StoreCaps from './store.js'
import * as UploadCaps from './upload.js'

@@ -225,10 +225,18 @@ import * as AccessCaps from './access.js'

export type UploadAdd = InferInvokedCapability<typeof UploadCaps.add>
export type UploadGet = InferInvokedCapability<typeof UploadCaps.get>
export type UploadRemove = InferInvokedCapability<typeof UploadCaps.remove>
export type UploadList = InferInvokedCapability<typeof UploadCaps.list>
export interface UploadNotFound extends Ucanto.Failure {
name: 'UploadNotFound'
}
export type UploadGetFailure = UploadNotFound | Ucanto.Failure
// Store
export type Store = InferInvokedCapability<typeof store>
export type StoreAdd = InferInvokedCapability<typeof add>
export type StoreRemove = InferInvokedCapability<typeof remove>
export type StoreList = InferInvokedCapability<typeof list>
export type Store = InferInvokedCapability<typeof StoreCaps.store>
export type StoreAdd = InferInvokedCapability<typeof StoreCaps.add>
export type StoreGet = InferInvokedCapability<typeof StoreCaps.get>
export type StoreRemove = InferInvokedCapability<typeof StoreCaps.remove>
export type StoreList = InferInvokedCapability<typeof StoreCaps.list>

@@ -262,2 +270,6 @@ export type StoreAddSuccess = StoreAddSuccessDone | StoreAddSuccessUpload

export type StoreGetSuccess = StoreListItem
export type StoreGetFailure = StoreItemNotFound | Ucanto.Failure
export interface StoreListSuccess extends ListResponse<StoreListItem> {}

@@ -277,9 +289,17 @@

origin?: UnknownLink
insertedAt: string
}
export interface UploadAddSuccess {
export interface UploadListItem {
root: UnknownLink
shards?: CARLink[]
insertedAt: string
updatedAt: string
}
// TODO: (olizilla) make this an UploadListItem too?
export type UploadAddSuccess = Omit<UploadListItem, 'insertedAt' | 'updatedAt'>
export type UploadGetSuccess = UploadListItem
export type UploadRemoveSuccess = UploadDidRemove | UploadDidNotRemove

@@ -296,4 +316,2 @@

export interface UploadListItem extends UploadAddSuccess {}
// UCAN core events

@@ -400,2 +418,3 @@

UploadAdd['can'],
UploadGet['can'],
UploadRemove['can'],

@@ -405,2 +424,3 @@ UploadList['can'],

StoreAdd['can'],
StoreGet['can'],
StoreRemove['can'],

@@ -407,0 +427,0 @@ StoreList['can'],

@@ -81,2 +81,34 @@ /**

/**
* Capability to get upload metadata by root CID.
* Use to check for inclusion, or find the shards for a root.
*
* `nb.root` is optional to allow delegation of `upload/get`
* capability for any root. If root is specified, then the
* capability only allows a get for that single cid.
*
* When used as as an invocation, `nb.root` must be specified.
*/
export const get = capability({
can: 'upload/get',
with: SpaceDID,
nb: Schema.struct({
/**
* Root CID of the DAG to fetch upload info about.
*/
root: Link.optional(),
}),
derives: (self, from) => {
const res = equalWith(self, from)
if (res.error) {
return res
}
if (!from.nb.root) {
return res
}
// root must match if specified in the proof
return equal(self.nb.root, from.nb.root, 'root')
},
})
/**
* Capability removes an upload (identified by it's root CID) from the upload

@@ -83,0 +115,0 @@ * list. Please note that removing an upload does not delete corresponding shards

@@ -63,3 +63,3 @@ import { DID, fail, ok } from '@ucanto/validator'

/**
* @template {Types.ParsedCapability<"store/add"|"store/remove", Types.URI<'did:'>, {link?: Types.Link<unknown, number, number, 0|1>}>} T
* @template {Types.ParsedCapability<"store/add"|"store/get"|"store/remove", Types.URI<'did:'>, {link?: Types.Link<unknown, number, number, 0|1>}>} T
* @param {T} claimed

@@ -66,0 +66,0 @@ * @param {T} delegated

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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