@pagopa/io-react-native-wallet 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/README.md +52 -19
  2. package/lib/commonjs/index.js +13 -24
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/pid/issuing.js +22 -28
  5. package/lib/commonjs/pid/issuing.js.map +1 -1
  6. package/lib/commonjs/rp/__test__/index.test.js +2 -2
  7. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  8. package/lib/commonjs/rp/index.js +5 -19
  9. package/lib/commonjs/rp/index.js.map +1 -1
  10. package/lib/commonjs/rp/types.js +1 -21
  11. package/lib/commonjs/rp/types.js.map +1 -1
  12. package/lib/commonjs/trust/index.js +24 -5
  13. package/lib/commonjs/trust/index.js.map +1 -1
  14. package/lib/commonjs/trust/types.js +95 -4
  15. package/lib/commonjs/trust/types.js.map +1 -1
  16. package/lib/commonjs/wallet-instance-attestation/issuing.js +5 -13
  17. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  18. package/lib/module/index.js +2 -5
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/pid/issuing.js +16 -23
  21. package/lib/module/pid/issuing.js.map +1 -1
  22. package/lib/module/rp/__test__/index.test.js +2 -2
  23. package/lib/module/rp/__test__/index.test.js.map +1 -1
  24. package/lib/module/rp/index.js +2 -17
  25. package/lib/module/rp/index.js.map +1 -1
  26. package/lib/module/rp/types.js +0 -20
  27. package/lib/module/rp/types.js.map +1 -1
  28. package/lib/module/trust/index.js +19 -5
  29. package/lib/module/trust/index.js.map +1 -1
  30. package/lib/module/trust/types.js +94 -2
  31. package/lib/module/trust/types.js.map +1 -1
  32. package/lib/module/wallet-instance-attestation/issuing.js +5 -13
  33. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  34. package/lib/typescript/index.d.ts +2 -5
  35. package/lib/typescript/index.d.ts.map +1 -1
  36. package/lib/typescript/pid/issuing.d.ts +3 -12
  37. package/lib/typescript/pid/issuing.d.ts.map +1 -1
  38. package/lib/typescript/rp/index.d.ts +4 -12
  39. package/lib/typescript/rp/index.d.ts.map +1 -1
  40. package/lib/typescript/rp/types.d.ts +4 -1256
  41. package/lib/typescript/rp/types.d.ts.map +1 -1
  42. package/lib/typescript/trust/index.d.ts +806 -3
  43. package/lib/typescript/trust/index.d.ts.map +1 -1
  44. package/lib/typescript/trust/types.d.ts +8637 -5
  45. package/lib/typescript/trust/types.d.ts.map +1 -1
  46. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +2 -1
  47. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  48. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  49. package/package.json +1 -1
  50. package/src/index.ts +11 -12
  51. package/src/pid/issuing.ts +24 -30
  52. package/src/rp/__test__/index.test.ts +2 -2
  53. package/src/rp/index.ts +8 -22
  54. package/src/rp/types.ts +0 -24
  55. package/src/trust/index.ts +106 -5
  56. package/src/trust/types.ts +114 -3
  57. package/src/wallet-instance-attestation/issuing.ts +10 -15
  58. package/lib/commonjs/pid/metadata.js +0 -52
  59. package/lib/commonjs/pid/metadata.js.map +0 -1
  60. package/lib/module/pid/metadata.js +0 -44
  61. package/lib/module/pid/metadata.js.map +0 -1
  62. package/lib/typescript/pid/metadata.d.ts +0 -1412
  63. package/lib/typescript/pid/metadata.d.ts.map +0 -1
  64. package/src/pid/metadata.ts +0 -51
@@ -8,10 +8,11 @@ import { JWK, fixBase64EncodingOnKey } from "../utils/jwk";
8
8
  import { WalletInstanceAttestationRequestJwt } from "./types";
9
9
  import uuid from "react-native-uuid";
