@tari-project/wallet-daemon-signer 0.12.1 → 0.12.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/dist/provider.js +2 -2
- package/dist/signer.js +4 -3
- package/dist/webrtc.js +10 -11
- package/package.json +7 -6
package/dist/provider.js
CHANGED
|
@@ -14,7 +14,7 @@ export class WalletDaemonTariProvider {
|
|
|
14
14
|
}
|
|
15
15
|
static async buildWebRtc(params) {
|
|
16
16
|
const allPermissions = WalletDaemonTariProvider.buildPermissions(params);
|
|
17
|
-
|
|
17
|
+
const connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
|
|
18
18
|
const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
|
|
19
19
|
await connection.init(allPermissions, (conn) => {
|
|
20
20
|
params.onConnection?.();
|
|
@@ -50,7 +50,7 @@ export class WalletDaemonTariProvider {
|
|
|
50
50
|
}
|
|
51
51
|
async getSubstate(req) {
|
|
52
52
|
// TODO: Substate address cannot be converted to SubstateId directly - Perhaps we need to change the provider interface
|
|
53
|
-
const { substate
|
|
53
|
+
const { substate } = await this.client.substatesGet({ substate_id: req.substate_address });
|
|
54
54
|
if (!substate) {
|
|
55
55
|
throw new Error(`Substate not found for address: ${req.substate_address}`);
|
|
56
56
|
}
|
package/dist/signer.js
CHANGED
|
@@ -16,7 +16,7 @@ export class WalletDaemonTariSigner {
|
|
|
16
16
|
}
|
|
17
17
|
static async build(params) {
|
|
18
18
|
const allPermissions = WalletDaemonTariSigner.buildPermissions(params);
|
|
19
|
-
|
|
19
|
+
const connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
|
|
20
20
|
const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
|
|
21
21
|
await connection.init(allPermissions, (conn) => {
|
|
22
22
|
params.onConnection?.();
|
|
@@ -82,6 +82,7 @@ export class WalletDaemonTariSigner {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
async getAccount() {
|
|
85
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
85
86
|
const { account, public_key } = (await this.client.accountsGetDefault({}));
|
|
86
87
|
const address = typeof account.address === "object" ? account.address.Component : account.address;
|
|
87
88
|
const { balances } = await this.client.accountsGetBalances({
|
|
@@ -106,7 +107,7 @@ export class WalletDaemonTariSigner {
|
|
|
106
107
|
return await this.client.accountsGetBalances({ account: { ComponentAddress: componentAddress }, refresh: true });
|
|
107
108
|
}
|
|
108
109
|
async getSubstate(substateId) {
|
|
109
|
-
const { substate
|
|
110
|
+
const { substate } = await this.client.substatesGet({ substate_id: substateId });
|
|
110
111
|
if (!substate) {
|
|
111
112
|
throw new Error(`Substate not found for address: ${substateId}`);
|
|
112
113
|
}
|
|
@@ -146,7 +147,7 @@ export class WalletDaemonTariSigner {
|
|
|
146
147
|
return res.public_key;
|
|
147
148
|
}
|
|
148
149
|
async getTemplateDefinition(template_address) {
|
|
149
|
-
|
|
150
|
+
const resp = await this.client.templatesGet({ template_address });
|
|
150
151
|
return resp.template_definition;
|
|
151
152
|
}
|
|
152
153
|
async getConfidentialVaultBalances({ vault_id, view_key_id, maximum_expected_value = null, minimum_expected_value = null, }) {
|
package/dist/webrtc.js
CHANGED
|
@@ -20,12 +20,12 @@ class SignalingServer {
|
|
|
20
20
|
console.log("jsonRpc", method, token, params);
|
|
21
21
|
let id = 0;
|
|
22
22
|
id += 1;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const address = this._server_url;
|
|
24
|
+
const headers = { "Content-Type": "application/json" };
|
|
25
25
|
if (token) {
|
|
26
26
|
headers["Authorization"] = `Bearer ${token}`;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
const response = await fetch(address, {
|
|
29
29
|
method: "POST",
|
|
30
30
|
body: JSON.stringify({
|
|
31
31
|
method: method,
|
|
@@ -35,7 +35,7 @@ class SignalingServer {
|
|
|
35
35
|
}),
|
|
36
36
|
headers: headers,
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
const json = await response.json();
|
|
39
39
|
if (json.error) {
|
|
40
40
|
throw json.error;
|
|
41
41
|
}
|
|
@@ -84,14 +84,14 @@ export class TariConnection {
|
|
|
84
84
|
await this._signalingServer.initToken(permissions);
|
|
85
85
|
// Setup our receiving end
|
|
86
86
|
this._dataChannel.onmessage = (message) => {
|
|
87
|
-
|
|
87
|
+
const response = JSON.parse(message.data);
|
|
88
88
|
console.log("response", response);
|
|
89
89
|
if (!this._callbacks[response.id]) {
|
|
90
90
|
console.error("No callback found for id", response.id);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
// The response should contain id, to identify the Promise.resolve, that is waiting for this result
|
|
94
|
-
|
|
94
|
+
const [resolve, reject] = this._callbacks[response.id];
|
|
95
95
|
delete this._callbacks[response.id];
|
|
96
96
|
if (response.payload?.error) {
|
|
97
97
|
reject(new Error(response.payload.error));
|
|
@@ -103,8 +103,7 @@ export class TariConnection {
|
|
|
103
103
|
this._dataChannel.onopen = () => {
|
|
104
104
|
// This should be removed before the release, but it's good for debugging.
|
|
105
105
|
console.log("Data channel is open!");
|
|
106
|
-
this.sendMessage({ id: 0, jsonrpc: "2.0", method: "get.token", params: {} }, this._signalingServer.token)
|
|
107
|
-
.then((walletToken) => {
|
|
106
|
+
this.sendMessage({ id: 0, jsonrpc: "2.0", method: "get.token", params: {} }, this._signalingServer.token).then((walletToken) => {
|
|
108
107
|
if (typeof walletToken !== "string") {
|
|
109
108
|
throw Error("Received invalid JWT from wallet daemon");
|
|
110
109
|
}
|
|
@@ -141,11 +140,11 @@ export class TariConnection {
|
|
|
141
140
|
async setAnswer() {
|
|
142
141
|
// This is called once the other end got the offer and ices and created and store an answer and its ice candidates
|
|
143
142
|
// We get its answer sdp
|
|
144
|
-
|
|
143
|
+
const sdp = await this._signalingServer.getAnswer();
|
|
145
144
|
// And its ice candidates
|
|
146
|
-
|
|
145
|
+
const iceCandidates = await this._signalingServer.getIceCandidates();
|
|
147
146
|
// For us the answer is remote sdp
|
|
148
|
-
|
|
147
|
+
const answer = new RTCSessionDescription({ sdp, type: "answer" });
|
|
149
148
|
this._peerConnection.setRemoteDescription(answer);
|
|
150
149
|
// We add all the ice candidates to connect, the other end is doing the same with our ice candidates
|
|
151
150
|
for (const iceCandidate of iceCandidates) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/wallet-daemon-signer",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@tari-project/typescript-bindings": ">=1.14.0",
|
|
14
14
|
"@tari-project/wallet_jrpc_client": "^1.7.2",
|
|
15
|
-
"@tari-project/tari-
|
|
16
|
-
"@tari-project/tari-provider": "^0.12.
|
|
17
|
-
"@tari-project/
|
|
18
|
-
"@tari-project/
|
|
15
|
+
"@tari-project/tari-permissions": "^0.12.2",
|
|
16
|
+
"@tari-project/tari-provider": "^0.12.2",
|
|
17
|
+
"@tari-project/tarijs-types": "^0.12.2",
|
|
18
|
+
"@tari-project/tari-signer": "^0.12.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^22.13.1",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"main": "dist/index.js",
|
|
28
28
|
"types": "dist/index.d.ts",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "tsc -b"
|
|
30
|
+
"build": "tsc -b",
|
|
31
|
+
"lint": "eslint src/"
|
|
31
32
|
}
|
|
32
33
|
}
|