autopass 3.3.0 → 3.4.1

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/spec/db/index.js CHANGED
@@ -7,9 +7,11 @@ const { version, getEncoding, setVersion } = require('./messages.js')
7
7
  const versions = { schema: version, db: 0 }
8
8
 
9
9
  // '@autopass/records' collection key
10
- const collection0_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 0 })
10
+ const collection0_key = new IndexEncoder([
11
+ IndexEncoder.STRING
12
+ ], { prefix: 0 })
11
13
 
12
- function collection0_indexify(record) {
14
+ function collection0_indexify (record) {
13
15
  const a = record.key
14
16
  return a === undefined ? [] : [a]
15
17
  }
@@ -18,7 +20,7 @@ function collection0_indexify(record) {
18
20
  const collection0_enc = getEncoding('@autopass/records/hyperdb#0')
19
21
 
20
22
  // '@autopass/records' reconstruction function
21
- function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
23
+ function collection0_reconstruct (schemaVersion, keyBuf, valueBuf) {
22
24
  const key = collection0_key.decode(keyBuf)
23
25
  setVersion(schemaVersion)
24
26
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -27,7 +29,7 @@ function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
27
29
  return record
28
30
  }
29
31
  // '@autopass/records' key reconstruction function
30
- function collection0_reconstruct_key(keyBuf) {
32
+ function collection0_reconstruct_key (keyBuf) {
31
33
  const key = collection0_key.decode(keyBuf)
32
34
  return {
33
35
  key: key[0]
@@ -39,11 +41,11 @@ const collection0 = {
39
41
  name: '@autopass/records',
40
42
  id: 0,
41
43
  version: 0,
42
- encodeKey(record) {
44
+ encodeKey (record) {
43
45
  const key = [record.key]
44
46
  return collection0_key.encode(key)
45
47
  },
46
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
48
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
47
49
  return collection0_key.encodeRange({
48
50
  gt: gt ? collection0_indexify(gt) : null,
49
51
  lt: lt ? collection0_indexify(lt) : null,
@@ -51,7 +53,7 @@ const collection0 = {
51
53
  lte: lte ? collection0_indexify(lte) : null
52
54
  })
53
55
  },
54
- encodeValue(schemaVersion, collectionVersion, record) {
56
+ encodeValue (schemaVersion, collectionVersion, record) {
55
57
  setVersion(schemaVersion)
56
58
  const state = { start: 0, end: 0, buffer: null }
57
59
  collection0_enc.preencode(state, record)
@@ -67,9 +69,11 @@ const collection0 = {
67
69
  }
68
70
 
69
71
  // '@autopass/invite' collection key
70
- const collection1_key = new IndexEncoder([IndexEncoder.BUFFER], { prefix: 1 })
72
+ const collection1_key = new IndexEncoder([
73
+ IndexEncoder.BUFFER
74
+ ], { prefix: 1 })
71
75
 
72
- function collection1_indexify(record) {
76
+ function collection1_indexify (record) {
73
77
  const a = record.id
74
78
  return a === undefined ? [] : [a]
75
79
  }
@@ -78,7 +82,7 @@ function collection1_indexify(record) {
78
82
  const collection1_enc = getEncoding('@autopass/invite/hyperdb#1')
79
83
 
80
84
  // '@autopass/invite' reconstruction function
81
- function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
85
+ function collection1_reconstruct (schemaVersion, keyBuf, valueBuf) {
82
86
  const key = collection1_key.decode(keyBuf)
83
87
  setVersion(schemaVersion)
84
88
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -87,7 +91,7 @@ function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
87
91
  return record
88
92
  }
89
93
  // '@autopass/invite' key reconstruction function
90
- function collection1_reconstruct_key(keyBuf) {
94
+ function collection1_reconstruct_key (keyBuf) {
91
95
  const key = collection1_key.decode(keyBuf)
92
96
  return {
93
97
  id: key[0]
@@ -99,11 +103,11 @@ const collection1 = {
99
103
  name: '@autopass/invite',
100
104
  id: 1,
101
105
  version: 0,
102
- encodeKey(record) {
106
+ encodeKey (record) {
103
107
  const key = [record.id]
104
108
  return collection1_key.encode(key)
105
109
  },
106
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
110
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
107
111
  return collection1_key.encodeRange({
108
112
  gt: gt ? collection1_indexify(gt) : null,
109
113
  lt: lt ? collection1_indexify(lt) : null,
@@ -111,7 +115,7 @@ const collection1 = {
111
115
  lte: lte ? collection1_indexify(lte) : null
112
116
  })
113
117
  },
114
- encodeValue(schemaVersion, collectionVersion, record) {
118
+ encodeValue (schemaVersion, collectionVersion, record) {
115
119
  setVersion(schemaVersion)
116
120
  const state = { start: 0, end: 0, buffer: null }
117
121
  collection1_enc.preencode(state, record)
@@ -127,9 +131,11 @@ const collection1 = {
127
131
  }
128
132
 
129
133
  // '@autopass/mirrors' collection key
130
- const collection2_key = new IndexEncoder([IndexEncoder.BUFFER], { prefix: 2 })
134
+ const collection2_key = new IndexEncoder([
135
+ IndexEncoder.BUFFER
136
+ ], { prefix: 2 })
131
137
 
132
- function collection2_indexify(record) {
138
+ function collection2_indexify (record) {
133
139
  const a = record.key
134
140
  return a === undefined ? [] : [a]
135
141
  }
@@ -138,7 +144,7 @@ function collection2_indexify(record) {
138
144
  const collection2_enc = getEncoding('@autopass/mirrors/hyperdb#2')
139
145
 
140
146
  // '@autopass/mirrors' reconstruction function
141
- function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
147
+ function collection2_reconstruct (schemaVersion, keyBuf, valueBuf) {
142
148
  const key = collection2_key.decode(keyBuf)
143
149
  setVersion(schemaVersion)
144
150
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -147,7 +153,7 @@ function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
147
153
  return record
148
154
  }
149
155
  // '@autopass/mirrors' key reconstruction function
150
- function collection2_reconstruct_key(keyBuf) {
156
+ function collection2_reconstruct_key (keyBuf) {
151
157
  const key = collection2_key.decode(keyBuf)
152
158
  return {
153
159
  key: key[0]
@@ -159,11 +165,11 @@ const collection2 = {
159
165
  name: '@autopass/mirrors',
160
166
  id: 2,
161
167
  version: 0,
162
- encodeKey(record) {
168
+ encodeKey (record) {
163
169
  const key = [record.key]
164
170
  return collection2_key.encode(key)
165
171
  },
166
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
172
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
167
173
  return collection2_key.encodeRange({
168
174
  gt: gt ? collection2_indexify(gt) : null,
169
175
  lt: lt ? collection2_indexify(lt) : null,
@@ -171,7 +177,7 @@ const collection2 = {
171
177
  lte: lte ? collection2_indexify(lte) : null
172
178
  })
173
179
  },
174
- encodeValue(schemaVersion, collectionVersion, record) {
180
+ encodeValue (schemaVersion, collectionVersion, record) {
175
181
  setVersion(schemaVersion)
176
182
  const state = { start: 0, end: 0, buffer: null }
177
183
  collection2_enc.preencode(state, record)
@@ -187,9 +193,11 @@ const collection2 = {
187
193
  }
188
194
 
189
195
  // '@autopass/writer' collection key
190
- const collection3_key = new IndexEncoder([IndexEncoder.BUFFER], { prefix: 3 })
196
+ const collection3_key = new IndexEncoder([
197
+ IndexEncoder.BUFFER
198
+ ], { prefix: 3 })
191
199
 
192
- function collection3_indexify(record) {
200
+ function collection3_indexify (record) {
193
201
  const a = record.key
194
202
  return a === undefined ? [] : [a]
195
203
  }
@@ -198,7 +206,7 @@ function collection3_indexify(record) {
198
206
  const collection3_enc = getEncoding('@autopass/writer/hyperdb#3')
199
207
 
200
208
  // '@autopass/writer' reconstruction function
201
- function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
209
+ function collection3_reconstruct (schemaVersion, keyBuf, valueBuf) {
202
210
  const key = collection3_key.decode(keyBuf)
203
211
  setVersion(schemaVersion)
204
212
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -207,7 +215,7 @@ function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
207
215
  return record
208
216
  }
209
217
  // '@autopass/writer' key reconstruction function
210
- function collection3_reconstruct_key(keyBuf) {
218
+ function collection3_reconstruct_key (keyBuf) {
211
219
  const key = collection3_key.decode(keyBuf)
212
220
  return {
213
221
  key: key[0]
@@ -219,11 +227,11 @@ const collection3 = {
219
227
  name: '@autopass/writer',
220
228
  id: 3,
221
229
  version: 0,
222
- encodeKey(record) {
230
+ encodeKey (record) {
223
231
  const key = [record.key]
224
232
  return collection3_key.encode(key)
225
233
  },
226
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
234
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
227
235
  return collection3_key.encodeRange({
228
236
  gt: gt ? collection3_indexify(gt) : null,
229
237
  lt: lt ? collection3_indexify(lt) : null,
@@ -231,7 +239,7 @@ const collection3 = {
231
239
  lte: lte ? collection3_indexify(lte) : null
232
240
  })
233
241
  },
234
- encodeValue(schemaVersion, collectionVersion, record) {
242
+ encodeValue (schemaVersion, collectionVersion, record) {
235
243
  setVersion(schemaVersion)
236
244
  const state = { start: 0, end: 0, buffer: null }
237
245
  collection3_enc.preencode(state, record)
@@ -247,9 +255,11 @@ const collection3 = {
247
255
  }
248
256
 
249
257
  // '@autopass/delete' collection key
250
- const collection4_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 4 })
258
+ const collection4_key = new IndexEncoder([
259
+ IndexEncoder.STRING
260
+ ], { prefix: 4 })
251
261
 
252
- function collection4_indexify(record) {
262
+ function collection4_indexify (record) {
253
263
  const a = record.key
254
264
  return a === undefined ? [] : [a]
255
265
  }
@@ -258,7 +268,7 @@ function collection4_indexify(record) {
258
268
  const collection4_enc = getEncoding('@autopass/delete/hyperdb#4')
259
269
 
260
270
  // '@autopass/delete' reconstruction function
261
- function collection4_reconstruct(schemaVersion, keyBuf, valueBuf) {
271
+ function collection4_reconstruct (schemaVersion, keyBuf, valueBuf) {
262
272
  const key = collection4_key.decode(keyBuf)
263
273
  setVersion(schemaVersion)
264
274
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -267,7 +277,7 @@ function collection4_reconstruct(schemaVersion, keyBuf, valueBuf) {
267
277
  return record
268
278
  }
269
279
  // '@autopass/delete' key reconstruction function
270
- function collection4_reconstruct_key(keyBuf) {
280
+ function collection4_reconstruct_key (keyBuf) {
271
281
  const key = collection4_key.decode(keyBuf)
272
282
  return {
273
283
  key: key[0]
@@ -279,11 +289,11 @@ const collection4 = {
279
289
  name: '@autopass/delete',
280
290
  id: 4,
281
291
  version: 0,
282
- encodeKey(record) {
292
+ encodeKey (record) {
283
293
  const key = [record.key]
284
294
  return collection4_key.encode(key)
285
295
  },
286
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
296
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
287
297
  return collection4_key.encodeRange({
288
298
  gt: gt ? collection4_indexify(gt) : null,
289
299
  lt: lt ? collection4_indexify(lt) : null,
@@ -291,7 +301,7 @@ const collection4 = {
291
301
  lte: lte ? collection4_indexify(lte) : null
292
302
  })
293
303
  },
294
- encodeValue(schemaVersion, collectionVersion, record) {
304
+ encodeValue (schemaVersion, collectionVersion, record) {
295
305
  setVersion(schemaVersion)
296
306
  const state = { start: 0, end: 0, buffer: null }
297
307
  collection4_enc.preencode(state, record)
@@ -307,9 +317,11 @@ const collection4 = {
307
317
  }
308
318
 
309
319
  // '@autopass/del-invite' collection key
310
- const collection5_key = new IndexEncoder([IndexEncoder.BUFFER], { prefix: 5 })
320
+ const collection5_key = new IndexEncoder([
321
+ IndexEncoder.BUFFER
322
+ ], { prefix: 5 })
311
323
 
312
- function collection5_indexify(record) {
324
+ function collection5_indexify (record) {
313
325
  const a = record.id
314
326
  return a === undefined ? [] : [a]
315
327
  }
@@ -318,7 +330,7 @@ function collection5_indexify(record) {
318
330
  const collection5_enc = getEncoding('@autopass/del-invite/hyperdb#5')
319
331
 
320
332
  // '@autopass/del-invite' reconstruction function
321
- function collection5_reconstruct(schemaVersion, keyBuf, valueBuf) {
333
+ function collection5_reconstruct (schemaVersion, keyBuf, valueBuf) {
322
334
  const key = collection5_key.decode(keyBuf)
323
335
  setVersion(schemaVersion)
324
336
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -327,7 +339,7 @@ function collection5_reconstruct(schemaVersion, keyBuf, valueBuf) {
327
339
  return record
328
340
  }
329
341
  // '@autopass/del-invite' key reconstruction function
330
- function collection5_reconstruct_key(keyBuf) {
342
+ function collection5_reconstruct_key (keyBuf) {
331
343
  const key = collection5_key.decode(keyBuf)
332
344
  return {
333
345
  id: key[0]
@@ -339,11 +351,11 @@ const collection5 = {
339
351
  name: '@autopass/del-invite',
340
352
  id: 5,
341
353
  version: 0,
342
- encodeKey(record) {
354
+ encodeKey (record) {
343
355
  const key = [record.id]
344
356
  return collection5_key.encode(key)
345
357
  },
346
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
358
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
347
359
  return collection5_key.encodeRange({
348
360
  gt: gt ? collection5_indexify(gt) : null,
349
361
  lt: lt ? collection5_indexify(lt) : null,
@@ -351,7 +363,7 @@ const collection5 = {
351
363
  lte: lte ? collection5_indexify(lte) : null
352
364
  })
353
365
  },
354
- encodeValue(schemaVersion, collectionVersion, record) {
366
+ encodeValue (schemaVersion, collectionVersion, record) {
355
367
  setVersion(schemaVersion)
356
368
  const state = { start: 0, end: 0, buffer: null }
357
369
  collection5_enc.preencode(state, record)
@@ -367,9 +379,11 @@ const collection5 = {
367
379
  }
368
380
 
369
381
  // '@autopass/del-mirror' collection key
370
- const collection6_key = new IndexEncoder([IndexEncoder.BUFFER], { prefix: 6 })
382
+ const collection6_key = new IndexEncoder([
383
+ IndexEncoder.BUFFER
384
+ ], { prefix: 6 })
371
385
 
372
- function collection6_indexify(record) {
386
+ function collection6_indexify (record) {
373
387
  const a = record.key
374
388
  return a === undefined ? [] : [a]
375
389
  }
@@ -378,7 +392,7 @@ function collection6_indexify(record) {
378
392
  const collection6_enc = getEncoding('@autopass/del-mirror/hyperdb#6')
379
393
 
380
394
  // '@autopass/del-mirror' reconstruction function
381
- function collection6_reconstruct(schemaVersion, keyBuf, valueBuf) {
395
+ function collection6_reconstruct (schemaVersion, keyBuf, valueBuf) {
382
396
  const key = collection6_key.decode(keyBuf)
383
397
  setVersion(schemaVersion)
384
398
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -387,7 +401,7 @@ function collection6_reconstruct(schemaVersion, keyBuf, valueBuf) {
387
401
  return record
388
402
  }
389
403
  // '@autopass/del-mirror' key reconstruction function
390
- function collection6_reconstruct_key(keyBuf) {
404
+ function collection6_reconstruct_key (keyBuf) {
391
405
  const key = collection6_key.decode(keyBuf)
392
406
  return {
393
407
  key: key[0]
@@ -399,11 +413,11 @@ const collection6 = {
399
413
  name: '@autopass/del-mirror',
400
414
  id: 6,
401
415
  version: 0,
402
- encodeKey(record) {
416
+ encodeKey (record) {
403
417
  const key = [record.key]
404
418
  return collection6_key.encode(key)
405
419
  },
406
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
420
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
407
421
  return collection6_key.encodeRange({
408
422
  gt: gt ? collection6_indexify(gt) : null,
409
423
  lt: lt ? collection6_indexify(lt) : null,
@@ -411,7 +425,7 @@ const collection6 = {
411
425
  lte: lte ? collection6_indexify(lte) : null
412
426
  })
413
427
  },
414
- encodeValue(schemaVersion, collectionVersion, record) {
428
+ encodeValue (schemaVersion, collectionVersion, record) {
415
429
  setVersion(schemaVersion)
416
430
  const state = { start: 0, end: 0, buffer: null }
417
431
  collection6_enc.preencode(state, record)
@@ -436,34 +450,26 @@ const collections = [
436
450
  collection6
437
451
  ]
438
452
 
439
- const indexes = []
453
+ const indexes = [
454
+ ]
440
455
 
441
456
  module.exports = { versions, collections, indexes, resolveCollection, resolveIndex }
442
457
 
443
- function resolveCollection(name) {
458
+ function resolveCollection (name) {
444
459
  switch (name) {
445
- case '@autopass/records':
446
- return collection0
447
- case '@autopass/invite':
448
- return collection1
449
- case '@autopass/mirrors':
450
- return collection2
451
- case '@autopass/writer':
452
- return collection3
453
- case '@autopass/delete':
454
- return collection4
455
- case '@autopass/del-invite':
456
- return collection5
457
- case '@autopass/del-mirror':
458
- return collection6
459
- default:
460
- return null
460
+ case '@autopass/records': return collection0
461
+ case '@autopass/invite': return collection1
462
+ case '@autopass/mirrors': return collection2
463
+ case '@autopass/writer': return collection3
464
+ case '@autopass/delete': return collection4
465
+ case '@autopass/del-invite': return collection5
466
+ case '@autopass/del-mirror': return collection6
467
+ default: return null
461
468
  }
462
469
  }
463
470
 
464
- function resolveIndex(name) {
471
+ function resolveIndex (name) {
465
472
  switch (name) {
466
- default:
467
- return null
473
+ default: return null
468
474
  }
469
475
  }
@@ -1,12 +1,12 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 3
2
+ // Schema Version: 4
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
  /* eslint-disable space-before-function-paren */
6
6
 
7
7
  const { c } = require('hyperschema/runtime')
8
8
 
9
- const VERSION = 3
9
+ const VERSION = 4
10
10
 
11
11
  // eslint-disable-next-line no-unused-vars
12
12
  let version = VERSION
@@ -62,15 +62,26 @@ const encoding1 = {
62
62
  const encoding2 = {
63
63
  preencode(state, m) {
64
64
  c.buffer.preencode(state, m.key)
65
+ state.end++ // max flag is 2 so always one byte
66
+
67
+ if (version >= 4 && m.name) c.string.preencode(state, m.name)
65
68
  },
66
69
  encode(state, m) {
70
+ const flags = ((version >= 4 && m.name) ? 1 : 0) | ((version >= 4 && m.readOnly) ? 2 : 0)
71
+
67
72
  c.buffer.encode(state, m.key)
73
+ c.uint.encode(state, flags)
74
+
75
+ if (version >= 4 && m.name) c.string.encode(state, m.name)
68
76
  },
69
77
  decode(state) {
70
78
  const r0 = c.buffer.decode(state)
79
+ const flags = state.start < state.end ? c.uint.decode(state) : 0
71
80
 
72
81
  return {
73
- key: r0
82
+ key: r0,
83
+ name: (version >= 4 && (flags & 1) !== 0) ? c.string.decode(state) : null,
84
+ readOnly: (version >= 4 && (flags & 2) !== 0)
74
85
  }
75
86
  }
76
87
  }
@@ -104,7 +115,7 @@ const encoding4 = {
104
115
  if (version >= 3 && m.additional) encoding4_5.preencode(state, m.additional)
105
116
  },
106
117
  encode(state, m) {
107
- const flags = (version >= 2 && m.readOnly ? 1 : 0) | (version >= 3 && m.additional ? 2 : 0)
118
+ const flags = ((version >= 2 && m.readOnly) ? 1 : 0) | ((version >= 3 && m.additional) ? 2 : 0)
108
119
 
109
120
  c.buffer.encode(state, m.id)
110
121
  c.buffer.encode(state, m.invite)
@@ -126,8 +137,8 @@ const encoding4 = {
126
137
  invite: r1,
127
138
  publicKey: r2,
128
139
  expires: r3,
129
- readOnly: version >= 2 && (flags & 1) !== 0,
130
- additional: version >= 3 && (flags & 2) !== 0 ? encoding4_5.decode(state) : null
140
+ readOnly: (version >= 2 && (flags & 1) !== 0),
141
+ additional: (version >= 3 && (flags & 2) !== 0) ? encoding4_5.decode(state) : null
131
142
  }
132
143
  }
133
144
  }
@@ -173,8 +184,54 @@ const encoding7 = {
173
184
  }
174
185
  }
175
186
 
176
- // @autopass/records/hyperdb#0
187
+ // @autopass/invitee
177
188
  const encoding8 = {
189
+ preencode(state, m) {
190
+ c.fixed32.preencode(state, m.key)
191
+ state.end++ // max flag is 1 so always one byte
192
+
193
+ if (version >= 4 && m.name) c.string.preencode(state, m.name)
194
+ },
195
+ encode(state, m) {
196
+ const flags = (version >= 4 && m.name) ? 1 : 0
197
+
198
+ c.fixed32.encode(state, m.key)
199
+ c.uint.encode(state, flags)
200
+
201
+ if (version >= 4 && m.name) c.string.encode(state, m.name)
202
+ },
203
+ decode(state) {
204
+ const r0 = c.fixed32.decode(state)
205
+ const flags = c.uint.decode(state)
206
+
207
+ return {
208
+ key: r0,
209
+ name: (version >= 4 && (flags & 1) !== 0) ? c.string.decode(state) : null
210
+ }
211
+ }
212
+ }
213
+
214
+ // @autopass/public-invite-metadata
215
+ const encoding9 = {
216
+ preencode(state, m) {
217
+ state.end++ // max flag is 1 so always one byte
218
+ },
219
+ encode(state, m) {
220
+ const flags = (version >= 4 && m.readOnly) ? 1 : 0
221
+
222
+ c.uint.encode(state, flags)
223
+ },
224
+ decode(state) {
225
+ const flags = c.uint.decode(state)
226
+
227
+ return {
228
+ readOnly: (version >= 4 && (flags & 1) !== 0)
229
+ }
230
+ }
231
+ }
232
+
233
+ // @autopass/records/hyperdb#0
234
+ const encoding10 = {
178
235
  preencode(state, m) {
179
236
  state.end++ // max flag is 2 so always one byte
180
237
 
@@ -201,24 +258,24 @@ const encoding8 = {
201
258
  }
202
259
 
203
260
  // @autopass/invite/hyperdb#1
204
- const encoding9 = {
261
+ const encoding11 = {
205
262
  preencode(state, m) {
206
263
  c.buffer.preencode(state, m.invite)
207
264
  c.buffer.preencode(state, m.publicKey)
208
265
  c.int.preencode(state, m.expires)
209
266
  state.end++ // max flag is 2 so always one byte
210
267
 
211
- if (version >= 3 && m.additional) encoding9_5.preencode(state, m.additional)
268
+ if (version >= 3 && m.additional) encoding11_5.preencode(state, m.additional)
212
269
  },
213
270
  encode(state, m) {
214
- const flags = (version >= 2 && m.readOnly ? 1 : 0) | (version >= 3 && m.additional ? 2 : 0)
271
+ const flags = ((version >= 2 && m.readOnly) ? 1 : 0) | ((version >= 3 && m.additional) ? 2 : 0)
215
272
 
216
273
  c.buffer.encode(state, m.invite)
217
274
  c.buffer.encode(state, m.publicKey)
218
275
  c.int.encode(state, m.expires)
219
276
  c.uint.encode(state, flags)
220
277
 
221
- if (version >= 3 && m.additional) encoding9_5.encode(state, m.additional)
278
+ if (version >= 3 && m.additional) encoding11_5.encode(state, m.additional)
222
279
  },
223
280
  decode(state) {
224
281
  const r1 = c.buffer.decode(state)
@@ -231,16 +288,20 @@ const encoding9 = {
231
288
  invite: r1,
232
289
  publicKey: r2,
233
290
  expires: r3,
234
- readOnly: version >= 2 && (flags & 1) !== 0,
235
- additional: version >= 3 && (flags & 2) !== 0 ? encoding9_5.decode(state) : null
291
+ readOnly: (version >= 2 && (flags & 1) !== 0),
292
+ additional: (version >= 3 && (flags & 2) !== 0) ? encoding11_5.decode(state) : null
236
293
  }
237
294
  }
238
295
  }
239
296
 
240
297
  // @autopass/mirrors/hyperdb#2
241
- const encoding10 = {
242
- preencode(state, m) {},
243
- encode(state, m) {},
298
+ const encoding12 = {
299
+ preencode(state, m) {
300
+
301
+ },
302
+ encode(state, m) {
303
+
304
+ },
244
305
  decode(state) {
245
306
  return {
246
307
  key: null
@@ -249,15 +310,41 @@ const encoding10 = {
249
310
  }
250
311
 
251
312
  // @autopass/writer/hyperdb#3
252
- const encoding11 = encoding10
313
+ const encoding13 = {
314
+ preencode(state, m) {
315
+ state.end++ // max flag is 2 so always one byte
316
+
317
+ if (version >= 4 && m.name) c.string.preencode(state, m.name)
318
+ },
319
+ encode(state, m) {
320
+ const flags = ((version >= 4 && m.name) ? 1 : 0) | ((version >= 4 && m.readOnly) ? 2 : 0)
321
+
322
+ c.uint.encode(state, flags)
323
+
324
+ if (version >= 4 && m.name) c.string.encode(state, m.name)
325
+ },
326
+ decode(state) {
327
+ const flags = state.start < state.end ? c.uint.decode(state) : 0
328
+
329
+ return {
330
+ key: null,
331
+ name: (version >= 4 && (flags & 1) !== 0) ? c.string.decode(state) : null,
332
+ readOnly: (version >= 4 && (flags & 2) !== 0)
333
+ }
334
+ }
335
+ }
253
336
 
254
337
  // @autopass/delete/hyperdb#4
255
- const encoding12 = encoding10
338
+ const encoding14 = encoding12
256
339
 
257
340
  // @autopass/del-invite/hyperdb#5
258
- const encoding13 = {
259
- preencode(state, m) {},
260
- encode(state, m) {},
341
+ const encoding15 = {
342
+ preencode(state, m) {
343
+
344
+ },
345
+ encode(state, m) {
346
+
347
+ },
261
348
  decode(state) {
262
349
  return {
263
350
  id: null
@@ -266,12 +353,12 @@ const encoding13 = {
266
353
  }
267
354
 
268
355
  // @autopass/del-mirror/hyperdb#6
269
- const encoding14 = encoding10
356
+ const encoding16 = encoding12
270
357
 
271
358
  // @autopass/invite.additional, deferred due to recusive use
272
359
  const encoding4_5 = c.frame(encoding7)
273
360
  // @autopass/invite/hyperdb#1.additional, deferred due to recusive use
274
- const encoding9_5 = encoding4_5
361
+ const encoding11_5 = encoding4_5
275
362
 
276
363
  function setVersion(v) {
277
364
  version = v
@@ -312,20 +399,24 @@ function getEncoding(name) {
312
399
  return encoding6
313
400
  case '@autopass/additional-invite-data':
314
401
  return encoding7
315
- case '@autopass/records/hyperdb#0':
402
+ case '@autopass/invitee':
316
403
  return encoding8
317
- case '@autopass/invite/hyperdb#1':
404
+ case '@autopass/public-invite-metadata':
318
405
  return encoding9
319
- case '@autopass/mirrors/hyperdb#2':
406
+ case '@autopass/records/hyperdb#0':
320
407
  return encoding10
321
- case '@autopass/writer/hyperdb#3':
408
+ case '@autopass/invite/hyperdb#1':
322
409
  return encoding11
323
- case '@autopass/delete/hyperdb#4':
410
+ case '@autopass/mirrors/hyperdb#2':
324
411
  return encoding12
325
- case '@autopass/del-invite/hyperdb#5':
412
+ case '@autopass/writer/hyperdb#3':
326
413
  return encoding13
327
- case '@autopass/del-mirror/hyperdb#6':
414
+ case '@autopass/delete/hyperdb#4':
328
415
  return encoding14
416
+ case '@autopass/del-invite/hyperdb#5':
417
+ return encoding15
418
+ case '@autopass/del-mirror/hyperdb#6':
419
+ return encoding16
329
420
  default:
330
421
  throw new Error('Encoder not found ' + name)
331
422
  }
@@ -51,4 +51,4 @@
51
51
  "version": 1
52
52
  }
53
53
  ]
54
- }
54
+ }