@pagopa/io-react-native-wallet 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. package/lib/commonjs/index.js +9 -1
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/pid/issuing.js +28 -0
  4. package/lib/commonjs/pid/issuing.js.map +1 -1
  5. package/lib/commonjs/pid/metadata.js +51 -0
  6. package/lib/commonjs/pid/metadata.js.map +1 -0
  7. package/lib/commonjs/pid/sd-jwt/index.js +2 -1
  8. package/lib/commonjs/pid/sd-jwt/index.js.map +1 -1
  9. package/lib/commonjs/rp/__test__/index.test.js +3 -5
  10. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  11. package/lib/commonjs/rp/index.js +165 -15
  12. package/lib/commonjs/rp/index.js.map +1 -1
  13. package/lib/commonjs/rp/types.js +13 -1
  14. package/lib/commonjs/rp/types.js.map +1 -1
  15. package/lib/commonjs/sd-jwt/__test__/index.test.js +119 -0
  16. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -0
  17. package/lib/commonjs/sd-jwt/index.js +84 -4
  18. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  19. package/lib/commonjs/sd-jwt/types.js +9 -0
  20. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  21. package/lib/commonjs/sd-jwt/verifier.js +7 -5
  22. package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
  23. package/lib/commonjs/utils/errors.js +76 -1
  24. package/lib/commonjs/utils/errors.js.map +1 -1
  25. package/lib/module/index.js +5 -1
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/pid/issuing.js +30 -2
  28. package/lib/module/pid/issuing.js.map +1 -1
  29. package/lib/module/pid/metadata.js +43 -0
  30. package/lib/module/pid/metadata.js.map +1 -0
  31. package/lib/module/pid/sd-jwt/index.js +3 -3
  32. package/lib/module/pid/sd-jwt/index.js.map +1 -1
  33. package/lib/module/rp/__test__/index.test.js +3 -5
  34. package/lib/module/rp/__test__/index.test.js.map +1 -1
  35. package/lib/module/rp/index.js +168 -18
  36. package/lib/module/rp/index.js.map +1 -1
  37. package/lib/module/rp/types.js +11 -0
  38. package/lib/module/rp/types.js.map +1 -1
  39. package/lib/module/sd-jwt/__test__/index.test.js +118 -0
  40. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -0
  41. package/lib/module/sd-jwt/index.js +83 -3
  42. package/lib/module/sd-jwt/index.js.map +1 -1
  43. package/lib/module/sd-jwt/types.js +10 -0
  44. package/lib/module/sd-jwt/types.js.map +1 -1
  45. package/lib/module/sd-jwt/verifier.js +8 -6
  46. package/lib/module/sd-jwt/verifier.js.map +1 -1
  47. package/lib/module/utils/errors.js +71 -0
  48. package/lib/module/utils/errors.js.map +1 -1
  49. package/lib/typescript/{index.d.ts → src/index.d.ts} +3 -1
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/lib/typescript/src/pid/index.d.ts.map +1 -0
  52. package/lib/typescript/{pid → src/pid}/issuing.d.ts +9 -0
  53. package/lib/typescript/src/pid/issuing.d.ts.map +1 -0
  54. package/lib/typescript/src/pid/metadata.d.ts +528 -0
  55. package/lib/typescript/src/pid/metadata.d.ts.map +1 -0
  56. package/lib/typescript/src/pid/sd-jwt/converters.d.ts.map +1 -0
  57. package/lib/typescript/{pid → src/pid}/sd-jwt/index.d.ts +1 -1
  58. package/lib/typescript/src/pid/sd-jwt/index.d.ts.map +1 -0
  59. package/lib/typescript/src/pid/sd-jwt/types.d.ts.map +1 -0
  60. package/lib/typescript/src/rp/__test__/index.test.d.ts.map +1 -0
  61. package/lib/typescript/src/rp/index.d.ts +89 -0
  62. package/lib/typescript/src/rp/index.d.ts.map +1 -0
  63. package/lib/typescript/{rp → src/rp}/types.d.ts +71 -47
  64. package/lib/typescript/{rp → src/rp}/types.d.ts.map +1 -1
  65. package/lib/typescript/src/sd-jwt/__test__/converters.test.d.ts.map +1 -0
  66. package/lib/typescript/src/sd-jwt/__test__/index.test.d.ts +2 -0
  67. package/lib/typescript/src/sd-jwt/__test__/index.test.d.ts.map +1 -0
  68. package/lib/typescript/src/sd-jwt/__test__/types.test.d.ts.map +1 -0
  69. package/lib/typescript/src/sd-jwt/converters.d.ts.map +1 -0
  70. package/lib/typescript/{sd-jwt → src/sd-jwt}/index.d.ts +22 -2
  71. package/lib/typescript/src/sd-jwt/index.d.ts.map +1 -0
  72. package/lib/typescript/{sd-jwt → src/sd-jwt}/types.d.ts +12 -0
  73. package/lib/typescript/src/sd-jwt/types.d.ts.map +1 -0
  74. package/lib/typescript/src/sd-jwt/verifier.d.ts +3 -0
  75. package/lib/typescript/src/sd-jwt/verifier.d.ts.map +1 -0
  76. package/lib/typescript/src/utils/dpop.d.ts.map +1 -0
  77. package/lib/typescript/{utils → src/utils}/errors.d.ts +41 -0
  78. package/lib/typescript/src/utils/errors.d.ts.map +1 -0
  79. package/lib/typescript/src/utils/jwk.d.ts.map +1 -0
  80. package/lib/typescript/src/wallet-instance-attestation/index.d.ts.map +1 -0
  81. package/lib/typescript/src/wallet-instance-attestation/issuing.d.ts.map +1 -0
  82. package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/types.d.ts +8 -8
  83. package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/types.d.ts.map +1 -1
  84. package/package.json +7 -5
  85. package/src/index.ts +13 -1
  86. package/src/pid/issuing.ts +38 -1
  87. package/src/pid/metadata.ts +46 -0
  88. package/src/pid/sd-jwt/index.ts +7 -4
  89. package/src/rp/__test__/index.test.ts +5 -9
  90. package/src/rp/index.ts +208 -24
  91. package/src/rp/types.ts +16 -0
  92. package/src/sd-jwt/__test__/index.test.ts +171 -0
  93. package/src/sd-jwt/index.ts +84 -7
  94. package/src/sd-jwt/types.ts +13 -0
  95. package/src/sd-jwt/verifier.ts +5 -7
  96. package/src/utils/errors.ts +81 -0
  97. package/lib/typescript/index.d.ts.map +0 -1
  98. package/lib/typescript/pid/index.d.ts.map +0 -1
  99. package/lib/typescript/pid/issuing.d.ts.map +0 -1
  100. package/lib/typescript/pid/sd-jwt/converters.d.ts.map +0 -1
  101. package/lib/typescript/pid/sd-jwt/index.d.ts.map +0 -1
  102. package/lib/typescript/pid/sd-jwt/types.d.ts.map +0 -1
  103. package/lib/typescript/rp/__test__/index.test.d.ts.map +0 -1
  104. package/lib/typescript/rp/index.d.ts +0 -43
  105. package/lib/typescript/rp/index.d.ts.map +0 -1
  106. package/lib/typescript/sd-jwt/__test__/converters.test.d.ts.map +0 -1
  107. package/lib/typescript/sd-jwt/__test__/types.test.d.ts.map +0 -1
  108. package/lib/typescript/sd-jwt/converters.d.ts.map +0 -1
  109. package/lib/typescript/sd-jwt/index.d.ts.map +0 -1
  110. package/lib/typescript/sd-jwt/types.d.ts.map +0 -1
  111. package/lib/typescript/sd-jwt/verifier.d.ts +0 -3
  112. package/lib/typescript/sd-jwt/verifier.d.ts.map +0 -1
  113. package/lib/typescript/utils/dpop.d.ts.map +0 -1
  114. package/lib/typescript/utils/errors.d.ts.map +0 -1
  115. package/lib/typescript/utils/jwk.d.ts.map +0 -1
  116. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +0 -1
  117. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +0 -1
  118. /package/lib/typescript/{pid → src/pid}/index.d.ts +0 -0
  119. /package/lib/typescript/{pid → src/pid}/sd-jwt/converters.d.ts +0 -0
  120. /package/lib/typescript/{pid → src/pid}/sd-jwt/types.d.ts +0 -0
  121. /package/lib/typescript/{rp → src/rp}/__test__/index.test.d.ts +0 -0
  122. /package/lib/typescript/{sd-jwt → src/sd-jwt}/__test__/converters.test.d.ts +0 -0
  123. /package/lib/typescript/{sd-jwt → src/sd-jwt}/__test__/types.test.d.ts +0 -0
  124. /package/lib/typescript/{sd-jwt → src/sd-jwt}/converters.d.ts +0 -0
  125. /package/lib/typescript/{utils → src/utils}/dpop.d.ts +0 -0
  126. /package/lib/typescript/{utils → src/utils}/jwk.d.ts +0 -0
  127. /package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/index.d.ts +0 -0
  128. /package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/issuing.d.ts +0 -0
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ var _index = require("../index");
4
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
5
+ var _types = require("../types");
6
+ // Examples from https://www.ietf.org/id/draft-terbu-sd-jwt-vc-02.html#name-example-4
7
+ // but adapted to adhere to format declared in https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/pid-eaa-data-model.html#id2
8
+ // In short, the token is a Frankenstein composed as follows:
9
+ // - the header is taken from the italian specification, with kid and alg valued according to the signing keys
10
+ // - disclosures are taken from the SD-JWT-4-VC standard
11
+ // - payload is taken from the italian specification, but _sd are compiled with:
12
+ // - "address" is used as verification._sd
13
+ // - all others disclosures are in claims._sd
14
+ const token = "eyJ0eXAiOiJ2YytzZC1qd3QiLCJhbGciOiJFUzI1NiIsImtpZCI6ImIxODZlYTBjMTkyNTc5MzA5N2JmMDFiOGEyODlhNDVmIiwidHJ1c3RfY2hhaW4iOlsiTkVoUmRFUnBZbmxIWTNNNVdsZFdUV1oyYVVobSAuLi4iLCJleUpoYkdjaU9pSlNVekkxTmlJc0ltdHBaQ0k2IC4uLiIsIklrSllkbVp5Ykc1b1FVMTFTRkl3TjJGcVZXMUIgLi4uIl19.eyJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tL2lzc3VlciIsInN1YiI6Ik56YkxzWGg4dURDY2Q3bm9XWEZaQWZIa3hac1JHQzlYcy4uLiIsImp0aSI6InVybjp1dWlkOjZjNWMwYTQ5LWI1ODktNDMxZC1iYWU3LTIxOTEyMmE5ZWMyYyIsImlhdCI6MTU0MTQ5MzcyNCwiZXhwIjoxNTQxNDkzNzI0LCJzdGF0dXMiOiJodHRwczovL2V4YW1wbGUuY29tL3N0YXR1cyIsImNuZiI6eyJqd2siOnsia3R5IjoiUlNBIiwidXNlIjoic2lnIiwibiI6IjFUYS1zRSIsImUiOiJBUU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= "8wwSHCd47wCgzRYXvvPTTRXGS-hk9V8jRzy7WSjRBTZxSHxJkGOSWwBVAA-kpJ-IvQS7699aLWxIMqAvr34sOA";
17
+ const signed = `${unsigned}.${signature}`;
18
+ const tokenizedDisclosures = ["WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd", "WyJlbHVWNU9nM2dTTklJOEVZbnN4QV9BIiwgImZhbWlseV9uYW1lIiwgIkRvZSJd", "WyI2SWo3dE0tYTVpVlBHYm9TNXRtdlZBIiwgImVtYWlsIiwgImpvaG5kb2VAZXhhbXBsZS5jb20iXQ", "WyJlSThaV205UW5LUHBOUGVOZW5IZGhRIiwgInBob25lX251bWJlciIsICIrMS0yMDItNTU1LTAxMDEiXQ", "WyJBSngtMDk1VlBycFR0TjRRTU9xUk9BIiwgImJpcnRoZGF0ZSIsICIxOTQwLTAxLTAxIl0", "WyJQYzMzSk0yTGNoY1VfbEhnZ3ZfdWZRIiwgImlzX292ZXJfMTgiLCB0cnVlXQ", "WyJHMDJOU3JRZmpGWFE3SW8wOXN5YWpBIiwgImlzX292ZXJfMjEiLCB0cnVlXQ", "WyJsa2x4RjVqTVlsR1RQVW92TU5JdkNBIiwgImlzX292ZXJfNjUiLCB0cnVlXQ", "WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgImFkZHJlc3MiLCB7InN0cmVldF9hZGRyZXNzIjogIjEyMyBNYWluIFN0IiwgImxvY2FsaXR5IjogIkFueXRvd24iLCAicmVnaW9uIjogIkFueXN0YXRlIiwgImNvdW50cnkiOiAiVVMifV0"];
19
+ const sdJwt = {
20
+ header: {
21
+ typ: "vc+sd-jwt",
22
+ alg: "ES256",
23
+ kid: "b186ea0c1925793097bf01b8a289a45f",
24
+ trust_chain: ["NEhRdERpYnlHY3M5WldWTWZ2aUhm ...", "eyJhbGciOiJSUzI1NiIsImtpZCI6 ...", "IkJYdmZybG5oQU11SFIwN2FqVW1B ..."]
25
+ },
26
+ payload: {
27
+ iss: "https://example.com/issuer",
28
+ sub: "NzbLsXh8uDCcd7noWXFZAfHkxZsRGC9Xs...",
29
+ jti: "urn:uuid:6c5c0a49-b589-431d-bae7-219122a9ec2c",
30
+ iat: 1541493724,
31
+ exp: 1541493724,
32
+ status: "https://example.com/status",
33
+ cnf: {
34
+ jwk: {
35
+ kty: "RSA",
36
+ use: "sig",
37
+ n: "1Ta-sE",
38
+ e: "AQAB",
39
+ kid: "YhNFS3YnC9tjiCaivhWLVUJ3AxwGGz_98uRFaqMEEs"
40
+ }
41
+ },
42
+ type: "PersonIdentificationData",
43
+ verified_claims: {
44
+ verification: {
45
+ _sd: ["JzYjH4svliH0R3PyEMfeZu6Jt69u5qehZo7F7EPYlSE"],
46
+ trust_framework: "eidas",
47
+ assurance_level: "high"
48
+ },
49
+ claims: {
50
+ _sd: ["09vKrJMOlyTWM0sjpu_pdOBVBQ2M1y3KhpH515nXkpY", "2rsjGbaC0ky8mT0pJrPioWTq0_daw1sX76poUlgCwbI", "EkO8dhW0dHEJbvUHlE_VCeuC9uRELOieLZhh7XbUTtA", "IlDzIKeiZdDwpqpK6ZfbyphFvz5FgnWa-sN6wqQXCiw", "PorFbpKuVu6xymJagvkFsFXAbRoc2JGlAUA2BA4o7cI", "TGf4oLbgwd5JQaHyKVQZU9UdGE0w5rtDsrZzfUaomLo", "jdrTE8YcbY4EifugihiAe_BPekxJQZICeiUQwY9QqxI", "jsu9yVulwQQlhFlM_3JlzMaSFzglhQG0DpfayQwLUK4"]
51
+ }
52
+ },
53
+ _sd_alg: "sha-256"
54
+ }
55
+ };
56
+
57
+ // In the very same order than tokenizedDisclosures
58
+ const disclosures = [["2GLC42sKQveCfGfryNRN9w", "given_name", "John"], ["eluV5Og3gSNII8EYnsxA_A", "family_name", "Doe"], ["6Ij7tM-a5iVPGboS5tmvVA", "email", "johndoe@example.com"], ["eI8ZWm9QnKPpNPeNenHdhQ", "phone_number", "+1-202-555-0101"], ["AJx-095VPrpTtN4QMOqROA", "birthdate", "1940-01-01"], ["Pc33JM2LchcU_lHggv_ufQ", "is_over_18", true], ["G02NSrQfjFXQ7Io09syajA", "is_over_21", true], ["lklxF5jMYlGTPUovMNIvCA", "is_over_65", true], ["Qg_O64zqAxe412a108iroA", "address", {
59
+ street_address: "123 Main St",
60
+ locality: "Anytown",
61
+ region: "Anystate",
62
+ country: "US"
63
+ }]];
64
+ it("Ensures example data correctness", () => {
65
+ expect(JSON.parse((0, _ioReactNativeJwt.decodeBase64)((0, _ioReactNativeJwt.encodeBase64)(JSON.stringify(sdJwt.header))))).toEqual(sdJwt.header);
66
+ expect([signed, ...tokenizedDisclosures].join("~")).toBe(token);
67
+ });
68
+ describe("decode", () => {
69
+ it("should decode a valid token", () => {
70
+ const result = (0, _index.decode)(token, _types.SdJwt4VC);
71
+ expect(result).toEqual({
72
+ sdJwt,
73
+ disclosures: disclosures.map((decoded, i) => ({
74
+ decoded,
75
+ encoded: tokenizedDisclosures[i]
76
+ }))
77
+ });
78
+ });
79
+ });
80
+ describe("disclose", () => {
81
+ it("should encode a valid sdjwt (one claim)", async () => {
82
+ const result = await (0, _index.disclose)(token, ["given_name"]);
83
+ const expected = {
84
+ token: `${signed}~WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd`,
85
+ paths: [{
86
+ claim: "given_name",
87
+ path: "verified_claims.claims._sd[7]"
88
+ }]
89
+ };
90
+ expect(result).toEqual(expected);
91
+ });
92
+ it("should encode a valid sdjwt (no claims)", async () => {
93
+ const result = await (0, _index.disclose)(token, []);
94
+ const expected = {
95
+ token: `${signed}`,
96
+ paths: []
97
+ };
98
+ expect(result).toEqual(expected);
99
+ });
100
+ it("should encode a valid sdjwt (multiple claims)", async () => {
101
+ const result = await (0, _index.disclose)(token, ["given_name", "email"]);
102
+ const expected = {
103
+ token: `${signed}~WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd~WyI2SWo3dE0tYTVpVlBHYm9TNXRtdlZBIiwgImVtYWlsIiwgImpvaG5kb2VAZXhhbXBsZS5jb20iXQ`,
104
+ paths: [{
105
+ claim: "given_name",
106
+ path: "verified_claims.claims._sd[7]"
107
+ }, {
108
+ claim: "email",
109
+ path: "verified_claims.verification._sd[0]"
110
+ }]
111
+ };
112
+ expect(result).toEqual(expected);
113
+ });
114
+ it("should fail on unknown claim", async () => {
115
+ const fn = async () => (0, _index.disclose)(token, ["unknown"]);
116
+ await expect(fn()).rejects.toEqual(expect.any(Error));
117
+ });
118
+ });
119
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_index","require","_ioReactNativeJwt","_types","token","unsigned","signature","signed","tokenizedDisclosures","sdJwt","header","typ","alg","kid","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","kty","use","n","e","type","verified_claims","verification","_sd","trust_framework","assurance_level","claims","_sd_alg","disclosures","street_address","locality","region","country","it","expect","JSON","parse","decodeBase64","encodeBase64","stringify","toEqual","join","toBe","describe","result","decode","SdJwt4VC","map","decoded","i","encoded","disclose","expected","paths","claim","path","fn","rejects","any","Error"],"sourceRoot":"../../../../src","sources":["sd-jwt/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,KAAK,GACT,kvEAAkvE;AAEpvE,MAAMC,QAAQ,GACZ,87CAA87C;AAEh8C,MAAMC,SAAS,GACb,wFAAwF;AAE1F,MAAMC,MAAM,GAAI,GAAEF,QAAS,IAAGC,SAAU,EAAC;AAEzC,MAAME,oBAAoB,GAAG,CAC3B,kEAAkE,EAClE,kEAAkE,EAClE,gFAAgF,EAChF,oFAAoF,EACpF,yEAAyE,EACzE,gEAAgE,EAChE,gEAAgE,E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AAC,CAAC,CAAC,CAACC,OAAO,CAACjB,OAAO,CAACN,MAAM,CAACwB,GAAG,CAACC,KAAK,CAAC,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -3,10 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verify = exports.decode = void 0;
6
+ exports.verify = exports.disclose = exports.decode = void 0;
7
7
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
8
  var _types = require("./types");
