@vordium/sdk 0.2.1 → 0.3.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/README.md +31 -5
- package/dist/cjs/client.js +257 -52
- package/dist/cjs/http.js +46 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/network.js +150 -10
- package/dist/cjs/nonce.js +7 -3
- package/dist/cjs/outcome.js +649 -0
- package/dist/cjs/outcomeWords.js +172 -0
- package/dist/cjs/pins.js +5 -0
- package/dist/cjs/releaseRecord.js +870 -0
- package/dist/cjs/types.js +2 -1
- package/dist/esm/client.d.ts +92 -9
- package/dist/esm/client.js +257 -52
- package/dist/esm/http.d.ts +6 -0
- package/dist/esm/http.js +46 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/network.d.ts +66 -12
- package/dist/esm/network.js +148 -9
- package/dist/esm/nonce.d.ts +3 -1
- package/dist/esm/nonce.js +7 -3
- package/dist/esm/outcome.d.ts +201 -0
- package/dist/esm/outcome.js +623 -0
- package/dist/esm/outcomeWords.d.ts +168 -0
- package/dist/esm/outcomeWords.js +169 -0
- package/dist/esm/pins.d.ts +8 -1
- package/dist/esm/pins.js +5 -0
- package/dist/esm/releaseRecord.d.ts +147 -0
- package/dist/esm/releaseRecord.js +856 -0
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.js +2 -1
- package/package.json +3 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** The words of an action whose outcome is not yet known: {action: {state: {text, next}}}. Placeholders in
|
|
2
|
+
* braces are filled by the caller. */
|
|
3
|
+
export declare const OUTCOME_WORDS: {
|
|
4
|
+
readonly headline: {
|
|
5
|
+
readonly pending_checking: "Pending — checking";
|
|
6
|
+
};
|
|
7
|
+
readonly limit_s: 120;
|
|
8
|
+
readonly actions: {
|
|
9
|
+
readonly order: {
|
|
10
|
+
readonly pending_checking: {
|
|
11
|
+
readonly text: "Pending — checking. Your order was sent but the answer was lost. Checking the network for it.";
|
|
12
|
+
readonly next: "Do not place it again. This takes up to 2 minutes.";
|
|
13
|
+
};
|
|
14
|
+
readonly applied: {
|
|
15
|
+
readonly text: "{order_words}. Found on the network at block {height}.";
|
|
16
|
+
readonly next: "";
|
|
17
|
+
};
|
|
18
|
+
readonly refused: {
|
|
19
|
+
readonly text: "Not placed: {meaning}.";
|
|
20
|
+
readonly next: "{action}";
|
|
21
|
+
};
|
|
22
|
+
readonly not_applied: {
|
|
23
|
+
readonly text: "Not placed. The network did not take it, and its time to apply has passed.";
|
|
24
|
+
readonly next: "You can place it again.";
|
|
25
|
+
};
|
|
26
|
+
readonly still_unknown: {
|
|
27
|
+
readonly text: "Still not known after 2 minutes. It was not sent again and may still apply.";
|
|
28
|
+
readonly next: "Check your open orders before you place it again.";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly cancel: {
|
|
32
|
+
readonly pending_checking: {
|
|
33
|
+
readonly text: "Pending — checking. Your cancel was sent but the answer was lost. Checking whether the order is gone.";
|
|
34
|
+
readonly next: "Wait. This takes up to 2 minutes.";
|
|
35
|
+
};
|
|
36
|
+
readonly applied: {
|
|
37
|
+
readonly text: "Cancelled. The order is off the book.";
|
|
38
|
+
readonly next: "";
|
|
39
|
+
};
|
|
40
|
+
readonly applied_other: {
|
|
41
|
+
readonly text: "Filled before the cancel.";
|
|
42
|
+
readonly next: "Check your position.";
|
|
43
|
+
};
|
|
44
|
+
readonly refused: {
|
|
45
|
+
readonly text: "Not cancelled: {meaning}.";
|
|
46
|
+
readonly next: "{action}";
|
|
47
|
+
};
|
|
48
|
+
readonly still_unknown: {
|
|
49
|
+
readonly text: "Still not known after 2 minutes. The order is still on the book.";
|
|
50
|
+
readonly next: "You can cancel it again: cancelling twice has no extra effect.";
|
|
51
|
+
};
|
|
52
|
+
readonly still_unknown_gone: {
|
|
53
|
+
readonly text: "Still not known after 2 minutes. The order is off the book: it was cancelled or filled.";
|
|
54
|
+
readonly next: "Check your position.";
|
|
55
|
+
};
|
|
56
|
+
readonly still_unknown_unread: {
|
|
57
|
+
readonly text: "Still not known after 2 minutes. The network's reads did not answer.";
|
|
58
|
+
readonly next: "You can cancel it again: cancelling twice has no extra effect.";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly cancel_all: {
|
|
62
|
+
readonly pending_checking: {
|
|
63
|
+
readonly text: "Pending — checking. Cancel all was sent but the answer was lost. Checking your open orders.";
|
|
64
|
+
readonly next: "Wait. This takes up to 2 minutes.";
|
|
65
|
+
};
|
|
66
|
+
readonly applied: {
|
|
67
|
+
readonly text: "All {n} orders cancelled.";
|
|
68
|
+
readonly next: "";
|
|
69
|
+
};
|
|
70
|
+
readonly applied_other: {
|
|
71
|
+
readonly text: "{n} of {m} cancelled; {k} filled first.";
|
|
72
|
+
readonly next: "";
|
|
73
|
+
};
|
|
74
|
+
readonly refused: {
|
|
75
|
+
readonly text: "Not cancelled: {meaning}.";
|
|
76
|
+
readonly next: "";
|
|
77
|
+
};
|
|
78
|
+
readonly still_unknown: {
|
|
79
|
+
readonly text: "Still not known after 2 minutes. {n} orders are still open.";
|
|
80
|
+
readonly next: "Check your open orders; cancel what is still open.";
|
|
81
|
+
};
|
|
82
|
+
readonly still_unknown_unread: {
|
|
83
|
+
readonly text: "Still not known after 2 minutes. The network's reads did not answer.";
|
|
84
|
+
readonly next: "Check your open orders; cancel what is still open.";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly close_all: {
|
|
88
|
+
readonly pending_checking: {
|
|
89
|
+
readonly text: "Pending — checking. The closes were sent but the answers were lost. Checking your positions.";
|
|
90
|
+
readonly next: "Wait. This takes up to 2 minutes.";
|
|
91
|
+
};
|
|
92
|
+
readonly applied: {
|
|
93
|
+
readonly text: "{n} positions closed.";
|
|
94
|
+
readonly next: "";
|
|
95
|
+
};
|
|
96
|
+
readonly applied_other: {
|
|
97
|
+
readonly text: "{n} of {m} closed. {k} still open.";
|
|
98
|
+
readonly next: "Close them on the trading page.";
|
|
99
|
+
};
|
|
100
|
+
readonly refused: {
|
|
101
|
+
readonly text: "Not closed: {meaning}.";
|
|
102
|
+
readonly next: "";
|
|
103
|
+
};
|
|
104
|
+
readonly still_unknown: {
|
|
105
|
+
readonly text: "Still not known after 2 minutes. {n} positions are still open.";
|
|
106
|
+
readonly next: "Close what is still open on the trading page.";
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
readonly revoke: {
|
|
110
|
+
readonly pending_checking: {
|
|
111
|
+
readonly text: "Pending — checking. The revoke was sent. Checking that the agent is revoked.";
|
|
112
|
+
readonly next: "Wait. This takes up to 2 minutes.";
|
|
113
|
+
};
|
|
114
|
+
readonly applied: {
|
|
115
|
+
readonly text: "Agent revoked at block {height}. {m} orders cancelled.";
|
|
116
|
+
readonly next: "";
|
|
117
|
+
};
|
|
118
|
+
readonly refused: {
|
|
119
|
+
readonly text: "Not revoked: {meaning}.";
|
|
120
|
+
readonly next: "";
|
|
121
|
+
};
|
|
122
|
+
readonly still_unknown: {
|
|
123
|
+
readonly text: "Still not known after 2 minutes. The agent is still live.";
|
|
124
|
+
readonly next: "You can revoke again: it has no extra effect.";
|
|
125
|
+
};
|
|
126
|
+
readonly still_unknown_unread: {
|
|
127
|
+
readonly text: "Still not known after 2 minutes. The network's reads did not answer.";
|
|
128
|
+
readonly next: "You can revoke again: it has no extra effect.";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
readonly stop: {
|
|
132
|
+
readonly pending_checking: {
|
|
133
|
+
readonly text: "Pending — checking. The stop was sent. Checking that your trading key and agents are stopped.";
|
|
134
|
+
readonly next: "Wait. This takes up to 2 minutes.";
|
|
135
|
+
};
|
|
136
|
+
readonly applied: {
|
|
137
|
+
readonly text: "Stopped on the network: no trading key, no live agent, no open order.";
|
|
138
|
+
readonly next: "";
|
|
139
|
+
};
|
|
140
|
+
readonly applied_other: {
|
|
141
|
+
readonly text: "Your trading key and every agent are stopped. {n} orders your wallet placed itself stay open.";
|
|
142
|
+
readonly next: "";
|
|
143
|
+
};
|
|
144
|
+
readonly refused: {
|
|
145
|
+
readonly text: "Not stopped: {meaning}.";
|
|
146
|
+
readonly next: "";
|
|
147
|
+
};
|
|
148
|
+
readonly not_applied: {
|
|
149
|
+
readonly text: "Not stopped. That signature has passed its time to apply.";
|
|
150
|
+
readonly next: "Press Stop everything now again.";
|
|
151
|
+
};
|
|
152
|
+
readonly still_unknown: {
|
|
153
|
+
readonly text: "Still not known after 2 minutes. {what_is_live}.";
|
|
154
|
+
readonly next: "You can stop again: it has no extra effect.";
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
readonly resend_while_pending: {
|
|
159
|
+
readonly order: null;
|
|
160
|
+
readonly cancel: "Send the same cancel again";
|
|
161
|
+
readonly cancel_all: null;
|
|
162
|
+
readonly close_all: null;
|
|
163
|
+
readonly revoke: "Send the same revoke again";
|
|
164
|
+
readonly stop: "Send the same stop again";
|
|
165
|
+
};
|
|
166
|
+
readonly check_again: "Check again";
|
|
167
|
+
readonly place_as_new: "Place as a new order";
|
|
168
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// GENERATED from the shared outcome word file (sha256 dc1376362841a1bd9e4870c3471b9a0a7b4f1246ab6736a5f42a10747422920f). Do not edit by hand: regenerate it.
|
|
2
|
+
/** The words of an action whose outcome is not yet known: {action: {state: {text, next}}}. Placeholders in
|
|
3
|
+
* braces are filled by the caller. */
|
|
4
|
+
export const OUTCOME_WORDS = {
|
|
5
|
+
"headline": {
|
|
6
|
+
"pending_checking": "Pending — checking"
|
|
7
|
+
},
|
|
8
|
+
"limit_s": 120,
|
|
9
|
+
"actions": {
|
|
10
|
+
"order": {
|
|
11
|
+
"pending_checking": {
|
|
12
|
+
"text": "Pending — checking. Your order was sent but the answer was lost. Checking the network for it.",
|
|
13
|
+
"next": "Do not place it again. This takes up to 2 minutes."
|
|
14
|
+
},
|
|
15
|
+
"applied": {
|
|
16
|
+
"text": "{order_words}. Found on the network at block {height}.",
|
|
17
|
+
"next": ""
|
|
18
|
+
},
|
|
19
|
+
"refused": {
|
|
20
|
+
"text": "Not placed: {meaning}.",
|
|
21
|
+
"next": "{action}"
|
|
22
|
+
},
|
|
23
|
+
"not_applied": {
|
|
24
|
+
"text": "Not placed. The network did not take it, and its time to apply has passed.",
|
|
25
|
+
"next": "You can place it again."
|
|
26
|
+
},
|
|
27
|
+
"still_unknown": {
|
|
28
|
+
"text": "Still not known after 2 minutes. It was not sent again and may still apply.",
|
|
29
|
+
"next": "Check your open orders before you place it again."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"cancel": {
|
|
33
|
+
"pending_checking": {
|
|
34
|
+
"text": "Pending — checking. Your cancel was sent but the answer was lost. Checking whether the order is gone.",
|
|
35
|
+
"next": "Wait. This takes up to 2 minutes."
|
|
36
|
+
},
|
|
37
|
+
"applied": {
|
|
38
|
+
"text": "Cancelled. The order is off the book.",
|
|
39
|
+
"next": ""
|
|
40
|
+
},
|
|
41
|
+
"applied_other": {
|
|
42
|
+
"text": "Filled before the cancel.",
|
|
43
|
+
"next": "Check your position."
|
|
44
|
+
},
|
|
45
|
+
"refused": {
|
|
46
|
+
"text": "Not cancelled: {meaning}.",
|
|
47
|
+
"next": "{action}"
|
|
48
|
+
},
|
|
49
|
+
"still_unknown": {
|
|
50
|
+
"text": "Still not known after 2 minutes. The order is still on the book.",
|
|
51
|
+
"next": "You can cancel it again: cancelling twice has no extra effect."
|
|
52
|
+
},
|
|
53
|
+
"still_unknown_gone": {
|
|
54
|
+
"text": "Still not known after 2 minutes. The order is off the book: it was cancelled or filled.",
|
|
55
|
+
"next": "Check your position."
|
|
56
|
+
},
|
|
57
|
+
"still_unknown_unread": {
|
|
58
|
+
"text": "Still not known after 2 minutes. The network's reads did not answer.",
|
|
59
|
+
"next": "You can cancel it again: cancelling twice has no extra effect."
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"cancel_all": {
|
|
63
|
+
"pending_checking": {
|
|
64
|
+
"text": "Pending — checking. Cancel all was sent but the answer was lost. Checking your open orders.",
|
|
65
|
+
"next": "Wait. This takes up to 2 minutes."
|
|
66
|
+
},
|
|
67
|
+
"applied": {
|
|
68
|
+
"text": "All {n} orders cancelled.",
|
|
69
|
+
"next": ""
|
|
70
|
+
},
|
|
71
|
+
"applied_other": {
|
|
72
|
+
"text": "{n} of {m} cancelled; {k} filled first.",
|
|
73
|
+
"next": ""
|
|
74
|
+
},
|
|
75
|
+
"refused": {
|
|
76
|
+
"text": "Not cancelled: {meaning}.",
|
|
77
|
+
"next": ""
|
|
78
|
+
},
|
|
79
|
+
"still_unknown": {
|
|
80
|
+
"text": "Still not known after 2 minutes. {n} orders are still open.",
|
|
81
|
+
"next": "Check your open orders; cancel what is still open."
|
|
82
|
+
},
|
|
83
|
+
"still_unknown_unread": {
|
|
84
|
+
"text": "Still not known after 2 minutes. The network's reads did not answer.",
|
|
85
|
+
"next": "Check your open orders; cancel what is still open."
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"close_all": {
|
|
89
|
+
"pending_checking": {
|
|
90
|
+
"text": "Pending — checking. The closes were sent but the answers were lost. Checking your positions.",
|
|
91
|
+
"next": "Wait. This takes up to 2 minutes."
|
|
92
|
+
},
|
|
93
|
+
"applied": {
|
|
94
|
+
"text": "{n} positions closed.",
|
|
95
|
+
"next": ""
|
|
96
|
+
},
|
|
97
|
+
"applied_other": {
|
|
98
|
+
"text": "{n} of {m} closed. {k} still open.",
|
|
99
|
+
"next": "Close them on the trading page."
|
|
100
|
+
},
|
|
101
|
+
"refused": {
|
|
102
|
+
"text": "Not closed: {meaning}.",
|
|
103
|
+
"next": ""
|
|
104
|
+
},
|
|
105
|
+
"still_unknown": {
|
|
106
|
+
"text": "Still not known after 2 minutes. {n} positions are still open.",
|
|
107
|
+
"next": "Close what is still open on the trading page."
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"revoke": {
|
|
111
|
+
"pending_checking": {
|
|
112
|
+
"text": "Pending — checking. The revoke was sent. Checking that the agent is revoked.",
|
|
113
|
+
"next": "Wait. This takes up to 2 minutes."
|
|
114
|
+
},
|
|
115
|
+
"applied": {
|
|
116
|
+
"text": "Agent revoked at block {height}. {m} orders cancelled.",
|
|
117
|
+
"next": ""
|
|
118
|
+
},
|
|
119
|
+
"refused": {
|
|
120
|
+
"text": "Not revoked: {meaning}.",
|
|
121
|
+
"next": ""
|
|
122
|
+
},
|
|
123
|
+
"still_unknown": {
|
|
124
|
+
"text": "Still not known after 2 minutes. The agent is still live.",
|
|
125
|
+
"next": "You can revoke again: it has no extra effect."
|
|
126
|
+
},
|
|
127
|
+
"still_unknown_unread": {
|
|
128
|
+
"text": "Still not known after 2 minutes. The network's reads did not answer.",
|
|
129
|
+
"next": "You can revoke again: it has no extra effect."
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"stop": {
|
|
133
|
+
"pending_checking": {
|
|
134
|
+
"text": "Pending — checking. The stop was sent. Checking that your trading key and agents are stopped.",
|
|
135
|
+
"next": "Wait. This takes up to 2 minutes."
|
|
136
|
+
},
|
|
137
|
+
"applied": {
|
|
138
|
+
"text": "Stopped on the network: no trading key, no live agent, no open order.",
|
|
139
|
+
"next": ""
|
|
140
|
+
},
|
|
141
|
+
"applied_other": {
|
|
142
|
+
"text": "Your trading key and every agent are stopped. {n} orders your wallet placed itself stay open.",
|
|
143
|
+
"next": ""
|
|
144
|
+
},
|
|
145
|
+
"refused": {
|
|
146
|
+
"text": "Not stopped: {meaning}.",
|
|
147
|
+
"next": ""
|
|
148
|
+
},
|
|
149
|
+
"not_applied": {
|
|
150
|
+
"text": "Not stopped. That signature has passed its time to apply.",
|
|
151
|
+
"next": "Press Stop everything now again."
|
|
152
|
+
},
|
|
153
|
+
"still_unknown": {
|
|
154
|
+
"text": "Still not known after 2 minutes. {what_is_live}.",
|
|
155
|
+
"next": "You can stop again: it has no extra effect."
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"resend_while_pending": {
|
|
160
|
+
"order": null,
|
|
161
|
+
"cancel": "Send the same cancel again",
|
|
162
|
+
"cancel_all": null,
|
|
163
|
+
"close_all": null,
|
|
164
|
+
"revoke": "Send the same revoke again",
|
|
165
|
+
"stop": "Send the same stop again"
|
|
166
|
+
},
|
|
167
|
+
"check_again": "Check again",
|
|
168
|
+
"place_as_new": "Place as a new order"
|
|
169
|
+
};
|
package/dist/esm/pins.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { NetworkMismatch } from './errors.js';
|
|
|
3
3
|
* The identity each named network is pinned to: its chain id and its genesis sha256. These values are part of the SDK.
|
|
4
4
|
* Before anything is signed, the SDK compares the pin with what the network reports (the network spec, the node's
|
|
5
5
|
* `/status` and the JSON-RPC `eth_chainId`); when any of them differs, nothing is signed. The EIP-712 domains are built
|
|
6
|
-
* from the pin.
|
|
6
|
+
* from the pin. When the signed release record is served (`releaseRecord.ts`: `releases.json` with its detached signature
|
|
7
|
+
* by the release key), a named network's genesis comes from it instead, so a new genesis listed there needs no new SDK
|
|
8
|
+
* release. These pins apply while no record is served.
|
|
7
9
|
*/
|
|
8
10
|
export interface Pin {
|
|
9
11
|
/** "mainnet" or "testnet" for a named network; absent for a pin you give. */
|
|
@@ -15,10 +17,15 @@ export interface Pin {
|
|
|
15
17
|
export declare const PINS: Readonly<Record<'mainnet' | 'testnet', Readonly<Pin>>>;
|
|
16
18
|
/** The network reports a chain id or genesis other than its pin. Nothing was signed. */
|
|
17
19
|
export declare class PinMismatch extends NetworkMismatch {
|
|
20
|
+
/** When the reason is the signed release record: its code (`expired`, `rollback`, `not_served`, `unsigned`,
|
|
21
|
+
* `bad_signature`, `not_listed`, …), else null. */
|
|
22
|
+
recordCode: string | null;
|
|
18
23
|
constructor(message: string);
|
|
19
24
|
}
|
|
20
25
|
/** The network is not a named network and carries no pin. It can be read; nothing is signed for it. */
|
|
21
26
|
export declare class UnpinnedNetwork extends NetworkMismatch {
|
|
27
|
+
/** When the reason is the signed release record (a network named only by its chain id): its code, else null. */
|
|
28
|
+
recordCode: string | null;
|
|
22
29
|
constructor(message: string);
|
|
23
30
|
}
|
|
24
31
|
/** A pin checked for shape: a positive safe-integer chain id and a 32-byte genesis (returned lower-case, no 0x). */
|
package/dist/esm/pins.js
CHANGED
|
@@ -5,6 +5,9 @@ export const PINS = Object.freeze({
|
|
|
5
5
|
});
|
|
6
6
|
/** The network reports a chain id or genesis other than its pin. Nothing was signed. */
|
|
7
7
|
export class PinMismatch extends NetworkMismatch {
|
|
8
|
+
/** When the reason is the signed release record: its code (`expired`, `rollback`, `not_served`, `unsigned`,
|
|
9
|
+
* `bad_signature`, `not_listed`, …), else null. */
|
|
10
|
+
recordCode = null;
|
|
8
11
|
constructor(message) {
|
|
9
12
|
super(message);
|
|
10
13
|
this.name = 'PinMismatch';
|
|
@@ -12,6 +15,8 @@ export class PinMismatch extends NetworkMismatch {
|
|
|
12
15
|
}
|
|
13
16
|
/** The network is not a named network and carries no pin. It can be read; nothing is signed for it. */
|
|
14
17
|
export class UnpinnedNetwork extends NetworkMismatch {
|
|
18
|
+
/** When the reason is the signed release record (a network named only by its chain id): its code, else null. */
|
|
19
|
+
recordCode = null;
|
|
15
20
|
constructor(message) {
|
|
16
21
|
super(message);
|
|
17
22
|
this.name = 'UnpinnedNetwork';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { VordiumError } from './errors.js';
|
|
2
|
+
import type { Transport } from './http.js';
|
|
3
|
+
import { type NonceStore } from './nonce.js';
|
|
4
|
+
/**
|
|
5
|
+
* The signed release record: the genesis, chain id and deposit bridge of each network, signed by the release key.
|
|
6
|
+
*
|
|
7
|
+
* A network's identity is taken from `releases.json`, and only after its detached OpenPGP signature
|
|
8
|
+
* (`releases.json.asc`) verifies under the release key that ships in this package ({@link RELEASE_KEY}, fingerprint
|
|
9
|
+
* {@link RELEASE_KEY_FINGERPRINT}). The signature covers the exact bytes as served; the record is read from those same
|
|
10
|
+
* bytes only after the signature holds.
|
|
11
|
+
*
|
|
12
|
+
* The key is pinned by its fingerprint. Its expiry is read from its newest self-signature. When that expiry is near
|
|
13
|
+
* ({@link KEY_REFRESH_BEFORE_S}) or past, the key is read again from where it is served ({@link KEY_URLS}). A served copy
|
|
14
|
+
* is used only when it is the same key (same fingerprint and point) and its self-signature verifies under that key: its
|
|
15
|
+
* newest self-signature then gives the expiry. A revocation that verifies under the key refuses every record. Nothing
|
|
16
|
+
* else is taken from a served copy, and when none can be read the shipped key is used as it is.
|
|
17
|
+
*
|
|
18
|
+
* Everything else is checked here, with no other program: the ASCII armour (and its CRC-24), the version 4 signature packet (EdDSA over Ed25519, SHA-256 or SHA-512),
|
|
19
|
+
* its hashed subpackets, the issuer fingerprint, the signature hash over the data and the hashed trailer, and the
|
|
20
|
+
* Ed25519 signature itself (RFC 8032).
|
|
21
|
+
*/
|
|
22
|
+
/** The release key: every network record must be signed by it. */
|
|
23
|
+
export declare const RELEASE_KEY_FINGERPRINT = "C5EB4728F660369CE519D834B48FB4B71EFD48AE";
|
|
24
|
+
export declare const RELEASE_KEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmDMEaqXHBhYJKwYBBAHaRw8BAQdA8NRFgXw3NaEYFesojdDl1TlSlk9O5bXhsM4i\no7k3e+q0J1ZvcmRpdW0gUmVsZWFzZXMgPHJlbGVhc2VzQHZvcmRpdW0uY29tPoi1\nBBMWCgBdFiEExetHKPZgNpzlGdg0tI+0tx79SK4FAmqlxwYbFIAAAAAABAAObWFu\ndTIsMi41KzEuMTIsMCwzAhsDBQkDwmcABQsJCAcCAiICBhUKCQgLAgQWAgMBAh4H\nAheAAAoJELSPtLce/UiuMUgA/2VojVnml+DJHQ6xbxhnbrNeD5p8H4lXsVASdpvs\nRsCIAQCkMr8M76++QNGj08s+apf7CDgEVwbBFo4shxsYAU+gDw==\n=20lT\n-----END PGP PUBLIC KEY BLOCK-----\n";
|
|
25
|
+
/** Where each named network's record is read, in order. The signature is read at the same address + ".asc". */
|
|
26
|
+
export declare const RELEASE_RECORD_URLS: Readonly<Record<'mainnet' | 'testnet', readonly string[]>>;
|
|
27
|
+
/** The lowest record sequence this SDK release accepts for each chain id, also on a computer that has read no record yet
|
|
28
|
+
* (an empty state folder): the release process sets it to the sequence of the record served when the release is made.
|
|
29
|
+
* 0 = no floor. A floor above 0 also counts as a record already seen: while none is served, nothing is signed. */
|
|
30
|
+
export declare const MIN_RECORD_SEQUENCE: Readonly<Record<number, number>>;
|
|
31
|
+
/** The record format this SDK reads. */
|
|
32
|
+
export declare const RELEASE_RECORD_SCHEMA = "vordium.release-record/3";
|
|
33
|
+
/** Where the release key is served. Read only when the key's expiry is near or past (see {@link refreshKey}). */
|
|
34
|
+
export declare const KEY_URLS: readonly string[];
|
|
35
|
+
/** The key is read again from {@link KEY_URLS} from this long (seconds) before its expiry. */
|
|
36
|
+
export declare const KEY_REFRESH_BEFORE_S: number;
|
|
37
|
+
/** A key read from {@link KEY_URLS} is used for this long (seconds) before it is read again. */
|
|
38
|
+
export declare const KEY_REFRESH_TTL_S: number;
|
|
39
|
+
/** A read that left an expired key as it was is tried again after this long (seconds). */
|
|
40
|
+
export declare const KEY_RETRY_S = 30;
|
|
41
|
+
/** The release record cannot be used. `code` names the reason; the message is a plain sentence. */
|
|
42
|
+
export declare class RecordRefused extends VordiumError {
|
|
43
|
+
constructor(code: string, message: string);
|
|
44
|
+
}
|
|
45
|
+
export declare function crc24(data: Uint8Array): number;
|
|
46
|
+
/** The bytes inside one ASCII-armoured block of `kind` ("PGP SIGNATURE", "PGP PUBLIC KEY BLOCK"). The CRC-24 line, when
|
|
47
|
+
* present, must match. Throws {@link RecordRefused}. */
|
|
48
|
+
export declare function dearmor(text: string | Uint8Array, kind: string): Uint8Array;
|
|
49
|
+
/** An Ed25519 OpenPGP public key: its v4 fingerprint (40 upper-case hex), its 32-byte point, and when it expires
|
|
50
|
+
* (seconds; null = never), read from its newest self-signature that verifies. */
|
|
51
|
+
export interface PublicKey {
|
|
52
|
+
fingerprint: string;
|
|
53
|
+
point: Uint8Array;
|
|
54
|
+
expires: number | null;
|
|
55
|
+
/** The time of the self-signature the expiry was read from. */
|
|
56
|
+
signedAt: number;
|
|
57
|
+
/** A key revocation signature by this key verifies. */
|
|
58
|
+
revoked: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** The primary key of an armoured public key block. The fingerprint is computed from the key packet (SHA-1 over
|
|
61
|
+
* 0x99 || length || packet). Only a version 4 EdDSA key on Ed25519 is accepted, with at least one user ID whose
|
|
62
|
+
* self-signature verifies; the newest such self-signature gives the key's expiry. */
|
|
63
|
+
export declare function parsePublicKey(armoured: string | Uint8Array): PublicKey;
|
|
64
|
+
/** A checked detached signature: who made it (issuer fingerprint) and when (seconds). */
|
|
65
|
+
export interface SignatureInfo {
|
|
66
|
+
fingerprint: string;
|
|
67
|
+
created: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Verify an armoured detached signature over the exact bytes `data` under one of `keys` (the pinned keys). Returns the
|
|
71
|
+
* signature's issuer and time; throws {@link RecordRefused} with a plain sentence otherwise.
|
|
72
|
+
*/
|
|
73
|
+
export declare function verifyDetached(data: Uint8Array, armouredSig: string | Uint8Array, keys: readonly PublicKey[], nowSec?: number): SignatureInfo;
|
|
74
|
+
/** The deposit bridge as the signed record names it (addresses lower-case). */
|
|
75
|
+
export interface RecordBridge {
|
|
76
|
+
chainId: number;
|
|
77
|
+
vault: string;
|
|
78
|
+
handler: string;
|
|
79
|
+
usdc: string;
|
|
80
|
+
}
|
|
81
|
+
/** One network of a signed record. */
|
|
82
|
+
export interface RecordNetwork {
|
|
83
|
+
chainId: number;
|
|
84
|
+
genesis: string;
|
|
85
|
+
bridge: RecordBridge;
|
|
86
|
+
retiredGenesis: readonly string[];
|
|
87
|
+
name: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** A signed record, read from the verified bytes. Times are in seconds. */
|
|
90
|
+
export interface ReleaseRecord {
|
|
91
|
+
sequence: number;
|
|
92
|
+
issuedAt: number;
|
|
93
|
+
validUntil: number;
|
|
94
|
+
networks: ReadonlyMap<number, RecordNetwork>;
|
|
95
|
+
signedBy: string;
|
|
96
|
+
}
|
|
97
|
+
/** JSON.parse that refuses a key given twice in one object (two readers could otherwise take different values). */
|
|
98
|
+
export declare function parseStrictJson(text: string): unknown;
|
|
99
|
+
/** Whether bytes that could not be verified claim to be a network record (a JSON object with `networks`). Used only to
|
|
100
|
+
* tell an unsigned record (refused) from another file (ignored); no value of it is ever used. */
|
|
101
|
+
export declare function isNetworkRecord(data: Uint8Array): boolean;
|
|
102
|
+
/** The record in the VERIFIED bytes `data`. Null when the file is not a network record (it has no `networks`: the
|
|
103
|
+
* release list of an earlier format). Throws {@link RecordRefused} for a record that is not well formed. */
|
|
104
|
+
export declare function parseRecord(data: Uint8Array, signedBy?: string): ReleaseRecord | null;
|
|
105
|
+
/** A verified record and the entry of the network it was read for. */
|
|
106
|
+
export interface VerifiedRecord {
|
|
107
|
+
record: ReleaseRecord;
|
|
108
|
+
entry: RecordNetwork;
|
|
109
|
+
url: string;
|
|
110
|
+
}
|
|
111
|
+
export interface RefreshKeyOptions {
|
|
112
|
+
transport: Transport;
|
|
113
|
+
urls?: readonly string[];
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `key` as its newest served copy states it. A copy at `urls` (default {@link KEY_URLS}, through `transport.getBytes`) is
|
|
118
|
+
* used only when it parses as the same key (same fingerprint and point, a self-signature that verifies under that key)
|
|
119
|
+
* and its newest self-signature is newer than the one `key` was read from; a copy carrying a revocation that verifies
|
|
120
|
+
* under the key gives the key as revoked. A copy that cannot be read, is another key or is older is skipped; with none
|
|
121
|
+
* usable, `key` is returned as it is.
|
|
122
|
+
*/
|
|
123
|
+
export declare function refreshKey(key: PublicKey, opts: RefreshKeyOptions): Promise<PublicKey>;
|
|
124
|
+
/** The keys a record must be signed by: the shipped release key, or (tests only) the armoured keys given. The shipped
|
|
125
|
+
* key's expiry is refreshed by {@link readRecord} from its served copy when near or past (see {@link refreshKey}). */
|
|
126
|
+
export declare function pinnedKeys(releaseKeys?: readonly string[]): PublicKey[];
|
|
127
|
+
export interface ReadRecordOptions {
|
|
128
|
+
transport: Transport;
|
|
129
|
+
timeoutMs?: number;
|
|
130
|
+
/** Where the highest sequence seen is kept (default: the nonce store, files 0600 under Node.js). */
|
|
131
|
+
store?: NonceStore;
|
|
132
|
+
/** This computer's clock in milliseconds (tests replace it). */
|
|
133
|
+
now?: () => number;
|
|
134
|
+
/** Tests only: the lowest sequence accepted per chain id, instead of {@link MIN_RECORD_SEQUENCE}. */
|
|
135
|
+
minSequence?: Readonly<Record<number, number>>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Read the signed record for `chainId` from the first of `urls` that serves one (through `transport.getBytes`; a
|
|
139
|
+
* transport without it reads no record).
|
|
140
|
+
*
|
|
141
|
+
* Resolves null when no address serves a network record (nothing, or a signed release list of an earlier format) and no
|
|
142
|
+
* record for this network was seen on this computer before. Throws {@link RecordRefused} (with a plain sentence) for an
|
|
143
|
+
* unsigned record, a bad signature, another key, a record of an unknown format, an expired record, a sequence lower than
|
|
144
|
+
* one seen before, a record that does not list `chainId`, or, when a record for this network was seen before, for no
|
|
145
|
+
* record served now.
|
|
146
|
+
*/
|
|
147
|
+
export declare function readRecord(chainId: number, urls: readonly string[], keys: readonly PublicKey[], opts: ReadRecordOptions): Promise<VerifiedRecord | null>;
|