@pagopa/io-react-native-wallet 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/client/generated/wallet-provider.js +126 -0
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -0
- package/lib/commonjs/client/index.js +41 -0
- package/lib/commonjs/client/index.js.map +1 -0
- package/lib/commonjs/index.js +10 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/errors.js +29 -1
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/integrity.js +2 -0
- package/lib/commonjs/utils/integrity.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +29 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js +48 -66
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +105 -0
- package/lib/module/client/generated/wallet-provider.js.map +1 -0
- package/lib/module/client/index.js +34 -0
- package/lib/module/client/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sd-jwt/verifier.js.map +1 -1
- package/lib/module/utils/errors.js +27 -0
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/integrity.js +2 -0
- package/lib/module/utils/integrity.js.map +1 -0
- package/lib/module/wallet-instance/index.js +23 -0
- package/lib/module/wallet-instance/index.js.map +1 -0
- package/lib/module/wallet-instance-attestation/issuing.js +48 -67
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +1 -1
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +242 -0
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -0
- package/lib/typescript/client/index.d.ts +7 -0
- package/lib/typescript/client/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +13 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/integrity.d.ts +21 -0
- package/lib/typescript/utils/integrity.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +7 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -0
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +15 -3
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +5 -5
- package/package.json +8 -5
- package/src/client/generated/wallet-provider.ts +170 -0
- package/src/client/index.ts +58 -0
- package/src/index.ts +7 -0
- package/src/sd-jwt/__test__/converters.test.js +24 -0
- package/src/sd-jwt/verifier.js +12 -0
- package/src/utils/errors.ts +28 -0
- package/src/utils/integrity.ts +23 -0
- package/src/wallet-instance/index.ts +29 -0
- package/src/wallet-instance-attestation/issuing.ts +68 -101
- package/src/wallet-instance-attestation/types.ts +1 -1
@@ -0,0 +1,105 @@
|
|
1
|
+
import z from "zod";
|
2
|
+
export const ProblemDetail = z.object({
|
3
|
+
type: z.string().optional(),
|
4
|
+
title: z.string().optional(),
|
5
|
+
status: z.number().optional(),
|
6
|
+
detail: z.string().optional(),
|
7
|
+
instance: z.string().optional()
|
8
|
+
});
|
9
|
+
export const FiscalCode = z.string();
|
10
|
+
export const Id = z.string();
|
11
|
+
export const get_GetEntityConfiguration = {
|
12
|
+
method: z.literal("GET"),
|
13
|
+
path: z.literal("/.well-known/openid-federation"),
|
14
|
+
parameters: z.never(),
|
15
|
+
response: z.unknown()
|
16
|
+
};
|
17
|
+
export const get_GetNonce = {
|
18
|
+
method: z.literal("GET"),
|
19
|
+
path: z.literal("/nonce"),
|
20
|
+
parameters: z.never(),
|
21
|
+
response: z.object({
|
22
|
+
nonce: z.string()
|
23
|
+
})
|
24
|
+
};
|
25
|
+
export const post_CreateWalletInstance = {
|
26
|
+
method: z.literal("POST"),
|
27
|
+
path: z.literal("/wallet-instances"),
|
28
|
+
parameters: z.object({
|
29
|
+
body: z.object({
|
30
|
+
challenge: z.string(),
|
31
|
+
key_attestation: z.string(),
|
32
|
+
hardware_key_tag: z.string()
|
33
|
+
})
|
34
|
+
}),
|
35
|
+
response: z.unknown()
|
36
|
+
};
|
37
|
+
export const post_CreateWalletAttestation = {
|
38
|
+
method: z.literal("POST"),
|
39
|
+
path: z.literal("/token"),
|
40
|
+
parameters: z.object({
|
41
|
+
body: z.object({
|
42
|
+
grant_type: z.literal("urn:ietf:params:oauth:grant-type:jwt-bearer"),
|
43
|
+
assertion: z.string()
|
44
|
+
})
|
45
|
+
}),
|
46
|
+
response: z.unknown()
|
47
|
+
};
|
48
|
+
|
49
|
+
// <EndpointByMethod>
|
50
|
+
export const EndpointByMethod = {
|
51
|
+
get: {
|
52
|
+
"/.well-known/openid-federation": get_GetEntityConfiguration,
|
53
|
+
"/nonce": get_GetNonce
|
54
|
+
},
|
55
|
+
post: {
|
56
|
+
"/wallet-instances": post_CreateWalletInstance,
|
57
|
+
"/token": post_CreateWalletAttestation
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
// </EndpointByMethod>
|
62
|
+
// <EndpointByMethod.Shorthands>
|
63
|
+
// </EndpointByMethod.Shorthands>
|
64
|
+
// <ApiClientTypes>
|
65
|
+
// </ApiClientTypes>
|
66
|
+
// <ApiClient>
|
67
|
+
export class ApiClient {
|
68
|
+
baseUrl = "";
|
69
|
+
constructor(fetcher) {
|
70
|
+
this.fetcher = fetcher;
|
71
|
+
}
|
72
|
+
setBaseUrl(baseUrl) {
|
73
|
+
this.baseUrl = baseUrl;
|
74
|
+
return this;
|
75
|
+
}
|
76
|
+
|
77
|
+
// <ApiClient.get>
|
78
|
+
get(path) {
|
79
|
+
return this.fetcher("get", this.baseUrl + path, arguments.length <= 1 ? undefined : arguments[1]);
|
80
|
+
}
|
81
|
+
// </ApiClient.get>
|
82
|
+
|
83
|
+
// <ApiClient.post>
|
84
|
+
post(path) {
|
85
|
+
return this.fetcher("post", this.baseUrl + path, arguments.length <= 1 ? undefined : arguments[1]);
|
86
|
+
}
|
87
|
+
// </ApiClient.post>
|
88
|
+
}
|
89
|
+
|
90
|
+
export function createApiClient(fetcher, baseUrl) {
|
91
|
+
return new ApiClient(fetcher).setBaseUrl(baseUrl ?? "");
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
Example usage:
|
96
|
+
const api = createApiClient((method, url, params) =>
|
97
|
+
fetch(url, { method, body: JSON.stringify(params) }).then((res) => res.json()),
|
98
|
+
);
|
99
|
+
api.get("/users").then((users) => console.log(users));
|
100
|
+
api.post("/users", { body: { name: "John" } }).then((user) => console.log(user));
|
101
|
+
api.put("/users/:id", { path: { id: 1 }, body: { name: "John" } }).then((user) => console.log(user));
|
102
|
+
*/
|
103
|
+
|
104
|
+
// </ApiClient
|
105
|
+
//# sourceMappingURL=wallet-provider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["z","ProblemDetail","object","type","string","optional","title","status","number","detail","instance","FiscalCode","Id","get_GetEntityConfiguration","method","literal","path","parameters","never","response","unknown","get_GetNonce","nonce","post_CreateWalletInstance","body","challenge","key_attestation","hardware_key_tag","post_CreateWalletAttestation","grant_type","assertion","EndpointByMethod","get","post","ApiClient","baseUrl","constructor","fetcher","setBaseUrl","arguments","length","undefined","createApiClient"],"sourceRoot":"../../../../src","sources":["client/generated/wallet-provider.ts"],"mappings":"AAAA,OAAOA,CAAC,MAAM,KAAK;AAGnB,OAAO,MAAMC,aAAa,GAAGD,CAAC,CAACE,MAAM,CAAC;EACpCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC3BC,KAAK,EAAEN,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC5BE,MAAM,EAAEP,CAAC,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AA,CAAAC,MAAA,QAAAC,SAAA,GAAAF,SAAA,GAAW,CAAC;EAC5D;EACA;;EAEA;EACAN,IAAIA,CACFjB,IAAU,EAE+B;IACzC,OAAO,IAAI,CAACqB,OAAO,CAAC,MAAM,EAAE,IAAI,CAACF,OAAO,GAAGnB,IAAI,EAAAuB,SAAA,CAAAC,MAAA,QAAAC,SAAA,GAAAF,SAAA,GAAW,CAAC;EAC7D;EACA;AACF;;AAEA,OAAO,SAASG,eAAeA,CAACL,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"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { WalletProviderResponseError } from "../utils/errors";
|
2
|
+
import { ProblemDetail, createApiClient as createWalletProviderApiClient } from "./generated/wallet-provider";
|
3
|
+
const validateResponse = async response => {
|
4
|
+
if (!response.ok) {
|
5
|
+
let problemDetail = {};
|
6
|
+
try {
|
7
|
+
problemDetail = ProblemDetail.parse(await response.json());
|
8
|
+
} catch {
|
9
|
+
problemDetail = {
|
10
|
+
title: "Invalid response from Wallet Provider"
|
11
|
+
};
|
12
|
+
}
|
13
|
+
let statusResponse = `Response status code: ${response.status}`;
|
14
|
+
throw new WalletProviderResponseError(problemDetail.title ? problemDetail.title : "Invalid response from Wallet Provider", problemDetail.type, problemDetail.detail ? statusResponse : `${statusResponse} with detail: ${problemDetail.detail}`);
|
15
|
+
}
|
16
|
+
return response;
|
17
|
+
};
|
18
|
+
export const getWalletProviderClient = context => {
|
19
|
+
const {
|
20
|
+
walletProviderBaseUrl,
|
21
|
+
appFetch = fetch
|
22
|
+
} = context;
|
23
|
+
return createWalletProviderApiClient((method, url, params) => appFetch(url, {
|
24
|
+
method,
|
25
|
+
body: params ? JSON.stringify(params.body) : undefined
|
26
|
+
}).then(validateResponse).then(res => {
|
27
|
+
const contentType = res.headers.get("content-type");
|
28
|
+
if (contentType === "application/json") {
|
29
|
+
return res.json();
|
30
|
+
}
|
31
|
+
return res.text();
|
32
|
+
}), walletProviderBaseUrl);
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["WalletProviderResponseError","ProblemDetail","createApiClient","createWalletProviderApiClient","validateResponse","response","ok","problemDetail","parse","json","title","statusResponse","status","type","detail","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","method","url","params","body","JSON","stringify","undefined","then","res","contentType","headers","get","text"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iBAAiB;AAC7D,SACEC,aAAa,EACbC,eAAe,IAAIC,6BAA6B,QAC3C,6BAA6B;AAKpC,MAAMC,gBAAgB,GAAG,MAAOC,QAAkB,IAAK;EACrD,IAAI,CAACA,QAAQ,CAACC,EAAE,EAAE;IAChB,IAAIC,aAA4B,GAAG,CAAC,CAAC;IACrC,IAAI;MACFA,aAAa,GAAGN,aAAa,CAACO,KAAK,CAAC,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,MAAM;MACNF,aAAa,GAAG;QACdG,KAAK,EAAE;MACT,CAAC;IACH;IAEA,IAAIC,cAAc,GAAI,yBAAwBN,QAAQ,CAACO,MAAO,EAAC;IAE/D,MAAM,IAAIZ,2BAA2B,CACnCO,aAAa,CAACG,KAAK,GACfH,aAAa,CAACG,KAAK,GACnB,uCAAuC,EAC3CH,aAAa,CAACM,IAAI,EAClBN,aAAa,CAACO,MAAM,GAChBH,cAAc,GACb,GAAEA,cAAe,iBAAgBJ,aAAa,CAACO,MAAO,EAC7D,CAAC;EACH;EACA,OAAOT,QAAQ;AACjB,CAAC;AAED,OAAO,MAAMU,uBAAuB,GAAIC,OAGvC,IAAK;EACJ,MAAM;IAAEC,qBAAqB;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAGH,OAAO;EAE3D,OAAOb,6BAA6B,CAClC,CAACiB,MAAM,EAAEC,GAAG,EAAEC,MAAM,KAClBJ,QAAQ,CAACG,GAAG,EAAE;IACZD,MAAM;IACNG,IAAI,EAAED,MAAM,GAAGE,IAAI,CAACC,SAAS,CAACH,MAAM,CAACC,IAAI,CAAC,GAAGG;EAC/C,CAAC,CAAC,CACCC,IAAI,CAACvB,gBAAgB,CAAC,CACtBuB,IAAI,CAAEC,GAAG,IAAK;IACb,MAAMC,WAAW,GAAGD,GAAG,CAACE,OAAO,CAACC,GAAG,CAAC,cAAc,CAAC;IACnD,IAAIF,WAAW,KAAK,kBAAkB,EAAE;MACtC,OAAOD,GAAG,CAACnB,IAAI,CAAC,CAAC;IACnB;IACA,OAAOmB,GAAG,CAACI,IAAI,CAAC,CAAC;EACnB,CAAC,CAAC,EACNf,qBACF,CAAC;AACH,CAAC"}
|
package/lib/module/index.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { fixBase64EncodingOnKey } from "./utils/jwk";
|
1
2
|
// polyfill due to known bugs on URL implementation for react native
|
2
3
|
// https://github.com/facebook/react-native/issues/24428
|
3
4
|
import "react-native-url-polyfill/auto";
|
@@ -7,7 +8,8 @@ import * as SdJwt from "./sd-jwt";
|
|
7
8
|
import * as Errors from "./utils/errors";
|
8
9
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
9
10
|
import * as Trust from "./trust";
|
11
|
+
import * as WalletInstance from "./wallet-instance";
|
10
12
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
11
13
|
import { createCryptoContextFor } from "./utils/crypto";
|
12
|
-
export { SdJwt, PID, Credential, WalletInstanceAttestation, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails };
|
14
|
+
export { SdJwt, PID, Credential, WalletInstanceAttestation, WalletInstance, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails, fixBase64EncodingOnKey };
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,
|
1
|
+
{"version":3,"names":["fixBase64EncodingOnKey","Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,aAAa;AACpD;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAGvD,SACEP,KAAK,EACLD,GAAG,EACHD,UAAU,EACVI,yBAAyB,EACzBE,cAAc,EACdH,MAAM,EACNE,KAAK,EACLI,sBAAsB,EACtBF,mBAAmB,EACnBC,oBAAoB,EACpBT,sBAAsB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","ValidationFailed","verifyDisclosure","_ref","claims","encoded","decoded","hash","includes"],"sourceRoot":"../../../src","sources":["sd-jwt/verifier.
|
1
|
+
{"version":3,"names":["sha256ToBase64","ValidationFailed","verifyDisclosure","_ref","claims","encoded","decoded","hash","includes"],"sourceRoot":"../../../src","sources":["sd-jwt/verifier.js"],"mappings":"AAAA,SAASA,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAAC,IAAA,EAA6BC,MAAM,KAAK;EAAA,IAAjC;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAAH,IAAA;EACzD,IAAII,IAAI,GAAG,MAAMP,cAAc,CAACK,OAAO,CAAC;EACxC,IAAI,CAACD,MAAM,CAACI,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC1B,MAAM,IAAIN,gBAAgB,CACxB,iCAAiC,EAChC,GAAEK,OAAQ,EAAC,EACZ,qCACF,CAAC;EACH;AACF,CAAC"}
|
@@ -218,4 +218,31 @@ export class PidMetadataError extends Error {
|
|
218
218
|
super(message);
|
219
219
|
}
|
220
220
|
}
|
221
|
+
|
222
|
+
/**
|
223
|
+
* An error subclass thrown when a Wallet Provider http request fail
|
224
|
+
*
|
225
|
+
*/
|
226
|
+
export class WalletProviderResponseError extends IoWalletError {
|
227
|
+
static get code() {
|
228
|
+
return "ERR_IO_WALLET_PROVIDER_RESPONSE_FAILED";
|
229
|
+
}
|
230
|
+
code = "ERR_IO_WALLET_PROVIDER_RESPONSE_FAILED";
|
231
|
+
|
232
|
+
/** The Claim for which the validation failed. */
|
233
|
+
|
234
|
+
/** Reason code for the validation failure. */
|
235
|
+
|
236
|
+
constructor(message) {
|
237
|
+
let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
|
238
|
+
let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
|
239
|
+
super(serializeAttrs({
|
240
|
+
message,
|
241
|
+
claim,
|
242
|
+
reason
|
243
|
+
}));
|
244
|
+
this.claim = claim;
|
245
|
+
this.reason = reason;
|
246
|
+
}
|
247
|
+
}
|
221
248
|
//# 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","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError","ClaimsNotFoundBetweenDislosures","claims","c","ClaimsNotFoundInToken","NoSuitableKeysFoundInEntityConfiguration","scenario","PidMetadataError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAIC,KAAsC,IAC5DC,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,IAAGA,CAAC,CAACG,IAAI,CAAC,IAAI,CAAE,GAAE,GAAGH,CAAC,CAAC;AAAA,EAAC,CAChEH,GAAG,CAAEO,CAAC,IAAKA,CAAC,CAACD,IAAI,CAAC,GAAG,CAAC,CAAC,CACvBA,IAAI,CAAC,GAAG,CAAC;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,aAAa,SAASC,KAAK,CAAC;EACvC;EACA,WAAWC,IAAIA,CAAA,EAAW;IACxB,OAAO,uBAAuB;EAChC;;EAEA;EACAA,IAAI,GAAW,uBAAuB;EAEtCC,WAAWA,CAACC,OAAgB,EAAE;IAAA,IAAAC,qBAAA;IAC5B,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,IAAI,CAACH,WAAW,CAACG,IAAI;IACjC;IACA,CAAAD,qBAAA,GAAAJ,KAAK,CAACM,iBAAiB,cAAAF,qBAAA,uBAAvBA,qBAAA,CAAAG,IAAA,CAAAP,KAAK,EAAqB,IAAI,EAAE,IA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,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF"}
|
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","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError","ClaimsNotFoundBetweenDislosures","claims","c","ClaimsNotFoundInToken","NoSuitableKeysFoundInEntityConfiguration","scenario","PidMetadataError","WalletProviderResponseError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAIC,KAAsC,IAC5DC,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,IAAGA,CAAC,CAACG,IAAI,CAAC,IAAI,CAAE,GAAE,GAAGH,CAAC,CAAC;AAAA,EAAC,CAChEH,GAAG,CAAEO,CAAC,IAAKA,CAAC,CAACD,IAAI,CAAC,GAAG,CAAC,CAAC,CACvBA,IAAI,CAAC,GAAG,CAAC;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,aAAa,SAASC,KAAK,CAAC;EACvC;EACA,WAAWC,IAAIA,CAAA,EAAW;IACxB,OAAO,uBAAuB;EAChC;;EAEA;EACAA,IAAI,GAAW,uBAAuB;EAEtCC,WAAWA,CAACC,OAAgB,EAAE;IAAA,IAAAC,qBAAA;IAC5B,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,IAAI,CAACH,WAAW,CAACG,IAAI;IACjC;IACA,CAAAD,qBAAA,G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oB,gBAAgB,SAASvB,KAAK,CAAC;EAC1C,WAAWC,IAAIA,CAAA,EAAyB;IACtC,OAAO,oBAAoB;EAC7B;EAEAC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMqB,2BAA2B,SAASzB,aAAa,CAAC;EAC7D,WAAWE,IAAIA,CAAA,EAA6C;IAC1D,OAAO,wCAAwC;EACjD;EAEAA,IAAI,GAAG,wCAAwC;;EAE/C;;EAGA;;EAGAC,WAAWA,CACTC,OAAe,EAGf;IAAA,IAFAM,KAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAAA,IAC7BG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAE9B,KAAK,CAACvB,cAAc,CAAC;MAAEgB,OAAO;MAAEM,KAAK;MAAEI;IAAO,CAAC,CAAC,CAAC;IACjD,IAAI,CAACJ,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/integrity.ts"],"mappings":""}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { getWalletProviderClient } from "../client";
|
2
|
+
export async function createWalletInstance(context) {
|
3
|
+
const {
|
4
|
+
integrityContext
|
5
|
+
} = context;
|
6
|
+
const api = getWalletProviderClient(context);
|
7
|
+
|
8
|
+
//1. Obtain nonce
|
9
|
+
const challenge = await api.get("/nonce").then(response => response.nonce);
|
10
|
+
const keyAttestation = await integrityContext.getAttestation(challenge);
|
11
|
+
const hardwareKeyTag = integrityContext.getHardwareKeyTag();
|
12
|
+
|
13
|
+
//2. Create Wallet Instance
|
14
|
+
await api.post("/wallet-instances", {
|
15
|
+
body: {
|
16
|
+
challenge,
|
17
|
+
key_attestation: keyAttestation,
|
18
|
+
hardware_key_tag: hardwareKeyTag
|
19
|
+
}
|
20
|
+
});
|
21
|
+
return hardwareKeyTag;
|
22
|
+
}
|
23
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["getWalletProviderClient","createWalletInstance","context","integrityContext","api","challenge","get","then","response","nonce","keyAttestation","getAttestation","hardwareKeyTag","getHardwareKeyTag","post","body","key_attestation","hardware_key_tag"],"sourceRoot":"../../../src","sources":["wallet-instance/index.ts"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,WAAW;AAGnD,OAAO,eAAeC,oBAAoBA,CAACC,OAI1C,EAAE;EACD,MAAM;IAAEC;EAAiB,CAAC,GAAGD,OAAO;EAEpC,MAAME,GAAG,GAAGJ,uBAAuB,CAACE,OAAO,CAAC;;EAE5C;EACA,MAAMG,SAAS,GAAG,MAAMD,GAAG,CAACE,GAAG,CAAC,QAAQ,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAKA,QAAQ,CAACC,KAAK,CAAC;EAE5E,MAAMC,cAAc,GAAG,MAAMP,gBAAgB,CAACQ,cAAc,CAACN,SAAS,CAAC;EACvE,MAAMO,cAAc,GAAGT,gBAAgB,CAACU,iBAAiB,CAAC,CAAC;;EAE3D;EACA,MAAMT,GAAG,CAACU,IAAI,CAAC,mBAAmB,EAAE;IAClCC,IAAI,EAAE;MACJV,SAAS;MACTW,eAAe,EAAEN,cAAc;MAC/BO,gBAAgB,EAAEL;IACpB;EACF,CAAC,CAAC;EAEF,OAAOA,cAAc;AACvB"}
|
@@ -1,11 +1,18 @@
|
|
1
|
-
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
2
|
-
import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
|
3
1
|
import { SignJWT, thumbprint } from "@pagopa/io-react-native-jwt";
|
4
2
|
import { JWK, fixBase64EncodingOnKey } from "../utils/jwk";
|
5
|
-
import {
|
6
|
-
import
|
7
|
-
|
8
|
-
|
3
|
+
import { getWalletProviderClient } from "../client";
|
4
|
+
import { z } from "zod";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Getter for an attestation request. The attestation request is a JWT that will be sent to the Wallet Provider to request a Wallet Instance Attestation.
|
8
|
+
*
|
9
|
+
* @param challenge - The nonce received from the Wallet Provider which is part of the signed clientData
|
10
|
+
* @param wiaCryptoContext - The key pair associated with the WIA. Will be use to prove the ownership of the attestation
|
11
|
+
* @param integrityContext - The integrity context which exposes a set of functions to interact with the device integrity service
|
12
|
+
* @param walletProviderBaseUrl - Base url for the Wallet Provider
|
13
|
+
* @returns A JWT containing the attestation request
|
14
|
+
*/
|
15
|
+
export async function getAttestationRequest(challenge, wiaCryptoContext, integrityContext, walletProviderBaseUrl) {
|
9
16
|
const jwk = await wiaCryptoContext.getPublicKey();
|
10
17
|
const parsedJwk = JWK.parse(jwk);
|
11
18
|
const keyThumbprint = await thumbprint(parsedJwk);
|
@@ -13,50 +20,31 @@ async function getAttestationRequest(wiaCryptoContext, walletProviderEntityConfi
|
|
13
20
|
...parsedJwk,
|
14
21
|
kid: keyThumbprint
|
15
22
|
};
|
23
|
+
const clientData = {
|
24
|
+
challenge,
|
25
|
+
jwk_thumbprint: keyThumbprint
|
26
|
+
};
|
27
|
+
const hardwareKeyTag = integrityContext.getHardwareKeyTag();
|
28
|
+
const {
|
29
|
+
signature,
|
30
|
+
authenticatorData
|
31
|
+
} = await integrityContext.getHardwareSignatureWithAuthData(JSON.stringify(clientData));
|
16
32
|
return new SignJWT(wiaCryptoContext).setPayload({
|
17
33
|
iss: keyThumbprint,
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
sub: walletProviderBaseUrl,
|
35
|
+
challenge,
|
36
|
+
hardware_signature: signature,
|
37
|
+
integrity_assertion: authenticatorData,
|
38
|
+
hardware_key_tag: hardwareKeyTag,
|
21
39
|
cnf: {
|
22
40
|
jwk: fixBase64EncodingOnKey(publicKey)
|
23
41
|
}
|
24
42
|
}).setProtectedHeader({
|
25
43
|
kid: publicKey.kid,
|
26
|
-
typ: "
|
44
|
+
typ: "war+jwt"
|
27
45
|
}).setIssuedAt().setExpirationTime("1h").sign();
|
28
46
|
}
|
29
47
|
|
30
|
-
/**
|
31
|
-
* Validate a Wallet Instance Attestation token.
|
32
|
-
* Either return true or throw an exception.
|
33
|
-
*
|
34
|
-
* @param wia Signed Wallet Instance Attestation token
|
35
|
-
* @param walletProviderEntityConfiguration Entity Configuration object for the issuing Wallet Provider
|
36
|
-
* @returns The token is valid
|
37
|
-
* @throws {WalletInstanceAttestationIssuingError} When the received token fails to validate. This can happen due to invalid signature, expired token or malformed JWT token.
|
38
|
-
*/
|
39
|
-
async function verifyWalletInstanceAttestation(wia, walletProviderEntityConfiguration) {
|
40
|
-
const {
|
41
|
-
payload: {
|
42
|
-
sub,
|
43
|
-
metadata: {
|
44
|
-
wallet_provider: {
|
45
|
-
jwks: {
|
46
|
-
keys
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
} = walletProviderEntityConfiguration;
|
52
|
-
return verifyJwt(wia, keys, {
|
53
|
-
issuer: sub
|
54
|
-
}).then(_ => true).catch(ex => {
|
55
|
-
const reason = ex && ex instanceof Error ? ex.message : "unknown reason";
|
56
|
-
throw new WalletInstanceAttestationIssuingError("Unable to validate received wallet instance attestation", reason);
|
57
|
-
});
|
58
|
-
}
|
59
|
-
|
60
48
|
/**
|
61
49
|
* Request a Wallet Instance Attestation (WIA) to the Wallet provider
|
62
50
|
*
|
@@ -65,38 +53,31 @@ async function verifyWalletInstanceAttestation(wia, walletProviderEntityConfigur
|
|
65
53
|
* @param walletProviderBaseUrl Base url for the Wallet Provider
|
66
54
|
* @returns The retrieved Wallet Instance Attestation token
|
67
55
|
*/
|
68
|
-
export const getAttestation = _ref => {
|
56
|
+
export const getAttestation = async _ref => {
|
69
57
|
let {
|
70
58
|
wiaCryptoContext,
|
59
|
+
integrityContext,
|
60
|
+
walletProviderBaseUrl,
|
71
61
|
appFetch = fetch
|
72
62
|
} = _ref;
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
63
|
+
const api = getWalletProviderClient({
|
64
|
+
walletProviderBaseUrl,
|
65
|
+
appFetch
|
66
|
+
});
|
67
|
+
|
68
|
+
// 1. Get nonce from backend
|
69
|
+
const challenge = await api.get("/nonce").then(response => response.nonce);
|
70
|
+
|
71
|
+
// 2. Get a signed attestation request
|
72
|
+
const signedAttestationRequest = await getAttestationRequest(challenge, wiaCryptoContext, integrityContext, walletProviderBaseUrl);
|
73
|
+
|
74
|
+
// 3. Request WIA
|
75
|
+
const wia = await api.post("/token", {
|
76
|
+
body: {
|
77
|
+
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
85
78
|
assertion: signedAttestationRequest
|
86
|
-
};
|
87
|
-
const response = await appFetch(tokenUrl, {
|
88
|
-
method: "POST",
|
89
|
-
headers: {
|
90
|
-
"Content-Type": "application/json"
|
91
|
-
},
|
92
|
-
body: JSON.stringify(requestBody)
|
93
|
-
});
|
94
|
-
if (response.status !== 201) {
|
95
|
-
throw new WalletInstanceAttestationIssuingError("Unable to obtain wallet instance attestation from wallet provider", `Response code: ${response.status}`);
|
96
79
|
}
|
97
|
-
|
98
|
-
|
99
|
-
return wia;
|
100
|
-
};
|
80
|
+
}).then(result => z.string().parse(result));
|
81
|
+
return wia;
|
101
82
|
};
|
102
83
|
//# sourceMappingURL=issuing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["SignJWT","thumbprint","JWK","fixBase64EncodingOnKey","getWalletProviderClient","z","getAttestationRequest","challenge","wiaCryptoContext","integrityContext","walletProviderBaseUrl","jwk","getPublicKey","parsedJwk","parse","keyThumbprint","publicKey","kid","clientData","jwk_thumbprint","hardwareKeyTag","getHardwareKeyTag","signature","authenticatorData","getHardwareSignatureWithAuthData","JSON","stringify","setPayload","iss","sub","hardware_signature","integrity_assertion","hardware_key_tag","cnf","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","api","get","then","response","nonce","signedAttestationRequest","wia","post","body","grant_type","assertion","result","string"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":"AACA,SAASA,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,EAAEC,sBAAsB,QAAQ,cAAc;AAC1D,SAASC,uBAAuB,QAAQ,WAAW;AAEnD,SAASC,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,qBAAqBA,CACzCC,SAAiB,EACjBC,gBAA+B,EAC/BC,gBAAkC,EAClCC,qBAA6B,EACZ;EACjB,MAAMC,GAAG,GAAG,MAAMH,gBAAgB,CAACI,YAAY,CAAC,CAAC;EACjD,MAAMC,SAAS,GAAGX,GAAG,CAACY,KAAK,CAACH,GAAG,CAAC;EAChC,MAAMI,aAAa,GAAG,MAAMd,UAAU,CAACY,SAAS,CAAC;EACjD,MAAMG,SAAS,GAAG;IAAE,GAAGH,SAAS;IAAEI,GAAG,EAAEF;EAAc,CAAC;EAEtD,MAAMG,UAAU,GAAG;IACjBX,SAAS;IACTY,cAAc,EAAEJ;EAClB,CAAC;EAED,MAAMK,cAAc,GAAGX,gBAAgB,CAACY,iBAAiB,CAAC,CAAC;EAC3D,MAAM;IAAEC,SAAS;IAAEC;EAAkB,CAAC,GACpC,MAAMd,gBAAgB,CAACe,gCAAgC,CACrDC,IAAI,CAACC,SAAS,CAACR,UAAU,CAC3B,CAAC;EAEH,OAAO,IAAIlB,OAAO,CAACQ,gBAAgB,CAAC,CACjCmB,UAAU,CAAC;IACVC,GAAG,EAAEb,aAAa;IAClBc,GAAG,EAAEnB,qBAAqB;IA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({
|
|
24
24
|
});
|
25
25
|
export const WalletInstanceAttestationRequestJwt = z.object({
|
26
26
|
header: z.intersection(Jwt.shape.header, z.object({
|
27
|
-
typ: z.literal("
|
27
|
+
typ: z.literal("war+jwt")
|
28
28
|
})),
|
29
29
|
payload: z.intersection(Jwt.shape.payload, z.object({
|
30
30
|
aud: z.string(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JWK","z","UnixTime","number","min","max","Jwt","object","header","alg","string","kid","typ","x5c","array","optional","trust_chain","payload","iss","iat","exp","cnf","jwk","intersection","WalletInstanceAttestationRequestJwt","shape","literal","aud","jti","nonce","WalletInstanceAttestationJwt","sub","attested_security_context","authorization_endpoint","response_types_supported","vp_formats_supported","jwt_vp_json","alg_values_supported","jwt_vc_json","request_object_signing_alg_values_supported","presentation_definition_uri_supported","boolean"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/types.ts"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAc;AAClC,OAAO,KAAKC,CAAC,MAAM,KAAK;AAExB,MAAMC,QAAQ,GAAGD,CAAC,CAACE,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAGrD,MAAMC,GAAG,GAAGL,CAAC,CAACM,MAAM,CAAC;EACnBC,MAAM,EAAEP,CAAC,CAACM,MAAM,CAAC;IACfE,GAAG,EAAER,CAAC,CAACS,MAAM,CAAC,CAAC;IACfC,GAAG,EAAEV,CAAC,CAACS,MAAM,CAAC,CAAC;IACfE,GAAG,EAAEX,CAAC,CAACS,MAAM,CAAC,CAAC;IACfG,GAAG,EAAEZ,CAAC,CAACa,KAAK,CAACb,CAAC,CAACS,MAAM,CAAC,CAAC,CAAC,CAACK,QAAQ,CAAC,CAAC;IACnCC,WAAW,EAAEf,CAAC,CAACa,KAAK,CAACb,CAAC,CAACS,MAAM,CAAC,CAAC,CAAC,CAACK,QAAQ,CAAC;EAC5C,CAAC,CAAC;EACFE,OAAO,EAAEhB,CAAC,CAACM,MAAM,CAAC;IAChBW,GAAG,EAAEjB,CAAC,CAACS,MAAM,CAAC,CAAC;IACfS,GAAG,EAAEjB,QAAQ;IACbkB,GAAG,EAAElB,QAAQ;IACbmB,GAAG,EAAEpB,CAAC,CAACM,MAAM,CAAC;MACZe,GAAG,EAAErB,CAAC,CAACsB,YAAY,CACjBvB,GAAG;MACH;MACAC,CAAC,CAACM,MAAM,CAAC;QAAEI,GAAG,EAAEV,CAAC,CAACS,MAAM,CAAC;MAAE,CAAC,CAC9B;IACF,CAAC;EACH,CAAC;AACH,CAAC,CAAC;AAKF,OAAO,MAAMc,mCAAmC,GAAGvB,CAAC,CAACM,MAAM,CAAC;EAC1DC,MAAM,EAAEP,CAAC,CAACsB,YAAY,CACpBjB,GAAG,CAACmB,KAAK,CAACjB,MAAM,EAChBP,CAAC,CAACM,MAAM,CAAC;IACPK,GAAG,EAAEX,CAAC,CAACyB,OAAO,CAAC,
|
1
|
+
{"version":3,"names":["JWK","z","UnixTime","number","min","max","Jwt","object","header","alg","string","kid","typ","x5c","array","optional","trust_chain","payload","iss","iat","exp","cnf","jwk","intersection","WalletInstanceAttestationRequestJwt","shape","literal","aud","jti","nonce","WalletInstanceAttestationJwt","sub","attested_security_context","authorization_endpoint","response_types_supported","vp_formats_supported","jwt_vp_json","alg_values_supported","jwt_vc_json","request_object_signing_alg_values_supported","presentation_definition_uri_supported","boolean"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/types.ts"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAc;AAClC,OAAO,KAAKC,CAAC,MAAM,KAAK;AAExB,MAAMC,QAAQ,GAAGD,CAAC,CAACE,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAGrD,MAAMC,GAAG,GAAGL,CAAC,CAACM,MAAM,CAAC;EACnBC,MAAM,EAAEP,CAAC,CAACM,MAAM,CAAC;IACfE,GAAG,EA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