@dynamic-labs/multi-wallet 0.11.19 → 0.11.21
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/package.json +2 -2
- package/src/utils/message.d.ts +1 -0
- package/src/utils/message.js +26 -5
- package/src/utils/message.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/multi-wallet",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.21",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
7
|
"repository": "git://github.com/dynamic-labs/WalletKit.git",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"buffer": "^6.0.3",
|
|
10
|
+
"ethers": "^5.6.9",
|
|
10
11
|
"@randlabs/myalgo-connect": "^1.3.0",
|
|
11
12
|
"@solana/web3.js": "^1.50.1",
|
|
12
|
-
"ethers": "^5.6.9",
|
|
13
13
|
"@coinbase/wallet-sdk": "^3.4.0",
|
|
14
14
|
"@walletconnect/client": "^1.8.0",
|
|
15
15
|
"@walletconnect/ethereum-provider": "^1.7.8",
|
package/src/utils/message.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export interface MessageParameters {
|
|
|
9
9
|
uri: string;
|
|
10
10
|
}
|
|
11
11
|
export declare const generateMessageToSign: ({ chain, domain, nonce, uri, publicKey, issuedAt, statement, requestId, }: MessageParameters) => string;
|
|
12
|
+
export declare const getEip55Address: (publicKey: string, chainId?: string) => string;
|
package/src/utils/message.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getEip55Address = exports.generateMessageToSign = void 0;
|
|
7
|
+
const utils_1 = require("ethers/lib/utils");
|
|
8
|
+
const console_1 = __importDefault(require("./console"));
|
|
2
9
|
// Util class to generate a message to sign, inspired by EIP-4361
|
|
3
10
|
// https://docs.login.xyz/general-information/siwe-overview/eip-4361
|
|
4
11
|
// TODO:
|
|
5
12
|
// - We might need to add prefix: \x19Ethereum Signed Message:\n<length of message> as per EIP-712
|
|
6
13
|
// - This implementation is missing some of the optional values
|
|
7
14
|
// - The work above and more should be covered in DYN-252
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.generateMessageToSign = void 0;
|
|
10
15
|
// internal mapping of blockchain abbrev to full network name
|
|
11
16
|
const networkNames = {
|
|
12
17
|
ALGO: 'Algorand',
|
|
@@ -28,13 +33,14 @@ const generateMessageToSign = ({ chain, domain, nonce, uri, publicKey, issuedAt
|
|
|
28
33
|
// https://docs.login.xyz/general-information/siwe-overview/eip-4361
|
|
29
34
|
const networkName = networkNames[chain.toUpperCase()];
|
|
30
35
|
const header = `${domain} wants you to sign in with your ${networkName} account:`;
|
|
31
|
-
|
|
36
|
+
// This is only required for Ethereum-based wallets
|
|
37
|
+
const chainId = chainIds[chain.toUpperCase()];
|
|
38
|
+
const messageAddress = (0, exports.getEip55Address)(publicKey, chainId);
|
|
39
|
+
const prefix = [header, messageAddress].join('\n');
|
|
32
40
|
const prefixWithStatement = `${[prefix, statement].join('\n\n')}\n`;
|
|
33
41
|
const suffixFields = [];
|
|
34
42
|
suffixFields.push(`URI: ${uri}`);
|
|
35
43
|
suffixFields.push('Version: 1');
|
|
36
|
-
// This is only required for Ethereum-based wallets
|
|
37
|
-
const chainId = chainIds[chain.toUpperCase()];
|
|
38
44
|
if (chainId) {
|
|
39
45
|
suffixFields.push(`Chain ID: ${chainId}`);
|
|
40
46
|
}
|
|
@@ -51,4 +57,19 @@ const generateMessageToSign = ({ chain, domain, nonce, uri, publicKey, issuedAt
|
|
|
51
57
|
return [prefixWithStatement, suffix].join('\n');
|
|
52
58
|
};
|
|
53
59
|
exports.generateMessageToSign = generateMessageToSign;
|
|
60
|
+
// The SIWE parser library used to validate signed messages for EVM/Ethereum
|
|
61
|
+
// checks that an address is in EIP55 format, so make sure we do that here.
|
|
62
|
+
// see: https://eips.ethereum.org/EIPS/eip-55
|
|
63
|
+
const getEip55Address = (publicKey, chainId) => {
|
|
64
|
+
try {
|
|
65
|
+
if (chainId) {
|
|
66
|
+
return (0, utils_1.getAddress)(publicKey);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
console_1.default.log(`Error getting checksum, returning default ${publicKey}`);
|
|
71
|
+
}
|
|
72
|
+
return publicKey;
|
|
73
|
+
};
|
|
74
|
+
exports.getEip55Address = getEip55Address;
|
|
54
75
|
//# sourceMappingURL=message.js.map
|
package/src/utils/message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../packages/multi-wallet/src/utils/message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../packages/multi-wallet/src/utils/message.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA8C;AAE9C,wDAAgC;AAEhC,iEAAiE;AACjE,oEAAoE;AACpE,QAAQ;AACR,mGAAmG;AACnG,+DAA+D;AAC/D,yDAAyD;AAEzD,6DAA6D;AAC7D,MAAM,YAAY,GAA8B;IAC9C,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,gEAAgE;AAChE,qEAAqE;AACrE,MAAM,QAAQ,GAA0C;IACtD,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,SAAS;CACf,CAAC;AAaK,MAAM,qBAAqB,GAAG,CAAC,EACpC,KAAK,EACL,MAAM,EACN,KAAK,EACL,GAAG,EACH,SAA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