New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ucanto/interface

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ucanto/interface - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

38

dist/src/capability.d.ts

@@ -42,7 +42,7 @@ import { Ability, Capability, DID, Link, Resource } from '@ipld/dag-ucan';

}
export declare type MatchResult<M extends Match> = Result<M, InvalidCapability>;
export type MatchResult<M extends Match> = Result<M, InvalidCapability>;
/**
* Error produced when parsing capabilities
*/
export declare type InvalidCapability = UnknownCapability | MalformedCapability;
export type InvalidCapability = UnknownCapability | MalformedCapability;
export interface DerivedMatch<T, M extends Match> extends Match<T, M | DerivedMatch<T, M>> {

@@ -59,3 +59,3 @@ }

*/
export declare type ToDeriveClaim<T extends ParsedCapability> = T | ParsedCapability<T['can'], T['with'], Partial<T['nb']>>;
export type ToDeriveClaim<T extends ParsedCapability> = T | ParsedCapability<T['can'], T['with'], Partial<T['nb']>>;
/**

@@ -68,3 +68,3 @@ * Utility type is used to infer type of the second argument of `derives`

*/
export declare type ToDeriveProof<T> = T extends ParsedCapability ? ToDeriveClaim<T> : ToDeriveProofs<T>;
export type ToDeriveProof<T> = T extends ParsedCapability ? ToDeriveClaim<T> : ToDeriveProofs<T>;
/**

@@ -74,3 +74,3 @@ * Another helper type which is equivalent of `ToDeriveClaim` except it works

*/
declare type ToDeriveProofs<T> = T extends [infer U, ...infer E] ? [ToDeriveClaim<U & ParsedCapability>, ...ToDeriveProofs<E>] : T extends never[] ? [] : never;
type ToDeriveProofs<T> = T extends [infer U, ...infer E] ? [ToDeriveClaim<U & ParsedCapability>, ...ToDeriveProofs<E>] : T extends never[] ? [] : never;
export interface Derives<T extends ParsedCapability, U = T> {

@@ -114,3 +114,3 @@ (claim: T, proof: U): Result<true, Failure>;

}
export declare type InferCaveatParams<T> = keyof T extends never ? never | undefined : {
export type InferCaveatParams<T> = keyof T extends never ? never | undefined : {
[K in keyof T]: T[K] extends {

@@ -135,3 +135,3 @@ toJSON(): infer U;

}
export declare type InferCreateOptions<R extends Resource, C extends {} | undefined> = keyof C extends never ? {
export type InferCreateOptions<R extends Resource, C extends {} | undefined> = keyof C extends never ? {
with: R;

@@ -143,6 +143,6 @@ nb?: never;

};
export declare type InferInvokeOptions<R extends Resource, C extends {} | undefined> = UCANOptions & {
export type InferInvokeOptions<R extends Resource, C extends {} | undefined> = UCANOptions & {
issuer: Signer;
} & InferCreateOptions<R, C>;
export declare type InferDelegationOptions<R extends Resource, C extends {} | undefined> = UCANOptions & {
export type InferDelegationOptions<R extends Resource, C extends {} | undefined> = UCANOptions & {
issuer: Signer;

@@ -152,10 +152,10 @@ with: R;

};
export declare type EmptyObject = {
export type EmptyObject = {
[key: string | number | symbol]: never;
};
declare type Optionalize<T> = InferRequried<T> & InferOptional<T>;
declare type InferOptional<T> = {
type Optionalize<T> = InferRequried<T> & InferOptional<T>;
type InferOptional<T> = {
[K in keyof T as T[K] | undefined extends T[K] ? K : never]?: T[K];
};
declare type InferRequried<T> = {
type InferRequried<T> = {
[K in keyof T as T[K] | undefined extends T[K] ? never : K]: T[K];

@@ -227,9 +227,9 @@ };

}
export declare type InferMembers<Selectors extends unknown[]> = Selectors extends [
export type InferMembers<Selectors extends unknown[]> = Selectors extends [
MatchSelector<infer Match>,
...infer Rest
] ? [Match, ...InferMembers<Rest>] : Selectors extends [] ? [] : never;
export declare type InferValue<Members extends unknown[]> = Members extends [] ? [] : Members extends [Match<infer T>, ...infer Rest] ? [T, ...InferValue<Rest>] : never;
export declare type InferMatch<Members extends unknown[]> = Members extends [] ? [] : Members extends [Match<unknown, infer M>, ...infer Rest] ? [M, ...InferMatch<Rest>] : never;
export declare type ParsedCapability<Can extends Ability = Ability, Resource extends URI = URI, C extends object = {}> = keyof C extends never ? {
export type InferValue<Members extends unknown[]> = Members extends [] ? [] : Members extends [Match<infer T>, ...infer Rest] ? [T, ...InferValue<Rest>] : never;
export type InferMatch<Members extends unknown[]> = Members extends [] ? [] : Members extends [Match<unknown, infer M>, ...infer Rest] ? [M, ...InferMatch<Rest>] : never;
export type ParsedCapability<Can extends Ability = Ability, Resource extends URI = URI, C extends object = {}> = keyof C extends never ? {
can: Can;

@@ -243,3 +243,3 @@ with: Resource;

};
export declare type InferCaveats<C> = Optionalize<{
export type InferCaveats<C> = Optionalize<{
[K in keyof C]: C[K] extends Reader<infer T, unknown, infer _> ? T : never;

@@ -341,3 +341,3 @@ }>;

*/
export declare type InvalidProof = Expired | NotValidBefore | InvalidSignature | InvalidAudience | DIDKeyResolutionError | UnavailableProof;
export type InvalidProof = Expired | NotValidBefore | InvalidSignature | InvalidAudience | DIDKeyResolutionError | UnavailableProof;
export interface Unauthorized extends Failure {

@@ -344,0 +344,0 @@ name: 'Unauthorized';

@@ -1,3 +0,3 @@

import { Ability, Block as UCANBlock, ByteView, Capabilities, Capability, DID, Fact, Link as UCANLink, MultihashHasher, MultihashDigest, MultibaseDecoder, MultibaseEncoder, Phantom, Resource, Signature, Principal, MulticodecCode, SigAlg } from '@ipld/dag-ucan';
import { Link, Block as IPLDBlock } from 'multiformats';
import { Ability, Block as UCANBlock, ByteView, Capabilities, Capability, DID, Fact, Link as UCANLink, MultihashHasher, MultihashDigest, MultibaseDecoder, MultibaseEncoder, Phantom, Resource, Signature, Principal, MulticodecCode, SigAlg, ToJSON, SignatureJSON, JSONUnknown, JSONObject } from '@ipld/dag-ucan';
import { Link, UnknownLink, Block as IPLDBlock, ToString } from 'multiformats';
import * as UCAN from '@ipld/dag-ucan';

@@ -9,3 +9,3 @@ import { CanIssue, Match, InvalidAudience, Unauthorized, UnavailableProof, DIDKeyResolutionError, ParsedCapability, CapabilityParser } from './capability.js';

export * from './transport.js';
export type { Transport, Phantom, Tuple, DID, Signature, ByteView, Capabilities, Capability, Fact, UCANBlock, UCANLink, Link, Link as IPLDLink, IPLDBlock, Block, Ability, Resource, SigAlg, MultihashDigest, MultihashHasher, MultibaseDecoder, MultibaseEncoder, MulticodecCode, Principal, };
export type { Transport, Phantom, Tuple, DID, Signature, ByteView, Capabilities, Capability, Fact, UCANBlock, UCANLink, Link, Link as IPLDLink, IPLDBlock, Block, Ability, Resource, SigAlg, MultihashDigest, MultihashHasher, MultibaseDecoder, MultibaseEncoder, MulticodecCode, Principal, ToJSON, ToString, UnknownLink, JSONUnknown, };
export * as UCAN from '@ipld/dag-ucan';

@@ -16,3 +16,3 @@ /**

*/
export declare type Proof<C extends Capabilities = Capabilities> = UCANLink<C> | Delegation<C>;
export type Proof<C extends Capabilities = Capabilities> = UCANLink<C> | Delegation<C>;
/**

@@ -88,3 +88,3 @@ * UCAN creation options that apply to all UCAN types.

capabilities: C;
expiration?: UCAN.UTCUnixTimestamp;
expiration: UCAN.UTCUnixTimestamp;
notBefore?: UCAN.UTCUnixTimestamp;

@@ -95,3 +95,27 @@ nonce?: UCAN.Nonce;

iterate(): IterableIterator<Delegation>;
signature: Signature;
version: UCAN.Version;
toJSON(): DelegationJSON<this>;
}
export type DelegationJSON<T extends Delegation = Delegation> = ToJSON<T, {
'/': ToString<T['cid']>;
v: T['version'];
iss: DID;
aud: DID;
att: ToJSON<T['capabilities'], T['capabilities'] & UCAN.Tuple<{
with: UCAN.Resource;
can: UCAN.Ability;
nb?: JSONObject;
}>>;
exp: T['expiration'];
nbf?: T['notBefore'] & {};
nnc?: T['nonce'] & {};
fct: ToJSON<T['facts']>;
prf: ProofJSON[] & JSONUnknown[];
s: SignatureJSON<T['signature']>;
}>;
export type ProofJSON = DelegationJSON | LinkJSON<UCANLink>;
export type LinkJSON<T extends UnknownLink = UnknownLink> = ToJSON<T, {
'/': ToString<T>;
}>;
/**

@@ -125,5 +149,5 @@ * An Invocation represents a UCAN that can be presented to a service provider to

}
export declare type ServiceInvocation<C extends Capability = Capability, S = InvocationService<C>> = IssuedInvocation<C> & ServiceInvocations<S>;
export declare type InferInvocation<T extends ServiceInvocation> = T extends ServiceInvocation<infer C> ? Invocation<C> : never;
export declare type InferInvocations<T> = T extends [] ? [] : T extends [ServiceInvocation<infer C>, ...infer Rest] ? [Invocation<C>, ...InferInvocations<Rest>] : T extends Array<IssuedInvocation<infer U>> ? Invocation<U>[] : never;
export type ServiceInvocation<C extends Capability = Capability, S = InvocationService<C>> = IssuedInvocation<C> & ServiceInvocations<S>;
export type InferInvocation<T extends ServiceInvocation> = T extends ServiceInvocation<infer C> ? Invocation<C> : never;
export type InferInvocations<T> = T extends [] ? [] : T extends [ServiceInvocation<infer C>, ...infer Rest] ? [Invocation<C>, ...InferInvocations<Rest>] : T extends Array<IssuedInvocation<infer U>> ? Invocation<U>[] : never;
/**

@@ -145,3 +169,3 @@ * An invocation handler, as returned by {@link @ucanto/server#provide | `Server.provide` }.

*/
export declare type InvocationError = HandlerNotFound | HandlerExecutionError | InvalidAudience | Unauthorized;
export type InvocationError = HandlerNotFound | HandlerExecutionError | InvalidAudience | Unauthorized;
export interface InvocationContext extends CanIssue {

@@ -153,6 +177,6 @@ id: Verifier;

}
export declare type ResolveServiceMethod<S extends Record<string, any>, Path extends string> = Path extends `${infer Base}/${infer SubPath}` ? ResolveServiceMethod<S[Base], SubPath> : S[Path] extends ServiceMethod<infer _C, infer _T, infer _X> ? S[Path] : never;
export declare type ResolveServiceInvocation<S extends Record<string, any>, C extends Capability> = ResolveServiceMethod<S, C['can']> extends ServiceMethod<infer C, infer _T, infer _X> ? IssuedInvocation<C> : never;
export declare type InferServiceInvocationReturn<C extends Capability, S extends Record<string, any>> = ResolveServiceMethod<S, C['can']> extends ServiceMethod<infer _, infer T, infer X> ? Result<T, X | HandlerNotFound | HandlerExecutionError | InvalidAudience | Unauthorized> : never;
export declare type InferServiceInvocations<I extends unknown[], T extends Record<string, any>> = I extends [] ? [] : I extends [ServiceInvocation<infer C, T>, ...infer Rest] ? [InferServiceInvocationReturn<C, T>, ...InferServiceInvocations<Rest, T>] : never;
export type ResolveServiceMethod<S extends Record<string, any>, Path extends string> = Path extends `${infer Base}/${infer SubPath}` ? ResolveServiceMethod<S[Base], SubPath> : S[Path] extends ServiceMethod<infer _C, infer _T, infer _X> ? S[Path] : never;
export type ResolveServiceInvocation<S extends Record<string, any>, C extends Capability> = ResolveServiceMethod<S, C['can']> extends ServiceMethod<infer C, infer _T, infer _X> ? IssuedInvocation<C> : never;
export type InferServiceInvocationReturn<C extends Capability, S extends Record<string, any>> = ResolveServiceMethod<S, C['can']> extends ServiceMethod<infer _, infer T, infer X> ? Result<T, X | HandlerNotFound | HandlerExecutionError | InvalidAudience | Unauthorized> : never;
export type InferServiceInvocations<I extends unknown[], T extends Record<string, any>> = I extends [] ? [] : I extends [ServiceInvocation<infer C, T>, ...infer Rest] ? [InferServiceInvocationReturn<C, T>, ...InferServiceInvocations<Rest, T>] : never;
export interface IssuedInvocationView<C extends Capability = Capability> extends IssuedInvocation<C> {

@@ -162,9 +186,9 @@ delegate(): Promise<Delegation<[C]>>;

}
export declare type ServiceInvocations<T> = IssuedInvocation<any> & {
export type ServiceInvocations<T> = IssuedInvocation<any> & {
[Key in keyof T]: SubServiceInvocations<T[Key], Key & string>;
}[keyof T];
declare type SubServiceInvocations<T, Path extends string> = {
type SubServiceInvocations<T, Path extends string> = {
[Key in keyof T]: T[Key] extends ServiceMethod<infer C, infer _R, infer _X> ? IssuedInvocation<C> : SubServiceInvocations<Path, Key & string>;
}[keyof T];
export declare type InvocationService<C extends Capability, A extends string = C['can']> = A extends `${infer Base}/${infer Path}` ? {
export type InvocationService<C extends Capability, A extends string = C['can']> = A extends `${infer Base}/${infer Path}` ? {
[Key in Base]: InvocationService<C, Path>;

@@ -174,4 +198,4 @@ } : {

};
export declare type ExecuteInvocation<C extends Capability, T extends Record<string, any>, Ability extends string = C['can']> = Ability extends `${infer Base}/${infer Path}` ? ExecuteInvocation<C, T[Base], Path> : T[Ability] extends (input: Invocation<C>) => infer Out ? Out : never;
export declare type Result<T extends unknown, X extends {
export type ExecuteInvocation<C extends Capability, T extends Record<string, any>, Ability extends string = C['can']> = Ability extends `${infer Base}/${infer Path}` ? ExecuteInvocation<C, T[Base], Path> : T[Ability] extends (input: Invocation<C>) => infer Out ? Out : never;
export type Result<T extends unknown, X extends {
error: true;

@@ -194,3 +218,3 @@ }> = (T extends null | undefined ? T : never) | (T & {

}
export declare type API<T> = T[keyof T];
export type API<T> = T[keyof T];
export interface OutboundTransportOptions {

@@ -282,11 +306,11 @@ readonly encoder: Transport.RequestEncoder;

*/
export declare type Service = Record<string, (input: Invocation<any>) => Promise<Result<any, any>>>;
export type Service = Record<string, (input: Invocation<any>) => Promise<Result<any, any>>>;
/**
* Something that can be `await`ed to get a value of type `T`.
*/
export declare type Await<T> = T | PromiseLike<T> | Promise<T>;
export type Await<T> = T | PromiseLike<T> | Promise<T>;
/**
* A string literal type that matches the "scheme" portion of a URI.
*/
export declare type Protocol<Scheme extends string = string> = `${Scheme}:`;
export type Protocol<Scheme extends string = string> = `${Scheme}:`;
/**

@@ -297,3 +321,3 @@ * A typed string representing a URI of a given protocol.

*/
export declare type URI<P extends Protocol = Protocol> = `${P}${string}` & Phantom<{
export type URI<P extends Protocol = Protocol> = `${P}${string}` & Phantom<{
protocol: P;

@@ -436,3 +460,3 @@ }>;

*/
export declare type DIDKey = DID<'key'>;
export type DIDKey = DID<'key'>;
/**

@@ -479,5 +503,5 @@ * {@link Signer} corresponding to [`did:key`] identified principal.

*/
export declare type KeyArchive<Alg extends SigAlg = SigAlg> = CryptoKey | ByteView<SignerKey<Alg> & CryptoKey>;
export declare type InferInvokedCapability<C extends CapabilityParser<Match<ParsedCapability>>> = C extends CapabilityParser<Match<infer T>> ? T : never;
export declare type Intersection<T> = (T extends any ? (i: T) => void : never) extends (i: infer I) => void ? I : never;
export type KeyArchive<Alg extends SigAlg = SigAlg> = CryptoKey | ByteView<SignerKey<Alg> & CryptoKey>;
export type InferInvokedCapability<C extends CapabilityParser<Match<ParsedCapability>>> = C extends CapabilityParser<Match<infer T>> ? T : never;
export type Intersection<T> = (T extends any ? (i: T) => void : never) extends (i: infer I) => void ? I : never;
//# sourceMappingURL=lib.d.ts.map
import type { InvocationOptions, IssuedInvocationView, Invocation, Proof, UCAN, Result, Connection, Failure } from './lib.js';
export declare type QueryInput = {
export type QueryInput = {
[K in string]: Select | QueryInput;

@@ -9,3 +9,3 @@ };

}
export declare type InstructionHandler<Ability extends UCAN.Ability = UCAN.Ability, In extends Input = Input, T = unknown, X extends Failure = Failure> = (instruction: Invocation<In & {
export type InstructionHandler<Ability extends UCAN.Ability = UCAN.Ability, In extends Input = Input, T = unknown, X extends Failure = Failure> = (instruction: Invocation<In & {
can: Ability;

@@ -17,3 +17,3 @@ }>) => Result<T, X>;

}
export declare type Selector = true | {
export type Selector = true | {
[K in string]: Selector;

@@ -26,17 +26,17 @@ };

}
declare type ExecuteQuery<In extends QueryInput, Service extends QueryService<In>> = {
type ExecuteQuery<In extends QueryInput, Service extends QueryService<In>> = {
[Key in keyof In & keyof Service & string]: ExecuteSubQuery<Key, In[Key], Service[Key]>;
};
declare type ExecuteSubQuery<Path extends string, In, Service> = {
type ExecuteSubQuery<Path extends string, In, Service> = {
[Key in keyof In & keyof Service & string]: In[Key] extends Select<infer Input, infer Selector> ? Service[Key] extends InstructionHandler<`${Path}/${Key}`, Input, infer T, infer X> ? ExecuteSelect<Selector, T, X> : never : ExecuteSubQuery<`${Path}/${Key}`, In[Key], Service[Key]>;
};
declare type ExecuteSelect<S extends Selector, T, X extends Failure> = S extends true ? Result<T, X> : Result<ExecuteSubSelect<S, T>, X>;
declare type ExecuteSubSelect<Selector, T> = T extends infer E | infer U ? Pick<E, keyof Selector & keyof E> | Pick<U, keyof Selector & keyof U> : Pick<T, keyof Selector & keyof T>;
declare type QueryService<In extends QueryInput> = {
type ExecuteSelect<S extends Selector, T, X extends Failure> = S extends true ? Result<T, X> : Result<ExecuteSubSelect<S, T>, X>;
type ExecuteSubSelect<Selector, T> = T extends infer E | infer U ? Pick<E, keyof Selector & keyof E> | Pick<U, keyof Selector & keyof U> : Pick<T, keyof Selector & keyof T>;
type QueryService<In extends QueryInput> = {
[Key in keyof In & string]: SubService<Key, In[Key]>;
};
declare type SubService<Path extends string, In> = {
type SubService<Path extends string, In> = {
[Key in keyof In & string]: In[Key] extends Select<infer In, infer Selector> ? InstructionHandler<`${Path}/${Key}`, In, Matches<Selector>> : SubService<`${Path}/${Key}`, In[Key]>;
};
export declare type Matches<S extends Selector> = S extends true ? unknown : {
export type Matches<S extends Selector> = S extends true ? unknown : {
[Key in keyof S]: S[Key] extends Selector ? Matches<S[Key]> : unknown;

@@ -43,0 +43,0 @@ };

@@ -10,3 +10,3 @@ import type { Block as IPLDBlock, Version as LinkVersion } from 'multiformats';

*/
export declare type Tuple<T = unknown> = [T, ...T[]];
export type Tuple<T = unknown> = [T, ...T[]];
export interface EncodeOptions {

@@ -13,0 +13,0 @@ readonly hasher?: UCAN.MultihashHasher;

{
"name": "@ucanto/interface",
"description": "interface definitions for ucanto",
"version": "4.0.3",
"version": "4.1.0",
"types": "./dist/src/lib.d.ts",

@@ -22,7 +22,7 @@ "main": "./src/lib.js",

"dependencies": {
"@ipld/dag-ucan": "^3.0.1",
"multiformats": "^10.0.2"
"@ipld/dag-ucan": "^3.2.0",
"multiformats": "^11.0.0"
},
"devDependencies": {
"typescript": "^4.8.4"
"typescript": "^4.9.4"
},

@@ -29,0 +29,0 @@ "exports": {

@@ -20,4 +20,9 @@ import {

SigAlg,
ToJSON,
SignatureJSON,
JSONUnknown,
IntoJSON,
JSONObject,
} from '@ipld/dag-ucan'
import { Link, Block as IPLDBlock } from 'multiformats'
import { Link, UnknownLink, Block as IPLDBlock, ToString } from 'multiformats'
import * as UCAN from '@ipld/dag-ucan'

@@ -63,2 +68,6 @@ import {

Principal,
ToJSON,
ToString,
UnknownLink,
JSONUnknown,
}

@@ -156,3 +165,3 @@ export * as UCAN from '@ipld/dag-ucan'

capabilities: C
expiration?: UCAN.UTCUnixTimestamp
expiration: UCAN.UTCUnixTimestamp
notBefore?: UCAN.UTCUnixTimestamp

@@ -165,4 +174,37 @@

iterate(): IterableIterator<Delegation>
signature: Signature
version: UCAN.Version
toJSON(): DelegationJSON<this>
}
export type DelegationJSON<T extends Delegation = Delegation> = ToJSON<
T,
{
'/': ToString<T['cid']>
v: T['version']
iss: DID
aud: DID
att: ToJSON<
T['capabilities'],
T['capabilities'] &
UCAN.Tuple<{ with: UCAN.Resource; can: UCAN.Ability; nb?: JSONObject }>
>
exp: T['expiration']
nbf?: T['notBefore'] & {}
nnc?: T['nonce'] & {}
fct: ToJSON<T['facts']>
prf: ProofJSON[] & JSONUnknown[]
s: SignatureJSON<T['signature']>
}
>
export type ProofJSON = DelegationJSON | LinkJSON<UCANLink>
export type LinkJSON<T extends UnknownLink = UnknownLink> = ToJSON<
T,
{ '/': ToString<T> }
>
/**

@@ -169,0 +211,0 @@ * An Invocation represents a UCAN that can be presented to a service provider to

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

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