@credo-ts/openid4vc 0.4.1-alpha.157
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/LICENSE +202 -0
- package/README.md +31 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +83 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.js +115 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.d.ts +13 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.js +30 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +33 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.js +512 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +153 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +11 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +18 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +228 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +1 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +43 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js +3 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js.map +1 -0
- package/build/openid4vc-holder/index.d.ts +6 -0
- package/build/openid4vc-holder/index.js +23 -0
- package/build/openid4vc-holder/index.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.d.ts +9 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js +14 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +60 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +106 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.d.ts +13 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js +8 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.ts +21 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +106 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +41 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +46 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +54 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js +425 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +88 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js +3 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js.map +1 -0
- package/build/openid4vc-issuer/index.d.ts +8 -0
- package/build/openid4vc-issuer/index.js +27 -0
- package/build/openid4vc-issuer/index.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.d.ts +18 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.js +99 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.d.ts +21 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.js +182 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.d.ts +17 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.js +68 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +84 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +58 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.d.ts +5 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js +29 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.ts +37 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +31 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.ts +8 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js +35 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js.map +1 -0
- package/build/openid4vc-issuer/repository/index.d.ts +4 -0
- package/build/openid4vc-issuer/repository/index.js +21 -0
- package/build/openid4vc-issuer/repository/index.js.map +1 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.d.ts +34 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js +111 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.d.ts +16 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.js +44 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.d.ts +11 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js +61 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/index.d.ts +5 -0
- package/build/openid4vc-issuer/router/index.js +12 -0
- package/build/openid4vc-issuer/router/index.js.map +1 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.d.ts +2 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.js +30 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/requestContext.d.ts +5 -0
- package/build/openid4vc-issuer/router/requestContext.js +3 -0
- package/build/openid4vc-issuer/router/requestContext.js.map +1 -0
- package/build/openid4vc-issuer/router/verifyAccessToken.d.ts +3 -0
- package/build/openid4vc-issuer/router/verifyAccessToken.js +33 -0
- package/build/openid4vc-issuer/router/verifyAccessToken.js.map +1 -0
- package/build/openid4vc-issuer/util/credentialRequest.d.ts +5 -0
- package/build/openid4vc-issuer/util/credentialRequest.js +18 -0
- package/build/openid4vc-issuer/util/credentialRequest.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +43 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +357 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +45 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js +3 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.d.ts +6 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js +11 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +60 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +102 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.d.ts +13 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js +8 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.ts +21 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +103 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +31 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +28 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -0
- package/build/openid4vc-verifier/index.d.ts +8 -0
- package/build/openid4vc-verifier/index.js +25 -0
- package/build/openid4vc-verifier/index.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.d.ts +50 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js +229 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.d.ts +19 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js +146 -0
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.ts +61 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js +45 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.d.ts +5 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js +29 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.ts +26 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js +28 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.ts +8 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js +35 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js.map +1 -0
- package/build/openid4vc-verifier/repository/index.d.ts +4 -0
- package/build/openid4vc-verifier/repository/index.js +21 -0
- package/build/openid4vc-verifier/repository/index.js.map +1 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.d.ts +11 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.js +37 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.d.ts +11 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js +65 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js.map +1 -0
- package/build/openid4vc-verifier/router/index.d.ts +2 -0
- package/build/openid4vc-verifier/router/index.js +6 -0
- package/build/openid4vc-verifier/router/index.js.map +1 -0
- package/build/openid4vc-verifier/router/requestContext.d.ts +5 -0
- package/build/openid4vc-verifier/router/requestContext.js +3 -0
- package/build/openid4vc-verifier/router/requestContext.js.map +1 -0
- package/build/shared/index.d.ts +2 -0
- package/build/shared/index.js +19 -0
- package/build/shared/index.js.map +1 -0
- package/build/shared/issuerMetadataUtils.d.ts +14 -0
- package/build/shared/issuerMetadataUtils.js +69 -0
- package/build/shared/issuerMetadataUtils.js.map +1 -0
- package/build/shared/models/CredentialHolderBinding.d.ts +10 -0
- package/build/shared/models/CredentialHolderBinding.js +3 -0
- package/build/shared/models/CredentialHolderBinding.js.map +1 -0
- package/build/shared/models/OpenId4VcJwtIssuer.d.ts +6 -0
- package/build/shared/models/OpenId4VcJwtIssuer.js +3 -0
- package/build/shared/models/OpenId4VcJwtIssuer.js.map +1 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.d.ts +6 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js +11 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js.map +1 -0
- package/build/shared/models/index.d.ts +21 -0
- package/build/shared/models/index.js +20 -0
- package/build/shared/models/index.js.map +1 -0
- package/build/shared/router/context.d.ts +10 -0
- package/build/shared/router/context.js +22 -0
- package/build/shared/router/context.js.map +1 -0
- package/build/shared/router/express.d.ts +2 -0
- package/build/shared/router/express.js +16 -0
- package/build/shared/router/express.js.map +1 -0
- package/build/shared/router/index.d.ts +3 -0
- package/build/shared/router/index.js +20 -0
- package/build/shared/router/index.js.map +1 -0
- package/build/shared/router/tenants.d.ts +13 -0
- package/build/shared/router/tenants.js +50 -0
- package/build/shared/router/tenants.js.map +1 -0
- package/build/shared/transform.d.ts +5 -0
- package/build/shared/transform.js +61 -0
- package/build/shared/transform.js.map +1 -0
- package/build/shared/utils.d.ts +21 -0
- package/build/shared/utils.js +85 -0
- package/build/shared/utils.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storeActorIdForContextCorrelationId = exports.getAgentContextForActorId = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const OPENID4VC_ACTOR_IDS_METADATA_KEY = '_openid4vc/openId4VcActorIds';
|
|
6
|
+
async function getAgentContextForActorId(rootAgentContext, actorId) {
|
|
7
|
+
// Check if multi-tenancy is enabled, and if so find the associated multi-tenant record
|
|
8
|
+
// This is a bit hacky as it uses the tenants module to store the openid4vc actor id
|
|
9
|
+
// but this way we don't have to expose the contextCorrelationId in the openid metadata
|
|
10
|
+
const tenantsApi = (0, core_1.getApiForModuleByName)(rootAgentContext, 'TenantsModule');
|
|
11
|
+
if (tenantsApi) {
|
|
12
|
+
const [tenant] = await tenantsApi.findTenantsByQuery({
|
|
13
|
+
[OPENID4VC_ACTOR_IDS_METADATA_KEY]: [actorId],
|
|
14
|
+
});
|
|
15
|
+
if (tenant) {
|
|
16
|
+
const agentContextProvider = rootAgentContext.dependencyManager.resolve(core_1.InjectionSymbols.AgentContextProvider);
|
|
17
|
+
return agentContextProvider.getAgentContextForContextCorrelationId(tenant.id);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return rootAgentContext;
|
|
21
|
+
}
|
|
22
|
+
exports.getAgentContextForActorId = getAgentContextForActorId;
|
|
23
|
+
/**
|
|
24
|
+
* Store the actor id associated with a context correlation id. If multi-tenancy is not used
|
|
25
|
+
* this method won't do anything as we can just use the actor from the default context. However
|
|
26
|
+
* if multi-tenancy is used, we will store the actor id in the tenant record metadata so it can
|
|
27
|
+
* be queried when a request comes in for the specific actor id.
|
|
28
|
+
*
|
|
29
|
+
* The reason for doing this is that we don't want to expose the context correlation id in the
|
|
30
|
+
* actor metadata url, as it is then possible to see exactly which actors are registered under
|
|
31
|
+
* the same agent.
|
|
32
|
+
*/
|
|
33
|
+
async function storeActorIdForContextCorrelationId(agentContext, actorId) {
|
|
34
|
+
var _a;
|
|
35
|
+
// It's kind of hacky, but we add support for the tenants module specifically here to map an actorId to
|
|
36
|
+
// a specific tenant. Otherwise we have to expose /:contextCorrelationId/:actorId in all the public URLs
|
|
37
|
+
// which is of course not so nice.
|
|
38
|
+
const tenantsApi = (0, core_1.getApiForModuleByName)(agentContext, 'TenantsModule');
|
|
39
|
+
// We don't want to query the tenant record if the current context is the root context
|
|
40
|
+
if (tenantsApi && tenantsApi.rootAgentContext.contextCorrelationId !== agentContext.contextCorrelationId) {
|
|
41
|
+
const tenantRecord = await tenantsApi.getTenantById(agentContext.contextCorrelationId);
|
|
42
|
+
const currentOpenId4VcActorIds = (_a = tenantRecord.metadata.get(OPENID4VC_ACTOR_IDS_METADATA_KEY)) !== null && _a !== void 0 ? _a : [];
|
|
43
|
+
const openId4VcActorIds = [...currentOpenId4VcActorIds, actorId];
|
|
44
|
+
tenantRecord.metadata.set(OPENID4VC_ACTOR_IDS_METADATA_KEY, openId4VcActorIds);
|
|
45
|
+
tenantRecord.setTag(OPENID4VC_ACTOR_IDS_METADATA_KEY, openId4VcActorIds);
|
|
46
|
+
await tenantsApi.updateTenant(tenantRecord);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.storeActorIdForContextCorrelationId = storeActorIdForContextCorrelationId;
|
|
50
|
+
//# sourceMappingURL=tenants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenants.js","sourceRoot":"","sources":["../../../src/shared/router/tenants.ts"],"names":[],"mappings":";;;AAGA,yCAAwE;AAExE,MAAM,gCAAgC,GAAG,8BAA8B,CAAA;AAEhE,KAAK,UAAU,yBAAyB,CAAC,gBAA8B,EAAE,OAAe;IAC7F,uFAAuF;IACvF,oFAAoF;IACpF,uFAAuF;IACvF,MAAM,UAAU,GAAG,IAAA,4BAAqB,EAAgB,gBAAgB,EAAE,eAAe,CAAC,CAAA;IAC1F,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;YACnD,CAAC,gCAAgC,CAAC,EAAE,CAAC,OAAO,CAAC;SAC9C,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE;YACV,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CACrE,uBAAgB,CAAC,oBAAoB,CACtC,CAAA;YACD,OAAO,oBAAoB,CAAC,sCAAsC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;SAC9E;KACF;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAnBD,8DAmBC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,mCAAmC,CAAC,YAA0B,EAAE,OAAe;;IACnG,uGAAuG;IACvG,wGAAwG;IACxG,kCAAkC;IAClC,MAAM,UAAU,GAAG,IAAA,4BAAqB,EAAgB,YAAY,EAAE,eAAe,CAAC,CAAA;IAEtF,sFAAsF;IACtF,IAAI,UAAU,IAAI,UAAU,CAAC,gBAAgB,CAAC,oBAAoB,KAAK,YAAY,CAAC,oBAAoB,EAAE;QACxG,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAA;QAEtF,MAAM,wBAAwB,GAAG,MAAA,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAW,gCAAgC,CAAC,mCAAI,EAAE,CAAA;QAC5G,MAAM,iBAAiB,GAAG,CAAC,GAAG,wBAAwB,EAAE,OAAO,CAAC,CAAA;QAEhE,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAA;QAC9E,YAAY,CAAC,MAAM,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAA;QACxE,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;KAC5C;AACH,CAAC;AAjBD,kFAiBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { VerifiablePresentation, VerifiableCredential } from '@credo-ts/core';
|
|
2
|
+
import type { W3CVerifiableCredential as SphereonW3cVerifiableCredential, W3CVerifiablePresentation as SphereonW3cVerifiablePresentation, CompactSdJwtVc as SphereonCompactSdJwtVc, WrappedVerifiablePresentation } from '@sphereon/ssi-types';
|
|
3
|
+
export declare function getSphereonVerifiableCredential(verifiableCredential: VerifiableCredential): SphereonW3cVerifiableCredential | SphereonCompactSdJwtVc;
|
|
4
|
+
export declare function getSphereonVerifiablePresentation(verifiablePresentation: VerifiablePresentation): SphereonW3cVerifiablePresentation | SphereonCompactSdJwtVc;
|
|
5
|
+
export declare function getVerifiablePresentationFromSphereonWrapped(wrappedVerifiablePresentation: WrappedVerifiablePresentation): VerifiablePresentation;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVerifiablePresentationFromSphereonWrapped = exports.getSphereonVerifiablePresentation = exports.getSphereonVerifiableCredential = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
function getSphereonVerifiableCredential(verifiableCredential) {
|
|
6
|
+
// encoded sd-jwt or jwt
|
|
7
|
+
if (typeof verifiableCredential === 'string') {
|
|
8
|
+
return verifiableCredential;
|
|
9
|
+
}
|
|
10
|
+
else if (verifiableCredential instanceof core_1.W3cJsonLdVerifiableCredential) {
|
|
11
|
+
return core_1.JsonTransformer.toJSON(verifiableCredential);
|
|
12
|
+
}
|
|
13
|
+
else if (verifiableCredential instanceof core_1.W3cJwtVerifiableCredential) {
|
|
14
|
+
return verifiableCredential.serializedJwt;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return verifiableCredential.compact;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.getSphereonVerifiableCredential = getSphereonVerifiableCredential;
|
|
21
|
+
function getSphereonVerifiablePresentation(verifiablePresentation) {
|
|
22
|
+
// encoded sd-jwt or jwt
|
|
23
|
+
if (typeof verifiablePresentation === 'string') {
|
|
24
|
+
return verifiablePresentation;
|
|
25
|
+
}
|
|
26
|
+
else if (verifiablePresentation instanceof core_1.W3cJsonLdVerifiablePresentation) {
|
|
27
|
+
return core_1.JsonTransformer.toJSON(verifiablePresentation);
|
|
28
|
+
}
|
|
29
|
+
else if (verifiablePresentation instanceof core_1.W3cJwtVerifiablePresentation) {
|
|
30
|
+
return verifiablePresentation.serializedJwt;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return verifiablePresentation.compact;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.getSphereonVerifiablePresentation = getSphereonVerifiablePresentation;
|
|
37
|
+
function getVerifiablePresentationFromSphereonWrapped(wrappedVerifiablePresentation) {
|
|
38
|
+
if (wrappedVerifiablePresentation.format === 'jwt_vp') {
|
|
39
|
+
if (typeof wrappedVerifiablePresentation.original !== 'string') {
|
|
40
|
+
throw new core_1.CredoError('Unable to transform JWT VP to W3C VP');
|
|
41
|
+
}
|
|
42
|
+
return core_1.W3cJwtVerifiablePresentation.fromSerializedJwt(wrappedVerifiablePresentation.original);
|
|
43
|
+
}
|
|
44
|
+
else if (wrappedVerifiablePresentation.format === 'ldp_vp') {
|
|
45
|
+
return core_1.JsonTransformer.fromJSON(wrappedVerifiablePresentation.original, core_1.W3cJsonLdVerifiablePresentation);
|
|
46
|
+
}
|
|
47
|
+
else if (wrappedVerifiablePresentation.format === 'vc+sd-jwt') {
|
|
48
|
+
// We use some custom logic here so we don't have to re-process the encoded SD-JWT
|
|
49
|
+
const [encodedHeader] = wrappedVerifiablePresentation.presentation.compactSdJwtVc.split('.');
|
|
50
|
+
const header = core_1.JsonEncoder.fromBase64(encodedHeader);
|
|
51
|
+
return {
|
|
52
|
+
compact: wrappedVerifiablePresentation.presentation.compactSdJwtVc,
|
|
53
|
+
header,
|
|
54
|
+
payload: wrappedVerifiablePresentation.presentation.signedPayload,
|
|
55
|
+
prettyClaims: wrappedVerifiablePresentation.presentation.decodedPayload,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
throw new core_1.CredoError(`Unsupported presentation format: ${wrappedVerifiablePresentation.format}`);
|
|
59
|
+
}
|
|
60
|
+
exports.getVerifiablePresentationFromSphereonWrapped = getVerifiablePresentationFromSphereonWrapped;
|
|
61
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/shared/transform.ts"],"names":[],"mappings":";;;AAQA,yCAQuB;AAEvB,SAAgB,+BAA+B,CAC7C,oBAA0C;IAE1C,wBAAwB;IACxB,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE;QAC5C,OAAO,oBAAoB,CAAA;KAC5B;SAAM,IAAI,oB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,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,MAAM;YACN,OAAO,EAAE,6BAA6B,CAAC,YAAY,CAAC,aAAa;YACjE,YAAY,EAAE,6BAA6B,CAAC,YAAY,CAAC,cAAc;SACtD,CAAA;KACpB;IAED,MAAM,IAAI,iBAAU,CAAC,oCAAoC,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAA;AAClG,CAAC;AAxBD,oGAwBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OpenId4VcJwtIssuer } from './models';
|
|
2
|
+
import type { AgentContext, JwaSignatureAlgorithm, Key } from '@credo-ts/core';
|
|
3
|
+
import type { DIDDocument, SuppliedSignature } from '@sphereon/did-auth-siop';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the JWA Signature Algorithms that are supported by the wallet.
|
|
6
|
+
*
|
|
7
|
+
* This is an approximation based on the supported key types of the wallet.
|
|
8
|
+
* This is not 100% correct as a supporting a key type does not mean you support
|
|
9
|
+
* all the algorithms for that key type. However, this needs refactoring of the wallet
|
|
10
|
+
* that is planned for the 0.5.0 release.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSupportedJwaSignatureAlgorithms(agentContext: AgentContext): JwaSignatureAlgorithm[];
|
|
13
|
+
export declare function getSphereonSuppliedSignatureFromJwtIssuer(agentContext: AgentContext, jwtIssuer: OpenId4VcJwtIssuer): Promise<SuppliedSignature>;
|
|
14
|
+
export declare function getSphereonDidResolver(agentContext: AgentContext): {
|
|
15
|
+
resolve: (didUrl: string) => Promise<{
|
|
16
|
+
didDocument: DIDDocument;
|
|
17
|
+
didResolutionMetadata: import("@credo-ts/core").DidResolutionMetadata;
|
|
18
|
+
didDocumentMetadata: import("did-resolver").DIDDocumentMetadata;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
export declare function getProofTypeFromKey(agentContext: AgentContext, key: Key): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProofTypeFromKey = exports.getSphereonDidResolver = exports.getSphereonSuppliedSignatureFromJwtIssuer = exports.getSupportedJwaSignatureAlgorithms = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
/**
|
|
6
|
+
* Returns the JWA Signature Algorithms that are supported by the wallet.
|
|
7
|
+
*
|
|
8
|
+
* This is an approximation based on the supported key types of the wallet.
|
|
9
|
+
* This is not 100% correct as a supporting a key type does not mean you support
|
|
10
|
+
* all the algorithms for that key type. However, this needs refactoring of the wallet
|
|
11
|
+
* that is planned for the 0.5.0 release.
|
|
12
|
+
*/
|
|
13
|
+
function getSupportedJwaSignatureAlgorithms(agentContext) {
|
|
14
|
+
const supportedKeyTypes = agentContext.wallet.supportedKeyTypes;
|
|
15
|
+
// Extract the supported JWS algs based on the key types the wallet support.
|
|
16
|
+
const supportedJwaSignatureAlgorithms = supportedKeyTypes
|
|
17
|
+
// Map the supported key types to the supported JWK class
|
|
18
|
+
.map(core_1.getJwkClassFromKeyType)
|
|
19
|
+
// Filter out the undefined values
|
|
20
|
+
.filter((jwkClass) => jwkClass !== undefined)
|
|
21
|
+
// Extract the supported JWA signature algorithms from the JWK class
|
|
22
|
+
.flatMap((jwkClass) => jwkClass.supportedSignatureAlgorithms);
|
|
23
|
+
return supportedJwaSignatureAlgorithms;
|
|
24
|
+
}
|
|
25
|
+
exports.getSupportedJwaSignatureAlgorithms = getSupportedJwaSignatureAlgorithms;
|
|
26
|
+
async function getSphereonSuppliedSignatureFromJwtIssuer(agentContext, jwtIssuer) {
|
|
27
|
+
var _a;
|
|
28
|
+
let key;
|
|
29
|
+
let alg;
|
|
30
|
+
let kid;
|
|
31
|
+
let did;
|
|
32
|
+
if (jwtIssuer.method === 'did') {
|
|
33
|
+
const didsApi = agentContext.dependencyManager.resolve(core_1.DidsApi);
|
|
34
|
+
const didDocument = await didsApi.resolveDidDocument(jwtIssuer.didUrl);
|
|
35
|
+
const verificationMethod = didDocument.dereferenceKey(jwtIssuer.didUrl, ['authentication']);
|
|
36
|
+
// get the key from the verification method and use the first supported signature algorithm
|
|
37
|
+
key = (0, core_1.getKeyFromVerificationMethod)(verificationMethod);
|
|
38
|
+
const _alg = (_a = (0, core_1.getJwkClassFromKeyType)(key.keyType)) === null || _a === void 0 ? void 0 : _a.supportedSignatureAlgorithms[0];
|
|
39
|
+
if (!_alg)
|
|
40
|
+
throw new core_1.CredoError(`No supported signature algorithms for key type: ${key.keyType}`);
|
|
41
|
+
alg = _alg;
|
|
42
|
+
kid = verificationMethod.id;
|
|
43
|
+
did = verificationMethod.controller;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new core_1.CredoError(`Unsupported jwt issuer method '${jwtIssuer.method}'. Only 'did' is supported.`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
signature: async (data) => {
|
|
50
|
+
if (typeof data !== 'string')
|
|
51
|
+
throw new core_1.CredoError("Expected string but received 'Uint8Array'");
|
|
52
|
+
const signedData = await agentContext.wallet.sign({
|
|
53
|
+
data: core_1.TypedArrayEncoder.fromString(data),
|
|
54
|
+
key,
|
|
55
|
+
});
|
|
56
|
+
const signature = core_1.TypedArrayEncoder.toBase64URL(signedData);
|
|
57
|
+
return signature;
|
|
58
|
+
},
|
|
59
|
+
alg: alg,
|
|
60
|
+
did,
|
|
61
|
+
kid,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.getSphereonSuppliedSignatureFromJwtIssuer = getSphereonSuppliedSignatureFromJwtIssuer;
|
|
65
|
+
function getSphereonDidResolver(agentContext) {
|
|
66
|
+
return {
|
|
67
|
+
resolve: async (didUrl) => {
|
|
68
|
+
var _a;
|
|
69
|
+
const didsApi = agentContext.dependencyManager.resolve(core_1.DidsApi);
|
|
70
|
+
const result = await didsApi.resolve(didUrl);
|
|
71
|
+
return Object.assign(Object.assign({}, result), { didDocument: (_a = result.didDocument) === null || _a === void 0 ? void 0 : _a.toJSON() });
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.getSphereonDidResolver = getSphereonDidResolver;
|
|
76
|
+
function getProofTypeFromKey(agentContext, key) {
|
|
77
|
+
const signatureSuiteRegistry = agentContext.dependencyManager.resolve(core_1.SignatureSuiteRegistry);
|
|
78
|
+
const supportedSignatureSuites = signatureSuiteRegistry.getAllByKeyType(key.keyType);
|
|
79
|
+
if (supportedSignatureSuites.length === 0) {
|
|
80
|
+
throw new core_1.CredoError(`Couldn't find a supported signature suite for the given key type '${key.keyType}'.`);
|
|
81
|
+
}
|
|
82
|
+
return supportedSignatureSuites[0].proofType;
|
|
83
|
+
}
|
|
84
|
+
exports.getProofTypeFromKey = getProofTypeFromKey;
|
|
85
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":";;;AAIA,yCAOuB;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;AAbD,gFAaC;AAEM,KAAK,UAAU,yCAAyC,C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
|
|
7
|
+
"build"
|
|
8
|
+
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/openwallet-foundation/credo-ts/tree/main/packages/openid4vc",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/openwallet-foundation/credo-ts",
|
|
17
|
+
"directory": "packages/openid4vc"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "yarn run clean && yarn run compile",
|
|
21
|
+
"clean": "rimraf ./build",
|
|
22
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
23
|
+
"prepublishOnly": "yarn run build",
|
|
24
|
+
"test": "jest"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@credo-ts/core": "0.4.1-alpha.157+b83c5173",
|
|
28
|
+
"@sphereon/did-auth-siop": "0.6.2",
|
|
29
|
+
"@sphereon/oid4vci-client": "^0.10.2",
|
|
30
|
+
"@sphereon/oid4vci-common": "^0.10.1",
|
|
31
|
+
"@sphereon/oid4vci-issuer": "^0.10.2",
|
|
32
|
+
"@sphereon/ssi-types": "^0.18.1",
|
|
33
|
+
"rxjs": "^7.8.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@credo-ts/tenants": "0.4.1-alpha.157+b83c5173",
|
|
37
|
+
"@types/express": "^4.17.21",
|
|
38
|
+
"express": "^4.18.2",
|
|
39
|
+
"nock": "^13.3.0",
|
|
40
|
+
"rimraf": "^4.4.0",
|
|
41
|
+
"typescript": "~4.9.5"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "b83c5173070594448d92f801331b3a31c7ac8049"
|
|
44
|
+
}
|