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

51 lines (47 loc) • 2.72 kB
import { TypedArrayEncoder } from "../../../utils/TypedArrayEncoder.mjs"; import { Hasher } from "../../../crypto/hashes/Hasher.mjs"; import "../../../utils/index.mjs"; import "../../kms/index.mjs"; import { publicJwkToSpki } from "../../../crypto/webcrypto/utils/keyAlgorithmConversion.mjs"; import "../../../crypto/webcrypto/utils/index.mjs"; import { AuthorityKeyIdentifierExtension, BasicConstraintsExtension, CRLDistributionPointsExtension, ExtendedKeyUsageExtension, IssuerAlternativeNameExtension, KeyUsagesExtension, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension } from "@peculiar/x509"; //#region src/modules/x509/utils/extensions.ts const createSubjectKeyIdentifierExtension = (options, additionalOptions) => { if (!options || !options.include) return; const spki = publicJwkToSpki(additionalOptions.publicJwk); const hash = Hasher.hash(new Uint8Array(spki.subjectPublicKey), "SHA-1"); return new SubjectKeyIdentifierExtension(TypedArrayEncoder.toHex(hash)); }; const createKeyUsagesExtension = (options) => { if (!options) return; return new KeyUsagesExtension(options.usages.reduce((prev, curr) => prev | curr, 0), options.markAsCritical); }; const createExtendedKeyUsagesExtension = (options) => { if (!options) return; return new ExtendedKeyUsageExtension(options.usages, options.markAsCritical); }; const createAuthorityKeyIdentifierExtension = (options, additionalOptions) => { if (!options) return; const spki = publicJwkToSpki(additionalOptions.publicJwk); const hash = Hasher.hash(new Uint8Array(spki.subjectPublicKey), "SHA-1"); return new AuthorityKeyIdentifierExtension(TypedArrayEncoder.toHex(hash), options.markAsCritical); }; const createIssuerAlternativeNameExtension = (options) => { if (!options) return; return new IssuerAlternativeNameExtension(options.name, options.markAsCritical); }; const createSubjectAlternativeNameExtension = (options) => { if (!options) return; return new SubjectAlternativeNameExtension(options.name, options.markAsCritical); }; const createBasicConstraintsExtension = (options) => { if (!options) return; return new BasicConstraintsExtension(options.ca, options.pathLenConstraint, options.markAsCritical); }; const createCrlDistributionPointsExtension = (options) => { if (!options) return; return new CRLDistributionPointsExtension(options.urls, options.markAsCritical); }; //#endregion export { createAuthorityKeyIdentifierExtension, createBasicConstraintsExtension, createCrlDistributionPointsExtension, createExtendedKeyUsagesExtension, createIssuerAlternativeNameExtension, createKeyUsagesExtension, createSubjectAlternativeNameExtension, createSubjectKeyIdentifierExtension }; //# sourceMappingURL=extensions.mjs.map