{
  "version": 3,
  "sources": ["../src/types.ts"],
  "sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec'\nimport type { Resolver as _DidResolver } from 'iso-did'\nimport type { DID, DIDURLObject, VerifiableDID } from 'iso-did/types'\nimport type { ISigner } from 'iso-signatures/types'\nimport type { Resolver } from 'iso-signatures/verifiers/resolver.js'\nimport type { CID } from 'multiformats'\nimport type { Capability } from './capability'\nimport type { Delegation } from './delegation'\nimport type { Invocation } from './invocation'\nimport type { Store } from './store'\nimport type { Policy } from './types/policy'\n\nexport type { StandardSchemaV1 } from '@standard-schema/spec'\nexport type { DID, DIDURL, DIDURLObject } from 'iso-did/types'\nexport type { ISigner } from 'iso-signatures/types'\nexport * from './types/envelope'\nexport * from './types/policy'\nexport * from './types/varsig'\n\nexport type ResolveProof = (proof: CID) => Promise<Delegation>\nexport type IsRevoked = (cid: CID) => Promise<boolean>\nexport type VerifierResolver = Resolver\nexport type DidResolver = _DidResolver\n\nexport type CborValue = CborPrimitive | CborArray | CborObject\n\nexport type CborPrimitive =\n  | string\n  | number\n  | boolean\n  | null\n  | bigint\n  | Uint8Array\n  | ArrayBuffer\nexport type CborArray = CborValue[] | readonly CborValue[]\nexport type CborObject =\n  | { [Key in string]: CborValue }\n  | { [Key in string]?: CborValue | undefined }\n\n/**\n * Delegation\n */\n\nexport interface DelegationOptions<Schema extends StandardSchemaV1> {\n  iss:ISigner\n  aud:DID\n  sub:DID | null\n  pol:Policy<StandardSchemaV1.InferOutput<Schema>>\n  /**\n   * Expiration time in seconds or null for no expiration\n   */\n  exp?:number|null\n\n  /**\n   * Time to live in seconds, expiration thats precedence over ttl\n   * @default 300\n   */\n  ttl?:number\n\n  /**\n   * Not before time in seconds\n   * Delegation is not valid before this time\n   */\n  nbf?:number\n  nonce?:Uint8Array\n  cmd:string\n  meta?:CborObject\n}\n\nexport interface DelegationValidateOptions {\n  isRevoked?:IsRevoked\n  didResolver?:DidResolver\n  verifierResolver:VerifierResolver\n}\n\nexport interface DelegationFromOptions extends DelegationValidateOptions {\n  bytes:Uint8Array\n}\n\n/**\n * Invocation\n */\n\n/**\n * Invocation options\n */\nexport interface InvocationOptions extends DelegationValidateOptions {\n  iss:ISigner\n  aud?:DID\n  sub:DID\n  cmd:string\n  args:CborObject\n  /**\n   * Proofs of the chain of authority\n   */\n  prf:Delegation[]\n  /**\n   * Expiration time in seconds or null for no expiration\n   */\n  exp?:number | null\n  /**\n   * Time to live in seconds, expiration thats precedence over ttl\n   * @default 300\n   */\n  ttl?:number\n  /**\n   * Issued at time in seconds\n   */\n  iat?:number\n  nbf?:number\n  nonce?:Uint8Array\n  cause?:CID\n  meta?:CborObject\n}\n\nexport interface InvocationFromOptions extends DelegationValidateOptions {\n  bytes:Uint8Array\n  audience:VerifiableDID\n  resolveProof:ResolveProof\n}\n\n/**\n * Capability types\n */\n\n/**\n * Capability options\n */\nexport interface CapabilityOptions<\n  Schema extends StandardSchemaV1,\n  Cmd extends string = string,\n> extends DelegationValidateOptions {\n  schema:Schema\n  cmd:Cmd\n}\n\n/**\n * Delegate a capability\n */\nexport interface CapabilityDelegateOptions<Schema extends StandardSchemaV1>\n  extends Omit<DelegationOptions<Schema>, 'cmd'> {\n  /**\n   * Store to add the delegation to\n   */\n  store:Store\n}\n\n/**\n * Invoke a capability\n */\nexport interface CapabilityInvokeOptions<Schema extends StandardSchemaV1>\n  extends Omit<\n    InvocationOptions,\n    'cmd' | 'args' | 'prf' | 'verifierResolver' | 'didResolver' | 'isRevoked'\n  > {\n  args:StandardSchemaV1.InferOutput<Schema>\n  /**\n   * Store to resolve proofs from\n   */\n  store:Store\n}\n\n/**\n * Store types\n */\n\n/**\n * Resolve proofs options\n */\nexport interface StoreProofsOptions {\n  aud?:DID\n  sub:DID | null\n  cmd:string\n  args:CborObject\n}\n\n/**\n * Server types\n */\nexport type Promisable<T> = T | PromiseLike<T>\n\nexport interface HandlerOptions<Schema extends StandardSchemaV1> {\n  args:StandardSchemaV1.InferOutput<Schema>\n  store:Store\n}\n\nexport type Handler<Schema extends StandardSchemaV1, Output> = (\n  options:HandlerOptions<Schema>\n) => Promisable<Output>\n\nexport interface RouteOptions<\n  Cap extends Capability<StandardSchemaV1>,\n  Output,\n> {\n  capability:Cap\n  handler:Handler<Cap['schema'], Output>\n}\n\nexport type RouteOutput<Cap extends Capability<StandardSchemaV1>, Output> = {\n  cap:Cap\n  fn:(options:RouteHandlerOptions) => Promisable<Output>\n}\n\n/**\n * Infer the protocol from a router\n */\nexport type InferProtocol<\n  Routes extends Record<\n    string,\n    RouteOutput<Capability<StandardSchemaV1>, unknown>\n  >,\n> = {\n  [K in keyof Routes]:Routes[K] extends RouteOutput<infer Cap, infer Output>\n    ? {\n        cmd:Cap['cmd'] extends K ? Cap['cmd'] : never\n        in:StandardSchemaV1.InferOutput<Cap['schema']>\n        out:Output\n      }\n    : never\n}[keyof Routes]\n\nexport type Protocol<\n  Cap extends Capability<StandardSchemaV1> = Capability<StandardSchemaV1>,\n> = {\n  cmd:Cap['cmd']\n  in:StandardSchemaV1.InferOutput<Cap['schema']>\n  out:unknown\n}[]\n\n/**\n * Creates a router type that validates:\n * 1. Router keys match capability commands\n * 2. Router values are RouteOutput types that match the capability\n */\nexport type Router<Caps extends readonly Capability<StandardSchemaV1>[]> = {\n  [K in Caps[number]['cmd']]:Extract<\n    Caps[number],\n    { cmd:K }\n  > extends infer Cap\n    ? Cap extends Capability<StandardSchemaV1>\n      ? RouteOutput<Cap, unknown>\n      : never\n    : never\n}\n\nexport interface RouteHandlerOptions {\n  request:Request\n  issuer:ISigner\n  invocation:Invocation\n  store:Store\n}\n\n/**\n * Client type that provides type-safe request methods based on router inference\n */\nexport type RouterClient<\n  Router extends InferProtocol<\n    Record<string, RouteOutput<Capability<StandardSchemaV1>, unknown>>\n  >,\n> = {\n  request<Cmd extends Router['cmd']>(\n    cmd:Cmd,\n    args:Extract<Router, { cmd:Cmd }>['in']\n  ):Promise<Extract<Router, { cmd:Cmd }>['out']>\n}\n\nexport type ClientOptions = {\n  url:string\n  issuer:ISigner\n  audience:DIDURLObject\n  store:Store\n  capabilities:Capability<StandardSchemaV1, string>[]\n}\n"],
  "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAeAE,EAAAF,EAAc,4BAfd,gBAgBAE,EAAAF,EAAc,0BAhBd,gBAiBAE,EAAAF,EAAc,0BAjBd",
  "names": ["types_exports", "__toCommonJS", "__reExport"]
}
