@pagopa/io-react-native-wallet 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/index.js +12 -5
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/pid/index.js +7 -0
  5. package/lib/commonjs/pid/index.js.map +1 -1
  6. package/lib/commonjs/pid/issuing.js +231 -0
  7. package/lib/commonjs/pid/issuing.js.map +1 -0
  8. package/lib/commonjs/rp/__test__/index.test.js +18 -0
  9. package/lib/commonjs/rp/__test__/index.test.js.map +1 -0
  10. package/lib/commonjs/rp/index.js +116 -0
  11. package/lib/commonjs/rp/index.js.map +1 -0
  12. package/lib/commonjs/rp/types.js +72 -0
  13. package/lib/commonjs/rp/types.js.map +1 -0
  14. package/lib/commonjs/sd-jwt/types.js +1 -1
  15. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  16. package/lib/commonjs/utils/dpop.js +27 -0
  17. package/lib/commonjs/utils/dpop.js.map +1 -0
  18. package/lib/commonjs/utils/errors.js +49 -1
  19. package/lib/commonjs/utils/errors.js.map +1 -1
  20. package/lib/commonjs/wallet-instance-attestation/issuing.js +3 -5
  21. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  22. package/lib/module/index.js +4 -4
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/pid/index.js +2 -1
  25. package/lib/module/pid/index.js.map +1 -1
  26. package/lib/module/pid/issuing.js +225 -0
  27. package/lib/module/pid/issuing.js.map +1 -0
  28. package/lib/module/rp/__test__/index.test.js +16 -0
  29. package/lib/module/rp/__test__/index.test.js.map +1 -0
  30. package/lib/module/rp/index.js +108 -0
  31. package/lib/module/rp/index.js.map +1 -0
  32. package/lib/module/rp/types.js +63 -0
  33. package/lib/module/rp/types.js.map +1 -0
  34. package/lib/module/sd-jwt/types.js +1 -1
  35. package/lib/module/sd-jwt/types.js.map +1 -1
  36. package/lib/module/utils/dpop.js +17 -0
  37. package/lib/module/utils/dpop.js.map +1 -0
  38. package/lib/module/utils/errors.js +46 -0
  39. package/lib/module/utils/errors.js.map +1 -1
  40. package/lib/module/wallet-instance-attestation/issuing.js +3 -5
  41. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  42. package/lib/typescript/index.d.ts +4 -2
  43. package/lib/typescript/index.d.ts.map +1 -1
  44. package/lib/typescript/pid/index.d.ts +2 -1
  45. package/lib/typescript/pid/index.d.ts.map +1 -1
  46. package/lib/typescript/pid/issuing.d.ts +93 -0
  47. package/lib/typescript/pid/issuing.d.ts.map +1 -0
  48. package/lib/typescript/rp/__test__/index.test.d.ts +2 -0
  49. package/lib/typescript/rp/__test__/index.test.d.ts.map +1 -0
  50. package/lib/typescript/rp/index.d.ts +43 -0
  51. package/lib/typescript/rp/index.d.ts.map +1 -0
  52. package/lib/typescript/rp/types.d.ts +840 -0
  53. package/lib/typescript/rp/types.d.ts.map +1 -0
  54. package/lib/typescript/sd-jwt/types.d.ts +5 -5
  55. package/lib/typescript/utils/dpop.d.ts +21 -0
  56. package/lib/typescript/utils/dpop.d.ts.map +1 -0
  57. package/lib/typescript/utils/errors.d.ts +26 -0
  58. package/lib/typescript/utils/errors.d.ts.map +1 -1
  59. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +3 -3
  60. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  61. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  62. package/package.json +4 -2
  63. package/src/index.ts +4 -5
  64. package/src/pid/index.ts +2 -1
  65. package/src/pid/issuing.ts +305 -0
  66. package/src/rp/__test__/index.test.ts +23 -0
  67. package/src/rp/index.ts +150 -0
  68. package/src/rp/types.ts +64 -0
  69. package/src/sd-jwt/types.ts +1 -1
  70. package/src/utils/dpop.ts +25 -0
  71. package/src/utils/errors.ts +48 -0
  72. package/src/wallet-instance-attestation/issuing.ts +9 -7
