@pagopa/io-react-native-wallet 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +98 -22
- package/lib/commonjs/index.js +12 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/index.js +3 -8
- package/lib/commonjs/pid/index.js.map +1 -1
- package/lib/commonjs/pid/issuing.js +152 -168
- package/lib/commonjs/pid/issuing.js.map +1 -1
- package/lib/commonjs/pid/metadata.js +28 -25
- package/lib/commonjs/pid/metadata.js.map +1 -1
- package/lib/commonjs/rp/__test__/index.test.js +5 -3
- package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
- package/lib/commonjs/rp/index.js +158 -154
- package/lib/commonjs/rp/index.js.map +1 -1
- package/lib/commonjs/trust/types.js +9 -7
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +46 -0
- package/lib/commonjs/utils/crypto.js.map +1 -0
- package/lib/commonjs/utils/dpop.js +14 -7
- package/lib/commonjs/utils/dpop.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +50 -60
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/index.js +1 -1
- package/lib/module/pid/index.js.map +1 -1
- package/lib/module/pid/issuing.js +151 -171
- package/lib/module/pid/issuing.js.map +1 -1
- package/lib/module/pid/metadata.js +28 -25
- package/lib/module/pid/metadata.js.map +1 -1
- package/lib/module/rp/__test__/index.test.js +1 -1
- package/lib/module/rp/__test__/index.test.js.map +1 -1
- package/lib/module/rp/index.js +155 -153
- package/lib/module/rp/index.js.map +1 -1
- package/lib/module/trust/types.js +7 -6
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/crypto.js +40 -0
- package/lib/module/utils/crypto.js.map +1 -0
- package/lib/module/utils/dpop.js +13 -5
- package/lib/module/utils/dpop.js.map +1 -1
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +48 -58
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/index.d.ts +1 -1
- package/lib/typescript/pid/index.d.ts.map +1 -1
- package/lib/typescript/pid/issuing.d.ts +51 -87
- package/lib/typescript/pid/issuing.d.ts.map +1 -1
- package/lib/typescript/pid/metadata.d.ts +1338 -408
- package/lib/typescript/pid/metadata.d.ts.map +1 -1
- package/lib/typescript/rp/index.d.ts +48 -86
- package/lib/typescript/rp/index.d.ts.map +1 -1
- package/lib/typescript/rp/types.d.ts +413 -57
- package/lib/typescript/rp/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +1 -1
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +1000 -274
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +10 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -0
- package/lib/typescript/utils/dpop.d.ts +10 -2
- package/lib/typescript/utils/dpop.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -31
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +5 -3
- package/src/pid/index.ts +1 -1
- package/src/pid/issuing.ts +233 -225
- package/src/pid/metadata.ts +32 -27
- package/src/rp/__test__/index.test.ts +1 -1
- package/src/rp/index.ts +180 -188
- package/src/sd-jwt/index.ts +1 -1
- package/src/trust/types.ts +39 -32
- package/src/utils/crypto.ts +41 -0
- package/src/utils/dpop.ts +17 -7
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +55 -62
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","_sdJwt","_trust","obj","__esModule","default","
|
1
|
+
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","_sdJwt","_trust","_dpop","_2","obj","__esModule","default","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","payload","metadata","wallet_relying_party","jwks","filter","jwk","use","kty","NoSuitableKeysFoundInEntityConfiguration","getEntityConfiguration","appFetch","fetch","arguments","length","undefined","relyingPartyBaseUrl","getGenericEntityConfiguration","then","RpEntityConfiguration","parse","exports","decodeAuthRequestQR","qrcode","decoded","decodeBase64","decodedUrl","URL","protocol","resource","hostname","requestURI","searchParams","get","clientId","result","QRCodePayload","safeParse","success","data","AuthRequestDecodeError","error","message","getRequestObject","_ref","wiaCryptoContext","walletInstanceAttestation","requestUri","rpEntityConfiguration","signedWalletInstanceDPoP","createDPopToken","jti","uuid","v4","htm","htu","ath","sha256ToBase64","response","method","headers","Authorization","DPoP","status","responseJson","json","responseEncodedJwt","responseJwt","decodeJwt","pubKey","find","_ref2","kid","protectedHeader","verify","requestObject","RequestObject","header","IoWalletError","text","prepareVpToken","_ref3","pidCryptoContext","_ref4","_ref5","vc","claims","token","vp","paths","disclose","iss","WalletInstanceAttestation","decode","pidKid","getPublicKey","_","vp_token","SignJWT","setProtectedHeader","typ","setPayload","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","_ref6","_ref7","presentation","authzResponsePayload","JSON","stringify","state","encrypted","EncryptJwe","alg","enc","encrypt","formBody","URLSearchParams","body","toString"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA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AE1E,QAAQ,EAAEoE;IAAU,CAAC,CAAC;IAC7D,MAAMO,IAAI,GAAGF,QAAQ,CAACG,QAAQ,CAAC,CAAC;IAEhC,MAAM5E,QAAQ,GAAG,MAAM/C,QAAQ,CAACgE,aAAa,CAAC1E,OAAO,CAACuG,YAAY,EAAE;MAClE7C,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDyE;IACF,CAAC,CAAC;IAEF,IAAI3E,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,OAAO,MAAML,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAIa,qBAAa,CACpB,oDAAmD,MAAMpB,QAAQ,CAACqB,IAAI,CAAC,CAAE,eACxErB,QAAQ,CAACK,MACV,EACH,CAAC;EACH,CAAC;AAAA;AAAC1C,OAAA,CAAAiG,yBAAA,GAAAA,yBAAA"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.TrustMark = exports.TrustAnchorEntityConfiguration = exports.EntityStatement = exports.EntityConfiguration = void 0;
|
6
|
+
exports.TrustMark = exports.TrustAnchorEntityConfiguration = exports.EntityStatement = exports.EntityConfigurationHeader = exports.EntityConfiguration = void 0;
|
7
7
|
var _types = require("../sd-jwt/types");
|
8
8
|
var _jwk = require("../utils/jwk");
|
9
9
|
var z = _interopRequireWildcard(require("zod"));
|
@@ -32,12 +32,14 @@ const EntityStatement = z.object({
|
|
32
32
|
})
|
33
33
|
});
|
34
34
|
exports.EntityStatement = EntityStatement;
|
35
|
+
const EntityConfigurationHeader = z.object({
|
36
|
+
typ: z.literal("entity-statement+jwt"),
|
37
|
+
alg: z.string(),
|
38
|
+
kid: z.string()
|
39
|
+
});
|
40
|
+
exports.EntityConfigurationHeader = EntityConfigurationHeader;
|
35
41
|
const EntityConfiguration = z.object({
|
36
|
-
header:
|
37
|
-
typ: z.literal("entity-statement+jwt"),
|
38
|
-
alg: z.string(),
|
39
|
-
kid: z.string()
|
40
|
-
}),
|
42
|
+
header: EntityConfigurationHeader,
|
41
43
|
payload: z.object({
|
42
44
|
exp: _types.UnixTime,
|
43
45
|
iat: _types.UnixTime,
|
@@ -60,7 +62,7 @@ const EntityConfiguration = z.object({
|
|
60
62
|
}).passthrough()
|
61
63
|
}).passthrough(),
|
62
64
|
authority_hints: z.array(z.string()).optional()
|
63
|
-
})
|
65
|
+
}).passthrough()
|
64
66
|
});
|
65
67
|
exports.EntityConfiguration = EntityConfiguration;
|
66
68
|
const TrustAnchorEntityConfiguration = EntityConfiguration;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","EntityStatement","header","typ","literal","alg","kid","payload","iss","sub","jwks","keys","array","JWK","trust_marks","iat","number","exp","EntityConfiguration","UnixTime","metadata","federation_entity","federation_fetch_endpoint","optional","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","contacts","passthrough","authority_hints","TrustAnchorEntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,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,KAA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GAAG,EAAEhC,CAAC,CAACiC,OAAO,CAAC,sBAAsB,CAAC;IACtCC,GAAG,EAAElC,CAAC,CAAC2B,MAAM,CAAC,CAAC;IACfQ,GAAG,EAAEnC,CAAC,CAAC2B,MAAM,CAAC;EAChB,CAAC,CAAC;EACFS,OAAO,EAAEpC,CAAC,CAACyB,MAAM,CAAC;IAChBY,GAAG,EAAErC,CAAC,CAAC2B,MAAM,CAAC,CAAC;IACfW,GAAG,EAAEtC,CAAC,CAAC2B,MAAM,CAAC,CAAC;IACfY,IAAI,EAAEvC,CAAC,CAACyB,MAAM,CAAC;MAAEe,IAAI,EAAExC,CAAC,CAACyC,KAAK,CAACC,QAAG;IAAE,CAAC,CAAC;IACtCC,WAAW,EAAE3C,CAAC,CAACyC,KAAK,CAACjB,SAAS,CAAC;IAC/BoB,GAAG,EAAE5C,CAAC,CAAC6C,MAAM,CAAC,CAAC;IACfC,GAAG,EAAE9C,CAAC,CAAC6C,MAAM,CAAC;EAChB,CAAC;AACH,CAAC,CAAC;AAAChB,OAAA,CAAAC,eAAA,GAAAA,eAAA;
|
1
|
+
{"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","EntityStatement","header","typ","literal","alg","kid","payload","iss","sub","jwks","keys","array","JWK","trust_marks","iat","number","exp","EntityConfigurationHeader","EntityConfiguration","UnixTime","metadata","federation_entity","federation_fetch_endpoint","optional","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","contacts","passthrough","authority_hints","TrustAnchorEntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;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C,CAAC,CAAC0B,QAAQ,CAAC;MACzC,CAAC,CAAC,CACDS,WAAW,CAAC;IACjB,CAAC,CAAC,CACDA,WAAW,CAAC,CAAC;IAChBC,eAAe,EAAE/D,CAAC,CAACyC,KAAK,CAACzC,CAAC,CAAC2B,MAAM,CAAC,CAAC,CAAC,CAAC0B,QAAQ,CAAC;EAChD,CAAC,CAAC,CACDS,WAAW,CAAC;AACjB,CAAC,CAAC;AAACjC,OAAA,CAAAmB,mBAAA,GAAAA,mBAAA;AAKI,MAAMgB,8BAA8B,GAAGhB,mBAAmB;AAACnB,OAAA,CAAAmC,8BAAA,GAAAA,8BAAA"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createCryptoContextFor = void 0;
|
7
|
+
var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
8
|
+
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
9
|
+
var _jwk = require("./jwk");
|
10
|
+
/**
|
11
|
+
* Create a CryptoContext bound to a key pair.
|
12
|
+
* Key pair is supposed to exist already in the device's keychain.
|
13
|
+
* It's identified by its unique keytag.
|
14
|
+
*
|
15
|
+
* @returns the crypto context
|
16
|
+
*/
|
17
|
+
const createCryptoContextFor = keytag => {
|
18
|
+
return {
|
19
|
+
/**
|
20
|
+
* Retrieve the public key of the pair.
|
21
|
+
* If the key pair doesn't exist yet, an error is raised
|
22
|
+
* @returns The public key.
|
23
|
+
*/
|
24
|
+
async getPublicKey() {
|
25
|
+
return (0, _ioReactNativeCrypto.getPublicKey)(keytag).then(_jwk.fixBase64EncodingOnKey).then(async jwk => ({
|
26
|
+
...jwk,
|
27
|
+
// Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
|
28
|
+
// (that is, KID is not a propoerty of the key itself, but it's property used to identify a key in a set).
|
29
|
+
// We assume the convention we use the thumbprint of the public key as KID, thus for easy development we decided to evaluate KID here
|
30
|
+
// However the values is an arbitrary string that might be anything
|
31
|
+
kid: await (0, _ioReactNativeJwt.thumbprint)(jwk)
|
32
|
+
}));
|
33
|
+
},
|
34
|
+
/**
|
35
|
+
* Get a signature for a provided value.
|
36
|
+
* If the key pair doesn't exist yet, an error is raised.
|
37
|
+
* @param value
|
38
|
+
* @returns The signature for the value
|
39
|
+
*/
|
40
|
+
async getSignature(value) {
|
41
|
+
return (0, _ioReactNativeCrypto.sign)(value, keytag);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
};
|
45
|
+
exports.createCryptoContextFor = createCryptoContextFor;
|
46
|
+
//# sourceMappingURL=crypto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_ioReactNativeCrypto","require","_ioReactNativeJwt","_jwk","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAO,IAAAA,iCAAY,EAACD,MAAM,CAAC,CACxBE,IAAI,CAACC,2BAAsB,CAAC,CAC5BD,IAAI,CAAC,MAAOE,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAM,IAAAC,4BAAU,EAACF,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMG,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAO,IAAAC,yBAAI,EAACD,KAAK,EAAER,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;AAACU,OAAA,CAAAX,sBAAA,GAAAA,sBAAA"}
|
@@ -3,20 +3,27 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.createDPopToken = exports.DPoPPayload = void 0;
|
7
7
|
var z = _interopRequireWildcard(require("zod"));
|
8
8
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
9
9
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
10
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
/**
|
12
|
+
* Create a signed DPoP token
|
13
|
+
*
|
14
|
+
* @param payload The payload to be included in the token.
|
15
|
+
* @param crypto The crypto context that handles the key bound to the DPoP.
|
16
|
+
*
|
17
|
+
* @returns The signed crypto token.
|
18
|
+
*/
|
19
|
+
const createDPopToken = async (payload, crypto) => {
|
20
|
+
const jwk = await crypto.getPublicKey();
|
21
|
+
return new _ioReactNativeJwt.SignJWT(crypto).setPayload(payload).setProtectedHeader({
|
14
22
|
typ: "dpop+jwt",
|
15
23
|
jwk
|
16
|
-
}).setIssuedAt().setExpirationTime("1h").
|
17
|
-
return dPop;
|
24
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
18
25
|
};
|
19
|
-
exports.
|
26
|
+
exports.createDPopToken = createDPopToken;
|
20
27
|
const DPoPPayload = z.object({
|
21
28
|
jti: z.string(),
|
22
29
|
htm: z.union([z.literal("POST"), z.literal("GET")]),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","_interopRequireWildcard","require","_ioReactNativeJwt","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_ioReactNativeJwt","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","createDPopToken","payload","crypto","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","exports","DPoPPayload","object","jti","string","htm","union","literal","htu","ath","optional"],"sourceRoot":"../../../src","sources":["utils/dpop.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAA0E,SAAAE,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,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,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CAAC;AACX,CAAC;AAACC,OAAA,CAAAZ,eAAA,GAAAA,eAAA;AAGK,MAAMa,WAAW,GAAGvC,CAAC,CAACwC,MAAM,CAAC;EAClCC,GAAG,EAAEzC,CAAC,CAAC0C,MAAM,CAAC,CAAC;EACfC,GAAG,EAAE3C,CAAC,CAAC4C,KAAK,CAAC,CAAC5C,CAAC,CAAC6C,OAAO,CAAC,MAAM,CAAC,EAAE7C,CAAC,CAAC6C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACnDC,GAAG,EAAE9C,CAAC,CAAC0C,MAAM,CAAC,CAAC;EACfK,GAAG,EAAE/C,CAAC,CAAC0C,MAAM,CAAC,CAAC,CAACM,QAAQ,CAAC;AAC3B,CAAC,CAAC;AAACV,OAAA,CAAAC,WAAA,GAAAA,WAAA"}
|
@@ -3,13 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
6
|
+
exports.decode = decode;
|
7
|
+
Object.defineProperty(exports, "getAttestation", {
|
7
8
|
enumerable: true,
|
8
9
|
get: function () {
|
9
|
-
return _issuing.
|
10
|
+
return _issuing.getAttestation;
|
10
11
|
}
|
11
12
|
});
|
12
|
-
exports.decode = decode;
|
13
13
|
exports.verify = verify;
|
14
14
|
var _types = require("./types");
|
15
15
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
@@ -3,68 +3,58 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.getAttestation = void 0;
|
7
7
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
8
|
var _jwk = require("../utils/jwk");
|
9
9
|
var _types = require("./types");
|
10
10
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
11
11
|
var _errors = require("../utils/errors");
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
cnf: {
|
43
|
-
jwk: (0, _jwk.fixBase64EncodingOnKey)(publicKey)
|
44
|
-
}
|
45
|
-
}).setProtectedHeader({
|
46
|
-
alg: "ES256",
|
47
|
-
kid: publicKey.kid,
|
48
|
-
typ: "wiar+jwt"
|
49
|
-
}).setIssuedAt().setExpirationTime("1h").toSign();
|
50
|
-
return walletInstanceAttestationRequest;
|
51
|
-
}
|
13
|
+
async function getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl) {
|
14
|
+
const jwk = await wiaCryptoContext.getPublicKey();
|
15
|
+
const parsedJwk = _jwk.JWK.parse(jwk);
|
16
|
+
const keyThumbprint = await (0, _ioReactNativeJwt.thumbprint)(parsedJwk);
|
17
|
+
const publicKey = {
|
18
|
+
...parsedJwk,
|
19
|
+
kid: keyThumbprint
|
20
|
+
};
|
21
|
+
return new _ioReactNativeJwt.SignJWT(wiaCryptoContext).setPayload({
|
22
|
+
iss: keyThumbprint,
|
23
|
+
aud: walletProviderBaseUrl,
|
24
|
+
jti: `${_reactNativeUuid.default.v4()}`,
|
25
|
+
nonce: `${_reactNativeUuid.default.v4()}`,
|
26
|
+
cnf: {
|
27
|
+
jwk: (0, _jwk.fixBase64EncodingOnKey)(publicKey)
|
28
|
+
}
|
29
|
+
}).setProtectedHeader({
|
30
|
+
kid: publicKey.kid,
|
31
|
+
typ: "wiar+jwt"
|
32
|
+
}).setPayload({
|
33
|
+
iss: keyThumbprint,
|
34
|
+
sub: walletProviderBaseUrl,
|
35
|
+
jti: `${_reactNativeUuid.default.v4()}`,
|
36
|
+
type: "WalletInstanceAttestationRequest",
|
37
|
+
cnf: {
|
38
|
+
jwk: (0, _jwk.fixBase64EncodingOnKey)(publicKey)
|
39
|
+
}
|
40
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
41
|
+
}
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
async
|
67
|
-
const signedAttestationRequest = await
|
43
|
+
/**
|
44
|
+
* Request a Wallet Instance Attestation (WIA) to the Wallet provider
|
45
|
+
*
|
46
|
+
* @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
|
47
|
+
* @param params.appFetch (optional) Http client
|
48
|
+
* @param walletProviderBaseUrl Base url for the Wallet Provider
|
49
|
+
* @returns The retrieved Wallet Instance Attestation token
|
50
|
+
*/
|
51
|
+
const getAttestation = _ref => {
|
52
|
+
let {
|
53
|
+
wiaCryptoContext,
|
54
|
+
appFetch = fetch
|
55
|
+
} = _ref;
|
56
|
+
return async walletProviderBaseUrl => {
|
57
|
+
const signedAttestationRequest = await getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl);
|
68
58
|
const decodedRequest = (0, _ioReactNativeJwt.decode)(signedAttestationRequest);
|
69
59
|
const parsedRequest = _types.WalletInstanceAttestationRequestJwt.parse({
|
70
60
|
payload: decodedRequest.payload,
|
@@ -72,12 +62,12 @@ class Issuing {
|
|
72
62
|
});
|
73
63
|
const publicKey = parsedRequest.payload.cnf.jwk;
|
74
64
|
await (0, _ioReactNativeJwt.verify)(signedAttestationRequest, publicKey);
|
75
|
-
const tokenUrl = new URL("token",
|
65
|
+
const tokenUrl = new URL("token", walletProviderBaseUrl).href;
|
76
66
|
const requestBody = {
|
77
67
|
grant_type: "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation",
|
78
68
|
assertion: signedAttestationRequest
|
79
69
|
};
|
80
|
-
const response = await
|
70
|
+
const response = await appFetch(tokenUrl, {
|
81
71
|
method: "POST",
|
82
72
|
headers: {
|
83
73
|
"Content-Type": "application/json"
|
@@ -88,7 +78,7 @@ class Issuing {
|
|
88
78
|
return await response.text();
|
89
79
|
}
|
90
80
|
throw new _errors.WalletInstanceAttestationIssuingError("Unable to obtain wallet instance attestation from wallet provider", `Response code: ${response.status}`);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
exports.
|
81
|
+
};
|
82
|
+
};
|
83
|
+
exports.getAttestation = getAttestation;
|
94
84
|
//# sourceMappingURL=issuing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_types","_reactNativeUuid","_interopRequireDefault","_errors","obj","__esModule","default","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_types","_reactNativeUuid","_interopRequireDefault","_errors","obj","__esModule","default","getAttestationRequest","wiaCryptoContext","walletProviderBaseUrl","jwk","getPublicKey","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","SignJWT","setPayload","iss","aud","jti","uuid","v4","nonce","cnf","fixBase64EncodingOnKey","setProtectedHeader","typ","sub","type","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","signedAttestationRequest","decodedRequest","decodeJwt","parsedRequest","WalletInstanceAttestationRequestJwt","payload","header","protectedHeader","verifyJwt","tokenUrl","URL","href","requestBody","grant_type","assertion","response","method","headers","body","JSON","stringify","status","text","WalletInstanceAttestationIssuingError","exports"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAMA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAAwE,SAAAI,uBAAAE,GAAA,WAAA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10 +5,11 @@ import * as PID from "./pid";
|
|
5
5
|
import * as RP from "./rp";
|
6
6
|
import * as Errors from "./utils/errors";
|
7
7
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
8
|
-
import
|
9
|
-
import { RelyingPartySolution } from "./rp";
|
8
|
+
import * as RelyingPartySolution from "./rp";
|
10
9
|
import { RpEntityConfiguration } from "./rp/types";
|
11
10
|
import { verifyTrustChain, getEntityConfiguration } from "./trust";
|
12
11
|
import { EntityConfiguration, EntityStatement, TrustAnchorEntityConfiguration } from "./trust/types";
|
13
|
-
|
12
|
+
import { createCryptoContextFor } from "./utils/crypto";
|
13
|
+
import { PidIssuerEntityConfiguration } from "./pid/metadata";
|
14
|
+
export { PID, RP, WalletInstanceAttestation, Errors, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, EntityConfiguration, EntityStatement, RpEntityConfiguration, PidIssuerEntityConfiguration, TrustAnchorEntityConfiguration, createCryptoContextFor };
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","
|
1
|
+
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","RelyingPartySolution","RpEntityConfiguration","verifyTrustChain","getEntityConfiguration","EntityConfiguration","EntityStatement","TrustAnchorEntityConfiguration","createCryptoContextFor","PidIssuerEntityConfiguration"],"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,OAAO,KAAKC,oBAAoB,MAAM,MAAM;AAC5C,SAASC,qBAAqB,QAAQ,YAAY;AAClD,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,SAAS;AAClE,SACEC,mBAAmB,EACnBC,eAAe,EACfC,8BAA8B,QACzB,eAAe;AACtB,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,4BAA4B,QAAQ,gBAAgB;AAE7D,SACEZ,GAAG,EACHC,EAAE,EACFE,yBAAyB,EACzBD,MAAM,EACNE,oBAAoB,EACpBE,gBAAgB,EAChBC,sBAAsB,EACtBC,mBAAmB,EACnBC,eAAe,EACfJ,qBAAqB,EACrBO,4BAA4B,EAC5BF,8BAA8B,EAC9BC,sBAAsB"}
|
package/lib/module/pid/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["SdJwt","Issuing"],"sourceRoot":"../../../src","sources":["pid/index.ts"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,UAAU;AACjC,
|
1
|
+
{"version":3,"names":["SdJwt","Issuing"],"sourceRoot":"../../../src","sources":["pid/index.ts"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,SAASD,KAAK,EAAEC,OAAO"}
|