@credo-ts/openid4vc 0.5.0-alpha.153 → 0.5.0-alpha.155
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/OpenId4VciHolderService.js +3 -1
- package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -1
- 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 +12 -19
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +15 -27
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +1 -1
- 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.js +3 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +7 -9
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +11 -33
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +24 -10
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js +76 -65
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +1 -11
- package/build/openid4vc-issuer/index.d.ts +2 -0
- package/build/openid4vc-issuer/index.js +2 -0
- package/build/openid4vc-issuer/index.js.map +1 -1
- package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.d.ts +17 -0
- package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.js +90 -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 +79 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +39 -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/index.d.ts +2 -0
- package/build/openid4vc-issuer/repository/index.js +2 -0
- package/build/openid4vc-issuer/repository/index.js.map +1 -1
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js +15 -10
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -1
- package/build/openid4vc-issuer/router/credentialEndpoint.js +22 -4
- package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -1
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.d.ts +11 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js +54 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/index.d.ts +1 -0
- package/build/openid4vc-issuer/router/index.js +3 -1
- package/build/openid4vc-issuer/router/index.js.map +1 -1
- 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 +22 -6
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +137 -57
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -1
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +5 -4
- 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 +17 -5
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +19 -6
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -1
- 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.js +6 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +4 -7
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +6 -23
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -1
- package/build/openid4vc-verifier/index.d.ts +2 -0
- package/build/openid4vc-verifier/index.js +2 -0
- package/build/openid4vc-verifier/index.js.map +1 -1
- 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/index.d.ts +2 -0
- package/build/openid4vc-verifier/repository/index.js +2 -0
- package/build/openid4vc-verifier/repository/index.js.map +1 -1
- package/build/openid4vc-verifier/router/authorizationEndpoint.js +9 -2
- package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -1
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.d.ts +11 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js +59 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js.map +1 -0
- package/build/shared/models/index.js.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenId4VcRelyingPartySessionManager = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
6
|
+
const OpenId4VcVerificationSessionState_1 = require("../OpenId4VcVerificationSessionState");
|
|
7
|
+
const OpenId4VcVerificationSessionRepository_1 = require("./OpenId4VcVerificationSessionRepository");
|
|
8
|
+
class OpenId4VcRelyingPartySessionManager {
|
|
9
|
+
constructor(agentContext, verifierId) {
|
|
10
|
+
this.agentContext = agentContext;
|
|
11
|
+
this.verifierId = verifierId;
|
|
12
|
+
this.openId4VcVerificationSessionRepository = agentContext.dependencyManager.resolve(OpenId4VcVerificationSessionRepository_1.OpenId4VcVerificationSessionRepository);
|
|
13
|
+
}
|
|
14
|
+
async getRequestStateByCorrelationId(correlationId, errorOnNotFound) {
|
|
15
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findById(this.agentContext, correlationId);
|
|
16
|
+
if (!verificationSession) {
|
|
17
|
+
if (errorOnNotFound)
|
|
18
|
+
throw new core_1.CredoError(`OpenID4VC Authorization request state for correlation id ${correlationId} not found`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return this.getRequestStateFromSessionRecord(verificationSession);
|
|
22
|
+
}
|
|
23
|
+
async getRequestStateByNonce(nonce, errorOnNotFound) {
|
|
24
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findSingleByQuery(this.agentContext, {
|
|
25
|
+
verifierId: this.verifierId,
|
|
26
|
+
nonce: nonce,
|
|
27
|
+
});
|
|
28
|
+
if (!verificationSession) {
|
|
29
|
+
if (errorOnNotFound)
|
|
30
|
+
throw new core_1.CredoError(`OpenID4VC Authorization request state for nonce ${nonce} not found`);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return this.getRequestStateFromSessionRecord(verificationSession);
|
|
34
|
+
}
|
|
35
|
+
async getRequestStateByState(state, errorOnNotFound) {
|
|
36
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findSingleByQuery(this.agentContext, {
|
|
37
|
+
verifierId: this.verifierId,
|
|
38
|
+
payloadState: state,
|
|
39
|
+
});
|
|
40
|
+
if (!verificationSession) {
|
|
41
|
+
if (errorOnNotFound)
|
|
42
|
+
throw new core_1.CredoError(`OpenID4VC Authorization request state for state ${state} not found`);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return this.getRequestStateFromSessionRecord(verificationSession);
|
|
46
|
+
}
|
|
47
|
+
async getResponseStateByCorrelationId(correlationId, errorOnNotFound) {
|
|
48
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findById(this.agentContext, correlationId);
|
|
49
|
+
const responseState = await this.getResponseStateFromSessionRecord(verificationSession);
|
|
50
|
+
if (!responseState) {
|
|
51
|
+
if (errorOnNotFound)
|
|
52
|
+
throw new core_1.CredoError(`OpenID4VC Authorization response state for correlation id ${correlationId} not found`);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return responseState;
|
|
56
|
+
}
|
|
57
|
+
async getResponseStateByNonce(nonce, errorOnNotFound) {
|
|
58
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findSingleByQuery(this.agentContext, {
|
|
59
|
+
verifierId: this.verifierId,
|
|
60
|
+
nonce,
|
|
61
|
+
});
|
|
62
|
+
const responseState = await this.getResponseStateFromSessionRecord(verificationSession);
|
|
63
|
+
if (!responseState) {
|
|
64
|
+
if (errorOnNotFound)
|
|
65
|
+
throw new core_1.CredoError(`OpenID4VC Authorization response state for nonce ${nonce} not found`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return responseState;
|
|
69
|
+
}
|
|
70
|
+
async getResponseStateByState(state, errorOnNotFound) {
|
|
71
|
+
const verificationSession = await this.openId4VcVerificationSessionRepository.findSingleByQuery(this.agentContext, {
|
|
72
|
+
verifierId: this.verifierId,
|
|
73
|
+
payloadState: state,
|
|
74
|
+
});
|
|
75
|
+
const responseState = await this.getResponseStateFromSessionRecord(verificationSession);
|
|
76
|
+
if (!responseState) {
|
|
77
|
+
if (errorOnNotFound)
|
|
78
|
+
throw new core_1.CredoError(`OpenID4VC Authorization response state for state ${state} not found`);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return responseState;
|
|
82
|
+
}
|
|
83
|
+
async getCorrelationIdByNonce(nonce, errorOnNotFound) {
|
|
84
|
+
const requestState = await this.getRequestStateByNonce(nonce, errorOnNotFound);
|
|
85
|
+
return requestState === null || requestState === void 0 ? void 0 : requestState.correlationId;
|
|
86
|
+
}
|
|
87
|
+
async getCorrelationIdByState(state, errorOnNotFound) {
|
|
88
|
+
const requestState = await this.getRequestStateByState(state, errorOnNotFound);
|
|
89
|
+
return requestState === null || requestState === void 0 ? void 0 : requestState.correlationId;
|
|
90
|
+
}
|
|
91
|
+
async deleteStateForCorrelationId() {
|
|
92
|
+
throw new Error('Method not implemented.');
|
|
93
|
+
}
|
|
94
|
+
async getRequestStateFromSessionRecord(sessionRecord) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
const lastUpdated = (_b = (_a = sessionRecord.updatedAt) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : sessionRecord.createdAt.getTime();
|
|
97
|
+
return {
|
|
98
|
+
lastUpdated,
|
|
99
|
+
timestamp: lastUpdated,
|
|
100
|
+
correlationId: sessionRecord.id,
|
|
101
|
+
// Not so nice that the session manager expects an error instance.....
|
|
102
|
+
error: sessionRecord.errorMessage ? new Error(sessionRecord.errorMessage) : undefined,
|
|
103
|
+
request: await did_auth_siop_1.AuthorizationRequest.fromUriOrJwt(sessionRecord.authorizationRequestJwt),
|
|
104
|
+
status: sphereonAuthorizationRequestStateFromOpenId4VcVerificationState(sessionRecord.state),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async getResponseStateFromSessionRecord(sessionRecord) {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
if (!sessionRecord)
|
|
110
|
+
return undefined;
|
|
111
|
+
const lastUpdated = (_b = (_a = sessionRecord.updatedAt) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : sessionRecord.createdAt.getTime();
|
|
112
|
+
// If we don't have the authorization response payload yet, it means we haven't
|
|
113
|
+
// received the response yet, and thus the response state does not exist yet
|
|
114
|
+
if (!sessionRecord.authorizationResponsePayload) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
lastUpdated,
|
|
119
|
+
timestamp: lastUpdated,
|
|
120
|
+
correlationId: sessionRecord.id,
|
|
121
|
+
// Not so nice that the session manager expects an error instance.....
|
|
122
|
+
error: sessionRecord.errorMessage ? new Error(sessionRecord.errorMessage) : undefined,
|
|
123
|
+
response: await did_auth_siop_1.AuthorizationResponse.fromPayload(sessionRecord.authorizationResponsePayload),
|
|
124
|
+
status: sphereonAuthorizationResponseStateFromOpenId4VcVerificationState(sessionRecord.state),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.OpenId4VcRelyingPartySessionManager = OpenId4VcRelyingPartySessionManager;
|
|
129
|
+
function sphereonAuthorizationResponseStateFromOpenId4VcVerificationState(state) {
|
|
130
|
+
if (state === OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.Error)
|
|
131
|
+
return did_auth_siop_1.AuthorizationResponseStateStatus.ERROR;
|
|
132
|
+
if (state === OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.ResponseVerified)
|
|
133
|
+
return did_auth_siop_1.AuthorizationResponseStateStatus.VERIFIED;
|
|
134
|
+
throw new core_1.CredoError(`Can not map OpenId4VcVerificationSessionState ${state} to AuthorizationResponseStateStatus`);
|
|
135
|
+
}
|
|
136
|
+
function sphereonAuthorizationRequestStateFromOpenId4VcVerificationState(state) {
|
|
137
|
+
if (state === OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.Error)
|
|
138
|
+
return did_auth_siop_1.AuthorizationRequestStateStatus.ERROR;
|
|
139
|
+
if ([OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestCreated, OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.ResponseVerified].includes(state)) {
|
|
140
|
+
return did_auth_siop_1.AuthorizationRequestStateStatus.CREATED;
|
|
141
|
+
}
|
|
142
|
+
if (state === OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestUriRetrieved)
|
|
143
|
+
return did_auth_siop_1.AuthorizationRequestStateStatus.SENT;
|
|
144
|
+
throw new core_1.CredoError(`Can not map OpenId4VcVerificationSessionState ${state} to AuthorizationRequestStateStatus`);
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=OpenId4VcRelyingPartySessionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VcRelyingPartySessionManager.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.ts"],"names":[],"mappings":";;;AAIA,yCAA2C;AAC3C,2DAKgC;AAEhC,4FAAwF;AAExF,qGAAiG;AAEjG,MAAa,mCAAmC;IAG9C,YAA2B,YAA0B,EAAU,UAAkB;QAAtD,iBAAY,GAAZ,YAAY,CAAc;QAAU,eAAU,GAAV,UAAU,CAAQ;QAC/E,IAAI,CAAC,sCAAsC,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAClF,+EAAsC,CACvC,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,8BAA8B,CACzC,aAAqB,EACrB,eAAyB;QAEzB,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,sCAAsC,CAAC,QAAQ,CACpF,IAAI,CAAC,YAAY,EACjB,aAAa,CACd,CAAA;QAED,IAAI,CAAC,mBAAmB,EAAE;YACxB,IAAI,eAAe;gBACjB,MAAM,IAAI,iBAAU,CAAC,4DAA4D,aAAa,YAAY,CAAC,CAAA;YAC7G,OAAO,SAAS,CAAA;SACjB;QAED,OAAO,IAAI,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,CAAA;IACnE,CAAC;IAEM,KAAK,CAAC,sBAAsB,CACjC,KAAa,EACb,eAAyB;QAEzB,M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,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;YACrF,QAAQ,EAAE,MAAM,qCAAqB,CAAC,WAAW,CAAC,aAAa,CAAC,4BAA4B,CAAC;YAC7F,MAAM,EAAE,gEAAgE,CAAC,aAAa,CAAC,KAAK,CAAC;SAC9F,CAAA;IACH,CAAC;CACF;AAvKD,kFAuKC;AAED,SAAS,gEAAgE,CACvE,KAAwC;IAExC,IAAI,KAAK,KAAK,qEAAiC,CAAC,KAAK;QAAE,OAAO,gDAAgC,CAAC,KAAK,CAAA;IACpG,IAAI,KAAK,KAAK,qEAAiC,CAAC,gBAAgB;QAAE,OAAO,gDAAgC,CAAC,QAAQ,CAAA;IAElH,MAAM,IAAI,iBAAU,CAAC,iDAAiD,KAAK,sCAAsC,CAAC,CAAA;AACpH,CAAC;AAED,SAAS,+DAA+D,CACtE,KAAwC;IAExC,IAAI,KAAK,KAAK,qEAAiC,CAAC,KAAK;QAAE,OAAO,+CAA+B,CAAC,KAAK,CAAA;IAEnG,IACE,CAAC,qEAAiC,CAAC,cAAc,EAAE,qEAAiC,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAC7G,KAAK,CACN,EACD;QACA,OAAO,+CAA+B,CAAC,OAAO,CAAA;KAC/C;IAED,IAAI,KAAK,KAAK,qEAAiC,CAAC,mBAAmB;QAAE,OAAO,+CAA+B,CAAC,IAAI,CAAA;IAEhH,MAAM,IAAI,iBAAU,CAAC,iDAAiD,KAAK,qCAAqC,CAAC,CAAA;AACnH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { OpenId4VcSiopAuthorizationResponsePayload } from '../../shared/models';
|
|
2
|
+
import type { OpenId4VcVerificationSessionState } from '../OpenId4VcVerificationSessionState';
|
|
3
|
+
import type { RecordTags, TagsBase } from '@credo-ts/core';
|
|
4
|
+
import { BaseRecord } from '@credo-ts/core';
|
|
5
|
+
export type OpenId4VcVerificationSessionRecordTags = RecordTags<OpenId4VcVerificationSessionRecord>;
|
|
6
|
+
export type DefaultOpenId4VcVerificationSessionRecordTags = {
|
|
7
|
+
verifierId: string;
|
|
8
|
+
state: OpenId4VcVerificationSessionState;
|
|
9
|
+
nonce: string;
|
|
10
|
+
payloadState: string;
|
|
11
|
+
authorizationRequestUri: string;
|
|
12
|
+
};
|
|
13
|
+
export interface OpenId4VcVerificationSessionRecordProps {
|
|
14
|
+
id?: string;
|
|
15
|
+
createdAt?: Date;
|
|
16
|
+
tags?: TagsBase;
|
|
17
|
+
verifierId: string;
|
|
18
|
+
state: OpenId4VcVerificationSessionState;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
authorizationRequestUri: string;
|
|
21
|
+
authorizationRequestJwt: string;
|
|
22
|
+
authorizationResponsePayload?: OpenId4VcSiopAuthorizationResponsePayload;
|
|
23
|
+
}
|
|
24
|
+
export declare class OpenId4VcVerificationSessionRecord extends BaseRecord<DefaultOpenId4VcVerificationSessionRecordTags> {
|
|
25
|
+
static readonly type = "OpenId4VcVerificationSessionRecord";
|
|
26
|
+
readonly type = "OpenId4VcVerificationSessionRecord";
|
|
27
|
+
/**
|
|
28
|
+
* The id of the verifier that this session is for.
|
|
29
|
+
*/
|
|
30
|
+
verifierId: string;
|
|
31
|
+
/**
|
|
32
|
+
* The state of the verification session.
|
|
33
|
+
*/
|
|
34
|
+
state: OpenId4VcVerificationSessionState;
|
|
35
|
+
/**
|
|
36
|
+
* Optional error message of the error that occurred during the verification session. Will be set when state is {@link OpenId4VcVerificationSessionState.Error}
|
|
37
|
+
*/
|
|
38
|
+
errorMessage?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The signed JWT containing the authorization request
|
|
41
|
+
*/
|
|
42
|
+
authorizationRequestJwt: string;
|
|
43
|
+
/**
|
|
44
|
+
* URI of the authorization request. This is the url that can be used to
|
|
45
|
+
* retrieve the authorization request
|
|
46
|
+
*/
|
|
47
|
+
authorizationRequestUri: string;
|
|
48
|
+
/**
|
|
49
|
+
* The payload of the received authorization response
|
|
50
|
+
*/
|
|
51
|
+
authorizationResponsePayload?: OpenId4VcSiopAuthorizationResponsePayload;
|
|
52
|
+
constructor(props: OpenId4VcVerificationSessionRecordProps);
|
|
53
|
+
assertState(expectedStates: OpenId4VcVerificationSessionState | OpenId4VcVerificationSessionState[]): void;
|
|
54
|
+
getTags(): {
|
|
55
|
+
verifierId: string;
|
|
56
|
+
state: OpenId4VcVerificationSessionState;
|
|
57
|
+
nonce: string;
|
|
58
|
+
payloadState: string;
|
|
59
|
+
authorizationRequestUri: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenId4VcVerificationSessionRecord = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
class OpenId4VcVerificationSessionRecord extends core_1.BaseRecord {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
super();
|
|
9
|
+
this.type = OpenId4VcVerificationSessionRecord.type;
|
|
10
|
+
if (props) {
|
|
11
|
+
this.id = (_a = props.id) !== null && _a !== void 0 ? _a : core_1.utils.uuid();
|
|
12
|
+
this.createdAt = (_b = props.createdAt) !== null && _b !== void 0 ? _b : new Date();
|
|
13
|
+
this._tags = (_c = props.tags) !== null && _c !== void 0 ? _c : {};
|
|
14
|
+
this.verifierId = props.verifierId;
|
|
15
|
+
this.state = props.state;
|
|
16
|
+
this.errorMessage = props.errorMessage;
|
|
17
|
+
this.authorizationRequestJwt = props.authorizationRequestJwt;
|
|
18
|
+
this.authorizationRequestUri = props.authorizationRequestUri;
|
|
19
|
+
this.authorizationResponsePayload = props.authorizationResponsePayload;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
assertState(expectedStates) {
|
|
23
|
+
if (!Array.isArray(expectedStates)) {
|
|
24
|
+
expectedStates = [expectedStates];
|
|
25
|
+
}
|
|
26
|
+
if (!expectedStates.includes(this.state)) {
|
|
27
|
+
throw new core_1.CredoError(`OpenId4VcVerificationSessionRecord is in invalid state ${this.state}. Valid states are: ${expectedStates.join(', ')}.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getTags() {
|
|
31
|
+
const parsedAuthorizationRequest = core_1.Jwt.fromSerializedJwt(this.authorizationRequestJwt);
|
|
32
|
+
const nonce = parsedAuthorizationRequest.payload.additionalClaims.nonce;
|
|
33
|
+
if (!nonce || typeof nonce !== 'string')
|
|
34
|
+
throw new core_1.CredoError('Expected nonce in authorization request payload');
|
|
35
|
+
const payloadState = parsedAuthorizationRequest.payload.additionalClaims.state;
|
|
36
|
+
if (!payloadState || typeof payloadState !== 'string')
|
|
37
|
+
throw new core_1.CredoError('Expected state in authorization request payload');
|
|
38
|
+
return Object.assign(Object.assign({}, this._tags), { verifierId: this.verifierId, state: this.state, nonce,
|
|
39
|
+
// FIXME: how do we call this property so it doesn't conflict with the record state?
|
|
40
|
+
payloadState, authorizationRequestUri: this.authorizationRequestUri });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.OpenId4VcVerificationSessionRecord = OpenId4VcVerificationSessionRecord;
|
|
44
|
+
OpenId4VcVerificationSessionRecord.type = 'OpenId4VcVerificationSessionRecord';
|
|
45
|
+
//# sourceMappingURL=OpenId4VcVerificationSessionRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VcVerificationSessionRecord.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.ts"],"names":[],"mappings":";;;AAIA,yCAAmE;AA2BnE,MAAa,kCAAmC,SAAQ,iBAAyD;IAmC/G,YAAmB,KAA8C;;QAC/D,KAAK,EAAE,CAAA;QAlCO,SAAI,GAAG,kCAAkC,CAAC,IAAI,CAAA;QAoC5D,IAAI,KA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AAC,CAAA;QAEhH,MAAM,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAA;QAC9E,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ;YACnD,MAAM,IAAI,iBAAU,CAAC,iDAAiD,CAAC,CAAA;QAEzE,uCACK,IAAI,CAAC,KAAK,KACb,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK;YACL,oFAAoF;YACpF,YAAY,EACZ,uBAAuB,EAAE,IAAI,CAAC,uBAAuB,IACtD;IACH,CAAC;;AArFH,gFAsFC;AArFwB,uCAAI,GAAG,oCAAoC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Repository, StorageService, EventEmitter } from '@credo-ts/core';
|
|
2
|
+
import { OpenId4VcVerificationSessionRecord } from './OpenId4VcVerificationSessionRecord';
|
|
3
|
+
export declare class OpenId4VcVerificationSessionRepository extends Repository<OpenId4VcVerificationSessionRecord> {
|
|
4
|
+
constructor(storageService: StorageService<OpenId4VcVerificationSessionRecord>, eventEmitter: EventEmitter);
|
|
5
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OpenId4VcVerificationSessionRepository = void 0;
|
|
16
|
+
const core_1 = require("@credo-ts/core");
|
|
17
|
+
const OpenId4VcVerificationSessionRecord_1 = require("./OpenId4VcVerificationSessionRecord");
|
|
18
|
+
let OpenId4VcVerificationSessionRepository = class OpenId4VcVerificationSessionRepository extends core_1.Repository {
|
|
19
|
+
constructor(storageService, eventEmitter) {
|
|
20
|
+
super(OpenId4VcVerificationSessionRecord_1.OpenId4VcVerificationSessionRecord, storageService, eventEmitter);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
OpenId4VcVerificationSessionRepository = __decorate([
|
|
24
|
+
(0, core_1.injectable)(),
|
|
25
|
+
__param(0, (0, core_1.inject)(core_1.InjectionSymbols.StorageService)),
|
|
26
|
+
__metadata("design:paramtypes", [Object, core_1.EventEmitter])
|
|
27
|
+
], OpenId4VcVerificationSessionRepository);
|
|
28
|
+
exports.OpenId4VcVerificationSessionRepository = OpenId4VcVerificationSessionRepository;
|
|
29
|
+
//# sourceMappingURL=OpenId4VcVerificationSessionRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VcVerificationSessionRepository.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+G;AAE/G,6FAAyF;AAGlF,IAAM,sCAAsC,GAA5C,MAAM,sCAAuC,SAAQ,iBAA8C;IACxG,YAC2C,cAAkE,EAC3G,YAA0B;QAE1B,KAAK,CAAC,uEAAkC,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IACzE,CAAC;CACF,CAAA;AAPY,sCAAsC;IADlD,IAAA,iBAAU,GAAE;IAGR,WAAA,IAAA,aAAM,EAAC,uBAAgB,CAAC,cAAc,CAAC,CAAA;6CAC1B,mBAAY;GAHjB,sCAAsC,CAOlD;AAPY,wFAAsC"}
|
|
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./OpenId4VcVerifierRecord"), exports);
|
|
18
18
|
__exportStar(require("./OpenId4VcVerifierRepository"), exports);
|
|
19
|
+
__exportStar(require("./OpenId4VcVerificationSessionRecord"), exports);
|
|
20
|
+
__exportStar(require("./OpenId4VcVerificationSessionRepository"), exports);
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,gEAA6C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,gEAA6C;AAC7C,uEAAoD;AACpD,2EAAwD"}
|
|
@@ -12,10 +12,17 @@ function configureAuthorizationEndpoint(router, config) {
|
|
|
12
12
|
const authorizationResponse = request.body;
|
|
13
13
|
if (isVpRequest)
|
|
14
14
|
authorizationResponse.presentation_submission = JSON.parse(request.body.presentation_submission);
|
|
15
|
-
|
|
15
|
+
const verificationSession = await openId4VcVerifierService.findVerificationSessionForAuthorizationResponse(agentContext, {
|
|
16
|
+
authorizationResponse,
|
|
17
|
+
verifierId: verifier.verifierId,
|
|
18
|
+
});
|
|
19
|
+
if (!verificationSession) {
|
|
20
|
+
agentContext.config.logger.warn(`No verification session found for incoming authorization response for verifier ${verifier.verifierId}`);
|
|
21
|
+
return (0, router_1.sendErrorResponse)(response, agentContext.config.logger, 404, 'invalid_request', null);
|
|
22
|
+
}
|
|
16
23
|
await openId4VcVerifierService.verifyAuthorizationResponse(agentContext, {
|
|
17
24
|
authorizationResponse: request.body,
|
|
18
|
-
|
|
25
|
+
verificationSession,
|
|
19
26
|
});
|
|
20
27
|
response.status(200).send();
|
|
21
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizationEndpoint.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/authorizationEndpoint.ts"],"names":[],"mappings":";;;AAIA,gDAA0E;AAC1E,kFAA8E;AAY9E,SAAgB,8BAA8B,CAAC,MAAc,EAAE,MAAgD;IAC7G,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,OAAqC,EAAE,QAAkB,EAAE,IAAI,EAAE,EAAE;QACzG,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAA;QAE7D,IAAI;YACF,MAAM,wBAAwB,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,2DAA4B,CAAC,CAAA;YACrG,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,uBAAuB,KAAK,SAAS,CAAA;YAEtE,MAAM,qBAAqB,GAAiC,OAAO,CAAC,IAAI,CAAA;YACxE,IAAI,WAAW;gBAAE,qBAAqB,CAAC,uBAAuB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;YAEjH,
|
|
1
|
+
{"version":3,"file":"authorizationEndpoint.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/authorizationEndpoint.ts"],"names":[],"mappings":";;;AAIA,gDAA0E;AAC1E,kFAA8E;AAY9E,SAAgB,8BAA8B,CAAC,MAAc,EAAE,MAAgD;IAC7G,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,OAAqC,E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AED,mFAAmF;QACnF,IAAI,EAAE,CAAA;IACR,CAAC,CAAC,CAAA;AACJ,CAAC;AAtCD,wEAsCC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Router } from 'express';
|
|
2
|
+
export interface OpenId4VcSiopAuthorizationRequestEndpointConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The path at which the authorization request should be made available. Note that it will be
|
|
5
|
+
* hosted at a subpath to take into account multiple tenants and verifiers.
|
|
6
|
+
*
|
|
7
|
+
* @default /authorization-requests
|
|
8
|
+
*/
|
|
9
|
+
endpointPath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function configureAuthorizationRequestEndpoint(router: Router, config: OpenId4VcSiopAuthorizationRequestEndpointConfig): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureAuthorizationRequestEndpoint = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const router_1 = require("../../shared/router");
|
|
6
|
+
const OpenId4VcSiopVerifierService_1 = require("../OpenId4VcSiopVerifierService");
|
|
7
|
+
const OpenId4VcVerificationSessionState_1 = require("../OpenId4VcVerificationSessionState");
|
|
8
|
+
const OpenId4VcVerifierEvents_1 = require("../OpenId4VcVerifierEvents");
|
|
9
|
+
const OpenId4VcVerifierModuleConfig_1 = require("../OpenId4VcVerifierModuleConfig");
|
|
10
|
+
const repository_1 = require("../repository");
|
|
11
|
+
function configureAuthorizationRequestEndpoint(router, config) {
|
|
12
|
+
router.get((0, core_1.joinUriParts)(config.endpointPath, [':authorizationRequestId']), async (request, response, next) => {
|
|
13
|
+
const { agentContext, verifier } = (0, router_1.getRequestContext)(request);
|
|
14
|
+
try {
|
|
15
|
+
const verifierService = agentContext.dependencyManager.resolve(OpenId4VcSiopVerifierService_1.OpenId4VcSiopVerifierService);
|
|
16
|
+
const verificationSessionRepository = agentContext.dependencyManager.resolve(repository_1.OpenId4VcVerificationSessionRepository);
|
|
17
|
+
const verifierConfig = agentContext.dependencyManager.resolve(OpenId4VcVerifierModuleConfig_1.OpenId4VcVerifierModuleConfig);
|
|
18
|
+
// TODO: is there a cleaner way to get the host (including port)?
|
|
19
|
+
const [, , host] = verifierConfig.baseUrl.split('/');
|
|
20
|
+
const authorizationRequestUri = `${request.protocol}://${host}${request.originalUrl}`;
|
|
21
|
+
const [verificationSession] = await verifierService.findVerificationSessionsByQuery(agentContext, {
|
|
22
|
+
verifierId: verifier.verifierId,
|
|
23
|
+
authorizationRequestUri,
|
|
24
|
+
});
|
|
25
|
+
if (!verificationSession) {
|
|
26
|
+
return (0, router_1.sendErrorResponse)(response, agentContext.config.logger, 404, 'not_found', 'Authorization request not found');
|
|
27
|
+
}
|
|
28
|
+
if (![
|
|
29
|
+
OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestCreated,
|
|
30
|
+
OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestUriRetrieved,
|
|
31
|
+
].includes(verificationSession.state)) {
|
|
32
|
+
return (0, router_1.sendErrorResponse)(response, agentContext.config.logger, 400, 'invalid_request', 'Invalid state for authorization request');
|
|
33
|
+
}
|
|
34
|
+
// It's okay to retrieve the offer multiple times. So we only update the state if it's not already retrieved
|
|
35
|
+
if (verificationSession.state !== OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestUriRetrieved) {
|
|
36
|
+
const previousState = verificationSession.state;
|
|
37
|
+
verificationSession.state = OpenId4VcVerificationSessionState_1.OpenId4VcVerificationSessionState.RequestUriRetrieved;
|
|
38
|
+
await verificationSessionRepository.update(agentContext, verificationSession);
|
|
39
|
+
agentContext.dependencyManager
|
|
40
|
+
.resolve(core_1.EventEmitter)
|
|
41
|
+
.emit(agentContext, {
|
|
42
|
+
type: OpenId4VcVerifierEvents_1.OpenId4VcVerifierEvents.VerificationSessionStateChanged,
|
|
43
|
+
payload: {
|
|
44
|
+
verificationSession: verificationSession.clone(),
|
|
45
|
+
previousState,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
response.status(200).send(verificationSession.authorizationRequestJwt);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
(0, router_1.sendErrorResponse)(response, agentContext.config.logger, 500, 'invalid_request', error);
|
|
53
|
+
}
|
|
54
|
+
// NOTE: if we don't call next, the agentContext session handler will NOT be called
|
|
55
|
+
next();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.configureAuthorizationRequestEndpoint = configureAuthorizationRequestEndpoint;
|
|
59
|
+
//# sourceMappingURL=authorizationRequestEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorizationRequestEndpoint.js","sourceRoot":"","sources":["../../../src/openid4vc-verifier/router/authorizationRequestEndpoint.ts"],"names":[],"mappings":";;;AAIA,yCAA2D;AAE3D,gDAA0E;AAC1E,kFAA8E;AAC9E,4FAAwF;AACxF,wEAAoE;AACpE,oFAAgF;AAChF,8CAAsE;AAYtE,SAAgB,qCAAqC,CACnD,MAAc,EACd,MAAuD;IAEvD,MAAM,CAAC,GAAG,CACR,IAAA,mBAAY,EAAC,MAAM,CAAC,YAAY,EAAE,CAAC,yBAAyB,CAAC,CAAC,EAC9D,KAAK,EAAE,OAAqC,EAAE,QAAkB,EAAE,IAAI,EAAE,EAAE;QACxE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAA;QAE7D,IAAI;YACF,MAAM,eAAe,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,2DAA4B,CAAC,CAAA;YAC5F,MAAM,6BAA6B,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAC1E,mDAAsC,CACvC,CAAA;YACD,MAAM,cAAc,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,6DAA6B,CAAC,CAAA;YA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wBACP,mBAAmB,EAAE,mBAAmB,CAAC,KAAK,EAAE;wBAChD,aAAa;qBACd;iBACF,CAAC,CAAA;aACL;YAED,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAA;SACvE;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,0BAAiB,EAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAA;SACvF;QAED,mFAAmF;QACnF,IAAI,EAAE,CAAA;IACR,CAAC,CACF,CAAA;AACH,CAAC;AA7ED,sFA6EC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAoCA,uDAAoC;AACpC,4DAAyC;AACzC,sEAAmD"}
|
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.5.0-alpha.
|
|
5
|
+
"version": "0.5.0-alpha.155+f4c386a6",
|
|
6
6
|
"files": [
|
|
7
7
|
"build"
|
|
8
8
|
],
|
|
@@ -24,20 +24,21 @@
|
|
|
24
24
|
"test": "jest"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@credo-ts/core": "0.5.0-alpha.
|
|
28
|
-
"@sphereon/did-auth-siop": "0.6.
|
|
29
|
-
"@sphereon/oid4vci-client": "0.
|
|
30
|
-
"@sphereon/oid4vci-common": "0.
|
|
31
|
-
"@sphereon/oid4vci-issuer": "0.
|
|
32
|
-
"@sphereon/ssi-types": "^0.18.1"
|
|
27
|
+
"@credo-ts/core": "0.5.0-alpha.155+f4c386a6",
|
|
28
|
+
"@sphereon/did-auth-siop": "0.6.2",
|
|
29
|
+
"@sphereon/oid4vci-client": "^0.10.1",
|
|
30
|
+
"@sphereon/oid4vci-common": "^0.10.1",
|
|
31
|
+
"@sphereon/oid4vci-issuer": "^0.10.1",
|
|
32
|
+
"@sphereon/ssi-types": "^0.18.1",
|
|
33
|
+
"rxjs": "^7.8.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@credo-ts/tenants": "0.5.0-alpha.
|
|
36
|
+
"@credo-ts/tenants": "0.5.0-alpha.155+f4c386a6",
|
|
36
37
|
"@types/express": "^4.17.21",
|
|
37
38
|
"express": "^4.18.2",
|
|
38
39
|
"nock": "^13.3.0",
|
|
39
40
|
"rimraf": "^4.4.0",
|
|
40
41
|
"typescript": "~4.9.5"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f4c386a6ccf8adb829cad30b81d524e6ffddb029"
|
|
43
44
|
}
|