@multiplatform.one/wallet 7.23.2 → 7.25.0
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/dist/cjs/util.cjs +5 -9
- package/dist/cjs/util.native.js +5 -9
- package/dist/cjs/util.native.js.map +1 -1
- package/dist/esm/util.mjs +5 -9
- package/dist/esm/util.mjs.map +1 -1
- package/dist/esm/util.native.js +5 -9
- package/dist/esm/util.native.js.map +1 -1
- package/package.json +5 -5
- package/src/util.spec.ts +41 -0
- package/src/util.ts +2 -10
- package/types/util.d.ts.map +1 -1
package/dist/cjs/util.cjs
CHANGED
|
@@ -26,7 +26,7 @@ __export(util_exports, {
|
|
|
26
26
|
getNonce: () => getNonce
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(util_exports);
|
|
29
|
-
var
|
|
29
|
+
var import_message = require("@multiplatform.one/web3/message");
|
|
30
30
|
async function getNonce(keycloakSiweUrl) {
|
|
31
31
|
const res = await fetch(`${keycloakSiweUrl}/nonce`, {
|
|
32
32
|
credentials: "include"
|
|
@@ -41,13 +41,9 @@ async function createMessage(nonce, address, chainId) {
|
|
|
41
41
|
if (typeof window === "undefined") {
|
|
42
42
|
throw new Error("createMessage requires browser context");
|
|
43
43
|
}
|
|
44
|
-
return
|
|
45
|
-
version: "1",
|
|
46
|
-
domain: window.location.host,
|
|
47
|
-
uri: window.location.origin,
|
|
48
|
-
address,
|
|
49
|
-
chainId,
|
|
44
|
+
return (0, import_message.buildWalletMessage)("eth", {
|
|
50
45
|
nonce,
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
address,
|
|
47
|
+
chainId
|
|
48
|
+
});
|
|
53
49
|
}
|
package/dist/cjs/util.native.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(util_exports, {
|
|
|
28
28
|
getNonce: () => getNonce
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(util_exports);
|
|
31
|
-
var
|
|
31
|
+
var import_message = require("@multiplatform.one/web3/message");
|
|
32
32
|
async function getNonce(keycloakSiweUrl) {
|
|
33
33
|
var res = await fetch(`${keycloakSiweUrl}/nonce`, {
|
|
34
34
|
credentials: "include"
|
|
@@ -43,14 +43,10 @@ async function createMessage(nonce, address, chainId) {
|
|
|
43
43
|
if (typeof window === "undefined") {
|
|
44
44
|
throw new Error("createMessage requires browser context");
|
|
45
45
|
}
|
|
46
|
-
return
|
|
47
|
-
version: "1",
|
|
48
|
-
domain: window.location.host,
|
|
49
|
-
uri: window.location.origin,
|
|
50
|
-
address,
|
|
51
|
-
chainId,
|
|
46
|
+
return (0, import_message.buildWalletMessage)("eth", {
|
|
52
47
|
nonce,
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
address,
|
|
49
|
+
chainId
|
|
50
|
+
});
|
|
55
51
|
}
|
|
56
52
|
//# sourceMappingURL=util.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","util_exports","createMessage","getNonce","module","exports","
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","util_exports","createMessage","getNonce","module","exports","import_message","require","keycloakSiweUrl","res","fetch","credentials","ok","data","text","length","Error","nonce","address","chainId","window","buildWalletMessage"],"sources":["util.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar util_exports = {};\n__export(util_exports, {\n createMessage: () => createMessage,\n getNonce: () => getNonce\n});\nmodule.exports = __toCommonJS(util_exports);\nvar import_message = require(\"@multiplatform.one/web3/message\");\nasync function getNonce(keycloakSiweUrl) {\n var res = await fetch(`${keycloakSiweUrl}/nonce`, {\n credentials: \"include\"\n });\n if (res.ok) {\n var data = await res.text();\n if (data === null || data === void 0 ? void 0 : data.length) return data;\n }\n throw new Error(\"failed to get nonce\");\n}\nasync function createMessage(nonce, address, chainId) {\n if (typeof window === \"undefined\") {\n throw new Error(\"createMessage requires browser context\");\n }\n return (0, import_message.buildWalletMessage)(\"eth\", {\n nonce,\n address,\n chainId\n });\n}\n//# sourceMappingURL=util.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAE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ID,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,IAAI,CAACE,MAAM,EAAE,OAAOF,IAAI;EAC1E;EACA,MAAM,IAAIG,KAAK,CAAC,qBAAqB,CAAC;AACxC;AACA,eAAed,aAAaA,CAACe,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAE;EACpD,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,IAAIJ,KAAK,CAAC,wCAAwC,CAAC;EAC3D;EACA,OAAO,CAAC,CAAC,EAAEV,cAAc,CAACe,kBAAkB,EAAE,KAAK,EAAE;IACnDJ,KAAK;IACLC,OAAO;IACPC;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/dist/esm/util.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildWalletMessage } from "@multiplatform.one/web3/message";
|
|
2
2
|
async function getNonce(keycloakSiweUrl) {
|
|
3
3
|
const res = await fetch(`${keycloakSiweUrl}/nonce`, {
|
|
4
4
|
credentials: "include"
|
|
@@ -13,15 +13,11 @@ async function createMessage(nonce, address, chainId) {
|
|
|
13
13
|
if (typeof window === "undefined") {
|
|
14
14
|
throw new Error("createMessage requires browser context");
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
version: "1",
|
|
18
|
-
domain: window.location.host,
|
|
19
|
-
uri: window.location.origin,
|
|
20
|
-
address,
|
|
21
|
-
chainId,
|
|
16
|
+
return buildWalletMessage("eth", {
|
|
22
17
|
nonce,
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
address,
|
|
19
|
+
chainId
|
|
20
|
+
});
|
|
25
21
|
}
|
|
26
22
|
export { createMessage, getNonce };
|
|
27
23
|
//# sourceMappingURL=util.mjs.map
|
package/dist/esm/util.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["buildWalletMessage","getNonce","keycloakSiweUrl","res","fetch","credentials","ok","data","text","length","Error","createMessage","nonce","address","chainId","window"],"sources":["../../src/util.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AAGnC,eAAsBC,SAASC,eAAA,EAAyB;EACtD,MAAMC,GAAA,GAAM,MAAMC,KAAA,CAAM,GAAGF,eAAe,UAAU;IAClDG,WAAA,EAAa;EACf,CAAC;EACD,IAAIF,GAAA,CAAIG,EAAA,EAAI;IACV,MAAMC,IAAA,GAAO,MAAMJ,GAAA,CAAIK,IAAA,CAAK;IAC5B,IAAID,IAAA,EAAME,MAAA,EAAQ,OAAOF,IAAA;EAC3B;EACA,MAAM,IAAIG,KAAA,CAAM,qBAAqB;AACvC;AAEA,eAAsBC,cAAcC,KAAA,EAAeC,OAAA,EAAkBC,OAAA,EAAiB;EACpF,IAAI,OAAOC,MAAA,KAAW,aAAa;IACjC,MAAM,IAAIL,KAAA,CAAM,wCAAwC;EAC1D;EACA,OAAOV,kBAAA,CAAmB,OAAO;IAAEY,KAAA;IAAOC,OAAA;IAASC;EAAQ,CAAC;AAC9D","ignoreList":[]}
|
package/dist/esm/util.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildWalletMessage } from "@multiplatform.one/web3/message";
|
|
2
2
|
async function getNonce(keycloakSiweUrl) {
|
|
3
3
|
var res = await fetch(`${keycloakSiweUrl}/nonce`, {
|
|
4
4
|
credentials: "include"
|
|
@@ -13,15 +13,11 @@ async function createMessage(nonce, address, chainId) {
|
|
|
13
13
|
if (typeof window === "undefined") {
|
|
14
14
|
throw new Error("createMessage requires browser context");
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
version: "1",
|
|
18
|
-
domain: window.location.host,
|
|
19
|
-
uri: window.location.origin,
|
|
20
|
-
address,
|
|
21
|
-
chainId,
|
|
16
|
+
return buildWalletMessage("eth", {
|
|
22
17
|
nonce,
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
address,
|
|
19
|
+
chainId
|
|
20
|
+
});
|
|
25
21
|
}
|
|
26
22
|
export { createMessage, getNonce };
|
|
27
23
|
//# sourceMappingURL=util.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["buildWalletMessage","getNonce","keycloakSiweUrl","res","fetch","credentials","ok","data","text","length","Error","createMessage","nonce","address","chainId","window"],"sources":["util.native.js"],"sourcesContent":["import { buildWalletMessage } from \"@multiplatform.one/web3/message\";\nasync function getNonce(keycloakSiweUrl) {\n var res = await fetch(`${keycloakSiweUrl}/nonce`, {\n credentials: \"include\"\n });\n if (res.ok) {\n var data = await res.text();\n if (data === null || data === void 0 ? void 0 : data.length) return data;\n }\n throw new Error(\"failed to get nonce\");\n}\nasync function createMessage(nonce, address, chainId) {\n if (typeof window === \"undefined\") {\n throw new Error(\"createMessage requires browser context\");\n }\n return buildWalletMessage(\"eth\", {\n nonce,\n address,\n chainId\n });\n}\nexport {\n createMessage,\n getNonce\n};\n//# sourceMappingURL=util.js.map\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,iCAAiC;AACpE,eAAeC,QAAQA,CAACC,eAAe,EAAE;EACvC,IAAIC,GAAG,GAAG,MAAMC,KAAK,CAAC,GAAGF,eAAe,QAAQ,EAAE;IAChDG,WAAW,EAAE;EACf,CAAC,CAAC;EACF,IAAIF,GAAG,CAACG,EAAE,EAAE;IACV,IAAIC,IAAI,GAAG,MAAMJ,GAAG,CAACK,IAAI,CAAC,CAAC;IAC3B,IAAID,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,IAAI,CAACE,MAAM,EAAE,OAAOF,IAAI;EAC1E;EACA,MAAM,IAAIG,KAAK,CAAC,qBAAqB,CAAC;AACxC;AACA,eAAeC,aAAaA,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAE;EACpD,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,IAAIL,KAAK,CAAC,wCAAwC,CAAC;EAC3D;EACA,OAAOV,kBAAkB,CAAC,KAAK,EAAE;IAC/BY,KAAK;IACLC,OAAO;IACPC;EACF,CAAC,CAAC;AACJ;AACA,SACEH,aAAa,EACbV,QAAQ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/wallet",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.25.0",
|
|
4
4
|
"description": "siwe keycloak client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"4361",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@multiplatform.one/keycloak-js": "7.
|
|
46
|
-
"@multiplatform.one/store": "7.
|
|
47
|
-
"@multiplatform.one/web3": "7.
|
|
45
|
+
"@multiplatform.one/keycloak-js": "7.25.0",
|
|
46
|
+
"@multiplatform.one/store": "7.25.0",
|
|
47
|
+
"@multiplatform.one/web3": "7.25.0",
|
|
48
48
|
"siwe": "^3.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@multiplatform.one/config": "7.
|
|
51
|
+
"@multiplatform.one/config": "7.25.0",
|
|
52
52
|
"@tamagui/build": "2.7.6",
|
|
53
53
|
"@tanstack/react-query": "^5.100.7",
|
|
54
54
|
"@types/js-cookie": "^3.0.6",
|
package/src/util.spec.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { buildWalletMessage } from "@multiplatform.one/web3/message";
|
|
2
|
+
import { SiweMessage } from "siwe";
|
|
1
3
|
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
|
|
2
4
|
import { getNonce, createMessage } from "./util";
|
|
3
5
|
|
|
@@ -69,4 +71,43 @@ describe("createMessage", () => {
|
|
|
69
71
|
expect(message).toContain(addr);
|
|
70
72
|
expect(message).toContain("Chain ID: 1");
|
|
71
73
|
});
|
|
74
|
+
|
|
75
|
+
it("is byte-identical to siwe's EIP-4361 prepareMessage", async () => {
|
|
76
|
+
vi.useFakeTimers();
|
|
77
|
+
vi.setSystemTime(new Date("2026-09-26T20:48:18.648Z"));
|
|
78
|
+
try {
|
|
79
|
+
const addr = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" as `0x${string}`;
|
|
80
|
+
const reference = new SiweMessage({
|
|
81
|
+
version: "1",
|
|
82
|
+
domain: window.location.host,
|
|
83
|
+
uri: window.location.origin,
|
|
84
|
+
address: addr,
|
|
85
|
+
chainId: 137,
|
|
86
|
+
nonce: "nonce12345678",
|
|
87
|
+
statement: "Sign in With Ethereum.",
|
|
88
|
+
}).prepareMessage();
|
|
89
|
+
expect(await createMessage("nonce12345678", addr, 137)).toBe(reference);
|
|
90
|
+
} finally {
|
|
91
|
+
vi.useRealTimers();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("buildWalletMessage eth without a statement", () => {
|
|
97
|
+
const fields = {
|
|
98
|
+
domain: "app.multiplatform.one",
|
|
99
|
+
uri: "https://app.multiplatform.one",
|
|
100
|
+
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
|
|
101
|
+
chainId: 1,
|
|
102
|
+
nonce: "nonce12345678",
|
|
103
|
+
issuedAt: "2026-09-26T20:48:18.648Z",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
it.each([null, ""])("a %j statement is siwe's statement-less EIP-4361 message", (statement) => {
|
|
107
|
+
const message = buildWalletMessage("eth", { ...fields, statement });
|
|
108
|
+
expect(message).toBe(new SiweMessage({ ...fields, version: "1" }).prepareMessage());
|
|
109
|
+
const parsed = new SiweMessage(message);
|
|
110
|
+
expect(parsed.statement).toBeUndefined();
|
|
111
|
+
expect(parsed.nonce).toBe(fields.nonce);
|
|
112
|
+
});
|
|
72
113
|
});
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildWalletMessage } from "@multiplatform.one/web3/message";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
|
|
4
4
|
export async function getNonce(keycloakSiweUrl: string) {
|
|
@@ -16,13 +16,5 @@ export async function createMessage(nonce: string, address: Address, chainId: nu
|
|
|
16
16
|
if (typeof window === "undefined") {
|
|
17
17
|
throw new Error("createMessage requires browser context");
|
|
18
18
|
}
|
|
19
|
-
return
|
|
20
|
-
version: "1",
|
|
21
|
-
domain: window.location.host,
|
|
22
|
-
uri: window.location.origin,
|
|
23
|
-
address,
|
|
24
|
-
chainId,
|
|
25
|
-
nonce,
|
|
26
|
-
statement: "Sign in With Ethereum.",
|
|
27
|
-
}).prepareMessage();
|
|
19
|
+
return buildWalletMessage("eth", { nonce, address, chainId });
|
|
28
20
|
}
|
package/types/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,wBAAsB,QAAQ,CAAC,eAAe,EAAE,MAAM,mBASrD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,wBAAsB,QAAQ,CAAC,eAAe,EAAE,MAAM,mBASrD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAKnF"}
|