@pagopa/io-react-native-wallet 0.28.2 → 0.29.0
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/README.md +43 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +12 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +9 -8
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +36 -5
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +16 -4
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +17 -9
- package/lib/commonjs/credential/presentation/errors.js +11 -13
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +2 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +2 -0
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +4 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +5 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +12 -0
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +5 -0
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +9 -8
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +36 -5
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +17 -5
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/README.md +17 -9
- package/lib/module/credential/presentation/errors.js +8 -10
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/status/02-status-attestation.js +2 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/module/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/decoder.js +2 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +2 -0
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/wallet-instance/index.js +4 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +5 -0
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- 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.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 +1 -1
- 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.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +17 -14
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +1 -3
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +11 -5
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/03-start-user-authorization.ts +18 -0
- package/src/credential/issuance/04-complete-user-authorization.ts +51 -0
- package/src/credential/issuance/05-authorize-access.ts +16 -0
- package/src/credential/issuance/06-obtain-credential.ts +31 -2
- package/src/credential/issuance/07-verify-and-parse-credential.ts +27 -1
- package/src/credential/presentation/01-start-flow.ts +12 -11
- package/src/credential/presentation/03-get-request-object.ts +2 -3
- package/src/credential/presentation/07-evaluate-dcql-query.ts +36 -1
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +25 -13
- package/src/credential/presentation/README.md +17 -9
- package/src/credential/presentation/errors.ts +15 -8
- package/src/credential/status/02-status-attestation.ts +3 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +10 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +19 -0
- package/src/index.ts +2 -0
- package/src/utils/decoder.ts +5 -0
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +6 -0
- package/src/wallet-instance/index.ts +17 -1
- package/src/wallet-instance-attestation/issuing.ts +19 -0
package/README.md
CHANGED
@@ -96,6 +96,45 @@ The suggested library to manage integrity is [io-react-native-integrity](https:/
|
|
96
96
|
|
97
97
|
</details>
|
98
98
|
|
99
|
+
<details>
|
100
|
+
<summary>LoggingContext (logging)</summary>
|
101
|
+
|
102
|
+
In order to log useful information while implementing the flows, the library supports custom logging logic by providing a `loggingContext` to the static `Logger` class:
|
103
|
+
|
104
|
+
```ts
|
105
|
+
export interface LoggingContext {
|
106
|
+
logDebug: (msg: string) => void;
|
107
|
+
logInfo: (msg: string) => void;
|
108
|
+
logWarn: (msg: string) => void;
|
109
|
+
logError: (msg: string) => void;
|
110
|
+
}
|
111
|
+
```
|
112
|
+
|
113
|
+
An example of a custom logging context:
|
114
|
+
|
115
|
+
```ts
|
116
|
+
import { Logging } from "@pagopa/io-react-native-wallet";
|
117
|
+
|
118
|
+
const loggingContext: Logging.LoggingContext = {
|
119
|
+
logDebug(msg: string) {
|
120
|
+
console.log("debug", msg);
|
121
|
+
},
|
122
|
+
logInfo(msg: string) {
|
123
|
+
console.log("info", msg);
|
124
|
+
},
|
125
|
+
logWarn(msg: string) {
|
126
|
+
console.log("warn", msg);
|
127
|
+
},
|
128
|
+
logError(msg: string) {
|
129
|
+
console.log("error", msg);
|
130
|
+
},
|
131
|
+
};
|
132
|
+
|
133
|
+
Logging.Logger.getInstance().initLogging(loggingContext);
|
134
|
+
```
|
135
|
+
|
136
|
+
</details>
|
137
|
+
|
99
138
|
<details>
|
100
139
|
<summary>appFetch (making HTTP requests)</summary>
|
101
140
|
|
@@ -120,6 +159,10 @@ Different flows are provided to perform common operations. Each flow is a set of
|
|
120
159
|
|
121
160
|
An example app is provided in [example](./example) folder which demostrates how to implemente these flows. To run it, follow the instructions in the [README](./example/README.md).
|
122
161
|
|
162
|
+
### Debug logging server
|
163
|
+
|
164
|
+
A debug logging server can be used with the example app to receive logs from the app. To run it, follow the instructions in the [README](./debug-logging-server/README.md).
|
165
|
+
|
123
166
|
### Ecosystem
|
124
167
|
|
125
168
|
`io-react-native-wallet` is designed to be used in [io-app](https://github.com/pagopa/io-app) and its ecosystem. There are a few libraries that can be used to implement the context required to implement the flows defined by this package.
|
@@ -7,6 +7,7 @@ exports.startUserAuthorization = void 0;
|
|
7
7
|
var _misc = require("../../utils/misc");
|
8
8
|
var _par = require("../../utils/par");
|
9
9
|
var _const = require("./const");
|
10
|
+
var _logging = require("../../utils/logging");
|
10
11
|
/**
|
11
12
|
* Ensures that the credential type requested is supported by the issuer and contained in the
|
12
13
|
* issuer configuration.
|
@@ -26,6 +27,7 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
26
27
|
type: "openid_credential"
|
27
28
|
}));
|
28
29
|
if (!result) {
|
30
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Requested credential type ${credentialType} is not supported by the issuer according to its configuration ${JSON.stringify(credential_configurations_supported)}`);
|
29
31
|
throw new Error(`No credential support the type '${credentialType}'`);
|
30
32
|
}
|
31
33
|
return result;
|
@@ -40,7 +42,9 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
40
42
|
const selectResponseMode = (issuerConf, credentialType) => {
|
41
43
|
const responseModeSupported = issuerConf.oauth_authorization_server.response_modes_supported;
|
42
44
|
const responseMode = credentialType === "PersonIdentificationData" ? "query" : "form_post.jwt";
|
45
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Selected response mode ${responseMode} for credential type ${credentialType}`);
|
43
46
|
if (!responseModeSupported.includes(responseMode)) {
|
47
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Requested response mode ${responseMode} is not supported by the issuer according to its configuration ${JSON.stringify(responseModeSupported)}`);
|
44
48
|
throw new Error(`No response mode support the type '${credentialType}'`);
|
45
49
|
}
|
46
50
|
return responseMode;
|
@@ -73,6 +77,7 @@ const startUserAuthorization = async (issuerConf, credentialType, ctx) => {
|
|
73
77
|
} = ctx;
|
74
78
|
const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
|
75
79
|
if (!clientId) {
|
80
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Public key associated with kid ${clientId} not found in the device`);
|
76
81
|
throw new Error("No public key found");
|
77
82
|
}
|
78
83
|
const codeVerifier = (0, _misc.generateRandomAlphaNumericString)(64);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_misc","require","_par","_const","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","generateRandomAlphaNumericString","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","makeParRequest","issuerRequestUri","ASSERTION_TYPE","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,
|
1
|
+
{"version":3,"names":["_misc","require","_par","_const","_logging","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","Logger","log","LogLevel","ERROR","JSON","stringify","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","DEBUG","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","generateRandomAlphaNumericString","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","makeParRequest","issuerRequestUri","ASSERTION_TYPE","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QA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B,CAAC,EACtBI,qBACF,CAAC;EAED,OAAO;IAAED,gBAAgB;IAAEZ,QAAQ;IAAEK,YAAY;IAAEI;EAAqB,CAAC;AAC3E,CAAC;AAACK,OAAA,CAAArB,sBAAA,GAAAA,sBAAA"}
|
@@ -14,6 +14,7 @@ var _uuid = require("uuid");
|
|
14
14
|
var _types2 = require("./types");
|
15
15
|
var _decoder = require("../../utils/decoder");
|
16
16
|
var _errors2 = require("./errors");
|
17
|
+
var _logging = require("../../utils/logging");
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
19
|
/**
|
19
20
|
* 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.
|
@@ -52,6 +53,7 @@ const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idp
|
|
52
53
|
*/
|
53
54
|
exports.buildAuthorizationUrl = buildAuthorizationUrl;
|
54
55
|
const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
56
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`);
|
55
57
|
const query = (0, _parseUrl.default)(authRedirectUrl).query;
|
56
58
|
return parseAuthorizationResponse(query);
|
57
59
|
};
|
@@ -71,15 +73,18 @@ const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
|
71
73
|
exports.completeUserAuthorizationWithQueryMode = completeUserAuthorizationWithQueryMode;
|
72
74
|
const getRequestedCredentialToBePresented = async function (issuerRequestUri, clientId, issuerConf) {
|
73
75
|
let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
|
76
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`);
|
74
77
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
75
78
|
const params = new URLSearchParams({
|
76
79
|
client_id: clientId,
|
77
80
|
request_uri: issuerRequestUri
|
78
81
|
});
|
82
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`);
|
79
83
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
80
84
|
method: "GET"
|
81
85
|
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.text()).then(jws => (0, _ioReactNativeJwt.decode)(jws)).then(reqObj => _types.RequestObject.safeParse(reqObj.payload));
|
82
86
|
if (!requestObject.success) {
|
87
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error while validating the response object: ${requestObject.error.message}`);
|
83
88
|
throw new _errors.ValidationFailed({
|
84
89
|
message: "Request Object validation failed",
|
85
90
|
reason: requestObject.error.message
|
@@ -106,6 +111,7 @@ const getRequestedCredentialToBePresented = async function (issuerRequestUri, cl
|
|
106
111
|
*/
|
107
112
|
exports.getRequestedCredentialToBePresented = getRequestedCredentialToBePresented;
|
108
113
|
const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
|
114
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
109
115
|
const {
|
110
116
|
wiaCryptoContext,
|
111
117
|
pidCryptoContext,
|
@@ -129,6 +135,7 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
|
|
129
135
|
jti: (0, _uuid.v4)().toString(),
|
130
136
|
nonce: requestObject.nonce
|
131
137
|
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
138
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Wallet instance attestation JWT token: ${wiaWpToken}`);
|
132
139
|
|
133
140
|
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
134
141
|
* is cointaned in the `vp` property of the signed jwt token payload
|
@@ -146,11 +153,13 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
|
|
146
153
|
format: "jwt"
|
147
154
|
}]
|
148
155
|
};
|
156
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
149
157
|
const authzResponsePayload = (0, _ioReactNativeJwt.encodeBase64)(JSON.stringify({
|
150
158
|
state: requestObject.state,
|
151
159
|
presentation_submission: presentationSubmission,
|
152
160
|
vp_token: [pidWpToken, wiaWpToken]
|
153
161
|
}));
|
162
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
154
163
|
|
155
164
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
156
165
|
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
@@ -173,6 +182,7 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
|
|
173
182
|
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(reqUri => reqUri.json());
|
174
183
|
const responseUri = _types2.ResponseUriResultShape.safeParse(resUriRes);
|
175
184
|
if (!responseUri.success) {
|
185
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error while validating the response uri: ${responseUri.error.message}`);
|
176
186
|
throw new _errors.ValidationFailed({
|
177
187
|
message: "Response Uri validation failed",
|
178
188
|
reason: responseUri.error.message
|
@@ -194,9 +204,11 @@ const parseAuthorizationResponse = authRes => {
|
|
194
204
|
if (!authResParsed.success) {
|
195
205
|
const authErr = _auth.AuthorizationErrorShape.safeParse(authRes);
|
196
206
|
if (!authErr.success) {
|
207
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error while parsing the authorization response: ${authResParsed.error.message}`);
|
197
208
|
throw new _errors2.AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
198
209
|
}
|
199
210
|
|
211
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error while authorizating with the idp: ${JSON.stringify(authErr)}`);
|
200
212
|
throw new _errors2.AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
201
213
|
}
|
202
214
|
return authResParsed.data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_ioReactNativeJwt","_types","_uuid","_types2","_decoder","_errors2","obj","__esModule","default","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","exports","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseUrl","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","
|
1
|
+
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_ioReactNativeJwt","_types","_uuid","_types2","_decoder","_errors2","_logging","obj","__esModule","default","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","exports","completeUserAuthorizationWithQueryMode","authRedirectUrl","Logger","log","LogLevel","DEBUG","query","parseUrl","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","hasStatusOrThrow","IssuerResponseError","res","text","jws","decode","reqObj","RequestObject","safeParse","payload","success","ERROR","error","message","ValidationFailed","reason","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","SignJWT","setProtectedHeader","alg","typ","setPayload","vp","jti","uuidv4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","JSON","stringify","authzResponsePayload","encodeBase64","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","ResponseUriResultShape","redirect_uri","getJwtFromFormPost","cbRes","decodedJwt","authRes","authResParsed","AuthorizationResultShape","authErr","AuthorizationErrorShape","AuthorizationError","AuthorizationIdpError","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,iBAAA,GAAAL,OAAA;AAMA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AAAuD,SAAAG,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,qBAA4C,GAAG,MAAAA,CAC1DC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,KACJ;EACH,MAAMC,oBAAoB,GACxBF,UAAU,CAACG,0BAA0B,CAACC,sBAAsB;EAE9D,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC;IACjCC,SAAS,EAAER,QAAQ;IACnBS,WAAW,EAAEV;EACf,CAAC,CAAC;EAEF,IAAIG,OAAO,EAAE;IACXI,MAAM,CAACI,MAAM,CAAC,SAAS,EAAER,OAAO,CAAC;EACnC;EAEA,MAAMS,OAAO,GAAI,GAAER,oBAAqB,IAAGG,MAAO,EAAC;EAEnD,OAAO;IAAEK;EAAQ,CAAC;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAC,OAAA,CAAAd,qBAAA,GAAAA,qBAAA;AAOO,MAAMe,sCAA8E,GACzF,MAAOC,eAAe,IAAK;EACzBC,eAAM,CAACC,GAAG,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ACC,UAAU,CAACtD,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AANA7B,OAAA,CAAAqC,4CAAA,GAAAA,4CAAA;AAOO,MAAM5B,0BAA0B,GACrC2E,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAGC,8BAAwB,CAAC1D,SAAS,CAACwD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAACvD,OAAO,EAAE;IAC1B,MAAMyD,OAAO,GAAGC,6BAAuB,CAAC5D,SAAS,CAACwD,OAAO,CAAC;IAC1D,IAAI,CAACG,OAAO,CAACzD,OAAO,EAAE;MACpB3B,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAAC0B,KAAK,EACb,mDAAkDsD,aAAa,CAACrD,KAAK,CAACC,OAAQ,EACjF,CAAC;MACD,MAAM,IAAIwD,2BAAkB,CAACJ,aAAa,CAACrD,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA9B,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAAC0B,KAAK,EACb,2CAA0CkC,IAAI,CAACC,SAAS,CAACqB,OAAO,CAAE,EACrE,CAAC;IACD,MAAM,IAAIG,8BAAqB,CAC7BH,OAAO,CAACnD,IAAI,CAACJ,KAAK,EAClBuD,OAAO,CAACnD,IAAI,CAACuD,iBACf,CAAC;EACH;EACA,OAAON,aAAa,CAACjD,IAAI;AAC3B,CAAC;AAACpC,OAAA,CAAAS,0BAAA,GAAAA,0BAAA"}
|
@@ -12,6 +12,7 @@ var WalletInstanceAttestation = _interopRequireWildcard(require("../../wallet-in
|
|
12
12
|
var _const = require("./const");
|
13
13
|
var _types = require("./types");
|
14
14
|
var _errors = require("../../utils/errors");
|
15
|
+
var _logging = require("../../utils/logging");
|
15
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
16
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
17
18
|
/**
|
@@ -49,11 +50,13 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
|
|
49
50
|
htu: tokenUrl,
|
50
51
|
jti: `${(0, _uuid.v4)()}`
|
51
52
|
}, dPopCryptoContext);
|
53
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
52
54
|
const signedWiaPoP = await (0, _pop.createPopToken)({
|
53
55
|
jti: `${(0, _uuid.v4)()}`,
|
54
56
|
aud,
|
55
57
|
iss
|
56
58
|
}, wiaCryptoContext);
|
59
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
57
60
|
const requestBody = {
|
58
61
|
grant_type: "authorization_code",
|
59
62
|
client_id: clientId,
|
@@ -64,6 +67,7 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
|
|
64
67
|
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
65
68
|
};
|
66
69
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
70
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
67
71
|
const tokenRes = await appFetch(tokenUrl, {
|
68
72
|
method: "POST",
|
69
73
|
headers: {
|
@@ -73,6 +77,7 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
|
|
73
77
|
body: authorizationRequestFormBody.toString()
|
74
78
|
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
|
75
79
|
if (!tokenRes.success) {
|
80
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Token Response validation failed: ${tokenRes.error.message}`);
|
76
81
|
throw new _errors.ValidationFailed({
|
77
82
|
message: "Token Response validation failed",
|
78
83
|
reason: tokenRes.error.message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_misc","require","_dpop","_uuid","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","TokenResponse","safeParse","success","
|
1
|
+
{"version":3,"names":["_misc","require","_dpop","_uuid","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_logging","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","Logger","log","LogLevel","DEBUG","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","TokenResponse","safeParse","success","ERROR","error","message","ValidationFailed","reason","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAC,uBAAA,CAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAEA,IAAAS,QAAA,GAAAT,OAAA;AAAuD,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,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,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAEzB;IACR,CAAC;IACD0B,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,2BAAmB,CAAC,CAAC,CAChDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBJ,IAAI,CAAEF,IAAI,IAAKO,oBAAa,CAACC,SAAS,CAACR,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACa,OAAO,EAAE;IACrB7B,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAAC4B,KAAK,EACb,qCAAoCd,QAAQ,CAACe,KAAK,CAACC,OAAQ,EAC9D,CAAC;IAED,MAAM,IAAIC,wBAAgB,CAAC;MACzBD,OAAO,EAAE,kCAAkC;MAC3CE,MAAM,EAAElB,QAAQ,CAACe,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEG,WAAW,EAAEnB,QAAQ,CAACoB;EAAK,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAvE,eAAA,GAAAA,eAAA"}
|
@@ -10,6 +10,7 @@ var _errors = require("../../utils/errors");
|
|
10
10
|
var _types = require("./types");
|
11
11
|
var _dpop = require("../../utils/dpop");
|
12
12
|
var _uuid = require("uuid");
|
13
|
+
var _logging = require("../../utils/logging");
|
13
14
|
const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
14
15
|
const jwk = await ctx.getPublicKey();
|
15
16
|
return new _ioReactNativeJwt.SignJWT(ctx).setPayload({
|
@@ -37,7 +38,7 @@ const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
37
38
|
* @returns The credential response containing the credential
|
38
39
|
*/
|
39
40
|
exports.createNonceProof = createNonceProof;
|
40
|
-
const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
41
|
+
const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
41
42
|
const {
|
42
43
|
credentialCryptoContext,
|
43
44
|
appFetch = fetch,
|
@@ -51,10 +52,12 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
51
52
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
52
53
|
*/
|
53
54
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
55
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
54
56
|
|
55
57
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
56
58
|
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
57
59
|
if (!containsCredentialDefinition) {
|
60
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
58
61
|
throw new _errors.ValidationFailed({
|
59
62
|
message: "The access token response does not contain the requested credential"
|
60
63
|
});
|
@@ -71,27 +74,34 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
71
74
|
proof_type: "jwt"
|
72
75
|
}
|
73
76
|
};
|
77
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`);
|
74
78
|
const tokenRequestSignedDPop = await (0, _dpop.createDPopToken)({
|
75
79
|
htm: "POST",
|
76
80
|
htu: credentialUrl,
|
77
81
|
jti: `${(0, _uuid.v4)()}`,
|
78
82
|
ath: await (0, _ioReactNativeJwt.sha256ToBase64)(accessToken.access_token)
|
79
83
|
}, dPopCryptoContext);
|
84
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
80
85
|
const credentialRes = await appFetch(credentialUrl, {
|
81
86
|
method: "POST",
|
82
87
|
headers: {
|
83
88
|
"Content-Type": "application/json",
|
84
89
|
DPoP: tokenRequestSignedDPop,
|
85
|
-
Authorization: `${accessToken.token_type} ${accessToken.access_token}
|
90
|
+
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
91
|
+
...(operationType === "reissuing" && {
|
92
|
+
operationType
|
93
|
+
})
|
86
94
|
},
|
87
95
|
body: JSON.stringify(credentialRequestFormBody)
|
88
96
|
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(body => _types.CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
89
97
|
if (!credentialRes.success) {
|
98
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential Response validation failed: ${credentialRes.error.message}`);
|
90
99
|
throw new _errors.ValidationFailed({
|
91
100
|
message: "Credential Response validation failed",
|
92
101
|
reason: credentialRes.error.message
|
93
102
|
});
|
94
103
|
}
|
104
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
95
105
|
return credentialRes.data;
|
96
106
|
};
|
97
107
|
|
@@ -103,6 +113,7 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
103
113
|
*/
|
104
114
|
exports.obtainCredential = obtainCredential;
|
105
115
|
const handleObtainCredentialError = e => {
|
116
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
106
117
|
if (!(e instanceof _errors.UnexpectedStatusCodeError)) {
|
107
118
|
throw e;
|
108
119
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_uuid","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ValidationFailed","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_uuid","_logging","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","Logger","log","LogLevel","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","ValidationFailed","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","hasStatusOrThrow","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","error","reason","data","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,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C,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEC,gCAAwB,CAACC,+BAA+B;IAC9D3C,OAAO,EACL;EACJ,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD5C,OAAO,EAAE;EACX,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD5C,OAAO,EAAE;EACX,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACG,uBAAuB;IACtD7C,OAAO,EAAE;EACX,CAAC,CAAC,CACD8C,SAAS,CAACV,CAAC,CAAC;AACjB,CAAC"}
|
@@ -8,6 +8,7 @@ var _errors = require("../../utils/errors");
|
|
8
8
|
var _types = require("../../sd-jwt/types");
|
9
9
|
var _sdJwt = require("../../sd-jwt");
|
10
10
|
var _converters = require("../../sd-jwt/converters");
|
11
|
+
var _logging = require("../../utils/logging");
|
11
12
|
// The credential as a collection of attributes in plain value
|
12
13
|
|
13
14
|
// handy alias
|
@@ -21,14 +22,17 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
21
22
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
22
23
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
23
24
|
if (!credentialSubject) {
|
25
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
|
24
26
|
throw new _errors.IoWalletError("Credential type not supported by the issuer");
|
25
27
|
}
|
26
28
|
if (credentialSubject.format !== sdJwt.header.typ) {
|
29
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
27
30
|
throw new _errors.IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
28
31
|
}
|
29
32
|
|
30
33
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
31
34
|
if (!credentialSubject.claims) {
|
35
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, "Missing claims in the credential subject");
|
32
36
|
throw new _errors.IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
33
37
|
}
|
34
38
|
|
@@ -46,6 +50,7 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
46
50
|
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
47
51
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
48
52
|
if (!ignoreMissingAttributes) {
|
53
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
49
54
|
throw new _errors.IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
50
55
|
}
|
51
56
|
}
|
@@ -124,6 +129,7 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
124
129
|
cnf
|
125
130
|
} = decodedCredential.sdJwt.payload;
|
126
131
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
132
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
127
133
|
throw new _errors.IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
128
134
|
}
|
129
135
|
return decodedCredential;
|
@@ -138,8 +144,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
138
144
|
includeUndefinedAttributes
|
139
145
|
} = _ref8;
|
140
146
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
147
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
141
148
|
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
142
149
|
const maybeIssuedAt = (0, _converters.getValueFromDisclosures)(decoded.disclosures, "iat");
|
150
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
143
151
|
return {
|
144
152
|
parsedCredential,
|
145
153
|
expiration: new Date(decoded.sdJwt.payload.exp * 1000),
|
@@ -162,8 +170,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
162
170
|
*/
|
163
171
|
const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
|
164
172
|
if (format === "vc+sd-jwt") {
|
173
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
|
165
174
|
return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
|
166
175
|
}
|
176
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Unsupported credential format: ${format}`);
|
167
177
|
throw new _errors.IoWalletError(`Unsupported credential format: ${format}`);
|
168
178
|
};
|
169
179
|
exports.verifyAndParseCredential = verifyAndParseCredential;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_types","_sdJwt","_converters","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","IoWalletError","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","parsedCredential","credential_configurations_supported","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;
|
1
|
+
{"version":3,"names":["_errors","require","_types","_sdJwt","_converters","_logging","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","Logger","log","LogLevel","ERROR","IoWalletError","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","parsedCredential","credential_configurations_supported","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GA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,EACvEP,OAAO,EACPrE,uBAAuB,EACvBI,0BACF,CAAC;EACD,MAAMyE,aAAa,GAAG,IAAAC,mCAAuB,EAACT,OAAO,CAACtE,WAAW,EAAE,KAAK,CAAC;EAEzES,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAAC8D,KAAK,EACb,sBAAqBC,IAAI,CAACC,SAAS,CAACC,gBAAgB,CAAE,gBAAeE,aAAc,EACtF,CAAC;EAED,OAAO;IACLF,gBAAgB;IAChBI,UAAU,EAAE,IAAIC,IAAI,CAACX,OAAO,CAACvE,KAAK,CAACQ,OAAO,CAAC2E,GAAG,GAAG,IAAI,CAAC;IACtDC,QAAQ,EACN,OAAOL,aAAa,KAAK,QAAQ,GAC7B,IAAIG,IAAI,CAACH,aAAa,GAAG,IAAI,CAAC,GAC9B1E;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMgF,wBAAkD,GAAG,MAAAA,CAChElB,UAAU,EACVC,UAAU,EACVrD,MAAM,EACNuE,OAAO,KACJ;EACH,IAAIvE,MAAM,KAAK,WAAW,EAAE;IAC1BL,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAAC8D,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOR,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVrD,MAAM,EACNuE,OACF,CAAC;EACH;EAEA5E,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAG,kCAAiCE,MAAO,EAAC,CAAC;EACtE,MAAM,IAAID,qBAAa,CAAE,kCAAiCC,MAAO,EAAC,CAAC;AACrE,CAAC;AAACwE,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
|
@@ -9,9 +9,9 @@ var _errors = require("./errors");
|
|
9
9
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
10
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11
11
|
const PresentationParams = z.object({
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
client_id: z.string().nonempty(),
|
13
|
+
request_uri: z.string().url(),
|
14
|
+
request_uri_method: z.enum(["get", "post"]),
|
15
15
|
state: z.string().optional()
|
16
16
|
});
|
17
17
|
|
@@ -19,21 +19,22 @@ const PresentationParams = z.object({
|
|
19
19
|
* The beginning of the presentation flow.
|
20
20
|
* To be implemented accordind to the user touchpoint
|
21
21
|
*
|
22
|
-
* @param params Presentation parameters, depending on the starting
|
22
|
+
* @param params Presentation parameters, depending on the starting touchpoint
|
23
23
|
* @returns The url for the Relying Party to connect with
|
24
24
|
*/
|
25
25
|
|
26
26
|
/**
|
27
|
-
* Start a presentation flow by
|
27
|
+
* Start a presentation flow by validating the required parameters.
|
28
|
+
* Parameters are extracted from a url encoded in a QR code or in a deep link.
|
28
29
|
*
|
29
|
-
* @param params The
|
30
|
+
* @param params The parameters to be validated
|
30
31
|
* @returns The url for the Relying Party to connect with
|
31
|
-
* @throws If the provided
|
32
|
+
* @throws If the provided parameters are not valid
|
32
33
|
*/
|
33
34
|
const startFlowFromQR = params => {
|
34
35
|
const result = PresentationParams.safeParse({
|
35
36
|
...params,
|
36
|
-
|
37
|
+
request_uri_method: params.request_uri_method ?? "get"
|
37
38
|
});
|
38
39
|
if (result.success) {
|
39
40
|
return result.data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","_interopRequireWildcard","require","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","PresentationParams","object","
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","PresentationParams","object","client_id","string","nonempty","request_uri","url","request_uri_method","enum","state","optional","startFlowFromQR","params","result","safeParse","success","data","InvalidQRCodeError","error","message","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAA8C,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,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AEK,MAAM,CAACL,kBAAkB,IAAI;EACnD,CAAC,CAAC;EAEF,IAAIM,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB;EAEA,MAAM,IAAIC,0BAAkB,CAACJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAAC;AACpD,CAAC;AAACC,OAAA,CAAAT,eAAA,GAAAA,eAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_misc","require","_types","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","RequestObjectWalletCapabilities","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","hasStatusOrThrow","res","text","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;
|
1
|
+
{"version":3,"names":["_misc","require","_types","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","RequestObjectWalletCapabilities","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","hasStatusOrThrow","res","text","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,gBAAkC,GAAG,eAAAA,CAChDC,UAAU,EAEP;EAAA,IADH;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAAmB,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE7C,IAAID,kBAAkB,EAAE;IACtB;IACA,MAAM;MAAEI,eAAe;MAAEC;IAAa,CAAC,GACrCC,sCAA+B,C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