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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/index.js +19 -5
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/rp/__test__/index.test.js +18 -0
  5. package/lib/commonjs/rp/__test__/index.test.js.map +1 -0
  6. package/lib/commonjs/rp/index.js +116 -0
  7. package/lib/commonjs/rp/index.js.map +1 -0
  8. package/lib/commonjs/rp/types.js +72 -0
  9. package/lib/commonjs/rp/types.js.map +1 -0
  10. package/lib/commonjs/utils/dpop.js +27 -0
  11. package/lib/commonjs/utils/dpop.js.map +1 -0
  12. package/lib/commonjs/utils/errors.js +25 -1
  13. package/lib/commonjs/utils/errors.js.map +1 -1
  14. package/lib/commonjs/utils/signature.js +10 -0
  15. package/lib/commonjs/utils/signature.js.map +1 -0
  16. package/lib/commonjs/wallet-instance-attestation/issuing.js +3 -5
  17. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  18. package/lib/module/index.js +5 -4
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/rp/__test__/index.test.js +16 -0
  21. package/lib/module/rp/__test__/index.test.js.map +1 -0
  22. package/lib/module/rp/index.js +108 -0
  23. package/lib/module/rp/index.js.map +1 -0
  24. package/lib/module/rp/types.js +63 -0
  25. package/lib/module/rp/types.js.map +1 -0
  26. package/lib/module/utils/dpop.js +17 -0
  27. package/lib/module/utils/dpop.js.map +1 -0
  28. package/lib/module/utils/errors.js +23 -0
  29. package/lib/module/utils/errors.js.map +1 -1
  30. package/lib/module/utils/signature.js +3 -0
  31. package/lib/module/utils/signature.js.map +1 -0
  32. package/lib/module/wallet-instance-attestation/issuing.js +3 -5
  33. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  34. package/lib/typescript/index.d.ts +5 -2
  35. package/lib/typescript/index.d.ts.map +1 -1
  36. package/lib/typescript/rp/__test__/index.test.d.ts +2 -0
  37. package/lib/typescript/rp/__test__/index.test.d.ts.map +1 -0
  38. package/lib/typescript/rp/index.d.ts +43 -0
  39. package/lib/typescript/rp/index.d.ts.map +1 -0
  40. package/lib/typescript/rp/types.d.ts +840 -0
  41. package/lib/typescript/rp/types.d.ts.map +1 -0
  42. package/lib/typescript/utils/dpop.d.ts +21 -0
  43. package/lib/typescript/utils/dpop.d.ts.map +1 -0
  44. package/lib/typescript/utils/errors.d.ts +13 -0
  45. package/lib/typescript/utils/errors.d.ts.map +1 -1
  46. package/lib/typescript/utils/signature.d.ts +2 -0
  47. package/lib/typescript/utils/signature.d.ts.map +1 -0
  48. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +3 -3
  49. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  50. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  51. package/package.json +1 -1
  52. package/src/index.ts +12 -5
  53. package/src/rp/__test__/index.test.ts +23 -0
  54. package/src/rp/index.ts +150 -0
  55. package/src/rp/types.ts +64 -0
  56. package/src/utils/dpop.ts +25 -0
  57. package/src/utils/errors.ts +24 -0
  58. package/src/utils/signature.ts +4 -0
  59. package/src/wallet-instance-attestation/issuing.ts +8 -6
