UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

34 lines (33 loc) • 1.36 kB
import { CredoError } from "../../../error/CredoError.mjs"; import "../../../error/index.mjs"; //#region src/modules/vc/sd-jwt-vc/disclosureFrame.ts /** * List of fields that cannot be selectively disclosed. * * @see https://www.w3.org/TR/vc-jose-cose/#securing-with-sd-jwt * @see https://www.w3.org/TR/vc-jose-cose/#securing-vps-sd-jwt */ const NON_DISCLOSEABLE_FIELDS = [ "@context", "type", "credentialStatus", "credentialSchema", "relatedResource" ]; /** * Asserts that a disclosure frame does not make any of the {@link NON_DISCLOSEABLE_FIELDS} of a W3C * VCDM 2.0 credential or presentation selectively disclosable. * * Only the top level of the frame is checked. A nested claim that happens to share a name with a * non-discloseable field, such as `credentialSubject.type`, may be selectively disclosed. */ function validateW3cV2SdJwtDisclosureFrame(disclosureFrame) { if (!disclosureFrame) return; for (const field of NON_DISCLOSEABLE_FIELDS) { if (disclosureFrame[field]) throw new CredoError(`'${field}' property cannot be selectively disclosed`); if (Array.isArray(disclosureFrame._sd) && disclosureFrame._sd.includes(field)) throw new CredoError(`'${field}' property cannot be selectively disclosed`); } } //#endregion export { NON_DISCLOSEABLE_FIELDS, validateW3cV2SdJwtDisclosureFrame }; //# sourceMappingURL=disclosureFrame.mjs.map