@ucanto/interface
Advanced tools
Comparing version 0.7.0 to 1.0.0
@@ -1,2 +0,4 @@ | ||
import { Delegation, Result, Failure, AuthorityParser, Identity, Resource, Ability, URI, Capability, DID, LinkedProof, Await, SigningAuthority, IssuedInvocationView, UCANOptions } from './lib.js'; | ||
import { Ability, Capability, DID, Link, Resource } from '@ipld/dag-ucan'; | ||
import * as UCAN from '@ipld/dag-ucan'; | ||
import { Delegation, Result, Failure, PrincipalParser, SigningPrincipal, URI, Await, IssuedInvocationView, UCANOptions } from './lib.js'; | ||
export interface Source { | ||
@@ -112,4 +114,4 @@ capability: Capability; | ||
}; | ||
export declare type InvokeCapabilityOptions<R extends Resource, C> = UCANOptions & InferCreateOptions<R, C> & { | ||
issuer: SigningAuthority; | ||
export declare type InvokeCapabilityOptions<R extends Resource, C extends {}> = UCANOptions & InferCreateOptions<R, C> & { | ||
issuer: SigningPrincipal; | ||
}; | ||
@@ -210,4 +212,4 @@ export interface CapabilityParser<M extends Match = Match> extends View<M> { | ||
} | ||
export interface AuthorityOptions { | ||
authority: AuthorityParser; | ||
export interface PrincipalOptions { | ||
principal: PrincipalParser; | ||
} | ||
@@ -222,3 +224,3 @@ export interface IssuingOptions { | ||
} | ||
export interface ProofResolver extends AuthorityOptions, IssuingOptions { | ||
export interface ProofResolver extends PrincipalOptions, IssuingOptions { | ||
/** | ||
@@ -229,5 +231,5 @@ * You can provide a proof resolver that validator will call when UCAN | ||
*/ | ||
resolve?: (proof: LinkedProof) => Await<Result<Delegation, UnavailableProof>>; | ||
resolve?: (proof: Link) => Await<Result<Delegation, UnavailableProof>>; | ||
} | ||
export interface ValidationOptions<C extends ParsedCapability> extends CanIssue, IssuingOptions, AuthorityOptions, ProofResolver { | ||
export interface ValidationOptions<C extends ParsedCapability> extends CanIssue, IssuingOptions, PrincipalOptions, ProofResolver { | ||
capability: CapabilityParser<Match<C, any>>; | ||
@@ -256,3 +258,3 @@ } | ||
readonly name: 'InvalidAudience'; | ||
readonly audience: Identity; | ||
readonly audience: UCAN.Principal; | ||
readonly delegation: Delegation; | ||
@@ -262,3 +264,3 @@ } | ||
readonly name: 'UnavailableProof'; | ||
readonly link: LinkedProof; | ||
readonly link: Link; | ||
} | ||
@@ -277,4 +279,4 @@ export interface Expired extends Failure { | ||
readonly name: 'InvalidSignature'; | ||
readonly issuer: Identity; | ||
readonly audience: Identity; | ||
readonly issuer: UCAN.Principal; | ||
readonly audience: UCAN.Principal; | ||
readonly delegation: Delegation; | ||
@@ -291,3 +293,3 @@ } | ||
export interface InvalidClaim extends Failure { | ||
issuer: Identity; | ||
issuer: UCAN.Principal; | ||
name: 'InvalidClaim'; | ||
@@ -294,0 +296,0 @@ capability: ParsedCapability; |
@@ -0,26 +1,20 @@ | ||
import { Ability, Block as UCANBlock, ByteView, Capabilities, Capability, DID, Fact, Link as UCANLink, IPLDLink as Link, MultihashHasher, MultihashDigest, Phantom, Resource, Signature } from '@ipld/dag-ucan'; | ||
import * as UCAN from '@ipld/dag-ucan'; | ||
import type { Principal, PrincipalParser, SigningPrincipal } from './principal.js'; | ||
import { CanIssue, InvalidAudience, Unauthorized, UnavailableProof } from './capability.js'; | ||
import type * as Transport from './transport.js'; | ||
import type { Tuple } from './transport.js'; | ||
import type { Tuple, Block } from './transport.js'; | ||
export type { MultibaseDecoder, MultibaseEncoder, } from 'multiformats/bases/interface'; | ||
export * from './principal.js'; | ||
export * from './capability.js'; | ||
export * from './transport.js'; | ||
export type { Transport, Principal, PrincipalParser, SigningPrincipal, Phantom, Tuple, DID, Signature, ByteView, Capabilities, Capability, Fact, UCANBlock, UCANLink, Link, Block, Ability, Resource, MultihashDigest, MultihashHasher, }; | ||
export * as UCAN from '@ipld/dag-ucan'; | ||
import type { Authority, SigningAuthority, AuthorityParser } from './authority.js'; | ||
import type { Phantom, Encoded, Link, Issuer, Identity, Audience, MultihashHasher, MultihashDigest, ByteView, Ability, Resource, DID, Fact, Proof as LinkedProof, View as UCANView, UCAN as UCANData, Capability } from '@ipld/dag-ucan'; | ||
export type { MultibaseEncoder, MultibaseDecoder, } from 'multiformats/bases/interface'; | ||
export type { MultihashDigest, MultihashHasher, Transport, Encoded, Link, Issuer, Audience, Authority, SigningAuthority, Identity, ByteView, Phantom, Ability, Resource, DID, Fact, Tuple, LinkedProof, Capability, }; | ||
import { InvalidAudience, Unauthorized, CanIssue, UnavailableProof } from './capability.js'; | ||
export * from './transport.js'; | ||
export * from './authority.js'; | ||
export * from './capability.js'; | ||
/** | ||
* Represents an {@link Ability} that a UCAN holder `Can` perform `With` some {@link Resource}. | ||
* | ||
* @template Can - the {@link Ability} (action/verb) the UCAN holder can perform | ||
* @template With - the {@link Resource} (thing/noun) the UCAN holder can perform their `Ability` on / with | ||
* | ||
*/ | ||
/** | ||
* Proof can either be a link to a delegated UCAN or a materialized `Delegation` | ||
* view. | ||
*/ | ||
export declare type Proof<C extends [Capability, ...Capability[]] = [Capability, ...Capability[]]> = LinkedProof<C[number]> | Delegation<C>; | ||
export declare type Proof<C extends Capabilities = Capabilities> = UCANLink<C> | Delegation<C>; | ||
export interface UCANOptions { | ||
audience: Identity; | ||
audience: Principal; | ||
lifetimeInSeconds?: number; | ||
@@ -33,17 +27,30 @@ expiration?: number; | ||
} | ||
export interface DelegationOptions<C extends [Capability, ...Capability[]], A extends number = number> extends UCANOptions { | ||
issuer: SigningAuthority<A>; | ||
audience: Identity; | ||
export interface DelegationOptions<C extends Capabilities, A extends number = number> extends UCANOptions { | ||
issuer: SigningPrincipal<A>; | ||
audience: Principal; | ||
capabilities: C; | ||
proofs?: Proof[]; | ||
} | ||
export interface Delegation<C extends [Capability, ...Capability[]] = [Capability, ...Capability[]]> { | ||
readonly root: Transport.Block<C>; | ||
readonly blocks: Map<string, Transport.Block>; | ||
readonly cid: LinkedProof<C[number]>; | ||
readonly bytes: ByteView<UCANData<C[number]>>; | ||
readonly data: UCANView<C[number]>; | ||
asCID: LinkedProof<Capability>; | ||
export(): IterableIterator<Transport.Block>; | ||
issuer: Identity; | ||
audience: Identity; | ||
export interface Delegation<C extends Capabilities = Capabilities> { | ||
readonly root: UCANBlock<C>; | ||
/** | ||
* Map of all the IPLD blocks that where included with this delegation DAG. | ||
* Usually this would be blocks corresponding to proofs, however it may | ||
* also contain other blocks e.g. things that `capabilities` or `facts` may | ||
* link. | ||
* It is not guaranteed to include all the blocks of this DAG, as it represents | ||
* a partial DAG of the delegation desired for transporting. | ||
* | ||
* Also note that map may contain blocks that are not part of this | ||
* delegation DAG. That is because `Delegation` is usually constructed as | ||
* view / selection over the CAR which may contain bunch of other blocks. | ||
*/ | ||
readonly blocks: Map<string, Block>; | ||
readonly cid: UCANLink<C>; | ||
readonly bytes: ByteView<UCAN.UCAN<C>>; | ||
readonly data: UCAN.View<C>; | ||
asCID: UCANLink<C>; | ||
export(): IterableIterator<Block>; | ||
issuer: UCAN.Principal; | ||
audience: UCAN.Principal; | ||
capabilities: C; | ||
@@ -60,8 +67,8 @@ expiration?: number; | ||
export interface InvocationOptions<C extends Capability = Capability> extends UCANOptions { | ||
issuer: SigningAuthority; | ||
issuer: SigningPrincipal; | ||
capability: C; | ||
} | ||
export interface IssuedInvocation<C extends Capability = Capability> extends DelegationOptions<[C]> { | ||
readonly issuer: SigningAuthority; | ||
readonly audience: Identity; | ||
readonly issuer: SigningPrincipal; | ||
readonly audience: Principal; | ||
readonly capabilities: [C]; | ||
@@ -80,11 +87,11 @@ readonly proofs: Proof[]; | ||
export interface InvocationContext extends CanIssue { | ||
id: Identity; | ||
id: Principal; | ||
my?: (issuer: DID) => Capability[]; | ||
resolve?: (proof: LinkedProof) => Await<Result<Delegation, UnavailableProof>>; | ||
authority: AuthorityParser; | ||
resolve?: (proof: UCANLink) => Await<Result<Delegation, UnavailableProof>>; | ||
principal: PrincipalParser; | ||
} | ||
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> = 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> = I extends [] ? [] : I extends [ServiceInvocation<infer C, T>, ...infer Rest] ? [InferServiceInvocationReturn<C, T>, ...InferServiceInvocations<Rest, T>] : 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 interface IssuedInvocationView<C extends Capability = Capability> extends IssuedInvocation<C> { | ||
@@ -129,12 +136,12 @@ delegate(): Promise<Delegation<[C]>>; | ||
} | ||
export interface ConnectionOptions<T> extends Transport.EncodeOptions, OutpboundTranpsortOptions { | ||
readonly id: Identity; | ||
export interface ConnectionOptions<T extends Record<string, any>> extends Transport.EncodeOptions, OutpboundTranpsortOptions { | ||
readonly id: Principal; | ||
readonly channel: Transport.Channel<T>; | ||
} | ||
export interface Connection<T> extends Phantom<T>, ConnectionOptions<T> { | ||
readonly id: Identity; | ||
export interface Connection<T extends Record<string, any>> extends Phantom<T>, ConnectionOptions<T> { | ||
readonly id: Principal; | ||
readonly hasher: MultihashHasher; | ||
} | ||
export interface ConnectionView<T> extends Connection<T> { | ||
id: Identity; | ||
export interface ConnectionView<T extends Record<string, any>> extends Connection<T> { | ||
id: Principal; | ||
execute<C extends Capability, I extends Transport.Tuple<ServiceInvocation<C, T>>>(...invocations: I): Await<InferServiceInvocations<I, T>>; | ||
@@ -157,6 +164,6 @@ } | ||
/** | ||
* Takes authority parser that can be used to turn an `UCAN.Identity` | ||
* into `Ucanto.Authority`. | ||
* Takes principal parser that can be used to turn a `UCAN.Principal` | ||
* into `Ucanto.Principal`. | ||
*/ | ||
readonly authority?: AuthorityParser; | ||
readonly principal?: PrincipalParser; | ||
readonly canIssue?: CanIssue['canIssue']; | ||
@@ -171,3 +178,3 @@ readonly my?: InvocationContext['my']; | ||
*/ | ||
readonly id: Identity; | ||
readonly id: Principal; | ||
} | ||
@@ -181,3 +188,3 @@ export interface Server<T> extends ServerOptions { | ||
} | ||
export interface ServerView<T> extends Server<T>, Transport.Channel<T> { | ||
export interface ServerView<T extends Record<string, any>> extends Server<T>, Transport.Channel<T> { | ||
context: InvocationContext; | ||
@@ -184,0 +191,0 @@ catch: (err: HandlerExecutionError) => void; |
@@ -42,3 +42,3 @@ import type { InvocationOptions, IssuedInvocationView, Invocation, Proof, UCAN, Result, Connection, Failure } from './lib.js'; | ||
export declare function invoke<Capability extends UCAN.Capability>(input: InvocationOptions<Capability>): IssuedInvocationView<Capability>; | ||
export declare function connection<T>(): Connection<T>; | ||
export declare function connection<T extends Record<string, any>>(): Connection<T>; | ||
export declare function query<In extends QueryInput>(query: In): Query<In>; | ||
@@ -45,0 +45,0 @@ export declare function select<In extends Input, S extends Selector = true>(input: In, selector?: S): S extends true ? Select<In, true> : Select<In, S>; |
@@ -1,4 +0,4 @@ | ||
import type { Phantom, Await } from '@ipld/dag-ucan'; | ||
import type { ByteView, Phantom, Await, IPLDLink as Link } from '@ipld/dag-ucan'; | ||
import * as UCAN from '@ipld/dag-ucan'; | ||
import type { ServiceInvocation, InferServiceInvocations, InferInvocations, Capability } from './lib.js'; | ||
import type { ServiceInvocation, InferServiceInvocations, InferInvocations } from './lib.js'; | ||
/** | ||
@@ -13,3 +13,3 @@ * This utility type can be used in place of `T[]` where you | ||
} | ||
export interface Channel<T> extends Phantom<T> { | ||
export interface Channel<T extends Record<string, any>> extends Phantom<T> { | ||
request<I extends Tuple<ServiceInvocation<UCAN.Capability, T>>>(request: HTTPRequest<I>): Await<HTTPResponse<InferServiceInvocations<I, T>>>; | ||
@@ -38,6 +38,7 @@ } | ||
} | ||
export interface Block<C extends [Capability, ...Capability[]] = [Capability, ...Capability[]], A extends number = number> { | ||
readonly cid: UCAN.Proof<C[number], A>; | ||
readonly bytes: UCAN.ByteView<UCAN.UCAN<C[number]>>; | ||
export interface Block<T extends unknown = unknown, Format extends number = number, Alg extends number = number, V extends UCAN.CIDVersion = 1> { | ||
bytes: ByteView<T>; | ||
cid: Link<T, Format, Alg, V>; | ||
data?: T; | ||
} | ||
//# sourceMappingURL=transport.d.ts.map |
{ | ||
"name": "@ucanto/interface", | ||
"description": "interface definitions for ucanto", | ||
"version": "0.7.0", | ||
"version": "1.0.0", | ||
"types": "./dist/src/lib.d.ts", | ||
@@ -21,8 +21,12 @@ "main": "./src/lib.js", | ||
"homepage": "https://github.com/web3-storage/ucanto", | ||
"scripts": { | ||
"typecheck": "tsc --build", | ||
"build": "tsc --build" | ||
}, | ||
"dependencies": { | ||
"@ipld/dag-ucan": "^1.7.0-beta", | ||
"multiformats": "^9.6.4" | ||
"@ipld/dag-ucan": "3.0.0-beta", | ||
"multiformats": "^9.8.1" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.7.4" | ||
"typescript": "^4.8.3" | ||
}, | ||
@@ -36,7 +40,3 @@ "exports": { | ||
"type": "module", | ||
"license": "(Apache-2.0 AND MIT)", | ||
"scripts": { | ||
"typecheck": "tsc --build", | ||
"build": "tsc --build" | ||
} | ||
} | ||
"license": "(Apache-2.0 AND MIT)" | ||
} |
@@ -0,1 +1,3 @@ | ||
import { Ability, Capability, DID, Link, Resource } from '@ipld/dag-ucan' | ||
import * as UCAN from '@ipld/dag-ucan' | ||
import { | ||
@@ -5,15 +7,7 @@ Delegation, | ||
Failure, | ||
AuthorityParser, | ||
Identity, | ||
Resource, | ||
Ability, | ||
PrincipalParser, | ||
SigningPrincipal, | ||
URI, | ||
Capability, | ||
DID, | ||
LinkedProof, | ||
Await, | ||
Proof, | ||
SigningAuthority, | ||
IssuedInvocationView, | ||
Fact, | ||
UCANOptions, | ||
@@ -172,5 +166,8 @@ } from './lib.js' | ||
export type InvokeCapabilityOptions<R extends Resource, C> = UCANOptions & | ||
export type InvokeCapabilityOptions< | ||
R extends Resource, | ||
C extends {} | ||
> = UCANOptions & | ||
InferCreateOptions<R, C> & { | ||
issuer: SigningAuthority | ||
issuer: SigningPrincipal | ||
} | ||
@@ -312,4 +309,4 @@ | ||
export interface AuthorityOptions { | ||
authority: AuthorityParser | ||
export interface PrincipalOptions { | ||
principal: PrincipalParser | ||
} | ||
@@ -327,3 +324,3 @@ | ||
export interface ProofResolver extends AuthorityOptions, IssuingOptions { | ||
export interface ProofResolver extends PrincipalOptions, IssuingOptions { | ||
/** | ||
@@ -334,3 +331,3 @@ * You can provide a proof resolver that validator will call when UCAN | ||
*/ | ||
resolve?: (proof: LinkedProof) => Await<Result<Delegation, UnavailableProof>> | ||
resolve?: (proof: Link) => Await<Result<Delegation, UnavailableProof>> | ||
} | ||
@@ -341,3 +338,3 @@ | ||
IssuingOptions, | ||
AuthorityOptions, | ||
PrincipalOptions, | ||
ProofResolver { | ||
@@ -373,3 +370,3 @@ capability: CapabilityParser<Match<C, any>> | ||
readonly name: 'InvalidAudience' | ||
readonly audience: Identity | ||
readonly audience: UCAN.Principal | ||
readonly delegation: Delegation | ||
@@ -380,3 +377,3 @@ } | ||
readonly name: 'UnavailableProof' | ||
readonly link: LinkedProof | ||
readonly link: Link | ||
} | ||
@@ -398,4 +395,4 @@ | ||
readonly name: 'InvalidSignature' | ||
readonly issuer: Identity | ||
readonly audience: Identity | ||
readonly issuer: UCAN.Principal | ||
readonly audience: UCAN.Principal | ||
readonly delegation: Delegation | ||
@@ -419,3 +416,3 @@ } | ||
export interface InvalidClaim extends Failure { | ||
issuer: Identity | ||
issuer: UCAN.Principal | ||
name: 'InvalidClaim' | ||
@@ -422,0 +419,0 @@ capability: ParsedCapability |
203
src/lib.ts
@@ -1,87 +0,73 @@ | ||
import type * as Transport from './transport.js' | ||
import type { Tuple } from './transport.js' | ||
export * as UCAN from '@ipld/dag-ucan' | ||
import type { | ||
Authority, | ||
SigningAuthority, | ||
AuthorityParser, | ||
} from './authority.js' | ||
import type { | ||
Phantom, | ||
Encoded, | ||
Link, | ||
Issuer, | ||
Identity, | ||
Audience, | ||
import { | ||
Ability, | ||
Block as UCANBlock, | ||
ByteView, | ||
Capabilities, | ||
Capability, | ||
DID, | ||
Fact, | ||
Link as UCANLink, | ||
IPLDLink as Link, | ||
MultihashHasher, | ||
MultihashDigest, | ||
ByteView, | ||
Ability, | ||
Phantom, | ||
Resource, | ||
DID, | ||
Fact, | ||
Proof as LinkedProof, | ||
View as UCANView, | ||
UCAN as UCANData, | ||
Capability, | ||
Signature, | ||
} from '@ipld/dag-ucan' | ||
import * as UCAN from '@ipld/dag-ucan' | ||
import type { | ||
Principal, | ||
PrincipalParser, | ||
SigningPrincipal, | ||
} from './principal.js' | ||
import { | ||
CanIssue, | ||
InvalidAudience, | ||
Unauthorized, | ||
UnavailableProof, | ||
} from './capability.js' | ||
import type * as Transport from './transport.js' | ||
import type { Tuple, Block } from './transport.js' | ||
export type { | ||
MultibaseDecoder, | ||
MultibaseEncoder, | ||
MultibaseDecoder, | ||
} from 'multiformats/bases/interface' | ||
export * from './principal.js' | ||
export * from './capability.js' | ||
export * from './transport.js' | ||
export type { | ||
MultihashDigest, | ||
MultihashHasher, | ||
Transport, | ||
Encoded, | ||
Principal, | ||
PrincipalParser, | ||
SigningPrincipal, | ||
Phantom, | ||
Tuple, | ||
DID, | ||
Signature, | ||
ByteView, | ||
Capabilities, | ||
Capability, | ||
Fact, | ||
UCANBlock, | ||
UCANLink, | ||
Link, | ||
Issuer, | ||
Audience, | ||
Authority, | ||
SigningAuthority, | ||
Identity, | ||
ByteView, | ||
Phantom, | ||
Block, | ||
Ability, | ||
Resource, | ||
DID, | ||
Fact, | ||
Tuple, | ||
LinkedProof, | ||
Capability, | ||
MultihashDigest, | ||
MultihashHasher, | ||
} | ||
export * as UCAN from '@ipld/dag-ucan' | ||
import { | ||
CapabilityParser, | ||
ParsedCapability, | ||
InvalidAudience, | ||
Unauthorized, | ||
CanIssue, | ||
UnavailableProof, | ||
} from './capability.js' | ||
export * from './transport.js' | ||
export * from './authority.js' | ||
export * from './capability.js' | ||
/** | ||
* Represents an {@link Ability} that a UCAN holder `Can` perform `With` some {@link Resource}. | ||
* | ||
* @template Can - the {@link Ability} (action/verb) the UCAN holder can perform | ||
* @template With - the {@link Resource} (thing/noun) the UCAN holder can perform their `Ability` on / with | ||
* | ||
*/ | ||
/** | ||
* Proof can either be a link to a delegated UCAN or a materialized `Delegation` | ||
* view. | ||
*/ | ||
export type Proof< | ||
C extends [Capability, ...Capability[]] = [Capability, ...Capability[]] | ||
> = LinkedProof<C[number]> | Delegation<C> | ||
export type Proof<C extends Capabilities = Capabilities> = | ||
| UCANLink<C> | ||
| Delegation<C> | ||
export interface UCANOptions { | ||
audience: Identity | ||
audience: Principal | ||
lifetimeInSeconds?: number | ||
@@ -98,26 +84,37 @@ expiration?: number | ||
export interface DelegationOptions< | ||
C extends [Capability, ...Capability[]], | ||
C extends Capabilities, | ||
A extends number = number | ||
> extends UCANOptions { | ||
issuer: SigningAuthority<A> | ||
audience: Identity | ||
issuer: SigningPrincipal<A> | ||
audience: Principal | ||
capabilities: C | ||
proofs?: Proof[] | ||
} | ||
export interface Delegation< | ||
C extends [Capability, ...Capability[]] = [Capability, ...Capability[]] | ||
> { | ||
readonly root: Transport.Block<C> | ||
readonly blocks: Map<string, Transport.Block> | ||
export interface Delegation<C extends Capabilities = Capabilities> { | ||
readonly root: UCANBlock<C> | ||
/** | ||
* Map of all the IPLD blocks that where included with this delegation DAG. | ||
* Usually this would be blocks corresponding to proofs, however it may | ||
* also contain other blocks e.g. things that `capabilities` or `facts` may | ||
* link. | ||
* It is not guaranteed to include all the blocks of this DAG, as it represents | ||
* a partial DAG of the delegation desired for transporting. | ||
* | ||
* Also note that map may contain blocks that are not part of this | ||
* delegation DAG. That is because `Delegation` is usually constructed as | ||
* view / selection over the CAR which may contain bunch of other blocks. | ||
*/ | ||
readonly blocks: Map<string, Block> | ||
readonly cid: LinkedProof<C[number]> | ||
readonly bytes: ByteView<UCANData<C[number]>> | ||
readonly data: UCANView<C[number]> | ||
readonly cid: UCANLink<C> | ||
readonly bytes: ByteView<UCAN.UCAN<C>> | ||
readonly data: UCAN.View<C> | ||
asCID: LinkedProof<Capability> | ||
asCID: UCANLink<C> | ||
export(): IterableIterator<Transport.Block> | ||
export(): IterableIterator<Block> | ||
issuer: Identity | ||
audience: Identity | ||
issuer: UCAN.Principal | ||
audience: UCAN.Principal | ||
capabilities: C | ||
@@ -139,3 +136,3 @@ expiration?: number | ||
extends UCANOptions { | ||
issuer: SigningAuthority | ||
issuer: SigningPrincipal | ||
capability: C | ||
@@ -146,4 +143,4 @@ } | ||
extends DelegationOptions<[C]> { | ||
readonly issuer: SigningAuthority | ||
readonly audience: Identity | ||
readonly issuer: SigningPrincipal | ||
readonly audience: Principal | ||
readonly capabilities: [C] | ||
@@ -187,7 +184,7 @@ | ||
export interface InvocationContext extends CanIssue { | ||
id: Identity | ||
id: Principal | ||
my?: (issuer: DID) => Capability[] | ||
resolve?: (proof: LinkedProof) => Await<Result<Delegation, UnavailableProof>> | ||
resolve?: (proof: UCANLink) => Await<Result<Delegation, UnavailableProof>> | ||
authority: AuthorityParser | ||
principal: PrincipalParser | ||
} | ||
@@ -217,3 +214,3 @@ | ||
C extends Capability, | ||
S | ||
S extends Record<string, any> | ||
> = ResolveServiceMethod<S, C['can']> extends ServiceMethod< | ||
@@ -234,3 +231,6 @@ infer _, | ||
export type InferServiceInvocations<I extends unknown[], T> = I extends [] | ||
export type InferServiceInvocations< | ||
I extends unknown[], | ||
T extends Record<string, any> | ||
> = I extends [] | ||
? [] | ||
@@ -306,16 +306,19 @@ : I extends [ServiceInvocation<infer C, T>, ...infer Rest] | ||
} | ||
export interface ConnectionOptions<T> | ||
export interface ConnectionOptions<T extends Record<string, any>> | ||
extends Transport.EncodeOptions, | ||
OutpboundTranpsortOptions { | ||
readonly id: Identity | ||
readonly id: Principal | ||
readonly channel: Transport.Channel<T> | ||
} | ||
export interface Connection<T> extends Phantom<T>, ConnectionOptions<T> { | ||
readonly id: Identity | ||
export interface Connection<T extends Record<string, any>> | ||
extends Phantom<T>, | ||
ConnectionOptions<T> { | ||
readonly id: Principal | ||
readonly hasher: MultihashHasher | ||
} | ||
export interface ConnectionView<T> extends Connection<T> { | ||
id: Identity | ||
export interface ConnectionView<T extends Record<string, any>> | ||
extends Connection<T> { | ||
id: Principal | ||
execute< | ||
@@ -345,6 +348,6 @@ C extends Capability, | ||
/** | ||
* Takes authority parser that can be used to turn an `UCAN.Identity` | ||
* into `Ucanto.Authority`. | ||
* Takes principal parser that can be used to turn a `UCAN.Principal` | ||
* into `Ucanto.Principal`. | ||
*/ | ||
readonly authority?: AuthorityParser | ||
readonly principal?: PrincipalParser | ||
@@ -363,3 +366,3 @@ readonly canIssue?: CanIssue['canIssue'] | ||
*/ | ||
readonly id: Identity | ||
readonly id: Principal | ||
} | ||
@@ -376,3 +379,5 @@ | ||
export interface ServerView<T> extends Server<T>, Transport.Channel<T> { | ||
export interface ServerView<T extends Record<string, any>> | ||
extends Server<T>, | ||
Transport.Channel<T> { | ||
context: InvocationContext | ||
@@ -379,0 +384,0 @@ catch: (err: HandlerExecutionError) => void |
@@ -12,4 +12,4 @@ import type { | ||
Service, | ||
Authority, | ||
SigningAuthority, | ||
Principal, | ||
SigningPrincipal, | ||
Failure, | ||
@@ -109,3 +109,5 @@ } from './lib.js' | ||
export declare function connection<T>(): Connection<T> | ||
export declare function connection< | ||
T extends Record<string, any> | ||
>(): Connection<T> | ||
@@ -140,4 +142,4 @@ export declare function query<In extends QueryInput>(query: In): Query<In> | ||
declare var channel: ConnectionView<{ store: Store }> | ||
declare const alice: SigningAuthority | ||
declare const bob: Authority | ||
declare const alice: SigningPrincipal | ||
declare const bob: Principal | ||
declare const car: UCAN.Link | ||
@@ -144,0 +146,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { Phantom, Await } from '@ipld/dag-ucan' | ||
import type { ByteView, Phantom, Await, IPLDLink as Link } from '@ipld/dag-ucan' | ||
import * as UCAN from '@ipld/dag-ucan' | ||
@@ -7,3 +7,2 @@ import type { | ||
InferInvocations, | ||
Capability, | ||
} from './lib.js' | ||
@@ -22,3 +21,3 @@ | ||
export interface Channel<T> extends Phantom<T> { | ||
export interface Channel<T extends Record<string, any>> extends Phantom<T> { | ||
request<I extends Tuple<ServiceInvocation<UCAN.Capability, T>>>( | ||
@@ -62,7 +61,11 @@ request: HTTPRequest<I> | ||
export interface Block< | ||
C extends [Capability, ...Capability[]] = [Capability, ...Capability[]], | ||
A extends number = number | ||
T extends unknown = unknown, | ||
Format extends number = number, | ||
Alg extends number = number, | ||
V extends UCAN.CIDVersion = 1 | ||
> { | ||
readonly cid: UCAN.Proof<C[number], A> | ||
readonly bytes: UCAN.ByteView<UCAN.UCAN<C[number]>> | ||
bytes: ByteView<T> | ||
cid: Link<T, Format, Alg, V> | ||
data?: T | ||
} |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
81069
1538
0
1
+ Added@ipld/dag-ucan@3.0.0-beta(transitive)
- Removed@ipld/dag-ucan@1.7.0-beta(transitive)
Updated@ipld/dag-ucan@3.0.0-beta
Updatedmultiformats@^9.8.1