@@ -0,0 +1,63 @@
1
+ import { JWK } from "../utils/jwk";
2
+ import { UnixTime } from "../sd-jwt/types";
3
+ import * as z from "zod";
4
+ export const RequestObject = z.object({
5
+ header: z.object({
6
+ typ: z.literal("JWT"),
7
+ alg: z.string(),
8
+ kid: z.string(),
9
+ trust_chain: z.array(z.string())
10
+ }),
11
+ payload: z.object({
12
+ iss: z.string(),
13
+ iat: UnixTime,
14
+ exp: UnixTime,
15
+ state: z.string(),
16
+ nonce: z.string(),
17
+ response_uri: z.string(),
18
+ response_type: z.literal("vp_token"),
19
+ response_mode: z.literal("direct_post.jwt"),
20
+ client_id: z.string(),
21
+ client_id_scheme: z.literal("entity_id"),
22
+ scope: z.string()
23
+ })
24
+ });
25
+
26
+ // TODO: This types is WIP in technical rules
27
+
28
+ export const RpEntityConfiguration = z.object({
29
+ header: z.object({
30
+ typ: z.literal("entity-statement+jwt"),
31
+ alg: z.string(),
32
+ kid: z.string()
33
+ }),
34
+ payload: z.object({
35
+ exp: UnixTime,
36
+ iat: UnixTime,
37
+ iss: z.string(),
38
+ sub: z.string(),
39
+ jwks: z.object({
40
+ keys: z.array(JWK)
41
+ }),
42
+ metadata: z.object({
43
+ wallet_relying_party: z.object({
44
+ application_type: z.string(),
45
+ client_id: z.string(),
46
+ client_name: z.string(),
47
+ jwks: z.object({
48
+ keys: z.array(JWK)
49
+ }),
50
+ contacts: z.array(z.string())
51
+ }),
52
+ federation_entity: z.object({
53
+ organization_name: z.string(),
54
+ homepage_uri: z.string(),
55
+ policy_uri: z.string(),
56
+ logo_uri: z.string(),
57
+ contacts: z.array(z.string())
58
+ })
59
+ }),
60
+ authority_hints: z.array(z.string())
61
+ })
62
+ });
63
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JWK","UnixTime","z","RequestObject","object","header","typ","literal","alg","string","kid","trust_chain","array","payload","iss","iat","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","RpEntityConfiguration","sub","jwks","keys","metadata","wallet_relying_party","application_type","client_name","contacts","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","authority_hints"],"sourceRoot":"../../../src","sources":["rp/types.ts"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAc;AAClC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,CAAC,MAAM,KAAK;AAGxB,OAAO,MAAMC,aAAa,GAAGD,CAAC,CAACE,MAAM,CAAC;EACpCC,MAAM,EAAEH,CAAC,CAACE,MAAM,CAAC;IACfE,GAAG,EAAEJ,CAAC,CAACK,OAAO,CAAC,KAAK,CAAC;IACrBC,GAAG,EAAEN,CAAC,CAACO,MAAM,CAAC,CAAC;IACfC,GAAG,EAAER,CAAC,CAACO,MAAM,CAAC,CAAC;IACfE,WAAW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E1B,CAAC,CAACU,KAAK,CAACZ,GAAG;IACnB,CAAC,CAAC;IACF6B,QAAQ,EAAE3B,CAAC,CAACE,MAAM,CAAC;MACjB0B,oBAAoB,EAAE5B,CAAC,CAACE,MAAM,CAAC;QAC7B2B,gBAAgB,EAAE7B,CAAC,CAACO,MAAM,CAAC,CAAC;QAC5Ba,SAAS,EAAEpB,CAAC,CAACO,MAAM,CAAC,CAAC;QACrBuB,WAAW,EAAE9B,CAAC,CAACO,MAAM,CAAC,CAAC;QACvBkB,IAAI,EAAEzB,CAAC,CAACE,MAAM,CAAC;UACbwB,IAAI,EAAE1B,CAAC,CAACU,KAAK,CAACZ,GAAG;QACnB,CAAC,CAAC;QACFiC,QAAQ,EAAE/B,CAAC,CAACU,KAAK,CAACV,CAAC,CAACO,MAAM,CAAC,CAAC;MAC9B,CAAC,CAAC;MACFyB,iBAAiB,EAAEhC,CAAC,CAACE,MAAM,CAAC;QAC1B+B,iBAAiB,EAAEjC,CAAC,CAACO,MAAM,CAAC,CAAC;QAC7B2B,YAAY,EAAElC,CAAC,CAACO,MAAM,CAAC,CAAC;QACxB4B,UAAU,EAAEnC,CAAC,CAACO,MAAM,CAAC,CAAC;QACtB6B,QAAQ,EAAEpC,CAAC,CAACO,MAAM,CAAC,CAAC;QACpBwB,QAAQ,EAAE/B,CAAC,CAACU,KAAK,CAACV,CAAC,CAACO,MAAM,CAAC,CAAC;MAC9B,CAAC;IACH,CAAC,CAAC;IACF8B,eAAe,EAAErC,CAAC,CAACU,KAAK,CAACV,CAAC,CAACO,MAAM,CAAC,CAAC;EACrC,CAAC;AACH,CAAC,CAAC"}
@@ -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()
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"],"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;AAChB,CAAC,CAAC"}
@@ -70,4 +70,27 @@ 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
+ }
73
96
  //# 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":"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,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;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qCAAqC,SAASf,aAAa,CAAC;EACvE,WAAWE,IAAIA,CAAA,EAAwD;IACrE,OAAO,mDAAmD;EAC5D;EAEAA,IAAI,GAAG,mDAAmD;;EAE1D;;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"}
1
+ {"version":3,"names":["IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError"],"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,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C,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;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAME,sBAAsB,SAAShB,aAAa,CAAC;EACxD,WAAWE,IAAIA,CAAA,EAAyD;IACtE,OAAO,oDAAoD;EAC7D;EAEAA,IAAI,GAAG,oDAAoD;;EAE3D;;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"}
@@ -0,0 +1,3 @@
1
+ import { SignJWT } from "@pagopa/io-react-native-jwt";
2
+ export const getSignedJwt = async (unsignedJwt, signature) => await SignJWT.appendSignature(unsignedJwt, signature);
3
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SignJWT","getSignedJwt","unsignedJwt","signature","appendSignature"],"sourceRoot":"../../../src","sources":["utils/signature.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,6BAA6B;AAErD,OAAO,MAAMC,YAAY,GAAG,MAAAA,CAAOC,WAAmB,EAAEC,SAAiB,KACvE,MAAMH,OAAO,CAACI,eAAe,CAACF,WAAW,EAAEC,SAAS,CAAC"}
@@ -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"],"sourceRo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AQ,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,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,CACTC,qBAA6B,EAE7B;IAAA,IADAC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,KAAK;IAEtC,IAAI,CAACL,qBAAqB,GAAGA,qBAAqB;IAClD,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMK,2BAA2BA,CAACC,GAAQ,EAAmB;IAC3D,MAAMC,SAAS,GAAGd,GAAG,CAACe,KAAK,CAACF,GAAG,CAAC;IAChC,MAAMG,aAAa,GAAG,MAAMjB,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CAACsC,IAAI;IAClE,MAAMC,WAAW,GAAG;MAClBC,UAAU,EACR,iEAAiE;MACnEC,SAAS,EAAEZ;IACb,CAAC;IACD,MAAMa,QAAQ,GAAG,MAAM,IAAI,CAACzC,QAAQ,CAACmC,QAAQ,EAAE;MAC7CO,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,5 +1,8 @@
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
+ import { getSignedJwt } from "./utils/signature";
7
+ export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, getSignedJwt, };
5
8
  //# 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;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,GAAG,EACH,EAAE,EACF,yBAAyB,EACzB,MAAM,EACN,eAAe,EACf,YAAY,GACb,CAAC"}
@@ -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"}