@pagopa/io-react-native-wallet 0.28.2 → 0.30.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 +3 -2
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +57 -22
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +43 -16
- 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/08-send-authorization-response.js +85 -3
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +27 -9
- package/lib/commonjs/credential/presentation/errors.js +28 -23
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +6 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +14 -7
- package/lib/commonjs/credential/presentation/types.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/error-codes.js +9 -1
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +31 -14
- package/lib/commonjs/utils/errors.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 +3 -2
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +58 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +44 -17
- 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/08-send-authorization-response.js +82 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +27 -9
- package/lib/module/credential/presentation/errors.js +17 -19
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +2 -2
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +12 -6
- package/lib/module/credential/presentation/types.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/error-codes.js +7 -0
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +23 -14
- package/lib/module/utils/errors.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/05-verify-request-object.d.ts +2 -1
- package/lib/typescript/credential/presentation/05-verify-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/08-send-authorization-response.d.ts +30 -2
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +17 -12
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +3 -3
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +24 -17
- package/lib/typescript/credential/presentation/types.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/error-codes.d.ts +8 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +32 -18
- package/lib/typescript/utils/errors.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 +5 -5
- package/src/credential/presentation/05-verify-request-object.ts +73 -15
- package/src/credential/presentation/07-evaluate-dcql-query.ts +43 -18
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +25 -13
- package/src/credential/presentation/08-send-authorization-response.ts +110 -3
- package/src/credential/presentation/README.md +27 -9
- package/src/credential/presentation/errors.ts +24 -17
- package/src/credential/presentation/index.ts +4 -0
- package/src/credential/presentation/types.ts +22 -10
- 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/error-codes.ts +11 -0
- package/src/utils/errors.ts +59 -29
- 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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logger = exports.LogLevel = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Logger interface which can be provided to the Logger class as a custom implementation.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Supported debug levels.
|
|
12
|
+
*/
|
|
13
|
+
let LogLevel = /*#__PURE__*/function (LogLevel) {
|
|
14
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
15
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
16
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
17
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
18
|
+
return LogLevel;
|
|
19
|
+
}({});
|
|
20
|
+
/**
|
|
21
|
+
* Logger singleton class which provides a simple logging interface with an init function to set the logging context and
|
|
22
|
+
* a static log function to log messages based on the debug level.
|
|
23
|
+
* This can be used as follows:
|
|
24
|
+
* const logger = Logger.getInstance();
|
|
25
|
+
* logger.initLogging(yourLoggingContext);
|
|
26
|
+
* logger.log(LogLevel.DEBUG, "Debug message");
|
|
27
|
+
*/
|
|
28
|
+
exports.LogLevel = LogLevel;
|
|
29
|
+
class Logger {
|
|
30
|
+
static instance = null;
|
|
31
|
+
// Private constructor to prevent direct instantiation
|
|
32
|
+
constructor() {}
|
|
33
|
+
|
|
34
|
+
// Public static method to get the Logger instance
|
|
35
|
+
static getInstance() {
|
|
36
|
+
if (Logger.instance === null) {
|
|
37
|
+
Logger.instance = new Logger();
|
|
38
|
+
}
|
|
39
|
+
return Logger.instance;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Method to initialize the logging context
|
|
43
|
+
initLogging(loggingCtx) {
|
|
44
|
+
Logger.loggingContext = loggingCtx;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Method to log based on the level which wraps the null check for the logging context
|
|
48
|
+
static log(level, msg) {
|
|
49
|
+
if (Logger.loggingContext) {
|
|
50
|
+
switch (level) {
|
|
51
|
+
case LogLevel.DEBUG:
|
|
52
|
+
Logger.loggingContext.logDebug(msg);
|
|
53
|
+
break;
|
|
54
|
+
case LogLevel.INFO:
|
|
55
|
+
Logger.loggingContext.logInfo(msg);
|
|
56
|
+
break;
|
|
57
|
+
case LogLevel.WARN:
|
|
58
|
+
Logger.loggingContext.logWarn(msg);
|
|
59
|
+
break;
|
|
60
|
+
case LogLevel.ERROR:
|
|
61
|
+
Logger.loggingContext.logError(msg);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Logger = Logger;
|
|
68
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LogLevel","exports","Logger","instance","constructor","getInstance","initLogging","loggingCtx","loggingContext","log","level","msg","DEBUG","logDebug","INFO","logInfo","WARN","logWarn","ERROR","logError"],"sourceRoot":"../../../src","sources":["utils/logging.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AAQA;AACA;AACA;AAFA,IAGYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAOpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AAQO,MAAME,MAAM,CAAC;EAClB,OAAeC,QAAQ,GAAkB,IAAI;EAG7C;EACQC,WAAWA,CAAA,EAAG,CAAC;;EAEvB;EACA,OAAcC,WAAWA,CAAA,EAAW;IAClC,IAAIH,MAAM,CAACC,QAAQ,KAAK,IAAI,EAAE;MAC5BD,MAAM,CAACC,QAAQ,GAAG,IAAID,MAAM,CAAC,CAAC;IAChC;IACA,OAAOA,MAAM,CAACC,QAAQ;EACxB;;EAEA;EACOG,WAAWA,CAACC,UAA0B,EAAQ;IACnDL,MAAM,CAACM,cAAc,GAAGD,UAAU;EACpC;;EAEA;EACA,OAAcE,GAAGA,CAACC,KAAe,EAAEC,GAAW,EAAQ;IACpD,IAAIT,MAAM,CAACM,cAAc,EAAE;MACzB,QAAQE,KAAK;QACX,KAAKV,QAAQ,CAACY,KAAK;UACjBV,MAAM,CAACM,cAAc,CAACK,QAAQ,CAACF,GAAG,CAAC;UACnC;QACF,KAAKX,QAAQ,CAACc,IAAI;UAChBZ,MAAM,CAACM,cAAc,CAACO,OAAO,CAACJ,GAAG,CAAC;UAClC;QACF,KAAKX,QAAQ,CAACgB,IAAI;UAChBd,MAAM,CAACM,cAAc,CAACS,OAAO,CAACN,GAAG,CAAC;UAClC;QACF,KAAKX,QAAQ,CAACkB,KAAK;UACjBhB,MAAM,CAACM,cAAc,CAACW,QAAQ,CAACR,GAAG,CAAC;UACnC;MACJ;IACF;EACF;AACF;AAACV,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.safeJsonParse = exports.parseRawHttpResponse = exports.hasStatusOrThrow = exports.getCredentialHashWithouDiscloures = exports.generateRandomAlphaNumericString = void 0;
|
|
7
7
|
var _errors = require("./errors");
|
|
8
8
|
var _jsSha = require("js-sha256");
|
|
9
|
+
var _logging = require("./logging");
|
|
9
10
|
/**
|
|
10
11
|
* Check if a response is in the expected status, otherwise throw an error
|
|
11
12
|
* @param status - The expected status
|
|
@@ -16,6 +17,7 @@ var _jsSha = require("js-sha256");
|
|
|
16
17
|
const hasStatusOrThrow = (status, customError) => async res => {
|
|
17
18
|
if (res.status !== status) {
|
|
18
19
|
const ErrorClass = customError ?? _errors.UnexpectedStatusCodeError;
|
|
20
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
|
|
19
21
|
throw new ErrorClass({
|
|
20
22
|
message: `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`,
|
|
21
23
|
statusCode: res.status,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_errors","require","_jsSha","hasStatusOrThrow","status","customError","res","ErrorClass","UnexpectedStatusCodeError","
|
|
1
|
+
{"version":3,"names":["_errors","require","_jsSha","_logging","hasStatusOrThrow","status","customError","res","ErrorClass","UnexpectedStatusCodeError","Logger","log","LogLevel","ERROR","url","message","statusCode","reason","parseRawHttpResponse","exports","response","_response$headers$get","headers","get","includes","json","text","generateRandomAlphaNumericString","size","Array","from","Math","floor","random","toString","join","getCredentialHashWithouDiscloures","credential","tildeIndex","indexOf","IoWalletError","sha256","slice","safeJsonParse","withDefault","JSON","parse","_"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,GAC3BA,CAACC,MAAc,EAAEC,WAA8C,KAC/D,MAAOC,GAAa,IAAwB;EAC1C,IAAIA,GAAG,CAACF,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAMG,UAAU,GAAGF,WAAW,IAAIG,iCAAyB;IAC3DC,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,iCAAgCR,MAAO,SAAQE,GAAG,CAACF,MAAO,UAASE,GAAG,CAACO,G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2B,CAAC;EACtD;EACA,OAAO,IAAAC,aAAM,EAACJ,UAAU,CAACK,KAAK,CAAC,CAAC,EAAEJ,UAAU,CAAC,CAAC;AAChD,CAAC;AAACnB,OAAA,CAAAiB,iCAAA,GAAAA,iCAAA;AAEK,MAAMO,aAAa,GAAGA,CAAIjB,IAAY,EAAEkB,WAAe,KAAe;EAC3E,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACpB,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOqB,CAAC,EAAE;IACV,OAAOH,WAAW,IAAI,IAAI;EAC5B;AACF,CAAC;AAACzB,OAAA,CAAAwB,aAAA,GAAAA,aAAA"}
|
|
@@ -11,6 +11,7 @@ var WalletInstanceAttestation = _interopRequireWildcard(require("../wallet-insta
|
|
|
11
11
|
var _misc = require("./misc");
|
|
12
12
|
var _pop = require("./pop");
|
|
13
13
|
var _errors = require("./errors");
|
|
14
|
+
var _logging = require("./logging");
|
|
14
15
|
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); }
|
|
15
16
|
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; }
|
|
16
17
|
const AuthorizationDetail = z.object({
|
|
@@ -81,6 +82,7 @@ const makeParRequest = _ref => {
|
|
|
81
82
|
client_assertion_type: assertionType,
|
|
82
83
|
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
|
83
84
|
});
|
|
85
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Sending to PAR endpoint ${parEndpoint}: ${formBody}`);
|
|
84
86
|
return await appFetch(parEndpoint, {
|
|
85
87
|
method: "POST",
|
|
86
88
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_uuid","z","_interopRequireWildcard","WalletInstanceAttestation","_misc","_pop","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","credential_configuration_id","string","format","union","literal","type","exports","AuthorizationDetails","array","makeParRequest","_ref","wiaCryptoContext","appFetch","clientId","codeVerifier","redirectUri","responseMode","parEndpoint","walletInstanceAttestation","authorizationDetails","assertionType","wiaPublicKey","getPublicKey","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","signedWiaPoP","createPopToken","jti","uuidv4","codeChallengeMethod","codeChallenge","sha256ToBase64","signedJwtForPar","SignJWT","setProtectedHeader","typ","setPayload","response_type","response_mode","client_id","state","generateRandomAlphaNumericString","code_challenge","code_challenge_method","authorization_details","redirect_uri","client_assertion_type","client_assertion","setIssuedAt","setExpirationTime","sign","formBody","URLSearchParams","request","method","headers","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","result","request_uri"],"sourceRoot":"../../../src","sources":["utils/par.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;
|
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_uuid","z","_interopRequireWildcard","WalletInstanceAttestation","_misc","_pop","_errors","_logging","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","credential_configuration_id","string","format","union","literal","type","exports","AuthorizationDetails","array","makeParRequest","_ref","wiaCryptoContext","appFetch","clientId","codeVerifier","redirectUri","responseMode","parEndpoint","walletInstanceAttestation","authorizationDetails","assertionType","wiaPublicKey","getPublicKey","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","signedWiaPoP","createPopToken","jti","uuidv4","codeChallengeMethod","codeChallenge","sha256ToBase64","signedJwtForPar","SignJWT","setProtectedHeader","typ","setPayload","response_type","response_mode","client_id","state","generateRandomAlphaNumericString","code_challenge","code_challenge_method","authorization_details","redirect_uri","client_assertion_type","client_assertion","setIssuedAt","setExpirationTime","sign","formBody","URLSearchParams","request","Logger","log","LogLevel","DEBUG","method","headers","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","result","request_uri"],"sourceRoot":"../../../src","sources":["utils/par.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAA6C,SAAAS,yBAAAC,WA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ACU,QAAQ,CAAC;IAC1B,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,CAAEK,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC;EACzC,CAAC;AAAA;AAACvE,OAAA,CAAAG,cAAA,GAAAA,cAAA"}
|
|
@@ -9,6 +9,7 @@ exports.getWalletInstanceStatus = getWalletInstanceStatus;
|
|
|
9
9
|
exports.revokeWalletInstance = revokeWalletInstance;
|
|
10
10
|
var _client = require("../client");
|
|
11
11
|
var _errors = require("../utils/errors");
|
|
12
|
+
var _logging = require("../utils/logging");
|
|
12
13
|
async function createWalletInstance(context) {
|
|
13
14
|
const {
|
|
14
15
|
integrityContext
|
|
@@ -17,8 +18,10 @@ async function createWalletInstance(context) {
|
|
|
17
18
|
|
|
18
19
|
//1. Obtain nonce
|
|
19
20
|
const challenge = await api.get("/nonce").then(response => response.nonce);
|
|
21
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Challenge obtained from ${context.walletProviderBaseUrl}: ${challenge}`);
|
|
20
22
|
const keyAttestation = await integrityContext.getAttestation(challenge);
|
|
21
23
|
const hardwareKeyTag = integrityContext.getHardwareKeyTag();
|
|
24
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Key attestation: ${keyAttestation}\nAssociated hardware key tag: ${hardwareKeyTag}`);
|
|
22
25
|
|
|
23
26
|
//2. Create Wallet Instance
|
|
24
27
|
await api.post("/wallet-instances", {
|
|
@@ -31,6 +34,7 @@ async function createWalletInstance(context) {
|
|
|
31
34
|
return hardwareKeyTag;
|
|
32
35
|
}
|
|
33
36
|
const handleCreateWalletInstanceError = e => {
|
|
37
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `An error occurred while calling /wallet-instances endpoint: ${e}`);
|
|
34
38
|
if (!(e instanceof _errors.WalletProviderResponseError)) {
|
|
35
39
|
throw e;
|
|
36
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_client","require","_errors","createWalletInstance","context","integrityContext","api","getWalletProviderClient","challenge","get","then","response","nonce","keyAttestation","getAttestation","hardwareKeyTag","getHardwareKeyTag","post","body","key_attestation","hardware_key_tag","catch","handleCreateWalletInstanceError","e","WalletProviderResponseError","ResponseErrorBuilder","handle","code","WalletProviderResponseErrorCodes","WalletInstanceIntegrityFailed","message","WalletInstanceCreationFailed","buildFrom","revokeWalletInstance","put","path","id","status","getWalletInstanceStatus","getCurrentWalletInstanceStatus"],"sourceRoot":"../../../src","sources":["wallet-instance/index.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_client","require","_errors","_logging","createWalletInstance","context","integrityContext","api","getWalletProviderClient","challenge","get","then","response","nonce","Logger","log","LogLevel","DEBUG","walletProviderBaseUrl","keyAttestation","getAttestation","hardwareKeyTag","getHardwareKeyTag","post","body","key_attestation","hardware_key_tag","catch","handleCreateWalletInstanceError","e","ERROR","WalletProviderResponseError","ResponseErrorBuilder","handle","code","WalletProviderResponseErrorCodes","WalletInstanceIntegrityFailed","message","WalletInstanceCreationFailed","buildFrom","revokeWalletInstance","put","path","id","status","getWalletInstanceStatus","getCurrentWalletInstanceStatus"],"sourceRoot":"../../../src","sources":["wallet-instance/index.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA,IAAAE,QAAA,GAAAF,OAAA;AAEO,eAAeG,oBAAoBA,CAACC,OAI1C,EAAE;EACD,MAAM;IAAEC;EAAiB,CAAC,GAAGD,OAAO;EACpC,MAAME,GAAG,GAAG,IAAAC,+BAAuB,EAACH,OAAO,CAAC;;EAE5C;EACA,MAAMI,SAAS,GAAG,MAAMF,GA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AAiB;EAChB,MAAME,GAAG,GAAG,IAAAC,+BAAuB,EAACH,OAAO,CAAC;EAE5C,MAAME,GAAG,CAACkC,GAAG,CAAC,+BAA+B,EAAE;IAC7CC,IAAI,EAAE;MAAEC,EAAE,EAAEtC,OAAO,CAACsC;IAAG,CAAC;IACxBnB,IAAI,EAAE;MAAEoB,MAAM,EAAE;IAAU;EAC5B,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACO,eAAeC,uBAAuBA,CAACxC,OAI7C,EAA+B;EAC9B,MAAME,GAAG,GAAG,IAAAC,+BAAuB,EAACH,OAAO,CAAC;EAE5C,OAAOE,GAAG,CAACG,GAAG,CAAC,+BAA+B,EAAE;IAC9CgC,IAAI,EAAE;MAAEC,EAAE,EAAEtC,OAAO,CAACsC;IAAG;EACzB,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACO,eAAeG,8BAA8BA,CAACzC,OAGpD,EAA+B;EAC9B,MAAME,GAAG,GAAG,IAAAC,+BAAuB,EAACH,OAAO,CAAC;EAE5C,OAAOE,GAAG,CAACG,GAAG,CAAC,kCAAkC,CAAC;AACpD"}
|
|
@@ -10,6 +10,7 @@ var _jwk = require("../utils/jwk");
|
|
|
10
10
|
var _client = require("../client");
|
|
11
11
|
var _errors = require("../utils/errors");
|
|
12
12
|
var _types = require("./types");
|
|
13
|
+
var _logging = require("../utils/logging");
|
|
13
14
|
/**
|
|
14
15
|
* Getter for an attestation request. The attestation request is a JWT that will be sent to the Wallet Provider to request a Wallet Instance Attestation.
|
|
15
16
|
*
|
|
@@ -75,9 +76,11 @@ const getAttestation = async _ref => {
|
|
|
75
76
|
|
|
76
77
|
// 1. Get nonce from backend
|
|
77
78
|
const challenge = await api.get("/nonce").then(response => response.nonce);
|
|
79
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Challenge obtained from ${walletProviderBaseUrl}: ${challenge} `);
|
|
78
80
|
|
|
79
81
|
// 2. Get a signed attestation request
|
|
80
82
|
const signedAttestationRequest = await getAttestationRequest(challenge, wiaCryptoContext, integrityContext, walletProviderBaseUrl);
|
|
83
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Signed attestation request: ${signedAttestationRequest}`);
|
|
81
84
|
|
|
82
85
|
// 3. Request WIA
|
|
83
86
|
const tokenResponse = await api.post("/token", {
|
|
@@ -86,10 +89,12 @@ const getAttestation = async _ref => {
|
|
|
86
89
|
assertion: signedAttestationRequest
|
|
87
90
|
}
|
|
88
91
|
}).then(result => _types.TokenResponse.parse(result)).catch(handleAttestationCreationError);
|
|
92
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Obtained wallet attestation: ${tokenResponse.wallet_attestation}`);
|
|
89
93
|
return tokenResponse.wallet_attestation;
|
|
90
94
|
};
|
|
91
95
|
exports.getAttestation = getAttestation;
|
|
92
96
|
const handleAttestationCreationError = e => {
|
|
97
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `An error occurred while calling /token endpoint: ${e}`);
|
|
93
98
|
if (!(e instanceof _errors.WalletProviderResponseError)) {
|
|
94
99
|
throw e;
|
|
95
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_client","_errors","_types","getAttestationRequest","challenge","wiaCryptoContext","integrityContext","walletProviderBaseUrl","jwk","getPublicKey","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","clientData","jwk_thumbprint","hardwareKeyTag","getHardwareKeyTag","signature","authenticatorData","getHardwareSignatureWithAuthData","JSON","stringify","SignJWT","setPayload","iss","sub","hardware_signature","integrity_assertion","hardware_key_tag","cnf","fixBase64EncodingOnKey","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","api","getWalletProviderClient","get","then","response","nonce","signedAttestationRequest","tokenResponse","post","body","grant_type","assertion","result","TokenResponse","catch","handleAttestationCreationError","wallet_attestation","exports","e","WalletProviderResponseError","ResponseErrorBuilder","handle","code","WalletProviderResponseErrorCodes","WalletInstanceRevoked","message","WalletInstanceNotFound","WalletInstanceIntegrityFailed","WalletInstanceAttestationIssuingFailed","buildFrom"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,
|
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_client","_errors","_types","_logging","getAttestationRequest","challenge","wiaCryptoContext","integrityContext","walletProviderBaseUrl","jwk","getPublicKey","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","clientData","jwk_thumbprint","hardwareKeyTag","getHardwareKeyTag","signature","authenticatorData","getHardwareSignatureWithAuthData","JSON","stringify","SignJWT","setPayload","iss","sub","hardware_signature","integrity_assertion","hardware_key_tag","cnf","fixBase64EncodingOnKey","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","api","getWalletProviderClient","get","then","response","nonce","Logger","log","LogLevel","DEBUG","signedAttestationRequest","tokenResponse","post","body","grant_type","assertion","result","TokenResponse","catch","handleAttestationCreationError","wallet_attestation","exports","e","ERROR","WalletProviderResponseError","ResponseErrorBuilder","handle","code","WalletProviderResponseErrorCodes","WalletInstanceRevoked","message","WalletInstanceNotFound","WalletInstanceIntegrityFailed","WalletInstanceAttestationIssuingFailed","buildFrom"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GA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ACC,GAAG,CACRC,iBAAQ,CAACe,KAAK,EACb,oDAAmDD,CAAE,EACxD,CAAC;EAED,IAAI,EAAEA,CAAC,YAAYE,mCAA2B,CAAC,EAAE;IAC/C,MAAMF,CAAC;EACT;EAEA,MAAM,IAAIG,4BAAoB,CAACD,mCAA2B,CAAC,CACxDE,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,wCAAgC,CAACC,qBAAqB;IAC5DC,OAAO,EAAE;EACX,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,wCAAgC,CAACG,sBAAsB;IAC7DD,OAAO,EACL;EACJ,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,wCAAgC,CAACI,6BAA6B;IACpEF,OAAO,EACL;EACJ,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,wCAAgC,CAACK,sCAAsC;IAC7EH,OAAO,EAAE;EACX,CAAC,CAAC,CACDI,SAAS,CAACZ,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { generateRandomAlphaNumericString } from "../../utils/misc";
|
|
2
2
|
import { makeParRequest } from "../../utils/par";
|
|
3
3
|
import { ASSERTION_TYPE } from "./const";
|
|
4
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
|
4
5
|
/**
|
|
5
6
|
* Ensures that the credential type requested is supported by the issuer and contained in the
|
|
6
7
|
* issuer configuration.
|
|
@@ -20,6 +21,7 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
|
20
21
|
type: "openid_credential"
|
|
21
22
|
}));
|
|
22
23
|
if (!result) {
|
|
24
|
+
Logger.log(LogLevel.ERROR, `Requested credential type ${credentialType} is not supported by the issuer according to its configuration ${JSON.stringify(credential_configurations_supported)}`);
|
|
23
25
|
throw new Error(`No credential support the type '${credentialType}'`);
|
|
24
26
|
}
|
|
25
27
|
return result;
|
|
@@ -34,7 +36,9 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
|
34
36
|
const selectResponseMode = (issuerConf, credentialType) => {
|
|
35
37
|
const responseModeSupported = issuerConf.oauth_authorization_server.response_modes_supported;
|
|
36
38
|
const responseMode = credentialType === "PersonIdentificationData" ? "query" : "form_post.jwt";
|
|
39
|
+
Logger.log(LogLevel.DEBUG, `Selected response mode ${responseMode} for credential type ${credentialType}`);
|
|
37
40
|
if (!responseModeSupported.includes(responseMode)) {
|
|
41
|
+
Logger.log(LogLevel.ERROR, `Requested response mode ${responseMode} is not supported by the issuer according to its configuration ${JSON.stringify(responseModeSupported)}`);
|
|
38
42
|
throw new Error(`No response mode support the type '${credentialType}'`);
|
|
39
43
|
}
|
|
40
44
|
return responseMode;
|
|
@@ -67,6 +71,7 @@ export const startUserAuthorization = async (issuerConf, credentialType, ctx) =>
|
|
|
67
71
|
} = ctx;
|
|
68
72
|
const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
|
|
69
73
|
if (!clientId) {
|
|
74
|
+
Logger.log(LogLevel.ERROR, `Public key associated with kid ${clientId} not found in the device`);
|
|
70
75
|
throw new Error("No public key found");
|
|
71
76
|
}
|
|
72
77
|
const codeVerifier = generateRandomAlphaNumericString(64);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generateRandomAlphaNumericString","makeParRequest","ASSERTION_TYPE","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","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","issuerRequestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAEA,SAASA,gCAAgC,QAAkB,kBAAkB;AAG7E,SAA8BC,cAAc,QAAQ,iBAAiB;AACrE,SAASC,cAAc,QAAQ,SAAS;
|
|
1
|
+
{"version":3,"names":["generateRandomAlphaNumericString","makeParRequest","ASSERTION_TYPE","LogLevel","Logger","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","log","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","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","issuerRequestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAEA,SAASA,gCAAgC,QAAkB,kBAAkB;AAG7E,SAA8BC,cAAc,QAAQ,iBAAiB;AACrE,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAkBtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGA,CACjCC,UAAkD,EAClDC,cAAgD,KACxB;EACxB,MAAMC,mCAAmC,GACvCF,UAAU,CAACG,wBAAwB,CAACD,mCAAmC;EAEzE,MAAM,CAACE,MAAM,CAAC,GAAGC,MAAM,CAACC,IAAI,CAACJ,mCAAmC,CAAC,CAC9DK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,QAAQ,CAACR,cAAc,CAAC,CAAC,CACzCS,GAAG,CAAEF,CAAC,KAAM;IACXG,2BAA2B,EAAEV,cAAc;IAC3CW,MAAM,EAAEV,mCAAmC,CAACM,CAAC,CAAC,CAAEI,MAAM;IACtDC,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAEL,IAAI,CAACT,MAAM,EAAE;IACXN,MAAM,CAACgB,GAAG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AG,CAAC;EACzE,IAAI,CAACJ,QAAQ,EAAE;IACblC,MAAM,CAACgB,GAAG,CACRjB,QAAQ,CAACkB,KAAK,EACb,kCAAiCiB,QAAS,0BAC7C,CAAC;IACD,MAAM,IAAId,KAAK,CAAC,qBAAqB,CAAC;EACxC;EACA,MAAMmB,YAAY,GAAG3C,gCAAgC,CAAC,EAAE,CAAC;EACzD,MAAM4C,WAAW,GACftC,UAAU,CAACqB,0BAA0B,CAACkB,qCAAqC;EAC7E,MAAMC,oBAAoB,GAAGzC,0BAA0B,CACrDC,UAAU,EACVC,cACF,CAAC;EACD,MAAMsB,YAAY,GAAGJ,kBAAkB,CAACnB,UAAU,EAAEC,cAAc,CAAC;EAEnE,MAAMwC,MAAM,GAAG9C,cAAc,CAAC;IAAEgC,gBAAgB;IAAEG;EAAS,CAAC,CAAC;EAC7D,MAAMY,gBAAgB,GAAG,MAAMD,MAAM,CACnCT,QAAQ,EACRK,YAAY,EACZR,WAAW,EACXN,YAAY,EACZe,WAAW,EACXV,yBAAyB,EACzB,CAACY,oBAAoB,CAAC,EACtB5C,cACF,CAAC;EAED,OAAO;IAAE8C,gBAAgB;IAAEV,QAAQ;IAAEK,YAAY;IAAEG;EAAqB,CAAC;AAC3E,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
8
8
|
import { ResponseUriResultShape } from "./types";
|
|
9
9
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
|
10
10
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
|
11
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
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.
|
|
@@ -45,6 +46,7 @@ export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerCo
|
|
|
45
46
|
* @returns the authorization response which contains code, state and iss
|
|
46
47
|
*/
|
|
47
48
|
export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
|
49
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`);
|
|
48
50
|
const query = parseUrl(authRedirectUrl).query;
|
|
49
51
|
return parseAuthorizationResponse(query);
|
|
50
52
|
};
|
|
@@ -63,15 +65,18 @@ export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
|
|
63
65
|
*/
|
|
64
66
|
export const getRequestedCredentialToBePresented = async function (issuerRequestUri, clientId, issuerConf) {
|
|
65
67
|
let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
|
|
68
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`);
|
|
66
69
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
|
67
70
|
const params = new URLSearchParams({
|
|
68
71
|
client_id: clientId,
|
|
69
72
|
request_uri: issuerRequestUri
|
|
70
73
|
});
|
|
74
|
+
Logger.log(LogLevel.DEBUG, `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`);
|
|
71
75
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
|
72
76
|
method: "GET"
|
|
73
77
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
|
|
74
78
|
if (!requestObject.success) {
|
|
79
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response object: ${requestObject.error.message}`);
|
|
75
80
|
throw new ValidationFailed({
|
|
76
81
|
message: "Request Object validation failed",
|
|
77
82
|
reason: requestObject.error.message
|
|
@@ -97,6 +102,7 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
|
97
102
|
* @returns the authorization response which contains code, state and iss
|
|
98
103
|
*/
|
|
99
104
|
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
|
|
105
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
|
100
106
|
const {
|
|
101
107
|
wiaCryptoContext,
|
|
102
108
|
pidCryptoContext,
|
|
@@ -120,6 +126,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
|
120
126
|
jti: uuidv4().toString(),
|
|
121
127
|
nonce: requestObject.nonce
|
|
122
128
|
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
|
129
|
+
Logger.log(LogLevel.DEBUG, `Wallet instance attestation JWT token: ${wiaWpToken}`);
|
|
123
130
|
|
|
124
131
|
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
|
125
132
|
* is cointaned in the `vp` property of the signed jwt token payload
|
|
@@ -137,11 +144,13 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
|
137
144
|
format: "jwt"
|
|
138
145
|
}]
|
|
139
146
|
};
|
|
147
|
+
Logger.log(LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
|
140
148
|
const authzResponsePayload = encodeBase64(JSON.stringify({
|
|
141
149
|
state: requestObject.state,
|
|
142
150
|
presentation_submission: presentationSubmission,
|
|
143
151
|
vp_token: [pidWpToken, wiaWpToken]
|
|
144
152
|
}));
|
|
153
|
+
Logger.log(LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
|
145
154
|
|
|
146
155
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
|
147
156
|
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
|
@@ -164,6 +173,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
|
164
173
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
|
|
165
174
|
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
|
166
175
|
if (!responseUri.success) {
|
|
176
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response uri: ${responseUri.error.message}`);
|
|
167
177
|
throw new ValidationFailed({
|
|
168
178
|
message: "Response Uri validation failed",
|
|
169
179
|
reason: responseUri.error.message
|
|
@@ -184,9 +194,11 @@ export const parseAuthorizationResponse = authRes => {
|
|
|
184
194
|
if (!authResParsed.success) {
|
|
185
195
|
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
|
186
196
|
if (!authErr.success) {
|
|
197
|
+
Logger.log(LogLevel.ERROR, `Error while parsing the authorization response: ${authResParsed.error.message}`);
|
|
187
198
|
throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
|
188
199
|
}
|
|
189
200
|
|
|
201
|
+
Logger.log(LogLevel.ERROR, `Error while authorizating with the idp: ${JSON.stringify(authErr)}`);
|
|
190
202
|
throw new AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
|
191
203
|
}
|
|
192
204
|
return authResParsed.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","
|
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","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","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","JSON","stringify","authzResponsePayload","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"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,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;AACpE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;;AAEtD;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAA4C,GAAG,MAAAA,CAC1DC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,KACJ;EACH,MAAMC,oBAAoB,GACxBF,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 -6,6 +6,7 @@ import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
|
|
6
6
|
import { ASSERTION_TYPE } from "./const";
|
|
7
7
|
import { TokenResponse } from "./types";
|
|
8
8
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
|
9
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
|
9
10
|
/**
|
|
10
11
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
|
11
12
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
|
@@ -41,11 +42,13 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
|
41
42
|
htu: tokenUrl,
|
|
42
43
|
jti: `${uuidv4()}`
|
|
43
44
|
}, dPopCryptoContext);
|
|
45
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
|
44
46
|
const signedWiaPoP = await createPopToken({
|
|
45
47
|
jti: `${uuidv4()}`,
|
|
46
48
|
aud,
|
|
47
49
|
iss
|
|
48
50
|
}, wiaCryptoContext);
|
|
51
|
+
Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
|
49
52
|
const requestBody = {
|
|
50
53
|
grant_type: "authorization_code",
|
|
51
54
|
client_id: clientId,
|
|
@@ -56,6 +59,7 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
|
56
59
|
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
|
57
60
|
};
|
|
58
61
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
|
62
|
+
Logger.log(LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
|
59
63
|
const tokenRes = await appFetch(tokenUrl, {
|
|
60
64
|
method: "POST",
|
|
61
65
|
headers: {
|
|
@@ -65,6 +69,7 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
|
65
69
|
body: authorizationRequestFormBody.toString()
|
|
66
70
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
|
|
67
71
|
if (!tokenRes.success) {
|
|
72
|
+
Logger.log(LogLevel.ERROR, `Token Response validation failed: ${tokenRes.error.message}`);
|
|
68
73
|
throw new ValidationFailed({
|
|
69
74
|
message: "Token Response validation failed",
|
|
70
75
|
reason: tokenRes.error.message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","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","htm","htu","jti","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","
|
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","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","htm","htu","jti","log","DEBUG","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","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,cAAc,QAAQ,SAAS;AACxC,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,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,OAAO,KACJ;EACH,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC,gBAAgB;IAChBC;EACF,CAAC,GAAGL,OAAO;EAEX,MAAMM,WAAW,GACfX,UAAU,CAACY,0BAA0B,CAACC,qCAAqC;EAC7E,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAACJ,WAAW,CAAC;EACnC,MAAMK,GAAG,GAAI,GAAEF,MAAM,CAACG,QAAS,KAAIH,MAAM,CAACI,QAAS,EAAC;EACpD,MAAMC,GAAG,GAAG3B,yBAAyB,CAAC4B,MAAM,CAACZ,yBAAyB,CAAC,CACpEa,OAAO,CAACC,GAAG,CAACC,GAAG,CAACC,GAAG;EAEtB,MAAMC,QAAQ,GAAGzB,UAAU,CAACY,0BAA0B,CAACc,cAAc;EAErE,MAAMC,sBAAsB,GAAG,MAAMvC,eAAe,CAClD;IACEwC,GAAG,EAAE,MAAM;IACXC,GAAG,EAAEJ,QAAQ;IACbK,GAA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,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrBvD,MAAM,CAACiC,GAAG,CACRlC,QAAQ,CAACyD,KAAK,EACb,qCAAoCX,QAAQ,CAACY,KAAK,CAACC,OAAQ,EAC9D,CAAC;IAED,MAAM,IAAI5D,gBAAgB,CAAC;MACzB4D,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"}
|
|
@@ -4,6 +4,7 @@ import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, Un
|
|
|
4
4
|
import { CredentialResponse } from "./types";
|
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
|
6
6
|
import { v4 as uuidv4 } from "uuid";
|
|
7
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
|
7
8
|
export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
8
9
|
const jwk = await ctx.getPublicKey();
|
|
9
10
|
return new SignJWT(ctx).setPayload({
|
|
@@ -30,7 +31,7 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
|
30
31
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
|
31
32
|
* @returns The credential response containing the credential
|
|
32
33
|
*/
|
|
33
|
-
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
|
34
|
+
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
|
34
35
|
const {
|
|
35
36
|
credentialCryptoContext,
|
|
36
37
|
appFetch = fetch,
|
|
@@ -44,10 +45,12 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
|
44
45
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
|
45
46
|
*/
|
|
46
47
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
|
48
|
+
Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
|
47
49
|
|
|
48
50
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
|
49
51
|
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
|
50
52
|
if (!containsCredentialDefinition) {
|
|
53
|
+
Logger.log(LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
|
51
54
|
throw new ValidationFailed({
|
|
52
55
|
message: "The access token response does not contain the requested credential"
|
|
53
56
|
});
|
|
@@ -64,27 +67,34 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
|
64
67
|
proof_type: "jwt"
|
|
65
68
|
}
|
|
66
69
|
};
|
|
70
|
+
Logger.log(LogLevel.DEBUG, `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`);
|
|
67
71
|
const tokenRequestSignedDPop = await createDPopToken({
|
|
68
72
|
htm: "POST",
|
|
69
73
|
htu: credentialUrl,
|
|
70
74
|
jti: `${uuidv4()}`,
|
|
71
75
|
ath: await sha256ToBase64(accessToken.access_token)
|
|
72
76
|
}, dPopCryptoContext);
|
|
77
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
|
73
78
|
const credentialRes = await appFetch(credentialUrl, {
|
|
74
79
|
method: "POST",
|
|
75
80
|
headers: {
|
|
76
81
|
"Content-Type": "application/json",
|
|
77
82
|
DPoP: tokenRequestSignedDPop,
|
|
78
|
-
Authorization: `${accessToken.token_type} ${accessToken.access_token}
|
|
83
|
+
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
|
84
|
+
...(operationType === "reissuing" && {
|
|
85
|
+
operationType
|
|
86
|
+
})
|
|
79
87
|
},
|
|
80
88
|
body: JSON.stringify(credentialRequestFormBody)
|
|
81
89
|
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
|
82
90
|
if (!credentialRes.success) {
|
|
91
|
+
Logger.log(LogLevel.ERROR, `Credential Response validation failed: ${credentialRes.error.message}`);
|
|
83
92
|
throw new ValidationFailed({
|
|
84
93
|
message: "Credential Response validation failed",
|
|
85
94
|
reason: credentialRes.error.message
|
|
86
95
|
});
|
|
87
96
|
}
|
|
97
|
+
Logger.log(LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
|
88
98
|
return credentialRes.data;
|
|
89
99
|
};
|
|
90
100
|
|
|
@@ -95,6 +105,7 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
|
95
105
|
* @throws {IssuerResponseError} with a specific code for more context
|
|
96
106
|
*/
|
|
97
107
|
const handleObtainCredentialError = e => {
|
|
108
|
+
Logger.log(LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
|
98
109
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
|
99
110
|
throw e;
|
|
100
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","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","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","
|
|
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","signedNonceProof","c_nonce","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","res","json","safeParse","catch","handleObtainCredentialError","success","error","reason","data","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,QAAQ,SAAS;AAC5C,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAetD,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAInB,OA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