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

@ucanto/core

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ucanto/core - npm Package Compare versions

Comparing version 5.2.0 to 7.0.0

dist/src/car.d.ts

20

dist/src/delegation.d.ts

@@ -15,10 +15,11 @@ export function isLink(value: API.Proof): value is UCAN.Link<UCAN.Capabilities, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>;

* @param {API.UCANBlock<C>} root
* @param {Map<string, API.Block>} [blocks]
* @param {DAG.BlockStore} [blocks]
*/
constructor(root: API.UCANBlock<C>, blocks?: Map<string, API.Transport.Block<any, number, number, 1>> | undefined);
constructor(root: API.UCANBlock<C>, blocks?: DAG.BlockStore<unknown> | undefined);
root: UCAN.Block<C, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>;
blocks: Map<string, API.Transport.Block<any, number, number, 1>>;
blocks: DAG.BlockStore<unknown>;
get version(): `${number}.${number}.${number}`;
get signature(): UCAN.Signature<unknown, UCAN.SigAlg>;
get signature(): UCAN.SignatureView<unknown, UCAN.SigAlg>;
get cid(): UCAN.IPLDLink<UCAN.UCAN<C>, UCAN.MulticodecCode<number, string>, UCAN.SigAlg, 1>;
link(): UCAN.IPLDLink<UCAN.UCAN<C>, UCAN.MulticodecCode<number, string>, UCAN.SigAlg, 1>;
get asCID(): UCAN.IPLDLink<UCAN.UCAN<C>, UCAN.MulticodecCode<number, string>, UCAN.SigAlg, 1>;

@@ -28,2 +29,3 @@ get bytes(): UCAN.ByteView<UCAN.UCAN<C>>;

export(): IterableIterator<API.Transport.Block<any, number, number, 1>>;
iterateIPLDBlocks(): IterableIterator<API.Transport.Block<any, number, number, 1>>;
/**

@@ -68,2 +70,3 @@ * @type {API.Proof[]}

delegate(): Delegation<C>;
buildIPLDView(): Delegation<C>;
/**

@@ -75,11 +78,16 @@ * @returns {API.DelegationJSON<this>}

export function delegate<C extends UCAN.Capabilities>({ issuer, audience, proofs, ...input }: API.DelegationOptions<C>, options?: API.EncodeOptions | undefined): Promise<API.Delegation<C>>;
export function exportDAG<C extends UCAN.Capabilities>(root: UCAN.Block<C, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>, blocks: Map<string, API.Block>): IterableIterator<API.Block>;
export function exportDAG<C extends UCAN.Capabilities>(root: UCAN.Block<C, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>, blocks: DAG.BlockStore<unknown>): IterableIterator<API.Block>;
export function importDAG<C extends UCAN.Capabilities>(dag: Iterable<API.Block>): API.Delegation<C>;
export function create<C extends UCAN.Capabilities>({ root, blocks }: {
root: UCAN.Block<C, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>;
blocks?: Map<string, API.Transport.Block<unknown, number, number, 1>> | undefined;
blocks?: DAG.BlockStore<unknown> | undefined;
}): API.Delegation<C>;
export function view<C extends UCAN.Capabilities, T = undefined>({ root, blocks }: {
root: UCAN.Link<C, UCAN.MulticodecCode<number, string>, UCAN.SigAlg>;
blocks: DAG.BlockStore<unknown>;
}, fallback?: T | undefined): T | API.Delegation<C>;
export { Delegation as View };
import * as API from "@ucanto/interface";
import * as UCAN from "@ipld/dag-ucan/.";
import * as DAG from "./dag.js";
//# sourceMappingURL=delegation.d.ts.map
export function invoke<Capability extends API.Capability<API.Ability, `${string}:${string}`, any>>(options: API.InvocationOptions<Capability>): API.IssuedInvocationView<Capability>;
export function create<C extends API.Capability<API.Ability, `${string}:${string}`, any>>({ root, blocks }: {
root: API.UCANBlock<[C], API.MulticodecCode<number, string>, API.SigAlg>;
blocks?: DAG.BlockStore<unknown> | undefined;
}): API.Invocation<C>;
export function view<C extends API.Capability<API.Ability, `${string}:${string}`, any>, Invocation_1 extends API.Invocation<API.Capability<API.Ability, `${string}:${string}`, unknown>>, T = never>({ root, blocks }: {
root: API.UCANLink<[C], API.MulticodecCode<number, string>, API.SigAlg>;
blocks: DAG.BlockStore<unknown>;
}, fallback?: T | undefined): T | API.Invocation<C>;
/**
* @template {API.Capability} Capability
* @implements {API.Invocation<Capability>}
* @extends {Delegation<[Capability]>}
*/
export class Invocation<Capability extends API.Capability<API.Ability, `${string}:${string}`, any>> extends Delegation<[Capability]> implements API.Invocation<Capability> {
constructor(root: API.UCANBlock<[Capability], API.MulticodecCode<number, string>, API.SigAlg>, blocks?: DAG.BlockStore<unknown> | undefined);
}
import * as API from "@ucanto/interface";
import * as DAG from "./dag.js";
import { Delegation } from "./delegation.js";
//# sourceMappingURL=invocation.d.ts.map

