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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. package/README.md +98 -22
  2. package/lib/commonjs/index.js +12 -8
  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 +152 -169
  7. package/lib/commonjs/pid/issuing.js.map +1 -1
  8. package/lib/commonjs/pid/metadata.js +28 -25
  9. package/lib/commonjs/pid/metadata.js.map +1 -1
  10. package/lib/commonjs/rp/__test__/index.test.js +5 -3
  11. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  12. package/lib/commonjs/rp/index.js +158 -154
  13. package/lib/commonjs/rp/index.js.map +1 -1
  14. package/lib/commonjs/trust/types.js +9 -7
  15. package/lib/commonjs/trust/types.js.map +1 -1
  16. package/lib/commonjs/utils/crypto.js +46 -0
  17. package/lib/commonjs/utils/crypto.js.map +1 -0
  18. package/lib/commonjs/utils/dpop.js +14 -7
  19. package/lib/commonjs/utils/dpop.js.map +1 -1
  20. package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
  21. package/lib/commonjs/wallet-instance-attestation/issuing.js +50 -60
  22. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  23. package/lib/module/index.js +4 -3
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/pid/index.js +1 -1
  26. package/lib/module/pid/index.js.map +1 -1
  27. package/lib/module/pid/issuing.js +151 -172
  28. package/lib/module/pid/issuing.js.map +1 -1
  29. package/lib/module/pid/metadata.js +28 -25
  30. package/lib/module/pid/metadata.js.map +1 -1
  31. package/lib/module/rp/__test__/index.test.js +1 -1
  32. package/lib/module/rp/__test__/index.test.js.map +1 -1
  33. package/lib/module/rp/index.js +155 -153
  34. package/lib/module/rp/index.js.map +1 -1
  35. package/lib/module/trust/types.js +7 -6
  36. package/lib/module/trust/types.js.map +1 -1
  37. package/lib/module/utils/crypto.js +40 -0
  38. package/lib/module/utils/crypto.js.map +1 -0
  39. package/lib/module/utils/dpop.js +13 -5
  40. package/lib/module/utils/dpop.js.map +1 -1
  41. package/lib/module/wallet-instance-attestation/index.js +2 -2
  42. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  43. package/lib/module/wallet-instance-attestation/issuing.js +48 -58
  44. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  45. package/lib/typescript/index.d.ts +4 -3
  46. package/lib/typescript/index.d.ts.map +1 -1
  47. package/lib/typescript/pid/index.d.ts +1 -1
  48. package/lib/typescript/pid/index.d.ts.map +1 -1
  49. package/lib/typescript/pid/issuing.d.ts +51 -87
  50. package/lib/typescript/pid/issuing.d.ts.map +1 -1
  51. package/lib/typescript/pid/metadata.d.ts +1338 -408
  52. package/lib/typescript/pid/metadata.d.ts.map +1 -1
  53. package/lib/typescript/rp/index.d.ts +48 -86
  54. package/lib/typescript/rp/index.d.ts.map +1 -1
  55. package/lib/typescript/rp/types.d.ts +413 -57
  56. package/lib/typescript/rp/types.d.ts.map +1 -1
  57. package/lib/typescript/sd-jwt/index.d.ts +1 -1
  58. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  59. package/lib/typescript/trust/types.d.ts +1000 -274
  60. package/lib/typescript/trust/types.d.ts.map +1 -1
  61. package/lib/typescript/utils/crypto.d.ts +10 -0
  62. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  63. package/lib/typescript/utils/dpop.d.ts +10 -2
  64. package/lib/typescript/utils/dpop.d.ts.map +1 -1
  65. package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
  66. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  67. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -31
  68. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  69. package/package.json +2 -2
  70. package/src/index.ts +5 -3
  71. package/src/pid/index.ts +1 -1
  72. package/src/pid/issuing.ts +233 -226
  73. package/src/pid/metadata.ts +32 -27
  74. package/src/rp/__test__/index.test.ts +1 -1
  75. package/src/rp/index.ts +180 -188
  76. package/src/sd-jwt/index.ts +1 -1
  77. package/src/trust/types.ts +39 -32
  78. package/src/utils/crypto.ts +41 -0
  79. package/src/utils/dpop.ts +17 -7
  80. package/src/wallet-instance-attestation/index.ts +2 -2
  81. package/src/wallet-instance-attestation/issuing.ts +55 -62
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/pid/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS7B,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,4BAA4B,CACpC,CAAC;AACF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BvC,CAAC"}
1
+ {"version":3,"file":"metadata.d.ts","sourceR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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BxC,CAAC"}
@@ -1,89 +1,51 @@
1
+ /// <reference types="react-native" />
2
+ import { type CryptoContext } from "@pagopa/io-react-native-jwt";
1
3
  import { QRCodePayload, RequestObject, RpEntityConfiguration, type Presentation } from "./types";
2
- export declare class RelyingPartySolution {
3
- relyingPartyBaseUrl: string;
4
+ /**
5
+ * Obtain the relying party entity configuration.
6
+ */
7
+ export declare const getEntityConfiguration: ({ appFetch }?: {
8
+ appFetch?: {
9
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
10
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
11
+ } | undefined;
12
+ }) => (relyingPartyBaseUrl: string) => Promise<RpEntityConfiguration>;
13
+ /**
14
+ * Decode a QR code content to an authentication request url.
15
+ * @function
16
+ * @param qrcode QR code content
17
+ *
18
+ * @returns The authentication request url
19
+ *
20
+ */
21
+ export declare const decodeAuthRequestQR: (qrcode: string) => QRCodePayload;
22
+ export type RequestObjectConf = {
23
+ requestObject: RequestObject;
24
+ rpEntityConfiguration: RpEntityConfiguration;
4
25
  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
- }
26
+ };
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
+ export declare const getRequestObject: ({ wiaCryptoContext, appFetch, }: {
32
+ wiaCryptoContext: CryptoContext;
33
+ appFetch?: {
34
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
35
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
36
+ } | undefined;
37
+ }) => (walletInstanceAttestation: string, requestUri: string, rpEntityConfiguration: RpEntityConfiguration) => Promise<RequestObjectConf>;
38
+ /**
39
+ * Compose and send an Authorization Response in the context of an authorization request flow.
40
+ *
41
+ * @todo MUST add presentation_submission
42
+ *
43
+ */
44
+ export declare const sendAuthorizationResponse: ({ pidCryptoContext, appFetch, }: {
45
+ pidCryptoContext: CryptoContext;
46
+ appFetch?: {
47
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
48
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
49
+ } | undefined;
50
+ }) => ({ requestObject, rpEntityConfiguration, walletInstanceAttestation, }: RequestObjectConf, presentation: Presentation) => Promise<string>;
89
51
  //# 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,EA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