9
9
  var _verifier = require("./verifier");
10
+ var _errors = require("../utils/errors");
11
+ const decodeDisclosure = encoded => {
12
+ const decoded = _types.Disclosure.parse(JSON.parse((0, _ioReactNativeJwt.decodeBase64)(encoded)));
13
+ return {
14
+ decoded,
15
+ encoded
16
+ };
17
+ };
18
+
10
19
  /**
11
20
  * Decode a given SD-JWT with Disclosures to get the parsed SD-JWT object they define.
12
21
  * It ensures provided data is in a valid shape.
@@ -39,13 +48,81 @@ const decode = (token, schema) => {
39
48
  // get disclosures as list of triples
40
49
  // validate each triple
41
50
  // throw a validation error if at least one fails to parse
42
- const disclosures = rawDisclosures.map(_ioReactNativeJwt.decodeBase64).map(e => JSON.parse(e)).map(e => _types.Disclosure.parse(e));
51
+ const disclosures = rawDisclosures.map(decodeDisclosure);
43
52
  return {
44
53
  sdJwt,
45
54
  disclosures
46
55
  };
47
56
  };
48
57
 
58
+ /**
59
+ * Select disclosures from a given SD-JWT with Disclosures.
60
+ * Claims relate with disclosures by their name.
61
+ *
62
+ * @function
63
+ * @param token The encoded token that represents a valid sd-jwt for verifiable credentials
64
+ * @param claims The list of claims to be disclosed
65
+ *
66
+ * @throws {ClaimsNotFoundBetweenDislosures} When one or more claims does not relate to any discloure.
67
+ * @throws {ClaimsNotFoundInToken} When one or more claims are not contained in the SD-JWT token.
68
+ * @returns The encoded token with only the requested disclosures, along with the path each claim can be found on the SD-JWT token
69
+ *
70
+ */
71
+ exports.decode = decode;
72
+ const disclose = async (token, claims) => {
73
+ const [rawSdJwt, ...rawDisclosures] = token.split("~");
74
+ const {
75
+ sdJwt,
76
+ disclosures
77
+ } = decode(token, _types.SdJwt4VC);
78
+
79
+ // for each claim, return the path on which they are located in the SD-JWT token
80
+ const paths = await Promise.all(claims.map(async claim => {
81
+ const disclosure = disclosures.find(_ref => {
82
+ let {
83
+ decoded: [, name]
84
+ } = _ref;
85
+ return name === claim;
86
+ });
87
+
88
+ // check every claim represents a known disclosure
89
+ if (!disclosure) {
90
+ throw new _errors.ClaimsNotFoundBetweenDislosures(claim);
91
+ }
92
+ const hash = await (0, _ioReactNativeJwt.sha256ToBase64)(disclosure.encoded);
93
+
94
+ // _sd is defined in verified_claims.claims and verified_claims.verification
95
+ // we must look into both
96
+ if (sdJwt.payload.verified_claims.claims._sd.includes(hash)) {
97
+ const index = sdJwt.payload.verified_claims.claims._sd.indexOf(hash);
98
+ return {
99
+ claim,
100
+ path: `verified_claims.claims._sd[${index}]`
101
+ };
102
+ } else if (sdJwt.payload.verified_claims.verification._sd.includes(hash)) {
103
+ const index = sdJwt.payload.verified_claims.verification._sd.indexOf(hash);
104
+ return {
105
+ claim,
106
+ path: `verified_claims.verification._sd[${index}]`
107
+ };
108
+ }
109
+ throw new _errors.ClaimsNotFoundInToken(claim);
110
+ }));
111
+ const filteredDisclosures = rawDisclosures.filter(d => {
112
+ const {
113
+ decoded: [, name]
114
+ } = decodeDisclosure(d);
115
+ return claims.includes(name);
116
+ });
117
+
118
+ // compose the final disclosed token
119
+ const disclosedToken = [rawSdJwt, ...filteredDisclosures].join("~");
120
+ return {
121
+ token: disclosedToken,
122
+ paths
123
+ };
124
+ };
125
+
49
126
  /**
50
127
  * Verify a given SD-JWT with Disclosures
51
128
  * Same as {@link decode} plus:
@@ -62,7 +139,7 @@ const decode = (token, schema) => {
62
139
  * @returns The parsed SD-JWT token and the parsed disclosures
63
140
  *
64
141
  */
