@pagopa/io-react-native-wallet 0.15.4 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/credential/index.js +3 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +19 -4
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +5 -6
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/const.js +1 -3
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +71 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +52 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/utils/errors.js +82 -2
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/misc.js +41 -3
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +1 -1
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/module/credential/index.js +2 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +21 -6
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +6 -13
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +5 -6
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/const.js +0 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +63 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +46 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/utils/errors.js +76 -1
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/misc.js +38 -3
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +1 -1
- package/lib/module/utils/par.js.map +1 -1
- package/lib/typescript/credential/index.d.ts +2 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +3 -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 +2 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +3 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +0 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +20 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +49 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts +18 -1
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +1 -4
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/credential/index.ts +2 -1
- package/src/credential/issuance/04-complete-user-authorization.ts +36 -6
- package/src/credential/issuance/05-authorize-access.ts +7 -14
- package/src/credential/issuance/06-obtain-credential.ts +8 -8
- package/src/credential/issuance/const.ts +0 -2
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +104 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +60 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/utils/errors.ts +82 -1
- package/src/utils/misc.ts +45 -4
- package/src/utils/par.ts +2 -2
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.WalletProviderResponseError = exports.WalletInstanceRevokedError = exports.WalletInstanceNotFoundError = exports.WalletInstanceAttestationIssuingError = exports.ValidationFailed = exports.PidMetadataError = exports.PidIssuingError = exports.NoSuitableKeysFoundInEntityConfiguration = exports.IoWalletError = exports.ClaimsNotFoundInToken = exports.ClaimsNotFoundBetweenDislosures = exports.AuthorizationIdpError = exports.AuthorizationError = exports.AuthRequestDecodeError = void 0;
|
6
|
+
exports.serializeAttrs = exports.WalletProviderResponseError = exports.WalletInstanceRevokedError = exports.WalletInstanceNotFoundError = exports.WalletInstanceAttestationIssuingError = exports.ValidationFailed = exports.UnexpectedStatusCodeError = exports.StatusAttestationInvalid = exports.StatusAttestationError = exports.PidMetadataError = exports.PidIssuingError = exports.OperationAbortedError = exports.NoSuitableKeysFoundInEntityConfiguration = exports.IoWalletError = exports.ClaimsNotFoundInToken = exports.ClaimsNotFoundBetweenDislosures = exports.AuthorizationIdpError = exports.AuthorizationError = exports.AuthRequestDecodeError = void 0;
|
7
7
|
/**
|
8
8
|
* utility to format a set of attributes into an error message string
|
9
9
|
*
|
@@ -30,6 +30,7 @@ const serializeAttrs = attrs => Object.entries(attrs).map(_ref => {
|
|
30
30
|
* }
|
31
31
|
* ```
|
32
32
|
*/
|
33
|
+
exports.serializeAttrs = serializeAttrs;
|
33
34
|
class IoWalletError extends Error {
|
34
35
|
/** A unique error code for the particular error subclass. */
|
35
36
|
static get code() {
|
@@ -46,11 +47,32 @@ class IoWalletError extends Error {
|
|
46
47
|
(_Error$captureStackTr = Error.captureStackTrace) === null || _Error$captureStackTr === void 0 ? void 0 : _Error$captureStackTr.call(Error, this, this.constructor);
|
47
48
|
}
|
48
49
|
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* An error subclass thrown when a Wallet Provider http request has a status code different from the one expected.
|
53
|
+
*/
|
54
|
+
exports.IoWalletError = IoWalletError;
|
55
|
+
class UnexpectedStatusCodeError extends IoWalletError {
|
56
|
+
static get code() {
|
57
|
+
return "ERR_UNEXPECTED_STATUS_CODE";
|
58
|
+
}
|
59
|
+
code = "ERR_UNEXPECTED_STATUS_CODE";
|
60
|
+
|
61
|
+
/** HTTP status code */
|
62
|
+
|
63
|
+
constructor(message, statusCode) {
|
64
|
+
super(serializeAttrs({
|
65
|
+
message,
|
66
|
+
statusCode: statusCode.toString()
|
67
|
+
}));
|
68
|
+
this.statusCode = statusCode;
|
69
|
+
}
|
70
|
+
}
|
49
71
|
/**
|
50
72
|
* An error subclass thrown when validation fail
|
51
73
|
*
|
52
74
|
*/
|
53
|
-
exports.
|
75
|
+
exports.UnexpectedStatusCodeError = UnexpectedStatusCodeError;
|
54
76
|
class ValidationFailed extends IoWalletError {
|
55
77
|
static get code() {
|
56
78
|
return "ERR_IO_WALLET_VALIDATION_FAILED";
|
@@ -335,5 +357,63 @@ class AuthorizationIdpError extends IoWalletError {
|
|
335
357
|
this.errorDescription = errorDescription;
|
336
358
|
}
|
337
359
|
}
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Error subclass thrown when an operation has been aborted.
|
363
|
+
*/
|
338
364
|
exports.AuthorizationIdpError = AuthorizationIdpError;
|
365
|
+
class OperationAbortedError extends IoWalletError {
|
366
|
+
static get code() {
|
367
|
+
return "ERR_IO_WALLET_OPERATION_ABORTED";
|
368
|
+
}
|
369
|
+
code = "ERR_IO_WALLET_OPERATION_ABORTED";
|
370
|
+
|
371
|
+
/** The aborted operation */
|
372
|
+
|
373
|
+
constructor(operation) {
|
374
|
+
super(serializeAttrs({
|
375
|
+
operation
|
376
|
+
}));
|
377
|
+
this.operation = operation;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Error subclass thrown when the status attestation for a credential is invalid.
|
383
|
+
*/
|
384
|
+
exports.OperationAbortedError = OperationAbortedError;
|
385
|
+
class StatusAttestationInvalid extends IoWalletError {
|
386
|
+
static get code() {
|
387
|
+
return "ERR_STATUS_ATTESTATION_INVALID";
|
388
|
+
}
|
389
|
+
code = "ERR_STATUS_ATTESTATION_INVALID";
|
390
|
+
constructor(message) {
|
391
|
+
let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
|
392
|
+
super(serializeAttrs({
|
393
|
+
message,
|
394
|
+
reason
|
395
|
+
}));
|
396
|
+
this.reason = reason;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
/**
|
401
|
+
* Error subclass thrown when an error occurs while obtaining a status attestation for a credential.
|
402
|
+
*/
|
403
|
+
exports.StatusAttestationInvalid = StatusAttestationInvalid;
|
404
|
+
class StatusAttestationError extends IoWalletError {
|
405
|
+
static get code() {
|
406
|
+
return "ERR_STATUS_ATTESTATION_ERROR";
|
407
|
+
}
|
408
|
+
code = "ERR_STATUS_ATTESTATION_ERROR";
|
409
|
+
constructor(message) {
|
410
|
+
let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
|
411
|
+
super(serializeAttrs({
|
412
|
+
message,
|
413
|
+
reason
|
414
|
+
}));
|
415
|
+
this.reason = reason;
|
416
|
+
}
|
417
|
+
}
|
418
|
+
exports.StatusAttestationError = StatusAttestationError;
|
339
419
|
//# sourceMappingURL=errors.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["serializeAttrs","attrs","Object","entries","map","_ref","k","v","Array","isArray","join","_","IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","
|
1
|
+
{"version":3,"names":["serializeAttrs","attrs","Object","entries","map","_ref","k","v","Array","isArray","join","_","exports","IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","UnexpectedStatusCodeError","statusCode","toString","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError","ClaimsNotFoundBetweenDislosures","claims","c","ClaimsNotFoundInToken","NoSuitableKeysFoundInEntityConfiguration","scenario","PidMetadataError","WalletProviderResponseError","WalletInstanceRevokedError","WalletInstanceNotFoundError","AuthorizationError","AuthorizationIdpError","error","errorDescription","OperationAbortedError","operation","StatusAttestationInvalid","StatusAttestationError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GACzBC,KAAsC,IAEtCC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAClBG,GAAG,CAACC,IAAA;EAAA,IAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAAF,IAAA;EAAA,OAAK,CAACC,CAAC,EAAEE,KAAK,CAACC,OAAO,CAACF,CAAC,CAAC,GAAI,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,OAAO,8BAA8B;EACvC;EAEAA,IAAI,GAAG,8BAA8B;EAIrCC,WAAWA,CAACC,OAAe,EAAkC;IAAA,IAAhCa,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IACzD,KAAK,CAAC3B,cAAc,CAAC;MAAEiB,OAAO;MAAEa;IAAO,CAAC,CAAC,CAAC;IAC1C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;AACF;AAAClB,OAAA,CAAAuC,sBAAA,GAAAA,sBAAA"}
|
@@ -3,16 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.until = exports.hasStatus = exports.generateRandomAlphaNumericString = void 0;
|
6
|
+
exports.until = exports.isDefined = exports.hasStatus = exports.getCredentialHashWithouDiscloures = exports.generateRandomAlphaNumericString = exports.createAbortPromiseFromSignal = void 0;
|
7
7
|
var _errors = require("./errors");
|
8
|
+
var _jsSha = require("js-sha256");
|
8
9
|
/**
|
9
10
|
* Check if a response is in the expected status, other
|
10
|
-
* @param status The expected status
|
11
|
+
* @param status - The expected status
|
12
|
+
* @throws {@link UnexpectedStatusCodeError} if the status is different from the one expected
|
11
13
|
* @returns The given response object
|
12
14
|
*/
|
13
15
|
const hasStatus = status => async res => {
|
14
16
|
if (res.status !== status) {
|
15
|
-
throw new _errors.
|
17
|
+
throw new _errors.UnexpectedStatusCodeError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url} with response: ${await res.text()}`, res.status);
|
16
18
|
}
|
17
19
|
return res;
|
18
20
|
};
|
@@ -52,5 +54,41 @@ const until = (conditionFunction, timeoutSeconds) => new Promise((resolve, rejec
|
|
52
54
|
};
|
53
55
|
poll();
|
54
56
|
});
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Get the hash of a credential without discloures.
|
60
|
+
* A credential is a string like `header.body.sign~sd1~sd2....` where `~` is the separator between the credential and the discloures.
|
61
|
+
* @param credential - The credential to hash
|
62
|
+
* @returns The hash of the credential without discloures
|
63
|
+
*/
|
55
64
|
exports.until = until;
|
65
|
+
const getCredentialHashWithouDiscloures = async credential => {
|
66
|
+
const tildeIndex = credential.indexOf("~");
|
67
|
+
if (tildeIndex === -1) {
|
68
|
+
throw new _errors.IoWalletError("Invalid credential format");
|
69
|
+
}
|
70
|
+
return (0, _jsSha.sha256)(credential.slice(0, tildeIndex));
|
71
|
+
};
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Creates a promise that waits until the provided signal is aborted.
|
75
|
+
* @returns {Object} An object with `listen` and `remove` methods to handle subscribing and unsubscribing.
|
76
|
+
*/
|
77
|
+
exports.getCredentialHashWithouDiscloures = getCredentialHashWithouDiscloures;
|
78
|
+
const createAbortPromiseFromSignal = signal => {
|
79
|
+
let listener;
|
80
|
+
return {
|
81
|
+
listen: () => new Promise(resolve => {
|
82
|
+
if (signal.aborted) {
|
83
|
+
return resolve("OPERATION_ABORTED");
|
84
|
+
}
|
85
|
+
listener = () => resolve("OPERATION_ABORTED");
|
86
|
+
signal.addEventListener("abort", listener);
|
87
|
+
}),
|
88
|
+
remove: () => signal.removeEventListener("abort", listener)
|
89
|
+
};
|
90
|
+
};
|
91
|
+
exports.createAbortPromiseFromSignal = createAbortPromiseFromSignal;
|
92
|
+
const isDefined = x => Boolean(x);
|
93
|
+
exports.isDefined = isDefined;
|
56
94
|
//# sourceMappingURL=misc.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","hasStatus","status","res","
|
1
|
+
{"version":3,"names":["_errors","require","_jsSha","hasStatus","status","res","UnexpectedStatusCodeError","url","text","exports","generateRandomAlphaNumericString","size","Array","from","Math","floor","random","toString","join","until","conditionFunction","timeoutSeconds","Promise","resolve","reject","start","Date","now","poll","undefined","Error","setTimeout","getCredentialHashWithouDiscloures","credential","tildeIndex","indexOf","IoWalletError","sha256","slice","createAbortPromiseFromSignal","signal","listener","listen","aborted","addEventListener","remove","removeEventListener","isDefined","x","Boolean"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,SAAS,GACnBC,MAAc,IACf,MAAOC,GAAa,IAAwB;EAC1C,IAAIA,GAAG,CAACD,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAM,IAAIE,iCAAyB,CAChC,iCAAgCF,MAAO,SAAQC,GAAG,CAACD,MAAO,UACzDC,GAAG,CAACE,GACL,mBAAkB,MAAMF,GAAG,CAACG,IAAI,CAAC,CAAE,EAAC,EACrCH,GAAG,CAACD,MACN,CAAC;EACH;EACA,OAAOC,GAAG;AACZ,CAAC;;AAEH;AACA;AAAAI,OAAA,CAAAN,SAAA,GAAAA,SAAA;AAOA;AACA;AACA;AACA;AACA;AACO,MAAMO,gCAAgC,GAAIC,IAAY,IAC3DC,KAAK,CAACC,IAAI,CAACD,KAAK,CAACD,IAAI,CAAC,EAAE,MACtBG,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAACC,QAAQ,CAAC,EAAE,CAC5C,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAT,OAAA,CAAAC,gCAAA,GAAAA,gCAAA;AAWO,MAAMS,KAAK,GAAGA,CACnBC,iBAAgC,EAChCC,cAAuB,KAEvB,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;EACrC,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;EACxB,MAAMC,IAAI,GAAGA,CAAA,KAAM;IACjB,IAAIR,iBAAiB,CAAC,CAAC,EAAE;MACvBG,OAAO,CAAC,CAAC;IACX,CAAC,MAAM,IACLF,cAAc,KAAKQ,SAA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AAMQ,SAAS,GAAOC,CAA4B,IACvDC,OAAO,CAACD,CAAC,CAAC;AAACvC,OAAA,CAAAsC,SAAA,GAAAA,SAAA"}
|
@@ -28,7 +28,7 @@ exports.AuthorizationDetails = AuthorizationDetails;
|
|
28
28
|
const makeParRequest = _ref => {
|
29
29
|
let {
|
30
30
|
wiaCryptoContext,
|
31
|
-
appFetch
|
31
|
+
appFetch
|
32
32
|
} = _ref;
|
33
33
|
return async (clientId, codeVerifier, redirectUri, responseMode, parEndpoint, walletInstanceAttestation, authorizationDetails, assertionType) => {
|
34
34
|
const wiaPublicKey = await wiaCryptoContext.getPublicKey();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","z","_interopRequireWildcard","WalletInstanceAttestation","_misc","_pop","_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","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","z","_interopRequireWildcard","WalletInstanceAttestation","_misc","_pop","_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","uuid","v4","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","hasStatus","res","json","result","request_uri"],"sourceRoot":"../../../src","sources":["utils/par.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,CAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAD,uBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAAuC,SAAAQ,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,SAAAL,wBAAAS,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,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,G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yB,GAAG,GAAG,GAAGgB;IACtD,CAAC,CAAC,CACDwB,WAAW,CAAC,CAAC,CAAC;IAAA,CACdC,iBAAiB,CAAC,MAAM,CAAC,CACzBC,IAAI,CAAC,CAAC;;IAET;IACA,IAAIC,QAAQ,GAAG,IAAIC,eAAe,CAAC;MACjCf,aAAa,EAAE,MAAM;MACrBE,SAAS,EAAEpC,QAAQ;MACnBuC,cAAc,EAAEZ,aAAa;MAC7Ba,qBAAqB,EAAE,MAAM;MAC7BU,OAAO,EAAErB,eAAe;MACxBc,qBAAqB,EAAEpC,aAAa;MACpCqC,gBAAgB,EAAEvC,yBAAyB,GAAG,GAAG,GAAGgB;IACtD,CAAC,CAAC;IAEF,OAAO,MAAMtB,QAAQ,CAACK,WAAW,EAAE;MACjC+C,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDC,IAAI,EAAEL,QAAQ,CAACM,QAAQ,CAAC;IAC1B,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,eAAS,EAAC,GAAG,CAAC,CAAC,CACpBD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEI,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC;EACzC,CAAC;AAAA;AAACnE,OAAA,CAAAG,cAAA,GAAAA,cAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Issuance","Presentation"],"sourceRoot":"../../../src","sources":["credential/index.ts"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,YAAY;AACtC,OAAO,KAAKC,YAAY,MAAM,gBAAgB;
|
1
|
+
{"version":3,"names":["Issuance","Presentation","Status"],"sourceRoot":"../../../src","sources":["credential/index.ts"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,YAAY;AACtC,OAAO,KAAKC,YAAY,MAAM,gBAAgB;AAC9C,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,SAASF,QAAQ,EAAEC,YAAY,EAAEC,MAAM"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/auth";
|
2
|
-
import { hasStatus, until } from "../../utils/misc";
|
2
|
+
import { createAbortPromiseFromSignal, hasStatus, isDefined, until } from "../../utils/misc";
|
3
3
|
import parseUrl from "parse-url";
|
4
|
-
import { AuthorizationError, AuthorizationIdpError, ValidationFailed } from "../../utils/errors";
|
4
|
+
import { AuthorizationError, AuthorizationIdpError, OperationAbortedError, ValidationFailed } from "../../utils/errors";
|
5
5
|
import { Linking } from "react-native";
|
6
6
|
import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
7
7
|
import { RequestObject } from "../presentation/types";
|
@@ -26,11 +26,13 @@ import { getJwtFromFormPost } from "../../utils/decoder";
|
|
26
26
|
* If not specified, the default browser is used
|
27
27
|
* @param idphint Unique identifier of the SPID IDP selected by the user
|
28
28
|
* @param redirectUri The url to reach to complete the user authorization which is the custom URL scheme that the Wallet Instance is registered to handle, usually a custom URL or deeplink
|
29
|
+
* @param signal An optional {@link AbortSignal} to abort the operation when using the default browser
|
29
30
|
* @throws {AuthorizationError} if an error occurs during the authorization process
|
30
31
|
* @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
|
32
|
+
* @throws {OperationAbortedError} if the caller aborts the operation via the provided signal
|
31
33
|
* @returns the authorization response which contains code, state and iss
|
32
34
|
*/
|
33
|
-
export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext) => {
|
35
|
+
export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext, signal) => {
|
34
36
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
35
37
|
const params = new URLSearchParams({
|
36
38
|
client_id: clientId,
|
@@ -46,7 +48,7 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
|
|
46
48
|
});
|
47
49
|
} else {
|
48
50
|
// handler for redirectUri
|
49
|
-
Linking.addEventListener("url", _ref => {
|
51
|
+
const urlEventListener = Linking.addEventListener("url", _ref => {
|
50
52
|
let {
|
51
53
|
url
|
52
54
|
} = _ref;
|
@@ -54,14 +56,27 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
|
|
54
56
|
authRedirectUrl = url;
|
55
57
|
}
|
56
58
|
});
|
57
|
-
const
|
59
|
+
const operationIsAborted = signal ? createAbortPromiseFromSignal(signal) : undefined;
|
60
|
+
await Linking.openURL(authUrl);
|
58
61
|
|
59
62
|
/*
|
60
63
|
* Waits for 120 seconds for the identificationRedirectUrl variable to be set
|
61
64
|
* by the custom url handler. If the timeout is exceeded, throw an exception
|
62
65
|
*/
|
63
66
|
const unitAuthRedirectIsNotUndefined = until(() => authRedirectUrl !== undefined, 120);
|
64
|
-
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Simultaneously listen for the abort signal (when provided) and the redirect url.
|
70
|
+
* The first event that occurs will resolve the promise.
|
71
|
+
* This is useful to properly cleanup when the caller aborts this operation.
|
72
|
+
*/
|
73
|
+
const winner = await Promise.race([operationIsAborted === null || operationIsAborted === void 0 ? void 0 : operationIsAborted.listen(), unitAuthRedirectIsNotUndefined].filter(isDefined)).finally(() => {
|
74
|
+
urlEventListener.remove();
|
75
|
+
operationIsAborted === null || operationIsAborted === void 0 ? void 0 : operationIsAborted.remove();
|
76
|
+
});
|
77
|
+
if (winner === "OPERATION_ABORTED") {
|
78
|
+
throw new OperationAbortedError("DefaultQueryModeAuthorization");
|
79
|
+
}
|
65
80
|
if (authRedirectUrl === undefined) {
|
66
81
|
throw new AuthorizationError("Invalid authentication redirect url");
|
67
82
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatus","until","parseUrl","AuthorizationError","AuthorizationIdpError","ValidationFailed","Linking","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","addEventListener","_ref","url","includes","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","createAbortPromiseFromSignal","hasStatus","isDefined","until","parseUrl","AuthorizationError","AuthorizationIdpError","OperationAbortedError","ValidationFailed","Linking","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","signal","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","urlEventListener","addEventListener","_ref","url","includes","operationIsAborted","undefined","openURL","unitAuthRedirectIsNotUndefined","winner","Promise","race","listen","filter","finally","remove","query","parseAuthroizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","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,QAGnB,kBA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CAAC,CAAC,CACzBF,IAAI,CAACrD,kBAAkB,CAAC,CACxBqD,IAAI,CAAEmD,KAAK,IAAK5D,0BAA0B,CAAC4D,KAAK,CAACC,UAAU,CAAC9C,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMf,0BAA0B,GACrC8D,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAG5H,wBAAwB,CAAC2E,SAAS,CAACgD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAAC/C,OAAO,EAAE;IAC1B,MAAMgD,OAAO,GAAG9H,uBAAuB,CAAC4E,SAAS,CAACgD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAChD,OAAO,EAAE;MACpB,MAAM,IAAIvE,kBAAkB,CAACsH,aAAa,CAAC9C,KAAK,CAACnC,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIpC,qBAAqB,CAC7BsH,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import { hasStatus } from "../../utils/misc";
|
2
|
-
import { createCryptoContextFor } from "../../utils/crypto";
|
3
2
|
import { createDPopToken } from "../../utils/dpop";
|
4
3
|
import uuid from "react-native-uuid";
|
5
4
|
import { createPopToken } from "../../utils/pop";
|
6
5
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
7
|
-
import { ASSERTION_TYPE
|
6
|
+
import { ASSERTION_TYPE } from "./const";
|
8
7
|
import { TokenResponse } from "./types";
|
9
8
|
import { ValidationFailed } from "../../utils/errors";
|
10
|
-
import { generate } from "@pagopa/io-react-native-crypto";
|
11
9
|
/**
|
12
10
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
13
11
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
@@ -20,6 +18,7 @@ import { generate } from "@pagopa/io-react-native-crypto";
|
|
20
18
|
* @param codeVerifier The code verifier returned by {@link startUserAuthorization}
|
21
19
|
* @param context.walletInstanceAttestation The Wallet Instance's attestation
|
22
20
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context
|
21
|
+
* @param context.dPopCryptoContext The DPoP crypto context
|
23
22
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
24
23
|
* @throws {ValidationFailed} if an error occurs while parsing the token response
|
25
24
|
* @return The token response containing the access token along with the token request signed with DPoP which has to be used in the {@link obtainCredential} step.
|
@@ -28,24 +27,19 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
28
27
|
const {
|
29
28
|
appFetch = fetch,
|
30
29
|
walletInstanceAttestation,
|
31
|
-
wiaCryptoContext
|
30
|
+
wiaCryptoContext,
|
31
|
+
dPopCryptoContext
|
32
32
|
} = context;
|
33
33
|
const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
34
34
|
const parUrl = new URL(parEndpoint);
|
35
35
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
36
36
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
37
37
|
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
38
|
-
try {
|
39
|
-
await generate(DPOP_KET_TAG);
|
40
|
-
} catch {
|
41
|
-
console.log("DPoP key already exist");
|
42
|
-
}
|
43
|
-
const dPoPContext = createCryptoContextFor(DPOP_KET_TAG);
|
44
38
|
const tokenRequestSignedDPop = await createDPopToken({
|
45
39
|
htm: "POST",
|
46
40
|
htu: tokenUrl,
|
47
41
|
jti: `${uuid.v4()}`
|
48
|
-
},
|
42
|
+
}, dPopCryptoContext);
|
49
43
|
const signedWiaPoP = await createPopToken({
|
50
44
|
jti: `${uuid.v4()}`,
|
51
45
|
aud,
|
@@ -73,8 +67,7 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
73
67
|
throw new ValidationFailed(tokenRes.error.message);
|
74
68
|
}
|
75
69
|
return {
|
76
|
-
accessToken: tokenRes.data
|
77
|
-
dPoPContext
|
70
|
+
accessToken: tokenRes.data
|
78
71
|
};
|
79
72
|
};
|
80
73
|
//# sourceMappingURL=05-authorize-access.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatus","
|
1
|
+
{"version":3,"names":["hasStatus","createDPopToken","uuid","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","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","v4","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","message","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,SAAS,QAAkB,kBAAkB;AAGtD,SAASC,eAAe,QAAQ,kBAAkB;AAClD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAiBrD;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,IAA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QAAQ,CAACmB,QAAQ,EAAE;IACxCkB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAElB;IACR,CAAC;IACDmB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAACzD,SAAS,CAAC,GAAG,CAAC,CAAC,CACpByD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,IAAKjD,aAAa,CAACsD,SAAS,CAACL,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrB,MAAM,IAAItD,gBAAgB,CAAC4C,QAAQ,CAACW,KAAK,CAACC,OAAO,CAAC;EACpD;EAEA,OAAO;IAAEC,WAAW,EAAEb,QAAQ,CAACc;EAAK,CAAC;AACvC,CAAC"}
|
@@ -4,8 +4,6 @@ import { ValidationFailed } from "../../utils/errors";
|
|
4
4
|
import { CredentialResponse } from "./types";
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
6
6
|
import uuid from "react-native-uuid";
|
7
|
-
import { deleteKey } from "@pagopa/io-react-native-crypto";
|
8
|
-
import { DPOP_KET_TAG } from "./const";
|
9
7
|
export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
10
8
|
const jwk = await ctx.getPublicKey();
|
11
9
|
return new SignJWT(ctx).setPayload({
|
@@ -28,13 +26,15 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
28
26
|
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
|
29
27
|
* @param tokenRequestSignedDPop The DPoP signed token request returned by {@link authorizeAccess}
|
30
28
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential
|
29
|
+
* @param context.dPopCryptoContext The DPoP crypto context
|
31
30
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
32
31
|
* @returns The credential response containing the credential
|
33
32
|
*/
|
34
|
-
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition,
|
33
|
+
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
35
34
|
const {
|
36
35
|
credentialCryptoContext,
|
37
|
-
appFetch = fetch
|
36
|
+
appFetch = fetch,
|
37
|
+
dPopCryptoContext
|
38
38
|
} = context;
|
39
39
|
const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
|
40
40
|
|
@@ -67,8 +67,7 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
67
67
|
htu: credentialUrl,
|
68
68
|
jti: `${uuid.v4()}`,
|
69
69
|
ath: await sha256ToBase64(accessToken.access_token)
|
70
|
-
},
|
71
|
-
await deleteKey(DPOP_KET_TAG);
|
70
|
+
}, dPopCryptoContext);
|
72
71
|
const credentialRes = await appFetch(credentialUrl, {
|
73
72
|
method: "POST",
|
74
73
|
headers: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatus","ValidationFailed","CredentialResponse","createDPopToken","uuid","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatus","ValidationFailed","CredentialResponse","createDPopToken","uuid","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","constainsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","htm","htu","jti","v4","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","res","json","safeParse","success","error","message","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA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CACzBF,IAAI,CAAEH,IAAI,IAAK1D,kBAAkB,CAACgE,SAAS,CAACN,IAAI,CAAC,CAAC;EAErD,IAAI,CAACN,aAAa,CAACa,OAAO,EAAE;IAC1B,MAAM,IAAIlE,gBAAgB,CAACqD,aAAa,CAACc,KAAK,CAACC,OAAO,CAAC;EACzD;EAEA,OAAOf,aAAa,CAACgB,IAAI;AAC3B,CAAC"}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as z from "zod";
|
2
2
|
export const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation";
|
3
|
-
export const DPOP_KET_TAG = `dpop`;
|
4
3
|
export const SupportedCredentialFormat = z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
|
5
4
|
//# sourceMappingURL=const.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","ASSERTION_TYPE","
|
1
|
+
{"version":3,"names":["z","ASSERTION_TYPE","SupportedCredentialFormat","union","literal"],"sourceRoot":"../../../../src","sources":["credential/issuance/const.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,OAAO,MAAMC,cAAc,GACzB,oEAAoE;AAKtE,OAAO,MAAMC,yBAAyB,GAAGF,CAAC,CAACG,KAAK,CAAC,CAC/CH,CAAC,CAACI,OAAO,CAAC,WAAW,CAAC,EACtBJ,CAAC,CAACI,OAAO,CAAC,cAAc,CAAC,CAC1B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/status/01-start-flow.ts"],"mappings":""}
|