@pagopa/io-react-native-wallet 0.24.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -32
- package/lib/commonjs/client/generated/wallet-provider.js +39 -16
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/client/index.js +25 -10
- package/lib/commonjs/client/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +2 -2
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +36 -67
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -2
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +26 -17
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +8 -14
- package/lib/commonjs/credential/issuance/errors.js +52 -0
- package/lib/commonjs/credential/issuance/errors.js.map +1 -0
- package/lib/commonjs/credential/issuance/index.js +13 -2
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +1 -5
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +2 -2
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js +2 -2
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/errors.js +49 -0
- package/lib/commonjs/credential/presentation/errors.js.map +1 -0
- package/lib/commonjs/credential/presentation/index.js +5 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +8 -6
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/status/README.md +5 -2
- package/lib/commonjs/credential/status/types.js +1 -14
- package/lib/commonjs/credential/status/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/errors.js +40 -0
- package/lib/commonjs/sd-jwt/errors.js.map +1 -0
- package/lib/commonjs/sd-jwt/index.js +8 -4
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/verifier.js +5 -1
- package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
- package/lib/commonjs/trust/index.js +2 -2
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +3 -1
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +51 -0
- package/lib/commonjs/utils/error-codes.js.map +1 -0
- package/lib/commonjs/utils/errors.js +119 -463
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/misc.js +23 -55
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +2 -1
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/wallet-instance/README.md +26 -5
- package/lib/commonjs/wallet-instance/index.js +33 -7
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -2
- package/lib/commonjs/wallet-instance-attestation/issuing.js +13 -10
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +31 -11
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/client/index.js +22 -8
- package/lib/module/client/index.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +2 -2
- package/lib/module/credential/issuance/04-complete-user-authorization.js +33 -65
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +7 -4
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +29 -20
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +8 -14
- package/lib/module/credential/issuance/errors.js +44 -0
- package/lib/module/credential/issuance/errors.js.map +1 -0
- package/lib/module/credential/issuance/index.js +3 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +0 -3
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +1 -1
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +3 -3
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-send-authorization-response.js +3 -3
- package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/errors.js +42 -0
- package/lib/module/credential/presentation/errors.js.map +1 -0
- package/lib/module/credential/presentation/index.js +2 -1
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/status/02-status-attestation.js +11 -9
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/credential/status/README.md +5 -2
- package/lib/module/credential/status/types.js +0 -12
- package/lib/module/credential/status/types.js.map +1 -1
- package/lib/module/sd-jwt/errors.js +32 -0
- package/lib/module/sd-jwt/errors.js.map +1 -0
- package/lib/module/sd-jwt/index.js +5 -5
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/verifier.js +5 -1
- package/lib/module/sd-jwt/verifier.js.map +1 -1
- package/lib/module/trust/index.js +3 -3
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -1
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +43 -0
- package/lib/module/utils/error-codes.js.map +1 -0
- package/lib/module/utils/errors.js +98 -438
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/misc.js +19 -49
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +3 -2
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/wallet-instance/README.md +26 -5
- package/lib/module/wallet-instance/index.js +32 -7
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -2
- package/lib/module/wallet-instance-attestation/issuing.js +15 -12
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +138 -27
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/client/index.d.ts +7 -1
- package/lib/typescript/client/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +2 -2
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +17 -16
- 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.map +1 -1
- package/lib/typescript/credential/issuance/errors.d.ts +28 -0
- package/lib/typescript/credential/issuance/errors.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/index.d.ts +4 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +0 -8
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -0
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/index.d.ts +2 -1
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +0 -15
- package/lib/typescript/credential/status/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/errors.d.ts +20 -0
- package/lib/typescript/sd-jwt/errors.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/index.d.ts +3 -2
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +45 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +88 -225
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts +9 -24
- 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 +17 -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/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
- package/package.json +1 -1
- package/src/client/generated/wallet-provider.ts +43 -13
- package/src/client/index.ts +28 -15
- package/src/credential/issuance/03-start-user-authorization.ts +2 -2
- package/src/credential/issuance/04-complete-user-authorization.ts +57 -118
- package/src/credential/issuance/05-authorize-access.ts +7 -4
- package/src/credential/issuance/06-obtain-credential.ts +39 -39
- package/src/credential/issuance/README.md +8 -14
- package/src/credential/issuance/errors.ts +44 -0
- package/src/credential/issuance/index.ts +8 -2
- package/src/credential/issuance/types.ts +0 -8
- package/src/credential/presentation/01-start-flow.ts +1 -1
- package/src/credential/presentation/03-get-request-object.ts +3 -3
- package/src/credential/presentation/04-send-authorization-response.ts +3 -3
- package/src/credential/presentation/errors.ts +41 -0
- package/src/credential/presentation/index.ts +2 -0
- package/src/credential/status/02-status-attestation.ts +17 -25
- package/src/credential/status/README.md +5 -2
- package/src/credential/status/types.ts +0 -15
- package/src/sd-jwt/errors.ts +39 -0
- package/src/sd-jwt/index.ts +5 -8
- package/src/sd-jwt/verifier.ts +5 -5
- package/src/trust/index.ts +3 -3
- package/src/utils/decoder.ts +3 -3
- package/src/utils/error-codes.ts +50 -0
- package/src/utils/errors.ts +152 -476
- package/src/utils/misc.ts +21 -65
- package/src/utils/par.ts +3 -2
- package/src/wallet-instance/README.md +26 -5
- package/src/wallet-instance/index.ts +40 -18
- package/src/wallet-instance-attestation/README.md +8 -2
- package/src/wallet-instance-attestation/issuing.ts +28 -36
package/README.md
CHANGED
@@ -70,36 +70,6 @@ The
|
|
70
70
|
|
71
71
|
</details>
|
72
72
|
|
73
|
-
<details>
|
74
|
-
<summary>AuthorizationContext (strong authentication handling)</summary>
|
75
|
-
|
76
|
-
Whenever a strong authentication is required, the library asks the consumer application to provide a way to perform the user authentication. This is done by providing a AuthenticationContext object formed as follows:
|
77
|
-
|
78
|
-
```ts
|
79
|
-
/**
|
80
|
-
* Context for authorization during the {@link 03-start-user-authorization.ts} phase.
|
81
|
-
* It consists of a single method to identify the user which takes a URL and a redirect schema as input.
|
82
|
-
* Once the authorization is completed and the URL calls the redirect schema, the method should return the redirect URL.
|
83
|
-
*/
|
84
|
-
export interface AuthorizationContext {
|
85
|
-
authorize: (url: string, redirectSchema: string) => Promise<string>;
|
86
|
-
}
|
87
|
-
```
|
88
|
-
|
89
|
-
The authorize function is called with the URL to be opened and the schema to be used to redirect the user back to the application. The function should return a promise that resolves with the URL that the user has been redirected to.
|
90
|
-
The suggested library to manage authorizations is [io-react-native-login-utils](https://github.com/pagopa/io-react-native-login-utils), an example is shown below:
|
91
|
-
|
92
|
-
```ts
|
93
|
-
import { type AuthorizationContext } from "@pagopa/io-react-native-wallet";
|
94
|
-
import { openAuthenticationSession } from "@pagopa/io-react-native-login-utils";
|
95
|
-
|
96
|
-
const authorizationContext: AuthorizationContext = {
|
97
|
-
authorize: openAuthenticationSession,
|
98
|
-
};
|
99
|
-
```
|
100
|
-
|
101
|
-
</details>
|
102
|
-
|
103
73
|
<details>
|
104
74
|
<summary>IntegrityToken (device integrity)</summary>
|
105
75
|
|
@@ -159,7 +129,6 @@ Below there's a list of the libraries and a schema of how they interact with eac
|
|
159
129
|
|
160
130
|
- [@pagopa/io-react-native-crypto](https://github.com/pagopa/io-react-native-crypto) - Used to manage cryptographic keys and signatures
|
161
131
|
- [@pagopa/io-react-native-integrity](https://github.com/pagopa/io-react-native-integrity) - Used to manage and verify the integrity of the device
|
162
|
-
- [@pagopa/io-react-native-login-utils](https://github.com/pagopa/io-react-native-login-utils) - Used to manage strong authentication flows securely
|
163
132
|
- [@pagopa/io-react-native-secure-storage](https://github.com/pagopa/io-react-native-secure-storage) - Used to store data securely on the device
|
164
133
|
|
165
134
|
```mermaid
|
@@ -168,7 +137,6 @@ graph TD;
|
|
168
137
|
iornw[io-react-native-wallet]
|
169
138
|
iornc[io-react-native-crypto]
|
170
139
|
iorni[io-react-native-integrity]
|
171
|
-
iornlu[io-react-native-login-utils]
|
172
140
|
iornss[io-react-native-secure-storage]
|
173
141
|
iornjwt[io-react-native-jwt]
|
174
142
|
rncie[react-native-cie]
|
@@ -3,9 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.WalletAttestationView = exports.
|
6
|
+
exports.WalletInstanceData = exports.WalletAttestationView = exports.SetWalletInstanceStatusBody = exports.RevocationReason = exports.ProblemDetail = exports.NonceDetailView = exports.EndpointByMethod = exports.CreateWalletInstanceBody = exports.CreateWalletAttestationBody = exports.ApiClient = void 0;
|
7
7
|
exports.createApiClient = createApiClient;
|
8
|
-
exports.
|
8
|
+
exports.put_SetWalletInstanceStatus = exports.post_CreateWalletInstance = exports.post_CreateWalletAttestation = exports.get_GetWalletInstanceStatus = exports.get_GetNonce = void 0;
|
9
9
|
var _zod = _interopRequireDefault(require("zod"));
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
11
|
const NonceDetailView = _zod.default.object({
|
@@ -35,10 +35,18 @@ const ProblemDetail = _zod.default.object({
|
|
35
35
|
instance: _zod.default.string().optional()
|
36
36
|
});
|
37
37
|
exports.ProblemDetail = ProblemDetail;
|
38
|
-
const
|
38
|
+
const SetWalletInstanceStatusBody = _zod.default.object({
|
39
39
|
status: _zod.default.literal("REVOKED")
|
40
40
|
});
|
41
|
-
exports.
|
41
|
+
exports.SetWalletInstanceStatusBody = SetWalletInstanceStatusBody;
|
42
|
+
const RevocationReason = _zod.default.union([_zod.default.literal("CERTIFICATE_REVOKED_BY_ISSUER"), _zod.default.literal("NEW_WALLET_INSTANCE_CREATED"), _zod.default.literal("REVOKED_BY_USER")]);
|
43
|
+
exports.RevocationReason = RevocationReason;
|
44
|
+
const WalletInstanceData = _zod.default.object({
|
45
|
+
id: _zod.default.string(),
|
46
|
+
is_revoked: _zod.default.boolean(),
|
47
|
+
revocation_reason: _zod.default.union([RevocationReason, _zod.default.undefined()]).optional()
|
48
|
+
});
|
49
|
+
exports.WalletInstanceData = WalletInstanceData;
|
42
50
|
const get_GetNonce = {
|
43
51
|
method: _zod.default.literal("GET"),
|
44
52
|
path: _zod.default.literal("/nonce"),
|
@@ -55,36 +63,51 @@ const post_CreateWalletInstance = {
|
|
55
63
|
response: _zod.default.unknown()
|
56
64
|
};
|
57
65
|
exports.post_CreateWalletInstance = post_CreateWalletInstance;
|
58
|
-
const
|
59
|
-
method: _zod.default.literal("
|
60
|
-
path: _zod.default.literal("/
|
66
|
+
const get_GetWalletInstanceStatus = {
|
67
|
+
method: _zod.default.literal("GET"),
|
68
|
+
path: _zod.default.literal("/wallet-instances/{id}/status"),
|
61
69
|
parameters: _zod.default.object({
|
62
|
-
|
70
|
+
path: _zod.default.object({
|
71
|
+
id: _zod.default.string()
|
72
|
+
})
|
63
73
|
}),
|
64
|
-
response:
|
74
|
+
response: WalletInstanceData
|
65
75
|
};
|
66
|
-
exports.
|
67
|
-
const
|
76
|
+
exports.get_GetWalletInstanceStatus = get_GetWalletInstanceStatus;
|
77
|
+
const put_SetWalletInstanceStatus = {
|
68
78
|
method: _zod.default.literal("PUT"),
|
69
|
-
path: _zod.default.literal("/wallet-instances/
|
79
|
+
path: _zod.default.literal("/wallet-instances/{id}/status"),
|
70
80
|
parameters: _zod.default.object({
|
71
|
-
|
81
|
+
path: _zod.default.object({
|
82
|
+
id: _zod.default.string()
|
83
|
+
}),
|
84
|
+
body: SetWalletInstanceStatusBody
|
72
85
|
}),
|
73
86
|
response: _zod.default.unknown()
|
74
87
|
};
|
88
|
+
exports.put_SetWalletInstanceStatus = put_SetWalletInstanceStatus;
|
89
|
+
const post_CreateWalletAttestation = {
|
90
|
+
method: _zod.default.literal("POST"),
|
91
|
+
path: _zod.default.literal("/token"),
|
92
|
+
parameters: _zod.default.object({
|
93
|
+
body: CreateWalletAttestationBody
|
94
|
+
}),
|
95
|
+
response: WalletAttestationView
|
96
|
+
};
|
75
97
|
|
76
98
|
// <EndpointByMethod>
|
77
|
-
exports.
|
99
|
+
exports.post_CreateWalletAttestation = post_CreateWalletAttestation;
|
78
100
|
const EndpointByMethod = {
|
79
101
|
get: {
|
80
|
-
"/nonce": get_GetNonce
|
102
|
+
"/nonce": get_GetNonce,
|
103
|
+
"/wallet-instances/{id}/status": get_GetWalletInstanceStatus
|
81
104
|
},
|
82
105
|
post: {
|
83
106
|
"/wallet-instances": post_CreateWalletInstance,
|
84
107
|
"/token": post_CreateWalletAttestation
|
85
108
|
},
|
86
109
|
put: {
|
87
|
-
"/wallet-instances/
|
110
|
+
"/wallet-instances/{id}/status": put_SetWalletInstanceStatus
|
88
111
|
}
|
89
112
|
};
|
90
113
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_zod","_interopRequireDefault","require","obj","__esModule","default","NonceDetailView","z","object","nonce","string","exports","WalletAttestationView","wallet_attestation","CreateWalletInstanceBody","challenge","key_attestation","hardware_key_tag","CreateWalletAttestationBody","grant_type","literal","assertion","ProblemDetail","type","optional","title","status","number","detail","instance","
|
1
|
+
{"version":3,"names":["_zod","_interopRequireDefault","require","obj","__esModule","default","NonceDetailView","z","object","nonce","string","exports","WalletAttestationView","wallet_attestation","CreateWalletInstanceBody","challenge","key_attestation","hardware_key_tag","CreateWalletAttestationBody","grant_type","literal","assertion","ProblemDetail","type","optional","title","status","number","detail","instance","SetWalletInstanceStatusBody","RevocationReason","union","WalletInstanceData","id","is_revoked","boolean","revocation_reason","undefined","get_GetNonce","method","path","parameters","never","response","post_CreateWalletInstance","body","unknown","get_GetWalletInstanceStatus","put_SetWalletInstanceStatus","post_CreateWalletAttestation","EndpointByMethod","get","post","put","ApiClient","baseUrl","constructor","fetcher","setBaseUrl","arguments","length","createApiClient"],"sourceRoot":"../../../../src","sources":["client/generated/wallet-provider.ts"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGb,MAAMG,eAAe,GAAGC,YAAC,CAACC,MAAM,CAAC;EACtCC,KAAK,EAAEF,YAAC,CAACG,MAAM,CAAC;AAClB,CAAC,CAAC;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAGI,MAAMM,qBAAqB,GAAGL,YAAC,CAACC,MAAM,CAAC;EAC5CK,kBAAkB,EAAEN,YAAC,CAACG,MAAM,CAAC;AAC/B,CAAC,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGI,MAAME,wBAAwB,GAAGP,YAAC,CAACC,MAAM,CAAC;EAC/CO,SAAS,EAAER,YAAC,CAACG,MAAM,CAAC,CAAC;EACrBM,eAAe,EAAET,YAAC,CAACG,MAAM,CAAC,CAAC;EAC3BO,gBAAgB,EAAEV,YAAC,CAACG,MAAM,CAAC;AAC7B,CAAC,CAAC;AAACC,OAAA,CAAAG,wBAAA,GAAAA,wBAAA;AAGI,MAAMI,2BAA2B,GAAGX,YAAC,CAACC,MAAM,CAAC;EAClDW,UAAU,EAAEZ,YAAC,CAACa,OAAO,CAAC,6CAA6C,CAAC;EACpEC,SAAS,EAAEd,YAAC,CAACG,MAAM,CAAC;AACtB,CAAC,CAAC;AAACC,OAAA,CAAAO,2BAAA,GAAAA,2BAAA;AAGI,MAAMI,aAAa,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AA,QAAAvB,SAAA,GAAAsB,SAAA,GAAW,CAAC;EAC5D;EACA;;EAEA;EACAP,IAAIA,CACFZ,IAAU,EAE+B;IACzC,OAAO,IAAI,CAACiB,OAAO,CAAC,MAAM,EAAE,IAAI,CAACF,OAAO,GAAGf,IAAI,EAAAmB,SAAA,CAAAC,MAAA,QAAAvB,SAAA,GAAAsB,SAAA,GAAW,CAAC;EAC7D;EACA;;EAEA;EACAN,GAAGA,CACDb,IAAU,EAE+B;IACzC,OAAO,IAAI,CAACiB,OAAO,CAAC,KAAK,EAAE,IAAI,CAACF,OAAO,GAAGf,IAAI,EAAAmB,SAAA,CAAAC,MAAA,QAAAvB,SAAA,GAAAsB,SAAA,GAAW,CAAC;EAC5D;EACA;AACF;AAACjD,OAAA,CAAA4C,SAAA,GAAAA,SAAA;AAEM,SAASO,eAAeA,CAACJ,OAAgB,EAAEF,OAAgB,EAAE;EAClE,OAAO,IAAID,SAAS,CAACG,OAAO,CAAC,CAACC,UAAU,CAACH,OAAO,IAAI,EAAE,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA"}
|
@@ -3,7 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getWalletProviderClient = void 0;
|
6
|
+
exports.interpolateUrl = exports.getWalletProviderClient = void 0;
|
7
|
+
var _misc = require("../utils/misc");
|
7
8
|
var _errors = require("../utils/errors");
|
8
9
|
var _walletProvider = require("./generated/wallet-provider");
|
9
10
|
const validateResponse = async response => {
|
@@ -16,7 +17,11 @@ const validateResponse = async response => {
|
|
16
17
|
title: "Invalid response from Wallet Provider"
|
17
18
|
};
|
18
19
|
}
|
19
|
-
throw new _errors.WalletProviderResponseError(
|
20
|
+
throw new _errors.WalletProviderResponseError({
|
21
|
+
message: problemDetail.title ?? "Invalid response from Wallet Provider",
|
22
|
+
reason: problemDetail,
|
23
|
+
statusCode: response.status
|
24
|
+
});
|
20
25
|
}
|
21
26
|
return response;
|
22
27
|
};
|
@@ -25,19 +30,29 @@ const getWalletProviderClient = context => {
|
|
25
30
|
walletProviderBaseUrl,
|
26
31
|
appFetch = fetch
|
27
32
|
} = context;
|
28
|
-
return (0, _walletProvider.createApiClient)((method, url, params) => appFetch(url, {
|
33
|
+
return (0, _walletProvider.createApiClient)((method, url, params) => appFetch(interpolateUrl(url, params), {
|
29
34
|
method,
|
30
35
|
body: params ? JSON.stringify(params.body) : undefined,
|
31
36
|
headers: {
|
32
37
|
"Content-Type": "application/json"
|
33
38
|
}
|
34
|
-
}).then(validateResponse).then(
|
35
|
-
const contentType = res.headers.get("content-type");
|
36
|
-
if (contentType !== null && contentType !== void 0 && contentType.includes("application/json")) {
|
37
|
-
return res.json();
|
38
|
-
}
|
39
|
-
return res.text();
|
40
|
-
}), walletProviderBaseUrl);
|
39
|
+
}).then(validateResponse).then(_misc.parseRawHttpResponse), walletProviderBaseUrl);
|
41
40
|
};
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Function to interpolate the url when the request includes path params.
|
44
|
+
* The client generator expects the literal name of the param in the url
|
45
|
+
* and passes the actual values in a separate object.
|
46
|
+
*/
|
42
47
|
exports.getWalletProviderClient = getWalletProviderClient;
|
48
|
+
const interpolateUrl = (url, params) => {
|
49
|
+
if (!(params !== null && params !== void 0 && params.path)) return url;
|
50
|
+
for (const [key, value] of Object.entries(params.path)) {
|
51
|
+
if (typeof value === "string") {
|
52
|
+
url = url.replace(`{${key}}`, value);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return url;
|
56
|
+
};
|
57
|
+
exports.interpolateUrl = interpolateUrl;
|
43
58
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_misc","require","_errors","_walletProvider","validateResponse","response","ok","problemDetail","ProblemDetail","parse","json","title","WalletProviderResponseError","message","reason","statusCode","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","createWalletProviderApiClient","method","url","params","interpolateUrl","body","JSON","stringify","undefined","headers","then","parseRawHttpResponse","exports","path","key","value","Object","entries","replace"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAWA,MAAMG,gBAAgB,GAAG,MAAOC,QAAkB,IAAK;EACrD,IAAI,CAACA,QAAQ,CAACC,EAAE,EAAE;IAChB,IAAIC,aAA4B,GAAG,CAAC,CAAC;IACrC,IAAI;MACFA,aAAa,GAAGC,6BAAa,CAACC,KAAK,CAAC,MAAMJ,QAAQ,CAACK,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,MAAM;MACNH,aAAa,GAAG;QACdI,KAAK,EAAE;MACT,CAAC;IACH;IAEA,MAAM,IAAIC,mCAA2B,CAAC;MACpCC,OAAO,EAAEN,aAAa,CAACI,KAAK,IAAI,uCAAuC;MACvEG,MAAM,EAAEP,aAAa;MACrBQ,UAAU,EAAEV,QAAQ,CAACW;IACvB,CAAC,CAAC;EACJ;EACA,OAAOX,QAAQ;AACjB,CAAC;AAEM,MAAMY,uBAAuB,GAAIC,OAGvC,IAAK;EACJ,MAAM;IAAEC,qBAAqB;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAGH,OAAO;EAE3D,OAAO,IAAAI,+BAA6B,EAClC,CAACC,MAAM,EAAEC,GAAG,EAAEC,MAAM,KAClBL,QAAQ,CAACM,cAAc,CAACF,GAAG,EAAEC,MAAM,CAAC,EAAE;IACpCF,MAAM;IACNI,IAAI,EAAEF,MAAM,GAAGG,IAAI,CAACC,SAAS,CAACJ,MAAM,CAACE,IAAI,CAAC,GAAGG,SAAS;IACtDC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB;EACF,CAAC,CAAC,CACCC,IAAI,CAAC5B,gBAAgB,CAAC,CACtB4B,IAAI,CAAkBC,0BAAoB,CAAC,EAChDd,qBACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAe,OAAA,CAAAjB,uBAAA,GAAAA,uBAAA;AAKO,MAAMS,cAAc,GAAGA,CAACF,GAAW,EAAEC,MAA2B,KAAK;EAC1E,IAAI,EAACA,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEU,IAAI,GAAE,OAAOX,GAAG;EAE7B,KAAK,MAAM,CAACY,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACd,MAAM,CAACU,IAAI,CAAC,EAAE;IACtD,IAAI,OAAOE,KAAK,KAAK,QAAQ,EAAE;MAC7Bb,GAAG,GAAGA,GAAG,CAACgB,OAAO,CAAE,IAAGJ,GAAI,GAAE,EAAEC,KAAK,CAAC;IACtC;EACF;EACA,OAAOb,GAAG;AACZ,CAAC;AAACU,OAAA,CAAAR,cAAA,GAAAA,cAAA"}
|
@@ -48,7 +48,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
|
|
48
48
|
|
49
49
|
/**
|
50
50
|
* WARNING: This function must be called after {@link evaluateIssuerTrust} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
|
51
|
-
* Creates and sends a PAR request to the /as/par endpoint of the
|
51
|
+
* Creates and sends a PAR request to the /as/par endpoint of the authorization server.
|
52
52
|
* This starts the authentication flow to obtain an access token.
|
53
53
|
* This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
|
54
54
|
* This is an HTTP POST request containing the Wallet Instance identifier (client id), the code challenge and challenge method as specified by PKCE according to RFC 9126
|
@@ -57,7 +57,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
|
|
57
57
|
* the application session identifier on the Wallet Instance side (state),
|
58
58
|
* the method (query or form_post.jwt) by which the Authorization Server
|
59
59
|
* should transmit the Authorization Response containing the authorization code issued upon the end user's authentication (response_mode)
|
60
|
-
* to the Wallet Instance's Token Endpoint to obtain the Access Token, and the
|
60
|
+
* to the Wallet Instance's Token Endpoint to obtain the Access Token, and the redirectUri of the Wallet Instance where the Authorization Response
|
61
61
|
* should be delivered. The redirect is achived by using a custom URL scheme that the Wallet Instance is registered to handle.
|
62
62
|
* @param issuerConf The issuer configuration
|
63
63
|
* @param credentialType The type of the credential to be requested returned by {@link selectCredentialDefinition}
|
@@ -3,42 +3,32 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.parseAuthorizationResponse = exports.getRequestedCredentialToBePresented = exports.completeUserAuthorizationWithQueryMode = exports.completeUserAuthorizationWithFormPostJwtMode = exports.buildAuthorizationUrl = void 0;
|
7
7
|
var _auth = require("../../utils/auth");
|
8
8
|
var _misc = require("../../utils/misc");
|
9
9
|
var _parseUrl = _interopRequireDefault(require("parse-url"));
|
10
10
|
var _errors = require("../../utils/errors");
|
11
|
-
var _reactNative = require("react-native");
|
12
11
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
13
12
|
var _types = require("../presentation/types");
|
14
13
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
15
14
|
var _types2 = require("./types");
|
16
15
|
var _decoder = require("../../utils/decoder");
|
16
|
+
var _errors2 = require("./errors");
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
18
|
/**
|
19
19
|
* 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.
|
20
20
|
*/
|
21
21
|
|
22
22
|
/**
|
23
|
-
* WARNING: This function must be called after {@link startUserAuthorization}. The
|
24
|
-
*
|
25
|
-
* It is used to complete the user authorization by catching the redirectSchema from the authorization server which then contains the authorization response.
|
26
|
-
* This function utilizes the authorization context to open an in-app browser capable of catching the redirectSchema to perform a get request to the authorization endpoint.
|
27
|
-
* If the 302 redirect happens and the redirectSchema is caught, the function will return the authorization response after parsing it from the query string.
|
23
|
+
* WARNING: This function must be called after {@link startUserAuthorization}. The generated authUrl must be used to open a browser or webview capable of catching the redirectSchema to perform a get request to the authorization endpoint.
|
24
|
+
* Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
|
28
25
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
29
26
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
30
27
|
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
31
|
-
* @param
|
32
|
-
*
|
33
|
-
* @param idphint Unique identifier of the SPID IDP selected by the user
|
34
|
-
* @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
|
35
|
-
* @param signal An optional {@link AbortSignal} to abort the operation when using the default browser
|
36
|
-
* @throws {AuthorizationError} if an error occurs during the authorization process
|
37
|
-
* @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
|
38
|
-
* @throws {OperationAbortedError} if the caller aborts the operation via the provided signal
|
39
|
-
* @returns the authorization response which contains code, state and iss
|
28
|
+
* @param idpHint Unique identifier of the IDP selected by the user
|
29
|
+
* @returns An object containing the authorization URL
|
40
30
|
*/
|
41
|
-
const
|
31
|
+
const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idpHint) => {
|
42
32
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
43
33
|
const params = new URLSearchParams({
|
44
34
|
client_id: clientId,
|
@@ -46,49 +36,22 @@ const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId
|
|
46
36
|
idphint: idpHint
|
47
37
|
});
|
48
38
|
const authUrl = `${authzRequestEndpoint}?${params}`;
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
throw new _errors.AuthorizationError(e.message);
|
54
|
-
});
|
55
|
-
} else {
|
56
|
-
// handler for redirectUri
|
57
|
-
const urlEventListener = _reactNative.Linking.addEventListener("url", _ref => {
|
58
|
-
let {
|
59
|
-
url
|
60
|
-
} = _ref;
|
61
|
-
if (url.includes(redirectUri)) {
|
62
|
-
authRedirectUrl = url;
|
63
|
-
}
|
64
|
-
});
|
65
|
-
const operationIsAborted = signal ? (0, _misc.createAbortPromiseFromSignal)(signal) : undefined;
|
66
|
-
await _reactNative.Linking.openURL(authUrl);
|
67
|
-
|
68
|
-
/*
|
69
|
-
* Waits for 120 seconds for the identificationRedirectUrl variable to be set
|
70
|
-
* by the custom url handler. If the timeout is exceeded, throw an exception
|
71
|
-
*/
|
72
|
-
const unitAuthRedirectIsNotUndefined = (0, _misc.until)(() => authRedirectUrl !== undefined, 120);
|
39
|
+
return {
|
40
|
+
authUrl
|
41
|
+
};
|
42
|
+
};
|
73
43
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
if (winner === "OPERATION_ABORTED") {
|
84
|
-
throw new _errors.OperationAbortedError("DefaultQueryModeAuthorization");
|
85
|
-
}
|
86
|
-
if (authRedirectUrl === undefined) {
|
87
|
-
throw new _errors.AuthorizationError("Invalid authentication redirect url");
|
88
|
-
}
|
89
|
-
}
|
44
|
+
/**
|
45
|
+
* WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
|
46
|
+
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
47
|
+
* This function parses the authorization redirect URL to extract the authorization response.
|
48
|
+
* @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
|
49
|
+
* @returns the authorization response which contains code, state and iss
|
50
|
+
*/
|
51
|
+
exports.buildAuthorizationUrl = buildAuthorizationUrl;
|
52
|
+
const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
90
53
|
const query = (0, _parseUrl.default)(authRedirectUrl).query;
|
91
|
-
return
|
54
|
+
return parseAuthorizationResponse(query);
|
92
55
|
};
|
93
56
|
|
94
57
|
/**
|
@@ -113,9 +76,12 @@ const getRequestedCredentialToBePresented = async function (issuerRequestUri, cl
|
|
113
76
|
});
|
114
77
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
115
78
|
method: "GET"
|
116
|
-
}).then((0, _misc.
|
79
|
+
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.text()).then(jws => (0, _ioReactNativeJwt.decode)(jws)).then(reqObj => _types.RequestObject.safeParse(reqObj.payload));
|
117
80
|
if (!requestObject.success) {
|
118
|
-
throw new _errors.ValidationFailed(
|
81
|
+
throw new _errors.ValidationFailed({
|
82
|
+
message: "Request Object validation failed",
|
83
|
+
reason: requestObject.error.message
|
84
|
+
});
|
119
85
|
}
|
120
86
|
return requestObject.data;
|
121
87
|
};
|
@@ -202,12 +168,15 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
|
|
202
168
|
"Content-Type": "application/x-www-form-urlencoded"
|
203
169
|
},
|
204
170
|
body
|
205
|
-
}).then((0, _misc.
|
171
|
+
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(reqUri => reqUri.json());
|
206
172
|
const responseUri = _types2.ResponseUriResultShape.safeParse(resUriRes);
|
207
173
|
if (!responseUri.success) {
|
208
|
-
throw new _errors.ValidationFailed(
|
174
|
+
throw new _errors.ValidationFailed({
|
175
|
+
message: "Response Uri validation failed",
|
176
|
+
reason: responseUri.error.message
|
177
|
+
});
|
209
178
|
}
|
210
|
-
return await appFetch(responseUri.data.redirect_uri).then((0, _misc.
|
179
|
+
return await appFetch(responseUri.data.redirect_uri).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.text()).then(_decoder.getJwtFromFormPost).then(cbRes => parseAuthorizationResponse(cbRes.decodedJwt.payload));
|
211
180
|
};
|
212
181
|
|
213
182
|
/**
|
@@ -218,17 +187,17 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
|
|
218
187
|
* @returns the authorization result which contains code, state and iss
|
219
188
|
*/
|
220
189
|
exports.completeUserAuthorizationWithFormPostJwtMode = completeUserAuthorizationWithFormPostJwtMode;
|
221
|
-
const
|
190
|
+
const parseAuthorizationResponse = authRes => {
|
222
191
|
const authResParsed = _auth.AuthorizationResultShape.safeParse(authRes);
|
223
192
|
if (!authResParsed.success) {
|
224
193
|
const authErr = _auth.AuthorizationErrorShape.safeParse(authRes);
|
225
194
|
if (!authErr.success) {
|
226
|
-
throw new
|
195
|
+
throw new _errors2.AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
227
196
|
}
|
228
197
|
|
229
|
-
throw new
|
198
|
+
throw new _errors2.AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
230
199
|
}
|
231
200
|
return authResParsed.data;
|
232
201
|
};
|
233
|
-
exports.
|
202
|
+
exports.parseAuthorizationResponse = parseAuthorizationResponse;
|
234
203
|
//# sourceMappingURL=04-complete-user-authorization.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","
|
1
|
+
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_ioReactNativeJwt","_types","_reactNativeUuid","_types2","_decoder","_errors2","obj","__esModule","default","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","exports","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseUrl","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","requestObject","toString","method","then","hasStatusOrThrow","IssuerResponseError","res","text","jws","decode","reqObj","RequestObject","safeParse","payload","success","ValidationFailed","message","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","SignJWT","setProtectedHeader","alg","typ","setPayload","vp","jti","uuid","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","encodeBase64","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","ResponseUriResultShape","redirect_uri","getJwtFromFormPost","cbRes","decodedJwt","authRes","authResParsed","AuthorizationResultShape","authErr","AuthorizationErrorShape","AuthorizationError","AuthorizationIdpError","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,iBAAA,GAAAL,OAAA;AAMA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAqE,SAAAG,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAErE;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,qBAA4C,GAAG,MAAAA,CAC1DC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,KACJ;EACH,MAAMC,oBAAoB,GACxBF,UAAU,CAACG,0BAA0B,CAACC,sBAAsB;EAE9D,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC;IACjCC,SAAS,EAAER,QAAQ;IACnBS,WAAW,EAAEV,gBAAgB;IAC7BW,OAAO,EAAER;EACX,CAAC,CAAC;EAEF,MAAMS,OAAO,GAAI,GAAER,oBAAqB,IAAGG,MAAO,EAAC;EAEnD,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AI;AAC3B,CAAC;AAAC/B,OAAA,CAAAK,0BAAA,GAAAA,0BAAA"}
|
@@ -71,9 +71,12 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
|
|
71
71
|
DPoP: tokenRequestSignedDPop
|
72
72
|
},
|
73
73
|
body: authorizationRequestFormBody.toString()
|
74
|
-
}).then((0, _misc.
|
74
|
+
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
|
75
75
|
if (!tokenRes.success) {
|
76
|
-
throw new _errors.ValidationFailed(
|
76
|
+
throw new _errors.ValidationFailed({
|
77
|
+
message: "Token Response validation failed",
|
78
|
+
reason: tokenRes.error.message
|
79
|
+
});
|
77
80
|
}
|
78
81
|
return {
|
79
82
|
accessToken: tokenRes.data
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_misc","require","_dpop","_reactNativeUuid","_interopRequireDefault","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","
|
1
|
+
{"version":3,"names":["_misc","require","_dpop","_reactNativeUuid","_interopRequireDefault","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","TokenResponse","safeParse","success","ValidationFailed","message","reason","error","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAC,uBAAA,CAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAA2E,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA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EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,2BAAmB,CAAC,CAAC,CAChDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBJ,IAAI,CAAEF,IAAI,IAAKO,oBAAa,CAACC,SAAS,CAACR,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACa,OAAO,EAAE;IACrB,MAAM,IAAIC,wBAAgB,CAAC;MACzBC,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAEhB,QAAQ,CAACiB,KAAK,CAACF;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEG,WAAW,EAAElB,QAAQ,CAACmB;EAAK,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAnE,eAAA,GAAAA,eAAA"}
|
@@ -54,9 +54,11 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
54
54
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
55
55
|
|
56
56
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
57
|
-
const
|
58
|
-
if (!
|
59
|
-
throw new _errors.ValidationFailed(
|
57
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
58
|
+
if (!containsCredentialDefinition) {
|
59
|
+
throw new _errors.ValidationFailed({
|
60
|
+
message: "The access token response does not contain the requested credential"
|
61
|
+
});
|
60
62
|
}
|
61
63
|
|
62
64
|
/** The credential request body */
|
@@ -70,7 +72,7 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
70
72
|
proof_type: "jwt"
|
71
73
|
}
|
72
74
|
};
|
73
|
-
const tokenRequestSignedDPop = await
|
75
|
+
const tokenRequestSignedDPop = await (0, _dpop.createDPopToken)({
|
74
76
|
htm: "POST",
|
75
77
|
htu: credentialUrl,
|
76
78
|
jti: `${_reactNativeUuid.default.v4()}`,
|
@@ -84,9 +86,12 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
84
86
|
Authorization: `${accessToken.token_type} ${accessToken.access_token}`
|
85
87
|
},
|
86
88
|
body: JSON.stringify(credentialRequestFormBody)
|
87
|
-
}).then((0, _misc.
|
89
|
+
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(body => _types.CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
88
90
|
if (!credentialRes.success) {
|
89
|
-
throw new _errors.ValidationFailed(
|
91
|
+
throw new _errors.ValidationFailed({
|
92
|
+
message: "Credential Response validation failed",
|
93
|
+
reason: credentialRes.error.message
|
94
|
+
});
|
90
95
|
}
|
91
96
|
return credentialRes.data;
|
92
97
|
};
|
@@ -103,16 +108,20 @@ const handleObtainCredentialError = e => {
|
|
103
108
|
if (!(e instanceof _errors.UnexpectedStatusCodeError)) {
|
104
109
|
throw e;
|
105
110
|
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
throw new _errors.ResponseErrorBuilder(_errors.IssuerResponseError).handle(201, {
|
112
|
+
// Although it is technically not an error, we handle it as such to avoid
|
113
|
+
// changing the return type of `obtainCredential` and introduce a breaking change.
|
114
|
+
code: _errors.IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
115
|
+
message: "This credential cannot be issued synchronously. It will be available at a later time."
|
116
|
+
}).handle(403, {
|
117
|
+
code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
|
118
|
+
message: "Invalid status found for the given credential"
|
119
|
+
}).handle(404, {
|
120
|
+
code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
|
121
|
+
message: "Invalid status found for the given credential"
|
122
|
+
}).handle("*", {
|
123
|
+
code: _errors.IssuerResponseErrorCodes.CredentialRequestFailed,
|
124
|
+
message: "Unable to obtain the requested credential"
|
125
|
+
}).buildFrom(e);
|
117
126
|
};
|
118
127
|
//# sourceMappingURL=06-obtain-credential.js.map
|