@ipld/dag-ucan
Advanced tools
Comparing version 1.2.4-beta to 1.3.0-beta
@@ -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"; |
{ | ||
"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
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
65649
1567
12