@xmtp/browser-sdk 0.0.3 → 0.0.4
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/index.d.ts +35 -21
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/workers/client.js +1 -1
- package/dist/workers/client.js.map +1 -1
- package/package.json +1 -1
- package/src/Client.ts +146 -45
- package/src/WorkerClient.ts +4 -4
- package/src/index.ts +5 -0
- package/src/types/clientEvents.ts +5 -5
- package/src/types/options.ts +4 -0
- package/src/utils/signer.ts +19 -0
- package/src/workers/client.ts +9 -9
|
@@ -43,21 +43,21 @@ export type ClientEvents =
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
| {
|
|
46
|
-
action: "
|
|
46
|
+
action: "createInboxSignatureText";
|
|
47
47
|
id: string;
|
|
48
48
|
result: string | undefined;
|
|
49
49
|
data: undefined;
|
|
50
50
|
}
|
|
51
51
|
| {
|
|
52
|
-
action: "
|
|
52
|
+
action: "addAccountSignatureText";
|
|
53
53
|
id: string;
|
|
54
54
|
result: string | undefined;
|
|
55
55
|
data: {
|
|
56
|
-
|
|
56
|
+
newAccountAddress: string;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
| {
|
|
60
|
-
action: "
|
|
60
|
+
action: "removeAccountSignatureText";
|
|
61
61
|
id: string;
|
|
62
62
|
result: string | undefined;
|
|
63
63
|
data: {
|
|
@@ -65,7 +65,7 @@ export type ClientEvents =
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
| {
|
|
68
|
-
action: "
|
|
68
|
+
action: "revokeInstallationsSignatureText";
|
|
69
69
|
id: string;
|
|
70
70
|
result: string | undefined;
|
|
71
71
|
data: undefined;
|
package/src/types/options.ts
CHANGED
|
@@ -48,6 +48,10 @@ export type OtherOptions = {
|
|
|
48
48
|
* Logging level
|
|
49
49
|
*/
|
|
50
50
|
loggingLevel?: "off" | "error" | "warn" | "info" | "debug" | "trace";
|
|
51
|
+
/**
|
|
52
|
+
* Disable automatic registration when creating a client
|
|
53
|
+
*/
|
|
54
|
+
disableAutoRegister?: boolean;
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
export type ClientOptions = NetworkOptions &
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;
|
|
2
|
+
export type GetAddress = () => Promise<string> | string;
|
|
3
|
+
export type GetChainId = () => bigint;
|
|
4
|
+
export type GetBlockNumber = () => bigint;
|
|
5
|
+
|
|
6
|
+
export type Signer = {
|
|
7
|
+
getAddress: GetAddress;
|
|
8
|
+
signMessage: SignMessage;
|
|
9
|
+
// these fields indicate that the signer is a smart contract wallet
|
|
10
|
+
getBlockNumber?: GetBlockNumber;
|
|
11
|
+
getChainId?: GetChainId;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SmartContractSigner = Required<Signer>;
|
|
15
|
+
|
|
16
|
+
export const isSmartContractSigner = (
|
|
17
|
+
signer: Signer,
|
|
18
|
+
): signer is SmartContractSigner =>
|
|
19
|
+
"getBlockNumber" in signer && "getChainId" in signer;
|
package/src/workers/client.ts
CHANGED
|
@@ -73,8 +73,8 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
break;
|
|
76
|
-
case "
|
|
77
|
-
const result = await client.
|
|
76
|
+
case "createInboxSignatureText": {
|
|
77
|
+
const result = await client.createInboxSignatureText();
|
|
78
78
|
postMessage({
|
|
79
79
|
id,
|
|
80
80
|
action,
|
|
@@ -82,9 +82,9 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
82
82
|
});
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
|
-
case "
|
|
86
|
-
const result = await client.
|
|
87
|
-
data.
|
|
85
|
+
case "addAccountSignatureText": {
|
|
86
|
+
const result = await client.addAccountSignatureText(
|
|
87
|
+
data.newAccountAddress,
|
|
88
88
|
);
|
|
89
89
|
postMessage({
|
|
90
90
|
id,
|
|
@@ -93,8 +93,8 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
93
93
|
});
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
|
-
case "
|
|
97
|
-
const result = await client.
|
|
96
|
+
case "removeAccountSignatureText": {
|
|
97
|
+
const result = await client.removeAccountSignatureText(
|
|
98
98
|
data.accountAddress,
|
|
99
99
|
);
|
|
100
100
|
postMessage({
|
|
@@ -104,8 +104,8 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
104
104
|
});
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
|
-
case "
|
|
108
|
-
const result = await client.
|
|
107
|
+
case "revokeInstallationsSignatureText": {
|
|
108
|
+
const result = await client.revokeInstallationsSignatureText();
|
|
109
109
|
postMessage({
|
|
110
110
|
id,
|
|
111
111
|
action,
|