@pagopa/io-react-native-wallet 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/index.js +9 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rp/__test__/index.test.js +3 -5
- package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
- package/lib/commonjs/rp/index.js +17 -12
- package/lib/commonjs/rp/index.js.map +1 -1
- package/lib/commonjs/rp/types.js +9 -1
- package/lib/commonjs/rp/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +4 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rp/__test__/index.test.js +3 -5
- package/lib/module/rp/__test__/index.test.js.map +1 -1
- package/lib/module/rp/index.js +18 -13
- package/lib/module/rp/index.js.map +1 -1
- package/lib/module/rp/types.js +7 -0
- package/lib/module/rp/types.js.map +1 -1
- package/lib/module/sd-jwt/index.js +4 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/index.d.ts +1 -1
- package/lib/typescript/pid/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/rp/index.d.ts +2 -2
- package/lib/typescript/rp/index.d.ts.map +1 -1
- package/lib/typescript/rp/types.d.ts +17 -0
- package/lib/typescript/rp/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +13 -1
- package/src/pid/sd-jwt/index.ts +1 -1
- package/src/rp/__test__/index.test.ts +5 -9
- package/src/rp/index.ts +20 -20
- package/src/rp/types.ts +8 -0
- package/src/sd-jwt/index.ts +4 -1
package/lib/commonjs/index.js
CHANGED
@@ -3,13 +3,21 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.RP = exports.PID = exports.Errors = void 0;
|
7
|
+
Object.defineProperty(exports, "RelyingPartySolution", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function () {
|
10
|
+
return RP.RelyingPartySolution;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
exports.WalletInstanceAttestation = void 0;
|
7
14
|
Object.defineProperty(exports, "getUnsignedDPop", {
|
8
15
|
enumerable: true,
|
9
16
|
get: function () {
|
10
17
|
return _dpop.getUnsignedDPop;
|
11
18
|
}
|
12
19
|
});
|
20
|
+
require("react-native-url-polyfill/auto");
|
13
21
|
var PID = _interopRequireWildcard(require("./pid"));
|
14
22
|
exports.PID = PID;
|
15
23
|
var RP = _interopRequireWildcard(require("./rp"));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["require","PID","_interopRequireWildcard","exports","RP","Errors","WalletInstanceAttestation","_dpop","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAEAA,OAAA;AAEA,IAAAC,GAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA6BG,OAAA,CAAAF,GAAA,GAAAA,GAAA;AAC7B,IAAAG,EAAA,GAAAF,uBAAA,CAAAF,OAAA;AAA2BG,OAAA,CAAAC,EAAA,GAAAA,EAAA;AAC3B,IAAAC,MAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAyCG,OAAA,CAAAE,MAAA,GAAAA,MAAA;AACzC,IAAAC,yBAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAA2EG,OAAA,CAAAG,yBAAA,GAAAA,yBAAA;AAC3E,IAAAC,KAAA,GAAAP,OAAA;AAA+C,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAA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6eyJhbGdfdmFsdWVzX3N1cHBvcnRlZCI6WyJFUzI1NiJdfSwiand0X3ZjX2pzb24iOnsiYWxnX3ZhbHVlc19zdXBwb3J0ZWQiOlsiRVMyNTYiXX19LCJyZXF1ZXN0X29iamVjdF9zaWduaW5nX2FsZ192YWx1ZXNfc3VwcG9ydGVkIjpbIkVTMjU2Il0sInByZXNlbnRhdGlvbl9kZWZpbml0aW9uX3VyaV9zdXBwb3J0ZWQiOmZhbHNlLCJpYXQiOjE2ODcyODExOTUsImV4cCI6MTY4NzI4ODM5NX0.OTuPik6p3o9j6VOx-uCyxRvHwoh1pDiiZcBQFNQt2uE3dK-8izGNflJVETi_uhGSZOf25Enkq-UvEin9NrbJNw";
|
6
|
-
const rp = new _.RelyingPartySolution("http://rp.example", walletInstanceAttestation);
|
7
5
|
describe("decodeAuthRequestQR", () => {
|
8
6
|
it("should return authentication request URL", async () => {
|
9
7
|
const qrcode = "ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
|
10
|
-
const result =
|
11
|
-
expect(result).toEqual("https://verifier.example.org/request_uri");
|
8
|
+
const result = _.RelyingPartySolution.decodeAuthRequestQR(qrcode);
|
9
|
+
expect(result.requestURI).toEqual("https://verifier.example.org/request_uri");
|
12
10
|
});
|
13
11
|
it("should throw exception with invalid QR", async () => {
|
14
12
|
const qrcode = "aHR0cDovL2dvb2dsZS5pdA==";
|
15
|
-
expect(() =>
|
13
|
+
expect(() => _.RelyingPartySolution.decodeAuthRequestQR(qrcode)).toThrowError(_errors.AuthRequestDecodeError);
|
16
14
|
});
|
17
15
|
});
|
18
16
|
//# sourceMappingURL=index.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_","require","_errors","
|
1
|
+
{"version":3,"names":["_","require","_errors","describe","it","qrcode","result","RelyingPartySolution","decodeAuthRequestQR","expect","requestURI","toEqual","toThrowError","AuthRequestDecodeError"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,CAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEAE,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGC,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC;IAC/DI,MAAM,CAACH,MAAM,CAACI,UAAU,CAAC,CAACC,OAAO,CAC/B,0CACF,CAAC;EACH,CAAC,CAAC;EACFP,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCI,MAAM,CAAC,MAAMF,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC,CAAC,CAACO,YAAY,CACzEC,8BACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/commonjs/rp/index.js
CHANGED
@@ -25,18 +25,23 @@ class RelyingPartySolution {
|
|
25
25
|
* @returns The authentication request url
|
26
26
|
*
|
27
27
|
*/
|
28
|
-
decodeAuthRequestQR(qrcode) {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
static decodeAuthRequestQR(qrcode) {
|
29
|
+
const decoded = (0, _ioReactNativeJwt.decodeBase64)(qrcode);
|
30
|
+
const decodedUrl = new URL(decoded);
|
31
|
+
const protocol = decodedUrl.protocol;
|
32
|
+
const resource = decodedUrl.hostname;
|
33
|
+
const requestURI = decodedUrl.searchParams.get("request_uri");
|
34
|
+
const clientId = decodedUrl.searchParams.get("client_id");
|
35
|
+
const result = _types.QRCodePayload.safeParse({
|
36
|
+
protocol,
|
37
|
+
resource,
|
38
|
+
requestURI,
|
39
|
+
clientId
|
40
|
+
});
|
41
|
+
if (result.success) {
|
42
|
+
return result.data;
|
43
|
+
} else {
|
44
|
+
throw new _errors.AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
|
40
45
|
}
|
41
46
|
}
|
42
47
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","obj","__esModule","default","RelyingPartySolution","constructor","relyingPartyBaseUrl","walletInstanceAttestation","appFetch","arguments","length","undefined","fetch","decodeAuthRequestQR","qrcode","decoded","decodeBase64","decodedUrl","URL","
|
1
|
+
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","obj","__esModule","default","RelyingPartySolution","constructor","relyingPartyBaseUrl","walletInstanceAttestation","appFetch","arguments","length","undefined","fetch","decodeAuthRequestQR","qrcode","decoded","decodeBase64","decodedUrl","URL","protocol","resource","hostname","requestURI","searchParams","get","clientId","result","QRCodePayload","safeParse","success","data","AuthRequestDecodeError","error","message","getUnsignedWalletInstanceDPoP","walletInstanceAttestationJwk","authRequestUrl","SignJWT","jti","uuid","v4","htm","htu","ath","sha256ToBase64","setProtectedHeader","alg","jwk","typ","setIssuedAt","setExpirationTime","toSign","getRequestObject","signedWalletInstanceDPoP","decodedJwtDPop","decodeJwt","requestUri","payload","response","method","headers","Authorization","DPoP","status","responseText","text","responseJwt","requestObj","RequestObject","parse","header","protectedHeader","IoWalletError","getEntityConfiguration","wellKnownUrl","href","RpEntityConfiguration","exports"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAMA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqC,SAAAI,uBAAAC,GAAA,WAAA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AAIK,qBAAa,CACpB,mDAAkDd,QAAQ,CAACK,MAAO,EACrE,CAAC;EACH;;EAEA;AACF;AACA;EACE,MAAMU,sBAAsBA,CAAA,EAAmC;IAC7D,MAAMC,YAAY,GAAG,IAAIxD,GAAG,CAC1B,gCAAgC,EAChC,IAAI,CAACZ,mBACP,CAAC,CAACqE,IAAI;IAEN,MAAMjB,QAAQ,GAAG,MAAM,IAAI,CAAClD,QAAQ,CAACkE,YAAY,EAAE;MACjDf,MAAM,EAAE;IACV,CAAC,CAAC;IAEF,IAAID,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAMC,YAAY,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;MAC1C,MAAMC,WAAW,GAAG,MAAM,IAAAX,wBAAS,EAACS,YAAY,CAAC;MACjD,OAAOY,4BAAqB,CAACP,KAAK,CAAC;QACjCC,MAAM,EAAEJ,WAAW,CAACK,eAAe;QACnCd,OAAO,EAAES,WAAW,CAACT;MACvB,CAAC,CAAC;IACJ;IAEA,MAAM,IAAIe,qBAAa,CACpB,4DAA2Dd,QAAQ,CAACK,MAAO,EAC9E,CAAC;EACH;AACF;AAACc,OAAA,CAAAzE,oBAAA,GAAAA,oBAAA"}
|
package/lib/commonjs/rp/types.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.RpEntityConfiguration = exports.RequestObject = void 0;
|
6
|
+
exports.RpEntityConfiguration = exports.RequestObject = exports.QRCodePayload = void 0;
|
7
7
|
var _jwk = require("../utils/jwk");
|
8
8
|
var _types = require("../sd-jwt/types");
|
9
9
|
var z = _interopRequireWildcard(require("zod"));
|
@@ -69,4 +69,12 @@ const RpEntityConfiguration = z.object({
|
|
69
69
|
})
|
70
70
|
});
|
71
71
|
exports.RpEntityConfiguration = RpEntityConfiguration;
|
72
|
+
const QRCodePayload = z.object({
|
73
|
+
protocol: z.literal("eudiw:"),
|
74
|
+
resource: z.string(),
|
75
|
+
// TODO: refine to known paths using literals
|
76
|
+
clientId: z.string(),
|
77
|
+
requestURI: z.string()
|
78
|
+
});
|
79
|
+
exports.QRCodePayload = QRCodePayload;
|
72
80
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_jwk","require","_types","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestObject","object","header","typ","literal","alg","string","kid","trust_chain","array","payload","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","exports","RpEntityConfiguration","sub","jwks","keys","JWK","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,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,K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8B,MAAM,CAAC,CAAC;QACrB0B,WAAW,EAAExD,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACvBoB,IAAI,EAAElD,CAAC,CAACyB,MAAM,CAAC;UACb0B,IAAI,EAAEnD,CAAC,CAACiC,KAAK,CAACmB,QAAG;QACnB,CAAC,CAAC;QACFK,QAAQ,EAAEzD,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;MAC9B,CAAC,CAAC;MACF4B,iBAAiB,EAAE1D,CAAC,CAACyB,MAAM,CAAC;QAC1BkC,iBAAiB,EAAE3D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QAC7B8B,YAAY,EAAE5D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACxB+B,UAAU,EAAE7D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACtBgC,QAAQ,EAAE9D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACpB2B,QAAQ,EAAEzD,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;MAC9B,CAAC;IACH,CAAC,CAAC;IACFiC,eAAe,EAAE/D,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACrC,CAAC;AACH,CAAC,CAAC;AAACiB,OAAA,CAAAC,qBAAA,GAAAA,qBAAA"}
|
1
|
+
{"version":3,"names":["_jwk","require","_types","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestObject","object","header","typ","literal","alg","string","kid","trust_chain","array","payload","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","exports","RpEntityConfiguration","sub","jwks","keys","JWK","metadata","wallet_relying_party","application_type","client_name","contacts","federation_entity","organization_name","homepage_uri","policy_uri","log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C,CAAC;QACpB2B,QAAQ,EAAEzD,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;MAC9B,CAAC;IACH,CAAC,CAAC;IACFiC,eAAe,EAAE/D,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACrC,CAAC;AACH,CAAC,CAAC;AAACiB,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGI,MAAMgB,aAAa,GAAGhE,CAAC,CAACyB,MAAM,CAAC;EACpCwC,QAAQ,EAAEjE,CAAC,CAAC4B,OAAO,CAAC,QAAQ,CAAC;EAC7BsC,QAAQ,EAAElE,CAAC,CAAC8B,MAAM,CAAC,CAAC;EAAE;EACtBqC,QAAQ,EAAEnE,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACpBsC,UAAU,EAAEpE,CAAC,CAAC8B,MAAM,CAAC;AACvB,CAAC,CAAC;AAACiB,OAAA,CAAAiB,aAAA,GAAAA,aAAA"}
|
@@ -22,7 +22,10 @@ var _verifier = require("./verifier");
|
|
22
22
|
*
|
23
23
|
*/
|
24
24
|
const decode = (token, schema) => {
|
25
|
-
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN"
|
25
|
+
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN~"
|
26
|
+
if (token.slice(-1) === "~") {
|
27
|
+
token = token.slice(0, -1);
|
28
|
+
}
|
26
29
|
const [rawSdJwt = "", ...rawDisclosures] = token.split("~");
|
27
30
|
|
28
31
|
// get the sd-jwt as object
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_types","_verifier","decode","token","schema","rawSdJwt","rawDisclosures","split","decodedJwt","decodeJwt","sdJwt","parse","header","protectedHeader","payload","disclosures","map","decodeBase64","e","JSON","Disclosure","exports","verify","publicKey","decoded","verifyJwt","claims","verified_claims","verification","_sd","Promise","all","disclosure","verifyDisclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,MAAM,GAAGA,CACpBC,KAAa,EACbC,MAAS,KAC4C;EACrD;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_types","_verifier","decode","token","schema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","decodeJwt","sdJwt","parse","header","protectedHeader","payload","disclosures","map","decodeBase64","e","JSON","Disclosure","exports","verify","publicKey","decoded","verifyJwt","claims","verified_claims","verification","_sd","Promise","all","disclosure","verifyDisclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":";;;;;;AAEA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,MAAM,GAAGA,CACpBC,KAAa,EACbC,MAAS,KAC4C;EACrD;EACA,IAAID,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAC3BF,KAAK,GAAGA,KAAK,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC5B;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,GAAGJ,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;;EAE3D;EACA;EACA,MAAMC,UAAU,GAAG,IAAAC,wBAAS,EAACJ,QAAQ,CAAC;EACtC,MAAMK,KAAK,GAAGP,MAAM,CAACQ,KAAK,CAAC;IACzBC,MAAM,EAAEJ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GED
@@ -1,7 +1,11 @@
|
|
1
|
+
// polyfill due to known bugs on URL implementation for react native
|
2
|
+
// https://github.com/facebook/react-native/issues/24428
|
3
|
+
import "react-native-url-polyfill/auto";
|
1
4
|
import * as PID from "./pid";
|
2
5
|
import * as RP from "./rp";
|
3
6
|
import * as Errors from "./utils/errors";
|
4
7
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
5
8
|
import { getUnsignedDPop } from "./utils/dpop";
|
6
|
-
|
9
|
+
import { RelyingPartySolution } from "./rp";
|
10
|
+
export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, RelyingPartySolution };
|
7
11
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","getUnsignedDPop"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAO,KAAKA,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,SAASC,eAAe,QAAQ,cAAc;
|
1
|
+
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","getUnsignedDPop","RelyingPartySolution"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKA,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,SAASC,eAAe,QAAQ,cAAc;AAC9C,SAASC,oBAAoB,QAAQ,MAAM;AAE3C,SACEL,GAAG,EACHC,EAAE,EACFE,yBAAyB,EACzBD,MAAM,EACNE,eAAe,EACfC,oBAAoB"}
|
@@ -1,16 +1,14 @@
|
|
1
1
|
import { RelyingPartySolution } from "..";
|
2
2
|
import { AuthRequestDecodeError } from "../../utils/errors";
|
3
|
-
const walletInstanceAttestation = "eyJhbGciOiJFUzI1NiIsImtpZCI6IjV0NVlZcEJoTi1FZ0lFRUk1aVV6cjZyME1SMDJMblZRME9tZWttTktjalkiLCJ0cnVzdF9jaGFpbiI6WyJleUpoYkdjaU9pSkZVei4uLjZTMEEiLCJleUpoYkdjaU9pSkZVei4uLmpKTEEiLCJleUpoYkdjaU9pSkZVei4uLkg5Z3ciXSwidHlwIjoidmErand0IiwieDVjIjpbIk1JSUJqRENDIC4uLiBYRmVoZ0tRQT09Il19.eyJpc3MiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZyIsInN1YiI6InZiZVhKa3NNNDV4cGh0QU5uQ2lHNm1DeXVVNGpmR056b3BHdUt2b2dnOWMiLCJ0eXBlIjoiV2FsbGV0SW5zdGFuY2VBdHRlc3RhdGlvbiIsInBvbGljeV91cmkiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9wcml2YWN5X3BvbGljeSIsInRvc191cmkiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9pbmZvX3BvbGljeSIsImxvZ29fdXJpIjoiaHR0cHM6Ly93YWxsZXQtcHJvdmlkZXIuZXhhbXBsZS5vcmcvbG9nby5zdmciLCJhc2MiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9Mb0EvYmFzaWMiLCJjbmYiOnsiandrIjp7ImNydiI6IlAtMjU2Iiwia3R5IjoiRUMiLCJ4IjoiNEhOcHRJLXhyMnBqeVJKS0dNbno0V21kblFEX3VKU3E0Ujk1Tmo5OGI0NCIsInkiOiJMSVpuU0IzOXZGSmhZZ1MzazdqWEU0cjMtQ29HRlF3WnRQQklScXBObHJnIiwia2lkIjoidmJlWEprc000NXhwaHRBTm5DaUc2bUN5dVU0amZHTnpvcEd1S3ZvZ2c5YyJ9fSwiYXV0aG9yaXphdGlvbl9lbmRwb2ludCI6ImV1ZGl3OiIsInJlc3BvbnNlX3R5cGVzX3N1cHBvcnRlZCI6WyJ2cF90b2tlbiJdLCJ2cF9mb3JtYXRzX3N1cHBvcnRlZCI6eyJqd3RfdnBfanNvbiI6eyJhbGdfdmFsdWVzX3N1cHBvcnRlZCI6WyJFUzI1NiJdfSwiand0X3ZjX2pzb24iOnsiYWxnX3ZhbHVlc19zdXBwb3J0ZWQiOlsiRVMyNTYiXX19LCJyZXF1ZXN0X29iamVjdF9zaWduaW5nX2FsZ192YWx1ZXNfc3VwcG9ydGVkIjpbIkVTMjU2Il0sInByZXNlbnRhdGlvbl9kZWZpbml0aW9uX3VyaV9zdXBwb3J0ZWQiOmZhbHNlLCJpYXQiOjE2ODcyODExOTUsImV4cCI6MTY4NzI4ODM5NX0.OTuPik6p3o9j6VOx-uCyxRvHwoh1pDiiZcBQFNQt2uE3dK-8izGNflJVETi_uhGSZOf25Enkq-UvEin9NrbJNw";
|
4
|
-
const rp = new RelyingPartySolution("http://rp.example", walletInstanceAttestation);
|
5
3
|
describe("decodeAuthRequestQR", () => {
|
6
4
|
it("should return authentication request URL", async () => {
|
7
5
|
const qrcode = "ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
|
8
|
-
const result =
|
9
|
-
expect(result).toEqual("https://verifier.example.org/request_uri");
|
6
|
+
const result = RelyingPartySolution.decodeAuthRequestQR(qrcode);
|
7
|
+
expect(result.requestURI).toEqual("https://verifier.example.org/request_uri");
|
10
8
|
});
|
11
9
|
it("should throw exception with invalid QR", async () => {
|
12
10
|
const qrcode = "aHR0cDovL2dvb2dsZS5pdA==";
|
13
|
-
expect(() =>
|
11
|
+
expect(() => RelyingPartySolution.decodeAuthRequestQR(qrcode)).toThrowError(AuthRequestDecodeError);
|
14
12
|
});
|
15
13
|
});
|
16
14
|
//# sourceMappingURL=index.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["RelyingPartySolution","AuthRequestDecodeError","
|
1
|
+
{"version":3,"names":["RelyingPartySolution","AuthRequestDecodeError","describe","it","qrcode","result","decodeAuthRequestQR","expect","requestURI","toEqual","toThrowError"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,IAAI;AACzC,SAASC,sBAAsB,QAAQ,oBAAoB;AAE3DC,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGL,oBAAoB,CAACM,mBAAmB,CAACF,MAAM,CAAC;IAC/DG,MAAM,CAACF,MAAM,CAACG,UAAU,CAAC,CAACC,OAAO,CAC/B,0CACF,CAAC;EACH,CAAC,CAAC;EACFN,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCG,MAAM,CAAC,MAAMP,oBAAoB,CAACM,mBAAmB,CAACF,MAAM,CAAC,CAAC,CAACM,YAAY,CACzET,sBACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/module/rp/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AuthRequestDecodeError, IoWalletError } from "../utils/errors";
|
2
2
|
import { decode as decodeJwt, decodeBase64, sha256ToBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
3
|
-
import { RequestObject, RpEntityConfiguration } from "./types";
|
3
|
+
import { QRCodePayload, RequestObject, RpEntityConfiguration } from "./types";
|
4
4
|
import uuid from "react-native-uuid";
|
5
5
|
export class RelyingPartySolution {
|
6
6
|
constructor(relyingPartyBaseUrl, walletInstanceAttestation) {
|
@@ -18,18 +18,23 @@ export class RelyingPartySolution {
|
|
18
18
|
* @returns The authentication request url
|
19
19
|
*
|
20
20
|
*/
|
21
|
-
decodeAuthRequestQR(qrcode) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
static decodeAuthRequestQR(qrcode) {
|
22
|
+
const decoded = decodeBase64(qrcode);
|
23
|
+
const decodedUrl = new URL(decoded);
|
24
|
+
const protocol = decodedUrl.protocol;
|
25
|
+
const resource = decodedUrl.hostname;
|
26
|
+
const requestURI = decodedUrl.searchParams.get("request_uri");
|
27
|
+
const clientId = decodedUrl.searchParams.get("client_id");
|
28
|
+
const result = QRCodePayload.safeParse({
|
29
|
+
protocol,
|
30
|
+
resource,
|
31
|
+
requestURI,
|
32
|
+
clientId
|
33
|
+
});
|
34
|
+
if (result.success) {
|
35
|
+
return result.data;
|
36
|
+
} else {
|
37
|
+
throw new AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
|
33
38
|
}
|
34
39
|
}
|
35
40
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthRequestDecodeError","IoWalletError","decode","decodeJwt","decodeBase64","sha256ToBase64","SignJWT","RequestObject","RpEntityConfiguration","uuid","RelyingPartySolution","constructor","relyingPartyBaseUrl","walletInstanceAttestation","appFetch","arguments","length","undefined","fetch","decodeAuthRequestQR","qrcode","decoded","decodedUrl","URL","
|
1
|
+
{"version":3,"names":["AuthRequestDecodeError","IoWalletError","decode","decodeJwt","decodeBase64","sha256ToBase64","SignJWT","QRCodePayload","RequestObject","RpEntityConfiguration","uuid","RelyingPartySolution","constructor","relyingPartyBaseUrl","walletInstanceAttestation","appFetch","arguments","length","undefined","fetch","decodeAuthRequestQR","qrcode","decoded","decodedUrl","URL","protocol","resource","hostname","requestURI","searchParams","get","clientId","result","safeParse","success","data","error","message","getUnsignedWalletInstanceDPoP","walletInstanceAttestationJwk","authRequestUrl","jti","v4","htm","htu","ath","setProtectedHeader","alg","jwk","typ","setIssuedAt","setExpirationTime","toSign","getRequestObject","signedWalletInstanceDPoP","decodedJwtDPop","requestUri","payload","response","method","headers","Authorization","DPoP","status","responseText","text","responseJwt","requestObj","parse","header","protectedHeader","getEntityConfiguration","wellKnownUrl","href"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":"AAAA,SAASA,sBAAsB,EAAEC,aAAa,QAAQ,iBAAiB;AACvE,SACEC,MAAM,IAAIC,SAAS,EACnBC,YAAY,EACZC,cAAc,EACdC,OAAO,QACF,6BAA6B;AACpC,SAASC,aAAa,EAAEC,aAAa,EAAEC,qBAAqB,QAAQ,SAAS;AAE7E,OAAOC,IAAI,MAAM,mBAAmB;AAGpC,OAAO,MAAMC,oBAAoB,CAAC;EAKhCC,WAAWA,CACTC,mBAA2B,EAC3BC,yBAAiC,EAEjC;IAAA,IADAC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,KAAK;IAEtC,IAAI,CAACN,mBAAmB,GAAGA,mBAAmB;IAC9C,IAAI,CAACC,yBAAyB,GAAGA,yBAAyB;IAC1D,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOK,mBAAmBA,CAACC,MAAc,EAAiB;IACxD,MAAMC,OAAO,GAAGlB,YAAY,CAACiB,MAAM,CAAC;IACpC,MAAME,UAAU,GAAG,IAAIC,GAAG,CAACF,OAAO,CAAC;IACnC,MAAMG,QAAQ,GAAGF,UAAU,CAACE,QAAQ;IACpC,MAAMC,QAAQ,GAAGH,UAAU,CAACI,QAAQ;IACpC,MAAMC,UAAU,GAAGL,UAAU,CAACM,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;IAC7D,MAAMC,QAAQ,GAAGR,UAAU,CAACM,YAAY,CAACC,GAAG,CAAC,WAAW,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gD,IAAI,EAAER;MACR;IACF,CAAC,CAAC;IAEF,IAAII,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAMC,YAAY,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;MAC1C,MAAMC,WAAW,GAAG,MAAM/D,SAAS,CAAC6D,YAAY,CAAC;MACjD,MAAMG,UAAU,GAAG3D,aAAa,CAAC4D,KAAK,CAAC;QACrCC,MAAM,EAAEH,WAAW,CAACI,eAAe;QACnCb,OAAO,EAAES,WAAW,CAACT;MACvB,CAAC,CAAC;MACF,OAAOU,UAAU;IACnB;IAEA,MAAM,IAAIlE,aAAa,CACpB,mDAAkDyD,QAAQ,CAACK,MAAO,EACrE,CAAC;EACH;;EAEA;AACF;AACA;EACE,MAAMQ,sBAAsBA,CAAA,EAAmC;IAC7D,MAAMC,YAAY,GAAG,IAAIhD,GAAG,CAC1B,gCAAgC,EAChC,IAAI,CAACX,mBACP,CAAC,CAAC4D,IAAI;IAEN,MAAMf,QAAQ,GAAG,MAAM,IAAI,CAAC3C,QAAQ,CAACyD,YAAY,EAAE;MACjDb,MAAM,EAAE;IACV,CAAC,CAAC;IAEF,IAAID,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAMC,YAAY,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;MAC1C,MAAMC,WAAW,GAAG,MAAM/D,SAAS,CAAC6D,YAAY,CAAC;MACjD,OAAOvD,qBAAqB,CAAC2D,KAAK,CAAC;QACjCC,MAAM,EAAEH,WAAW,CAACI,eAAe;QACnCb,OAAO,EAAES,WAAW,CAACT;MACvB,CAAC,CAAC;IACJ;IAEA,MAAM,IAAIxD,aAAa,CACpB,4DAA2DyD,QAAQ,CAACK,MAAO,EAC9E,CAAC;EACH;AACF"}
|
package/lib/module/rp/types.js
CHANGED
@@ -60,4 +60,11 @@ export const RpEntityConfiguration = z.object({
|
|
60
60
|
authority_hints: z.array(z.string())
|
61
61
|
})
|
62
62
|
});
|
63
|
+
export const QRCodePayload = z.object({
|
64
|
+
protocol: z.literal("eudiw:"),
|
65
|
+
resource: z.string(),
|
66
|
+
// TODO: refine to known paths using literals
|
67
|
+
clientId: z.string(),
|
68
|
+
requestURI: z.string()
|
69
|
+
});
|
63
70
|
//# sourceMappingURL=types.js.map
|
@@ -1 +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,EAAET,CAAC,CAACU,KAAK,CAACV,CAAC,CAACO,MAAM,CAAC,CAAC;EACjC,CAAC,CAAC;EACFI,OAAO,EAAEX,CAAC,CAACE,MAAM,CAAC;IAChBU,GAAG,EAAEZ,CAAC,CAACO,MAAM,CAAC,CAAC;IACfM,GAAG,EAAEd,QAAQ;IACbe,GAAG,EAAEf,QAAQ;IACbgB,KAAK,EAAEf,CAAC,CAACO,MAAM,CAAC,CAAC;IACjBS,KAAK,EAAEhB,CAAC,CAACO,MAAM,CAAC,CAAC;IACjBU,YAAY,EAAEjB,CAAC,CAACO,MA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B,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"}
|
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","QRCodePayload","protocol","resource","clientId","requestURI"],"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,C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AAC,CAACO,MAAM,CAAC,CAAC;EAAE;EACtBkC,QAAQ,EAAEzC,CAAC,CAACO,MAAM,CAAC,CAAC;EACpBmC,UAAU,EAAE1C,CAAC,CAACO,MAAM,CAAC;AACvB,CAAC,CAAC"}
|
@@ -18,7 +18,10 @@ import { verifyDisclosure } from "./verifier";
|
|
18
18
|
*
|
19
19
|
*/
|
20
20
|
export const decode = (token, schema) => {
|
21
|
-
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN"
|
21
|
+
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN~"
|
22
|
+
if (token.slice(-1) === "~") {
|
23
|
+
token = token.slice(0, -1);
|
24
|
+
}
|
22
25
|
const [rawSdJwt = "", ...rawDisclosures] = token.split("~");
|
23
26
|
|
24
27
|
// get the sd-jwt as object
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","decodeBase64","Disclosure","verifyDisclosure","token","schema","rawSdJwt","rawDisclosures","split","decodedJwt","sdJwt","parse","header","protectedHeader","payload","disclosures","map","e","JSON","publicKey","decoded","claims","verified_claims","verification","_sd","Promise","all","disclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":"AAEA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AAEjE,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,gBAAgB,QAAQ,YAAY;AAG7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMN,MAAM,GAAGA,CACpBO,KAAa,EACbC,MAAS,KAC4C;EACrD;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,
|
1
|
+
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","decodeBase64","Disclosure","verifyDisclosure","token","schema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","sdJwt","parse","header","protectedHeader","payload","disclosures","map","e","JSON","publicKey","decoded","claims","verified_claims","verification","_sd","Promise","all","disclosure"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":"AAEA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AAEjE,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,gBAAgB,QAAQ,YAAY;AAG7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMN,MAAM,GAAGA,CACpBO,KAAa,EACbC,MAAS,KAC4C;EACrD;EACA,IAAID,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAC3BF,KAAK,GAAGA,KAAK,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC5B;EACA,MAAM,CAACC,QAAQ,GAAG,EAAE,EAAE,GAAGC,cAAc,CAAC,GAAGJ,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;;EAE3D;EACA;EACA,MAAMC,UAAU,GAAGZ,SAAS,CAACS,QAAQ,CAAC;EACtC,MAAMI,KAAK,GAAGN,MAAM,CAACO,KAAK,CAAC;IACzBC,MAAM,EAAEH,UAAU,CAACI,eAAe;IAClCC,OAAO,EAAEL,UAAU,CAACK;EACtB,CAAC,CAAC;;EAEF;EACA;EACA;EACA,MAAMC,WAAW,GAAGR,cAAc,CAC/BS,GAAG,CAAChB,YAAY,CAAC,CACjBgB,GAAG,CAAEC,CAAC,IAAKC,IAAI,CAACP,KAAK,CAACM,CAAC,CAAC,CAAC,CACzBD,GAAG,CAAEC,CAAC,IAAKhB,UAAU,CAACU,KAAK,CAACM,CAAC,CAAC,CAAC;EAElC,OAAO;IAAEP,KAAK;IAAEK;EAAY,CAAC;AAC/B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMjB,MAAM,GAAG,MAAAA,CACpBK,KAAa,EACbgB,SAAc,EACdf,MAAS,KACqD;EAC9D;EACA,MAAM,CAACE,QAAQ,GAAG,EAAE,CAAC,GAAGH,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;EACxC,MAAMY,OAAO,GAAGxB,MAAM,CAACO,KAAK,EAAEC,MAAM,CAAC;;EAErC;EACA,MAAML,SAAS,CAACO,QAAQ,EAAEa,SAAS,CAAC;;EAEpC;EACA,MAAME,MAAM,GAAG,CACb,GAAGD,OAAO,CAACV,KAAK,CAACI,OAAO,CAACQ,eAAe,CAACC,YAAY,CAACC,GAAG,EACzD,GAAGJ,OAAO,CAACV,KAAK,CAACI,OAAO,CAACQ,eAAe,CAACD,MAAM,CAACG,GAAG,CACpD;EAED,MAAMC,OAAO,CAACC,GAAG,CACfN,OAAO,CAACL,WAAW,CAACC,GAAG,CACrB,MAAOW,UAAU,IAAK,MAAMzB,gBAAgB,CAACyB,UAAU,EAAEN,MAAM,CACjE,CACF,CAAC;EAED,OAAOD,OAAO;AAChB,CAAC"}
|
@@ -1,7 +1,9 @@
|
|
1
|
+
import "react-native-url-polyfill/auto";
|
1
2
|
import * as PID from "./pid";
|
2
3
|
import * as RP from "./rp";
|
3
4
|
import * as Errors from "./utils/errors";
|
4
5
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
5
6
|
import { getUnsignedDPop } from "./utils/dpop";
|
6
|
-
|
7
|
+
import { RelyingPartySolution } from "./rp";
|
8
|
+
export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, RelyingPartySolution, };
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
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;AAE5C,OAAO,EACL,GAAG,EACH,EAAE,EACF,yBAAyB,EACzB,MAAM,EACN,eAAe,EACf,oBAAoB,GACrB,CAAC"}
|
@@ -37,7 +37,7 @@ export declare function decode(token: string): PidWithToken;
|
|
37
37
|
*
|
38
38
|
*/
|
39
39
|
export declare function verify(token: string): Promise<VerifyResult>;
|
40
|
-
type PidWithToken = {
|
40
|
+
export type PidWithToken = {
|
41
41
|
pid: PID;
|
42
42
|
sdJwt: SdJwt4VC;
|
43
43
|
disclosures: Disclosure[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pid/sd-jwt/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAKlD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAMjE;AAED,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pid/sd-jwt/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAKlD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAMjE;AAED,MAAM,MAAM,YAAY,GAAG;IAEzB,GAAG,EAAE,GAAG,CAAC;IAET,KAAK,EAAE,QAAQ,CAAC;IAEhB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { RequestObject, RpEntityConfiguration } from "./types";
|
1
|
+
import { QRCodePayload, RequestObject, RpEntityConfiguration } from "./types";
|
2
2
|
import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
|
3
3
|
export declare class RelyingPartySolution {
|
4
4
|
relyingPartyBaseUrl: string;
|
@@ -13,7 +13,7 @@ export declare class RelyingPartySolution {
|
|
13
13
|
* @returns The authentication request url
|
14
14
|
*
|
15
15
|
*/
|
16
|
-
decodeAuthRequestQR(qrcode: string):
|
16
|
+
static decodeAuthRequestQR(qrcode: string): QRCodePayload;
|
17
17
|
/**
|
18
18
|
* Obtain the unsigned wallet instance DPoP for authentication request
|
19
19
|
*
|
@@ -1 +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;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rp/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG9E,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,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;;;;;;;;OAQG;IACG,gBAAgB,CACpB,wBAAwB,EAAE,MAAM,GAC/B,OAAO,CAAC,aAAa,CAAC;IA0BzB;;OAEG;IACG,sBAAsB,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAuB/D"}
|
@@ -837,4 +837,21 @@ export declare const RpEntityConfiguration: z.ZodObject<{
|
|
837
837
|
authority_hints: string[];
|
838
838
|
};
|
839
839
|
}>;
|
840
|
+
export type QRCodePayload = z.infer<typeof QRCodePayload>;
|
841
|
+
export declare const QRCodePayload: z.ZodObject<{
|
842
|
+
protocol: z.ZodLiteral<"eudiw:">;
|
843
|
+
resource: z.ZodString;
|
844
|
+
clientId: z.ZodString;
|
845
|
+
requestURI: z.ZodString;
|
846
|
+
}, "strip", z.ZodTypeAny, {
|
847
|
+
protocol: "eudiw:";
|
848
|
+
resource: string;
|
849
|
+
clientId: string;
|
850
|
+
requestURI: string;
|
851
|
+
}, {
|
852
|
+
protocol: "eudiw:";
|
853
|
+
resource: string;
|
854
|
+
clientId: string;
|
855
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkChC,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sd-jwt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,oCACV,MAAM;;iBAEsB,UAAU,EAAE;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sd-jwt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,oCACV,MAAM;;iBAEsB,UAAU,EAAE;CAwBhD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,oCACV,MAAM,aACF,GAAG;;iBAE6B,UAAU,EAAE;EAqBxD,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.2",
|
4
4
|
"description": "Provide data structures, helpers and API for IO Wallet",
|
5
5
|
"main": "lib/commonjs/index",
|
6
6
|
"module": "lib/module/index",
|
@@ -52,6 +52,7 @@
|
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
54
|
"@pagopa/eslint-config": "^3.0.0",
|
55
|
+
"@pagopa/io-react-native-crypto": "^0.2.3",
|
55
56
|
"@pagopa/io-react-native-jwt": "^0.4.0",
|
56
57
|
"@react-native-community/eslint-config": "^3.2.0",
|
57
58
|
"@rushstack/eslint-patch": "^1.3.2",
|
@@ -66,15 +67,14 @@
|
|
66
67
|
"react": "18.2.0",
|
67
68
|
"react-native": "0.71.8",
|
68
69
|
"react-native-builder-bob": "^0.20.0",
|
69
|
-
"typescript": "^5.0.2"
|
70
|
-
"@pagopa/io-react-native-crypto": "^0.2.3"
|
70
|
+
"typescript": "^5.0.2"
|
71
71
|
},
|
72
72
|
"resolutions": {
|
73
73
|
"@types/react": "17.0.21"
|
74
74
|
},
|
75
75
|
"peerDependencies": {
|
76
|
-
"@pagopa/io-react-native-jwt": "*",
|
77
76
|
"@pagopa/io-react-native-crypto": "*",
|
77
|
+
"@pagopa/io-react-native-jwt": "*",
|
78
78
|
"react": "*",
|
79
79
|
"react-native": "*"
|
80
80
|
},
|
@@ -104,6 +104,7 @@
|
|
104
104
|
]
|
105
105
|
},
|
106
106
|
"dependencies": {
|
107
|
+
"react-native-url-polyfill": "^2.0.0",
|
107
108
|
"react-native-uuid": "^2.0.1",
|
108
109
|
"zod": "^3.21.4"
|
109
110
|
}
|
package/src/index.ts
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
+
// polyfill due to known bugs on URL implementation for react native
|
2
|
+
// https://github.com/facebook/react-native/issues/24428
|
3
|
+
import "react-native-url-polyfill/auto";
|
4
|
+
|
1
5
|
import * as PID from "./pid";
|
2
6
|
import * as RP from "./rp";
|
3
7
|
import * as Errors from "./utils/errors";
|
4
8
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
5
9
|
import { getUnsignedDPop } from "./utils/dpop";
|
10
|
+
import { RelyingPartySolution } from "./rp";
|
6
11
|
|
7
|
-
export {
|
12
|
+
export {
|
13
|
+
PID,
|
14
|
+
RP,
|
15
|
+
WalletInstanceAttestation,
|
16
|
+
Errors,
|
17
|
+
getUnsignedDPop,
|
18
|
+
RelyingPartySolution,
|
19
|
+
};
|
package/src/pid/sd-jwt/index.ts
CHANGED
@@ -54,7 +54,7 @@ export async function verify(token: string): Promise<VerifyResult> {
|
|
54
54
|
return decoded;
|
55
55
|
}
|
56
56
|
|
57
|
-
type PidWithToken = {
|
57
|
+
export type PidWithToken = {
|
58
58
|
// The object with the parsed data for PID
|
59
59
|
pid: PID;
|
60
60
|
// The object with the parsed SD-JWT token that shipped the PID. It will be needed to present PID data.
|
@@ -1,22 +1,18 @@
|
|
1
1
|
import { RelyingPartySolution } from "..";
|
2
2
|
import { AuthRequestDecodeError } from "../../utils/errors";
|
3
3
|
|
4
|
-
const walletInstanceAttestation =
|
5
|
-
"eyJhbGciOiJFUzI1NiIsImtpZCI6IjV0NVlZcEJoTi1FZ0lFRUk1aVV6cjZyME1SMDJMblZRME9tZWttTktjalkiLCJ0cnVzdF9jaGFpbiI6WyJleUpoYkdjaU9pSkZVei4uLjZTMEEiLCJleUpoYkdjaU9pSkZVei4uLmpKTEEiLCJleUpoYkdjaU9pSkZVei4uLkg5Z3ciXSwidHlwIjoidmErand0IiwieDVjIjpbIk1JSUJqRENDIC4uLiBYRmVoZ0tRQT09Il19.eyJpc3MiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZyIsInN1YiI6InZiZVhKa3NNNDV4cGh0QU5uQ2lHNm1DeXVVNGpmR056b3BHdUt2b2dnOW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p3o9j6VOx-uCyxRvHwoh1pDiiZcBQFNQt2uE3dK-8izGNflJVETi_uhGSZOf25Enkq-UvEin9NrbJNw";
|
6
|
-
const rp = new RelyingPartySolution(
|
7
|
-
"http://rp.example",
|
8
|
-
walletInstanceAttestation
|
9
|
-
);
|
10
4
|
describe("decodeAuthRequestQR", () => {
|
11
5
|
it("should return authentication request URL", async () => {
|
12
6
|
const qrcode =
|
13
7
|
"ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
|
14
|
-
const result =
|
15
|
-
expect(result).toEqual(
|
8
|
+
const result = RelyingPartySolution.decodeAuthRequestQR(qrcode);
|
9
|
+
expect(result.requestURI).toEqual(
|
10
|
+
"https://verifier.example.org/request_uri"
|
11
|
+
);
|
16
12
|
});
|
17
13
|
it("should throw exception with invalid QR", async () => {
|
18
14
|
const qrcode = "aHR0cDovL2dvb2dsZS5pdA==";
|
19
|
-
expect(() =>
|
15
|
+
expect(() => RelyingPartySolution.decodeAuthRequestQR(qrcode)).toThrowError(
|
20
16
|
AuthRequestDecodeError
|
21
17
|
);
|
22
18
|
});
|
package/src/rp/index.ts
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
sha256ToBase64,
|
6
6
|
SignJWT,
|
7
7
|
} from "@pagopa/io-react-native-jwt";
|
8
|
-
import { RequestObject, RpEntityConfiguration } from "./types";
|
8
|
+
import { QRCodePayload, RequestObject, RpEntityConfiguration } from "./types";
|
9
9
|
|
10
10
|
import uuid from "react-native-uuid";
|
11
11
|
import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
|
@@ -33,24 +33,25 @@ export class RelyingPartySolution {
|
|
33
33
|
* @returns The authentication request url
|
34
34
|
*
|
35
35
|
*/
|
36
|
-
decodeAuthRequestQR(qrcode: string):
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
36
|
+
static decodeAuthRequestQR(qrcode: string): QRCodePayload {
|
37
|
+
const decoded = decodeBase64(qrcode);
|
38
|
+
const decodedUrl = new URL(decoded);
|
39
|
+
const protocol = decodedUrl.protocol;
|
40
|
+
const resource = decodedUrl.hostname;
|
41
|
+
const requestURI = decodedUrl.searchParams.get("request_uri");
|
42
|
+
const clientId = decodedUrl.searchParams.get("client_id");
|
43
|
+
|
44
|
+
const result = QRCodePayload.safeParse({
|
45
|
+
protocol,
|
46
|
+
resource,
|
47
|
+
requestURI,
|
48
|
+
clientId,
|
49
|
+
});
|
50
|
+
|
51
|
+
if (result.success) {
|
52
|
+
return result.data;
|
53
|
+
} else {
|
54
|
+
throw new AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
|
54
55
|
}
|
55
56
|
}
|
56
57
|
/**
|
@@ -97,7 +98,6 @@ export class RelyingPartySolution {
|
|
97
98
|
): Promise<RequestObject> {
|
98
99
|
const decodedJwtDPop = await decodeJwt(signedWalletInstanceDPoP);
|
99
100
|
const requestUri = decodedJwtDPop.payload.htu as string;
|
100
|
-
|
101
101
|
const response = await this.appFetch(requestUri, {
|
102
102
|
method: "GET",
|
103
103
|
headers: {
|
package/src/rp/types.ts
CHANGED
@@ -62,3 +62,11 @@ export const RpEntityConfiguration = z.object({
|
|
62
62
|
authority_hints: z.array(z.string()),
|
63
63
|
}),
|
64
64
|
});
|
65
|
+
|
66
|
+
export type QRCodePayload = z.infer<typeof QRCodePayload>;
|
67
|
+
export const QRCodePayload = z.object({
|
68
|
+
protocol: z.literal("eudiw:"),
|
69
|
+
resource: z.string(), // TODO: refine to known paths using literals
|
70
|
+
clientId: z.string(),
|
71
|
+
requestURI: z.string(),
|
72
|
+
});
|
package/src/sd-jwt/index.ts
CHANGED
@@ -26,7 +26,10 @@ export const decode = <S extends z.AnyZodObject>(
|
|
26
26
|
token: string,
|
27
27
|
schema: S
|
28
28
|
): { sdJwt: z.infer<S>; disclosures: Disclosure[] } => {
|
29
|
-
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN"
|
29
|
+
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN~"
|
30
|
+
if (token.slice(-1) === "~") {
|
31
|
+
token = token.slice(0, -1);
|
32
|
+
}
|
30
33
|
const [rawSdJwt = "", ...rawDisclosures] = token.split("~");
|
31
34
|
|
32
35
|
// get the sd-jwt as object
|