@novasamatech/host-papp 0.7.5-0 → 0.7.5-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.
|
@@ -6,7 +6,17 @@ import { nanoid } from 'nanoid';
|
|
|
6
6
|
import { ResultAsync, err, ok, okAsync } from 'neverthrow';
|
|
7
7
|
import { AccountId } from 'polkadot-api';
|
|
8
8
|
import { createAsyncTaskPool } from '../../helpers/createAsyncTaskPool.js';
|
|
9
|
+
import { toError } from '../../helpers/utils.js';
|
|
9
10
|
import { RemoteMessageCodec } from './scale/remoteMessage.js';
|
|
11
|
+
// Timeout for the inner queue task. Without it the queue wedges forever when
|
|
12
|
+
// the remote signer doesn't respond — e.g. the request
|
|
13
|
+
// payload is for an SDK version the mobile app doesn't support yet. After
|
|
14
|
+
// this timeout the queue task fails, freeing the pool for the next request.
|
|
15
|
+
const QUEUE_TASK_TIMEOUT_MS = 180_000;
|
|
16
|
+
function withQueueTimeout(resultAsync, label) {
|
|
17
|
+
const timeoutPromise = new Promise(resolve => setTimeout(() => resolve(err(new Error(`${label} timed out — queue freed`))), QUEUE_TASK_TIMEOUT_MS));
|
|
18
|
+
return ResultAsync.fromPromise(Promise.race([resultAsync, timeoutPromise]), toError).andThen(r => r);
|
|
19
|
+
}
|
|
10
20
|
export function createUserSession({ userSession, statementStore, encryption, storage, prover, }) {
|
|
11
21
|
const accountId = AccountId();
|
|
12
22
|
const requestQueue = createAsyncTaskPool({ poolSize: 1, retryCount: 0, retryDelay: 0 });
|
|
@@ -54,7 +64,7 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
54
64
|
return message.data.value.value.payload;
|
|
55
65
|
}
|
|
56
66
|
};
|
|
57
|
-
|
|
67
|
+
const inner = request
|
|
58
68
|
.andThen(() => session.waitForRequestMessage(RemoteMessageCodec, responseFilter))
|
|
59
69
|
.andThen(message => {
|
|
60
70
|
if (message.success) {
|
|
@@ -64,6 +74,7 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
64
74
|
return err(new Error(message.value));
|
|
65
75
|
}
|
|
66
76
|
});
|
|
77
|
+
return withQueueTimeout(inner, 'signPayload');
|
|
67
78
|
});
|
|
68
79
|
},
|
|
69
80
|
signRaw(payload) {
|
|
@@ -83,7 +94,7 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
83
94
|
return message.data.value.value.payload;
|
|
84
95
|
}
|
|
85
96
|
};
|
|
86
|
-
|
|
97
|
+
const inner = request
|
|
87
98
|
.andThen(() => session.waitForRequestMessage(RemoteMessageCodec, responseFilter))
|
|
88
99
|
.andThen(message => {
|
|
89
100
|
if (message.success) {
|
|
@@ -93,6 +104,7 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
93
104
|
return err(new Error(message.value));
|
|
94
105
|
}
|
|
95
106
|
});
|
|
107
|
+
return withQueueTimeout(inner, 'signRaw');
|
|
96
108
|
});
|
|
97
109
|
},
|
|
98
110
|
sendDisconnectMessage() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.5-
|
|
4
|
+
"version": "0.7.5-2",
|
|
5
5
|
"description": "Polkadot app integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@noble/ciphers": "2.2.0",
|
|
30
30
|
"@noble/curves": "2.2.0",
|
|
31
31
|
"@noble/hashes": "2.2.0",
|
|
32
|
-
"@novasamatech/host-api": "0.7.5-
|
|
33
|
-
"@novasamatech/scale": "0.7.5-
|
|
34
|
-
"@novasamatech/statement-store": "0.7.5-
|
|
35
|
-
"@novasamatech/storage-adapter": "0.7.5-
|
|
32
|
+
"@novasamatech/host-api": "0.7.5-2",
|
|
33
|
+
"@novasamatech/scale": "0.7.5-2",
|
|
34
|
+
"@novasamatech/statement-store": "0.7.5-2",
|
|
35
|
+
"@novasamatech/storage-adapter": "0.7.5-2",
|
|
36
36
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
37
37
|
"nanoevents": "9.1.0",
|
|
38
38
|
"nanoid": "5.1.9",
|