@@ -0,0 +1,17 @@
1
+ import * as z from "zod";
2
+ import { SignJWT } from "@pagopa/io-react-native-jwt";
3
+ export const getUnsignedDPop = (jwk, payload) => {
4
+ const dPop = new SignJWT(payload).setProtectedHeader({
5
+ alg: "ES256",
6
+ typ: "dpop+jwt",
7
+ jwk
8
+ }).setIssuedAt().setExpirationTime("1h").toSign();
9
+ return dPop;
10
+ };
11
+ export const DPoPPayload = z.object({
12
+ jti: z.string(),
13
+ htm: z.union([z.literal("POST"), z.literal("GET")]),
14
+ htu: z.string(),
15
+ ath: z.string().optional()
16
+ });
17
+ //# sourceMappingURL=dpop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","SignJWT","getUnsignedDPop","jwk","payload","dPop","setProtectedHeader","alg","typ","setIssuedAt","setExpirationTime","toSign","DPoPPayload","object","jti","string","htm","union","literal","htu","ath","optional"],"sourceRoot":"../../../src","sources":["utils/dpop.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AAExB,SAASC,OAAO,QAAQ,6BAA6B;AAGrD,OAAO,MAAMC,eAAe,GAAGA,CAACC,GAAQ,EAAEC,OAAoB,KAAa;EACzE,MAAMC,IAAI,GAAG,IAAIJ,OAAO,CAACG,OAAO,CAAC,CAC9BE,kBAAkB,CAAC;IAClBC,GAAG,EAAE,OAAO;IACZC,GAAG,EAAE,UAAU;IACfL;EACF,CAAC,CAAC,CACDM,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,IAAI,CAAC,CACvBC,MAAM,CAAC,CAAC;EACX,OAAON,IAAI;AACb,CAAC;AAGD,OAAO,MAAMO,WAAW,GAAGZ,CAAC,CAACa,MAAM,CAAC;EAClCC,GAAG,EAAEd,CAAC,CAACe,MAAM,CAAC,CAAC;EACfC,GAAG,EAAEhB,CAAC,CAACiB,KAAK,CAAC,CAACjB,CAAC,CAACkB,OAAO,CAAC,MAAM,CAAC,EAAElB,CAAC,CAACkB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACnDC,GAAG,EAAEnB,CAAC,CAACe,MAAM,CAAC,CAAC;EACfK,GAAG,EAAEpB,CAAC,CAACe,MAAM,CAAC,CAAC,CAACM,QAAQ,CAAC;AAC3B,CAAC,CAAC"}
@@ -70,4 +70,50 @@ export class WalletInstanceAttestationIssuingError extends IoWalletError {
70
70
  this.reason = reason;
71
71
  }
72
72
  }
