@credo-ts/openid4vc 0.6.0-pr-2094-20241124155338 → 0.6.0-pr-2100-20241124170219
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,118 +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 did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
7
|
-
const router_1 = require("../../shared/router");
|
|
8
|
-
const OpenId4VcSiopVerifierService_1 = require("../OpenId4VcSiopVerifierService");
|
|
9
|
-
const OpenId4VcVerifierModuleConfig_1 = require("../OpenId4VcVerifierModuleConfig");
|
|
10
|
-
// TODO: Add types but this function is originally from the @
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
const createRPRegistrationMetadataPayload = (opts) => {
|
|
13
|
-
const rpRegistrationMetadataPayload = {
|
|
14
|
-
id_token_signing_alg_values_supported: opts.idTokenSigningAlgValuesSupported,
|
|
15
|
-
request_object_signing_alg_values_supported: opts.requestObjectSigningAlgValuesSupported,
|
|
16
|
-
response_types_supported: opts.responseTypesSupported,
|
|
17
|
-
scopes_supported: opts.scopesSupported,
|
|
18
|
-
subject_types_supported: opts.subjectTypesSupported,
|
|
19
|
-
subject_syntax_types_supported: opts.subject_syntax_types_supported || ['did:web:', 'did:ion:'],
|
|
20
|
-
vp_formats: opts.vpFormatsSupported,
|
|
21
|
-
client_name: opts.clientName,
|
|
22
|
-
logo_uri: opts.logo_uri,
|
|
23
|
-
tos_uri: opts.tos_uri,
|
|
24
|
-
client_purpose: opts.clientPurpose,
|
|
25
|
-
client_id: opts.client_id,
|
|
26
|
-
};
|
|
27
|
-
const languageTagEnabledFieldsNamesMapping = new Map();
|
|
28
|
-
languageTagEnabledFieldsNamesMapping.set('clientName', 'client_name');
|
|
29
|
-
languageTagEnabledFieldsNamesMapping.set('clientPurpose', 'client_purpose');
|
|
30
|
-
// TODO: Do we need this?
|
|
31
|
-
const languageTaggedFields = did_auth_siop_1.LanguageTagUtils.getLanguageTaggedPropertiesMapped(opts, languageTagEnabledFieldsNamesMapping);
|
|
32
|
-
languageTaggedFields.forEach((value, key) => {
|
|
33
|
-
const _key = key;
|
|
34
|
-
rpRegistrationMetadataPayload[_key] = value;
|
|
35
|
-
});
|
|
36
|
-
return (0, did_auth_siop_1.removeNullUndefined)(rpRegistrationMetadataPayload);
|
|
37
|
-
};
|
|
38
|
-
function configureFederationEndpoint(router) {
|
|
39
|
-
// TODO: this whole result needs to be cached and the ttl should be the expires of this node
|
|
40
|
-
// TODO: This will not work for multiple instances so we have to save it in the database.
|
|
41
|
-
const federationKeyMapping = new Map();
|
|
42
|
-
const rpSigningKeyMapping = new Map();
|
|
43
|
-
router.get('/.well-known/openid-federation', async (request, response, next) => {
|
|
44
|
-
const { agentContext, verifier } = (0, router_1.getRequestContext)(request);
|
|
45
|
-
const verifierService = agentContext.dependencyManager.resolve(OpenId4VcSiopVerifierService_1.OpenId4VcSiopVerifierService);
|
|
46
|
-
const verifierConfig = agentContext.dependencyManager.resolve(OpenId4VcVerifierModuleConfig_1.OpenId4VcVerifierModuleConfig);
|
|
47
|
-
try {
|
|
48
|
-
let federationKey = federationKeyMapping.get(verifier.verifierId);
|
|
49
|
-
if (!federationKey) {
|
|
50
|
-
federationKey = await agentContext.wallet.createKey({
|
|
51
|
-
keyType: core_1.KeyType.Ed25519,
|
|
52
|
-
});
|
|
53
|
-
federationKeyMapping.set(verifier.verifierId, federationKey);
|
|
54
|
-
}
|
|
55
|
-
let rpSigningKey = rpSigningKeyMapping.get(verifier.verifierId);
|
|
56
|
-
if (!rpSigningKey) {
|
|
57
|
-
rpSigningKey = await agentContext.wallet.createKey({
|
|
58
|
-
keyType: core_1.KeyType.Ed25519,
|
|
59
|
-
});
|
|
60
|
-
rpSigningKeyMapping.set(verifier.verifierId, rpSigningKey);
|
|
61
|
-
}
|
|
62
|
-
const relyingParty = await verifierService.getRelyingParty(agentContext, verifier, {
|
|
63
|
-
clientId: verifierConfig.baseUrl,
|
|
64
|
-
clientIdScheme: 'entity_id',
|
|
65
|
-
authorizationResponseUrl: `${verifierConfig.baseUrl}/siop/${verifier.verifierId}/authorize`,
|
|
66
|
-
});
|
|
67
|
-
const verifierEntityId = `${verifierConfig.baseUrl}/${verifier.verifierId}`;
|
|
68
|
-
const rpMetadata = createRPRegistrationMetadataPayload(relyingParty.createRequestOptions.clientMetadata);
|
|
69
|
-
// TODO: We also need to cache the entity configuration until it expires
|
|
70
|
-
const now = new Date();
|
|
71
|
-
// TODO: We also need to check if the x509 certificate is still valid until this expires
|
|
72
|
-
const expires = new Date(now.getTime() + 1000 * 60 * 60 * 24); // 1 day
|
|
73
|
-
const jwk = (0, core_1.getJwkFromKey)(federationKey);
|
|
74
|
-
const alg = jwk.supportedSignatureAlgorithms[0];
|
|
75
|
-
const kid = federationKey.fingerprint;
|
|
76
|
-
const entityConfiguration = await (0, core_2.createEntityConfiguration)({
|
|
77
|
-
header: {
|
|
78
|
-
kid,
|
|
79
|
-
alg,
|
|
80
|
-
typ: 'entity-statement+jwt',
|
|
81
|
-
},
|
|
82
|
-
claims: {
|
|
83
|
-
sub: verifierEntityId,
|
|
84
|
-
iss: verifierEntityId,
|
|
85
|
-
iat: now,
|
|
86
|
-
exp: expires,
|
|
87
|
-
jwks: {
|
|
88
|
-
keys: [Object.assign({ kid, alg }, jwk.toJson())],
|
|
89
|
-
},
|
|
90
|
-
metadata: {
|
|
91
|
-
federation_entity: {
|
|
92
|
-
organization_name: rpMetadata.client_name,
|
|
93
|
-
logo_uri: rpMetadata.logo_uri,
|
|
94
|
-
},
|
|
95
|
-
openid_relying_party: Object.assign(Object.assign({}, rpMetadata), { jwks: {
|
|
96
|
-
keys: [Object.assign({ kid: rpSigningKey.fingerprint, alg }, (0, core_1.getJwkFromKey)(rpSigningKey).toJson())],
|
|
97
|
-
}, client_registration_types: ['automatic'] }),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
signJwtCallback: ({ toBeSigned }) => agentContext.wallet.sign({
|
|
101
|
-
data: toBeSigned,
|
|
102
|
-
key: federationKey,
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
response.writeHead(200, { 'Content-Type': 'application/entity-statement+jwt' }).end(entityConfiguration);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
agentContext.config.logger.error('Failed to create entity configuration', {
|
|
109
|
-
error,
|
|
110
|
-
});
|
|
111
|
-
(0, router_1.sendErrorResponse)(response, next, agentContext.config.logger, 500, 'invalid_request', error);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// NOTE: if we don't call next, the agentContext session handler will NOT be called
|
|
115
|
-
next();
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=federationEndpoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"federationEndpoint.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/federationEndpoint.ts"],"names":[],"mappings":";;AAiDA,kEAkGC;AA9ID,yCAAuD;AACvD,kDAAmE;AACnE,2DAA+E;AAE/E,gDAA0E;AAC1E,kFAA8E;AAC9E,oFAAgF;AAEhF,6DAA6D;AAC7D,8DAA8D;AAC9D,MAAM,mCAAmC,GAAG,CA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