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

@ipld/dag-ucan

Package Overview
Dependencies
Maintainers
8
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-ucan - npm Package Compare versions

Comparing version 1.0.0-beta to 1.1.0-beta

12

dist/src/lib.d.ts
export * from "./ucan.js";
/** @type {UCAN.Version} */
export const VERSION: UCAN.Version;
export const name: "dag-ucan";
export const raw: 85;
export function encode<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(ucan: UCAN.UCAN<C>): UCAN.ByteView<UCAN.UCAN<C>>;
export function decode<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(bytes: UCAN.ByteView<UCAN.UCAN<C>>): UCAN.View<C>;
export function link<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(ucan: UCAN.UCAN<C>, { hasher }?: {
export function link<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(ucan: UCAN.UCAN<C>, options?: {
hasher?: UCAN.MultihashHasher<number> | undefined;
} | undefined): Promise<UCAN.Proof<C>>;
} | undefined): Promise<CID & UCAN.Proof<C, number>>;
export function write<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>, A extends number = 18>(ucan: UCAN.UCAN<C>, { hasher }?: {
hasher?: UCAN.MultihashHasher<A> | undefined;
} | undefined): Promise<{
cid: CID & UCAN.Proof<C, A>;
bytes: UCAN.ByteView<UCAN.UCAN<C>>;
}>;
export function parse<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(input: UCAN.JWT<UCAN.UCAN<C>>): UCAN.View<C>;

@@ -15,2 +22,3 @@ export function format<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(ucan: UCAN.UCAN<C>): UCAN.JWT<UCAN.UCAN<C>>;

import * as View from "./view.js";
import { CID } from "multiformats/cid";
//# sourceMappingURL=lib.d.ts.map

@@ -56,3 +56,7 @@ import type { MultihashDigest, MultihashHasher } from "multiformats/hashes/interface";

}
export declare type Proof<C extends Capability = Capability> = Link<Data<C>, 1, typeof code> | Link<JWT<Data<C>>, 1, typeof RAW_CODE>;
export declare type Proof<C extends Capability = Capability, A extends number = number> = Link<Data<C>, 1, typeof code, A> | Link<JWT<Data<C>>, 1, typeof RAW_CODE, A>;
export interface Block<T extends unknown = unknown, C extends number = number, A extends number = number> {
bytes: ByteView<T>;
cid: Link<T, 1, C, A>;
}
export declare type Ability = `${string}/${string}` | "*";

@@ -59,0 +63,0 @@ export declare type Resource = `${string}:${string}`;

2

dist/src/view.d.ts

@@ -53,3 +53,3 @@ export function cbor<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(data: UCAN.Data<C>): UCAN.View<C>;

*/
get proofs(): UCAN.Proof<UCAN.Capability<UCAN.Ability, `${string}:${string}`>>[];
get proofs(): UCAN.Proof<UCAN.Capability<UCAN.Ability, `${string}:${string}`>, number>[];
}

@@ -56,0 +56,0 @@ import * as RAW from "multiformats/codecs/raw";

{
"name": "@ipld/dag-ucan",
"description": "UCAN codec for IPLD",
"version": "1.0.0-beta",
"version": "1.1.0-beta",
"keywords": [
"UCAN",
"IPLD",
"JWT",
"multicodec",
"codec",
"parser"
],
"files": [

@@ -6,0 +14,0 @@ "src",

@@ -16,2 +16,3 @@ import * as UCAN from "./ucan.js"

export const VERSION = "0.8.1"
export const name = "dag-ucan"

@@ -94,9 +95,23 @@ export const raw = RAW.code

* @param {{hasher?: UCAN.MultihashHasher}} [options]
* @returns {Promise<UCAN.Proof<C>>}
*/
export const link = async (ucan, { hasher = sha256 } = {}) => {
const digest = await hasher.digest(encode(ucan))
return /** @type {UCAN.Proof<C>} */ (
CID.createV1(ucan.code === raw ? raw : code, digest)
export const link = async (ucan, options) => {
const { cid } = await write(ucan, options)
return cid
}
/**
* @template {UCAN.Capability} C
* @template {number} [A=typeof sha256.code]
* @param {UCAN.UCAN<C>} ucan
* @param {{hasher?: UCAN.MultihashHasher<A>}} [options]
*/
export const write = async (
ucan,
{ hasher = /** @type {UCAN.MultihashHasher<any> } */ (sha256) } = {}
) => {
const bytes = encode(ucan)
const cid = /** @type {CID & UCAN.Proof<C, A>} */ (
CID.createV1(ucan.code, await hasher.digest(bytes))
)
return { cid, bytes }
}

@@ -103,0 +118,0 @@

@@ -82,6 +82,16 @@ import type {

export type Proof<C extends Capability = Capability> =
| Link<Data<C>, 1, typeof code>
| Link<JWT<Data<C>>, 1, typeof RAW_CODE>
export type Proof<
C extends Capability = Capability,
A extends number = number
> = Link<Data<C>, 1, typeof code, A> | Link<JWT<Data<C>>, 1, typeof RAW_CODE, A>
export interface Block<
T extends unknown = unknown,
C extends number = number,
A extends number = number
> {
bytes: ByteView<T>
cid: Link<T, 1, C, A>
}
export type Ability = `${string}/${string}` | "*"

@@ -88,0 +98,0 @@ export type Resource = `${string}:${string}`

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