@pagopa/io-react-native-wallet 2.0.0-next.2 → 2.0.0-next.4
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/lib/commonjs/credential/issuance/03-start-user-authorization.js +38 -24
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +75 -57
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +6 -10
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +43 -11
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +51 -48
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +77 -45
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/types.js +17 -10
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +10 -11
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +1 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/README.md +0 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +11 -15
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +5 -2
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/utils.test.js +37 -0
- package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -0
- package/lib/commonjs/sd-jwt/index.js +26 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +71 -8
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/utils.js +64 -0
- package/lib/commonjs/sd-jwt/utils.js.map +1 -0
- package/lib/commonjs/trust/types.js +18 -13
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/par.js +32 -22
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/pop.js +1 -1
- package/lib/commonjs/utils/pop.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +4 -1
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +38 -24
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +76 -58
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +6 -10
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +44 -12
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +51 -48
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +77 -45
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/types.js +13 -8
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +10 -11
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/types.js +1 -1
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/README.md +0 -1
- package/lib/module/sd-jwt/__test__/index.test.js +11 -16
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +5 -2
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/utils.test.js +35 -0
- package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -0
- package/lib/module/sd-jwt/index.js +7 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +70 -7
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/utils.js +57 -0
- package/lib/module/sd-jwt/utils.js.map +1 -0
- package/lib/module/trust/types.js +18 -13
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/par.js +29 -20
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/pop.js +1 -1
- package/lib/module/utils/pop.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +4 -1
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +12 -12
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +2 -2
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +7 -6
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +7 -14
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +10 -5
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -2
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +49 -26
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +2 -2
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +4 -3
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +9 -5
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +3 -4
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +4 -4
- package/lib/typescript/pid/sd-jwt/types.d.ts +7 -7
- package/lib/typescript/sd-jwt/__test__/utils.test.d.ts +2 -0
- package/lib/typescript/sd-jwt/__test__/utils.test.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/index.d.ts +69 -28
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +264 -31
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/utils.d.ts +18 -0
- package/lib/typescript/sd-jwt/utils.d.ts.map +1 -0
- package/lib/typescript/trust/build-chain.d.ts +30 -14
- package/lib/typescript/trust/build-chain.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +322 -158
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +29 -13
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +9 -9
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/01-start-flow.ts +2 -2
- package/src/credential/issuance/03-start-user-authorization.ts +57 -38
- package/src/credential/issuance/04-complete-user-authorization.ts +79 -85
- package/src/credential/issuance/05-authorize-access.ts +5 -11
- package/src/credential/issuance/06-obtain-credential.ts +56 -23
- package/src/credential/issuance/07-verify-and-parse-credential.ts +54 -62
- package/src/credential/issuance/README.md +77 -45
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/types.ts +19 -8
- package/src/credential/presentation/07-evaluate-dcql-query.ts +16 -17
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +19 -16
- package/src/credential/presentation/types.ts +1 -2
- package/src/credential/status/README.md +0 -1
- package/src/sd-jwt/__test__/index.test.ts +8 -29
- package/src/sd-jwt/__test__/types.test.ts +6 -2
- package/src/sd-jwt/__test__/utils.test.ts +37 -0
- package/src/sd-jwt/index.ts +7 -1
- package/src/sd-jwt/types.ts +68 -7
- package/src/sd-jwt/utils.ts +73 -0
- package/src/trust/types.ts +23 -17
- package/src/utils/par.ts +37 -21
- package/src/utils/pop.ts +1 -1
- package/src/wallet-instance-attestation/types.ts +3 -1
@@ -2,13 +2,13 @@ import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/a
|
|
2
2
|
import { hasStatusOrThrow } from "../../utils/misc";
|
3
3
|
import parseUrl from "parse-url";
|
4
4
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
5
|
-
import { decode,
|
5
|
+
import { decode, SignJWT } from "@pagopa/io-react-native-jwt";
|
6
6
|
import { RequestObject } from "../presentation/types";
|
7
|
-
import { v4 as uuidv4 } from "uuid";
|
8
7
|
import { ResponseUriResultShape } from "./types";
|
9
8
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
10
9
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
11
10
|
import { LogLevel, Logger } from "../../utils/logging";
|
11
|
+
import { Presentation } from "..";
|
12
12
|
|
13
13
|
/**
|
14
14
|
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
@@ -86,70 +86,46 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
86
86
|
};
|
87
87
|
|
88
88
|
/**
|
89
|
-
* WARNING: This function must be called after {@link
|
89
|
+
* WARNING: This function must be called after {@link getRequestedCredentialToBePresented}. The next function to be called is {@link authorizeAccess}.
|
90
90
|
* The interface of the phase to complete User authorization via presentation of existing credentials when the response mode is "form_post.jwt".
|
91
|
-
*
|
92
|
-
*
|
93
|
-
* @param
|
94
|
-
* @param
|
95
|
-
* @param
|
96
|
-
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
97
|
-
* @param context.pid the PID to be presented
|
98
|
-
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
99
|
-
* @param context.pidCryptoContext The PID crypto context associated with the pid parameter
|
100
|
-
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
91
|
+
* The information is obtained by performing a POST request to the endpoint received in the response_uri field of the requestObject, where the Authorization Response payload is posted.
|
92
|
+
* Following this,the redirect_uri from the response is used to obtain the final authorization response.
|
93
|
+
* @param requestObject - The request object containing the necessary parameters for authorization.
|
94
|
+
* @param pid The `PID` that must be presented for the issuance of credentials.
|
95
|
+
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
101
96
|
* @throws {ValidationFailed} if an error while validating the response
|
102
97
|
* @returns the authorization response which contains code, state and iss
|
103
98
|
*/
|
104
|
-
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject,
|
105
|
-
|
106
|
-
const {
|
99
|
+
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, pid, _ref) => {
|
100
|
+
let {
|
107
101
|
wiaCryptoContext,
|
108
102
|
pidCryptoContext,
|
109
|
-
pid,
|
110
|
-
walletInstanceAttestation,
|
111
103
|
appFetch = fetch
|
112
|
-
} =
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
*/
|
134
|
-
const presentationSubmission = {
|
135
|
-
definition_id: `${uuidv4()}`,
|
136
|
-
id: `${uuidv4()}`,
|
137
|
-
descriptor_map: [{
|
138
|
-
id: "PersonIdentificationData",
|
139
|
-
path: "$.vp_token[0].vp",
|
140
|
-
format: "vc+sd-jwt"
|
141
|
-
}, {
|
142
|
-
id: "WalletAttestation",
|
143
|
-
path: "$.vp_token[1].vp",
|
144
|
-
format: "jwt"
|
145
|
-
}]
|
146
|
-
};
|
147
|
-
Logger.log(LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
148
|
-
const authzResponsePayload = encodeBase64(JSON.stringify({
|
104
|
+
} = _ref;
|
105
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
106
|
+
if (!requestObject.dcql_query) {
|
107
|
+
throw new Error("Invalid request object");
|
108
|
+
}
|
109
|
+
const dcqlQueryResult = Presentation.evaluateDcqlQuery([[pidCryptoContext, pid]], requestObject.dcql_query);
|
110
|
+
const credentialsToPresent = dcqlQueryResult.map(_ref2 => {
|
111
|
+
let {
|
112
|
+
requiredDisclosures,
|
113
|
+
...rest
|
114
|
+
} = _ref2;
|
115
|
+
return {
|
116
|
+
...rest,
|
117
|
+
requestedClaims: requiredDisclosures.map(_ref3 => {
|
118
|
+
let [, claimName] = _ref3;
|
119
|
+
return claimName;
|
120
|
+
})
|
121
|
+
};
|
122
|
+
});
|
123
|
+
const remotePresentations = await Presentation.prepareRemotePresentations(credentialsToPresent, requestObject.nonce, requestObject.client_id);
|
124
|
+
const authzResponsePayload = await createAuthzResponsePayload({
|
149
125
|
state: requestObject.state,
|
150
|
-
|
151
|
-
|
152
|
-
})
|
126
|
+
remotePresentations,
|
127
|
+
wiaCryptoContext
|
128
|
+
});
|
153
129
|
Logger.log(LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
154
130
|
|
155
131
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
@@ -203,4 +179,46 @@ export const parseAuthorizationResponse = authRes => {
|
|
203
179
|
}
|
204
180
|
return authResParsed.data;
|
205
181
|
};
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Creates the authorization response payload to be sent.
|
185
|
+
* This payload includes the state and the VP tokens for the presented credentials.
|
186
|
+
* The payload is encoded in Base64.
|
187
|
+
* @param state - The state parameter from the request object (optional).
|
188
|
+
* @param remotePresentations - An array of remote presentations containing credential IDs and their corresponding VP tokens.
|
189
|
+
* @returns The Base64 encoded authorization response payload.
|
190
|
+
*/
|
191
|
+
const createAuthzResponsePayload = async _ref4 => {
|
192
|
+
let {
|
193
|
+
state,
|
194
|
+
remotePresentations,
|
195
|
+
wiaCryptoContext
|
196
|
+
} = _ref4;
|
197
|
+
const {
|
198
|
+
kid
|
199
|
+
} = await wiaCryptoContext.getPublicKey();
|
200
|
+
return new SignJWT(wiaCryptoContext).setProtectedHeader({
|
201
|
+
typ: "jwt",
|
202
|
+
kid
|
203
|
+
}).setPayload({
|
204
|
+
/**
|
205
|
+
* TODO [SIW-2264]: `state` coming from `requestObject` is marked as `optional`
|
206
|
+
* At the moment, it is not entirely clear whether this value can indeed be omitted
|
207
|
+
* and, if so, what the consequences of its absence might be.
|
208
|
+
*/
|
209
|
+
...(state ? {
|
210
|
+
state
|
211
|
+
} : {}),
|
212
|
+
vp_token: remotePresentations.reduce((vp_token, _ref5) => {
|
213
|
+
let {
|
214
|
+
credentialId,
|
215
|
+
vpToken
|
216
|
+
} = _ref5;
|
217
|
+
return {
|
218
|
+
...vp_token,
|
219
|
+
[credentialId]: vpToken
|
220
|
+
};
|
221
|
+
}, {})
|
222
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
223
|
+
};
|
206
224
|
//# sourceMappingURL=04-complete-user-authorization.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","SignJWT","RequestObject","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","Presentation","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","log","DEBUG","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","res","text","jws","reqObj","safeParse","payload","success","ERROR","error","message","reason","data","completeUserAuthorizationWithFormPostJwtMode","pid","_ref","wiaCryptoContext","pidCryptoContext","dcql_query","Error","dcqlQueryResult","evaluateDcqlQuery","credentialsToPresent","map","_ref2","requiredDisclosures","rest","requestedClaims","_ref3","claimName","remotePresentations","prepareRemotePresentations","nonce","authzResponsePayload","createAuthzResponsePayload","state","body","response","resUriRes","response_uri","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","JSON","stringify","error_description","_ref4","kid","getPublicKey","setProtectedHeader","typ","setPayload","vp_token","reduce","_ref5","credentialId","vpToken","setIssuedAt","setExpirationTime","sign"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,OAAO,QAEF,6BAA6B;AACpC,SAAkCC,aAAa,QAAQ,uBAAuB;AAC9E,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;AACpE,SAASC,QAAQ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,CAAC;IAAA,CAAC,EACF,CAAC,CACH;EACF,CAAC,CAAC,CACDC,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,IAAI,CAAC,CACvBC,IAAI,CAAC,CAAC;AACX,CAAC"}
|
@@ -3,7 +3,6 @@ import { createDPopToken } from "../../utils/dpop";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
4
4
|
import { createPopToken } from "../../utils/pop";
|
5
5
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
6
|
-
import { ASSERTION_TYPE } from "./const";
|
7
6
|
import { TokenResponse } from "./types";
|
8
7
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
9
8
|
import { LogLevel, Logger } from "../../utils/logging";
|
@@ -25,16 +24,14 @@ import { LogLevel, Logger } from "../../utils/logging";
|
|
25
24
|
* @throws {IssuerResponseError} with a specific code for more context
|
26
25
|
* @return The token response containing the access token along with the token request signed with DPoP which has to be used in the {@link obtainCredential} step.
|
27
26
|
*/
|
28
|
-
export const authorizeAccess = async (issuerConf, code,
|
27
|
+
export const authorizeAccess = async (issuerConf, code, _, redirectUri, codeVerifier, context) => {
|
29
28
|
const {
|
30
29
|
appFetch = fetch,
|
31
30
|
walletInstanceAttestation,
|
32
31
|
wiaCryptoContext,
|
33
32
|
dPopCryptoContext
|
34
33
|
} = context;
|
35
|
-
const
|
36
|
-
const parUrl = new URL(parEndpoint);
|
37
|
-
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
34
|
+
const aud = issuerConf.openid_credential_issuer.credential_issuer;
|
38
35
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
39
36
|
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
40
37
|
const tokenRequestSignedDPop = await createDPopToken({
|
@@ -51,12 +48,9 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
51
48
|
Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
52
49
|
const requestBody = {
|
53
50
|
grant_type: "authorization_code",
|
54
|
-
client_id: clientId,
|
55
51
|
code,
|
56
|
-
redirect_uri: redirectUri,
|
57
52
|
code_verifier: codeVerifier,
|
58
|
-
|
59
|
-
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
53
|
+
redirect_uri: redirectUri
|
60
54
|
};
|
61
55
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
62
56
|
Logger.log(LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
@@ -64,7 +58,9 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
64
58
|
method: "POST",
|
65
59
|
headers: {
|
66
60
|
"Content-Type": "application/x-www-form-urlencoded",
|
67
|
-
DPoP: tokenRequestSignedDPop
|
61
|
+
DPoP: tokenRequestSignedDPop,
|
62
|
+
"OAuth-Client-Attestation": walletInstanceAttestation,
|
63
|
+
"OAuth-Client-Attestation-PoP": signedWiaPoP
|
68
64
|
},
|
69
65
|
body: authorizationRequestFormBody.toString()
|
70
66
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","authorizeAccess","issuerConf","code","_","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","aud","openid_credential_issuer","credential_issuer","iss","decode","payload","cnf","jwk","kid","tokenUrl","oauth_authorization_server","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","log","DEBUG","signedWiaPoP","requestBody","grant_type","code_verifier","redirect_uri","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","ERROR","error","message","reason","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAgBtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAgC,GAAG,MAAAA,CAC9CC,UAAU,EACVC,IAAI,EACJC,CAAC,EACDC,WAAW,EACXC,YAAY,EACZC,OAAO,KACJ;EACH,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC,gBAAgB;IAChBC;EACF,CAAC,GAAGL,OAAO;EACX,MAAMM,GAAG,GAAGX,UAAU,CAACY,wBAAwB,CAACC,iBAAiB;EACjE,MAAMC,GAAG,GAAGrB,yBAAyB,CAACsB,MAAM,CAACP,yBAAyB,CAAC,CACpEQ,OAAO,CAACC,GAAG,CAACC,GAAG,CAACC,GAAG;EAEtB,MAAMC,QAAQ,GAAGpB,UAAU,CAACqB,0BAA0B,CAACC,cAAc;EAErE,MAAMC,sBAAsB,GAAG,MAAMlC,eAAe,CAClD;IACEmC,GAAG,EAAE,MAAM;IACXC,GAAG,EAAEL,QAAQ;IACbM,GAAG,EAAG,GAAEnC,MAAM,CAAC,CAAE;EACnB,CAAC,EACDmB,iBACF,CAAC;EAEDZ,MAAM,CAAC6B,GAAG,CAAC9B,QAAQ,CAAC+B,KAAK,EAAG,uBAAsBL,sBAAuB,EAAC,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AC;MACzBqD,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAEd,QAAQ,CAACY,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEE,WAAW,EAAEf,QAAQ,CAACgB;EAAK,CAAC;AACvC,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { sha256ToBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { hasStatusOrThrow } from "../../utils/misc";
|
3
3
|
import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
|
4
|
-
import { CredentialResponse } from "./types";
|
4
|
+
import { CredentialResponse, NonceResponse } from "./types";
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
6
6
|
import { v4 as uuidv4 } from "uuid";
|
7
7
|
import { LogLevel, Logger } from "../../utils/logging";
|
@@ -24,11 +24,11 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
24
24
|
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
25
25
|
* @param accessToken The access token response returned by {@link authorizeAccess}
|
26
26
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
27
|
-
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link
|
28
|
-
* @param tokenRequestSignedDPop The DPoP signed token request returned by {@link authorizeAccess}
|
27
|
+
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link authorizeAccess}
|
29
28
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential
|
30
29
|
* @param context.dPopCryptoContext The DPoP crypto context
|
31
30
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
31
|
+
* @param operationType Specify the type of credential issuance (used for reissuing)
|
32
32
|
* @returns The credential response containing the credential
|
33
33
|
*/
|
34
34
|
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
@@ -37,18 +37,34 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
37
37
|
appFetch = fetch,
|
38
38
|
dPopCryptoContext
|
39
39
|
} = context;
|
40
|
+
const {
|
41
|
+
credential_configuration_id,
|
42
|
+
credential_identifier
|
43
|
+
} = credentialDefinition;
|
40
44
|
const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
|
45
|
+
const issuerUrl = issuerConf.oauth_authorization_server.issuer;
|
46
|
+
const nonceUrl = issuerConf.openid_credential_issuer.nonce_endpoint;
|
47
|
+
|
48
|
+
// Fetch the nonce from the Credential Issuer
|
49
|
+
const {
|
50
|
+
c_nonce
|
51
|
+
} = await appFetch(nonceUrl, {
|
52
|
+
method: "POST",
|
53
|
+
headers: {
|
54
|
+
"Content-Type": "application/json"
|
55
|
+
}
|
56
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => NonceResponse.parse(body));
|
41
57
|
|
42
58
|
/**
|
43
59
|
* JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
|
44
60
|
* This is presented along with the access token to the Credential Endpoint as proof of possession of the private key used to sign the Access Token.
|
45
61
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
46
62
|
*/
|
47
|
-
const signedNonceProof = await createNonceProof(
|
63
|
+
const signedNonceProof = await createNonceProof(c_nonce, clientId, issuerUrl, credentialCryptoContext);
|
48
64
|
Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
49
65
|
|
50
66
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
51
|
-
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id ===
|
67
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credential_configuration_id && (credential_identifier ? c.credential_identifiers.includes(credential_identifier) : true));
|
52
68
|
if (!containsCredentialDefinition) {
|
53
69
|
Logger.log(LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
54
70
|
throw new ValidationFailed({
|
@@ -56,12 +72,20 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
56
72
|
});
|
57
73
|
}
|
58
74
|
|
59
|
-
/**
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
75
|
+
/**
|
76
|
+
* The credential request body.
|
77
|
+
* We accept both `credential_identifier` (recommended) and `credential_configuration_id`
|
78
|
+
* when the Authorization Server does not support `credential_identifier`.
|
79
|
+
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#section-3.3.4
|
80
|
+
*/
|
81
|
+
const credentialRequestFormBody = credential_identifier ? {
|
82
|
+
credential_identifier: credential_identifier,
|
83
|
+
proof: {
|
84
|
+
jwt: signedNonceProof,
|
85
|
+
proof_type: "jwt"
|
86
|
+
}
|
87
|
+
} : {
|
88
|
+
credential_configuration_id: credential_configuration_id,
|
65
89
|
proof: {
|
66
90
|
jwt: signedNonceProof,
|
67
91
|
proof_type: "jwt"
|
@@ -95,7 +119,15 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
95
119
|
});
|
96
120
|
}
|
97
121
|
Logger.log(LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
98
|
-
|
122
|
+
|
123
|
+
// Extract the format corresponding to the credential_configuration_id used
|
124
|
+
const issuerCredentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credential_configuration_id];
|
125
|
+
|
126
|
+
// TODO: [SIW-2264] Handle multiple credentials
|
127
|
+
return {
|
128
|
+
credential: credentialRes.data.credentials.at(0).credential,
|
129
|
+
format: issuerCredentialConfig.format
|
130
|
+
};
|
99
131
|
};
|
100
132
|
|
101
133
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","NonceResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credential_configuration_id","credential_identifier","credentialUrl","openid_credential_issuer","credential_endpoint","issuerUrl","oauth_authorization_server","nonceUrl","nonce_endpoint","c_nonce","method","headers","then","res","json","body","parse","signedNonceProof","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_identifiers","includes","ERROR","message","credentialRequestFormBody","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","DPoP","Authorization","token_type","safeParse","catch","handleObtainCredentialError","success","error","reason","data","issuerCredentialConfig","credential_configurations_supported","credential","credentials","at","format","e","handle","code","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SAEEA,cAAc,EACdC,OAAO,QACF,6BAA6B;AAGpC,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,EACzBC,gBAAgB,QACX,oBAAoB;AAC3B,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,SAAS;AAC3D,SAAS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C,CACD+B,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEhG,wBAAwB,CAACmG,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDoC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
|
@@ -8,45 +8,39 @@ import { LogLevel, Logger } from "../../utils/logging";
|
|
8
8
|
|
9
9
|
// handy alias
|
10
10
|
|
11
|
-
const parseCredentialSdJwt = function (
|
11
|
+
const parseCredentialSdJwt = function (credentialConfig, _ref) {
|
12
12
|
let {
|
13
13
|
sdJwt,
|
14
14
|
disclosures
|
15
15
|
} = _ref;
|
16
16
|
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
17
17
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
18
|
-
|
19
|
-
|
20
|
-
Logger.log(LogLevel.ERROR,
|
21
|
-
throw new IoWalletError(
|
22
|
-
}
|
23
|
-
if (credentialSubject.format !== sdJwt.header.typ) {
|
24
|
-
Logger.log(LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
25
|
-
throw new IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
18
|
+
if (credentialConfig.format !== sdJwt.header.typ) {
|
19
|
+
const message = `Received credential is of an unknwown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
|
20
|
+
Logger.log(LogLevel.ERROR, message);
|
21
|
+
throw new IoWalletError(message);
|
26
22
|
}
|
27
|
-
|
28
|
-
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
29
|
-
if (!credentialSubject.claims) {
|
23
|
+
if (!credentialConfig.claims) {
|
30
24
|
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
31
25
|
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
32
26
|
}
|
33
27
|
|
34
|
-
const attrDefinitions =
|
28
|
+
const attrDefinitions = credentialConfig.claims;
|
35
29
|
|
36
30
|
// the key of the attribute defintion must match the disclosure's name
|
37
|
-
const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
|
38
|
-
let [
|
39
|
-
return
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
});
|
31
|
+
const attrsNotInDisclosures = attrDefinitions.filter(definition => !disclosures.some(_ref2 => {
|
32
|
+
let [, name] = _ref2;
|
33
|
+
return name === definition.path[0];
|
34
|
+
}) // Ignore nested paths for now, see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#name-claims-path-pointer
|
35
|
+
);
|
36
|
+
|
44
37
|
if (attrsNotInDisclosures.length > 0) {
|
45
|
-
const missing = attrsNotInDisclosures.map(_ => _[0
|
38
|
+
const missing = attrsNotInDisclosures.map(_ => _.path[0]).join(", ");
|
46
39
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
47
40
|
if (!ignoreMissingAttributes) {
|
48
|
-
|
49
|
-
|
41
|
+
const message = `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`;
|
42
|
+
Logger.log(LogLevel.ERROR, message);
|
43
|
+
throw new IoWalletError(message);
|
50
44
|
}
|
51
45
|
}
|
52
46
|
|
@@ -54,28 +48,31 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
54
48
|
// and are present in the disclosure set
|
55
49
|
const definedValues = Object.fromEntries(attrDefinitions
|
56
50
|
// retrieve the value from the disclosure set
|
57
|
-
.map(
|
51
|
+
.map(_ref3 => {
|
58
52
|
var _disclosures$find;
|
59
|
-
let
|
60
|
-
|
53
|
+
let {
|
54
|
+
path,
|
55
|
+
...definition
|
56
|
+
} = _ref3;
|
57
|
+
return [path[0], {
|
61
58
|
...definition,
|
62
|
-
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] ===
|
59
|
+
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === path[0])) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
|
63
60
|
}];
|
64
61
|
})
|
65
62
|
// add a human readable attribute name, with i18n, in the form { locale: name }
|
66
63
|
// example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
67
|
-
.map(
|
64
|
+
.map(_ref4 => {
|
68
65
|
let [attrKey, {
|
69
66
|
display,
|
70
67
|
...definition
|
71
|
-
}] =
|
68
|
+
}] = _ref4;
|
72
69
|
return [attrKey, {
|
73
70
|
...definition,
|
74
|
-
name: display.reduce((names,
|
71
|
+
name: display.reduce((names, _ref5) => {
|
75
72
|
let {
|
76
73
|
locale,
|
77
74
|
name
|
78
|
-
} =
|
75
|
+
} = _ref5;
|
79
76
|
return {
|
80
77
|
...names,
|
81
78
|
[locale]: name
|
@@ -86,8 +83,8 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
86
83
|
if (includeUndefinedAttributes) {
|
87
84
|
// attributes that are in the disclosure set
|
88
85
|
// but are not defined in the issuer configuration
|
89
|
-
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(
|
90
|
-
let [, key, value] =
|
86
|
+
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref6 => {
|
87
|
+
let [, key, value] = _ref6;
|
91
88
|
return [key, {
|
92
89
|
value,
|
93
90
|
name: key
|
@@ -124,23 +121,26 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
124
121
|
cnf
|
125
122
|
} = decodedCredential.sdJwt.payload;
|
126
123
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
127
|
-
|
128
|
-
|
124
|
+
const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
|
125
|
+
Logger.log(LogLevel.ERROR, message);
|
126
|
+
throw new IoWalletError(message);
|
129
127
|
}
|
130
128
|
return decodedCredential;
|
131
129
|
}
|
132
|
-
|
133
|
-
// utility type that specialize VerifyAndParseCredential for given format
|
134
|
-
|
135
|
-
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
|
130
|
+
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId, _ref7) => {
|
136
131
|
let {
|
137
132
|
credentialCryptoContext,
|
138
133
|
ignoreMissingAttributes,
|
139
134
|
includeUndefinedAttributes
|
140
|
-
} =
|
135
|
+
} = _ref7;
|
141
136
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
142
137
|
Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
143
|
-
const
|
138
|
+
const credentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId];
|
139
|
+
if (!credentialConfig) {
|
140
|
+
Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${credentialConfigurationId}`);
|
141
|
+
throw new IoWalletError("Credential type not supported by the issuer");
|
142
|
+
}
|
143
|
+
const parsedCredential = parseCredentialSdJwt(credentialConfig, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
144
144
|
const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
|
145
145
|
Logger.log(LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
146
146
|
return {
|
@@ -154,7 +154,7 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
154
154
|
* Verify and parse an encoded credential.
|
155
155
|
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
156
156
|
* @param credential The encoded credential returned by {@link obtainCredential}
|
157
|
-
* @param
|
157
|
+
* @param credentialConfigurationId The credential configuration ID that defines the provided credential
|
158
158
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
159
159
|
* @param context.ignoreMissingAttributes Skip error when attributes declared in the issuer configuration are not found within disclosures
|
160
160
|
* @param context.includeUndefinedAttributes Include attributes not explicitly declared in the issuer configuration
|
@@ -163,12 +163,15 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
163
163
|
* @throws {IoWalletError} If the credential is not bound to the provided user key
|
164
164
|
* @throws {IoWalletError} If the credential data fail to parse
|
165
165
|
*/
|
166
|
-
export const verifyAndParseCredential = async (issuerConf, credential,
|
167
|
-
|
168
|
-
|
169
|
-
|
166
|
+
export const verifyAndParseCredential = async (issuerConf, credential, credentialConfigurationId, context) => {
|
167
|
+
var _issuerConf$openid_cr;
|
168
|
+
const format = (_issuerConf$openid_cr = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId]) === null || _issuerConf$openid_cr === void 0 ? void 0 : _issuerConf$openid_cr.format;
|
169
|
+
if (format === "dc+sd-jwt") {
|
170
|
+
Logger.log(LogLevel.DEBUG, "Parsing credential in dc+sd-jwt format");
|
171
|
+
return verifyAndParseCredentialSdJwt(issuerConf, credential, credentialConfigurationId, context);
|
170
172
|
}
|
171
|
-
|
172
|
-
|
173
|
+
const message = `Unsupported credential format: ${format}`;
|
174
|
+
Logger.log(LogLevel.ERROR, message);
|
175
|
+
throw new IoWalletError(message);
|
173
176
|
};
|
174
177
|
//# sourceMappingURL=07-verify-and-parse-credential.js.map
|