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

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 (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
@@ -5,61 +5,51 @@ import { JWK, fixBase64EncodingOnKey } from "../utils/jwk";
5
5
  import { WalletInstanceAttestationRequestJwt } from "./types";
6
6
  import uuid from "react-native-uuid";
7
7
  import { WalletInstanceAttestationIssuingError } from "../utils/errors";
8
- export class Issuing {
9
- constructor(walletProviderBaseUrl) {
10
- let appFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fetch;
11
- this.walletProviderBaseUrl = walletProviderBaseUrl;
12
- this.appFetch = appFetch;
13
- }
14
-
15
- /**
16
- * Get the Wallet Instance Attestation Request to sign
17
- *
18
- * @async @function
19
- *
20
- * @param jwk Public key of the wallet instance
21
- *
22
- * @returns {string} Wallet Instance Attestation Request to sign
23
- *
24
- */
25
- async getAttestationRequestToSign(jwk) {
26
- const parsedJwk = JWK.parse(jwk);
27
- const keyThumbprint = await thumbprint(parsedJwk);
28
- const publicKey = {
29
- ...parsedJwk,
30
- kid: keyThumbprint
31
- };
32
- const walletInstanceAttestationRequest = new SignJWT({
33
- iss: keyThumbprint,
34
- aud: this.walletProviderBaseUrl,
35
- jti: `${uuid.v4()}`,
36
- nonce: `${uuid.v4()}`,
37
- cnf: {
38
- jwk: fixBase64EncodingOnKey(publicKey)
39
- }
40
- }).setProtectedHeader({
41
- alg: "ES256",
42
- kid: publicKey.kid,
43
- typ: "wiar+jwt"
44
- }).setIssuedAt().setExpirationTime("1h").toSign();
45
- return walletInstanceAttestationRequest;
46
- }
8
+ async function getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl) {
9
+ const jwk = await wiaCryptoContext.getPublicKey();
10
+ const parsedJwk = JWK.parse(jwk);
11
+ const keyThumbprint = await thumbprint(parsedJwk);
12
+ const publicKey = {
13
+ ...parsedJwk,
14
+ kid: keyThumbprint
15
+ };
16
+ return new SignJWT(wiaCryptoContext).setPayload({
17
+ iss: keyThumbprint,
18
+ aud: walletProviderBaseUrl,
19
+ jti: `${uuid.v4()}`,
20
+ nonce: `${uuid.v4()}`,
21
+ cnf: {
22
+ jwk: fixBase64EncodingOnKey(publicKey)
23
+ }
24
+ }).setProtectedHeader({
25
+ kid: publicKey.kid,
26
+ typ: "wiar+jwt"
27
+ }).setPayload({
28
+ iss: keyThumbprint,
29
+ sub: walletProviderBaseUrl,
30
+ jti: `${uuid.v4()}`,
31
+ type: "WalletInstanceAttestationRequest",
32
+ cnf: {
33
+ jwk: fixBase64EncodingOnKey(publicKey)
34
+ }
35
+ }).setIssuedAt().setExpirationTime("1h").sign();
36
+ }
47
37
 
48
- /**
49
- * Get the Wallet Instance Attestation given a
50
- * Wallet Instance Attestation Request and signature
51
- *
52
- * @async @function
53
- *
54
- * @param attestationRequest Wallet Instance Attestaion Request
55
- * obtained with {@link getAttestationRequestToSign}
56
- * @param signature Signature of the Wallet Instance Attestaion Request
57
- *
58
- * @returns {string} Wallet Instance Attestation
59
- *
60
- */
61
- async getAttestation(attestationRequest, signature) {
62
- const signedAttestationRequest = await SignJWT.appendSignature(attestationRequest, signature);
38
+ /**
39
+ * Request a Wallet Instance Attestation (WIA) to the Wallet provider
40
+ *
41
+ * @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
42
+ * @param params.appFetch (optional) Http client
43
+ * @param walletProviderBaseUrl Base url for the Wallet Provider
44
+ * @returns The retrieved Wallet Instance Attestation token
45
+ */
46
+ export const getAttestation = _ref => {
47
+ let {
48
+ wiaCryptoContext,
49
+ appFetch = fetch
50
+ } = _ref;
51
+ return async walletProviderBaseUrl => {
52
+ const signedAttestationRequest = await getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl);
63
53
  const decodedRequest = decodeJwt(signedAttestationRequest);
64
54
  const parsedRequest = WalletInstanceAttestationRequestJwt.parse({
65
55
  payload: decodedRequest.payload,
@@ -67,12 +57,12 @@ export class Issuing {
67
57
  });
68
58
  const publicKey = parsedRequest.payload.cnf.jwk;
69
59
  await verifyJwt(signedAttestationRequest, publicKey);
70
- const tokenUrl = new URL("token", this.walletProviderBaseUrl).href;
60
+ const tokenUrl = new URL("token", walletProviderBaseUrl).href;
71
61
  const requestBody = {
72
62
  grant_type: "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation",
73
63
  assertion: signedAttestationRequest
74
64
  };
75
- const response = await this.appFetch(tokenUrl, {
65
+ const response = await appFetch(tokenUrl, {
76
66
  method: "POST",
77
67
  headers: {
78
68
  "Content-Type": "application/json"
@@ -83,6 +73,6 @@ export class Issuing {
83
73
  return await response.text();
84
74
  }
85
75
  throw new WalletInstanceAttestationIssuingError("Unable to obtain wallet instance attestation from wallet provider", `Response code: ${response.status}`);
86
- }
87
- }
76
+ };
77
+ };
88
78
  //# sourceMappingURL=issuing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","fixBase64EncodingOnKey","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","Issuing","constructor","walletProviderBaseUrl","appFetch","arguments","length","undefined","fetch","getAttestationRequestToSign","jwk","parsedJwk","parse","keyThumbprint","publicKey","kid","walletInstanceAttestationRequest","iss","aud","jti","v4","nonce","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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qC,CAC7C,mEAAmE,EAClE,kBAAiB6C,QAAQ,CAACM,MAAO,EACpC,CAAC;EACH;AACF"}
1
+ {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","fixBase64EncodingOnKey","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","getAttestationRequest","wiaCryptoContext","walletProviderBaseUrl","jwk","getPublicKey","parsedJwk","parse","keyThumbprint","publicKey","kid","setPayload","iss","aud","jti","v4","nonce","cnf","setProtectedHeader","typ","sub","type","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","signedAttestationRequest","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,SAEEA,MAAM,IAAIC,SAAS,QACd,6BAA6B;AACpC,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,EAAEC,sBAAsB,QAAQ,cAAc;AAC1D,SAASC,mCAAmC,QAAQ,SAAS;AAC7D,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,qCAAqC,QAAQ,iBAAiB;AAEvE,eAAeC,qBAAqBA,CAClCC,gBAA+B,EAC/BC,qBAA6B,EACZ;EACjB,MAAMC,GAAG,GAAG,MAAMF,gBAAgB,CAACG,YAAY,CAAC,CAAC;EACjD,MAAMC,SAAS,GAAGV,GAAG,CAACW,KAAK,CAACH,GAAG,CAAC;EAChC,MAAMI,aAAa,GAAG,MAAMb,UAAU,CAACW,SAAS,CAAC;EACjD,MAAMG,SAAS,GAAG;IAAE,GAAGH,SAAS;IAAEI,GAAG,EAAEF;EAAc,CAAC;EAEtD,OAAO,IAAId,OAAO,CAACQ,gBAAgB,CAAC,CACjCS,UAAU,CAAC;IACVC,GAAG,EAA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MAAMX,SAAS,CAACoC,wBAAwB,EAAEpB,SAAS,CAAC;IAEpD,MAAM0B,QAAQ,GAAG,IAAIC,GAAG,CAAC,OAAO,EAAEjC,qBAAqB,CAAC,CAACkC,IAAI;IAC7D,MAAMC,WAAW,GAAG;MAClBC,UAAU,EACR,oEAAoE;MACtEC,SAAS,EAAEX;IACb,CAAC;IACD,MAAMY,QAAQ,GAAG,MAAMd,QAAQ,CAACQ,QAAQ,EAAE;MACxCO,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,IAAIhD,qCAAqC,CAC7C,mEAAmE,EAClE,kBAAiByC,QAAQ,CAACM,MAAO,EACpC,CAAC;EACH,CAAC;AAAA"}
@@ -3,10 +3,11 @@ import * as PID from "./pid";
3
3
  import * as RP from "./rp";
4
4
  import * as Errors from "./utils/errors";
5
5
  import * as WalletInstanceAttestation from "./wallet-instance-attestation";
6
- import { getUnsignedDPop } from "./utils/dpop";
7
- import { RelyingPartySolution } from "./rp";
6
+ import * as RelyingPartySolution from "./rp";
8
7
  import { RpEntityConfiguration } from "./rp/types";
9
8
  import { verifyTrustChain, getEntityConfiguration } from "./trust";
10
9
  import { EntityConfiguration, EntityStatement, TrustAnchorEntityConfiguration } from "./trust/types";
11
- export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, EntityConfiguration, EntityStatement, RpEntityConfiguration, TrustAnchorEntityConfiguration, };
10
+ import { createCryptoContextFor } from "./utils/crypto";
11
+ import { PidIssuerEntityConfiguration } from "./pid/metadata";
12
+ export { PID, RP, WalletInstanceAttestation, Errors, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, EntityConfiguration, EntityStatement, RpEntityConfiguration, PidIssuerEntityConfiguration, TrustAnchorEntityConfiguration, createCryptoContextFor, };
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gCAAgC,CAAC;AAExC,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,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,8BAA8B,EAC/B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,GAAG,EACH,EAAE,EACF,yBAAyB,EACzB,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,8BAA8B,GAC/B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gCAAgC,CAAC;AAExC,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,KAAK,oBAAoB,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,8BAA8B,EAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,GAAG,EACH,EAAE,EACF,yBAAyB,EACzB,MAAM,EACN,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,GACvB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import * as SdJwt from "./sd-jwt";
2
- import { Issuing } from "./issuing";
2
+ import * as Issuing from "./issuing";
3
3
  export { SdJwt, Issuing };
4
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,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,OAAO,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,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
- import { JWK } from "../utils/jwk";
1
+ /// <reference types="react-native" />
2
+ import { type CryptoContext } from "@pagopa/io-react-native-jwt";
2
3
  import { PidIssuerEntityConfiguration } from "./metadata";
3
4
  export type CieData = {
4
5
  birthDate: string;
@@ -6,9 +7,13 @@ export type CieData = {
6
7
  name: string;
7
8
  surname: string;
8
9
  };
9
- export type TokenResponse = {
10
- access_token: string;
11
- c_nonce: string;
10
+ export type AuthorizationConf = {
11
+ accessToken: string;
12
+ nonce: string;
13
+ clientId: string;
14
+ authorizationCode: string;
15
+ codeVerifier: string;
16
+ walletProviderBaseUrl: string;
12
17
  };
13
18
  export type PidResponse = {
14
19
  credential: string;
@@ -16,87 +21,46 @@ export type PidResponse = {
16
21
  c_nonce_expires_in: number;
17
22
  format: string;
18
23
  };
19
- export declare class Issuing {
20
- pidProviderBaseUrl: string;
21
- walletProviderBaseUrl: string;
22
- walletInstanceAttestation: string;
23
- codeVerifier: string;
24
- clientId: string;
25
- state: string;
26
- authorizationCode: string;
27
- appFetch: GlobalFetch["fetch"];
28
- constructor(pidProviderBaseUrl: string, walletProviderBaseUrl: string, walletInstanceAttestation: string, clientId: string, appFetch?: GlobalFetch["fetch"]);
29
- /**
30
- * Return the unsigned jwt to call the PAR request.
31
- *
32
- * @function
33
- * @param jwk The wallet instance attestation public JWK
34
- *
35
- * @returns Unsigned jwt
36
- *
37
- */
38
- getUnsignedJwtForPar(jwk: JWK): Promise<string>;
39
- /**
40
- * Make a PAR request to the PID issuer and return the response url
41
- *
42
- * @function
43
- * @param unsignedJwtForPar The unsigned JWT for PAR
44
- * @param signature The JWT for PAR signature
45
- *
46
- * @returns Unsigned PAR url
47
- *
48
- */
49
- getPar(unsignedJwtForPar: string, signature: string): Promise<string>;
50
- /**
51
- * Return the unsigned jwt for a generic DPoP
52
- *
53
- * @function
54
- * @param jwk the public key for which the DPoP is to be created
55
- *
56
- * @returns Unsigned JWT for DPoP
57
- *
58
- */
59
- getUnsignedDPoP(jwk: JWK): Promise<string>;
60
- /**
61
- * Make an auth token request to the PID issuer
62
- *
63
- * @function
64
- * @returns a token response
65
- *
66
- */
67
- getAuthToken(): Promise<TokenResponse>;
68
- /**
69
- * Return the unsigned jwt for nonce proof of possession
70
- *
71
- * @function
72
- * @param nonce the nonce
73
- *
74
- * @returns Unsigned JWT for nonce proof
75
- *
76
- */
77
- getUnsignedNonceProof(nonce: string): Promise<string>;
78
- /**
79
- * Make the credential issuing request to the PID issuer
80
- *
81
- * @function
82
- * @param unsignedDPopForPid The unsigned JWT for PID DPoP
83
- * @param dPopPidSignature The JWT for PID DPoP signature
84
- * @param unsignedNonceProof The unsigned JWT for nonce proof
85
- * @param nonceProofSignature The JWT for nonce proof signature
86
- * @param accessToken The access token obtained with getAuthToken
87
- * @param cieData Personal data read by the CIE
88
- *
89
- * @returns a credential
90
- *
91
- */
92
- getCredential(unsignedDPopForPid: string, dPopPidSignature: string, unsignedNonceProof: string, nonceProofSignature: string, accessToken: string, cieData: CieData): Promise<PidResponse>;
93
- /**
94
- * Obtain the PID issuer metadata
95
- *
96
- * @function
97
- * @returns PID issuer metadata
98
- *
99
- */
100
- getEntityConfiguration(): Promise<PidIssuerEntityConfiguration>;
101
- }
24
+ /**
25
+ * Obtain the PID provider entity configuration.
26
+ */
27
+ export declare const getEntityConfiguration: ({ appFetch }?: {
28
+ appFetch?: {
29
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
30
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
31
+ } | undefined;
32
+ }) => (relyingPartyBaseUrl: string) => Promise<PidIssuerEntityConfiguration>;
33
+ /**
34
+ * Start the issuing flow by generating an authorization request to the PID Provider. Obtain from the PID Provider an access token to be used to complete the issuing flow.
35
+ *
36
+ * @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
37
+ * @param params.appFetch (optional) Http client
38
+ * @param walletInstanceAttestation Wallet Instance Attestation token.
39
+ * @param walletProviderBaseUrl Base url for the Wallet Provider
40
+ * @param pidProviderEntityConfiguration The Entity Configuration of the PID Provider, from which discover public endooints.
41
+ * @returns The access token along with the values that identify the issuing session.
42
+ */
43
+ export declare const authorizeIssuing: ({ wiaCryptoContext, appFetch, }: {
44
+ wiaCryptoContext: CryptoContext;
45
+ appFetch?: {
46
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
47
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
48
+ } | undefined;
49
+ }) => (walletInstanceAttestation: string, walletProviderBaseUrl: string, pidProviderEntityConfiguration: PidIssuerEntityConfiguration) => Promise<AuthorizationConf>;
50
+ /**
51
+ * Complete the issuing flow and get the PID credential.
52
+ *
53
+ * @param params.pidCryptoContext The key pair associated with the PID. Will be use to prove the ownership of the credential.
54
+ * @param params.appFetch (optional) Http client
55
+ * @param authConf The authorization configuration retrieved with the access token
56
+ * @param cieData Data red from the CIE login process
57
+ * @returns The PID credential token
58
+ */
59
+ export declare const getCredential: ({ pidCryptoContext, appFetch, }: {
60
+ pidCryptoContext: CryptoContext;
61
+ appFetch?: {
62
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
63
+ (input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
64
+ } | undefined;
65
+ }) => ({ nonce, accessToken, clientId, walletProviderBaseUrl }: AuthorizationConf, pidProviderEntityConfiguration: PidIssuerEntityConfiguration, cieData: CieData) => Promise<PidResponse>;
102
66
  //# sourceMappingURL=issuing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAKnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAI1D,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,GAAG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