@metamask/profile-sync-controller 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/dist/{chunk-DHHBHLVN.mjs → chunk-2XGRQBXI.mjs} +4 -4
- package/dist/{chunk-2MVOZPBN.js → chunk-5C53GKTU.js} +14 -6
- package/dist/chunk-5C53GKTU.js.map +1 -0
- package/dist/{chunk-K6G7X6PX.js → chunk-5SXXO4MV.js} +9 -9
- package/dist/{chunk-BFE6TB7Y.mjs → chunk-5TOWF6UW.mjs} +2 -2
- package/dist/{chunk-W7JFFMEZ.mjs → chunk-7SW3CC66.mjs} +13 -5
- package/dist/chunk-7SW3CC66.mjs.map +1 -0
- package/dist/{chunk-JTDFOATG.js → chunk-AK7OTIWA.js} +3 -3
- package/dist/{chunk-772MKTIO.mjs → chunk-AUFUOKJW.mjs} +2 -2
- package/dist/{chunk-6TK7544L.js → chunk-AVOOINGJ.js} +27 -27
- package/dist/{chunk-UEZI2POO.mjs → chunk-AXWK4Y23.mjs} +4 -4
- package/dist/{chunk-VTM5T7Y4.mjs → chunk-B5DBQDB3.mjs} +2 -2
- package/dist/{chunk-7FCK4BY3.js → chunk-B6CSNLGE.js} +3 -3
- package/dist/{chunk-XUPRRLBI.js → chunk-BOET676P.js} +8 -8
- package/dist/{chunk-YWA77VMP.mjs → chunk-CAIIVJAO.mjs} +1 -1
- package/dist/chunk-CAIIVJAO.mjs.map +1 -0
- package/dist/{chunk-3FJQHCCQ.mjs → chunk-FCT2LIGH.mjs} +5 -5
- package/dist/{chunk-GLS4QZF6.mjs → chunk-FQ5SDMRE.mjs} +1 -1
- package/dist/chunk-FQ5SDMRE.mjs.map +1 -0
- package/dist/{chunk-BVM4HBM4.js → chunk-FRVMGTOY.js} +13 -39
- package/dist/chunk-FRVMGTOY.js.map +1 -0
- package/dist/{chunk-WAS6V24H.js → chunk-GWBBZZVV.js} +39 -30
- package/dist/chunk-GWBBZZVV.js.map +1 -0
- package/dist/chunk-H4TDS65R.js +81 -0
- package/dist/chunk-H4TDS65R.js.map +1 -0
- package/dist/chunk-IGY2S5BC.js +36 -0
- package/dist/{chunk-UWRKMJBI.mjs → chunk-JLDFMYAH.mjs} +3 -3
- package/dist/{chunk-QE2F5AZL.mjs → chunk-K5UKU454.mjs} +2 -2
- package/dist/{chunk-QHL6SQTC.mjs → chunk-KKB3U6KO.mjs} +10 -36
- package/dist/chunk-KKB3U6KO.mjs.map +1 -0
- package/dist/{chunk-JAGWB4JI.mjs → chunk-LSVRA3X2.mjs} +13 -34
- package/dist/chunk-LSVRA3X2.mjs.map +1 -0
- package/dist/{chunk-DLXLU44Z.js → chunk-NLHLVVOO.js} +21 -21
- package/dist/{chunk-GLDUXN2T.js → chunk-P4DUDLMY.js} +24 -24
- package/dist/{chunk-LUKNP4HM.js → chunk-P52TG263.js} +19 -19
- package/dist/{chunk-T77FC4PB.js → chunk-PBRUOBEQ.js} +1 -1
- package/dist/chunk-PBRUOBEQ.js.map +1 -0
- package/dist/chunk-PTR4DAX6.js +79 -0
- package/dist/{chunk-LHDVZNW5.js → chunk-Q5WIUNX5.js} +37 -37
- package/dist/{chunk-PRDECQM6.mjs → chunk-QU3RCIV3.mjs} +15 -6
- package/dist/chunk-QU3RCIV3.mjs.map +1 -0
- package/dist/{chunk-4OMJ7A6A.js → chunk-SMKTWM6I.js} +1 -1
- package/dist/chunk-SMKTWM6I.js.map +1 -0
- package/dist/{chunk-JWTNHCVG.js → chunk-T3FNDVE3.js} +13 -13
- package/dist/{chunk-PNZGAAT4.mjs → chunk-TGFMKARH.mjs} +5 -4
- package/dist/chunk-TGFMKARH.mjs.map +1 -0
- package/dist/chunk-U5UIDVOO.mjs +36 -0
- package/dist/{chunk-7VMXBDXN.mjs → chunk-WB6MUIML.mjs} +2 -2
- package/dist/{chunk-IZHWP5VW.mjs → chunk-WJCKQLKK.mjs} +9 -9
- package/dist/{chunk-LN2BY2QF.mjs → chunk-Y46NMA3V.mjs} +3 -3
- package/dist/{chunk-ARWL2LBB.js → chunk-YASNOFBV.js} +38 -37
- package/dist/chunk-YASNOFBV.js.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.js +15 -13
- package/dist/controllers/authentication/AuthenticationController.mjs +16 -14
- package/dist/controllers/authentication/auth-snap-requests.js +1 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +1 -1
- package/dist/controllers/authentication/index.js +16 -15
- package/dist/controllers/authentication/index.mjs +17 -16
- package/dist/controllers/authentication/services.js +12 -12
- package/dist/controllers/authentication/services.mjs +11 -11
- package/dist/controllers/index.js +20 -21
- package/dist/controllers/index.mjs +19 -20
- package/dist/controllers/user-storage/UserStorageController.js +18 -16
- package/dist/controllers/user-storage/UserStorageController.mjs +19 -17
- package/dist/controllers/user-storage/encryption/cache.js +1 -1
- package/dist/controllers/user-storage/encryption/cache.mjs +1 -1
- package/dist/controllers/user-storage/encryption/encryption.js +3 -3
- package/dist/controllers/user-storage/encryption/encryption.mjs +2 -2
- package/dist/controllers/user-storage/encryption/index.js +4 -4
- package/dist/controllers/user-storage/encryption/index.mjs +3 -3
- package/dist/controllers/user-storage/encryption/utils.js +1 -1
- package/dist/controllers/user-storage/encryption/utils.mjs +1 -1
- package/dist/controllers/user-storage/index.js +19 -18
- package/dist/controllers/user-storage/index.mjs +20 -19
- package/dist/controllers/user-storage/schema.js +5 -5
- package/dist/controllers/user-storage/schema.mjs +4 -4
- package/dist/controllers/user-storage/services.js +15 -15
- package/dist/controllers/user-storage/services.mjs +14 -14
- package/dist/index.js +20 -21
- package/dist/index.mjs +19 -20
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +6 -6
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +5 -5
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +6 -6
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +5 -5
- package/dist/sdk/authentication-jwt-bearer/services.js +5 -5
- package/dist/sdk/authentication-jwt-bearer/services.mjs +4 -4
- package/dist/sdk/authentication-jwt-bearer/types.js +3 -3
- package/dist/sdk/authentication-jwt-bearer/types.mjs +2 -2
- package/dist/sdk/authentication.js +8 -8
- package/dist/sdk/authentication.mjs +7 -7
- package/dist/sdk/encryption.js +3 -3
- package/dist/sdk/encryption.mjs +2 -2
- package/dist/sdk/env.js +3 -3
- package/dist/sdk/env.mjs +2 -2
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/errors.mjs +1 -1
- package/dist/sdk/index.js +11 -11
- package/dist/sdk/index.mjs +10 -10
- package/dist/sdk/user-storage.js +5 -5
- package/dist/sdk/user-storage.mjs +4 -4
- package/dist/sdk/utils/eip-6963-metamask-provider.js +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.js +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/controllers/authentication/AuthenticationController.d.ts +2 -1
- package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +1 -1
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts +0 -1
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts.map +1 -1
- package/dist/types/controllers/authentication/services.d.ts +2 -1
- package/dist/types/controllers/authentication/services.d.ts.map +1 -1
- package/dist/types/controllers/user-storage/UserStorageController.d.ts +1 -0
- package/dist/types/controllers/user-storage/UserStorageController.d.ts.map +1 -1
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts.map +1 -1
- package/dist/types/sdk/authentication-jwt-bearer/types.d.ts +1 -1
- package/dist/types/sdk/authentication-jwt-bearer/types.d.ts.map +1 -1
- package/dist/types/sdk/env.d.ts +2 -2
- package/dist/types/sdk/env.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-26CCETCM.mjs +0 -70
- package/dist/chunk-2MVOZPBN.js.map +0 -1
- package/dist/chunk-4OMJ7A6A.js.map +0 -1
- package/dist/chunk-ARWL2LBB.js.map +0 -1
- package/dist/chunk-BVM4HBM4.js.map +0 -1
- package/dist/chunk-GJJT2CAL.js +0 -3342
- package/dist/chunk-GJJT2CAL.js.map +0 -1
- package/dist/chunk-GLS4QZF6.mjs.map +0 -1
- package/dist/chunk-JAGWB4JI.mjs.map +0 -1
- package/dist/chunk-JMU3OVPK.mjs +0 -3342
- package/dist/chunk-JMU3OVPK.mjs.map +0 -1
- package/dist/chunk-PNZGAAT4.mjs.map +0 -1
- package/dist/chunk-PRDECQM6.mjs.map +0 -1
- package/dist/chunk-QHL6SQTC.mjs.map +0 -1
- package/dist/chunk-QILE6KIE.js +0 -79
- package/dist/chunk-T77FC4PB.js.map +0 -1
- package/dist/chunk-V46WVGWN.js +0 -70
- package/dist/chunk-VYE2DKST.js +0 -102
- package/dist/chunk-VYE2DKST.js.map +0 -1
- package/dist/chunk-W7JFFMEZ.mjs.map +0 -1
- package/dist/chunk-WAS6V24H.js.map +0 -1
- package/dist/chunk-YWA77VMP.mjs.map +0 -1
- /package/dist/{chunk-DHHBHLVN.mjs.map → chunk-2XGRQBXI.mjs.map} +0 -0
- /package/dist/{chunk-K6G7X6PX.js.map → chunk-5SXXO4MV.js.map} +0 -0
- /package/dist/{chunk-BFE6TB7Y.mjs.map → chunk-5TOWF6UW.mjs.map} +0 -0
- /package/dist/{chunk-JTDFOATG.js.map → chunk-AK7OTIWA.js.map} +0 -0
- /package/dist/{chunk-772MKTIO.mjs.map → chunk-AUFUOKJW.mjs.map} +0 -0
- /package/dist/{chunk-6TK7544L.js.map → chunk-AVOOINGJ.js.map} +0 -0
- /package/dist/{chunk-UEZI2POO.mjs.map → chunk-AXWK4Y23.mjs.map} +0 -0
- /package/dist/{chunk-VTM5T7Y4.mjs.map → chunk-B5DBQDB3.mjs.map} +0 -0
- /package/dist/{chunk-7FCK4BY3.js.map → chunk-B6CSNLGE.js.map} +0 -0
- /package/dist/{chunk-XUPRRLBI.js.map → chunk-BOET676P.js.map} +0 -0
- /package/dist/{chunk-3FJQHCCQ.mjs.map → chunk-FCT2LIGH.mjs.map} +0 -0
- /package/dist/{chunk-V46WVGWN.js.map → chunk-IGY2S5BC.js.map} +0 -0
- /package/dist/{chunk-UWRKMJBI.mjs.map → chunk-JLDFMYAH.mjs.map} +0 -0
- /package/dist/{chunk-QE2F5AZL.mjs.map → chunk-K5UKU454.mjs.map} +0 -0
- /package/dist/{chunk-DLXLU44Z.js.map → chunk-NLHLVVOO.js.map} +0 -0
- /package/dist/{chunk-GLDUXN2T.js.map → chunk-P4DUDLMY.js.map} +0 -0
- /package/dist/{chunk-LUKNP4HM.js.map → chunk-P52TG263.js.map} +0 -0
- /package/dist/{chunk-QILE6KIE.js.map → chunk-PTR4DAX6.js.map} +0 -0
- /package/dist/{chunk-LHDVZNW5.js.map → chunk-Q5WIUNX5.js.map} +0 -0
- /package/dist/{chunk-JWTNHCVG.js.map → chunk-T3FNDVE3.js.map} +0 -0
- /package/dist/{chunk-26CCETCM.mjs.map → chunk-U5UIDVOO.mjs.map} +0 -0
- /package/dist/{chunk-7VMXBDXN.mjs.map → chunk-WB6MUIML.mjs.map} +0 -0
- /package/dist/{chunk-IZHWP5VW.mjs.map → chunk-WJCKQLKK.mjs.map} +0 -0
- /package/dist/{chunk-LN2BY2QF.mjs.map → chunk-Y46NMA3V.mjs.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQ5WIUNX5js = require('./chunk-Q5WIUNX5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkAVOOINGJjs = require('./chunk-AVOOINGJ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkBOET676Pjs = require('./chunk-BOET676P.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,43 +17,43 @@ var _chunkMBTBE4P5js = require('./chunk-MBTBE4P5.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
|
|
21
21
|
|
|
22
22
|
// src/sdk/authentication.ts
|
|
23
23
|
var _type, _env, _sdk, _assertSIWE, assertSIWE_fn;
|
|
24
24
|
var JwtBearerAuth = class {
|
|
25
25
|
constructor(...args) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _assertSIWE);
|
|
27
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _type, void 0);
|
|
28
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _env, void 0);
|
|
29
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _sdk, void 0);
|
|
30
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _type, args[0].type);
|
|
31
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _env, args[0].env);
|
|
32
32
|
if (args[0].type === "SRP" /* SRP */) {
|
|
33
|
-
|
|
33
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _sdk, new (0, _chunkAVOOINGJjs.SRPJwtBearerAuth)(args[0], args[1]));
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
if (args[0].type === "SiWE" /* SiWE */) {
|
|
37
|
-
|
|
37
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _sdk, new (0, _chunkQ5WIUNX5js.SIWEJwtBearerAuth)(args[0], args[1]));
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
throw new (0, _chunkMBTBE4P5js.UnsupportedAuthTypeError)("unsupported auth type");
|
|
41
41
|
}
|
|
42
42
|
async getAccessToken() {
|
|
43
|
-
return await
|
|
43
|
+
return await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk).getAccessToken();
|
|
44
44
|
}
|
|
45
45
|
async getUserProfile() {
|
|
46
|
-
return await
|
|
46
|
+
return await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk).getUserProfile();
|
|
47
47
|
}
|
|
48
48
|
async getIdentifier() {
|
|
49
|
-
return await
|
|
49
|
+
return await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk).getIdentifier();
|
|
50
50
|
}
|
|
51
51
|
async signMessage(message) {
|
|
52
|
-
return await
|
|
52
|
+
return await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk).signMessage(message);
|
|
53
53
|
}
|
|
54
54
|
async pairIdentifiers(pairing) {
|
|
55
55
|
const profile = await this.getUserProfile();
|
|
56
|
-
const n = await
|
|
56
|
+
const n = await _chunkBOET676Pjs.getNonce.call(void 0, profile.profileId, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _env));
|
|
57
57
|
const logins = await Promise.all(
|
|
58
58
|
pairing.map(async (p) => {
|
|
59
59
|
try {
|
|
@@ -80,11 +80,11 @@ var JwtBearerAuth = class {
|
|
|
80
80
|
})
|
|
81
81
|
);
|
|
82
82
|
const accessToken = await this.getAccessToken();
|
|
83
|
-
await
|
|
83
|
+
await _chunkBOET676Pjs.pairIdentifiers.call(void 0, n.nonce, logins, accessToken, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _env));
|
|
84
84
|
}
|
|
85
85
|
prepare(signer) {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertSIWE, assertSIWE_fn).call(this, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _type), _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk));
|
|
87
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _sdk).prepare(signer);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
_type = new WeakMap();
|
|
@@ -103,4 +103,4 @@ assertSIWE_fn = function(type, sdk) {
|
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
exports.JwtBearerAuth = JwtBearerAuth;
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-NLHLVVOO.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
|
|
6
6
|
|
|
7
7
|
// src/sdk/encryption.ts
|
|
8
8
|
var _aes = require('@noble/ciphers/aes');
|
|
@@ -23,32 +23,32 @@ function bytesToUtf8(byteArray) {
|
|
|
23
23
|
var _ALGORITHM_NONCE_SIZE, _ALGORITHM_KEY_SIZE, _PBKDF2_SALT_SIZE, _PBKDF2_ITERATIONS, _encryptStringV1, encryptStringV1_fn, _decryptStringV1, decryptStringV1_fn, _encrypt, encrypt_fn, _decrypt, decrypt_fn;
|
|
24
24
|
var EncryptorDecryptor = class {
|
|
25
25
|
constructor() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _encryptStringV1);
|
|
27
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _decryptStringV1);
|
|
28
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _encrypt);
|
|
29
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _decrypt);
|
|
30
30
|
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
32
|
-
|
|
32
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _ALGORITHM_NONCE_SIZE, 12);
|
|
33
33
|
// 12 bytes
|
|
34
34
|
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
36
|
-
|
|
36
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _ALGORITHM_KEY_SIZE, 16);
|
|
37
37
|
// 16 bytes
|
|
38
38
|
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
-
|
|
40
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _PBKDF2_SALT_SIZE, 16);
|
|
41
41
|
// 16 bytes
|
|
42
42
|
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
44
|
-
|
|
44
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _PBKDF2_ITERATIONS, 9e5);
|
|
45
45
|
}
|
|
46
46
|
encryptString(plaintext, password) {
|
|
47
47
|
try {
|
|
48
48
|
if (plaintext.trim().length === 0) {
|
|
49
49
|
throw new Error("No plain text provided");
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _encryptStringV1, encryptStringV1_fn).call(this, plaintext, password);
|
|
52
52
|
} catch (e) {
|
|
53
53
|
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
54
54
|
throw new Error(`Unable to encrypt string - ${errorMessage}`);
|
|
@@ -58,7 +58,7 @@ var EncryptorDecryptor = class {
|
|
|
58
58
|
try {
|
|
59
59
|
const encryptedData = JSON.parse(encryptedDataStr);
|
|
60
60
|
if (encryptedData.v === "1") {
|
|
61
|
-
return
|
|
61
|
+
return _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _decryptStringV1, decryptStringV1_fn).call(this, encryptedData, password);
|
|
62
62
|
}
|
|
63
63
|
throw new Error(
|
|
64
64
|
`Unsupported encrypted data payload - ${JSON.stringify(encryptedData)}`
|
|
@@ -75,21 +75,21 @@ _PBKDF2_SALT_SIZE = new WeakMap();
|
|
|
75
75
|
_PBKDF2_ITERATIONS = new WeakMap();
|
|
76
76
|
_encryptStringV1 = new WeakSet();
|
|
77
77
|
encryptStringV1_fn = function(plaintext, password) {
|
|
78
|
-
const salt = _webcrypto.randomBytes.call(void 0,
|
|
78
|
+
const salt = _webcrypto.randomBytes.call(void 0, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _PBKDF2_SALT_SIZE));
|
|
79
79
|
const key = _pbkdf2.pbkdf2.call(void 0, _sha256.sha256, password, salt, {
|
|
80
|
-
c:
|
|
81
|
-
dkLen:
|
|
80
|
+
c: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _PBKDF2_ITERATIONS),
|
|
81
|
+
dkLen: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _ALGORITHM_KEY_SIZE)
|
|
82
82
|
});
|
|
83
83
|
const plaintextRaw = _utils.utf8ToBytes.call(void 0, plaintext);
|
|
84
84
|
const ciphertextAndNonceAndSalt = _utils.concatBytes.call(void 0,
|
|
85
85
|
salt,
|
|
86
|
-
|
|
86
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _encrypt, encrypt_fn).call(this, plaintextRaw, key)
|
|
87
87
|
);
|
|
88
88
|
const encryptedData = byteArrayToBase64(ciphertextAndNonceAndSalt);
|
|
89
89
|
const encryptedPayload = {
|
|
90
90
|
v: "1",
|
|
91
91
|
d: encryptedData,
|
|
92
|
-
iterations:
|
|
92
|
+
iterations: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _PBKDF2_ITERATIONS)
|
|
93
93
|
};
|
|
94
94
|
return JSON.stringify(encryptedPayload);
|
|
95
95
|
};
|
|
@@ -99,28 +99,28 @@ decryptStringV1_fn = function(data, password) {
|
|
|
99
99
|
const ciphertextAndNonceAndSalt = base64ToByteArray(
|
|
100
100
|
base64CiphertextAndNonceAndSalt
|
|
101
101
|
);
|
|
102
|
-
const salt = ciphertextAndNonceAndSalt.slice(0,
|
|
102
|
+
const salt = ciphertextAndNonceAndSalt.slice(0, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _PBKDF2_SALT_SIZE));
|
|
103
103
|
const ciphertextAndNonce = ciphertextAndNonceAndSalt.slice(
|
|
104
|
-
|
|
104
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _PBKDF2_SALT_SIZE),
|
|
105
105
|
ciphertextAndNonceAndSalt.length
|
|
106
106
|
);
|
|
107
107
|
const key = _pbkdf2.pbkdf2.call(void 0, _sha256.sha256, password, salt, {
|
|
108
108
|
c: iterations,
|
|
109
|
-
dkLen:
|
|
109
|
+
dkLen: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _ALGORITHM_KEY_SIZE)
|
|
110
110
|
});
|
|
111
|
-
return bytesToUtf8(
|
|
111
|
+
return bytesToUtf8(_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _decrypt, decrypt_fn).call(this, ciphertextAndNonce, key));
|
|
112
112
|
};
|
|
113
113
|
_encrypt = new WeakSet();
|
|
114
114
|
encrypt_fn = function(plaintext, key) {
|
|
115
|
-
const nonce = _webcrypto.randomBytes.call(void 0,
|
|
115
|
+
const nonce = _webcrypto.randomBytes.call(void 0, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _ALGORITHM_NONCE_SIZE));
|
|
116
116
|
const ciphertext = _aes.gcm.call(void 0, key, nonce).encrypt(plaintext);
|
|
117
117
|
return _utils.concatBytes.call(void 0, nonce, ciphertext);
|
|
118
118
|
};
|
|
119
119
|
_decrypt = new WeakSet();
|
|
120
120
|
decrypt_fn = function(ciphertextAndNonce, key) {
|
|
121
|
-
const nonce = ciphertextAndNonce.slice(0,
|
|
121
|
+
const nonce = ciphertextAndNonce.slice(0, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _ALGORITHM_NONCE_SIZE));
|
|
122
122
|
const ciphertext = ciphertextAndNonce.slice(
|
|
123
|
-
|
|
123
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _ALGORITHM_NONCE_SIZE),
|
|
124
124
|
ciphertextAndNonce.length
|
|
125
125
|
);
|
|
126
126
|
return _aes.gcm.call(void 0, key, nonce).decrypt(ciphertext);
|
|
@@ -137,4 +137,4 @@ function createSHA256Hash(data) {
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
exports.Encryption = Encryption; exports.encryption_default = encryption_default; exports.createSHA256Hash = createSHA256Hash;
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-P4DUDLMY.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkP4DUDLMYjs = require('./chunk-P4DUDLMY.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSMKTWM6Ijs = require('./chunk-SMKTWM6I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -13,19 +13,19 @@ var _chunkMBTBE4P5js = require('./chunk-MBTBE4P5.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
|
|
17
17
|
|
|
18
18
|
// src/sdk/user-storage.ts
|
|
19
|
-
var STORAGE_URL = (env, feature, entry) => `${
|
|
19
|
+
var STORAGE_URL = (env, feature, entry) => `${_chunkSMKTWM6Ijs.getEnvUrls.call(void 0, env).userStorageApiUrl}/api/v1/userstorage/${feature}/${entry}`;
|
|
20
20
|
var _upsertUserStorage, upsertUserStorage_fn, _getUserStorage, getUserStorage_fn, _createEntryKey, createEntryKey_fn, _getAuthorizationHeader, getAuthorizationHeader_fn;
|
|
21
21
|
var UserStorage = class {
|
|
22
22
|
constructor(config, options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _upsertUserStorage);
|
|
24
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _getUserStorage);
|
|
25
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _createEntryKey);
|
|
26
26
|
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28
|
-
|
|
28
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _getAuthorizationHeader);
|
|
29
29
|
this.env = config.env;
|
|
30
30
|
this.config = config;
|
|
31
31
|
this.options = options;
|
|
@@ -34,13 +34,13 @@ var UserStorage = class {
|
|
|
34
34
|
if (!feature.trim() || !key.trim()) {
|
|
35
35
|
throw new (0, _chunkMBTBE4P5js.ValidationError)("feature or key cannot be empty strings");
|
|
36
36
|
}
|
|
37
|
-
await
|
|
37
|
+
await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _upsertUserStorage, upsertUserStorage_fn).call(this, feature, key, value);
|
|
38
38
|
}
|
|
39
39
|
async getItem(feature, key) {
|
|
40
40
|
if (!feature.trim() || !key.trim()) {
|
|
41
41
|
throw new (0, _chunkMBTBE4P5js.ValidationError)("feature or key cannot be empty strings");
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this, feature, key);
|
|
44
44
|
}
|
|
45
45
|
async getStorageKey() {
|
|
46
46
|
const storageKey = await this.options.storage?.getStorageKey();
|
|
@@ -51,7 +51,7 @@ var UserStorage = class {
|
|
|
51
51
|
const storageKeySignature = await this.config.auth.signMessage(
|
|
52
52
|
`metamask:${userProfile.profileId}`
|
|
53
53
|
);
|
|
54
|
-
const hashedStorageKeySignature =
|
|
54
|
+
const hashedStorageKeySignature = _chunkP4DUDLMYjs.createSHA256Hash.call(void 0, storageKeySignature);
|
|
55
55
|
await this.options.storage?.setStorageKey(hashedStorageKeySignature);
|
|
56
56
|
return hashedStorageKeySignature;
|
|
57
57
|
}
|
|
@@ -59,11 +59,11 @@ var UserStorage = class {
|
|
|
59
59
|
_upsertUserStorage = new WeakSet();
|
|
60
60
|
upsertUserStorage_fn = async function(feature, key, data) {
|
|
61
61
|
try {
|
|
62
|
-
const headers = await
|
|
62
|
+
const headers = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getAuthorizationHeader, getAuthorizationHeader_fn).call(this);
|
|
63
63
|
const storageKey = await this.getStorageKey();
|
|
64
|
-
const encryptedData =
|
|
64
|
+
const encryptedData = _chunkP4DUDLMYjs.encryption_default.encryptString(data, storageKey);
|
|
65
65
|
const url = new URL(
|
|
66
|
-
STORAGE_URL(this.env, feature,
|
|
66
|
+
STORAGE_URL(this.env, feature, _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _createEntryKey, createEntryKey_fn).call(this, key, storageKey))
|
|
67
67
|
);
|
|
68
68
|
const response = await fetch(url.toString(), {
|
|
69
69
|
method: "PUT",
|
|
@@ -92,10 +92,10 @@ upsertUserStorage_fn = async function(feature, key, data) {
|
|
|
92
92
|
_getUserStorage = new WeakSet();
|
|
93
93
|
getUserStorage_fn = async function(feature, key) {
|
|
94
94
|
try {
|
|
95
|
-
const headers = await
|
|
95
|
+
const headers = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getAuthorizationHeader, getAuthorizationHeader_fn).call(this);
|
|
96
96
|
const storageKey = await this.getStorageKey();
|
|
97
97
|
const url = new URL(
|
|
98
|
-
STORAGE_URL(this.env, feature,
|
|
98
|
+
STORAGE_URL(this.env, feature, _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _createEntryKey, createEntryKey_fn).call(this, key, storageKey))
|
|
99
99
|
);
|
|
100
100
|
const response = await fetch(url.toString(), {
|
|
101
101
|
headers: {
|
|
@@ -115,7 +115,7 @@ getUserStorage_fn = async function(feature, key) {
|
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
const { Data: encryptedData } = await response.json();
|
|
118
|
-
return
|
|
118
|
+
return _chunkP4DUDLMYjs.encryption_default.decryptString(encryptedData, storageKey);
|
|
119
119
|
} catch (e) {
|
|
120
120
|
if (e instanceof _chunkMBTBE4P5js.NotFoundError) {
|
|
121
121
|
throw e;
|
|
@@ -128,7 +128,7 @@ getUserStorage_fn = async function(feature, key) {
|
|
|
128
128
|
};
|
|
129
129
|
_createEntryKey = new WeakSet();
|
|
130
130
|
createEntryKey_fn = function(key, storageKey) {
|
|
131
|
-
const hashedKey =
|
|
131
|
+
const hashedKey = _chunkP4DUDLMYjs.createSHA256Hash.call(void 0, key + storageKey);
|
|
132
132
|
return hashedKey;
|
|
133
133
|
};
|
|
134
134
|
_getAuthorizationHeader = new WeakSet();
|
|
@@ -141,4 +141,4 @@ getAuthorizationHeader_fn = async function() {
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
exports.STORAGE_URL = STORAGE_URL; exports.UserStorage = UserStorage;
|
|
144
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-P52TG263.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk/authentication-jwt-bearer/types.ts"],"names":["AuthType"],"mappings":";AAEO,IAAK,WAAL,kBAAKA,cAAL;AAGL,EAAAA,UAAA,SAAM;AAGN,EAAAA,UAAA,UAAO;AANG,SAAAA;AAAA,GAAA","sourcesContent":["import type { Env, Platform } from '../env';\n\nexport enum AuthType {\n /* sign in using a private key derived from your secret recovery phrase (SRP). \n Uses message signing snap to perform this operation */\n SRP = 'SRP',\n\n /* sign in with Ethereum */\n SiWE = 'SiWE',\n}\n\nexport type AuthConfig = {\n env: Env;\n platform: Platform;\n type: AuthType;\n};\n\nexport type AccessToken = {\n /**\n * The JWT Access Token\n */\n accessToken: string;\n /**\n * Expiration in seconds\n */\n expiresIn: number;\n /**\n * Date in milliseconds\n */\n obtainedAt: number;\n};\n\nexport type UserProfile = {\n /**\n * The \"Identifier\" used to log in with.\n */\n identifierId: string;\n /**\n * The Unique profile for a logged in user. A Profile can be logged in via multiple Identifiers\n */\n profileId: string;\n /**\n * Server MetaMetrics ID. Allows grouping of user events cross platform.\n */\n metaMetricsId: string;\n};\n\nexport type LoginResponse = {\n token: AccessToken;\n profile: UserProfile;\n};\n\nexport type IBaseAuth = {\n getAccessToken: () => Promise<string>;\n getUserProfile: () => Promise<UserProfile>;\n getIdentifier: () => Promise<string>;\n signMessage: (message: string) => Promise<string>;\n};\n\nexport type AuthStorageOptions = {\n getLoginResponse: () => Promise<LoginResponse | null>;\n setLoginResponse: (val: LoginResponse) => Promise<void>;\n};\n\nexport type AuthSigningOptions = {\n signMessage: (message: string) => Promise<string>;\n getIdentifier: () => Promise<string>;\n};\n\nexport type ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport type Pair = {\n identifier: string;\n encryptedStorageKey: string;\n identifierType: 'SIWE' | 'SRP';\n signMessage: (message: string) => Promise<string>;\n};\n"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkNLHLVVOOjs = require('./chunk-NLHLVVOO.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQ5WIUNX5js = require('./chunk-Q5WIUNX5.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkAVOOINGJjs = require('./chunk-AVOOINGJ.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkPBRUOBEQjs = require('./chunk-PBRUOBEQ.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkPQ5T4GHYjs = require('./chunk-PQ5T4GHY.js');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkP52TG263js = require('./chunk-P52TG263.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkP4DUDLMYjs = require('./chunk-P4DUDLMY.js');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkSMKTWM6Ijs = require('./chunk-SMKTWM6I.js');
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var _chunkMBTBE4P5js = require('./chunk-MBTBE4P5.js');
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
|
|
46
|
+
|
|
47
|
+
// src/sdk/index.ts
|
|
48
|
+
var sdk_exports = {};
|
|
49
|
+
_chunkIGY2S5BCjs.__export.call(void 0, sdk_exports, {
|
|
50
|
+
AuthType: () => _chunkPBRUOBEQjs.AuthType,
|
|
51
|
+
Encryption: () => _chunkP4DUDLMYjs.Encryption,
|
|
52
|
+
Env: () => _chunkSMKTWM6Ijs.Env,
|
|
53
|
+
JwtBearerAuth: () => _chunkNLHLVVOOjs.JwtBearerAuth,
|
|
54
|
+
MESSAGE_SIGNING_SNAP: () => _chunkPQ5T4GHYjs.MESSAGE_SIGNING_SNAP,
|
|
55
|
+
NonceRetrievalError: () => _chunkMBTBE4P5js.NonceRetrievalError,
|
|
56
|
+
NotFoundError: () => _chunkMBTBE4P5js.NotFoundError,
|
|
57
|
+
PairError: () => _chunkMBTBE4P5js.PairError,
|
|
58
|
+
Platform: () => _chunkSMKTWM6Ijs.Platform,
|
|
59
|
+
SIWEJwtBearerAuth: () => _chunkQ5WIUNX5js.SIWEJwtBearerAuth,
|
|
60
|
+
SNAP_ORIGIN: () => _chunkPQ5T4GHYjs.SNAP_ORIGIN,
|
|
61
|
+
SRPJwtBearerAuth: () => _chunkAVOOINGJjs.SRPJwtBearerAuth,
|
|
62
|
+
STORAGE_URL: () => _chunkP52TG263js.STORAGE_URL,
|
|
63
|
+
SignInError: () => _chunkMBTBE4P5js.SignInError,
|
|
64
|
+
UnsupportedAuthTypeError: () => _chunkMBTBE4P5js.UnsupportedAuthTypeError,
|
|
65
|
+
UserStorage: () => _chunkP52TG263js.UserStorage,
|
|
66
|
+
UserStorageError: () => _chunkMBTBE4P5js.UserStorageError,
|
|
67
|
+
ValidationError: () => _chunkMBTBE4P5js.ValidationError,
|
|
68
|
+
connectSnap: () => _chunkPQ5T4GHYjs.connectSnap,
|
|
69
|
+
createSHA256Hash: () => _chunkP4DUDLMYjs.createSHA256Hash,
|
|
70
|
+
getEnvUrls: () => _chunkSMKTWM6Ijs.getEnvUrls,
|
|
71
|
+
getOidcClientId: () => _chunkSMKTWM6Ijs.getOidcClientId,
|
|
72
|
+
getSnap: () => _chunkPQ5T4GHYjs.getSnap,
|
|
73
|
+
getSnaps: () => _chunkPQ5T4GHYjs.getSnaps
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
exports.sdk_exports = sdk_exports;
|
|
79
|
+
//# sourceMappingURL=chunk-PTR4DAX6.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkBOET676Pjs = require('./chunk-BOET676P.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkMBTBE4P5js = require('./chunk-MBTBE4P5.js');
|
|
@@ -12,7 +12,7 @@ var _chunkMBTBE4P5js = require('./chunk-MBTBE4P5.js');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
|
|
16
16
|
|
|
17
17
|
// src/sdk/authentication-jwt-bearer/flow-siwe.ts
|
|
18
18
|
var _siwe = require('siwe');
|
|
@@ -20,42 +20,42 @@ var _config, _options, _signer, _getAuthSession, getAuthSession_fn, _login, logi
|
|
|
20
20
|
var SIWEJwtBearerAuth = class {
|
|
21
21
|
constructor(config, options) {
|
|
22
22
|
// convert expiresIn from seconds to milliseconds and use 90% of expiresIn
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _getAuthSession);
|
|
24
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _login);
|
|
25
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _createSiWELoginRawMessage);
|
|
26
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _assertSigner);
|
|
27
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _config, void 0);
|
|
28
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _options, void 0);
|
|
29
|
+
_chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _signer, void 0);
|
|
30
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _config, config);
|
|
31
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _options, options);
|
|
32
32
|
}
|
|
33
33
|
async getAccessToken() {
|
|
34
|
-
const session = await
|
|
34
|
+
const session = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getAuthSession, getAuthSession_fn).call(this);
|
|
35
35
|
if (session) {
|
|
36
36
|
return session.token.accessToken;
|
|
37
37
|
}
|
|
38
|
-
const loginResponse = await
|
|
38
|
+
const loginResponse = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _login, login_fn).call(this);
|
|
39
39
|
return loginResponse.token.accessToken;
|
|
40
40
|
}
|
|
41
41
|
async getUserProfile() {
|
|
42
|
-
const session = await
|
|
42
|
+
const session = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getAuthSession, getAuthSession_fn).call(this);
|
|
43
43
|
if (session) {
|
|
44
44
|
return session.profile;
|
|
45
45
|
}
|
|
46
|
-
const loginResponse = await
|
|
46
|
+
const loginResponse = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _login, login_fn).call(this);
|
|
47
47
|
return loginResponse.profile;
|
|
48
48
|
}
|
|
49
49
|
async getIdentifier() {
|
|
50
|
-
|
|
51
|
-
return
|
|
50
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertSigner, assertSigner_fn).call(this, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer));
|
|
51
|
+
return _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer).address;
|
|
52
52
|
}
|
|
53
53
|
async signMessage(message) {
|
|
54
|
-
|
|
55
|
-
return await
|
|
54
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertSigner, assertSigner_fn).call(this, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer));
|
|
55
|
+
return await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer).signMessage(message);
|
|
56
56
|
}
|
|
57
57
|
prepare(signer) {
|
|
58
|
-
|
|
58
|
+
_chunkIGY2S5BCjs.__privateSet.call(void 0, this, _signer, signer);
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
_config = new WeakMap();
|
|
@@ -63,7 +63,7 @@ _options = new WeakMap();
|
|
|
63
63
|
_signer = new WeakMap();
|
|
64
64
|
_getAuthSession = new WeakSet();
|
|
65
65
|
getAuthSession_fn = async function() {
|
|
66
|
-
const auth = await
|
|
66
|
+
const auth = await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _options).storage.getLoginResponse();
|
|
67
67
|
if (!auth) {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
@@ -77,38 +77,38 @@ getAuthSession_fn = async function() {
|
|
|
77
77
|
};
|
|
78
78
|
_login = new WeakSet();
|
|
79
79
|
login_fn = async function() {
|
|
80
|
-
|
|
80
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertSigner, assertSigner_fn).call(this, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer));
|
|
81
81
|
const address = await this.getIdentifier();
|
|
82
|
-
const nonceRes = await
|
|
83
|
-
const rawMessage =
|
|
82
|
+
const nonceRes = await _chunkBOET676Pjs.getNonce.call(void 0, address, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).env);
|
|
83
|
+
const rawMessage = _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _createSiWELoginRawMessage, createSiWELoginRawMessage_fn).call(this, nonceRes.nonce);
|
|
84
84
|
const signature = await this.signMessage(rawMessage);
|
|
85
|
-
const authResponse = await
|
|
85
|
+
const authResponse = await _chunkBOET676Pjs.authenticate.call(void 0,
|
|
86
86
|
rawMessage,
|
|
87
87
|
signature,
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).type,
|
|
89
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).env
|
|
90
90
|
);
|
|
91
|
-
const tokenResponse = await
|
|
91
|
+
const tokenResponse = await _chunkBOET676Pjs.authorizeOIDC.call(void 0,
|
|
92
92
|
authResponse.token,
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).env,
|
|
94
|
+
_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).platform
|
|
95
95
|
);
|
|
96
96
|
const result = {
|
|
97
97
|
profile: authResponse.profile,
|
|
98
98
|
token: tokenResponse
|
|
99
99
|
};
|
|
100
|
-
await
|
|
100
|
+
await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _options).storage.setLoginResponse(result);
|
|
101
101
|
return result;
|
|
102
102
|
};
|
|
103
103
|
_createSiWELoginRawMessage = new WeakSet();
|
|
104
104
|
createSiWELoginRawMessage_fn = function(nonce) {
|
|
105
|
-
|
|
105
|
+
_chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertSigner, assertSigner_fn).call(this, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer));
|
|
106
106
|
return new (0, _siwe.SiweMessage)({
|
|
107
|
-
domain:
|
|
108
|
-
address:
|
|
109
|
-
uri:
|
|
107
|
+
domain: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer)?.domain,
|
|
108
|
+
address: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer)?.address,
|
|
109
|
+
uri: _chunkBOET676Pjs.SIWE_LOGIN_URL.call(void 0, _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _config).env),
|
|
110
110
|
version: "1",
|
|
111
|
-
chainId:
|
|
111
|
+
chainId: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _signer)?.chainId,
|
|
112
112
|
nonce,
|
|
113
113
|
issuedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
114
114
|
}).prepareMessage();
|
|
@@ -123,4 +123,4 @@ assertSigner_fn = function(signer) {
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
exports.SIWEJwtBearerAuth = SIWEJwtBearerAuth;
|
|
126
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-Q5WIUNX5.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getAccessToken,
|
|
4
4
|
getNonce,
|
|
5
5
|
login
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7SW3CC66.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createSnapPublicKeyRequest,
|
|
9
9
|
createSnapSignMessageRequest
|
|
@@ -13,13 +13,15 @@ import {
|
|
|
13
13
|
__privateGet,
|
|
14
14
|
__privateMethod,
|
|
15
15
|
__privateSet
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-U5UIDVOO.mjs";
|
|
17
17
|
|
|
18
18
|
// src/controllers/authentication/AuthenticationController.ts
|
|
19
19
|
import { BaseController } from "@metamask/base-controller";
|
|
20
20
|
var THIRTY_MIN_MS = 1e3 * 60 * 30;
|
|
21
21
|
var controllerName = "AuthenticationController";
|
|
22
|
-
var defaultState = {
|
|
22
|
+
var defaultState = {
|
|
23
|
+
isSignedIn: false
|
|
24
|
+
};
|
|
23
25
|
var metadata = {
|
|
24
26
|
isSignedIn: {
|
|
25
27
|
persist: true,
|
|
@@ -65,6 +67,9 @@ var AuthenticationController = class extends BaseController {
|
|
|
65
67
|
*/
|
|
66
68
|
__privateAdd(this, _snapSignMessage);
|
|
67
69
|
__privateAdd(this, _metametrics, void 0);
|
|
70
|
+
if (!metametrics) {
|
|
71
|
+
throw new Error("`metametrics` field is required");
|
|
72
|
+
}
|
|
68
73
|
__privateSet(this, _metametrics, metametrics);
|
|
69
74
|
__privateMethod(this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
|
|
70
75
|
}
|
|
@@ -148,7 +153,7 @@ performAuthenticationFlow_fn = async function() {
|
|
|
148
153
|
const rawMessage = createLoginRawMessage(nonce, publicKey);
|
|
149
154
|
const signature = await __privateMethod(this, _snapSignMessage, snapSignMessage_fn).call(this, rawMessage);
|
|
150
155
|
const loginResponse = await login(rawMessage, signature, {
|
|
151
|
-
metametricsId: __privateGet(this, _metametrics).getMetaMetricsId(),
|
|
156
|
+
metametricsId: await __privateGet(this, _metametrics).getMetaMetricsId(),
|
|
152
157
|
agent: __privateGet(this, _metametrics).agent
|
|
153
158
|
});
|
|
154
159
|
if (!loginResponse?.token) {
|
|
@@ -158,7 +163,10 @@ performAuthenticationFlow_fn = async function() {
|
|
|
158
163
|
identifierId: loginResponse.profile.identifier_id,
|
|
159
164
|
profileId: loginResponse.profile.profile_id
|
|
160
165
|
};
|
|
161
|
-
const accessToken = await getAccessToken(
|
|
166
|
+
const accessToken = await getAccessToken(
|
|
167
|
+
loginResponse.token,
|
|
168
|
+
__privateGet(this, _metametrics).agent
|
|
169
|
+
);
|
|
162
170
|
if (!accessToken) {
|
|
163
171
|
throw new Error(`Unable to get Access Token`);
|
|
164
172
|
}
|
|
@@ -216,6 +224,7 @@ snapSignMessage_fn = function(message) {
|
|
|
216
224
|
};
|
|
217
225
|
|
|
218
226
|
export {
|
|
227
|
+
defaultState,
|
|
219
228
|
AuthenticationController
|
|
220
229
|
};
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-QU3RCIV3.mjs.map
|