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.2.4-beta to 1.3.0-beta

4

dist/src/lib.d.ts

@@ -22,2 +22,6 @@ export * from "./ucan.js";

export function issue<A extends number, C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>({ issuer, audience, capabilities, lifetimeInSeconds, expiration, notBefore, facts, proofs, nonce, }: UCAN.UCANOptions<C, A>): Promise<UCAN.View<C>>;
export function verifySignature<C extends UCAN.Capability<UCAN.Ability, `${string}:${string}`>>(ucan: UCAN.Model<C>, verifier: UCAN.Verifier & UCAN.Agent): UCAN.Await<boolean>;
export function isExpired(ucan: UCAN.Model): boolean;
export function isTooEarly(ucan: UCAN.Model): boolean;
export function now(): number;
import * as UCAN from "./ucan.js";

@@ -24,0 +28,0 @@ import * as CBOR from "./codec/cbor.js";

5

package.json
{
"name": "@ipld/dag-ucan",
"description": "UCAN codec for IPLD",
"version": "1.2.4-beta",
"version": "1.3.0-beta",
"keywords": [

@@ -87,5 +87,6 @@ "UCAN",

"playwright-test": "^7.2.2",
"typescript": "^4.6.3"
"typescript": "^4.6.3",
"@noble/ed25519": "^1.6.0"
},
"license": "(Apache-2.0 AND MIT)"
}

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

import { CID } from "multiformats/cid"
import { format as formatDID } from "./did.js"

@@ -170,3 +171,33 @@ export * from "./ucan.js"

/**
* Verifies UCAN signature.
*
* @template {UCAN.Capability} C
* @param {UCAN.Model<C>} ucan
* @param {UCAN.Verifier & UCAN.Agent} verifier
*/
export const verifySignature = (ucan, verifier) =>
formatDID(ucan.issuer) === verifier.did() &&
verifier.verify(UTF8.encode(Formatter.formatPayload(ucan)), ucan.signature)
/**
* Check if a UCAN is expired.
*
* @param {UCAN.Model} ucan
*/
export const isExpired = ucan => ucan.expiration <= now()
/**
* Check if a UCAN is not active yet.
* @param {UCAN.Model} ucan
*/
export const isTooEarly = ucan =>
ucan.notBefore != null && now() <= ucan.notBefore
/**
* Returns UTC Unix timestamp for comparing it against time window of the UCAN.
*/
export const now = () => Math.floor(Date.now() / 1000)
/**
*
* @param {unknown & {did?:unknown}} value

@@ -173,0 +204,0 @@ * @param {string} context

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