@@ -0,7 +1,18 @@

export * as API from "@ucanto/interface";
export * as Delegation from "./delegation.js";
export * as Invocation from "./invocation.js";
export * as Message from "./message.js";
export * as Receipt from "./receipt.js";
export * as DAG from "./dag.js";
export * as CBOR from "./cbor.js";
export * as CAR from "./car.js";
export { invoke } from "./invocation.js";
export { sha256 } from "multiformats/hashes/sha2";
export * as UCAN from "@ipld/dag-ucan/.";
export * as DID from "@ipld/dag-ucan/did";
export * as Signature from "@ipld/dag-ucan/signature";
export * from "./result.js";
export * as Schema from "./schema.js";
export { delegate, isDelegation } from "./delegation.js";
export { create as createLink, createLegacy as createLegacyLink, isLink, parse as parseLink, decode as decodeLink } from "./link.js";
//# sourceMappingURL=lib.d.ts.map
export * from "multiformats/dist/types/src/link";
export { base32 } from "multiformats/bases/base32";
export { base58btc } from "multiformats/bases/base58";
//# sourceMappingURL=link.d.ts.map
{
"name": "@ucanto/core",
"description": "ucanto core",
"version": "5.2.0",
"version": "7.0.0",
"keywords": [

@@ -26,5 +26,5 @@ "UCAN",

"@ipld/dag-cbor": "^9.0.0",
"@ipld/dag-ucan": "^3.2.0",
"@ipld/dag-ucan": "^3.3.2",
"multiformats": "^11.0.0",
"@ucanto/interface": "^6.2.0"
"@ucanto/interface": "^7.0.0"
},

@@ -40,3 +40,3 @@ "devDependencies": {

"typescript": "^4.9.5",
"@ucanto/principal": "^5.1.0"
"@ucanto/principal": "^7.0.0"
},

@@ -72,2 +72,26 @@ "type": "module",

"import": "./src/delegation.js"
},
"./receipt": {
"types": "./dist/src/receipt.d.ts",
"import": "./src/receipt.js"
},
"./cbor": {
"types": "./dist/src/cbor.d.ts",
"import": "./src/cbor.js"
},
"./car": {
"types": "./dist/src/car.d.ts",
"import": "./src/car.js"
},
"./dag": {
"types": "./dist/src/dag.d.ts",
"import": "./src/dag.js"
},
"./result": {
"types": "./dist/src/result.d.ts",
"import": "./src/result.js"
},
"./schema": {
"types": "./dist/src/schema.d.ts",
"import": "./src/schema.js"
}

@@ -85,3 +109,3 @@ },

"test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/*.spec.js",
"test": "npm run test:node",
"test": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha --bail test/*.spec.js",
"coverage": "c8 --reporter=html mocha test/*.spec.js && npm_config_yes=true npx st -d coverage -p 8080",

@@ -88,0 +112,0 @@ "check": "tsc --build",

import * as UCAN from '@ipld/dag-ucan'
import * as API from '@ucanto/interface'
import * as Link from './link.js'
import * as DAG from './dag.js'

@@ -158,3 +159,3 @@ /**

* @param {API.UCANBlock<C>} root
* @param {Map<string, API.Block>} [blocks]
* @param {DAG.BlockStore} [blocks]
*/