10
10
  import { WalletInstanceAttestationIssuingError } from "../utils/errors";
11
+ import type { WalletProviderEntityConfiguration } from "../trust/types";
11
12
 
12
13
  async function getAttestationRequest(
13
14
  wiaCryptoContext: CryptoContext,
14
- walletProviderBaseUrl: string
15
+ walletProviderEntityConfiguration: WalletProviderEntityConfiguration
15
16
  ): Promise<string> {
16
17
  const jwk = await wiaCryptoContext.getPublicKey();
17
18
  const parsedJwk = JWK.parse(jwk);
@@ -21,7 +22,7 @@ async function getAttestationRequest(
21
22
  return new SignJWT(wiaCryptoContext)
22
23
  .setPayload({
23
24
  iss: keyThumbprint,
24
- aud: walletProviderBaseUrl,
25
+ aud: walletProviderEntityConfiguration.payload.iss,
25
26
  jti: `${uuid.v4()}`,
26
27
  nonce: `${uuid.v4()}`,
27
28
  cnf: {
@@ -32,16 +33,6 @@ async function getAttestationRequest(
32
33
  kid: publicKey.kid,
33
34
  typ: "wiar+jwt",
34
35
  })
35
- .setPayload({
36
- iss: keyThumbprint,
37
- sub: walletProviderBaseUrl,
38
- jti: `${uuid.v4()}`,
39
- type: "WalletInstanceAttestationRequest",
40
- cnf: {
41
- jwk: fixBase64EncodingOnKey(publicKey),
42
- },
43
- })
44
-
45
36
  .setIssuedAt()
46
37
  .setExpirationTime("1h")
47
38
  .sign();
@@ -63,10 +54,12 @@ export const getAttestation =
63
54
  wiaCryptoContext: CryptoContext;
64
55
  appFetch?: GlobalFetch["fetch"];
65
56
  }) =>
66
- async (walletProviderBaseUrl: string): Promise<string> => {
57
+ async (
58
+ walletProviderEntityConfiguration: WalletProviderEntityConfiguration
59
+ ): Promise<string> => {
67
60
  const signedAttestationRequest = await getAttestationRequest(
68
61
  wiaCryptoContext,
69
- walletProviderBaseUrl
62
+ walletProviderEntityConfiguration
70
63
  );
71
64
 
72
65
  const decodedRequest = decodeJwt(signedAttestationRequest);
@@ -78,7 +71,9 @@ export const getAttestation =
78
71
 
79
72
  await verifyJwt(signedAttestationRequest, publicKey);
80
73
 
81
- const tokenUrl = new URL("token", walletProviderBaseUrl).href;
74
+ const tokenUrl =
75
+ walletProviderEntityConfiguration.payload.metadata.wallet_provider
76
+ .token_endpoint;
82
77
  const requestBody = {
83
78
  grant_type:
84
79
  "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation",
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PidIssuerEntityConfiguration = exports.PidDisplayMetadata = void 0;
7
- var _types = require("../trust/types");
8
- var _jwk = require("../utils/jwk");
9
- var _zod = require("zod");
10
- const PidDisplayMetadata = _zod.z.object({
11
- name: _zod.z.string(),
12
- locale: _zod.z.string(),
13
- logo: _zod.z.object({
14
- url: _zod.z.string(),
15
- alt_text: _zod.z.string()
16
- }),
17
- background_color: _zod.z.string(),
18
- text_color: _zod.z.string()
19
- });
20
- exports.PidDisplayMetadata = PidDisplayMetadata;
21
- const PidIssuerEntityConfiguration = _types.EntityConfiguration.and(_zod.z.object({
22
- payload: _zod.z.object({
23
- jwks: _zod.z.object({
24
- keys: _zod.z.array(_jwk.JWK)
25
- }),
26
- metadata: _zod.z.object({
27
- openid_credential_issuer: _zod.z.object({
28
- credential_issuer: _zod.z.string(),
29
- authorization_endpoint: _zod.z.string(),
30
- token_endpoint: _zod.z.string(),
31
- pushed_authorization_request_endpoint: _zod.z.string(),
32
- dpop_signing_alg_values_supported: _zod.z.array(_zod.z.string()),
33
- credential_endpoint: _zod.z.string(),
34
- credentials_supported: _zod.z.array(_zod.z.object({
35
- format: _zod.z.literal("vc+sd-jwt"),
36
- cryptographic_binding_methods_supported: _zod.z.array(_zod.z.string()),
37
- cryptographic_suites_supported: _zod.z.array(_zod.z.string()),
38
- display: _zod.z.array(PidDisplayMetadata)
39
- }))
40
- }),
41
- federation_entity: _zod.z.object({
42
- organization_name: _zod.z.string(),
43
- homepage_uri: _zod.z.string(),
44
- policy_uri: _zod.z.string(),
45
- tos_uri: _zod.z.string(),
46
- logo_uri: _zod.z.string()
47
- })
48
- })
49
- })
50
- }));
51
- exports.PidIssuerEntityConfiguration = PidIssuerEntityConfiguration;
52
- //# sourceMappingURL=metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_types","require","_jwk","_zod","PidDisplayMetadata","z","object","name","string","locale","logo","url","alt_text","background_color","text_color","exports","PidIssuerEntityConfiguration","EntityConfiguration","and","payload","jwks","keys","array","JWK","metadata","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","display","federation_entity","organization_name","homepage_uri","policy_uri","tos_uri","logo_uri"],"sourceRoot":"../../../src","sources":["pid/metadata.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAGO,MAAMG,kBAAkB,GAAGC,MAAC,CAACC,MAAM,CAAC;EACzCC,IAAI,EAAEF,MAAC,CAACG,MAAM,CAAC,CAAC;EAChBC,MAAM,EAAEJ,MAAC,CAACG,MAAM,CAAC,CAAC;EAClBE,IAAI,EAAEL,MAAC,CAACC,MAAM,CAAC;IACbK,GAAG,EAAEN,MAAC,CAACG,MAAM,CAAC,CAAC;IACfI,QAAQ,EAAEP,MAAC,CAACG,MAAM,CAAC;EACrB,CAAC,CAAC;EACFK,gBAAgB,EAAER,MAAC,CAACG,MAAM,CAAC,CAAC;EAC5BM,UAAU,EAAET,MAAC,CAACG,MAAM,CAAC;AACvB,CAAC,CAAC;AAACO,OAAA,CAAAX,kBAAA,GAAAA,kBAAA;AAKI,MAAMY,4BAA4B,GAAGC,0BAAmB,CAACC,GAAG,CACjEb,MAAC,CAACC,MAAM,CAAC;EACPa,OAAO,EAAEd,MAAC,CAACC,MAAM,CAAC;IAChBc,IAAI,EAAEf,MAAC,CAACC,MAAM,CAAC;MAAEe,IAAI,EAAEhB,MAAC,CAACiB,KAAK,CAACC,QAAG;IAAE,CAAC,CAAC;IACtCC,QAAQ,EAAEnB,MAAC,CAACC,MAAM,CAAC;MACjBmB,wBAAwB,EAAEpB,MAAC,CAACC,MAAM,CAAC;QACjCoB,iBAAiB,EAAErB,MAAC,CAACG,MAAM,CAAC,CAAC;QAC7BmB,sBAAsB,EAAEtB,MAAC,CAACG,MAAM,CAAC,CAAC;QAClCoB,cAAc,EAAEvB,MAAC,CAACG,MAAM,CAAC,CAAC;QAC1BqB,qCAAqC,EAAExB,MAAC,CAACG,MAAM,CAAC,CAAC;QACjDsB,iCAAiC,EAAEzB,MAAC,CAACiB,KAAK,CAACjB,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;QACtDuB,mBAAmB,EAAE1B,MAAC,CAACG,MAAM,CAAC,CAAC;QAC/BwB,qBAAqB,EAAE3B,MAAC,CAACiB,KAAK,CAC5BjB,MAAC,CAACC,MAAM,CAAC;UACP2B,MAAM,EAAE5B,MAAC,CAAC6B,OAAO,CAAC,WAAW,CAAC;UAC9BC,uCAAuC,EAAE9B,MAAC,CAACiB,KAAK,CAACjB,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;UAC5D4B,8BAA8B,EAAE/B,MAAC,CAACiB,KAAK,CAACjB,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;UACnD6B,OAAO,EAAEhC,MAAC,CAACiB,KAAK,CAAClB,kBAAkB;QACrC,CAAC,CACH;MACF,CAAC,CAAC;MACFkC,iBAAiB,EAAEjC,MAAC,CAACC,MAAM,CAAC;QAC1BiC,iBAAiB,EAAElC,MAAC,CAACG,MAAM,CAAC,CAAC;QAC7BgC,YAAY,EAAEnC,MAAC,CAACG,MAAM,CAAC,CAAC;QACxBiC,UAAU,EAAEpC,MAAC,CAACG,MAAM,CAAC,CAAC;QACtBkC,OAAO,EAAErC,MAAC,CAACG,MAAM,CAAC,CAAC;QACnBmC,QAAQ,EAAEtC,MAAC,CAACG,MAAM,CAAC;MACrB,CAAC;IACH,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;AAACO,OAAA,CAAAC,4BAAA,GAAAA,4BAAA"}
@@ -1,44 +0,0 @@
1
- import { EntityConfiguration } from "../trust/types";
2
- import { JWK } from "../utils/jwk";
3
- import { z } from "zod";
4
- export const PidDisplayMetadata = z.object({
5
- name: z.string(),
6
- locale: z.string(),
7
- logo: z.object({
8
- url: z.string(),
9
- alt_text: z.string()
10
- }),
11
- background_color: z.string(),
12
- text_color: z.string()
13
- });
14
- export const PidIssuerEntityConfiguration = EntityConfiguration.and(z.object({
15
- payload: z.object({
16
- jwks: z.object({
17
- keys: z.array(JWK)
18
- }),
19
- metadata: z.object({
20
- openid_credential_issuer: z.object({
21
- credential_issuer: z.string(),
22
- authorization_endpoint: z.string(),
23
- token_endpoint: z.string(),
24
- pushed_authorization_request_endpoint: z.string(),
25
- dpop_signing_alg_values_supported: z.array(z.string()),
26
- credential_endpoint: z.string(),
27
- credentials_supported: z.array(z.object({
28
- format: z.literal("vc+sd-jwt"),
29
- cryptographic_binding_methods_supported: z.array(z.string()),
30
- cryptographic_suites_supported: z.array(z.string()),
31
- display: z.array(PidDisplayMetadata)
32
- }))
33
- }),
34
- federation_entity: z.object({
35
- organization_name: z.string(),
36
- homepage_uri: z.string(),
37
- policy_uri: z.string(),
38
- tos_uri: z.string(),
39
- logo_uri: z.string()
40
- })
41
- })
42
- })
43
- }));
44
- //# sourceMappingURL=metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["EntityConfiguration","JWK","z","PidDisplayMetadata","object","name","string","locale","logo","url","alt_text","background_color","text_color","PidIssuerEntityConfiguration","and","payload","jwks","keys","array","metadata","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","display","federation_entity","organization_name","homepage_uri","policy_uri","tos_uri","logo_uri"],"sourceRoot":"../../../src","sources":["pid/metadata.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,CAAC,QAAQ,KAAK;AAGvB,OAAO,MAAMC,kBAAkB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACzCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EA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