@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
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type StartFlow } from "./01-start-flow";
|
2
|
+
import { statusAttestation, type StatusAttestation } from "./02-status-attestation";
|
3
|
+
import { evaluateIssuerTrust, type EvaluateIssuerTrust } from "../issuance";
|
4
|
+
import { verifyAndParseStatusAttestation, type VerifyAndParseStatusAttestation } from "./03-verify-and-parse-status-attestation";
|
5
|
+
export { evaluateIssuerTrust, statusAttestation, verifyAndParseStatusAttestation, };
|
6
|
+
export type { StartFlow, EvaluateIssuerTrust, StatusAttestation, VerifyAndParseStatusAttestation, };
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EACL,+BAA+B,EAC/B,KAAK,+BAA+B,EACrC,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAChC,CAAC;AACF,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAChC,CAAC"}
|
@@ -0,0 +1,305 @@
|
|
1
|
+
import * as z from "zod";
|
2
|
+
/**
|
3
|
+
* Shape from parsing a status attestation response in case of 201.
|
4
|
+
*/
|
5
|
+
export declare const StatusAttestationResponse: z.ZodObject<{
|
6
|
+
status_attestation: z.ZodString;
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
8
|
+
status_attestation: string;
|
9
|
+
}, {
|
10
|
+
status_attestation: string;
|
11
|
+
}>;
|
12
|
+
/**
|
13
|
+
* Type from parsing a status attestation response in case of 201.
|
14
|
+
* Inferred from {@link StatusAttestationResponse}.
|
15
|
+
*/
|
16
|
+
export type StatusAttestationResponse = z.infer<typeof StatusAttestationResponse>;
|
17
|
+
/**
|
18
|
+
* Type for a parsed status attestation.
|
19
|
+
*/
|
20
|
+
export type ParsedStatusAttestation = z.infer<typeof ParsedStatusAttestation>;
|
21
|
+
/**
|
22
|
+
* Shape for parsing a status attestation in a JWT.
|
23
|
+
*/
|
24
|
+
export declare const ParsedStatusAttestation: z.ZodObject<{
|
25
|
+
header: z.ZodObject<{
|
26
|
+
typ: z.ZodLiteral<"status-attestation+jwt">;
|
27
|
+
alg: z.ZodString;
|
28
|
+
kid: z.ZodOptional<z.ZodString>;
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
30
|
+
alg: string;
|
31
|
+
typ: "status-attestation+jwt";
|
32
|
+
kid?: string | undefined;
|
33
|
+
}, {
|
34
|
+
alg: string;
|
35
|
+
typ: "status-attestation+jwt";
|
36
|
+
kid?: string | undefined;
|
37
|
+
}>;
|
38
|
+
payload: z.ZodObject<{
|
39
|
+
credential_hash_alg: z.ZodString;
|
40
|
+
credential_hash: z.ZodString;
|
41
|
+
cnf: z.ZodObject<{
|
42
|
+
jwk: z.ZodObject<{
|
43
|
+
alg: z.ZodOptional<z.ZodString>;
|
44
|
+
crv: z.ZodOptional<z.ZodString>;
|
45
|
+
d: z.ZodOptional<z.ZodString>;
|
46
|
+
dp: z.ZodOptional<z.ZodString>;
|
47
|
+
dq: z.ZodOptional<z.ZodString>;
|
48
|
+
e: z.ZodOptional<z.ZodString>;
|
49
|
+
ext: z.ZodOptional<z.ZodBoolean>;
|
50
|
+
k: z.ZodOptional<z.ZodString>;
|
51
|
+
key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
52
|
+
kid: z.ZodOptional<z.ZodString>;
|
53
|
+
kty: z.ZodUnion<[z.ZodLiteral<"RSA">, z.ZodLiteral<"EC">]>;
|
54
|
+
n: z.ZodOptional<z.ZodString>;
|
55
|
+
p: z.ZodOptional<z.ZodString>;
|
56
|
+
q: z.ZodOptional<z.ZodString>;
|
57
|
+
qi: z.ZodOptional<z.ZodString>;
|
58
|
+
use: z.ZodOptional<z.ZodString>;
|
59
|
+
x: z.ZodOptional<z.ZodString>;
|
60
|
+
y: z.ZodOptional<z.ZodString>;
|
61
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
62
|
+
x5t: z.ZodOptional<z.ZodString>;
|
63
|
+
"x5t#S256": z.ZodOptional<z.ZodString>;
|
64
|
+
x5u: z.ZodOptional<z.ZodString>;
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
66
|
+
kty: "RSA" | "EC";
|
67
|
+
alg?: string | undefined;
|
68
|
+
crv?: string | undefined;
|
69
|
+
d?: string | undefined;
|
70
|
+
dp?: string | undefined;
|
71
|
+
dq?: string | undefined;
|
72
|
+
e?: string | undefined;
|
73
|
+
ext?: boolean | undefined;
|
74
|
+
k?: string | undefined;
|
75
|
+
key_ops?: string[] | undefined;
|
76
|
+
kid?: string | undefined;
|
77
|
+
n?: string | undefined;
|
78
|
+
p?: string | undefined;
|
79
|
+
q?: string | undefined;
|
80
|
+
qi?: string | undefined;
|
81
|
+
use?: string | undefined;
|
82
|
+
x?: string | undefined;
|
83
|
+
y?: string | undefined;
|
84
|
+
x5c?: string[] | undefined;
|
85
|
+
x5t?: string | undefined;
|
86
|
+
"x5t#S256"?: string | undefined;
|
87
|
+
x5u?: string | undefined;
|
88
|
+
}, {
|
89
|
+
kty: "RSA" | "EC";
|
90
|
+
alg?: string | undefined;
|
91
|
+
crv?: string | undefined;
|
92
|
+
d?: string | undefined;
|
93
|
+
dp?: string | undefined;
|
94
|
+
dq?: string | undefined;
|
95
|
+
e?: string | undefined;
|
96
|
+
ext?: boolean | undefined;
|
97
|
+
k?: string | undefined;
|
98
|
+
key_ops?: string[] | undefined;
|
99
|
+
kid?: string | undefined;
|
100
|
+
n?: string | undefined;
|
101
|
+
p?: string | undefined;
|
102
|
+
q?: string | undefined;
|
103
|
+
qi?: string | undefined;
|
104
|
+
use?: string | undefined;
|
105
|
+
x?: string | undefined;
|
106
|
+
y?: string | undefined;
|
107
|
+
x5c?: string[] | undefined;
|
108
|
+
x5t?: string | undefined;
|
109
|
+
"x5t#S256"?: string | undefined;
|
110
|
+
x5u?: string | undefined;
|
111
|
+
}>;
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
113
|
+
jwk: {
|
114
|
+
kty: "RSA" | "EC";
|
115
|
+
alg?: string | undefined;
|
116
|
+
crv?: string | undefined;
|
117
|
+
d?: string | undefined;
|
118
|
+
dp?: string | undefined;
|
119
|
+
dq?: string | undefined;
|
120
|
+
e?: string | undefined;
|
121
|
+
ext?: boolean | undefined;
|
122
|
+
k?: string | undefined;
|
123
|
+
key_ops?: string[] | undefined;
|
124
|
+
kid?: string | undefined;
|
125
|
+
n?: string | undefined;
|
126
|
+
p?: string | undefined;
|
127
|
+
q?: string | undefined;
|
128
|
+
qi?: string | undefined;
|
129
|
+
use?: string | undefined;
|
130
|
+
x?: string | undefined;
|
131
|
+
y?: string | undefined;
|
132
|
+
x5c?: string[] | undefined;
|
133
|
+
x5t?: string | undefined;
|
134
|
+
"x5t#S256"?: string | undefined;
|
135
|
+
x5u?: string | undefined;
|
136
|
+
};
|
137
|
+
}, {
|
138
|
+
jwk: {
|
139
|
+
kty: "RSA" | "EC";
|
140
|
+
alg?: string | undefined;
|
141
|
+
crv?: string | undefined;
|
142
|
+
d?: string | undefined;
|
143
|
+
dp?: string | undefined;
|
144
|
+
dq?: string | undefined;
|
145
|
+
e?: string | undefined;
|
146
|
+
ext?: boolean | undefined;
|
147
|
+
k?: string | undefined;
|
148
|
+
key_ops?: string[] | undefined;
|
149
|
+
kid?: string | undefined;
|
150
|
+
n?: string | undefined;
|
151
|
+
p?: string | undefined;
|
152
|
+
q?: string | undefined;
|
153
|
+
qi?: string | undefined;
|
154
|
+
use?: string | undefined;
|
155
|
+
x?: string | undefined;
|
156
|
+
y?: string | undefined;
|
157
|
+
x5c?: string[] | undefined;
|
158
|
+
x5t?: string | undefined;
|
159
|
+
"x5t#S256"?: string | undefined;
|
160
|
+
x5u?: string | undefined;
|
161
|
+
};
|
162
|
+
}>;
|
163
|
+
exp: z.ZodNumber;
|
164
|
+
iat: z.ZodNumber;
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
166
|
+
iat: number;
|
167
|
+
exp: number;
|
168
|
+
credential_hash_alg: string;
|
169
|
+
cnf: {
|
170
|
+
jwk: {
|
171
|
+
kty: "RSA" | "EC";
|
172
|
+
alg?: string | undefined;
|
173
|
+
crv?: string | undefined;
|
174
|
+
d?: string | undefined;
|
175
|
+
dp?: string | undefined;
|
176
|
+
dq?: string | undefined;
|
177
|
+
e?: string | undefined;
|
178
|
+
ext?: boolean | undefined;
|
179
|
+
k?: string | undefined;
|
180
|
+
key_ops?: string[] | undefined;
|
181
|
+
kid?: string | undefined;
|
182
|
+
n?: string | undefined;
|
183
|
+
p?: string | undefined;
|
184
|
+
q?: string | undefined;
|
185
|
+
qi?: string | undefined;
|
186
|
+
use?: string | undefined;
|
187
|
+
x?: string | undefined;
|
188
|
+
y?: string | undefined;
|
189
|
+
x5c?: string[] | undefined;
|
190
|
+
x5t?: string | undefined;
|
191
|
+
"x5t#S256"?: string | undefined;
|
192
|
+
x5u?: string | undefined;
|
193
|
+
};
|
194
|
+
};
|
195
|
+
credential_hash: string;
|
196
|
+
}, {
|
197
|
+
iat: number;
|
198
|
+
exp: number;
|
199
|
+
credential_hash_alg: string;
|
200
|
+
cnf: {
|
201
|
+
jwk: {
|
202
|
+
kty: "RSA" | "EC";
|
203
|
+
alg?: string | undefined;
|
204
|
+
crv?: string | undefined;
|
205
|
+
d?: string | undefined;
|
206
|
+
dp?: string | undefined;
|
207
|
+
dq?: string | undefined;
|
208
|
+
e?: string | undefined;
|
209
|
+
ext?: boolean | undefined;
|
210
|
+
k?: string | undefined;
|
211
|
+
key_ops?: string[] | undefined;
|
212
|
+
kid?: string | undefined;
|
213
|
+
n?: string | undefined;
|
214
|
+
p?: string | undefined;
|
215
|
+
q?: string | undefined;
|
216
|
+
qi?: string | undefined;
|
217
|
+
use?: string | undefined;
|
218
|
+
x?: string | undefined;
|
219
|
+
y?: string | undefined;
|
220
|
+
x5c?: string[] | undefined;
|
221
|
+
x5t?: string | undefined;
|
222
|
+
"x5t#S256"?: string | undefined;
|
223
|
+
x5u?: string | undefined;
|
224
|
+
};
|
225
|
+
};
|
226
|
+
credential_hash: string;
|
227
|
+
}>;
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
229
|
+
header: {
|
230
|
+
alg: string;
|
231
|
+
typ: "status-attestation+jwt";
|
232
|
+
kid?: string | undefined;
|
233
|
+
};
|
234
|
+
payload: {
|
235
|
+
iat: number;
|
236
|
+
exp: number;
|
237
|
+
credential_hash_alg: string;
|
238
|
+
cnf: {
|
239
|
+
jwk: {
|
240
|
+
kty: "RSA" | "EC";
|
241
|
+
alg?: string | undefined;
|
242
|
+
crv?: string | undefined;
|
243
|
+
d?: string | undefined;
|
244
|
+
dp?: string | undefined;
|
245
|
+
dq?: string | undefined;
|
246
|
+
e?: string | undefined;
|
247
|
+
ext?: boolean | undefined;
|
248
|
+
k?: string | undefined;
|
249
|
+
key_ops?: string[] | undefined;
|
250
|
+
kid?: string | undefined;
|
251
|
+
n?: string | undefined;
|
252
|
+
p?: string | undefined;
|
253
|
+
q?: string | undefined;
|
254
|
+
qi?: string | undefined;
|
255
|
+
use?: string | undefined;
|
256
|
+
x?: string | undefined;
|
257
|
+
y?: string | undefined;
|
258
|
+
x5c?: string[] | undefined;
|
259
|
+
x5t?: string | undefined;
|
260
|
+
"x5t#S256"?: string | undefined;
|
261
|
+
x5u?: string | undefined;
|
262
|
+
};
|
263
|
+
};
|
264
|
+
credential_hash: string;
|
265
|
+
};
|
266
|
+
}, {
|
267
|
+
header: {
|
268
|
+
alg: string;
|
269
|
+
typ: "status-attestation+jwt";
|
270
|
+
kid?: string | undefined;
|
271
|
+
};
|
272
|
+
payload: {
|
273
|
+
iat: number;
|
274
|
+
exp: number;
|
275
|
+
credential_hash_alg: string;
|
276
|
+
cnf: {
|
277
|
+
jwk: {
|
278
|
+
kty: "RSA" | "EC";
|
279
|
+
alg?: string | undefined;
|
280
|
+
crv?: string | undefined;
|
281
|
+
d?: string | undefined;
|
282
|
+
dp?: string | undefined;
|
283
|
+
dq?: string | undefined;
|
284
|
+
e?: string | undefined;
|
285
|
+
ext?: boolean | undefined;
|
286
|
+
k?: string | undefined;
|
287
|
+
key_ops?: string[] | undefined;
|
288
|
+
kid?: string | undefined;
|
289
|
+
n?: string | undefined;
|
290
|
+
p?: string | undefined;
|
291
|
+
q?: string | undefined;
|
292
|
+
qi?: string | undefined;
|
293
|
+
use?: string | undefined;
|
294
|
+
x?: string | undefined;
|
295
|
+
y?: string | undefined;
|
296
|
+
x5c?: string[] | undefined;
|
297
|
+
x5t?: string | undefined;
|
298
|
+
"x5t#S256"?: string | undefined;
|
299
|
+
x5u?: string | undefined;
|
300
|
+
};
|
301
|
+
};
|
302
|
+
credential_hash: string;
|
303
|
+
};
|
304
|
+
}>;
|
305
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;EAEpC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,yBAAyB,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAelC,CAAC"}
|
@@ -1,3 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* utility to format a set of attributes into an error message string
|
3
|
+
*
|
4
|
+
* @example
|
5
|
+
* // returns "foo=value bar=(list, item)"
|
6
|
+
* serializeAttrs({ foo: "value", bar: ["list", "item"] })
|
7
|
+
*
|
8
|
+
* @param attrs A key value record set
|
9
|
+
* @returns a human-readable serialization of the set
|
10
|
+
*/
|
11
|
+
export declare const serializeAttrs: (attrs: Record<string, string | string>) => string;
|
1
12
|
/**
|
2
13
|
* A generic Error that all other io-wallet specific Error subclasses extend.
|
3
14
|
*
|
@@ -16,6 +27,16 @@ export declare class IoWalletError extends Error {
|
|
16
27
|
code: string;
|
17
28
|
constructor(message?: string);
|
18
29
|
}
|
30
|
+
/**
|
31
|
+
* An error subclass thrown when a Wallet Provider http request has a status code different from the one expected.
|
32
|
+
*/
|
33
|
+
export declare class UnexpectedStatusCodeError extends IoWalletError {
|
34
|
+
static get code(): "ERR_UNEXPECTED_STATUS_CODE";
|
35
|
+
code: string;
|
36
|
+
/** HTTP status code */
|
37
|
+
statusCode: number;
|
38
|
+
constructor(message: string, statusCode: number);
|
39
|
+
}
|
19
40
|
/**
|
20
41
|
* An error subclass thrown when validation fail
|
21
42
|
*
|
@@ -157,4 +178,32 @@ export declare class AuthorizationIdpError extends IoWalletError {
|
|
157
178
|
errorDescription?: string;
|
158
179
|
constructor(error: string, errorDescription?: string);
|
159
180
|
}
|
181
|
+
/**
|
182
|
+
* Error subclass thrown when an operation has been aborted.
|
183
|
+
*/
|
184
|
+
export declare class OperationAbortedError extends IoWalletError {
|
185
|
+
static get code(): "ERR_IO_WALLET_OPERATION_ABORTED";
|
186
|
+
code: string;
|
187
|
+
/** The aborted operation */
|
188
|
+
operation: string;
|
189
|
+
constructor(operation: string);
|
190
|
+
}
|
191
|
+
/**
|
192
|
+
* Error subclass thrown when the status attestation for a credential is invalid.
|
193
|
+
*/
|
194
|
+
export declare class StatusAttestationInvalid extends IoWalletError {
|
195
|
+
static get code(): "ERR_STATUS_ATTESTATION_INVALID";
|
196
|
+
code: string;
|
197
|
+
reason: string;
|
198
|
+
constructor(message: string, reason?: string);
|
199
|
+
}
|
200
|
+
/**
|
201
|
+
* Error subclass thrown when an error occurs while obtaining a status attestation for a credential.
|
202
|
+
*/
|
203
|
+
export declare class StatusAttestationError extends IoWalletError {
|
204
|
+
static get code(): "ERR_STATUS_ATTESTATION_ERROR";
|
205
|
+
code: string;
|
206
|
+
reason: string;
|
207
|
+
constructor(message: string, reason?: string);
|
208
|
+
}
|
160
209
|
//# sourceMappingURL=errors.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"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"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Check if a response is in the expected status, other
|
3
|
-
* @param status The expected status
|
3
|
+
* @param status - The expected status
|
4
|
+
* @throws {@link UnexpectedStatusCodeError} if the status is different from the one expected
|
4
5
|
* @returns The given response object
|
5
6
|
*/
|
6
7
|
export declare const hasStatus: (status: number) => (res: Response) => Promise<Response>;
|
@@ -23,4 +24,20 @@ export declare const generateRandomAlphaNumericString: (size: number) => string;
|
|
23
24
|
* @returns A promise that resolves once the conditionFunction returns true or rejects if timed out.
|
24
25
|
*/
|
25
26
|
export declare const until: (conditionFunction: () => boolean, timeoutSeconds?: number) => Promise<void>;
|
27
|
+
/**
|
28
|
+
* Get the hash of a credential without discloures.
|
29
|
+
* A credential is a string like `header.body.sign~sd1~sd2....` where `~` is the separator between the credential and the discloures.
|
30
|
+
* @param credential - The credential to hash
|
31
|
+
* @returns The hash of the credential without discloures
|
32
|
+
*/
|
33
|
+
export declare const getCredentialHashWithouDiscloures: (credential: string) => Promise<string>;
|
34
|
+
/**
|
35
|
+
* Creates a promise that waits until the provided signal is aborted.
|
36
|
+
* @returns {Object} An object with `listen` and `remove` methods to handle subscribing and unsubscribing.
|
37
|
+
*/
|
38
|
+
export declare const createAbortPromiseFromSignal: (signal: AbortSignal) => {
|
39
|
+
listen: () => Promise<"OPERATION_ABORTED">;
|
40
|
+
remove: () => void;
|
41
|
+
};
|
42
|
+
export declare const isDefined: <T>(x: "" | T | null | undefined) => x is T;
|
26
43
|
//# sourceMappingURL=misc.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/utils/misc.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/utils/misc.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,WACX,MAAM,WACH,QAAQ,KAAG,QAAQ,QAAQ,CAUtC,CAAC;AAIJ,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAC7D,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,GACvB,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAClC,UAAU,CAAC,EAAE,CAAC,GACd,KAAK,CAAC;AAEV;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,SAAU,MAAM,WAGjD,CAAC;AAEb;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,sBACG,MAAM,OAAO,mBACf,MAAM,KACtB,QAAQ,IAAI,CAiBX,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,eAChC,MAAM,KACjB,QAAQ,MAAM,CAMhB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,WAAY,WAAW;;;CAa/D,CAAC;AAEF,eAAO,MAAM,SAAS,6CACV,CAAC"}
|
@@ -33,10 +33,7 @@ export declare const AuthorizationDetails: z.ZodArray<z.ZodObject<{
|
|
33
33
|
*/
|
34
34
|
export declare const makeParRequest: ({ wiaCryptoContext, appFetch, }: {
|
35
35
|
wiaCryptoContext: CryptoContext;
|
36
|
-
appFetch
|
37
|
-
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
38
|
-
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
39
|
-
} | undefined;
|
36
|
+
appFetch: GlobalFetch["fetch"];
|
40
37
|
}) => (clientId: string, codeVerifier: string, redirectUri: string, responseMode: string, parEndpoint: string, walletInstanceAttestation: string, authorizationDetails: {
|
41
38
|
type: "openid_credential";
|
42
39
|
format: "vc+sd-jwt" | "vc+mdoc-cbor";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"par.d.ts","sourceRoot":"","sources":["../../../src/utils/par.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;WAA+B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc;sBAKL,aAAa
|
1
|
+
{"version":3,"file":"par.d.ts","sourceRoot":"","sources":["../../../src/utils/par.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;WAA+B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc;sBAKL,aAAa;cACrB,WAAW,CAAC,OAAO,CAAC;iBAGpB,MAAM,gBACF,MAAM,eACP,MAAM,gBACL,MAAM,eACP,MAAM,6BACQ,MAAM;;;;oBAElB,MAAM,KACpB,QAAQ,MAAM,CAyEhB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.16.1",
|
4
4
|
"description": "Provide data structures, helpers and API for IO Wallet",
|
5
5
|
"main": "lib/commonjs/index",
|
6
6
|
"module": "lib/module/index",
|
@@ -28,13 +28,13 @@
|
|
28
28
|
],
|
29
29
|
"scripts": {
|
30
30
|
"test": "jest",
|
31
|
-
"
|
31
|
+
"tsc": "tsc --noEmit",
|
32
32
|
"lint": "eslint \"src/**\" \"example/src/**\" \"__mocks__/**\"",
|
33
33
|
"prepack": "bob build",
|
34
34
|
"release": "release-it",
|
35
35
|
"example": "yarn --cwd example",
|
36
36
|
"bootstrap": "yarn example && yarn install",
|
37
|
-
"code-review": "yarn generate && yarn lint && yarn
|
37
|
+
"code-review": "yarn generate && yarn lint && yarn tsc && yarn test",
|
38
38
|
"generate-wallet-provider-client": "typed-openapi openapi/wallet-provider.yaml -o src/client/generated/wallet-provider.ts -r zod",
|
39
39
|
"generate": "yarn generate-wallet-provider-client"
|
40
40
|
},
|
package/src/credential/index.ts
CHANGED
@@ -4,12 +4,19 @@ import {
|
|
4
4
|
type AuthorizationContext,
|
5
5
|
type AuthorizationResult,
|
6
6
|
} from "../../utils/auth";
|
7
|
-
import {
|
7
|
+
import {
|
8
|
+
createAbortPromiseFromSignal,
|
9
|
+
hasStatus,
|
10
|
+
isDefined,
|
11
|
+
until,
|
12
|
+
type Out,
|
13
|
+
} from "../../utils/misc";
|
8
14
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
9
15
|
import parseUrl from "parse-url";
|
10
16
|
import {
|
11
17
|
AuthorizationError,
|
12
18
|
AuthorizationIdpError,
|
19
|
+
OperationAbortedError,
|
13
20
|
ValidationFailed,
|
14
21
|
} from "../../utils/errors";
|
15
22
|
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
@@ -34,7 +41,8 @@ export type CompleteUserAuthorizationWithQueryMode = (
|
|
34
41
|
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
35
42
|
idpHint: string,
|
36
43
|
redirectUri: string,
|
37
|
-
authorizationContext?: AuthorizationContext
|
44
|
+
authorizationContext?: AuthorizationContext,
|
45
|
+
signal?: AbortSignal
|
38
46
|
) => Promise<AuthorizationResult>;
|
39
47
|
|
40
48
|
export type CompleteUserAuthorizationWithFormPostJwtMode = (
|
@@ -68,8 +76,10 @@ export type GetRequestedCredentialToBePresented = (
|
|
68
76
|
* If not specified, the default browser is used
|
69
77
|
* @param idphint Unique identifier of the SPID IDP selected by the user
|
70
78
|
* @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
|
79
|
+
* @param signal An optional {@link AbortSignal} to abort the operation when using the default browser
|
71
80
|
* @throws {AuthorizationError} if an error occurs during the authorization process
|
72
81
|
* @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
|
82
|
+
* @throws {OperationAbortedError} if the caller aborts the operation via the provided signal
|
73
83
|
* @returns the authorization response which contains code, state and iss
|
74
84
|
*/
|
75
85
|
export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWithQueryMode =
|
@@ -79,7 +89,8 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
|
|
79
89
|
issuerConf,
|
80
90
|
idpHint,
|
81
91
|
redirectUri,
|
82
|
-
authorizationContext
|
92
|
+
authorizationContext,
|
93
|
+
signal
|
83
94
|
) => {
|
84
95
|
const authzRequestEndpoint =
|
85
96
|
issuerConf.oauth_authorization_server.authorization_endpoint;
|
@@ -100,13 +111,16 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
|
|
100
111
|
});
|
101
112
|
} else {
|
102
113
|
// handler for redirectUri
|
103
|
-
Linking.addEventListener("url", ({ url }) => {
|
114
|
+
const urlEventListener = Linking.addEventListener("url", ({ url }) => {
|
104
115
|
if (url.includes(redirectUri)) {
|
105
116
|
authRedirectUrl = url;
|
106
117
|
}
|
107
118
|
});
|
108
119
|
|
109
|
-
const
|
120
|
+
const operationIsAborted = signal
|
121
|
+
? createAbortPromiseFromSignal(signal)
|
122
|
+
: undefined;
|
123
|
+
await Linking.openURL(authUrl);
|
110
124
|
|
111
125
|
/*
|
112
126
|
* Waits for 120 seconds for the identificationRedirectUrl variable to be set
|
@@ -117,7 +131,23 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
|
|
117
131
|
120
|
118
132
|
);
|
119
133
|
|
120
|
-
|
134
|
+
/**
|
135
|
+
* Simultaneously listen for the abort signal (when provided) and the redirect url.
|
136
|
+
* The first event that occurs will resolve the promise.
|
137
|
+
* This is useful to properly cleanup when the caller aborts this operation.
|
138
|
+
*/
|
139
|
+
const winner = await Promise.race(
|
140
|
+
[operationIsAborted?.listen(), unitAuthRedirectIsNotUndefined].filter(
|
141
|
+
isDefined
|
142
|
+
)
|
143
|
+
).finally(() => {
|
144
|
+
urlEventListener.remove();
|
145
|
+
operationIsAborted?.remove();
|
146
|
+
});
|
147
|
+
|
148
|
+
if (winner === "OPERATION_ABORTED") {
|
149
|
+
throw new OperationAbortedError("DefaultQueryModeAuthorization");
|
150
|
+
}
|
121
151
|
|
122
152
|
if (authRedirectUrl === undefined) {
|
123
153
|
throw new AuthorizationError("Invalid authentication redirect url");
|
@@ -1,17 +1,15 @@
|
|
1
1
|
import { hasStatus, type Out } from "../../utils/misc";
|
2
2
|
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
3
3
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
4
|
-
import { createCryptoContextFor } from "../../utils/crypto";
|
5
4
|
import { createDPopToken } from "../../utils/dpop";
|
6
5
|
import uuid from "react-native-uuid";
|
7
6
|
import { createPopToken } from "../../utils/pop";
|
8
7
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
9
8
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
10
|
-
import { ASSERTION_TYPE
|
9
|
+
import { ASSERTION_TYPE } from "./const";
|
11
10
|
import { TokenResponse } from "./types";
|
12
11
|
import { ValidationFailed } from "../../utils/errors";
|
13
12
|
import type { CompleteUserAuthorizationWithQueryMode } from "./04-complete-user-authorization";
|
14
|
-
import { generate } from "@pagopa/io-react-native-crypto";
|
15
13
|
|
16
14
|
export type AuthorizeAccess = (
|
17
15
|
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
@@ -23,8 +21,9 @@ export type AuthorizeAccess = (
|
|
23
21
|
walletInstanceAttestation: string;
|
24
22
|
appFetch?: GlobalFetch["fetch"];
|
25
23
|
wiaCryptoContext: CryptoContext;
|
24
|
+
dPopCryptoContext: CryptoContext;
|
26
25
|
}
|
27
|
-
) => Promise<{ accessToken: TokenResponse
|
26
|
+
) => Promise<{ accessToken: TokenResponse }>;
|
28
27
|
|
29
28
|
/**
|
30
29
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
@@ -38,6 +37,7 @@ export type AuthorizeAccess = (
|
|
38
37
|
* @param codeVerifier The code verifier returned by {@link startUserAuthorization}
|
39
38
|
* @param context.walletInstanceAttestation The Wallet Instance's attestation
|
40
39
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context
|
40
|
+
* @param context.dPopCryptoContext The DPoP crypto context
|
41
41
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
42
42
|
* @throws {ValidationFailed} if an error occurs while parsing the token response
|
43
43
|
* @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.
|
@@ -54,6 +54,7 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
54
54
|
appFetch = fetch,
|
55
55
|
walletInstanceAttestation,
|
56
56
|
wiaCryptoContext,
|
57
|
+
dPopCryptoContext,
|
57
58
|
} = context;
|
58
59
|
|
59
60
|
const parEndpoint =
|
@@ -65,21 +66,13 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
65
66
|
|
66
67
|
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
67
68
|
|
68
|
-
try {
|
69
|
-
await generate(DPOP_KET_TAG);
|
70
|
-
} catch {
|
71
|
-
console.log("DPoP key already exist");
|
72
|
-
}
|
73
|
-
|
74
|
-
const dPoPContext = createCryptoContextFor(DPOP_KET_TAG);
|
75
|
-
|
76
69
|
const tokenRequestSignedDPop = await createDPopToken(
|
77
70
|
{
|
78
71
|
htm: "POST",
|
79
72
|
htu: tokenUrl,
|
80
73
|
jti: `${uuid.v4()}`,
|
81
74
|
},
|
82
|
-
|
75
|
+
dPopCryptoContext
|
83
76
|
);
|
84
77
|
|
85
78
|
const signedWiaPoP = await createPopToken(
|
@@ -118,5 +111,5 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
118
111
|
throw new ValidationFailed(tokenRes.error.message);
|
119
112
|
}
|
120
113
|
|
121
|
-
return { accessToken: tokenRes.data
|
114
|
+
return { accessToken: tokenRes.data };
|
122
115
|
};
|