@pagopa/io-react-native-wallet 2.0.0-next.3 → 2.0.0-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +75 -57
  2. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  4. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
  5. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/README.md +45 -34
  7. package/lib/commonjs/credential/issuance/types.js +1 -0
  8. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  9. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +6 -13
  10. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  11. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +7 -8
  12. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  13. package/lib/commonjs/credential/presentation/types.js +1 -1
  14. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  15. package/lib/commonjs/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
  16. package/lib/commonjs/credential/status/02-status-assertion.js.map +1 -0
  17. package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js +85 -0
  18. package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
  19. package/lib/commonjs/credential/status/README.md +22 -20
  20. package/lib/commonjs/credential/status/index.js +6 -6
  21. package/lib/commonjs/credential/status/index.js.map +1 -1
  22. package/lib/commonjs/credential/status/types.js +48 -15
  23. package/lib/commonjs/credential/status/types.js.map +1 -1
  24. package/lib/commonjs/sd-jwt/index.js +6 -1
  25. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  26. package/lib/commonjs/sd-jwt/types.js +25 -9
  27. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  28. package/lib/commonjs/utils/credentials.js +33 -0
  29. package/lib/commonjs/utils/credentials.js.map +1 -0
  30. package/lib/commonjs/utils/crypto.js +1 -7
  31. package/lib/commonjs/utils/crypto.js.map +1 -1
  32. package/lib/commonjs/utils/jwk.js +12 -0
  33. package/lib/commonjs/utils/jwk.js.map +1 -1
  34. package/lib/commonjs/wallet-instance-attestation/types.js +1 -2
  35. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  36. package/lib/module/credential/issuance/04-complete-user-authorization.js +76 -58
  37. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  38. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  39. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +4 -4
  40. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  41. package/lib/module/credential/issuance/README.md +45 -34
  42. package/lib/module/credential/issuance/types.js +1 -0
  43. package/lib/module/credential/issuance/types.js.map +1 -1
  44. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +6 -13
  45. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  46. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +7 -8
  47. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  48. package/lib/module/credential/presentation/types.js +1 -1
  49. package/lib/module/credential/presentation/types.js.map +1 -1
  50. package/lib/module/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
  51. package/lib/module/credential/status/02-status-assertion.js.map +1 -0
  52. package/lib/module/credential/status/03-verify-and-parse-status-assertion.js +78 -0
  53. package/lib/module/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
  54. package/lib/module/credential/status/README.md +22 -20
  55. package/lib/module/credential/status/index.js +3 -3
  56. package/lib/module/credential/status/index.js.map +1 -1
  57. package/lib/module/credential/status/types.js +43 -12
  58. package/lib/module/credential/status/types.js.map +1 -1
  59. package/lib/module/sd-jwt/index.js +6 -1
  60. package/lib/module/sd-jwt/index.js.map +1 -1
  61. package/lib/module/sd-jwt/types.js +25 -9
  62. package/lib/module/sd-jwt/types.js.map +1 -1
  63. package/lib/module/utils/credentials.js +26 -0
  64. package/lib/module/utils/credentials.js.map +1 -0
  65. package/lib/module/utils/crypto.js +2 -8
  66. package/lib/module/utils/crypto.js.map +1 -1
  67. package/lib/module/utils/jwk.js +11 -1
  68. package/lib/module/utils/jwk.js.map +1 -1
  69. package/lib/module/wallet-instance-attestation/types.js +1 -2
  70. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  71. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +7 -14
  72. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  73. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  74. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  75. package/lib/typescript/credential/issuance/types.d.ts +3 -0
  76. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  77. package/lib/typescript/credential/presentation/01-start-flow.d.ts +2 -2
  78. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +4 -3
  79. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  80. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +9 -5
  81. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  82. package/lib/typescript/credential/presentation/types.d.ts +3 -4
  83. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  84. package/lib/typescript/credential/status/02-status-assertion.d.ts +23 -0
  85. package/lib/typescript/credential/status/02-status-assertion.d.ts.map +1 -0
  86. package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts +21 -0
  87. package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts.map +1 -0
  88. package/lib/typescript/credential/status/index.d.ts +4 -4
  89. package/lib/typescript/credential/status/index.d.ts.map +1 -1
  90. package/lib/typescript/credential/status/types.d.ts +499 -22
  91. package/lib/typescript/credential/status/types.d.ts.map +1 -1
  92. package/lib/typescript/sd-jwt/index.d.ts +68 -40
  93. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  94. package/lib/typescript/sd-jwt/types.d.ts +97 -46
  95. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  96. package/lib/typescript/utils/credentials.d.ts +11 -0
  97. package/lib/typescript/utils/credentials.d.ts.map +1 -0
  98. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  99. package/lib/typescript/utils/jwk.d.ts +7 -0
  100. package/lib/typescript/utils/jwk.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/src/credential/issuance/04-complete-user-authorization.ts +79 -85
  103. package/src/credential/issuance/06-obtain-credential.ts +4 -1
  104. package/src/credential/issuance/07-verify-and-parse-credential.ts +4 -6
  105. package/src/credential/issuance/README.md +45 -34
  106. package/src/credential/issuance/types.ts +1 -0
  107. package/src/credential/presentation/07-evaluate-dcql-query.ts +16 -17
  108. package/src/credential/presentation/07-evaluate-input-descriptor.ts +16 -13
  109. package/src/credential/presentation/types.ts +1 -2
  110. package/src/credential/status/{02-status-attestation.ts → 02-status-assertion.ts} +37 -28
  111. package/src/credential/status/03-verify-and-parse-status-assertion.ts +109 -0
  112. package/src/credential/status/README.md +22 -20
  113. package/src/credential/status/index.ts +7 -14
  114. package/src/credential/status/types.ts +62 -15
  115. package/src/sd-jwt/index.ts +5 -1
  116. package/src/sd-jwt/types.ts +24 -10
  117. package/src/utils/credentials.ts +29 -0
  118. package/src/utils/crypto.ts +12 -20
  119. package/src/utils/jwk.ts +15 -1
  120. package/src/wallet-instance-attestation/types.ts +1 -1
  121. package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
  122. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -55
  123. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  124. package/lib/module/credential/status/02-status-attestation.js.map +0 -1
  125. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -49
  126. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  127. package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
  128. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
  129. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
  130. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
  131. package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -70
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.verifyAndParseStatusAttestation = void 0;
7
- var _errors = require("../../utils/errors");
8
- var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
- var _types = require("./types");
10
- var _logging = require("../../utils/logging");
11
- /**
12
- * Given a status attestation, verifies that:
13
- * - It's in the supported format;
14
- * - The attestation is correctly signed;
15
- * - It's bound to the given key.
16
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
17
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
18
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
19
- * @returns A parsed status attestation
20
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
21
- * @throws {IoWalletError} If the credential is not bound to the provided user key
22
- * @throws {IoWalletError} If the credential data fail to parse
23
- */
24
- const verifyAndParseStatusAttestation = async (issuerConf, rawStatusAttestation, context) => {
25
- try {
26
- const {
27
- statusAttestation
28
- } = rawStatusAttestation;
29
- const {
30
- credentialCryptoContext
31
- } = context;
32
- await (0, _ioReactNativeJwt.verify)(statusAttestation, issuerConf.openid_credential_issuer.jwks.keys);
33
- const decodedJwt = (0, _ioReactNativeJwt.decode)(statusAttestation);
34
- const parsedStatusAttestation = _types.ParsedStatusAttestation.parse({
35
- header: decodedJwt.protectedHeader,
36
- payload: decodedJwt.payload
37
- });
38
- _logging.Logger.log(_logging.LogLevel.DEBUG, `Parsed status attestation: ${JSON.stringify(parsedStatusAttestation)}`);
39
- const holderBindingKey = await credentialCryptoContext.getPublicKey();
40
- const {
41
- cnf
42
- } = parsedStatusAttestation.payload;
43
- if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
44
- _logging.Logger.log(_logging.LogLevel.ERROR, `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
45
- throw new _errors.IoWalletError(`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
46
- }
47
- return {
48
- parsedStatusAttestation
49
- };
50
- } catch (e) {
51
- throw new _errors.IoWalletError(`Failed to verify status attestation: ${JSON.stringify(e)}`);
52
- }
53
- };
54
- exports.verifyAndParseStatusAttestation = verifyAndParseStatusAttestation;
55
- //# sourceMappingURL=03-verify-and-parse-status-attestation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_logging","verifyAndParseStatusAttestation","issuerConf","rawStatusAttestation","context","statusAttestation","credentialCryptoContext","verify","openid_credential_issuer","jwks","keys","decodedJwt","decodeJwt","parsedStatusAttestation","ParsedStatusAttestation","parse","header","protectedHeader","payload","Logger","log","LogLevel","DEBUG","JSON","stringify","holderBindingKey","getPublicKey","cnf","jwk","kid","ERROR","IoWalletError","e","exports"],"sourceRoot":"../../../../src","sources":["credential/status/03-verify-and-parse-status-attestation.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,+BAAgE,GAC3E,MAAAA,CAAOC,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AuCR,IAAI,CAACC,SAAS,CAACQ,CAAC,CAAE,EAC5D,CAAC;EACH;AACF,CAAC;AAACC,OAAA,CAAAhC,+BAAA,GAAAA,+BAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["getCredentialHashWithouDiscloures","hasStatusOrThrow","SignJWT","v4","uuidv4","StatusAttestationResponse","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","LogLevel","Logger","statusAttestation","issuerConf","credential","credentialCryptoContext","appFetch","arguments","length","undefined","fetch","jwk","getPublicKey","credentialHash","statusAttUrl","openid_credential_issuer","status_attestation_endpoint","credentialPop","setPayload","aud","jti","toString","credential_hash","credential_hash_alg","setProtectedHeader","alg","typ","kid","setIssuedAt","setExpirationTime","sign","body","credential_pop","log","DEBUG","result","method","headers","JSON","stringify","then","raw","json","parse","catch","handleStatusAttestationError","status_attestation","e","handle","code","CredentialInvalidStatus","message","StatusAttestationRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/status/02-status-attestation.ts"],"mappings":"AAAA,SACEA,iCAAiC,EACjCC,gBAAgB,QAEX,kBAAkB;AAEzB,SAA6BC,OAAO,QAAQ,6BAA6B;AACzE,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,QACpB,oBAAoB;AAC3B,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAWtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAoC,GAAG,eAAAA,CAClDC,UAAU,EACVC,UAAU,EACVC,uBAAuB,EAEpB;EAAA,IADHC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,KAAK;EAEtC,MAAMC,GAAG,GAAG,MAAMN,uBAAuB,CA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ACW;EAAmB,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMD,4BAA4B,GAAIE,CAAU,IAAK;EACnD,IAAI,EAAEA,CAAC,YAAYhD,yBAAyB,CAAC,EAAE;IAC7C,MAAMgD,CAAC;EACT;EAEA,MAAM,IAAIjD,oBAAoB,CAACF,mBAAmB,CAAC,CAChDoD,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpD,wBAAwB,CAACqD,uBAAuB;IACtDC,OAAO,EAAE;EACX,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpD,wBAAwB,CAACuD,8BAA8B;IAC7DD,OAAO,EAAG;EACZ,CAAC,CAAC,CACDE,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
@@ -1,49 +0,0 @@
1
- import { IoWalletError } from "../../utils/errors";
2
- import { verify } from "@pagopa/io-react-native-jwt";
3
- import { ParsedStatusAttestation } from "./types";
4
- import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
5
- import { LogLevel, Logger } from "../../utils/logging";
6
- /**
7
- * Given a status attestation, verifies that:
8
- * - It's in the supported format;
9
- * - The attestation is correctly signed;
10
- * - It's bound to the given key.
11
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
12
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
13
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
14
- * @returns A parsed status attestation
15
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
16
- * @throws {IoWalletError} If the credential is not bound to the provided user key
17
- * @throws {IoWalletError} If the credential data fail to parse
18
- */
19
- export const verifyAndParseStatusAttestation = async (issuerConf, rawStatusAttestation, context) => {
20
- try {
21
- const {
22
- statusAttestation
23
- } = rawStatusAttestation;
24
- const {
25
- credentialCryptoContext
26
- } = context;
27
- await verify(statusAttestation, issuerConf.openid_credential_issuer.jwks.keys);
28
- const decodedJwt = decodeJwt(statusAttestation);
29
- const parsedStatusAttestation = ParsedStatusAttestation.parse({
30
- header: decodedJwt.protectedHeader,
31
- payload: decodedJwt.payload
32
- });
33
- Logger.log(LogLevel.DEBUG, `Parsed status attestation: ${JSON.stringify(parsedStatusAttestation)}`);
34
- const holderBindingKey = await credentialCryptoContext.getPublicKey();
35
- const {
36
- cnf
37
- } = parsedStatusAttestation.payload;
38
- if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
39
- Logger.log(LogLevel.ERROR, `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
40
- throw new IoWalletError(`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
41
- }
42
- return {
43
- parsedStatusAttestation
44
- };
45
- } catch (e) {
46
- throw new IoWalletError(`Failed to verify status attestation: ${JSON.stringify(e)}`);
47
- }
48
- };
49
- //# sourceMappingURL=03-verify-and-parse-status-attestation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IoWalletError","verify","ParsedStatusAttestation","decode","decodeJwt","LogLevel","Logger","verifyAndParseStatusAttestation","issuerConf","rawStatusAttestation","context","statusAttestation","credentialCryptoContext","openid_credential_issuer","jwks","keys","decodedJwt","parsedStatusAttestation","parse","header","protectedHeader","payload","log","DEBUG","JSON","stringify","holderBindingKey","getPublicKey","cnf","jwk","kid","ERROR","e"],"sourceRoot":"../../../../src","sources":["credential/status/03-verify-and-parse-status-attestation.ts"],"mappings":"AACA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,MAAM,QAA4B,6BAA6B;AAExE,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAUtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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ACV,MAAM,IAAIhC,aAAa,CACpB,wCAAuCwB,IAAI,CAACC,SAAS,CAACO,CAAC,CAAE,EAC5D,CAAC;EACH;AACF,CAAC"}
@@ -1,19 +0,0 @@
1
- import { type Out } from "../../utils/misc";
2
- import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance";
3
- import { type CryptoContext } from "@pagopa/io-react-native-jwt";
4
- import { StatusAttestationResponse } from "./types";
5
- export type StatusAttestation = (issuerConf: Out<EvaluateIssuerTrust>["issuerConf"], credential: Out<ObtainCredential>["credential"], credentialCryptoContext: CryptoContext, appFetch?: GlobalFetch["fetch"]) => Promise<{
6
- statusAttestation: StatusAttestationResponse["status_attestation"];
7
- }>;
8
- /**
9
- * WARNING: This function must be called after {@link startFlow}.
10
- * Verify the status of the credential attestation.
11
- * @param issuerConf - The issuer's configuration
12
- * @param credential - The credential to be verified
13
- * @param credentialCryptoContext - The credential's crypto context
14
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
15
- * @throws {IssuerResponseError} with a specific code for more context
16
- * @returns The credential status attestation
17
- */
18
- export declare const statusAttestation: StatusAttestation;
19
- //# sourceMappingURL=02-status-attestation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"02-status-attestation.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/02-status-attestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AASpD,MAAM,MAAM,iBAAiB,GAAG,CAC9B,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAClD,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,uBAAuB,EAAE,aAAa,EACtC,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,KAC5B,OAAO,CAAC;IACX,iBAAiB,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;CACpE,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBA6C/B,CAAC"}
@@ -1,24 +0,0 @@
1
- import type { Out } from "../../utils/misc";
2
- import { type CryptoContext } from "@pagopa/io-react-native-jwt";
3
- import type { EvaluateIssuerTrust, StatusAttestation } from "../status";
4
- import { ParsedStatusAttestation } from "./types";
5
- export type VerifyAndParseStatusAttestation = (issuerConf: Out<EvaluateIssuerTrust>["issuerConf"], statusAttestation: Out<StatusAttestation>, context: {
6
- credentialCryptoContext: CryptoContext;
7
- }) => Promise<{
8
- parsedStatusAttestation: ParsedStatusAttestation;
9
- }>;
10
- /**
11
- * Given a status attestation, verifies that:
12
- * - It's in the supported format;
13
- * - The attestation is correctly signed;
14
- * - It's bound to the given key.
15
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
16
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
17
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
18
- * @returns A parsed status attestation
19
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
20
- * @throws {IoWalletError} If the credential is not bound to the provided user key
21
- * @throws {IoWalletError} If the credential data fail to parse
22
- */
23
- export declare const verifyAndParseStatusAttestation: VerifyAndParseStatusAttestation;
24
- //# sourceMappingURL=03-verify-and-parse-status-attestation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"03-verify-and-parse-status-attestation.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/03-verify-and-parse-status-attestation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIlD,MAAM,MAAM,+BAA+B,GAAG,CAC5C,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAClD,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,CAAC,EACzC,OAAO,EAAE;IACP,uBAAuB,EAAE,aAAa,CAAC;CACxC,KACE,OAAO,CAAC;IAAE,uBAAuB,EAAE,uBAAuB,CAAA;CAAE,CAAC,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,+BAA+B,EAAE,+BAwC3C,CAAC"}
@@ -1,70 +0,0 @@
1
- import type { Out } from "../../utils/misc";
2
- import { IoWalletError } from "../../utils/errors";
3
- import { verify, type CryptoContext } from "@pagopa/io-react-native-jwt";
4
- import type { EvaluateIssuerTrust, StatusAttestation } from "../status";
5
- import { ParsedStatusAttestation } from "./types";
6
- import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
7
- import { LogLevel, Logger } from "../../utils/logging";
8
-
9
- export type VerifyAndParseStatusAttestation = (
10
- issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
11
- statusAttestation: Out<StatusAttestation>,
12
- context: {
13
- credentialCryptoContext: CryptoContext;
14
- }
15
- ) => Promise<{ parsedStatusAttestation: ParsedStatusAttestation }>;
16
-
17
- /**
18
- * Given a status attestation, verifies that:
19
- * - It's in the supported format;
20
- * - The attestation is correctly signed;
21
- * - It's bound to the given key.
22
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
23
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
24
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
25
- * @returns A parsed status attestation
26
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
27
- * @throws {IoWalletError} If the credential is not bound to the provided user key
28
- * @throws {IoWalletError} If the credential data fail to parse
29
- */
30
- export const verifyAndParseStatusAttestation: VerifyAndParseStatusAttestation =
31
- async (issuerConf, rawStatusAttestation, context) => {
32
- try {
33
- const { statusAttestation } = rawStatusAttestation;
34
- const { credentialCryptoContext } = context;
35
-
36
- await verify(
37
- statusAttestation,
38
- issuerConf.openid_credential_issuer.jwks.keys
39
- );
40
-
41
- const decodedJwt = decodeJwt(statusAttestation);
42
- const parsedStatusAttestation = ParsedStatusAttestation.parse({
43
- header: decodedJwt.protectedHeader,
44
- payload: decodedJwt.payload,
45
- });
46
-
47
- Logger.log(
48
- LogLevel.DEBUG,
49
- `Parsed status attestation: ${JSON.stringify(parsedStatusAttestation)}`
50
- );
51
-
52
- const holderBindingKey = await credentialCryptoContext.getPublicKey();
53
- const { cnf } = parsedStatusAttestation.payload;
54
- if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
55
- Logger.log(
56
- LogLevel.ERROR,
57
- `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`
58
- );
59
- throw new IoWalletError(
60
- `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`
61
- );
62
- }
63
-
64
- return { parsedStatusAttestation };
65
- } catch (e) {
66
- throw new IoWalletError(
67
- `Failed to verify status attestation: ${JSON.stringify(e)}`
68
- );
69
- }
70
- };