{"version":3,"file":"model.mjs","names":["d: CapabilityDict"],"sources":["../../src/zcap/model.ts"],"sourcesContent":["/** ZCAP-LD data model — W3C-CCG zcap-spec wire shape. */\n\nexport interface CapabilityProof {\n  type: string\n  created?: string\n  verificationMethod: string\n  proofPurpose: string\n  proofValue: string\n}\n\nexport interface CapabilityDict {\n  '@context': string\n  id: string\n  controller: string\n  invocationTarget: string\n  parentCapability?: string\n  allowedAction: string[]\n  expires?: string\n  caveat?: Array<Record<string, unknown>>\n  proof?: CapabilityProof\n}\n\n/**\n * Mutable capability object. `toDict`/`fromDict` round-trip through\n * the spec's camelCase wire form. `withoutProof` returns the dict\n * that gets canonicalized (JCS) and signed.\n */\nexport class Capability {\n  public id: string\n  public controller: string\n  public invocationTarget: string\n  public parentCapability?: string\n  public allowedAction: string[]\n  public expires?: string\n  public caveat: Array<Record<string, unknown>>\n  public proof?: CapabilityProof\n\n  public constructor(opts: {\n    id: string\n    controller: string\n    invocationTarget: string\n    parentCapability?: string\n    allowedAction: string[]\n    expires?: string\n    caveat?: Array<Record<string, unknown>>\n    proof?: CapabilityProof\n  }) {\n    this.id = opts.id\n    this.controller = opts.controller\n    this.invocationTarget = opts.invocationTarget\n    this.parentCapability = opts.parentCapability\n    this.allowedAction = [...opts.allowedAction]\n    this.expires = opts.expires\n    this.caveat = opts.caveat ? [...opts.caveat] : []\n    this.proof = opts.proof\n  }\n\n  public toDict(): CapabilityDict {\n    const d: CapabilityDict = {\n      '@context': 'https://w3id.org/zcap/v1',\n      id: this.id,\n      controller: this.controller,\n      invocationTarget: this.invocationTarget,\n      allowedAction: [...this.allowedAction],\n    }\n    if (this.parentCapability) d.parentCapability = this.parentCapability\n    if (this.expires) d.expires = this.expires\n    if (this.caveat.length > 0) d.caveat = [...this.caveat]\n    if (this.proof !== undefined) d.proof = this.proof\n    return d\n  }\n\n  public withoutProof(): Omit<CapabilityDict, 'proof'> {\n    const d = this.toDict()\n    delete d.proof\n    return d\n  }\n\n  public static fromDict(d: CapabilityDict | Record<string, unknown>): Capability {\n    const r = d as Record<string, unknown>\n    return new Capability({\n      id: r.id as string,\n      controller: r.controller as string,\n      invocationTarget: r.invocationTarget as string,\n      parentCapability: r.parentCapability as string | undefined,\n      allowedAction: Array.isArray(r.allowedAction) ? (r.allowedAction as string[]) : [],\n      expires: r.expires as string | undefined,\n      caveat: Array.isArray(r.caveat) ? (r.caveat as Array<Record<string, unknown>>) : [],\n      proof: r.proof as CapabilityProof | undefined,\n    })\n  }\n}\n\n/**\n * Ed25519 keypair handle for proof creation / verification.\n *\n * `verificationMethod` is the DID URL fragment that resolves to the\n * public key (e.g. `did:example:alice#key-1`); it lands in the proof\n * and is what a verifier uses to look up the public bytes via DID\n * resolution.\n */\nexport interface KeyMaterial {\n  verificationMethod: string\n  publicKeyBytes: Uint8Array\n  privateKeyBytes?: Uint8Array\n}\n\n/**\n * Runtime context the verifier evaluates caveats against. Built by\n * the EDV server (or any resource-fronting service) on each request\n * from the HTTP verb + target + claimed byte budget + clock.\n */\nexport interface InvocationContext {\n  verb: string\n  invocationTarget: string\n  requestBytes?: number\n  nowIso?: string\n}\n"],"mappings":";;;;;;AA2BA,IAAa,aAAb,MAAa,WAAW;CAUtB,AAAO,YAAY,MAShB;AACD,OAAK,KAAK,KAAK;AACf,OAAK,aAAa,KAAK;AACvB,OAAK,mBAAmB,KAAK;AAC7B,OAAK,mBAAmB,KAAK;AAC7B,OAAK,gBAAgB,CAAC,GAAG,KAAK,cAAc;AAC5C,OAAK,UAAU,KAAK;AACpB,OAAK,SAAS,KAAK,SAAS,CAAC,GAAG,KAAK,OAAO,GAAG,EAAE;AACjD,OAAK,QAAQ,KAAK;;CAGpB,AAAO,SAAyB;EAC9B,MAAMA,IAAoB;GACxB,YAAY;GACZ,IAAI,KAAK;GACT,YAAY,KAAK;GACjB,kBAAkB,KAAK;GACvB,eAAe,CAAC,GAAG,KAAK,cAAc;GACvC;AACD,MAAI,KAAK,iBAAkB,GAAE,mBAAmB,KAAK;AACrD,MAAI,KAAK,QAAS,GAAE,UAAU,KAAK;AACnC,MAAI,KAAK,OAAO,SAAS,EAAG,GAAE,SAAS,CAAC,GAAG,KAAK,OAAO;AACvD,MAAI,KAAK,UAAU,OAAW,GAAE,QAAQ,KAAK;AAC7C,SAAO;;CAGT,AAAO,eAA8C;EACnD,MAAM,IAAI,KAAK,QAAQ;AACvB,SAAO,EAAE;AACT,SAAO;;CAGT,OAAc,SAAS,GAAyD;EAC9E,MAAM,IAAI;AACV,SAAO,IAAI,WAAW;GACpB,IAAI,EAAE;GACN,YAAY,EAAE;GACd,kBAAkB,EAAE;GACpB,kBAAkB,EAAE;GACpB,eAAe,MAAM,QAAQ,EAAE,cAAc,GAAI,EAAE,gBAA6B,EAAE;GAClF,SAAS,EAAE;GACX,QAAQ,MAAM,QAAQ,EAAE,OAAO,GAAI,EAAE,SAA4C,EAAE;GACnF,OAAO,EAAE;GACV,CAAC"}