65
- exports.decode = decode;
142
+ exports.disclose = disclose;
66
143
  const verify = async (token, publicKey, schema) => {
67
144
  // get decoded data
68
145
  const [rawSdJwt = ""] = token.split("~");
@@ -74,7 +151,10 @@ const verify = async (token, publicKey, schema) => {
74
151
  //Check disclosures in sd-jwt
75
152
  const claims = [...decoded.sdJwt.payload.verified_claims.verification._sd, ...decoded.sdJwt.payload.verified_claims.claims._sd];
76
153
  await Promise.all(decoded.disclosures.map(async disclosure => await (0, _verifier.verifyDisclosure)(disclosure, claims)));
77
- return decoded;
154
+ return {
155
+ sdJwt: decoded.sdJwt,
156
+ disclosures: decoded.disclosures.map(d => d.decoded)
157
+ };
78
158
  };
79
159
  exports.verify = verify;
80
160
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_types","_verifier","decode","token","schema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","decodeJwt","sdJwt","parse","header","protectedHeader","payload","disclosures","map","decodeBase64","e","JSON","Disclosure","exports","verify","publicKey","decoded","verifyJwt","claims","verified_claims","verification","_sd","Promise","all","disclosure","verifyDisclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,MAAM,GAAGA,CACpBC,KAAa,EACbC,MAAS,KAC4C;EACrD;EACA,IAAID,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAC3BF,KAAK,GAAGA,KAAK,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC5B;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,GAAGJ,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;;EAE3D;EACA;EACA,MAAMC,UAAU,GAAG,IAAAC,wBAAS,EAAC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ED,OAAOF,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_types","_verifier","_errors","decodeDisclosure","encoded","decoded","Disclosure","parse","JSON","decodeBase64","decode","token","schema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","decodeJwt","sdJwt","header","protectedHeader","payload","disclosures","map","exports","disclose","claims","SdJwt4VC","paths","Promise","all","claim","disclosure","find","_ref","name","ClaimsNotFoundBetweenDislosures","hash","sha256ToBase64","verified_claims","_sd","includes","index","indexOf","path","verification","ClaimsNotFoundInToken","filteredDisclosures","filter","d","disclosedToken","join","verify","publicKey","verifyJwt","verifyDisclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAKA,MAAMI,gBAAgB,GAAIC,OAAe,IAA4B;EACnE,MAAMC,OAAO,GAAGC,iBAAU,CAACC,KAAK,CAACC,IAAI,CAACD,KAAK,CAAC,IAAAE,8BAAY,EAACL,OAAO,CAAC,CAAC,CAAC;EACnE,OAAO;IAAEC,OAAO;IAAED;EAAQ,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,MAAM,GAAGA,CACpBC,KAAa,EACbC,MAAS,KAIN;EACH;EACA,IAAID,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAC3BF,KAAK,GAAGA,KAAK,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC5B;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,GAAGJ,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;;EA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EAC9D;EACA,MAAM,CAACE,QAAQ,GAAG,EAAE,CAAC,GAAGH,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;EACxC,MAAMX,OAAO,GAAGK,MAAM,CAACC,KAAK,EAAEC,MAAM,CAAC;;EAErC;EACA,MAAM,IAAA2C,wBAAS,EAACzC,QAAQ,EAAEwC,SAAS,CAAC;;EAEpC;EACA,MAAM3B,MAAM,GAAG,CACb,GAAGtB,OAAO,CAACc,KAAK,CAACG,OAAO,CAACkB,eAAe,CAACM,YAAY,CAACL,GAAG,EACzD,GAAGpC,OAAO,CAACc,KAAK,CAACG,OAAO,CAACkB,eAAe,CAACb,MAAM,CAACc,GAAG,CACpD;EAED,MAAMX,OAAO,CAACC,GAAG,CACf1B,OAAO,CAACkB,WAAW,CAACC,GAAG,CACrB,MAAOS,UAAU,IAAK,MAAM,IAAAuB,0BAAgB,EAACvB,UAAU,EAAEN,MAAM,CACjE,CACF,CAAC;EAED,OAAO;IACLR,KAAK,EAAEd,OAAO,CAACc,KAAK;IACpBI,WAAW,EAAElB,OAAO,CAACkB,WAAW,CAACC,GAAG,CAAE0B,CAAC,IAAKA,CAAC,CAAC7C,OAAO;EACvD,CAAC;AACH,CAAC;AAACoB,OAAA,CAAA4B,MAAA,GAAAA,MAAA"}
@@ -20,6 +20,15 @@ const ObfuscatedDisclosures = _zod.z.object({
20
20
  */
21
21
  exports.ObfuscatedDisclosures = ObfuscatedDisclosures;
22
22
  const Disclosure = _zod.z.tuple([/* salt */_zod.z.string(), /* claim name */_zod.z.string(), /* claim value */_zod.z.unknown()]);
23
+
24
+ /**
25
+ * Encoding depends on the serialization algorithm used when generating the disclosure tokens.
26
+ * The SD-JWT reference itself take no decision about how to handle whitespaces in serialized objects.
27
+ * For such reason, we may find conveninent to have encoded and decode values stored explicitly in the same structure.
28
+ * Please note that `encoded` can always decode into `decode`, but `decode` may or may not be encoded with the same value of `encoded`
29
+ *
30
+ * @see https://www.ietf.org/id/draft-ietf-oauth-selective-disclosure-jwt-05.html#name-disclosures-for-object-prop
31
+ */
23
32
  exports.Disclosure = Disclosure;
24
33
  const SdJwt4VC = _zod.z.object({
25
34
  header: _zod.z.object({
@@ -1 +1 @@
1
- {"version":3,"names":["_jwk","require","_zod","UnixTime","z","number","min","max","exports","ObfuscatedDisclosures","object","_sd","array","string","Disclosure","tuple","unknown","SdJwt4VC","header","typ","literal","alg","kid","optional","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","JWK","type","verified_claims","verification","intersection","trust_framework","assurance_level","claims","_sd_alg"],"sourceRoot":"../../../src","sources":["sd-jwt/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAGC,MAAC,CAACC,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAItD,MAAMM,qBAAqB,GAAGL,MAAC,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAEP,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;AAAE,CAAC,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AALAL,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAOO,MAAMK,UAAU,GAAGV,MAAC,CAACW,KAAK,CAAC,CAChC,UAAWX,MAAC,CAACS,MAAM,CAAC,CAAC,EACrB,gBAAiBT,MAAC,CAACS,MAAM,CAAC,CAAC,EAC3B,iBAAkBT,MAAC,CAACY,OAAO,CAAC,CAAC,CAC9B,CAAC;AAACR,OAAA,CAAAM,UAAA,GAAAA,UAAA;AAGI,MAAMG,QAAQ,GAAGb,MAAC,CAACM,MAAM,CAAC;EAC/BQ,MAAM,EAAEd,MAAC,CAACM,MAAM,CAAC;IACfS,GAAG,EAAEf,MAAC,CAACgB,OAAO,CAAC,WAAW,CAAC;IAC3BC,GAAG,EAAEjB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfS,GAAG,EAAElB,MAAC,CAACS,MAAM,CAAC,CAAC,CAACU,QAAQ,CAAC,CAAC;IAC1BC,WAAW,EAAEpB,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;EACjC,CAAC,CAAC;EACFY,OAAO,EAAErB,MAAC,CAACM,MAAM,CAAC;IAChBgB,GAAG,EAAEtB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfc,GAAG,EAAEvB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfe,GAAG,EAAExB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfgB,GAAG,EAAE1B,QAAQ;IACb2B,GAAG,EAAE3B,QAAQ;IACb4B,MAAM,EAAE3B,MAAC,CAACS,MAAM,CAAC,CAAC;IAClBmB,GAAG,EAAE5B,MAAC,CAACM,MAAM,CAAC;MACZuB,GAAG,EAAEC;IACP,CAAC,CAAC;IACFC,IAAI,EAAE/B,MAAC,CAACgB,OAAO,CAAC,0BAA0B,CAAC;IAC3CgB,eAAe,EAAEhC,MAAC,CAACM,MAAM,CAAC;MACxB2B,YAAY,EAAEjC,MAAC,CAACkC,YAAY,CAC1BlC,MAAC,CAACM,MAAM,CAAC;QACP6B,eAAe,EAAEnC,MAAC,CAACgB,OAAO,CAAC,OAAO,CAAC;QACnCoB,eAAe,EAAEpC,MAAC,CAACS,MAAM,CAAC;MAC5B,CAAC,CAAC,EACFJ,qBACF,CAAC;MACDgC,MAAM,EAAEhC;IACV,CAAC,CAAC;IACFiC,OAAO,EAAEtC,MAAC,CAACgB,OAAO,CAAC,SAAS;EAC9B,CAAC;AACH,CAAC,CAAC;AAACZ,OAAA,CAAAS,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_jwk","require","_zod","UnixTime","z","number","min","max","exports","ObfuscatedDisclosures","object","_sd","array","string","Disclosure","tuple","unknown","SdJwt4VC","header","typ","literal","alg","kid","optional","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","JWK","type","verified_claims","verification","intersection","trust_framework","assurance_level","claims","_sd_alg"],"sourceRoot":"../../../src","sources":["sd-jwt/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAGC,MAAC,CAACC,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAItD,MAAMM,qBAAqB,GAAGL,MAAC,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAEP,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;AAAE,CAAC,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AALAL,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAOO,MAAMK,UAAU,GAAGV,MAAC,CAACW,KAAK,CAAC,CAChC,UAAWX,MAAC,CAACS,MAAM,CAAC,CAAC,EACrB,gBAAiBT,MAAC,CAACS,MAAM,CAAC,CAAC,EAC3B,iBAAkBT,MAAC,CAACY,OAAO,CAAC,CAAC,CAC9B,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAR,OAAA,CAAAM,UAAA,GAAAA,UAAA;AAcO,MAAMG,QAAQ,GAAGb,MAAC,CAACM,MAAM,CAAC;EAC/BQ,MAAM,EAAEd,MAAC,CAACM,MAAM,CAAC;IACfS,GAAG,EAAEf,MAAC,CAACgB,OAAO,CAAC,WAAW,CAAC;IAC3BC,GAAG,EAAEjB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfS,GAAG,EAAElB,MAAC,CAACS,MAAM,CAAC,CAAC,CAACU,QAAQ,CAAC,CAAC;IAC1BC,WAAW,EAAEpB,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;EACjC,CAAC,CAAC;EACFY,OAAO,EAAErB,MAAC,CAACM,MAAM,CAAC;IAChBgB,GAAG,EAAEtB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfc,GAAG,EAAEvB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfe,GAAG,EAAExB,MAAC,CAACS,MAAM,CAAC,CAAC;IACfgB,GAAG,EAAE1B,QAAQ;IACb2B,GAAG,EAAE3B,QAAQ;IACb4B,MAAM,EAAE3B,MAAC,CAACS,MAAM,CAAC,CAAC;IAClBmB,GAAG,EAAE5B,MAAC,CAACM,MAAM,CAAC;MACZuB,GAAG,EAAEC;IACP,CAAC,CAAC;IACFC,IAAI,EAAE/B,MAAC,CAACgB,OAAO,CAAC,0BAA0B,CAAC;IAC3CgB,eAAe,EAAEhC,MAAC,CAACM,MAAM,CAAC;MACxB2B,YAAY,EAAEjC,MAAC,CAACkC,YAAY,CAC1BlC,MAAC,CAACM,MAAM,CAAC;QACP6B,eAAe,EAAEnC,MAAC,CAACgB,OAAO,CAAC,OAAO,CAAC;QACnCoB,eAAe,EAAEpC,MAAC,CAACS,MAAM,CAAC;MAC5B,CAAC,CAAC,EACFJ,qBACF,CAAC;MACDgC,MAAM,EAAEhC;IACV,CAAC,CAAC;IACFiC,OAAO,EAAEtC,MAAC,CAACgB,OAAO,CAAC,SAAS;EAC9B,CAAC;AACH,CAAC,CAAC;AAACZ,OAAA,CAAAS,QAAA,GAAAA,QAAA"}
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.verifyDisclosure = void 0;
7
7
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
8
  var _errors = require("../utils/errors");
9
- const verifyDisclosure = async (disclosure, claims) => {
10
- let disclosureString = JSON.stringify(disclosure);
11
- let encodedDisclosure = (0, _ioReactNativeJwt.encodeBase64)(disclosureString);
12
- let hash = await (0, _ioReactNativeJwt.sha256ToBase64)(encodedDisclosure);
9
+ const verifyDisclosure = async (_ref, claims) => {
10
+ let {
11
+ encoded,
12
+ decoded
13
+ } = _ref;
14
+ let hash = await (0, _ioReactNativeJwt.sha256ToBase64)(encoded);
13
15
  if (!claims.includes(hash)) {
14
- throw new _errors.ValidationFailed("Validation of disclosure failed", `${disclosure}`, "Disclosure hash not found in claims");
16
+ throw new _errors.ValidationFailed("Validation of disclosure failed", `${decoded}`, "Disclosure hash not found in claims");
15
17
  }
16
18
  };
17
19
  exports.verifyDisclosure = verifyDisclosure;
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_errors","verifyDisclosure","disclosure","claims","disclosureString","JSON","stringify","encodedDisclosure","encodeBase64","hash","sha256ToBase64","includes","ValidationFailed","exports"],"sourceRoot":"../../../src","sources":["sd-jwt/verifier.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAGO,MAAME,gBAAgB,GAAG,MAAAA,CAC9BC,UAAsB,EACtBC,MAAoC,KACjC;EACH,IAAIC,gBAAgB,GAAGC,IAAI,CAACC,SAAS,CAACJ,UAAU,CAAC;EACjD,IAAIK,iBAAiB,GAAG,IAAAC,8BAAY,EAACJ,gBAAgB,CAAC;EACtD,IAAIK,IAAI,GAAG,MAAM,IAAAC,gCAAc,EAACH,iBAAiB,CAAC;EAClD,IAAI,CAACJ,MAAM,CAACQ,QAAQ,CAACF,IAAI,CAAC,EAAE;IAC1B,MAAM,IAAIG,wBAAgB,CACxB,iCAAiC,EAChC,GAAEV,UAAW,EAAC,EACf,qCACF,CAAC;EACH;AACF,CAAC;AAACW,OAAA,CAAAZ,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_errors","verifyDisclosure","_ref","claims","encoded","decoded","hash","sha256ToBase64","includes","ValidationFailed","exports"],"sourceRoot":"../../../src","sources":["sd-jwt/verifier.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAGO,MAAME,gBAAgB,GAAG,MAAAA,CAAAC,IAAA,EAE9BC,MAAoC,KACjC;EAAA,IAFH;IAAEC,OAAO;IAAEC;EAA+B,CAAC,GAAAH,IAAA;EAG3C,IAAII,IAAI,GAAG,MAAM,IAAAC,gCAAc,EAACH,OAAO,CAAC;EACxC,IAAI,CAACD,MAAM,CAACK,QAAQ,CAACF,IAAI,CAAC,EAAE;IAC1B,MAAM,IAAIG,wBAAgB,CACxB,iCAAiC,EAChC,GAAEJ,OAAQ,EAAC,EACZ,qCACF,CAAC;EACH;AACF,CAAC;AAACK,OAAA,CAAAT,gBAAA,GAAAA,gBAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WalletInstanceAttestationIssuingError = exports.ValidationFailed = exports.PidIssuingError = exports.IoWalletError = exports.AuthRequestDecodeError = void 0;
6
+ exports.WalletInstanceAttestationIssuingError = exports.ValidationFailed = exports.PidMetadataError = exports.PidIssuingError = exports.NoSuitableKeysFoundInEntityConfiguration = exports.IoWalletError = exports.ClaimsNotFoundInToken = exports.ClaimsNotFoundBetweenDislosures = exports.AuthRequestDecodeError = void 0;
7
7
  /**
8
8
  * A generic Error that all other io-wallet specific Error subclasses extend.
9
9
  *
@@ -126,5 +126,80 @@ class PidIssuingError extends IoWalletError {
126
126
  this.reason = reason;
127
127
  }
128
128
  }
129
+
130
+ /**
131
+ * When claims are requested but not found in the credential
132
+ *
133
+ */
129
134
  exports.PidIssuingError = PidIssuingError;
135
+ class ClaimsNotFoundBetweenDislosures extends Error {
136
+ static get code() {
137
+ return "ERR_CLAIMS_NOT_FOUND";
138
+ }
139
+ code = "ERR_CLAIMS_NOT_FOUND";
140
+
141
+ /** The Claims not found */
142
+
143
+ constructor(claims) {
144
+ const c = Array.isArray(claims) ? claims : [claims];
145
+ const message = `Some requested claims are not present in the disclosurable values, claims: ${c.join(", ")}`;
146
+ super(message);
147
+ this.claims = c;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * When the SD-JWT does not contain an hashed reference to a given set of claims
153
+ */
154
+ exports.ClaimsNotFoundBetweenDislosures = ClaimsNotFoundBetweenDislosures;
155
+ class ClaimsNotFoundInToken extends Error {
156
+ static get code() {
157
+ return "ERR_CLAIMS_NOT_FOUND_IN_TOKEN";
158
+ }
159
+ code = "ERR_CLAIMS_NOT_FOUND_IN_TOKEN";
160
+
161
+ /** The Claims not found */
162
+
163
+ constructor(claims) {
164
+ const c = Array.isArray(claims) ? claims : [claims];
165
+ const message = `Some claims are not found in the given token, claims: ${c.join(", ")}`;
166
+ super(message);
167
+ this.claims = c;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
173
+ *
174
+ */
175
+ exports.ClaimsNotFoundInToken = ClaimsNotFoundInToken;
176
+ class NoSuitableKeysFoundInEntityConfiguration extends Error {
177
+ static get code() {
178
+ return "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
179
+ }
180
+ code = "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
181
+
182
+ /**
183
+ * @param scenario describe the scenario in which the error arise
184
+ */
185
+ constructor(scenario) {
186
+ const message = `Entity configuration do not provide any suitable keys (${scenario}).`;
187
+ super(message);
188
+ }
189
+ }
190
+
191
+ /**
192
+ * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
193
+ *
194
+ */
195
+ exports.NoSuitableKeysFoundInEntityConfiguration = NoSuitableKeysFoundInEntityConfiguration;
196
+ class PidMetadataError extends Error {
197
+ static get code() {
198
+ return "PID_METADATA_ERROR";
199
+ }
200
+ constructor(message) {
201
+ super(message);
202
+ }
203
+ }
204
+ exports.PidMetadataError = PidMetadataError;
130
205
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","exports","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError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IAA/CO,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAAA,IAAEG,MAAM,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IACxE,KAAK,CAACR,OAAO,CAAC;IACd,IAAI,CAACO,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF;AAACN,OAAA,CAAAS,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","exports","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError","ClaimsNotFoundBetweenDislosures","claims","c","Array","isArray","join","ClaimsNotFoundInToken","NoSuitableKeysFoundInEntityConfiguration","scenario","PidMetadataError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,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,IAAI,CAACE,WAAW,CAAC;EACnD;AACF;AACA;AACA;AACA;AACA;AAHAM,OAAA,CAAAT,aAAA,GAAAA,aAAA;AAIO,MAAMU,gBAAgB,SAASV,aAAa,CAAC;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B,gBAAA,GAAAA,gBAAA"}
@@ -1,7 +1,11 @@
1
+ // polyfill due to known bugs on URL implementation for react native
2
+ // https://github.com/facebook/react-native/issues/24428
3
+ import "react-native-url-polyfill/auto";
1
4
  import * as PID from "./pid";
2
5
  import * as RP from "./rp";
3
6
  import * as Errors from "./utils/errors";
4
7
  import * as WalletInstanceAttestation from "./wallet-instance-attestation";
5
8
  import { getUnsignedDPop } from "./utils/dpop";
6
- export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop };
9
+ import { RelyingPartySolution } from "./rp";
10
+ export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, RelyingPartySolution };
7
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","getUnsignedDPop"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAO,KAAKA,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASJ,GAAG,EAAEC,EAAE,EAAEE,yBAAyB,EAAED,MAAM,EAAEE,eAAe"}
1
+ {"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","getUnsignedDPop","RelyingPartySolution"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKA,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,SAASC,eAAe,QAAQ,cAAc;AAC9C,SAASC,oBAAoB,QAAQ,MAAM;AAE3C,SACEL,GAAG,EACHC,EAAE,EACFE,yBAAyB,EACzBD,MAAM,EACNE,eAAe,EACfC,oBAAoB"}
@@ -1,10 +1,11 @@
1
- import { decode as decodeJwt, sha256ToBase64 } from "@pagopa/io-react-native-jwt";
1
+ import { decode as decodeJwt, verify as verifyJwt, sha256ToBase64 } from "@pagopa/io-react-native-jwt";
2
2
  import { SignJWT, thumbprint } from "@pagopa/io-react-native-jwt";
3
3
  import { JWK } from "../utils/jwk";
4
4
  import uuid from "react-native-uuid";
5
- import { PidIssuingError } from "../utils/errors";
5
+ import { PidIssuingError, PidMetadataError } from "../utils/errors";
6
6
  import { getUnsignedDPop } from "../utils/dpop";
7
7
  import { sign, generate, deleteKey } from "@pagopa/io-react-native-crypto";
8
+ import { PidIssuerEntityConfiguration } from "./metadata";
8
9
 
9
10
  // This is a temporary type that will be used for demo purposes only
10
11
 
@@ -221,5 +222,32 @@ export class Issuing {
221
222
  }
222
223
  throw new PidIssuingError(`Unable to obtain credential!`);
223
224
  }
225
+
226
+ /**
227
+ * Obtain the PID issuer metadata
228
+ *
229
+ * @function
230
+ * @returns PID issuer metadata
231
+ *
232
+ */
233
+ async getEntityConfiguration() {
234
+ const metadataUrl = new URL(".well-known/openid-federation", this.pidProviderBaseUrl).href;
235
+ const response = await this.appFetch(metadataUrl);
236
+ if (response.status === 200) {
237
+ const jwtMetadata = await response.text();
238
+ const {
239
+ payload
240
+ } = decodeJwt(jwtMetadata);
241
+ const result = PidIssuerEntityConfiguration.safeParse(payload);
242
+ if (result.success) {
243
+ const parsedMetadata = result.data;
244
+ await verifyJwt(jwtMetadata, parsedMetadata.jwks.keys);
245
+ return parsedMetadata;
246
+ } else {
247
+ throw new PidMetadataError(result.error.message);
248
+ }
249
+ }
250
+ throw new PidMetadataError(`Unable to obtain PID metadata. Response: ${await response.text()} with status: ${response.status}`);
251
+ }
224
252
  }
225
253
  //# sourceMappingURL=issuing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["decode","decodeJwt","sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","getUnsignedDPop","sign","generate","deleteKey","Issuing","constructor","pidProviderBaseUrl","walletProviderBaseUrl","walletInstanceAttestation","clientId","appFetch","arguments","length","undefined","fetch","state","v4","codeVerifier","authorizationCode","getUnsignedJwtForPar","jwk","parsedJwk","parse","keyThumbprint","publicKey","kid","codeChallenge","unsignedJwtForPar","client_assertion_type","authorization_details","credentialDefinition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setProtectedHeader","alg","setIssuedAt","setExpirationTime","toSign","getPar","signature","signedJwtForPar","appendSignature","parUrl","URL","href","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","text","getUnsignedDPoP","tokenUrl","dPop","htm","htu","jti","getAuthToken","dPopKeyTag","dPopKey","unsignedDPopForToken","dPopTokenSignature","signedDPop","decodedJwtDPop","payload","grant_type","code","code_verifier","DPoP","getUnsignedNonceProof","nonce","unsignedProof","setAudience","setIssuer","getCredential","unsignedDPopForPid","dPopPidSignature","unsignedNonceProof","nonceProofSignature","accessToken","cieData","signedDPopForPid","signedNonceProof","credentialUrl","credential_definition","JSON","stringify","proof","jwt","proof_type","Authorization"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":"AAAA,SACEA,MAAM,IAAIC,SAAS,EACnBC,cAAc,QACT,6BAA6B;AAEpC,SAASC,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,gCAAgC;;AAE1E;;AAgBA,OAAO,MAAMC,OAAO,CAAC;EAUnBC,WAAWA,CACTC,kBAA0B,EAC1BC,qBAA6B,EAC7BC,yBAAiC,EACjCC,QAAgB,EAEhB;IAAA,IADAC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA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
1
+ {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","PidMetadataError","getUnsignedDPop","sign","generate","deleteKey","PidIssuerEntityConfiguration","Issuing","constructor","pidProviderBaseUrl","walletProviderBaseUrl","walletInstanceAttestation","clientId","appFetch","arguments","length","undefined","fetch","state","v4","codeVerifier","authorizationCode","getUnsignedJwtForPar","jwk","parsedJwk","parse","keyThumbprint","publicKey","kid","codeChallenge","unsignedJwtForPar","client_assertion_type","authorization_details","credentialDefinition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setProtectedHeader","alg","setIssuedAt","setExpirationTime","toSign","getPar","signature","signedJwtForPar","appendSignature","parUrl","URL","href","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","text","getUnsignedDPoP","tokenUrl","dPop","htm","htu","jti","getAuthToken","dPopKeyTag","dPopKey","unsignedDPopForToken","dPopTokenSignature","signedDPop","decodedJwtDPop","payload","grant_type","code","code_verifier","DPoP","getUnsignedNonceProof","nonce","unsignedProof","setAudience","setIssuer","getCredential","unsignedDPopForPid","dPopPidSignature","unsignedNonceProof","nonceProofSignature","accessToken","cieData","signedDPopForPid","signedNonceProof","credentialUrl","credential_definition","JSON","stringify","proof","jwt","proof_type","Authorization","getEntityConfiguration","metadataUrl","jwtMetadata","safeParse","success","parsedMetadata","data","jwks","keys","error","message"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":"AAAA,SACEA,MAAM,IAAIC,SAAS,EACnBC,MAAM,IAAIC,SAAS,EACnBC,cAAc,QACT,6BAA6B;AAEpC,SAASC,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,iBAAiB;AACnE,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,IAAI,EA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/jwk";
2
+ import { z } from "zod";
3
+ export const PidDisplayMetadata = z.object({
4
+ name: z.string(),
5
+ locale: z.string(),
6
+ logo: z.object({
7
+ url: z.string(),
8
+ alt_text: z.string()
9
+ }),
10
+ background_color: z.string(),
11
+ text_color: z.string()
12
+ });
13
+ export const PidIssuerEntityConfiguration = z.object({
14
+ jwks: z.object({
15
+ keys: z.array(JWK)
16
+ }),
17
+ metadata: z.object({
18
+ openid_credential_issuer: z.object({
19
+ credential_issuer: z.string(),
20
+ authorization_endpoint: z.string(),
21
+ token_endpoint: z.string(),
22
+ pushed_authorization_request_endpoint: z.string(),
23
+ dpop_signing_alg_values_supported: z.array(z.string()),
24
+ credential_endpoint: z.string(),
25
+ credentials_supported: z.object({
26
+ "eu.eudiw.pid.it": z.object({
27
+ format: z.literal("vc+sd-jwt"),
28
+ cryptographic_binding_methods_supported: z.array(z.string()),
29
+ cryptographic_suites_supported: z.array(z.string()),
30
+ display: z.array(PidDisplayMetadata)
31
+ })
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
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JWK","z","PidDisplayMetadata","object","name","string","locale","logo","url","alt_text","background_color","text_color","PidIssuerEntityConfiguration","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,GAAG,QAAQ,cAAc;AAClC,SAASC,CAAC,QAAQ,KAAK;AAGvB,OAAO,MAAMC,kBAAkB,GAAGD,C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