73
+
74
+ /**
75
+ * An error subclass thrown when auth request decode fail
76
+ *
77
+ */
78
+ export class AuthRequestDecodeError extends IoWalletError {
79
+ static get code() {
80
+ return "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
81
+ }
82
+ code = "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
83
+
84
+ /** The Claim for which the validation failed. */
85
+
86
+ /** Reason code for the validation failure. */
87
+
88
+ constructor(message) {
89
+ let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
90
+ let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
91
+ super(message);
92
+ this.claim = claim;
93
+ this.reason = reason;
94
+ }
95
+ }
96
+
97
+ /**
98
+ * An error subclass thrown when validation fail
99
+ *
100
+ */
101
+ export class PidIssuingError extends IoWalletError {
102
+ static get code() {
103
+ return "ERR_IO_WALLET_PID_ISSUING_FAILED";
104
+ }
105
+ code = "ERR_IO_WALLET_PID_ISSUING_FAILED";
106
+
107
+ /** The Claim for which the validation failed. */
108
+
109
+ /** Reason code for the validation failure. */
110
+
111
+ constructor(message) {
112
+ let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
113
+ let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
114
+ super(message);
115
+ this.claim = claim;
116
+ this.reason = reason;
117
+ }
118
+ }
73
119
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":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AA/CM,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,CAACP,OAAO,CAAC;IACd,IAAI,CAACM,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF"}
1
+ {"version":3,"names":["IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,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;AACA,OAAO,MAAMM,gBAAgB,SAAST,aAAa,CAAC;EAClD,WAAWE,IAAIA,CAAA,EAAsC;IACnD,OAAO,iCAAiC;EAC1C;EAEAA,IAAI,GAAG,iCAAiC;;EAExC;;EAGA;;EAGAC,WAAWA,CAACC,OAAe,EAAiD;IAAA,IAA/CM,KAAK,GAAAC,SAAA,CAA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CAACM,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMG,eAAe,SAASjB,aAAa,CAAC;EACjD,WAAWE,IAAIA,CAAA,EAAuC;IACpD,OAAO,kCAAkC;EAC3C;EAEAA,IAAI,GAAG,kCAAkC;;EAEzC;;EAGA;;EAGAC,WAAWA,CAACC,OAAe,EAAiD;IAAA,IAA/CM,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,CAACP,OAAO,CAAC;IACd,IAAI,CAACM,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF"}
@@ -7,7 +7,9 @@ import uuid from "react-native-uuid";
7
7
  import { WalletInstanceAttestationIssuingError } from "../utils/errors";
8
8
  export class Issuing {
9
9
  constructor(walletProviderBaseUrl) {
10
+ let appFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fetch;
10
11
  this.walletProviderBaseUrl = walletProviderBaseUrl;
12
+ this.appFetch = appFetch;
11
13
  }
12
14
 
13
15
  /**
@@ -52,15 +54,11 @@ export class Issuing {
52
54
  * @param attestationRequest Wallet Instance Attestaion Request
53
55
  * obtained with {@link getAttestationRequestToSign}
54
56
  * @param signature Signature of the Wallet Instance Attestaion Request
55
- * @param appFetch Optional object with fetch function to use
56
57
  *
57
58
  * @returns {string} Wallet Instance Attestation
58
59
  *
59
60
  */
60
61
  async getAttestation(attestationRequest, signature) {
61
- let appFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
62
- fetch
63
- };
64
62
  const signedAttestationRequest = await SignJWT.appendSignature(attestationRequest, signature);
65
63
  const decodedRequest = decodeJwt(signedAttestationRequest);
66
64
  const parsedRequest = WalletInstanceAttestationRequestJwt.parse({
@@ -74,7 +72,7 @@ export class Issuing {
74
72
  grant_type: "urn:ietf:params:oauth:client-assertion-type:jwt-key-attestation",
75
73
  assertion: signedAttestationRequest
76
74
  };
77
- const response = await appFetch.fetch(tokenUrl, {
75
+ const response = await this.appFetch(tokenUrl, {
78
76
  method: "POST",
79
77
  headers: {
80
78
  "Content-Type": "application/json"
@@ -1 +1 @@
1
- {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","Issuing","constructor","walletProviderBaseUrl","getAttestationRequestToSign","jwk","parsedJwk","parse","keyThumbprint","publicKey","kid","walletInstanceAttestationRequest","iss","sub","jti","v4","type","cnf","setProtectedHeader","alg","typ","setIssuedAt","setExpirationTime","toSign","getAttestation","attestationRequest","signature","appFetch","arguments","length","undefined","fetch","signedAttestationRequest","appendSignature","decodedRequest","parsedRequest","payload","header","protectedHeader","tokenUrl","URL","href","requestBody","grant_type","assertion","response","method","headers","body","JSON","stringify","status","text"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":"AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,mCAAmC,QAAQ,SAAS;AAC7D,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,qCAAqC,QAAQ,iBAAiB;AAEvE,OAAO,MAAMC,OAAO,CAAC;EAGnBC,WAAWA,CAACC,qBAA6B,EAAE;IACzC,IAAI,CAACA,qBAAqB,GAAGA,qBAAqB;EACpD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,2BAA2BA,CAACC,GAAQ,EAAm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C;IACF,MAAM7B,SAAS,GAAG0B,aAAa,CAACC,OAAO,CAACnB,GAAG,CAACZ,GAAG;IAE/C,MAAMX,SAAS,CAACsC,wBAAwB,EAAEvB,SAAS,CAAC;IAEpD,MAAM8B,QAAQ,GAAG,IAAIC,GAAG,CAAC,OAAO,EAAE,IAAI,CAACrC,qBAAqB,CAAC,CAACsC,IAAI;IAClE,MAAMC,WAAW,GAAG;MAClBC,UAAU,EACR,iEAAiE;MACnEC,SAAS,EAAEZ;IACb,CAAC;IACD,MAAMa,QAAQ,GAAG,MAAMlB,QAAQ,CAACI,KAAK,CAACQ,QAAQ,EAAE;MAC9CO,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACR,WAAW;IAClC,CAAC,CAAC;IAEF,IAAIG,QAAQ,CAACM,MAAM,KAAK,GAAG,EAAE;MAC3B,OAAO,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAIpD,qCAAqC,CAC7C,mEAAmE,EAClE,kBAAiB6C,QAAQ,CAACM,MAAO,EACpC,CAAC;EACH;AACF"}
1
+ {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","Issuing","constructor","walletProviderBaseUrl","appFetch","arguments","length","undefined","fetch","getAttestationRequestToSign","jwk","parsedJwk","parse","keyThumbprint","publicKey","kid","walletInstanceAttestationRequest","iss","sub","jti","v4","type","cnf","setProtectedHeader","alg","typ","setIssuedAt","setExpirationTime","toSign","getAttestation","attestationRequest","signature","signedAttestationRequest","appendSignature","decodedRequest","parsedRequest","payload","header","protectedHeader","tokenUrl","URL","href","requestBody","grant_type","assertion","response","method","headers","body","JSON","stringify","status","text"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":"AAAA,SAASA,MAAM,IAA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-1,5 +1,7 @@
1
1
  import * as PID from "./pid";
2
+ import * as RP from "./rp";
3
+ import * as Errors from "./utils/errors";
2
4
  import * as WalletInstanceAttestation from "./wallet-instance-attestation";
3
- export declare function multiply(a: number, b: number): Promise<number>;
4
- export { PID, WalletInstanceAttestation };
5
+ import { getUnsignedDPop } from "./utils/dpop";
6
+ export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop };
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,yBAAyB,MAAM,+BAA+B,CAAC;AAE3E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D;AAED,OAAO,EAAE,GAAG,EAAE,yBAAyB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,yBAAyB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,yBAAyB,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import * as SdJwt from "./sd-jwt";
2
- export { SdJwt };
2
+ import { Issuing } from "./issuing";
3
+ export { SdJwt, Issuing };
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pid/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pid/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { JWK } from "../utils/jwk";
2
+ export type CieData = {
3
+ birthDate: string;
4
+ fiscalCode: string;
5
+ name: string;
6
+ surname: string;
7
+ };
8
+ export type TokenResponse = {
9
+ access_token: string;
10
+ c_nonce: string;
11
+ };
12
+ export type PidResponse = {
13
+ credential: string;
14
+ c_nonce: string;
15
+ c_nonce_expires_in: number;
16
+ format: string;
17
+ };
18
+ export declare class Issuing {
19
+ pidProviderBaseUrl: string;
20
+ walletProviderBaseUrl: string;
21
+ walletInstanceAttestation: string;
22
+ codeVerifier: string;
23
+ clientId: string;
24
+ state: string;
25
+ authorizationCode: string;
26
+ appFetch: GlobalFetch["fetch"];
27
+ constructor(pidProviderBaseUrl: string, walletProviderBaseUrl: string, walletInstanceAttestation: string, clientId: string, appFetch?: GlobalFetch["fetch"]);
28
+ /**
29
+ * Return the unsigned jwt to call the PAR request.
30
+ *
31
+ * @function
32
+ * @param jwk The wallet instance attestation public JWK
33
+ *
34
+ * @returns Unsigned jwt
35
+ *
36
+ */
37
+ getUnsignedJwtForPar(jwk: JWK): Promise<string>;
38
+ /**
39
+ * Make a PAR request to the PID issuer and return the response url
40
+ *
41
+ * @function
42
+ * @param unsignedJwtForPar The unsigned JWT for PAR
43
+ * @param signature The JWT for PAR signature
44
+ *
45
+ * @returns Unsigned PAR url
46
+ *
47
+ */
48
+ getPar(unsignedJwtForPar: string, signature: string): Promise<string>;
49
+ /**
50
+ * Return the unsigned jwt for a generic DPoP
51
+ *
52
+ * @function
53
+ * @param jwk the public key for which the DPoP is to be created
54
+ *
55
+ * @returns Unsigned JWT for DPoP
56
+ *
57
+ */
58
+ getUnsignedDPoP(jwk: JWK): Promise<string>;
59
+ /**
60
+ * Make an auth token request to the PID issuer
61
+ *
62
+ * @function
63
+ * @returns a token response
64
+ *
65
+ */
66
+ getAuthToken(): Promise<TokenResponse>;
67
+ /**
68
+ * Return the unsigned jwt for nonce proof of possession
69
+ *
70
+ * @function
71
+ * @param nonce the nonce
72
+ *
73
+ * @returns Unsigned JWT for nonce proof
74
+ *
75
+ */
76
+ getUnsignedNonceProof(nonce: string): Promise<string>;
77
+ /**
78
+ * Make the credential issuing request to the PID issuer
79
+ *
80
+ * @function
81
+ * @param unsignedDPopForPid The unsigned JWT for PID DPoP
82
+ * @param dPopPidSignature The JWT for PID DPoP signature
83
+ * @param unsignedNonceProof The unsigned JWT for nonce proof
84
+ * @param nonceProofSignature The JWT for nonce proof signature
85
+ * @param accessToken The access token obtained with getAuthToken
86
+ * @param cieData Personal data read by the CIE
87
+ *
88
+ * @returns a credential
89
+ *
90
+ */
91
+ getCredential(unsignedDPopForPid: string, dPopPidSignature: string, unsignedNonceProof: string, nonceProofSignature: string, accessToken: string, cieData: CieData): Promise<PidResponse>;
92
+ }
93
+ //# sourceMappingURL=issuing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOnC,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACtE,MAAM,MAAM,WAAW,GAA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,CAAC,WAAW,CAAC;CAsCxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../src/rp/__test__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ import { RequestObject, RpEntityConfiguration } from "./types";
2
+ import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
3
+ export declare class RelyingPartySolution {
4
+ relyingPartyBaseUrl: string;
5
+ walletInstanceAttestation: string;
6
+ appFetch: GlobalFetch["fetch"];
7
+ constructor(relyingPartyBaseUrl: string, walletInstanceAttestation: string, appFetch?: GlobalFetch["fetch"]);
8
+ /**
9
+ * Decode a QR code content to an authentication request url.
10
+ * @function
11
+ * @param qrcode QR code content
12
+ *
13
+ * @returns The authentication request url
14
+ *
15
+ */
16
+ decodeAuthRequestQR(qrcode: string): string;
17
+ /**
18
+ * Obtain the unsigned wallet instance DPoP for authentication request
19
+ *
20
+ * @function
21
+ * @param walletInstanceAttestationJwk JWT of the Wallet Instance Attestation
22
+ * @param authRequestUrl authentication request url
23
+ *
24
+ * @returns The unsigned wallet instance DPoP
25
+ *
26
+ */
27
+ getUnsignedWalletInstanceDPoP(walletInstanceAttestationJwk: JWK, authRequestUrl: string): Promise<string>;
28
+ /**
29
+ * Obtain the Request Object for RP authentication
30
+ *
31
+ * @function
32
+ * @param signedWalletInstanceDPoP JWT of the Wallet Instance Attestation DPoP
33
+ *
34
+ * @returns The Request Object JWT
35
+ *
36
+ */
37
+ getRequestObject(signedWalletInstanceDPoP: string): Promise<RequestObject>;
38
+ /**
39
+ * Obtain the relying party entity configuration.
40
+ */
41
+ getEntityConfiguration(): Promise<RpEntityConfiguration>;
42
+ }
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rp/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kDAAkD,CAAC;AAE5E,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,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAoB3C;;;;;;;;;OASG;IACG,6BAA6B,CACjC,4BAA4B,EAAE,GAAG,EACjC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;;;OAQG;IACG,gBAAgB,CACpB,wBAAwB,EAAE,MAAM,GAC/B,OAAO,CAAC,aAAa,CAAC;IA2BzB;;OAEG;IACG,sBAAsB,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAuB/D"}