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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/README.md +128 -19
  2. package/lib/commonjs/index.js +16 -23
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/pid/index.js +3 -8
  5. package/lib/commonjs/pid/index.js.map +1 -1
  6. package/lib/commonjs/pid/issuing.js +153 -176
  7. package/lib/commonjs/pid/issuing.js.map +1 -1
  8. package/lib/commonjs/rp/__test__/index.test.js +7 -5
  9. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  10. package/lib/commonjs/rp/index.js +145 -155
  11. package/lib/commonjs/rp/index.js.map +1 -1
  12. package/lib/commonjs/rp/types.js +1 -21
  13. package/lib/commonjs/rp/types.js.map +1 -1
  14. package/lib/commonjs/trust/index.js +24 -5
  15. package/lib/commonjs/trust/index.js.map +1 -1
  16. package/lib/commonjs/trust/types.js +102 -9
  17. package/lib/commonjs/trust/types.js.map +1 -1
  18. package/lib/commonjs/utils/crypto.js +46 -0
  19. package/lib/commonjs/utils/crypto.js.map +1 -0
  20. package/lib/commonjs/utils/dpop.js +14 -7
  21. package/lib/commonjs/utils/dpop.js.map +1 -1
  22. package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
  23. package/lib/commonjs/wallet-instance-attestation/issuing.js +42 -60
  24. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  25. package/lib/module/index.js +4 -6
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/pid/index.js +1 -1
  28. package/lib/module/pid/index.js.map +1 -1
  29. package/lib/module/pid/issuing.js +152 -180
  30. package/lib/module/pid/issuing.js.map +1 -1
  31. package/lib/module/rp/__test__/index.test.js +3 -3
  32. package/lib/module/rp/__test__/index.test.js.map +1 -1
  33. package/lib/module/rp/index.js +141 -154
  34. package/lib/module/rp/index.js.map +1 -1
  35. package/lib/module/rp/types.js +0 -20
  36. package/lib/module/rp/types.js.map +1 -1
  37. package/lib/module/trust/index.js +19 -5
  38. package/lib/module/trust/index.js.map +1 -1
  39. package/lib/module/trust/types.js +100 -7
  40. package/lib/module/trust/types.js.map +1 -1
  41. package/lib/module/utils/crypto.js +40 -0
  42. package/lib/module/utils/crypto.js.map +1 -0
  43. package/lib/module/utils/dpop.js +13 -5
  44. package/lib/module/utils/dpop.js.map +1 -1
  45. package/lib/module/wallet-instance-attestation/index.js +2 -2
  46. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  47. package/lib/module/wallet-instance-attestation/issuing.js +40 -58
  48. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  49. package/lib/typescript/index.d.ts +4 -6
  50. package/lib/typescript/index.d.ts.map +1 -1
  51. package/lib/typescript/pid/index.d.ts +1 -1
  52. package/lib/typescript/pid/index.d.ts.map +1 -1
  53. package/lib/typescript/pid/issuing.d.ts +43 -88
  54. package/lib/typescript/pid/issuing.d.ts.map +1 -1
  55. package/lib/typescript/rp/index.d.ts +41 -87
  56. package/lib/typescript/rp/index.d.ts.map +1 -1
  57. package/lib/typescript/rp/types.d.ts +10 -906
  58. package/lib/typescript/rp/types.d.ts.map +1 -1
  59. package/lib/typescript/sd-jwt/index.d.ts +1 -1
  60. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  61. package/lib/typescript/trust/index.d.ts +806 -3
  62. package/lib/typescript/trust/index.d.ts.map +1 -1
  63. package/lib/typescript/trust/types.d.ts +9655 -297
  64. package/lib/typescript/trust/types.d.ts.map +1 -1
  65. package/lib/typescript/utils/crypto.d.ts +10 -0
  66. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  67. package/lib/typescript/utils/dpop.d.ts +10 -2
  68. package/lib/typescript/utils/dpop.d.ts.map +1 -1
  69. package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
  70. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  71. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +18 -31
  72. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  73. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  74. package/package.json +2 -2
  75. package/src/index.ts +14 -13
  76. package/src/pid/index.ts +1 -1
  77. package/src/pid/issuing.ts +233 -232
  78. package/src/rp/__test__/index.test.ts +3 -3
  79. package/src/rp/index.ts +172 -194
  80. package/src/rp/types.ts +0 -24
  81. package/src/sd-jwt/index.ts +1 -1
  82. package/src/trust/index.ts +106 -5
  83. package/src/trust/types.ts +152 -34
  84. package/src/utils/crypto.ts +41 -0
  85. package/src/utils/dpop.ts +17 -7
  86. package/src/wallet-instance-attestation/index.ts +2 -2
  87. package/src/wallet-instance-attestation/issuing.ts +51 -63
  88. package/lib/commonjs/pid/metadata.js +0 -49
  89. package/lib/commonjs/pid/metadata.js.map +0 -1
  90. package/lib/module/pid/metadata.js +0 -41
  91. package/lib/module/pid/metadata.js.map +0 -1
  92. package/lib/typescript/pid/metadata.d.ts +0 -482
  93. package/lib/typescript/pid/metadata.d.ts.map +0 -1
  94. package/src/pid/metadata.ts +0 -46
