1import{B as t,n as e,v as s}from"./index-Dab3X91f-dKXR6RU7.js";import"./main.js";import"./jsonld-signatures-B0DqrrUT-B4B7KZ3F.js";import"./jsonld-BHLXlZBJ-dtl20tiV.js"; 2/*! 3 * Copyright (c) 2024 Digital Bazaar, Inc. All rights reserved. 4 */class r{constructor({length:e,buffer:s}={}){this.bitstring=new t({length:e,buffer:s}),this.length=this.bitstring.length}setStatus(t,e){if("boolean"!=typeof e)throw new TypeError('"status" must be a boolean.');return this.bitstring.set(t,e)}getStatus(t){return this.bitstring.get(t)}async encode(){return"u"+await this.bitstring.encodeBits()}static async decode({encodedList:e}){try{if("u"!==e[0])throw'"encodedList" must start with the character "u".';const s=await t.decodeBits({encoded:e.slice(1)});return new r({buffer:s})}catch(t){if(t instanceof Error)throw t;throw new Error(`Could not decode encoded status list; reason: ${t}`)}}} 5/*! 6 * Copyright (c) 2024 Digital Bazaar, Inc. All rights reserved. 7 */ 8/*! 9 * Copyright (c) 2024 Digital Bazaar, Inc. All rights reserved. 10 */ 11const i="https://www.w3.org/ns/credentials/status/v1",n=0;(new Map).set(i,{"@context":{"@protected":!0,id:"@id",type:"@type",BitstringStatusListCredential:"https://www.w3.org/ns/credentials/status#BitstringStatusListCredential",BitstringStatusList:{"@id":"https://www.w3.org/ns/credentials/status#BitstringStatusList","@context":{"@protected":!0,id:"@id",type:"@type",encodedList:{"@id":"https://www.w3.org/ns/credentials/status#encodedList","@type":"https://w3id.org/security#multibase"},statusPurpose:"https://www.w3.org/ns/credentials/status#statusPurpose",ttl:"https://www.w3.org/ns/credentials/status#ttl"}},BitstringStatusListEntry:{"@id":"https://www.w3.org/ns/credentials/status#BitstringStatusListEntry","@context":{"@protected":!0,id:"@id",type:"@type",statusListCredential:{"@id":"https://www.w3.org/ns/credentials/status#statusListCredential","@type":"@id"},statusListIndex:"https://www.w3.org/ns/credentials/status#statusListIndex",statusPurpose:"https://www.w3.org/ns/credentials/status#statusPurpose",statusMessage:{"@id":"https://www.w3.org/ns/credentials/status#statusMessage","@context":{"@protected":!0,id:"@id",type:"@type",message:"https://www.w3.org/ns/credentials/status#message",status:"https://www.w3.org/ns/credentials/status#status"}},statusReference:{"@id":"https://www.w3.org/ns/credentials/status#statusReference","@type":"@id"},statusSize:{"@id":"https://www.w3.org/ns/credentials/status#statusSize","@type":"https://www.w3.org/2001/XMLSchema#integer"}}}}});(new Map).set(i,n);const a=i,o=e.get("v1").id,u=e.get("v2").id,d=[o,a],c=[u]; 12/*! 13 * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved. 14 */async function w({length:t}){return new r({length:t})}async function l({encodedList:t}){return r.decode({encodedList:t})}async function p({id:t,list:e,statusPurpose:s,context:r}){if(!t||"string"!=typeof t)throw new TypeError('"id" is required.');if(!e||"function"!=typeof e.encode)throw new TypeError('"list" is required.');if(!s||"string"!=typeof s)throw new TypeError('"statusPurpose" is required.');if(r){if(!r.every((t,e)=>t===d[e])&&!r.every((t,e)=>t===c[e]))throw new TypeError(`"context" must be either "${d}" or "${c}".`)}else r=[...c];return{"@context":r,id:t,type:["VerifiableCredential","BitstringStatusListCredential"],credentialSubject:{id:`${t}#list`,type:"BitstringStatusList",encodedList:await e.encode(),statusPurpose:s}}}async function f({credential:t,documentLoader:e,suite:r,verifyBitstringStatusListCredential:i=!0,verifyMatchingIssuers:n=!0}={}){let a;try{a=await async function({credential:t,documentLoader:e,suite:r,verifyBitstringStatusListCredential:i,verifyMatchingIssuers:n}){if(L({credential:t}),"function"!=typeof e)throw new TypeError('"documentLoader" must be a function.');if(i&&!(r&&(a=r,Array.isArray(a)&&a.length>0&&a.every(t=>t&&"object"==typeof t)||!Array.isArray(r)&&"object"==typeof r)))throw new TypeError('"suite" must be an object or an array of objects.');var a;const o=m({credential:t});if(0===o.length)throw new Error('"credentialStatus.type" must be "BitstringStatusListEntry".');o.forEach(t=>S({credentialStatus:t}));const u=await Promise.all(o.map(a=>async function({credential:t,credentialStatus:e,verifyBitstringStatusListCredential:r,verifyMatchingIssuers:i,suite:n,documentLoader:a}){const{statusListIndex:o}=e,u=parseInt(o,10);let d;try{({document:d}=await a(e.statusListCredential))}catch(t){const e=new Error(`Could not load "BitstringStatusListCredential"; reason: ${t.message}`);throw e.cause=t,e}const{statusPurpose:c}=e,{statusPurpose:w}=d.credentialSubject;if(w!==c)throw new Error(`The status purpose "${w}" of the status list credential does not match the status purpose "${c}" in the credential.`);if(r){const t=await s({credential:d,suite:n,documentLoader:a});if(!t.verified){const{error:e}=t;let s='"BitstringStatusListCredential" not verified';s+=e?`; reason: ${e.message}`:".";const r=new Error(s);throw e&&(r.cause=t.error),r}}if(i){const e="object"==typeof t.issuer?t.issuer.id:t.issuer,s="object"==typeof d.issuer?d.issuer.id:d.issuer;if(!e||!s||e!==s)throw new Error("Issuers of the status list credential and verifiable credential do not match.")}if(!d.type.includes("BitstringStatusListCredential"))throw new Error('Status list credential type must include "BitstringStatusListCredential".');const{credentialSubject:p}=d;if("BitstringStatusList"!==p.type)throw new Error('Status list type must be "BitstringStatusList".');const{encodedList:f}=p,y=(await l({encodedList:f})).getStatus(u);return{verified:!0,credentialStatus:e,status:y}}({credential:t,credentialStatus:a,suite:r,documentLoader:e,verifyBitstringStatusListCredential:i,verifyMatchingIssuers:n})));return{verified:u.every(({verified:t=!1}={})=>!0===t),results:u}}({credential:t,documentLoader:e,suite:r,verifyBitstringStatusListCredential:i,verifyMatchingIssuers:n})}catch(t){a={verified:!1,error:t}}return a}function y({credential:t}={}){L({credential:t});const{"@context":e}=t;if(!Array.isArray(e))throw new TypeError('"@context" must be an array.');const s=e[0]===u;if(!s&&e[0]!==o)throw new TypeError(`The first "@context" value must be "${o}" or "${u}".`);const{credentialStatus:r}=t;if(!r)return!1;if("object"!=typeof r)throw new Error('"credentialStatus" is invali
14d.');if(!s&&!e.includes(a))return!1;return m({credential:t}).length>0}function h({credential:t}={}){L({credential:t});const{"@context":e}=t;if(!Array.isArray(e))throw new TypeError('"@context" must be an array.');if(e[0]!==u){if(e[0]!==o)throw new TypeError(`The first "@context" value must be "${o}".`);if(!e.includes(a))throw new TypeError(`"@context" must include "${a}".`)}}function g({credential:t,statusPurpose:e}={}){if(L({credential:t}),h({credential:t}),!e||"string"!=typeof e)throw new TypeError('"statusPurpose" must be a string.');if(!t.credentialStatus||"object"!=typeof t.credentialStatus)throw new Error('"credentialStatus" is missing or invalid.');const s=m({credential:t});if(0===s.length)throw new Error(`"credentialStatus" with type "BitstringStatusListEntry" and status purpose "${e}" not found.`);const r=s.filter(t=>S({credentialStatus:t})).find(t=>t.statusPurpose===e);if(!r)throw new Error(`"credentialStatus" with type "BitstringStatusListEntry" and status purpose "${e}" not found.`);return r}function S({credentialStatus:t}){if("BitstringStatusListEntry"!==t.type)throw new Error('"credentialStatus.type" must be "BitstringStatusListEntry".');if("string"!=typeof t.statusPurpose)throw new TypeError('"credentialStatus.statusPurpose" must be a string.');if(t.id&&"string"!=typeof t.id)throw new TypeError('"credentialStatus.id" must be a string.');if("string"!=typeof t.statusListCredential)throw new TypeError('"credentialStatus.statusListCredential" must be a string.');const e=parseInt(t.statusListIndex,10);if(isNaN(e))throw new TypeError('"statusListIndex" must be an integer.');if(t.id===t.statusListCredential)throw new Error('"credentialStatus.id" must not be "credentialStatus.statusListCredential".');return t}function L({credential:t}){if(!t||"object"!=typeof t)throw new TypeError('"credential" must be an object.')}function m({credential:t}){const{credentialStatus:e}=t;return Array.isArray(e)?e.filter(t=>"BitstringStatusListEntry"===t.type):e&&"BitstringStatusListEntry"===e.type?[e]:[]}export{r as BitstringStatusList,d as VC_BSL_VC_V1_CONTEXT,c as VC_BSL_VC_V2_CONTEXT,h as assertBitstringStatusListContext,f as checkStatus,p as createCredential,w as createList,l as decodeList,g as getCredentialStatus,y as statusTypeMatches};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.