@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.
- package/README.md +1 -1
- package/lib/commonjs/index.js +12 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/index.js +7 -0
- package/lib/commonjs/pid/index.js.map +1 -1
- package/lib/commonjs/pid/issuing.js +231 -0
- package/lib/commonjs/pid/issuing.js.map +1 -0
- package/lib/commonjs/rp/__test__/index.test.js +18 -0
- package/lib/commonjs/rp/__test__/index.test.js.map +1 -0
- package/lib/commonjs/rp/index.js +116 -0
- package/lib/commonjs/rp/index.js.map +1 -0
- package/lib/commonjs/rp/types.js +72 -0
- package/lib/commonjs/rp/types.js.map +1 -0
- package/lib/commonjs/sd-jwt/types.js +1 -1
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/utils/dpop.js +27 -0
- package/lib/commonjs/utils/dpop.js.map +1 -0
- package/lib/commonjs/utils/errors.js +49 -1
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +3 -5
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/index.js +2 -1
- package/lib/module/pid/index.js.map +1 -1
- package/lib/module/pid/issuing.js +225 -0
- package/lib/module/pid/issuing.js.map +1 -0
- package/lib/module/rp/__test__/index.test.js +16 -0
- package/lib/module/rp/__test__/index.test.js.map +1 -0
- package/lib/module/rp/index.js +108 -0
- package/lib/module/rp/index.js.map +1 -0
- package/lib/module/rp/types.js +63 -0
- package/lib/module/rp/types.js.map +1 -0
- package/lib/module/sd-jwt/types.js +1 -1
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/utils/dpop.js +17 -0
- package/lib/module/utils/dpop.js.map +1 -0
- package/lib/module/utils/errors.js +46 -0
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +3 -5
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/index.d.ts +2 -1
- package/lib/typescript/pid/index.d.ts.map +1 -1
- package/lib/typescript/pid/issuing.d.ts +93 -0
- package/lib/typescript/pid/issuing.d.ts.map +1 -0
- package/lib/typescript/rp/__test__/index.test.d.ts +2 -0
- package/lib/typescript/rp/__test__/index.test.d.ts.map +1 -0
- package/lib/typescript/rp/index.d.ts +43 -0
- package/lib/typescript/rp/index.d.ts.map +1 -0
- package/lib/typescript/rp/types.d.ts +840 -0
- package/lib/typescript/rp/types.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/types.d.ts +5 -5
- package/lib/typescript/utils/dpop.d.ts +21 -0
- package/lib/typescript/utils/dpop.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +26 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +3 -3
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
- package/package.json +4 -2
- package/src/index.ts +4 -5
- package/src/pid/index.ts +2 -1
- package/src/pid/issuing.ts +305 -0
- package/src/rp/__test__/index.test.ts +23 -0
- package/src/rp/index.ts +150 -0
- package/src/rp/types.ts +64 -0
- package/src/sd-jwt/types.ts +1 -1
- package/src/utils/dpop.ts +25 -0
- package/src/utils/errors.ts +48 -0
- 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":"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","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,WAA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A,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,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
|
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","
|
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,UAAU,CAACe,SAAS,CAAC;IACjD,MAAMG,SAAS,GAAG;MAAE,GAAGH,SAAS;MAAEI,GAAG,EAAEF;IAAc,CAAC;IAEtD,MAAMG,gCAAgC,GAAG,IAAIrB,OAAO,CAAC;MACnDsB,GAAG,EAAEJ,aAAa;MAClBK,GAAG,EAAE,IAAI,CAACf,qBAAqB;MAC/BgB,GAAG,EAAG,GAAEpB,IAAI,CAACqB,EAAE,CAAC,CAAE,EAAC;MACnBC,IAAI,EAAE,kCAAkC;MACxCC,GAAG,EAAE;QACHZ,GAAG,EAAEI;MACP;IACF,CAAC,CAAC,CACCS,kBAAkB,CAAC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IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAIpD,qCAAqC,CAC7C,mEAAmE,EAClE,kBAAiB6C,QAAQ,CAACM,MAAO,EACpC,CAAC;EACH;AACF"}
|
@@ -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
|
-
|
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,
|
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 +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,E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IAAI,OAAO,CAAC,aAAa,CAAC;IA4C5C;;;;;;;;OAQG;IACG,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB3D;;;;;;;;;;;;;OAaG;IACG,aAAa,CACjB,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,EAC1B,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,CAAC;CAsCxB"}
|
@@ -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"}
|