@@ -1,89 +1,43 @@
1
- import { QRCodePayload, RequestObject, RpEntityConfiguration, type Presentation } from "./types";
2
- export declare class RelyingPartySolution {
3
- relyingPartyBaseUrl: string;
1
+ /// <reference types="react-native" />
2
+ import { type CryptoContext } from "@pagopa/io-react-native-jwt";
3
+ import { QRCodePayload, RequestObject, type Presentation } from "./types";
4
+ import { RelyingPartyEntityConfiguration } from "../trust/types";
5
+ /**
6
+ * Decode a QR code content to an authentication request url.
7
+ * @function
8
+ * @param qrcode QR code content
9
+ *
10
+ * @returns The authentication request url
11
+ *
12
+ */
13
+ export declare const decodeAuthRequestQR: (qrcode: string) => QRCodePayload;
14
+ export type RequestObjectConf = {
15
+ requestObject: RequestObject;
16
+ rpEntityConfiguration: RelyingPartyEntityConfiguration;
4
17
  walletInstanceAttestation: string;
5
- appFetch: GlobalFetch["fetch"];
6
- constructor(relyingPartyBaseUrl: string, walletInstanceAttestation: string, appFetch?: GlobalFetch["fetch"]);
7
- /**
8
- * Decode a QR code content to an authentication request url.
9
- * @function
10
- * @param qrcode QR code content
11
- *
12
- * @returns The authentication request url
13
- *
14
- */
15
- static decodeAuthRequestQR(qrcode: string): QRCodePayload;
16
- /**
17
- * Obtain the unsigned wallet instance DPoP for authentication request
18
- *
19
- * @function
20
- * @param walletInstanceAttestationJwk JWT of the Wallet Instance Attestation
21
- * @param authRequestUrl authentication request url
22
- *
23
- * @returns The unsigned wallet instance DPoP
24
- *
25
- */
26
- getUnsignedWalletInstanceDPoP(walletInstanceAttestationJwk: any, authRequestUrl: string): Promise<string>;
27
- /**
28
- * Obtain the Request Object for RP authentication
29
- * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
30
- *
31
- * @async @function
32
- * @param signedWalletInstanceDPoP JWT of the Wallet Instance Attestation DPoP
33
- *
34
- * @returns The Request Object JWT
35
- * @throws {NoSuitableKeysFoundInEntityConfiguration} When the Request Object is signed with a key not listed in RP's entity configuration
36
- *
37
- */
38
- getRequestObject(signedWalletInstanceDPoP: string, requestUri: string, entity: RpEntityConfiguration): Promise<RequestObject>;
39
- /**
40
- * Prepare the Verified Presentation token for a received request object in the context of an authorization request flow.
41
- * The presentation is prepared by disclosing data from provided credentials, according to requested claims
42
- * Each Verified Credential come along with the claims the user accepts to disclose from it.
43
- *
44
- * The returned token is unsigned (sign should be apply by the caller).
45
- *
46
- * @todo accept more than a Verified Credential
47
- *
48
- * @param requestObj The incoming request object, which the requirements for the requested authorization
49
- * @param walletInstanceIdentifier The identifies of the wallt instance that is presenting
50
- * @param presentation The Verified Credential containing user data along with the list of claims to be disclosed.
51
- * @param signKeyId The kid of the key that will be used to sign
52
- * @returns The unsigned Verified Presentation token
53
- * @throws {ClaimsNotFoundBetweenDislosures} If the Verified Credential does not contain one or more requested claims.
54
- *
55
- */
56
- prepareVpToken(requestObj: RequestObject, walletInstanceIdentifier: string, [vc, claims]: Presentation, // TODO: [SIW-353] support multiple presentations,
57
- signKeyId: string): Promise<{
58
- vp_token: string;
59
- presentation_submission: Record<string, unknown>;
60
- }>;
61
- /**
62
- * Compose and send an Authorization Response in the context of an authorization request flow.
63
- *
64
- * @todo MUST add presentation_submission
65
- *
66
- * @param requestObj The incoming request object, which the requirements for the requested authorization
67
- * @param vp_token The signed Verified Presentation token with data to send.
68
- * @param presentation_submission
69
- * @param entity The RP entity configuration
70
- * @returns The response from the RP
71
- * @throws {IoWalletError} if the submission fails.
72
- * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key
73
- *
74
- */
75
- sendAuthorizationResponse(requestObj: RequestObject, vp_token: string, presentation_submission: Record<string, unknown>, entity: RpEntityConfiguration): Promise<string>;
76
- /**
77
- * Select a RSA public key from those provided by the RP to encrypt.
78
- *
79
- * @param entity The RP entity configuration
80
- * @returns A suitable public key with its compatible encryption algorithm
81
- * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
82
- */
83
- private chooseRSAPublicKeyToEncrypt;
84
- /**
85
- * Obtain the relying party entity configuration.
86
- */
87
- getEntityConfiguration(): Promise<RpEntityConfiguration>;
88
- }
18
+ };
19
+ /**
20
+ * Obtain the Request Object for RP authentication
21
+ * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
22
+ */
23
+ export declare const getRequestObject: ({ wiaCryptoContext, appFetch, }: {
24
+ wiaCryptoContext: CryptoContext;
25
+ appFetch?: {
26
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
27
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
28
+ } | undefined;
29
+ }) => (walletInstanceAttestation: string, requestUri: string, rpEntityConfiguration: RelyingPartyEntityConfiguration) => Promise<RequestObjectConf>;
30
+ /**
31
+ * Compose and send an Authorization Response in the context of an authorization request flow.
32
+ *
33
+ * @todo MUST add presentation_submission
34
+ *
35
+ */
36
+ export declare const sendAuthorizationResponse: ({ pidCryptoContext, appFetch, }: {
37
+ pidCryptoContext: CryptoContext;
38
+ appFetch?: {
39
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
40
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
41
+ } | undefined;
42
+ }) => ({ requestObject, rpEntityConfiguration, walletInstanceAttestation, }: RequestObjectConf, presentation: Presentation) => Promise<string>;
89
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rp/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AAOjB,qBAAa,oBAAoB;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;gBAG7B,mBAAmB,EAAE,MAAM,EAC3B,yBAAyB,EAAE,MAAM,EACjC,QAAQ,GAAE,WAAW,CAAC,OAAO,CAAS;IAOxC;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAqBzD;;;;;;;;;OASG;IACG,6BAA6B,CACjC,4BAA4B,EAAE,GAAG,EACjC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,wBAAwB,EAAE,MAAM,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,aAAa,CAAC;IA2CzB;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAClB,UAAU,EAAE,aAAa,EACzB,wBAAwB,EAAE,MAAM,EAChC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,kDAAkD;IAC9E,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,uBAAuB,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