@spacesops/wdk-react-native-provider 1.0.0-beta.3
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/LICENSE +176 -0
- package/README.md +841 -0
- package/lib/module/contexts/constants.js +20 -0
- package/lib/module/contexts/constants.js.map +1 -0
- package/lib/module/contexts/reducer.js +87 -0
- package/lib/module/contexts/reducer.js.map +1 -0
- package/lib/module/contexts/types.js +4 -0
- package/lib/module/contexts/types.js.map +1 -0
- package/lib/module/contexts/wallet-context.js +409 -0
- package/lib/module/contexts/wallet-context.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills.js +34 -0
- package/lib/module/polyfills.js.map +1 -0
- package/lib/module/services/wdk-service/bare-api.js +69 -0
- package/lib/module/services/wdk-service/bare-api.js.map +1 -0
- package/lib/module/services/wdk-service/index.js +506 -0
- package/lib/module/services/wdk-service/index.js.map +1 -0
- package/lib/module/services/wdk-service/types.js +48 -0
- package/lib/module/services/wdk-service/types.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-encryption-salt.js +29 -0
- package/lib/module/services/wdk-service/wdk-encryption-salt.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-storage.js +64 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-storage.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-worklet.bundle.js +1 -0
- package/lib/module/services/wdk-service/wdk-worklet.mobile.bundle.js +1 -0
- package/lib/module/spec/hrpc/hrpc.json +66 -0
- package/lib/module/spec/hrpc/index.js +121 -0
- package/lib/module/spec/hrpc/index.js.map +1 -0
- package/lib/module/spec/hrpc/messages.js +291 -0
- package/lib/module/spec/hrpc/messages.js.map +1 -0
- package/lib/module/spec/schema/index.js +291 -0
- package/lib/module/spec/schema/index.js.map +1 -0
- package/lib/module/spec/schema/schema.json +186 -0
- package/lib/module/utils/get-balances-from-balance-map.js +18 -0
- package/lib/module/utils/get-balances-from-balance-map.js.map +1 -0
- package/lib/module/utils/get-transactions-from-transaction-map.js +10 -0
- package/lib/module/utils/get-transactions-from-transaction-map.js.map +1 -0
- package/lib/module/worklet/wdk-secret-manager-worklet.js +106 -0
- package/lib/module/worklet/wdk-secret-manager-worklet.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/contexts/constants.d.ts +3 -0
- package/lib/typescript/src/contexts/constants.d.ts.map +1 -0
- package/lib/typescript/src/contexts/reducer.d.ts +38 -0
- package/lib/typescript/src/contexts/reducer.d.ts.map +1 -0
- package/lib/typescript/src/contexts/types.d.ts +40 -0
- package/lib/typescript/src/contexts/types.d.ts.map +1 -0
- package/lib/typescript/src/contexts/wallet-context.d.ts +10 -0
- package/lib/typescript/src/contexts/wallet-context.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/polyfills.d.ts +7 -0
- package/lib/typescript/src/polyfills.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/bare-api.d.ts +32 -0
- package/lib/typescript/src/services/wdk-service/bare-api.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/index.d.ts +68 -0
- package/lib/typescript/src/services/wdk-service/index.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/types.d.ts +125 -0
- package/lib/typescript/src/services/wdk-service/types.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/wdk-encryption-salt.d.ts +6 -0
- package/lib/typescript/src/services/wdk-service/wdk-encryption-salt.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/wdk-secret-manager-storage.d.ts +13 -0
- package/lib/typescript/src/services/wdk-service/wdk-secret-manager-storage.d.ts.map +1 -0
- package/lib/typescript/src/utils/get-balances-from-balance-map.d.ts +4 -0
- package/lib/typescript/src/utils/get-balances-from-balance-map.d.ts.map +1 -0
- package/lib/typescript/src/utils/get-transactions-from-transaction-map.d.ts +4 -0
- package/lib/typescript/src/utils/get-transactions-from-transaction-map.d.ts.map +1 -0
- package/metro-polyfills.js +89 -0
- package/package.json +152 -0
- package/src/contexts/constants.ts +19 -0
- package/src/contexts/reducer.ts +103 -0
- package/src/contexts/types.ts +51 -0
- package/src/contexts/wallet-context.tsx +411 -0
- package/src/index.tsx +28 -0
- package/src/polyfills.ts +31 -0
- package/src/services/wdk-service/bare-api.ts +88 -0
- package/src/services/wdk-service/index.ts +765 -0
- package/src/services/wdk-service/types.ts +137 -0
- package/src/services/wdk-service/wdk-encryption-salt.ts +30 -0
- package/src/services/wdk-service/wdk-secret-manager-storage.ts +102 -0
- package/src/spec/hrpc/hrpc.json +66 -0
- package/src/spec/hrpc/index.js +228 -0
- package/src/spec/hrpc/messages.js +328 -0
- package/src/spec/schema/index.js +328 -0
- package/src/spec/schema/schema.json +186 -0
- package/src/utils/get-balances-from-balance-map.ts +22 -0
- package/src/utils/get-transactions-from-transaction-map.ts +18 -0
- package/src/worklet/wdk-secret-manager-worklet.js +118 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// This file is autogenerated by the hyperschema compiler
|
|
2
|
+
// Schema Version: 1
|
|
3
|
+
|
|
4
|
+
const { c } = require('hyperschema/runtime');
|
|
5
|
+
|
|
6
|
+
const VERSION = 1;
|
|
7
|
+
|
|
8
|
+
let version = VERSION;
|
|
9
|
+
|
|
10
|
+
// @tetherto/wdk-secret-manager/command-workletStart-request
|
|
11
|
+
const encoding0 = {
|
|
12
|
+
preencode(state, m) {
|
|
13
|
+
state.end++; // max flag is 1 so always one byte
|
|
14
|
+
|
|
15
|
+
if (m.enableDebugLogs) c.uint.preencode(state, m.enableDebugLogs);
|
|
16
|
+
},
|
|
17
|
+
encode(state, m) {
|
|
18
|
+
const flags = m.enableDebugLogs ? 1 : 0;
|
|
19
|
+
|
|
20
|
+
c.uint.encode(state, flags);
|
|
21
|
+
|
|
22
|
+
if (m.enableDebugLogs) c.uint.encode(state, m.enableDebugLogs);
|
|
23
|
+
},
|
|
24
|
+
decode(state) {
|
|
25
|
+
const flags = c.uint.decode(state);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
enableDebugLogs: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// @tetherto/wdk-secret-manager/command-workletStart-response
|
|
34
|
+
const encoding1 = {
|
|
35
|
+
preencode(state, m) {
|
|
36
|
+
state.end++; // max flag is 1 so always one byte
|
|
37
|
+
|
|
38
|
+
if (m.status) c.string.preencode(state, m.status);
|
|
39
|
+
},
|
|
40
|
+
encode(state, m) {
|
|
41
|
+
const flags = m.status ? 1 : 0;
|
|
42
|
+
|
|
43
|
+
c.uint.encode(state, flags);
|
|
44
|
+
|
|
45
|
+
if (m.status) c.string.encode(state, m.status);
|
|
46
|
+
},
|
|
47
|
+
decode(state) {
|
|
48
|
+
const flags = c.uint.decode(state);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
status: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// @tetherto/wdk-secret-manager/command-workletStop-request
|
|
57
|
+
const encoding2 = {
|
|
58
|
+
preencode(state, m) {
|
|
59
|
+
state.end++; // max flag is 1 so always one byte
|
|
60
|
+
|
|
61
|
+
if (m.payload) c.string.preencode(state, m.payload);
|
|
62
|
+
},
|
|
63
|
+
encode(state, m) {
|
|
64
|
+
const flags = m.payload ? 1 : 0;
|
|
65
|
+
|
|
66
|
+
c.uint.encode(state, flags);
|
|
67
|
+
|
|
68
|
+
if (m.payload) c.string.encode(state, m.payload);
|
|
69
|
+
},
|
|
70
|
+
decode(state) {
|
|
71
|
+
const flags = c.uint.decode(state);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
payload: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// @tetherto/wdk-secret-manager/command-workletStop-response
|
|
80
|
+
const encoding3 = encoding1;
|
|
81
|
+
|
|
82
|
+
// @tetherto/wdk-secret-manager/command-generateAndEncrypt-request
|
|
83
|
+
const encoding4 = {
|
|
84
|
+
preencode(state, m) {
|
|
85
|
+
state.end++; // max flag is 8 so always one byte
|
|
86
|
+
|
|
87
|
+
if (m.passkey) c.string.preencode(state, m.passkey);
|
|
88
|
+
if (m.salt) c.string.preencode(state, m.salt);
|
|
89
|
+
if (m.seedPhrase) c.string.preencode(state, m.seedPhrase);
|
|
90
|
+
if (m.derivedKey) c.string.preencode(state, m.derivedKey);
|
|
91
|
+
},
|
|
92
|
+
encode(state, m) {
|
|
93
|
+
const flags =
|
|
94
|
+
(m.passkey ? 1 : 0) |
|
|
95
|
+
(m.salt ? 2 : 0) |
|
|
96
|
+
(m.seedPhrase ? 4 : 0) |
|
|
97
|
+
(m.derivedKey ? 8 : 0);
|
|
98
|
+
|
|
99
|
+
c.uint.encode(state, flags);
|
|
100
|
+
|
|
101
|
+
if (m.passkey) c.string.encode(state, m.passkey);
|
|
102
|
+
if (m.salt) c.string.encode(state, m.salt);
|
|
103
|
+
if (m.seedPhrase) c.string.encode(state, m.seedPhrase);
|
|
104
|
+
if (m.derivedKey) c.string.encode(state, m.derivedKey);
|
|
105
|
+
},
|
|
106
|
+
decode(state) {
|
|
107
|
+
const flags = c.uint.decode(state);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
passkey: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
111
|
+
salt: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
112
|
+
seedPhrase: (flags & 4) !== 0 ? c.string.decode(state) : null,
|
|
113
|
+
derivedKey: (flags & 8) !== 0 ? c.string.decode(state) : null,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// @tetherto/wdk-secret-manager/command-generateAndEncrypt-response
|
|
119
|
+
const encoding5 = {
|
|
120
|
+
preencode(state, m) {
|
|
121
|
+
state.end++; // max flag is 2 so always one byte
|
|
122
|
+
|
|
123
|
+
if (m.encryptedEntropy) c.string.preencode(state, m.encryptedEntropy);
|
|
124
|
+
if (m.encryptedSeed) c.string.preencode(state, m.encryptedSeed);
|
|
125
|
+
},
|
|
126
|
+
encode(state, m) {
|
|
127
|
+
const flags = (m.encryptedEntropy ? 1 : 0) | (m.encryptedSeed ? 2 : 0);
|
|
128
|
+
|
|
129
|
+
c.uint.encode(state, flags);
|
|
130
|
+
|
|
131
|
+
if (m.encryptedEntropy) c.string.encode(state, m.encryptedEntropy);
|
|
132
|
+
if (m.encryptedSeed) c.string.encode(state, m.encryptedSeed);
|
|
133
|
+
},
|
|
134
|
+
decode(state) {
|
|
135
|
+
const flags = c.uint.decode(state);
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
encryptedEntropy: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
139
|
+
encryptedSeed: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// @tetherto/wdk-secret-manager/command-decrypt-request
|
|
145
|
+
const encoding6 = {
|
|
146
|
+
preencode(state, m) {
|
|
147
|
+
state.end++; // max flag is 8 so always one byte
|
|
148
|
+
|
|
149
|
+
if (m.passkey) c.string.preencode(state, m.passkey);
|
|
150
|
+
if (m.salt) c.string.preencode(state, m.salt);
|
|
151
|
+
if (m.encryptedData) c.string.preencode(state, m.encryptedData);
|
|
152
|
+
if (m.derivedKey) c.string.preencode(state, m.derivedKey);
|
|
153
|
+
},
|
|
154
|
+
encode(state, m) {
|
|
155
|
+
const flags =
|
|
156
|
+
(m.passkey ? 1 : 0) |
|
|
157
|
+
(m.salt ? 2 : 0) |
|
|
158
|
+
(m.encryptedData ? 4 : 0) |
|
|
159
|
+
(m.derivedKey ? 8 : 0);
|
|
160
|
+
|
|
161
|
+
c.uint.encode(state, flags);
|
|
162
|
+
|
|
163
|
+
if (m.passkey) c.string.encode(state, m.passkey);
|
|
164
|
+
if (m.salt) c.string.encode(state, m.salt);
|
|
165
|
+
if (m.encryptedData) c.string.encode(state, m.encryptedData);
|
|
166
|
+
if (m.derivedKey) c.string.encode(state, m.derivedKey);
|
|
167
|
+
},
|
|
168
|
+
decode(state) {
|
|
169
|
+
const flags = c.uint.decode(state);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
passkey: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
173
|
+
salt: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
174
|
+
encryptedData: (flags & 4) !== 0 ? c.string.decode(state) : null,
|
|
175
|
+
derivedKey: (flags & 8) !== 0 ? c.string.decode(state) : null,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// @tetherto/wdk-secret-manager/command-decrypt-response
|
|
181
|
+
const encoding7 = {
|
|
182
|
+
preencode(state, m) {
|
|
183
|
+
state.end++; // max flag is 1 so always one byte
|
|
184
|
+
|
|
185
|
+
if (m.result) c.string.preencode(state, m.result);
|
|
186
|
+
},
|
|
187
|
+
encode(state, m) {
|
|
188
|
+
const flags = m.result ? 1 : 0;
|
|
189
|
+
|
|
190
|
+
c.uint.encode(state, flags);
|
|
191
|
+
|
|
192
|
+
if (m.result) c.string.encode(state, m.result);
|
|
193
|
+
},
|
|
194
|
+
decode(state) {
|
|
195
|
+
const flags = c.uint.decode(state);
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
result: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const encoding8_enum = {
|
|
204
|
+
info: 1,
|
|
205
|
+
error: 2,
|
|
206
|
+
debug: 3,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// @tetherto/wdk-secret-manager/log-type-enum enum
|
|
210
|
+
const encoding8 = {
|
|
211
|
+
preencode(state, m) {
|
|
212
|
+
state.end++; // max enum is 3 so always one byte
|
|
213
|
+
},
|
|
214
|
+
encode(state, m) {
|
|
215
|
+
if (m > 3) throw new Error('Unknown enum');
|
|
216
|
+
c.uint.encode(state, m);
|
|
217
|
+
},
|
|
218
|
+
decode(state) {
|
|
219
|
+
return c.uint.decode(state);
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// @tetherto/wdk-secret-manager/command-log-request
|
|
224
|
+
const encoding9 = {
|
|
225
|
+
preencode(state, m) {
|
|
226
|
+
state.end++; // max flag is 2 so always one byte
|
|
227
|
+
|
|
228
|
+
if (m.type) encoding8.preencode(state, m.type);
|
|
229
|
+
if (m.data) c.string.preencode(state, m.data);
|
|
230
|
+
},
|
|
231
|
+
encode(state, m) {
|
|
232
|
+
const flags = (m.type ? 1 : 0) | (m.data ? 2 : 0);
|
|
233
|
+
|
|
234
|
+
c.uint.encode(state, flags);
|
|
235
|
+
|
|
236
|
+
if (m.type) encoding8.encode(state, m.type);
|
|
237
|
+
if (m.data) c.string.encode(state, m.data);
|
|
238
|
+
},
|
|
239
|
+
decode(state) {
|
|
240
|
+
const flags = c.uint.decode(state);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
type: (flags & 1) !== 0 ? encoding8.decode(state) : 0,
|
|
244
|
+
data: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
function setVersion(v) {
|
|
250
|
+
version = v;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function encode(name, value, v = VERSION) {
|
|
254
|
+
version = v;
|
|
255
|
+
return c.encode(getEncoding(name), value);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function decode(name, buffer, v = VERSION) {
|
|
259
|
+
version = v;
|
|
260
|
+
return c.decode(getEncoding(name), buffer);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function getEnum(name) {
|
|
264
|
+
switch (name) {
|
|
265
|
+
case '@tetherto/wdk-secret-manager/log-type-enum':
|
|
266
|
+
return encoding8_enum;
|
|
267
|
+
default:
|
|
268
|
+
throw new Error('Enum not found ' + name);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getEncoding(name) {
|
|
273
|
+
switch (name) {
|
|
274
|
+
case '@tetherto/wdk-secret-manager/command-workletStart-request':
|
|
275
|
+
return encoding0;
|
|
276
|
+
case '@tetherto/wdk-secret-manager/command-workletStart-response':
|
|
277
|
+
return encoding1;
|
|
278
|
+
case '@tetherto/wdk-secret-manager/command-workletStop-request':
|
|
279
|
+
return encoding2;
|
|
280
|
+
case '@tetherto/wdk-secret-manager/command-workletStop-response':
|
|
281
|
+
return encoding3;
|
|
282
|
+
case '@tetherto/wdk-secret-manager/command-generateAndEncrypt-request':
|
|
283
|
+
return encoding4;
|
|
284
|
+
case '@tetherto/wdk-secret-manager/command-generateAndEncrypt-response':
|
|
285
|
+
return encoding5;
|
|
286
|
+
case '@tetherto/wdk-secret-manager/command-decrypt-request':
|
|
287
|
+
return encoding6;
|
|
288
|
+
case '@tetherto/wdk-secret-manager/command-decrypt-response':
|
|
289
|
+
return encoding7;
|
|
290
|
+
case '@tetherto/wdk-secret-manager/log-type-enum':
|
|
291
|
+
return encoding8;
|
|
292
|
+
case '@tetherto/wdk-secret-manager/command-log-request':
|
|
293
|
+
return encoding9;
|
|
294
|
+
default:
|
|
295
|
+
throw new Error('Encoder not found ' + name);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function getStruct(name, v = VERSION) {
|
|
300
|
+
const enc = getEncoding(name);
|
|
301
|
+
return {
|
|
302
|
+
preencode(state, m) {
|
|
303
|
+
version = v;
|
|
304
|
+
enc.preencode(state, m);
|
|
305
|
+
},
|
|
306
|
+
encode(state, m) {
|
|
307
|
+
version = v;
|
|
308
|
+
enc.encode(state, m);
|
|
309
|
+
},
|
|
310
|
+
decode(state) {
|
|
311
|
+
version = v;
|
|
312
|
+
return enc.decode(state);
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const resolveStruct = getStruct; // compat
|
|
318
|
+
|
|
319
|
+
module.exports = {
|
|
320
|
+
resolveStruct,
|
|
321
|
+
getStruct,
|
|
322
|
+
getEnum,
|
|
323
|
+
getEncoding,
|
|
324
|
+
encode,
|
|
325
|
+
decode,
|
|
326
|
+
setVersion,
|
|
327
|
+
version,
|
|
328
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// This file is autogenerated by the hyperschema compiler
|
|
2
|
+
// Schema Version: 1
|
|
3
|
+
|
|
4
|
+
const { c } = require('hyperschema/runtime');
|
|
5
|
+
|
|
6
|
+
const VERSION = 1;
|
|
7
|
+
|
|
8
|
+
let version = VERSION;
|
|
9
|
+
|
|
10
|
+
// @tetherto/wdk-secret-manager/command-workletStart-request
|
|
11
|
+
const encoding0 = {
|
|
12
|
+
preencode(state, m) {
|
|
13
|
+
state.end++; // max flag is 1 so always one byte
|
|
14
|
+
|
|
15
|
+
if (m.enableDebugLogs) c.uint.preencode(state, m.enableDebugLogs);
|
|
16
|
+
},
|
|
17
|
+
encode(state, m) {
|
|
18
|
+
const flags = m.enableDebugLogs ? 1 : 0;
|
|
19
|
+
|
|
20
|
+
c.uint.encode(state, flags);
|
|
21
|
+
|
|
22
|
+
if (m.enableDebugLogs) c.uint.encode(state, m.enableDebugLogs);
|
|
23
|
+
},
|
|
24
|
+
decode(state) {
|
|
25
|
+
const flags = c.uint.decode(state);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
enableDebugLogs: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// @tetherto/wdk-secret-manager/command-workletStart-response
|
|
34
|
+
const encoding1 = {
|
|
35
|
+
preencode(state, m) {
|
|
36
|
+
state.end++; // max flag is 1 so always one byte
|
|
37
|
+
|
|
38
|
+
if (m.status) c.string.preencode(state, m.status);
|
|
39
|
+
},
|
|
40
|
+
encode(state, m) {
|
|
41
|
+
const flags = m.status ? 1 : 0;
|
|
42
|
+
|
|
43
|
+
c.uint.encode(state, flags);
|
|
44
|
+
|
|
45
|
+
if (m.status) c.string.encode(state, m.status);
|
|
46
|
+
},
|
|
47
|
+
decode(state) {
|
|
48
|
+
const flags = c.uint.decode(state);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
status: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// @tetherto/wdk-secret-manager/command-workletStop-request
|
|
57
|
+
const encoding2 = {
|
|
58
|
+
preencode(state, m) {
|
|
59
|
+
state.end++; // max flag is 1 so always one byte
|
|
60
|
+
|
|
61
|
+
if (m.payload) c.string.preencode(state, m.payload);
|
|
62
|
+
},
|
|
63
|
+
encode(state, m) {
|
|
64
|
+
const flags = m.payload ? 1 : 0;
|
|
65
|
+
|
|
66
|
+
c.uint.encode(state, flags);
|
|
67
|
+
|
|
68
|
+
if (m.payload) c.string.encode(state, m.payload);
|
|
69
|
+
},
|
|
70
|
+
decode(state) {
|
|
71
|
+
const flags = c.uint.decode(state);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
payload: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// @tetherto/wdk-secret-manager/command-workletStop-response
|
|
80
|
+
const encoding3 = encoding1;
|
|
81
|
+
|
|
82
|
+
// @tetherto/wdk-secret-manager/command-generateAndEncrypt-request
|
|
83
|
+
const encoding4 = {
|
|
84
|
+
preencode(state, m) {
|
|
85
|
+
state.end++; // max flag is 8 so always one byte
|
|
86
|
+
|
|
87
|
+
if (m.passkey) c.string.preencode(state, m.passkey);
|
|
88
|
+
if (m.salt) c.string.preencode(state, m.salt);
|
|
89
|
+
if (m.seedPhrase) c.string.preencode(state, m.seedPhrase);
|
|
90
|
+
if (m.derivedKey) c.string.preencode(state, m.derivedKey);
|
|
91
|
+
},
|
|
92
|
+
encode(state, m) {
|
|
93
|
+
const flags =
|
|
94
|
+
(m.passkey ? 1 : 0) |
|
|
95
|
+
(m.salt ? 2 : 0) |
|
|
96
|
+
(m.seedPhrase ? 4 : 0) |
|
|
97
|
+
(m.derivedKey ? 8 : 0);
|
|
98
|
+
|
|
99
|
+
c.uint.encode(state, flags);
|
|
100
|
+
|
|
101
|
+
if (m.passkey) c.string.encode(state, m.passkey);
|
|
102
|
+
if (m.salt) c.string.encode(state, m.salt);
|
|
103
|
+
if (m.seedPhrase) c.string.encode(state, m.seedPhrase);
|
|
104
|
+
if (m.derivedKey) c.string.encode(state, m.derivedKey);
|
|
105
|
+
},
|
|
106
|
+
decode(state) {
|
|
107
|
+
const flags = c.uint.decode(state);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
passkey: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
111
|
+
salt: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
112
|
+
seedPhrase: (flags & 4) !== 0 ? c.string.decode(state) : null,
|
|
113
|
+
derivedKey: (flags & 8) !== 0 ? c.string.decode(state) : null,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// @tetherto/wdk-secret-manager/command-generateAndEncrypt-response
|
|
119
|
+
const encoding5 = {
|
|
120
|
+
preencode(state, m) {
|
|
121
|
+
state.end++; // max flag is 2 so always one byte
|
|
122
|
+
|
|
123
|
+
if (m.encryptedEntropy) c.string.preencode(state, m.encryptedEntropy);
|
|
124
|
+
if (m.encryptedSeed) c.string.preencode(state, m.encryptedSeed);
|
|
125
|
+
},
|
|
126
|
+
encode(state, m) {
|
|
127
|
+
const flags = (m.encryptedEntropy ? 1 : 0) | (m.encryptedSeed ? 2 : 0);
|
|
128
|
+
|
|
129
|
+
c.uint.encode(state, flags);
|
|
130
|
+
|
|
131
|
+
if (m.encryptedEntropy) c.string.encode(state, m.encryptedEntropy);
|
|
132
|
+
if (m.encryptedSeed) c.string.encode(state, m.encryptedSeed);
|
|
133
|
+
},
|
|
134
|
+
decode(state) {
|
|
135
|
+
const flags = c.uint.decode(state);
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
encryptedEntropy: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
139
|
+
encryptedSeed: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// @tetherto/wdk-secret-manager/command-decrypt-request
|
|
145
|
+
const encoding6 = {
|
|
146
|
+
preencode(state, m) {
|
|
147
|
+
state.end++; // max flag is 8 so always one byte
|
|
148
|
+
|
|
149
|
+
if (m.passkey) c.string.preencode(state, m.passkey);
|
|
150
|
+
if (m.salt) c.string.preencode(state, m.salt);
|
|
151
|
+
if (m.encryptedData) c.string.preencode(state, m.encryptedData);
|
|
152
|
+
if (m.derivedKey) c.string.preencode(state, m.derivedKey);
|
|
153
|
+
},
|
|
154
|
+
encode(state, m) {
|
|
155
|
+
const flags =
|
|
156
|
+
(m.passkey ? 1 : 0) |
|
|
157
|
+
(m.salt ? 2 : 0) |
|
|
158
|
+
(m.encryptedData ? 4 : 0) |
|
|
159
|
+
(m.derivedKey ? 8 : 0);
|
|
160
|
+
|
|
161
|
+
c.uint.encode(state, flags);
|
|
162
|
+
|
|
163
|
+
if (m.passkey) c.string.encode(state, m.passkey);
|
|
164
|
+
if (m.salt) c.string.encode(state, m.salt);
|
|
165
|
+
if (m.encryptedData) c.string.encode(state, m.encryptedData);
|
|
166
|
+
if (m.derivedKey) c.string.encode(state, m.derivedKey);
|
|
167
|
+
},
|
|
168
|
+
decode(state) {
|
|
169
|
+
const flags = c.uint.decode(state);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
passkey: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
173
|
+
salt: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
174
|
+
encryptedData: (flags & 4) !== 0 ? c.string.decode(state) : null,
|
|
175
|
+
derivedKey: (flags & 8) !== 0 ? c.string.decode(state) : null,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// @tetherto/wdk-secret-manager/command-decrypt-response
|
|
181
|
+
const encoding7 = {
|
|
182
|
+
preencode(state, m) {
|
|
183
|
+
state.end++; // max flag is 1 so always one byte
|
|
184
|
+
|
|
185
|
+
if (m.result) c.string.preencode(state, m.result);
|
|
186
|
+
},
|
|
187
|
+
encode(state, m) {
|
|
188
|
+
const flags = m.result ? 1 : 0;
|
|
189
|
+
|
|
190
|
+
c.uint.encode(state, flags);
|
|
191
|
+
|
|
192
|
+
if (m.result) c.string.encode(state, m.result);
|
|
193
|
+
},
|
|
194
|
+
decode(state) {
|
|
195
|
+
const flags = c.uint.decode(state);
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
result: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const encoding8_enum = {
|
|
204
|
+
info: 1,
|
|
205
|
+
error: 2,
|
|
206
|
+
debug: 3,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// @tetherto/wdk-secret-manager/log-type-enum enum
|
|
210
|
+
const encoding8 = {
|
|
211
|
+
preencode(state, m) {
|
|
212
|
+
state.end++; // max enum is 3 so always one byte
|
|
213
|
+
},
|
|
214
|
+
encode(state, m) {
|
|
215
|
+
if (m > 3) throw new Error('Unknown enum');
|
|
216
|
+
c.uint.encode(state, m);
|
|
217
|
+
},
|
|
218
|
+
decode(state) {
|
|
219
|
+
return c.uint.decode(state);
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// @tetherto/wdk-secret-manager/command-log-request
|
|
224
|
+
const encoding9 = {
|
|
225
|
+
preencode(state, m) {
|
|
226
|
+
state.end++; // max flag is 2 so always one byte
|
|
227
|
+
|
|
228
|
+
if (m.type) encoding8.preencode(state, m.type);
|
|
229
|
+
if (m.data) c.string.preencode(state, m.data);
|
|
230
|
+
},
|
|
231
|
+
encode(state, m) {
|
|
232
|
+
const flags = (m.type ? 1 : 0) | (m.data ? 2 : 0);
|
|
233
|
+
|
|
234
|
+
c.uint.encode(state, flags);
|
|
235
|
+
|
|
236
|
+
if (m.type) encoding8.encode(state, m.type);
|
|
237
|
+
if (m.data) c.string.encode(state, m.data);
|
|
238
|
+
},
|
|
239
|
+
decode(state) {
|
|
240
|
+
const flags = c.uint.decode(state);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
type: (flags & 1) !== 0 ? encoding8.decode(state) : 0,
|
|
244
|
+
data: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
function setVersion(v) {
|
|
250
|
+
version = v;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function encode(name, value, v = VERSION) {
|
|
254
|
+
version = v;
|
|
255
|
+
return c.encode(getEncoding(name), value);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function decode(name, buffer, v = VERSION) {
|
|
259
|
+
version = v;
|
|
260
|
+
return c.decode(getEncoding(name), buffer);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function getEnum(name) {
|
|
264
|
+
switch (name) {
|
|
265
|
+
case '@tetherto/wdk-secret-manager/log-type-enum':
|
|
266
|
+
return encoding8_enum;
|
|
267
|
+
default:
|
|
268
|
+
throw new Error('Enum not found ' + name);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getEncoding(name) {
|
|
273
|
+
switch (name) {
|
|
274
|
+
case '@tetherto/wdk-secret-manager/command-workletStart-request':
|
|
275
|
+
return encoding0;
|
|
276
|
+
case '@tetherto/wdk-secret-manager/command-workletStart-response':
|
|
277
|
+
return encoding1;
|
|
278
|
+
case '@tetherto/wdk-secret-manager/command-workletStop-request':
|
|
279
|
+
return encoding2;
|
|
280
|
+
case '@tetherto/wdk-secret-manager/command-workletStop-response':
|
|
281
|
+
return encoding3;
|
|
282
|
+
case '@tetherto/wdk-secret-manager/command-generateAndEncrypt-request':
|
|
283
|
+
return encoding4;
|
|
284
|
+
case '@tetherto/wdk-secret-manager/command-generateAndEncrypt-response':
|
|
285
|
+
return encoding5;
|
|
286
|
+
case '@tetherto/wdk-secret-manager/command-decrypt-request':
|
|
287
|
+
return encoding6;
|
|
288
|
+
case '@tetherto/wdk-secret-manager/command-decrypt-response':
|
|
289
|
+
return encoding7;
|
|
290
|
+
case '@tetherto/wdk-secret-manager/log-type-enum':
|
|
291
|
+
return encoding8;
|
|
292
|
+
case '@tetherto/wdk-secret-manager/command-log-request':
|
|
293
|
+
return encoding9;
|
|
294
|
+
default:
|
|
295
|
+
throw new Error('Encoder not found ' + name);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function getStruct(name, v = VERSION) {
|
|
300
|
+
const enc = getEncoding(name);
|
|
301
|
+
return {
|
|
302
|
+
preencode(state, m) {
|
|
303
|
+
version = v;
|
|
304
|
+
enc.preencode(state, m);
|
|
305
|
+
},
|
|
306
|
+
encode(state, m) {
|
|
307
|
+
version = v;
|
|
308
|
+
enc.encode(state, m);
|
|
309
|
+
},
|
|
310
|
+
decode(state) {
|
|
311
|
+
version = v;
|
|
312
|
+
return enc.decode(state);
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const resolveStruct = getStruct; // compat
|
|
318
|
+
|
|
319
|
+
module.exports = {
|
|
320
|
+
resolveStruct,
|
|
321
|
+
getStruct,
|
|
322
|
+
getEnum,
|
|
323
|
+
getEncoding,
|
|
324
|
+
encode,
|
|
325
|
+
decode,
|
|
326
|
+
setVersion,
|
|
327
|
+
version,
|
|
328
|
+
};
|