@credo-ts/openid4vc 0.6.0-pr-2094-20241124155338 → 0.6.0-pr-2100-20241125134343
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.
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +12 -11
- package/build/openid4vc-holder/OpenId4VcHolderApi.js +15 -9
- package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -1
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +5 -170
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +70 -89
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +1 -1
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +13 -26
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +0 -2
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +7 -7
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +2 -10
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js +14 -6
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +7 -2
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +3 -12
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +28 -25
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -1
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +12 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +0 -3
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -1
- package/build/openid4vc-verifier/router/index.d.ts +0 -1
- package/build/openid4vc-verifier/router/index.js +1 -3
- package/build/openid4vc-verifier/router/index.js.map +1 -1
- package/build/shared/models/OpenId4VcJwtIssuer.d.ts +1 -4
- package/build/shared/transform.d.ts +3 -3
- package/build/shared/transform.js +4 -32
- package/build/shared/transform.js.map +1 -1
- package/build/shared/utils.d.ts +3 -11
- package/build/shared/utils.js +8 -100
- package/build/shared/utils.js.map +1 -1
- package/package.json +4 -6
- package/build/openid4vc-issuer/router/federationEndpoint.d.ts +0 -2
- package/build/openid4vc-issuer/router/federationEndpoint.js +0 -89
- package/build/openid4vc-issuer/router/federationEndpoint.js.map +0 -1
- package/build/openid4vc-verifier/router/federationEndpoint.d.ts +0 -2
- package/build/openid4vc-verifier/router/federationEndpoint.js +0 -118
- package/build/openid4vc-verifier/router/federationEndpoint.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenId4VcVerificationSessionRecord, OpenId4VcVerifierRecordProps } from './repository';
|
|
2
2
|
import type { OpenId4VcIssuerX5c, OpenId4VcJwtIssuer, OpenId4VcSiopAuthorizationResponsePayload, OpenId4VcSiopIdTokenPayload } from '../shared';
|
|
3
|
-
import type { DifPresentationExchangeDefinition, DifPresentationExchangeSubmission, DifPresentationExchangeDefinitionV2, VerifiablePresentation, DifPexPresentationWithDescriptor } from '@credo-ts/core';
|
|
3
|
+
import type { DifPresentationExchangeDefinition, DifPresentationExchangeSubmission, DifPresentationExchangeDefinitionV2, VerifiablePresentation, DcqlQuery, DcqlPresentation, DifPexPresentationWithDescriptor, DcqlPresentationResult } from '@credo-ts/core';
|
|
4
4
|
export type ResponseMode = 'direct_post' | 'direct_post.jwt';
|
|
5
5
|
export interface OpenId4VcSiopCreateAuthorizationRequestOptions {
|
|
6
6
|
/**
|
|
@@ -23,6 +23,12 @@ export interface OpenId4VcSiopCreateAuthorizationRequestOptions {
|
|
|
23
23
|
presentationExchange?: {
|
|
24
24
|
definition: DifPresentationExchangeDefinitionV2;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* A Digital Credentials Query Language (DCQL) can be provided to request the presentation of a Verifiable Credentials.
|
|
28
|
+
*/
|
|
29
|
+
dcql?: {
|
|
30
|
+
query: DcqlQuery;
|
|
31
|
+
};
|
|
26
32
|
/**
|
|
27
33
|
* The response mode to use for the authorization request.
|
|
28
34
|
* @default to `direct_post`.
|
|
@@ -48,6 +54,10 @@ export interface OpenId4VcSiopVerifiedAuthorizationResponsePresentationExchange
|
|
|
48
54
|
presentations: Array<VerifiablePresentation>;
|
|
49
55
|
descriptors: DifPexPresentationWithDescriptor[];
|
|
50
56
|
}
|
|
57
|
+
export interface OpenId4VcSiopVerifiedAuthorizationResponseDcql {
|
|
58
|
+
presentation: DcqlPresentation;
|
|
59
|
+
presentationResult: DcqlPresentationResult;
|
|
60
|
+
}
|
|
51
61
|
/**
|
|
52
62
|
* Either `idToken` and/or `presentationExchange` will be present.
|
|
53
63
|
*/
|
|
@@ -56,6 +66,7 @@ export interface OpenId4VcSiopVerifiedAuthorizationResponse {
|
|
|
56
66
|
payload: OpenId4VcSiopIdTokenPayload;
|
|
57
67
|
};
|
|
58
68
|
presentationExchange?: OpenId4VcSiopVerifiedAuthorizationResponsePresentationExchange;
|
|
69
|
+
dcql?: OpenId4VcSiopVerifiedAuthorizationResponseDcql;
|
|
59
70
|
}
|
|
60
71
|
/**
|
|
61
72
|
* Verifier metadata that will be send when creating a request
|
|
@@ -91,9 +91,6 @@ class OpenId4VcVerifierModule {
|
|
|
91
91
|
// Configure endpoints
|
|
92
92
|
(0, router_2.configureAuthorizationEndpoint)(endpointRouter, this.config.authorizationEndpoint);
|
|
93
93
|
(0, authorizationRequestEndpoint_1.configureAuthorizationRequestEndpoint)(endpointRouter, this.config.authorizationRequestEndpoint);
|
|
94
|
-
// TODO: The keys needs to be passed down to the federation endpoint to be used in the entity configuration for the openid relying party
|
|
95
|
-
// TODO: But the keys also needs to be available for the request signing. They also needs to get saved because it needs to survive a restart of the agent.
|
|
96
|
-
(0, router_2.configureFederationEndpoint)(endpointRouter);
|
|
97
94
|
// First one will be called for all requests (when next is called)
|
|
98
95
|
contextRouter.use(async (req, _res, next) => {
|
|
99
96
|
const { agentContext } = (0, router_1.getRequestContext)(req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenId4VcVerifierModule.js","sourceRoot":"","sources":["../../src/openid4vc-verifier/OpenId4VcVerifierModule.ts"],"names":[],"mappings":";;;AAKA,6CAAkD;AAClD,yCAA4C;AAE5C,6CAA8F;AAE9F,iFAA6E;AAC7E,iEAA6D;AAC7D,mFAA+E;AAC/E,6CAA0D;AAC1D,sGAAkG;AAClG,
|
|
1
|
+
{"version":3,"file":"OpenId4VcVerifierModule.js","sourceRoot":"","sources":["../../src/openid4vc-verifier/OpenId4VcVerifierModule.ts"],"names":[],"mappings":";;;AAKA,6CAAkD;AAClD,yCAA4C;AAE5C,6CAA8F;AAE9F,iFAA6E;AAC7E,iEAA6D;AAC7D,mFAA+E;AAC/E,6CAA0D;AAC1D,sGAAkG;AAClG,qCAAyD;AACzD,wFAA6F;AAE7F;;GAEG;AACH,MAAa,uBAAuB;IAIlC,YAAmB,OAA6C;QAHhD,QAAG,GAAG,2CAAoB,CAAA;QAIxC,IAAI,CAAC,MAAM,GAAG,IAAI,6DAA6B,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,iBAAoC;QAClD,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAA;QAE1D,iCAAiC;QACjC,WAAW,CAAC,MAAM,CAAC,IAAI,CACrB,0LAA0L,CAC3L,CAAA;QAED,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;YACtC,IAAA,wBAAe,EAAC;gBACd,iBAAiB,EAAE,IAAI;aACxB,CAAC,CAAA;QACJ,CAAC;QAED,kBAAkB;QAClB,iBAAiB,CAAC,gBAAgB,CAAC,6DAA6B,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAE9E,WAAW;QACX,iBAAiB,CAAC,iBAAiB,CAAC,2DA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GAAiC,EAAE,IAAa,EAAE,IAAkB,EAAE,EAAE;YAChH,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,0BAAiB,EAAC,GAAG,CAAC,CAAA;YAC/C,MAAM,YAAY,CAAC,UAAU,EAAE,CAAA;YAC/B,IAAI,EAAE,CAAA;QACR,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAvHD,0DAuHC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.configureAuthorizationEndpoint = void 0;
|
|
4
4
|
var authorizationEndpoint_1 = require("./authorizationEndpoint");
|
|
5
5
|
Object.defineProperty(exports, "configureAuthorizationEndpoint", { enumerable: true, get: function () { return authorizationEndpoint_1.configureAuthorizationEndpoint; } });
|
|
6
|
-
var federationEndpoint_1 = require("./federationEndpoint");
|
|
7
|
-
Object.defineProperty(exports, "configureFederationEndpoint", { enumerable: true, get: function () { return federationEndpoint_1.configureFederationEndpoint; } });
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/index.ts"],"names":[],"mappings":";;;AAAA,iEAAwE;AAA/D,uIAAA,8BAA8B,OAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/index.ts"],"names":[],"mappings":";;;AAAA,iEAAwE;AAA/D,uIAAA,8BAA8B,OAAA"}
|
|
@@ -24,8 +24,5 @@ interface OpenId4VcJwtIssuerJwk {
|
|
|
24
24
|
method: 'jwk';
|
|
25
25
|
jwk: Jwk;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
28
|
-
method: 'openid-federation';
|
|
29
|
-
}
|
|
30
|
-
export type OpenId4VcJwtIssuer = OpenId4VcJwtIssuerDid | OpenId4VcIssuerX5c | OpenId4VcJwtIssuerJwk | OpenId4VcJwtIssuerFederation;
|
|
27
|
+
export type OpenId4VcJwtIssuer = OpenId4VcJwtIssuerDid | OpenId4VcIssuerX5c | OpenId4VcJwtIssuerJwk;
|
|
31
28
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VerifiablePresentation, VerifiableCredential } from '@credo-ts/core';
|
|
2
|
-
import type { W3CVerifiableCredential as SphereonW3cVerifiableCredential, W3CVerifiablePresentation as SphereonW3cVerifiablePresentation,
|
|
3
|
-
export declare function getSphereonVerifiableCredential(verifiableCredential: VerifiableCredential): SphereonW3cVerifiableCredential
|
|
4
|
-
export declare function getSphereonVerifiablePresentation(verifiablePresentation: VerifiablePresentation): SphereonW3cVerifiablePresentation
|
|
2
|
+
import type { W3CVerifiableCredential as SphereonW3cVerifiableCredential, W3CVerifiablePresentation as SphereonW3cVerifiablePresentation, WrappedVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
|
+
export declare function getSphereonVerifiableCredential(verifiableCredential: VerifiableCredential): SphereonW3cVerifiableCredential;
|
|
4
|
+
export declare function getSphereonVerifiablePresentation(verifiablePresentation: VerifiablePresentation): SphereonW3cVerifiablePresentation;
|
|
5
5
|
export declare function getVerifiablePresentationFromSphereonWrapped(wrappedVerifiablePresentation: WrappedVerifiablePresentation): VerifiablePresentation;
|
|
@@ -5,40 +5,10 @@ exports.getSphereonVerifiablePresentation = getSphereonVerifiablePresentation;
|
|
|
5
5
|
exports.getVerifiablePresentationFromSphereonWrapped = getVerifiablePresentationFromSphereonWrapped;
|
|
6
6
|
const core_1 = require("@credo-ts/core");
|
|
7
7
|
function getSphereonVerifiableCredential(verifiableCredential) {
|
|
8
|
-
|
|
9
|
-
if (typeof verifiableCredential === 'string') {
|
|
10
|
-
return verifiableCredential;
|
|
11
|
-
}
|
|
12
|
-
else if (verifiableCredential instanceof core_1.W3cJsonLdVerifiableCredential) {
|
|
13
|
-
return core_1.JsonTransformer.toJSON(verifiableCredential);
|
|
14
|
-
}
|
|
15
|
-
else if (verifiableCredential instanceof core_1.W3cJwtVerifiableCredential) {
|
|
16
|
-
return verifiableCredential.serializedJwt;
|
|
17
|
-
}
|
|
18
|
-
else if (verifiableCredential instanceof core_1.Mdoc) {
|
|
19
|
-
return verifiableCredential.base64Url;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return verifiableCredential.compact;
|
|
23
|
-
}
|
|
8
|
+
return verifiableCredential.encoded;
|
|
24
9
|
}
|
|
25
10
|
function getSphereonVerifiablePresentation(verifiablePresentation) {
|
|
26
|
-
|
|
27
|
-
if (typeof verifiablePresentation === 'string') {
|
|
28
|
-
return verifiablePresentation;
|
|
29
|
-
}
|
|
30
|
-
else if (verifiablePresentation instanceof core_1.W3cJsonLdVerifiablePresentation) {
|
|
31
|
-
return core_1.JsonTransformer.toJSON(verifiablePresentation);
|
|
32
|
-
}
|
|
33
|
-
else if (verifiablePresentation instanceof core_1.W3cJwtVerifiablePresentation) {
|
|
34
|
-
return verifiablePresentation.serializedJwt;
|
|
35
|
-
}
|
|
36
|
-
else if (verifiablePresentation instanceof core_1.MdocDeviceResponse) {
|
|
37
|
-
return verifiablePresentation.base64Url;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return verifiablePresentation.compact;
|
|
41
|
-
}
|
|
11
|
+
return verifiablePresentation.encoded;
|
|
42
12
|
}
|
|
43
13
|
function getVerifiablePresentationFromSphereonWrapped(wrappedVerifiablePresentation) {
|
|
44
14
|
if (wrappedVerifiablePresentation.format === 'jwt_vp') {
|
|
@@ -56,9 +26,11 @@ function getVerifiablePresentationFromSphereonWrapped(wrappedVerifiablePresentat
|
|
|
56
26
|
const header = core_1.JsonEncoder.fromBase64(encodedHeader);
|
|
57
27
|
return {
|
|
58
28
|
compact: wrappedVerifiablePresentation.presentation.compactSdJwtVc,
|
|
29
|
+
encoded: wrappedVerifiablePresentation.presentation.compactSdJwtVc,
|
|
59
30
|
header,
|
|
60
31
|
payload: wrappedVerifiablePresentation.presentation.signedPayload,
|
|
61
32
|
prettyClaims: wrappedVerifiablePresentation.presentation.decodedPayload,
|
|
33
|
+
claimFormat: core_1.ClaimFormat.SdJwtVc,
|
|
62
34
|
};
|
|
63
35
|
}
|
|
64
36
|
else if (wrappedVerifiablePresentation.format === 'mso_mdoc') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/shared/transform.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/shared/transform.ts"],"names":[],"mappings":";;AAkBA,0EAIC;AAED,8EAIC;AAED,oGAkCC;AAzDD,yCASuB;AAEvB,SAAgB,+BAA+B,CAC7C,oBAA0C;IAE1C,OAAO,oBAAoB,CAAC,OAA0C,CAAA;AACxE,CAAC;AAED,SAAgB,iCAAiC,CAC/C,sBAA8C;IAE9C,OAAO,sBAAsB,CAAC,OAA4C,CAAA;AAC5E,CAAC;AAED,SAAgB,4CAA4C,CAC1D,6BAA4D;IAE5D,IAAI,6BAA6B,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACtD,IAAI,OAAO,6BAA6B,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/D,MAAM,IAAI,iBAAU,CAAC,sCAAsC,CAAC,CAAA;QAC9D,CAAC;QAED,OAAO,mCAA4B,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAA;IAC/F,CAAC;SAAM,IAAI,6BAA6B,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO,sBAAe,CAAC,QAAQ,CAAC,6BAA6B,CAAC,QAAQ,EAAE,sCAA+B,CAAC,CAAA;IAC1G,CAAC;SAAM,IAAI,6BAA6B,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAChE,kFAAkF;QAClF,MAAM,CAAC,aAAa,CAAC,GAAG,6BAA6B,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5F,MAAM,MAAM,GAAG,kBAAW,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;QACpD,OAAO;YACL,OAAO,EAAE,6BAA6B,CAAC,YAAY,CAAC,cAAc;YAClE,OAAO,EAAE,6BAA6B,CAAC,YAAY,CAAC,cAAc;YAClE,MAAM;YACN,OAAO,EAAE,6BAA6B,CAAC,YAAY,CAAC,aAAa;YACjE,YAAY,EAAE,6BAA6B,CAAC,YAAY,CAAC,cAAc;YACvE,WAAW,EAAE,kBAAW,CAAC,OAAO;SACf,CAAA;IACrB,CAAC;SAAM,IAAI,6BAA6B,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC/D,IAAI,OAAO,6BAA6B,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/D,MAAM,SAAS,GAAG,wBAAiB,CAAC,WAAW,CAC7C,IAAI,UAAU,CAAC,6BAA6B,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CACpE,CAAA;YACD,OAAO,yBAAkB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QACpD,CAAC;QACD,OAAO,yBAAkB,CAAC,aAAa,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAA;IACjF,CAAC;IAED,MAAM,IAAI,iBAAU,CAAC,oCAAoC,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAA;AAClG,CAAC"}
|
package/build/shared/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OpenId4VcIssuerX5c, OpenId4VcJwtIssuer
|
|
1
|
+
import type { OpenId4VcIssuerX5c, OpenId4VcJwtIssuer } from './models';
|
|
2
2
|
import type { AgentContext, DidPurpose, JwaSignatureAlgorithm, Key } from '@credo-ts/core';
|
|
3
3
|
import type { JwtIssuerWithContext as VpJwtIssuerWithContext, VerifyJwtCallback } from '@sphereon/did-auth-siop';
|
|
4
4
|
import type { DPoPJwtIssuerWithContext, CreateJwtCallback, JwtIssuer } from '@sphereon/oid4vc-common';
|
|
@@ -12,19 +12,11 @@ import type { DPoPJwtIssuerWithContext, CreateJwtCallback, JwtIssuer } from '@sp
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function getSupportedJwaSignatureAlgorithms(agentContext: AgentContext): JwaSignatureAlgorithm[];
|
|
14
14
|
export declare function getKeyFromDid(agentContext: AgentContext, didUrl: string, allowedPurposes?: DidPurpose[]): Promise<Key>;
|
|
15
|
-
|
|
16
|
-
federation?: {
|
|
17
|
-
trustedEntityIds?: string[];
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export declare function getVerifyJwtCallback(agentContext: AgentContext, options?: VerifyJwtCallbackOptions): VerifyJwtCallback;
|
|
15
|
+
export declare function getVerifyJwtCallback(agentContext: AgentContext): VerifyJwtCallback;
|
|
21
16
|
export declare function getCreateJwtCallback(agentContext: AgentContext): CreateJwtCallback<DPoPJwtIssuerWithContext | VpJwtIssuerWithContext>;
|
|
22
|
-
export declare function openIdTokenIssuerToJwtIssuer(agentContext: AgentContext, openId4VcTokenIssuer: Exclude<OpenId4VcJwtIssuer, OpenId4VcIssuerX5c
|
|
17
|
+
export declare function openIdTokenIssuerToJwtIssuer(agentContext: AgentContext, openId4VcTokenIssuer: Exclude<OpenId4VcJwtIssuer, OpenId4VcIssuerX5c> | (OpenId4VcIssuerX5c & {
|
|
23
18
|
issuer: string;
|
|
24
|
-
}) | (OpenId4VcJwtIssuerFederation & {
|
|
25
|
-
entityId: string;
|
|
26
19
|
})): Promise<JwtIssuer>;
|
|
27
20
|
export declare function getProofTypeFromKey(agentContext: AgentContext, key: Key): string;
|
|
28
21
|
export declare function addSecondsToDate(date: Date, seconds: number): Date;
|
|
29
22
|
export declare function dateToSeconds(date: Date): number;
|
|
30
|
-
export {};
|
package/build/shared/utils.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.getProofTypeFromKey = getProofTypeFromKey;
|
|
|
9
9
|
exports.addSecondsToDate = addSecondsToDate;
|
|
10
10
|
exports.dateToSeconds = dateToSeconds;
|
|
11
11
|
const core_1 = require("@credo-ts/core");
|
|
12
|
-
const core_2 = require("@openid-federation/core");
|
|
13
12
|
/**
|
|
14
13
|
* Returns the JWA Signature Algorithms that are supported by the wallet.
|
|
15
14
|
*
|
|
@@ -36,10 +35,8 @@ async function getKeyFromDid(agentContext, didUrl, allowedPurposes = ['authentic
|
|
|
36
35
|
const verificationMethod = didDocument.dereferenceKey(didUrl, allowedPurposes);
|
|
37
36
|
return (0, core_1.getKeyFromVerificationMethod)(verificationMethod);
|
|
38
37
|
}
|
|
39
|
-
function getVerifyJwtCallback(agentContext
|
|
40
|
-
const logger = agentContext.config.logger;
|
|
38
|
+
function getVerifyJwtCallback(agentContext) {
|
|
41
39
|
return async (jwtVerifier, jwt) => {
|
|
42
|
-
var _a, _b, _c, _d;
|
|
43
40
|
const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
|
|
44
41
|
if (jwtVerifier.method === 'did') {
|
|
45
42
|
const key = await getKeyFromDid(agentContext, jwtVerifier.didUrl);
|
|
@@ -47,55 +44,17 @@ function getVerifyJwtCallback(agentContext, options = {}) {
|
|
|
47
44
|
const res = await jwsService.verifyJws(agentContext, { jws: jwt.raw, jwkResolver: () => jwk });
|
|
48
45
|
return res.isValid;
|
|
49
46
|
}
|
|
50
|
-
if (jwtVerifier.method === 'x5c' || jwtVerifier.method === 'jwk') {
|
|
47
|
+
else if (jwtVerifier.method === 'x5c' || jwtVerifier.method === 'jwk') {
|
|
51
48
|
const res = await jwsService.verifyJws(agentContext, { jws: jwt.raw });
|
|
52
49
|
return res.isValid;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const trustedEntityIds = (_a = options.federation) === null || _a === void 0 ? void 0 : _a.trustedEntityIds;
|
|
57
|
-
if (!trustedEntityIds) {
|
|
58
|
-
logger.error('No trusted entity ids provided but is required for the "openid-federation" method.');
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
const validTrustChains = await (0, core_2.resolveTrustChains)({
|
|
62
|
-
entityId,
|
|
63
|
-
trustAnchorEntityIds: trustedEntityIds,
|
|
64
|
-
verifyJwtCallback: async ({ jwt, jwk }) => {
|
|
65
|
-
const res = await jwsService.verifyJws(agentContext, {
|
|
66
|
-
jws: jwt,
|
|
67
|
-
jwkResolver: () => (0, core_1.getJwkFromJson)(jwk),
|
|
68
|
-
});
|
|
69
|
-
return res.isValid;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
// When the chain is already invalid we can return false immediately
|
|
73
|
-
if (validTrustChains.length === 0) {
|
|
74
|
-
logger.error(`${entityId} is not part of a trusted federation.`);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
// Pick the first valid trust chain for validation of the leaf entity jwks
|
|
78
|
-
const { leafEntityConfiguration } = validTrustChains[0];
|
|
79
|
-
// TODO: No support yet for signed jwks and external jwks
|
|
80
|
-
const rpSigningKeys = (_d = (_c = (_b = leafEntityConfiguration === null || leafEntityConfiguration === void 0 ? void 0 : leafEntityConfiguration.metadata) === null || _b === void 0 ? void 0 : _b.openid_relying_party) === null || _c === void 0 ? void 0 : _c.jwks) === null || _d === void 0 ? void 0 : _d.keys;
|
|
81
|
-
if (!rpSigningKeys || rpSigningKeys.length === 0)
|
|
82
|
-
throw new core_1.CredoError('No rp signing keys found in the entity configuration.');
|
|
83
|
-
const res = await jwsService.verifyJws(agentContext, {
|
|
84
|
-
jws: jwt.raw,
|
|
85
|
-
jwkResolver: () => (0, core_1.getJwkFromJson)(rpSigningKeys[0]),
|
|
86
|
-
});
|
|
87
|
-
if (!res.isValid) {
|
|
88
|
-
logger.error(`${entityId} does not match the expected signing key.`);
|
|
89
|
-
}
|
|
90
|
-
// TODO: There is no check yet for the policies
|
|
91
|
-
return res.isValid;
|
|
51
|
+
else {
|
|
52
|
+
throw new Error(`Unsupported jwt verifier method: '${jwtVerifier.method}'`);
|
|
92
53
|
}
|
|
93
|
-
throw new Error(`Unsupported jwt verifier method: '${jwtVerifier.method}'`);
|
|
94
54
|
};
|
|
95
55
|
}
|
|
96
56
|
function getCreateJwtCallback(agentContext) {
|
|
97
57
|
return async (jwtIssuer, jwt) => {
|
|
98
|
-
var _a;
|
|
99
58
|
const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
|
|
100
59
|
if (jwtIssuer.method === 'did') {
|
|
101
60
|
const key = await getKeyFromDid(agentContext, jwtIssuer.didUrl);
|
|
@@ -106,7 +65,7 @@ function getCreateJwtCallback(agentContext) {
|
|
|
106
65
|
});
|
|
107
66
|
return jws;
|
|
108
67
|
}
|
|
109
|
-
if (jwtIssuer.method === 'jwk') {
|
|
68
|
+
else if (jwtIssuer.method === 'jwk') {
|
|
110
69
|
if (!jwtIssuer.jwk.kty) {
|
|
111
70
|
throw new core_1.CredoError('Missing required key type (kty) in the jwk.');
|
|
112
71
|
}
|
|
@@ -119,7 +78,7 @@ function getCreateJwtCallback(agentContext) {
|
|
|
119
78
|
});
|
|
120
79
|
return jws;
|
|
121
80
|
}
|
|
122
|
-
if (jwtIssuer.method === 'x5c') {
|
|
81
|
+
else if (jwtIssuer.method === 'x5c') {
|
|
123
82
|
const leafCertificate = core_1.X509Service.getLeafCertificate(agentContext, { certificateChain: jwtIssuer.x5c });
|
|
124
83
|
const jws = await jwsService.createJwsCompact(agentContext, {
|
|
125
84
|
protectedHeaderOptions: Object.assign(Object.assign({}, jwt.header), { alg: jwtIssuer.alg, jwk: undefined }),
|
|
@@ -128,47 +87,6 @@ function getCreateJwtCallback(agentContext) {
|
|
|
128
87
|
});
|
|
129
88
|
return jws;
|
|
130
89
|
}
|
|
131
|
-
if (jwtIssuer.method === 'custom') {
|
|
132
|
-
// TODO: This could be used as the issuer and verifier. Based on that we need to search for a jwk in the entity configuration
|
|
133
|
-
const { options } = jwtIssuer;
|
|
134
|
-
if (!options)
|
|
135
|
-
throw new core_1.CredoError(`Custom jwtIssuer must have options defined.`);
|
|
136
|
-
if (!options.method)
|
|
137
|
-
throw new core_1.CredoError(`Custom jwtIssuer's options must have a 'method' property defined.`);
|
|
138
|
-
if (options.method !== 'openid-federation')
|
|
139
|
-
throw new core_1.CredoError(`Custom jwtIssuer's options 'method' property must be 'openid-federation' when using the 'custom' method.`);
|
|
140
|
-
if (!options.entityId)
|
|
141
|
-
throw new core_1.CredoError(`Custom jwtIssuer must have entityId defined.`);
|
|
142
|
-
if (typeof options.entityId !== 'string')
|
|
143
|
-
throw new core_1.CredoError(`Custom jwtIssuer's entityId must be a string.`);
|
|
144
|
-
const { entityId } = options;
|
|
145
|
-
const entityConfiguration = await (0, core_2.fetchEntityConfiguration)({
|
|
146
|
-
entityId,
|
|
147
|
-
verifyJwtCallback: async ({ jwt, jwk }) => {
|
|
148
|
-
const res = await jwsService.verifyJws(agentContext, { jws: jwt, jwkResolver: () => (0, core_1.getJwkFromJson)(jwk) });
|
|
149
|
-
return res.isValid;
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
// TODO: Not really sure if this is also used for the issuer so if so we need to change this logic. But currently it's not possible to specify a issuer method with issuance so I think it's fine.
|
|
153
|
-
// NOTE: Hardcoded part for the verifier
|
|
154
|
-
const openIdRelyingParty = (_a = entityConfiguration.metadata) === null || _a === void 0 ? void 0 : _a.openid_relying_party;
|
|
155
|
-
if (!openIdRelyingParty)
|
|
156
|
-
throw new core_1.CredoError('No openid-relying-party found in the entity configuration.');
|
|
157
|
-
// NOTE: No support for signed jwks and external jwks
|
|
158
|
-
const jwks = openIdRelyingParty.jwks;
|
|
159
|
-
if (!jwks)
|
|
160
|
-
throw new core_1.CredoError('No jwks found in the openid-relying-party.');
|
|
161
|
-
// TODO: Not 100% sure what key to pick here I think the one that matches the kid in the jwt header of the entity configuration or we should pass a alg and pick a jwk based on that?
|
|
162
|
-
const jwk = (0, core_1.getJwkFromJson)(jwks.keys[0]);
|
|
163
|
-
// TODO: This gives a weird error when the private key is not available in the wallet so we should handle that better
|
|
164
|
-
const jws = await jwsService.createJwsCompact(agentContext, {
|
|
165
|
-
protectedHeaderOptions: Object.assign(Object.assign({}, jwt.header), { jwk, alg: jwk.supportedSignatureAlgorithms[0] }),
|
|
166
|
-
payload: core_1.JwtPayload.fromJson(jwt.payload),
|
|
167
|
-
key: jwk.key,
|
|
168
|
-
});
|
|
169
|
-
return jws;
|
|
170
|
-
}
|
|
171
|
-
// @ts-expect-error - All methods are supported currently so there is no unsupported method anymore
|
|
172
90
|
throw new Error(`Unsupported jwt issuer method '${jwtIssuer.method}'`);
|
|
173
91
|
};
|
|
174
92
|
}
|
|
@@ -185,7 +103,7 @@ async function openIdTokenIssuerToJwtIssuer(agentContext, openId4VcTokenIssuer)
|
|
|
185
103
|
alg,
|
|
186
104
|
};
|
|
187
105
|
}
|
|
188
|
-
if (openId4VcTokenIssuer.method === 'x5c') {
|
|
106
|
+
else if (openId4VcTokenIssuer.method === 'x5c') {
|
|
189
107
|
const leafCertificate = core_1.X509Service.getLeafCertificate(agentContext, {
|
|
190
108
|
certificateChain: openId4VcTokenIssuer.x5c,
|
|
191
109
|
});
|
|
@@ -210,23 +128,13 @@ async function openIdTokenIssuerToJwtIssuer(agentContext, openId4VcTokenIssuer)
|
|
|
210
128
|
}
|
|
211
129
|
return Object.assign(Object.assign({}, openId4VcTokenIssuer), { alg });
|
|
212
130
|
}
|
|
213
|
-
if (openId4VcTokenIssuer.method === 'jwk') {
|
|
131
|
+
else if (openId4VcTokenIssuer.method === 'jwk') {
|
|
214
132
|
const alg = openId4VcTokenIssuer.jwk.supportedSignatureAlgorithms[0];
|
|
215
133
|
if (!alg) {
|
|
216
134
|
throw new core_1.CredoError(`No supported signature algorithms for key type: '${openId4VcTokenIssuer.jwk.keyType}'`);
|
|
217
135
|
}
|
|
218
136
|
return Object.assign(Object.assign({}, openId4VcTokenIssuer), { jwk: openId4VcTokenIssuer.jwk.toJson(), alg });
|
|
219
137
|
}
|
|
220
|
-
if (openId4VcTokenIssuer.method === 'openid-federation') {
|
|
221
|
-
// TODO: Not sure what we want here if we need to add a new type to the sphereon library or that we can do it with the custom issuer
|
|
222
|
-
return {
|
|
223
|
-
method: 'custom',
|
|
224
|
-
options: {
|
|
225
|
-
method: 'openid-federation',
|
|
226
|
-
entityId: openId4VcTokenIssuer.entityId,
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
138
|
throw new core_1.CredoError(`Unsupported jwt issuer method '${openId4VcTokenIssuer.method}'`);
|
|
231
139
|
}
|
|
232
140
|
function getProofTypeFromKey(agentContext, key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":";;AA2BA,gFAaC;AAED,sCAUC;AAED,oDAgBC;AAED,oDA0CC;AAED,oEAkEC;AAED,kDASC;AAED,4CAEC;AAED,sCAEC;AApMD,yCAYuB;AAEvB;;;;;;;GAOG;AACH,SAAgB,kCAAkC,CAAC,YAA0B;IAC3E,MAAM,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAA;IAE/D,4EAA4E;IAC5E,MAAM,+BAA+B,GAAG,iBAAiB;QACvD,yDAAyD;SACxD,GAAG,CAAC,6BAAsB,CAAC;QAC5B,kCAAkC;SACjC,MAAM,CAAC,CAAC,QAAQ,EAAmD,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC;QAC9F,oEAAoE;SACnE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAA;IAE/D,OAAO,+BAA+B,CAAA;AACxC,CAAC;AAEM,KAAK,UAAU,aAAa,CACjC,YAA0B,EAC1B,MAAc,EACd,kBAAgC,CAAC,gBAAgB,CAAC;IAElD,MAAM,OAAO,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,cAAO,CAAC,CAAA;IAC/D,MAAM,WAAW,GAAG,M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
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@credo-ts/openid4vc",
|
|
3
3
|
"main": "build/index",
|
|
4
4
|
"types": "build/index",
|
|
5
|
-
"version": "0.6.0-pr-
|
|
5
|
+
"version": "0.6.0-pr-2100-20241125134343",
|
|
6
6
|
"files": [
|
|
7
7
|
"build"
|
|
8
8
|
],
|
|
@@ -17,16 +17,14 @@
|
|
|
17
17
|
"directory": "packages/openid4vc"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@sphereon/did-auth-siop": "
|
|
20
|
+
"@sphereon/did-auth-siop": "https://gitpkg.vercel.app/animo/OID4VC/packages/siop-oid4vp?funke",
|
|
21
21
|
"@sphereon/oid4vc-common": "0.16.1-fix.173",
|
|
22
22
|
"@sphereon/ssi-types": "0.30.2-next.135",
|
|
23
|
-
"@openid-federation/core": "0.1.1-alpha.13",
|
|
24
23
|
"class-transformer": "^0.5.1",
|
|
25
24
|
"rxjs": "^7.8.0",
|
|
26
|
-
"zod": "^3.23.8",
|
|
27
25
|
"@animo-id/oid4vci": "0.1.4",
|
|
28
26
|
"@animo-id/oauth2": "0.1.4",
|
|
29
|
-
"@credo-ts/core": "0.6.0-pr-
|
|
27
|
+
"@credo-ts/core": "0.6.0-pr-2100-20241125134343"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@types/express": "^4.17.21",
|
|
@@ -34,7 +32,7 @@
|
|
|
34
32
|
"nock": "^14.0.0-beta.16",
|
|
35
33
|
"rimraf": "^4.4.0",
|
|
36
34
|
"typescript": "~5.5.2",
|
|
37
|
-
"@credo-ts/tenants": "0.6.0-pr-
|
|
35
|
+
"@credo-ts/tenants": "0.6.0-pr-2100-20241125134343"
|
|
38
36
|
},
|
|
39
37
|
"scripts": {
|
|
40
38
|
"build": "pnpm run clean && pnpm run compile",
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureFederationEndpoint = configureFederationEndpoint;
|
|
4
|
-
const core_1 = require("@credo-ts/core");
|
|
5
|
-
const core_2 = require("@openid-federation/core");
|
|
6
|
-
const router_1 = require("../../shared/router");
|
|
7
|
-
// TODO: It's also possible that the issuer and the verifier can have the same openid-federation endpoint. In that case we need to combine them.
|
|
8
|
-
function configureFederationEndpoint(router) {
|
|
9
|
-
// TODO: this whole result needs to be cached and the ttl should be the expires of this node
|
|
10
|
-
router.get('/.well-known/openid-federation', async (request, response, next) => {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
const { agentContext, issuer } = (0, router_1.getRequestContext)(request);
|
|
13
|
-
try {
|
|
14
|
-
// TODO: Should be only created once per issuer and be used between instances
|
|
15
|
-
const federationKey = await agentContext.wallet.createKey({
|
|
16
|
-
keyType: core_1.KeyType.Ed25519,
|
|
17
|
-
});
|
|
18
|
-
const now = new Date();
|
|
19
|
-
const expires = new Date(now.getTime() + 1000 * 60 * 60 * 24); // 1 day from now
|
|
20
|
-
// TODO: We need to generate a key and always use that for the entity configuration
|
|
21
|
-
const jwk = (0, core_1.getJwkFromKey)(federationKey);
|
|
22
|
-
const kid = federationKey.fingerprint;
|
|
23
|
-
const alg = jwk.supportedSignatureAlgorithms[0];
|
|
24
|
-
const issuerDisplay = (_a = issuer.display) === null || _a === void 0 ? void 0 : _a[0];
|
|
25
|
-
const accessTokenSigningKey = core_1.Key.fromFingerprint(issuer.accessTokenPublicKeyFingerprint);
|
|
26
|
-
const entityConfiguration = await (0, core_2.createEntityConfiguration)({
|
|
27
|
-
claims: {
|
|
28
|
-
sub: issuer.issuerId,
|
|
29
|
-
iss: issuer.issuerId,
|
|
30
|
-
iat: now,
|
|
31
|
-
exp: expires,
|
|
32
|
-
jwks: {
|
|
33
|
-
keys: [Object.assign({ kid, alg }, jwk.toJson())],
|
|
34
|
-
},
|
|
35
|
-
metadata: {
|
|
36
|
-
federation_entity: issuerDisplay
|
|
37
|
-
? {
|
|
38
|
-
organization_name: issuerDisplay.name,
|
|
39
|
-
logo_uri: (_b = issuerDisplay.logo) === null || _b === void 0 ? void 0 : _b.uri,
|
|
40
|
-
}
|
|
41
|
-
: undefined,
|
|
42
|
-
openid_provider: {
|
|
43
|
-
// TODO: The type isn't correct yet down the line so that needs to be updated before
|
|
44
|
-
// credential_issuer: issuerMetadata.issuerUrl,
|
|
45
|
-
// token_endpoint: issuerMetadata.tokenEndpoint,
|
|
46
|
-
// credential_endpoint: issuerMetadata.credentialEndpoint,
|
|
47
|
-
// authorization_server: issuerMetadata.authorizationServer,
|
|
48
|
-
// authorization_servers: issuerMetadata.authorizationServer
|
|
49
|
-
// ? [issuerMetadata.authorizationServer]
|
|
50
|
-
// : undefined,
|
|
51
|
-
// credentials_supported: issuerMetadata.credentialsSupported,
|
|
52
|
-
// credential_configurations_supported: issuerMetadata.credentialConfigurationsSupported,
|
|
53
|
-
// display: issuerMetadata.issuerDisplay,
|
|
54
|
-
// dpop_signing_alg_values_supported: issuerMetadata.dpopSigningAlgValuesSupported,
|
|
55
|
-
client_registration_types_supported: ['automatic'],
|
|
56
|
-
jwks: {
|
|
57
|
-
keys: [
|
|
58
|
-
Object.assign({
|
|
59
|
-
// TODO: Not 100% sure if this is the right key that we want to expose here or a different one
|
|
60
|
-
kid: accessTokenSigningKey.fingerprint }, (0, core_1.getJwkFromKey)(accessTokenSigningKey).toJson()),
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
header: {
|
|
67
|
-
kid,
|
|
68
|
-
alg,
|
|
69
|
-
typ: 'entity-statement+jwt',
|
|
70
|
-
},
|
|
71
|
-
signJwtCallback: ({ toBeSigned }) => agentContext.wallet.sign({
|
|
72
|
-
data: toBeSigned,
|
|
73
|
-
key: federationKey,
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
response.writeHead(200, { 'Content-Type': 'application/entity-statement+jwt' }).end(entityConfiguration);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
agentContext.config.logger.error('Failed to create entity configuration', {
|
|
80
|
-
error,
|
|
81
|
-
});
|
|
82
|
-
(0, router_1.sendErrorResponse)(response, next, agentContext.config.logger, 500, 'invalid_request', error);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// NOTE: if we don't call next, the agentContext session handler will NOT be called
|
|
86
|
-
next();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=federationEndpoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"federationEndpoint.js","sourceRoot":"","sources":["../../../src/openid4vc-issuer/router/federationEndpoint.ts"],"names":[],"mappings":";;AAWA,kEA6FC;AApGD,yCAA4D;AAC5D,kDAAmE;AAEnE,gDAA0E;AAE1E,gJAAgJ;AAEhJ,SAAgB,2BAA2B,CAAC,MAAc;IACxD,4FAA4F;IAE5F,MAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE,KAAK,EAAE,OAAiC,EAAE,QAAkB,EAAE,IAAI,EAAE,EAAE;;QACjH,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAA;QAE3D,IAAI,CAAC;YACH,6EAA6E;YAC7E,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;gBACxD,OAAO,EAAE,cAAO,CAAC,OAAO;aACzB,CAAC,CAAA;YAEF,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;YACtB,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA,CAAC,iBAAiB;YAE/E,mFAAmF;YAEnF,MAAM,GAAG,GAAG,IAAA,oBAAa,EAAC,aAAa,CAAC,CAAA;YAExC,MAAM,GAAG,GAAG,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