@@ -181,2 +182,5 @@ constructor(root, blocks = new Map()) {

}
link() {
return this.root.cid
}
get asCID() {

@@ -197,2 +201,6 @@ return this.cid

iterateIPLDBlocks() {
return exportDAG(this.root, this.blocks)
}
/**

@@ -268,2 +276,6 @@ * @type {API.Proof[]}

buildIPLDView() {
return this
}
/**

@@ -359,3 +371,3 @@ * @returns {API.DelegationJSON<this>}

* @param {API.UCANBlock<C>} root
* @param {Map<string, API.Block>} blocks
* @param {DAG.BlockStore} blocks
* @returns {IterableIterator<API.Block>}

@@ -367,3 +379,3 @@ */

// Check if block is included in this delegation
const root = /** @type {UCAN.Block} */ (blocks.get(link.toString()))
const root = /** @type {UCAN.Block} */ (blocks.get(`${link}`))
if (root) {

@@ -406,3 +418,3 @@ yield* exportDAG(root, blocks)

* @param {API.UCANBlock<C>} dag.root
* @param {Map<string, API.Block<unknown>>} [dag.blocks]
* @param {DAG.BlockStore} [dag.blocks]
* @returns {API.Delegation<C>}

@@ -413,2 +425,16 @@ */

/**
* @template {API.Capabilities} C
* @template [T=undefined]
* @param {object} dag
* @param {API.UCANLink<C>} dag.root
* @param {DAG.BlockStore} dag.blocks
* @param {T} [fallback]
* @returns {API.Delegation<C>|T}
*/
export const view = ({ root, blocks }, fallback) => {
const block = DAG.get(root, blocks, null)
return block ? create({ root: block, blocks }) : /** @type {T} */ (fallback)
}
/**
* @param {API.Delegation} delegation

@@ -415,0 +441,0 @@ */

import * as API from '@ucanto/interface'
import { delegate } from './delegation.js'
import { delegate, Delegation } from './delegation.js'
import * as DAG from './dag.js'

@@ -12,2 +13,36 @@ /**

/**
* @template {API.Capability} C
* @param {object} dag
* @param {API.UCANBlock<[C]>} dag.root
* @param {DAG.BlockStore} [dag.blocks]
* @returns {API.Invocation<C>}
*/
export const create = ({ root, blocks }) => new Invocation(root, blocks)
/**
* Takes a link of the `root` block and a map of blocks and constructs an
* `Invocation` from it. If `root` is not included in the provided blocks
* provided fallback is returned and if not provided than throws an error.
* If root points to wrong block (that is not an invocation) it will misbehave
* and likely throw some errors on field access.
*
* @template {API.Capability} C
* @template {API.Invocation} Invocation
* @template [T=never]
* @param {object} dag
* @param {API.UCANLink<[C]>} dag.root
* @param {DAG.BlockStore} dag.blocks
* @param {T} [fallback]
* @returns {API.Invocation<C>|T}
*/
export const view = ({ root, blocks }, fallback) => {
const block = DAG.get(root, blocks, null)
if (block == null) {
return fallback !== undefined ? fallback : DAG.notFound(root)
}
return /** @type {API.Invocation<C>} */ (create({ root: block, blocks }))
}
/**
* @template {API.Capability} Capability

@@ -56,6 +91,10 @@ * @implements {API.IssuedInvocationView<Capability>}

buildIPLDView() {
return delegate(this)
}
/**
* @template {API.InvocationService<Capability>} Service
* @param {API.ConnectionView<Service>} connection
* @returns {Promise<API.InferServiceInvocationReturn<Capability, Service>>}
* @returns {Promise<API.InferReceipt<Capability, Service>>}
*/

@@ -72,1 +111,8 @@ async execute(connection) {

}
/**
* @template {API.Capability} Capability
* @implements {API.Invocation<Capability>}
* @extends {Delegation<[Capability]>}
*/
export class Invocation extends Delegation {}

@@ -0,2 +1,9 @@

export * as API from '@ucanto/interface'
export * as Delegation from './delegation.js'
export * as Invocation from './invocation.js'
export * as Message from './message.js'
export * as Receipt from './receipt.js'
export * as DAG from './dag.js'
export * as CBOR from './cbor.js'
export * as CAR from './car.js'
export { delegate, isDelegation } from './delegation.js'

@@ -11,3 +18,7 @@ export { invoke } from './invocation.js'

} from './link.js'
export { sha256 } from 'multiformats/hashes/sha2'
export * as UCAN from '@ipld/dag-ucan'
export * as DID from '@ipld/dag-ucan/did'
export * as Signature from '@ipld/dag-ucan/signature'
export * from './result.js'
export * as Schema from './schema.js'
export * from 'multiformats/link'
export { base32 } from 'multiformats/bases/base32'
export { base58btc } from 'multiformats/bases/base58'

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