@web3-storage/capabilities
Advanced tools
Comparing version 17.1.1 to 17.2.0
@@ -58,4 +58,13 @@ /** | ||
}>>>; | ||
/** | ||
* Capability can be used to get the stored Blob from the (memory) | ||
* space identified by `with` field. | ||
*/ | ||
export const get: import("@ucanto/interface").TheCapabilityParser<import("@ucanto/interface").CapabilityMatch<"space/blob/get/0/1", `did:key:${string}` & `did:${string}` & import("@ucanto/interface").Phantom<{ | ||
protocol: "did:"; | ||
}>, Schema.InferStruct<{ | ||
digest: Schema.Schema<Uint8Array, unknown>; | ||
}>>>; | ||
export { Schema }; | ||
import { Schema } from '@ucanto/validator'; | ||
//# sourceMappingURL=blob.d.ts.map |
@@ -381,2 +381,3 @@ import type { TupleToUnion } from 'type-fest'; | ||
export type BlobList = InferInvokedCapability<typeof BlobCaps.list>; | ||
export type BlobGet = InferInvokedCapability<typeof BlobCaps.get>; | ||
export type ServiceBlob = InferInvokedCapability<typeof W3sBlobCaps.blob>; | ||
@@ -410,2 +411,10 @@ export type BlobAllocate = InferInvokedCapability<typeof W3sBlobCaps.allocate>; | ||
export type BlobListFailure = Ucanto.Failure; | ||
export interface BlobGetSuccess { | ||
blob: { | ||
digest: Uint8Array; | ||
size: number; | ||
}; | ||
cause: UnknownLink; | ||
} | ||
export type BlobGetFailure = Ucanto.Failure; | ||
export interface BlobAllocateSuccess { | ||
@@ -660,2 +669,3 @@ size: number; | ||
BlobList['can'], | ||
BlobGet['can'], | ||
ServiceBlob['can'], | ||
@@ -662,0 +672,0 @@ BlobAllocate['can'], |
{ | ||
"name": "@web3-storage/capabilities", | ||
"version": "17.1.1", | ||
"version": "17.2.0", | ||
"description": "UCAN Capabilities provided by web3.storage", | ||
@@ -5,0 +5,0 @@ "homepage": "https://web3.storage", |
@@ -140,4 +140,39 @@ /** | ||
/** | ||
* Capability can be used to get the stored Blob from the (memory) | ||
* space identified by `with` field. | ||
*/ | ||
export const get = capability({ | ||
can: 'space/blob/get/0/1', | ||
/** | ||
* DID of the (memory) space where Blob is stored. | ||
*/ | ||
with: SpaceDID, | ||
nb: Schema.struct({ | ||
/** | ||
* A multihash digest of the blob payload bytes, uniquely identifying blob. | ||
*/ | ||
digest: Schema.bytes(), | ||
}), | ||
derives: (claimed, delegated) => { | ||
if (claimed.with !== delegated.with) { | ||
return fail( | ||
`Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` | ||
) | ||
} else if ( | ||
delegated.nb.digest && | ||
!equals(delegated.nb.digest, claimed.nb.digest) | ||
) { | ||
return fail( | ||
`Link ${ | ||
claimed.nb.digest ? `${claimed.nb.digest}` : '' | ||
} violates imposed ${delegated.nb.digest} constraint.` | ||
) | ||
} | ||
return ok({}) | ||
}, | ||
}) | ||
// ⚠️ We export imports here so they are not omitted in generated typedefs | ||
// @see https://github.com/microsoft/TypeScript/issues/51548 | ||
export { Schema } |
@@ -505,2 +505,3 @@ import type { TupleToUnion } from 'type-fest' | ||
export type BlobList = InferInvokedCapability<typeof BlobCaps.list> | ||
export type BlobGet = InferInvokedCapability<typeof BlobCaps.get> | ||
export type ServiceBlob = InferInvokedCapability<typeof W3sBlobCaps.blob> | ||
@@ -554,2 +555,11 @@ export type BlobAllocate = InferInvokedCapability<typeof W3sBlobCaps.allocate> | ||
// Blob get | ||
export interface BlobGetSuccess { | ||
blob: { digest: Uint8Array; size: number } | ||
cause: UnknownLink | ||
} | ||
// TODO: make types more specific | ||
export type BlobGetFailure = Ucanto.Failure | ||
// Blob allocate | ||
@@ -907,2 +917,3 @@ export interface BlobAllocateSuccess { | ||
BlobList['can'], | ||
BlobGet['can'], | ||
ServiceBlob['can'], | ||
@@ -909,0 +920,0 @@ BlobAllocate['can'], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196731
4629
4
1
15206