@sphereon/ssi-sdk.mdl-mdoc 0.33.1-feature.vcdm2.4 → 0.33.1-feature.vcdm2.tsup.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,214 +0,0 @@
1
- import { com } from '@sphereon/kmp-mdoc-core';
2
- import { calculateJwkThumbprint, globalCrypto, verifyRawSignature } from '@sphereon/ssi-sdk-ext.key-utils';
3
- import { derToPEM, getCertificateInfo, getSubjectDN, pemOrDerToX509Certificate, validateX509CertificateChain, } from '@sphereon/ssi-sdk-ext.x509-utils';
4
- import * as crypto from 'crypto';
5
- import { CryptoEngine, setEngine } from 'pkijs';
6
- import * as u8a from 'uint8arrays';
7
- var CoseKeyCbor = com.sphereon.crypto.cose.CoseKeyCbor;
8
- var CoseJoseKeyMappingService = com.sphereon.crypto.CoseJoseKeyMappingService;
9
- var DefaultCallbacks = com.sphereon.crypto.DefaultCallbacks;
10
- var SignatureAlgorithm = com.sphereon.crypto.generic.SignatureAlgorithm;
11
- var KeyInfo = com.sphereon.crypto.KeyInfo;
12
- var ResolvedKeyInfo = com.sphereon.crypto.ResolvedKeyInfo;
13
- var DateTimeUtils = com.sphereon.kmp.DateTimeUtils;
14
- var decodeFrom = com.sphereon.kmp.decodeFrom;
15
- var encodeTo = com.sphereon.kmp.encodeTo;
16
- var Encoding = com.sphereon.kmp.Encoding;
17
- export class CoseCryptoService {
18
- context;
19
- constructor(context) {
20
- this.context = context;
21
- }
22
- setContext(context) {
23
- this.context = context;
24
- }
25
- async signAsync(input, requireX5Chain) {
26
- if (!this.context) {
27
- throw Error('No context provided. Please provide a context with the setContext method or constructor');
28
- }
29
- const { keyInfo, alg, value } = input;
30
- let kmsKeyRef = keyInfo.kmsKeyRef ?? undefined;
31
- if (!kmsKeyRef) {
32
- const key = keyInfo.key;
33
- if (key == null) {
34
- return Promise.reject(Error('No key present in keyInfo. This implementation cannot sign without a key!'));
35
- }
36
- const resolvedKeyInfo = ResolvedKeyInfo.Static.fromKeyInfo(keyInfo, key);
37
- const jwkKeyInfo = CoseJoseKeyMappingService.toResolvedJwkKeyInfo(resolvedKeyInfo);
38
- const kid = jwkKeyInfo.kid ?? calculateJwkThumbprint({ jwk: jwkKeyInfo.key.toJsonDTO() }) ?? jwkKeyInfo.key.getKidAsString(true);
39
- if (!kid) {
40
- return Promise.reject(Error('No kid present and not kmsKeyRef provided'));
41
- }
42
- kmsKeyRef = kid;
43
- }
44
- const result = await this.context.agent.keyManagerSign({
45
- algorithm: alg.jose.value,
46
- data: encodeTo(value, Encoding.UTF8),
47
- encoding: 'utf-8',
48
- keyRef: kmsKeyRef,
49
- });
50
- return decodeFrom(result, Encoding.UTF8);
51
- }
52
- async verify1Async(input, keyInfo, requireX5Chain) {
53
- const getCertAndKey = async (x5c) => {
54
- if (requireX5Chain && (!x5c || x5c.length === 0)) {
55
- // We should not be able to get here anyway, as the MLD-mdoc library already validated at this point. But let's make sure
56
- return Promise.reject(new Error(`No x5chain was present in the CoseSign headers!`));
57
- }
58
- // TODO: According to the IETF spec there should be a x5t in case the x5chain is in the protected headers. In the Funke this does not seem to be done/used!
59
- issuerCert = x5c ? pemOrDerToX509Certificate(x5c[0]) : undefined;
60
- let issuerJwk;
61
- if (issuerCert) {
62
- const info = await getCertificateInfo(issuerCert);
63
- issuerJwk = info.publicKeyJWK;
64
- }
65
- return { issuerCert, issuerJwk };
66
- };
67
- const coseKeyInfo = CoseJoseKeyMappingService.toCoseKeyInfo(keyInfo);
68
- if (coseKeyInfo?.key?.d) {
69
- throw Error('Do not use private keys to verify!');
70
- }
71
- else if (!input.payload?.value) {
72
- return Promise.reject(Error('Signature validation without payload not supported'));
73
- }
74
- const sign1Json = input.toJson(); // Let's make it a bit easier on ourselves, instead of working with CBOR
75
- const coseAlg = sign1Json.protectedHeader.alg;
76
- if (!coseAlg) {
77
- return Promise.reject(Error('No alg protected header present'));
78
- }
79
- let issuerCert;
80
- let issuerCoseKey;
81
- let kid = coseKeyInfo?.kid ?? sign1Json.protectedHeader.kid ?? sign1Json.unprotectedHeader?.kid;
82
- // Please note this method does not perform chain validation. The MDL-MSO_MDOC library already performed this before this step
83
- const x5c = coseKeyInfo?.key?.getX509CertificateChain() ?? sign1Json.protectedHeader?.x5chain ?? sign1Json.unprotectedHeader?.x5chain;
84
- if (!coseKeyInfo || !coseKeyInfo?.key || coseKeyInfo?.key?.x5chain) {
85
- const certAndKey = await getCertAndKey(x5c);
86
- issuerCoseKey = certAndKey.issuerJwk ? CoseJoseKeyMappingService.toCoseKey(certAndKey.issuerJwk) : undefined;
87
- issuerCert = certAndKey.issuerCert;
88
- }
89
- if (!issuerCoseKey) {
90
- if (!coseKeyInfo?.key) {
91
- return Promise.reject(Error(`Either a x5c needs to be in the headers, or you need to provide a key for verification`));
92
- }
93
- if (kid === null) {
94
- kid = coseKeyInfo.key.getKidAsString(false);
95
- }
96
- issuerCoseKey = CoseKeyCbor.Static.fromDTO(coseKeyInfo.key);
97
- }
98
- const issuerCoseKeyInfo = new KeyInfo(kid, issuerCoseKey, coseKeyInfo.opts, coseKeyInfo.keyVisibility, issuerCoseKey.getSignatureAlgorithm() ?? coseKeyInfo.signatureAlgorithm, x5c, coseKeyInfo.kmsKeyRef, coseKeyInfo.kms, coseKeyInfo.keyType ?? issuerCoseKey.getKty());
99
- const recalculatedToBeSigned = input.toBeSignedJson(issuerCoseKeyInfo, SignatureAlgorithm.Static.fromCose(coseAlg));
100
- const key = CoseJoseKeyMappingService.toJoseJwk(issuerCoseKeyInfo.key).toJsonDTO();
101
- const valid = await verifyRawSignature({
102
- data: u8a.fromString(recalculatedToBeSigned.base64UrlValue, 'base64url'),
103
- signature: u8a.fromString(sign1Json.signature, 'base64url'),
104
- key,
105
- });
106
- return {
107
- name: 'mdoc',
108
- critical: true,
109
- error: !valid,
110
- message: `Signature of '${issuerCert ? getSubjectDN(issuerCert).DN : kid}' was ${valid ? '' : 'in'}valid`,
111
- keyInfo: issuerCoseKeyInfo,
112
- };
113
- }
114
- resolvePublicKeyAsync(keyInfo) {
115
- if (keyInfo.key) {
116
- return Promise.resolve(CoseJoseKeyMappingService.toResolvedKeyInfo(keyInfo, keyInfo.key));
117
- }
118
- return Promise.reject(Error('No key present in keyInfo. This implementation cannot resolve public keys on its own currently!'));
119
- }
120
- }
121
- /**
122
- * This class can be used for X509 validations.
123
- * Either have an instance per trustedCerts and verification invocation or use a single instance and provide the trusted certs in the method argument
124
- *
125
- * The class is also registered with the low-level mDL/mdoc Kotlin Multiplatform library
126
- * Next to the specific function for the library it exports a more powerful version of the same verification method as well
127
- */
128
- export class X509CallbackService {
129
- _trustedCerts;
130
- constructor(trustedCerts) {
131
- this.setTrustedCerts(trustedCerts);
132
- }
133
- /**
134
- * A more powerful version of the method below. Allows to verify at a specific time and returns more information
135
- * @param chain
136
- * @param trustAnchors
137
- * @param verificationTime
138
- */
139
- async verifyCertificateChain({ chain, trustAnchors = this.getTrustedCerts(), verificationTime, opts, }) {
140
- return await validateX509CertificateChain({
141
- chain,
142
- trustAnchors,
143
- verificationTime,
144
- opts,
145
- });
146
- }
147
- /**
148
- * This method is the implementation used within the mDL/Mdoc library
149
- */
150
- async verifyCertificateChainJS(chainDER, chainPEM, trustedCerts, verificationProfile, verificationTime) {
151
- const verificationAt = verificationTime ?? DateTimeUtils.Static.DEFAULT.dateTimeLocal();
152
- let chain = [];
153
- if (chainDER && chainDER.length > 0) {
154
- chain = chainDER.map((der) => Uint8Array.from(der));
155
- }
156
- if (chainPEM && chainPEM.length > 0) {
157
- chain = (chain ?? []).concat(chainPEM);
158
- }
159
- const result = await validateX509CertificateChain({
160
- chain: chain, // The function will handle an empty array
161
- trustAnchors: trustedCerts ?? this.getTrustedCerts(),
162
- verificationTime: new Date(verificationAt.toEpochSeconds().toULong() * 1000),
163
- opts: { trustRootWhenNoAnchors: true },
164
- });
165
- const cert = result.certificateChain ? result.certificateChain[result.certificateChain.length - 1] : undefined;
166
- return {
167
- publicKey: cert?.publicKeyJWK, // fixme
168
- publicKeyAlgorithm: cert?.publicKeyJWK?.alg,
169
- name: 'x.509',
170
- critical: result.critical,
171
- message: result.message,
172
- error: result.error,
173
- verificationTime: verificationAt,
174
- };
175
- }
176
- setTrustedCerts = (trustedCertsInPEM) => {
177
- this._trustedCerts = trustedCertsInPEM?.map((cert) => {
178
- if (cert.includes('CERTIFICATE')) {
179
- // PEM
180
- return cert;
181
- }
182
- return derToPEM(cert);
183
- });
184
- };
185
- getTrustedCerts = () => this._trustedCerts;
186
- }
187
- const defaultCryptoEngine = () => {
188
- if (typeof self !== 'undefined') {
189
- if ('crypto' in self) {
190
- let engineName = 'webcrypto';
191
- if ('webkitSubtle' in self.crypto) {
192
- engineName = 'safari';
193
- }
194
- // @ts-ignore
195
- setEngine(engineName, new CryptoEngine({ name: engineName, crypto: crypto }));
196
- }
197
- }
198
- else if (typeof crypto !== 'undefined' && 'webcrypto' in crypto) {
199
- const name = 'NodeJS ^15';
200
- const nodeCrypto = crypto.webcrypto;
201
- // @ts-ignore
202
- setEngine(name, new CryptoEngine({ name, crypto: nodeCrypto }));
203
- }
204
- else {
205
- // @ts-ignore
206
- const name = 'crypto';
207
- setEngine(name, new CryptoEngine({ name, crypto: globalCrypto(false) }));
208
- }
209
- };
210
- defaultCryptoEngine();
211
- // We register the services with the mDL/mdoc library. Please note that the context is not passed in, meaning we cannot sign by default.
212
- DefaultCallbacks.setCoseCryptoDefault(new CoseCryptoService());
213
- DefaultCallbacks.setX509Default(new X509CallbackService());
214
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAC1G,OAAO,EAEL,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,yBAAyB,EACzB,4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vB,CAAC;YACD,aAAa;YACb,SAAS,CAAC,UAAU,EAAE,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAClE,MAAM,IAAI,GAAG,YAAY,CAAA;QACzB,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAA;QACnC,aAAa;QACb,SAAS,CAAC,IAAI,EAAE,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IACjE,CAAC;SAAM,CAAC;QACN,aAAa;QACb,MAAM,IAAI,GAAG,QAAQ,CAAA;QACrB,SAAS,CAAC,IAAI,EAAE,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;AACH,CAAC,CAAA;AAED,mBAAmB,EAAE,CAAA;AAErB,wIAAwI;AACxI,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAA;AAC9D,gBAAgB,CAAC,cAAc,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,sDAAuC,CAAA;AAC1D,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
@@ -1,75 +0,0 @@
1
- import { com } from '@sphereon/kmp-mdoc-core';
2
- import { PresentationDefinitionV2, PresentationSubmission } from '@sphereon/pex-models';
3
- import { ISphereonKeyManager } from '@sphereon/ssi-sdk-ext.key-manager';
4
- import { CertificateInfo, SubjectAlternativeGeneralName, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils';
5
- import { IAgentContext, IDIDManager, IPluginMethodMap, IResolver } from '@veramo/core';
6
- import CoseSign1Json = com.sphereon.crypto.cose.CoseSign1Json;
7
- import ICoseKeyCbor = com.sphereon.crypto.cose.ICoseKeyCbor;
8
- import ICoseKeyJson = com.sphereon.crypto.cose.ICoseKeyJson;
9
- import IKeyInfo = com.sphereon.crypto.IKeyInfo;
10
- import IVerifyResults = com.sphereon.crypto.generic.IVerifyResults;
11
- import IVerifySignatureResult = com.sphereon.crypto.generic.IVerifySignatureResult;
12
- import DocumentJson = com.sphereon.mdoc.data.device.DocumentJson;
13
- import DocumentCbor = com.sphereon.mdoc.data.device.DocumentCbor;
14
- export interface ImDLMdoc extends IPluginMethodMap {
15
- x509VerifyCertificateChain(args: VerifyCertificateChainArgs, context: IRequiredContext): Promise<X509ValidationResult>;
16
- x509GetCertificateInfo(args: GetX509CertificateInfoArgs, context: IRequiredContext): Promise<CertificateInfo[]>;
17
- mdocVerifyIssuerSigned(args: MdocVerifyIssuerSignedArgs, context: IRequiredContext): Promise<IVerifySignatureResult<KeyType>>;
18
- mdocOid4vpHolderPresent(args: MdocOid4vpPresentArgs, context: IRequiredContext): Promise<MdocOid4VPPresentationAuth>;
19
- mdocOid4vpRPVerify(args: MdocOid4vpRPVerifyArgs, _context: IRequiredContext): Promise<MdocOid4vpRPVerifyResult>;
20
- }
21
- export type IRequiredContext = IAgentContext<ISphereonKeyManager & IDIDManager & IResolver>;
22
- export type VerifyCertificateChainArgs = {
23
- chain: Array<string | Uint8Array>;
24
- trustAnchors?: string[];
25
- verificationTime?: Date;
26
- opts?: {
27
- allowNoTrustAnchorsFound?: boolean;
28
- trustRootWhenNoAnchors?: boolean;
29
- allowSingleNoCAChainElement?: boolean;
30
- blindlyTrustedAnchors?: string[];
31
- };
32
- };
33
- export type GetX509CertificateInfoArgs = {
34
- certificates: (string | Uint8Array)[];
35
- sanTypeFilter?: SubjectAlternativeGeneralName | SubjectAlternativeGeneralName[];
36
- };
37
- export type KeyType = ICoseKeyJson;
38
- export type MdocVerifyIssuerSignedArgs = {
39
- input: CoseSign1Json;
40
- keyInfo?: IKeyInfo<KeyType>;
41
- requireX5Chain?: boolean;
42
- };
43
- export interface MdocOid4VPPresentationAuth {
44
- vp_token: string;
45
- presentation_submission: PresentationSubmission;
46
- }
47
- export interface MdocOid4vpPresentArgs {
48
- mdocs: DocumentCbor[];
49
- mdocHolderNonce?: string;
50
- presentationDefinition: PresentationDefinitionV2;
51
- trustAnchors?: string[];
52
- verifications?: VerificationOptions;
53
- clientId: string;
54
- responseUri: string;
55
- authorizationRequestNonce: string;
56
- }
57
- export type VerificationOptions = {
58
- allowExpiredDocuments?: boolean;
59
- verificationTime?: Date;
60
- };
61
- export type DocumentVerifyResult = {
62
- document: DocumentJson;
63
- validations: IVerifyResults<ICoseKeyCbor>;
64
- };
65
- export type MdocOid4vpRPVerifyResult = {
66
- error: boolean;
67
- documents: Array<DocumentVerifyResult>;
68
- presentation_submission: PresentationSubmission;
69
- };
70
- export interface MdocOid4vpRPVerifyArgs {
71
- vp_token: string;
72
- presentation_submission: PresentationSubmission;
73
- trustAnchors?: string[];
74
- }
75
- //# sourceMappingURL=ImDLMdoc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ImDLMdoc.d.ts","sourceRoot":"","sources":["../../src/types/ImDLMdoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC7C,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,kC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