@ixo/action-protocol 0.6.0 → 0.8.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/CHANGELOG.md +311 -0
- package/README.md +50 -3
- package/package.json +1 -1
- package/src/index.d.ts +706 -3
- package/src/index.js +1090 -20
- package/src/operation-schema.js +356 -0
package/src/operation-schema.js
CHANGED
|
@@ -39,6 +39,35 @@ const instant = {
|
|
|
39
39
|
"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?(?:Z|[+-]\\d{2}:\\d{2})$",
|
|
40
40
|
};
|
|
41
41
|
const hex = { ...string(64, 64), pattern: "^[a-f0-9]{64}$" };
|
|
42
|
+
// 0.7.0 application and claim cards: the network, a claim collection that
|
|
43
|
+
// exists (never 0), and the rows the review card shows, one per answer.
|
|
44
|
+
const integer = (minimum, maximum) => ({ type: "integer", minimum, maximum });
|
|
45
|
+
const network = enumeration("ixo mainnet", "ixo testnet", "ixo devnet");
|
|
46
|
+
const submissionCollectionId = { ...string(1, 20), pattern: "^[1-9][0-9]{0,19}$" };
|
|
47
|
+
// Each row shows one answer of `data`: `field` is its path (as an evidence
|
|
48
|
+
// `field`), `value` its display form (submissionDisplayValue); the parser
|
|
49
|
+
// checks that every answer has its row and every row is its answer.
|
|
50
|
+
const summary = {
|
|
51
|
+
type: "array",
|
|
52
|
+
items: object({
|
|
53
|
+
field: string(1, 200),
|
|
54
|
+
label: string(1, 200),
|
|
55
|
+
value: string(0, 2000),
|
|
56
|
+
}),
|
|
57
|
+
// No rows only when `data` has no answers (a claim of files only).
|
|
58
|
+
minItems: 0,
|
|
59
|
+
maxItems: 100,
|
|
60
|
+
};
|
|
61
|
+
// 0.6.0: a file the person sent on the channel, kept by the gateway until the
|
|
62
|
+
// Hub uploads it as claim evidence.
|
|
63
|
+
const evidence = object({
|
|
64
|
+
field: string(1, 200),
|
|
65
|
+
url: string(1, 2000),
|
|
66
|
+
filename: string(1, 200),
|
|
67
|
+
mimetype: string(1, 100),
|
|
68
|
+
size: integer(1, 52428800),
|
|
69
|
+
sha256: hex,
|
|
70
|
+
});
|
|
42
71
|
// One ASCII mailbox only; no display names, address lists or header characters.
|
|
43
72
|
const mailbox = {
|
|
44
73
|
...string(3, 254),
|
|
@@ -63,6 +92,95 @@ const chainText = (min, max) => ({
|
|
|
63
92
|
...string(min, max),
|
|
64
93
|
pattern: min > 0 ? "^[A-Za-z0-9:._/-]+$" : "^[A-Za-z0-9:._/-]*$",
|
|
65
94
|
});
|
|
95
|
+
// 0.8.0 (wire level 6) shapes. Cross-field rules (end after start, at least
|
|
96
|
+
// one date, role-only options, distinct payment denoms, uint64/10^9 maxima,
|
|
97
|
+
// calendar dates, https host parsing, `admin`) are the field parser's.
|
|
98
|
+
const denom = { ...string(3, 128), pattern: "^[a-zA-Z][a-zA-Z0-9/:._-]{2,127}$" };
|
|
99
|
+
const valoper = {
|
|
100
|
+
...string(49, 49),
|
|
101
|
+
pattern: "^ixovaloper1[023456789acdefghjklmnpqrstuvwxyz]{38}$",
|
|
102
|
+
};
|
|
103
|
+
const entityDid = { ...string(47, 47), pattern: "^did:ixo:entity:[0-9a-f]{32}$" };
|
|
104
|
+
const uint64Text = collectionId;
|
|
105
|
+
const proposalId = { ...string(1, 20), pattern: "^[1-9][0-9]{0,19}$" };
|
|
106
|
+
const claimPermissionCount = { ...string(1, 10), pattern: "^[1-9][0-9]{0,9}$" };
|
|
107
|
+
const seconds = integer(0, 31536000);
|
|
108
|
+
const boolean = { type: "boolean" };
|
|
109
|
+
// The field parser's CONTROL set (index.js), as a character class body.
|
|
110
|
+
const control =
|
|
111
|
+
"\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200b-\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069\\ufeff";
|
|
112
|
+
// PLAIN_TEXT(max): 1..max characters, not blank, no control/bidi/zero-width.
|
|
113
|
+
const plainText = (max) => ({
|
|
114
|
+
...string(1, max),
|
|
115
|
+
pattern: `^(?!\\s*$)[^${control}]+$`,
|
|
116
|
+
});
|
|
117
|
+
// No whitespace, backslash or CONTROL character anywhere; no user info.
|
|
118
|
+
const httpsUrl = `https://[^\\s/?#@\\\\${control}]+(?:[/?#][^\\s\\\\${control}]*)?`;
|
|
119
|
+
const ipfsUrl = `ipfs://[A-Za-z0-9]+(?:/[^\\s\\\\${control}]*)?`;
|
|
120
|
+
const httpsLink = { ...string(9, 300), pattern: `^${httpsUrl}$` };
|
|
121
|
+
const link = { ...string(8, 300), pattern: `^(?:${httpsUrl}|${ipfsUrl})$` };
|
|
122
|
+
const itemId = {
|
|
123
|
+
...string(6, 233),
|
|
124
|
+
pattern: "^(?:\\{id\\}|did:ixo:[A-Za-z0-9._:%-]{1,160})#[A-Za-z0-9._~:-]{1,64}$",
|
|
125
|
+
};
|
|
126
|
+
// D28: an item to remove is named exactly as the document holds it.
|
|
127
|
+
const removeId = { ...string(1, 300), pattern: `^[^\\s${control}]+$` };
|
|
128
|
+
const iidType = { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9._:/+-]{0,63}$" };
|
|
129
|
+
// D28: linked resources and claims as Portal stores them.
|
|
130
|
+
const linkDescription = { ...string(0, 300), pattern: `^[^${control}]*$` };
|
|
131
|
+
const linkRight = optional({
|
|
132
|
+
...string(0, 300),
|
|
133
|
+
pattern: `^(?:(?!\\s*$)[^${control}]+)?$`,
|
|
134
|
+
});
|
|
135
|
+
const linkedEntityId = {
|
|
136
|
+
anyOf: [
|
|
137
|
+
ixoDid,
|
|
138
|
+
{
|
|
139
|
+
...string(42, 67),
|
|
140
|
+
pattern:
|
|
141
|
+
"^(?:\\{id\\}#)?ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
const contextKey = { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9_-]{0,63}$" };
|
|
146
|
+
const coins = {
|
|
147
|
+
type: "array",
|
|
148
|
+
items: object({ denom, amountBaseUnits: baseUnits }),
|
|
149
|
+
minItems: 0,
|
|
150
|
+
maxItems: 4,
|
|
151
|
+
};
|
|
152
|
+
const leg = object({ amount: coins, payAfterSeconds: optional(seconds) });
|
|
153
|
+
const payments = object({
|
|
154
|
+
submission: optional(leg),
|
|
155
|
+
evaluation: optional(leg),
|
|
156
|
+
approval: optional(
|
|
157
|
+
object({
|
|
158
|
+
amount: coins,
|
|
159
|
+
payAfterSeconds: optional(seconds),
|
|
160
|
+
networkSplit: optional(boolean),
|
|
161
|
+
}),
|
|
162
|
+
),
|
|
163
|
+
rejection: optional(leg),
|
|
164
|
+
});
|
|
165
|
+
const tokenLines = {
|
|
166
|
+
type: "array",
|
|
167
|
+
items: object({ id: chainText(1, 128), amount: baseUnits }),
|
|
168
|
+
minItems: 1,
|
|
169
|
+
maxItems: 32,
|
|
170
|
+
};
|
|
171
|
+
const collectionState = enumeration("open", "paused", "closed");
|
|
172
|
+
const entityPermission = enumeration(
|
|
173
|
+
"change-collection-state",
|
|
174
|
+
"change-collection-dates",
|
|
175
|
+
"change-collection-quota",
|
|
176
|
+
"change-collection-payments",
|
|
177
|
+
"authorize-claim-agents",
|
|
178
|
+
"file-claims",
|
|
179
|
+
"check-claims",
|
|
180
|
+
);
|
|
181
|
+
const ixoDidOrHttps = {
|
|
182
|
+
anyOf: [httpsLink, { ...ixoDid, maxLength: 300 }],
|
|
183
|
+
};
|
|
66
184
|
const chainTxMessage = {
|
|
67
185
|
anyOf: [
|
|
68
186
|
object({
|
|
@@ -104,6 +222,228 @@ const chainTxMessage = {
|
|
|
104
222
|
maxItems: 32,
|
|
105
223
|
},
|
|
106
224
|
}),
|
|
225
|
+
// 0.8.0 (wire level 6), in CHAIN_TX_MESSAGE_TYPES order.
|
|
226
|
+
object({
|
|
227
|
+
type: { const: "ixo.token.retire" },
|
|
228
|
+
tokens: tokenLines,
|
|
229
|
+
jurisdiction: {
|
|
230
|
+
...string(2, 71),
|
|
231
|
+
pattern:
|
|
232
|
+
"^(?:Global|[A-Z]{2}(?:-[A-Za-z0-9]{1,3}(?: [A-Za-z0-9]{1,64})?)?)$",
|
|
233
|
+
},
|
|
234
|
+
reason: plainText(200),
|
|
235
|
+
}),
|
|
236
|
+
object({
|
|
237
|
+
type: { const: "cosmos.staking.delegate" },
|
|
238
|
+
validatorAddress: valoper,
|
|
239
|
+
amountBaseUnits: baseUnits,
|
|
240
|
+
}),
|
|
241
|
+
object({
|
|
242
|
+
type: { const: "cosmos.staking.undelegate" },
|
|
243
|
+
validatorAddress: valoper,
|
|
244
|
+
amountBaseUnits: baseUnits,
|
|
245
|
+
}),
|
|
246
|
+
object({
|
|
247
|
+
type: { const: "cosmos.staking.redelegate" },
|
|
248
|
+
fromValidatorAddress: valoper,
|
|
249
|
+
toValidatorAddress: valoper,
|
|
250
|
+
amountBaseUnits: baseUnits,
|
|
251
|
+
}),
|
|
252
|
+
object({
|
|
253
|
+
type: { const: "cosmos.distribution.withdraw-rewards" },
|
|
254
|
+
validatorAddress: valoper,
|
|
255
|
+
}),
|
|
256
|
+
object({
|
|
257
|
+
type: { const: "cosmos.gov.vote" },
|
|
258
|
+
proposalId,
|
|
259
|
+
option: enumeration("yes", "no", "abstain", "no_with_veto"),
|
|
260
|
+
}),
|
|
261
|
+
object({
|
|
262
|
+
type: { const: "ixo.claims.claim-intent" },
|
|
263
|
+
collectionId,
|
|
264
|
+
agentDid: ixoDid,
|
|
265
|
+
}),
|
|
266
|
+
object({
|
|
267
|
+
type: { const: "ixo.claims.dispute" },
|
|
268
|
+
claimId: chainText(1, 256),
|
|
269
|
+
collectionId,
|
|
270
|
+
agentDid: ixoDid,
|
|
271
|
+
reason: enumeration("not_as_asked", "not_delivered", "check_wrong", "other"),
|
|
272
|
+
evidence: object({
|
|
273
|
+
uri: link,
|
|
274
|
+
type: { ...string(1, 100), pattern: "^[A-Za-z0-9][A-Za-z0-9.+/_-]{0,99}$" },
|
|
275
|
+
proof: chainText(1, 300),
|
|
276
|
+
encrypted: optional(boolean),
|
|
277
|
+
}),
|
|
278
|
+
}),
|
|
279
|
+
object({
|
|
280
|
+
type: { const: "ixo.claims.update-collection-state" },
|
|
281
|
+
collectionId,
|
|
282
|
+
adminAddress: account,
|
|
283
|
+
state: collectionState,
|
|
284
|
+
}),
|
|
285
|
+
object({
|
|
286
|
+
type: { const: "ixo.claims.update-collection-dates" },
|
|
287
|
+
collectionId,
|
|
288
|
+
adminAddress: account,
|
|
289
|
+
startDate: optional(instant),
|
|
290
|
+
endDate: optional(nullable(instant)),
|
|
291
|
+
}),
|
|
292
|
+
object({
|
|
293
|
+
type: { const: "ixo.claims.update-collection-quota" },
|
|
294
|
+
collectionId,
|
|
295
|
+
adminAddress: account,
|
|
296
|
+
maxClaims: uint64Text,
|
|
297
|
+
}),
|
|
298
|
+
object({
|
|
299
|
+
type: { const: "ixo.claims.create-claim-authorization" },
|
|
300
|
+
collectionId,
|
|
301
|
+
adminAddress: account,
|
|
302
|
+
granteeAddress: account,
|
|
303
|
+
role: enumeration("file-claims", "check-claims"),
|
|
304
|
+
maxClaims: claimPermissionCount,
|
|
305
|
+
expiresAt: optional(instant),
|
|
306
|
+
reservationSeconds: optional(seconds),
|
|
307
|
+
decideBefore: optional(instant),
|
|
308
|
+
creatorDid: ixoDid,
|
|
309
|
+
}),
|
|
310
|
+
object({
|
|
311
|
+
type: { const: "ixo.claims.update-collection-payments" },
|
|
312
|
+
collectionId,
|
|
313
|
+
adminAddress: account,
|
|
314
|
+
payments,
|
|
315
|
+
}),
|
|
316
|
+
object({
|
|
317
|
+
type: { const: "ixo.claims.create-collection" },
|
|
318
|
+
entityId: entityDid,
|
|
319
|
+
protocolId: ixoDid,
|
|
320
|
+
startDate: instant,
|
|
321
|
+
endDate: nullable(instant),
|
|
322
|
+
maxClaims: uint64Text,
|
|
323
|
+
state: collectionState,
|
|
324
|
+
reservations: enumeration("allow", "deny", "required"),
|
|
325
|
+
payments,
|
|
326
|
+
}),
|
|
327
|
+
object({
|
|
328
|
+
type: { const: "ixo.entity.create-account" },
|
|
329
|
+
entityId: entityDid,
|
|
330
|
+
name: {
|
|
331
|
+
...string(1, 64),
|
|
332
|
+
pattern: "^[A-Za-z0-9](?:[A-Za-z0-9 _-]{0,62}[A-Za-z0-9])?$",
|
|
333
|
+
},
|
|
334
|
+
}),
|
|
335
|
+
object({
|
|
336
|
+
type: { const: "ixo.entity.update" },
|
|
337
|
+
entityId: entityDid,
|
|
338
|
+
startDate: optional(instant),
|
|
339
|
+
endDate: optional(nullable(instant)),
|
|
340
|
+
controllerDid: ixoDid,
|
|
341
|
+
}),
|
|
342
|
+
object({
|
|
343
|
+
type: { const: "ixo.entity.revoke-account-authz" },
|
|
344
|
+
entityId: entityDid,
|
|
345
|
+
granteeAddress: account,
|
|
346
|
+
permission: entityPermission,
|
|
347
|
+
}),
|
|
348
|
+
object({
|
|
349
|
+
type: { const: "ixo.entity.grant-account-authz" },
|
|
350
|
+
entityId: entityDid,
|
|
351
|
+
granteeAddress: account,
|
|
352
|
+
permission: entityPermission,
|
|
353
|
+
collectionId: optional(collectionId),
|
|
354
|
+
maxClaims: optional(claimPermissionCount),
|
|
355
|
+
reservationSeconds: optional(seconds),
|
|
356
|
+
decideBefore: optional(instant),
|
|
357
|
+
expiresAt: optional(instant),
|
|
358
|
+
}),
|
|
359
|
+
object({
|
|
360
|
+
type: { const: "ixo.entity.create" },
|
|
361
|
+
entityType: {
|
|
362
|
+
...string(1, 65),
|
|
363
|
+
pattern: "^[a-z][a-z0-9_-]{0,31}(?:/[a-z][a-z0-9_-]{0,31})?$",
|
|
364
|
+
},
|
|
365
|
+
profile: optional(object({ serviceEndpoint: httpsLink, proof: chainText(1, 300) })),
|
|
366
|
+
protocolId: optional(ixoDid),
|
|
367
|
+
startDate: optional(instant),
|
|
368
|
+
endDate: optional(instant),
|
|
369
|
+
ownerDid: ixoDid,
|
|
370
|
+
}),
|
|
371
|
+
object({
|
|
372
|
+
type: { const: "ixo.iid.add-service" },
|
|
373
|
+
did: ixoDid,
|
|
374
|
+
service: object({ id: itemId, type: iidType, serviceEndpoint: link }),
|
|
375
|
+
}),
|
|
376
|
+
object({
|
|
377
|
+
type: { const: "ixo.iid.delete-service" },
|
|
378
|
+
did: ixoDid,
|
|
379
|
+
serviceId: removeId,
|
|
380
|
+
}),
|
|
381
|
+
object({
|
|
382
|
+
type: { const: "ixo.iid.add-linked-resource" },
|
|
383
|
+
did: ixoDid,
|
|
384
|
+
resource: object({
|
|
385
|
+
id: itemId,
|
|
386
|
+
type: iidType,
|
|
387
|
+
description: linkDescription,
|
|
388
|
+
mediaType: { ...string(3, 128), pattern: "^[a-z]+/[A-Za-z0-9.+-]{1,90}$" },
|
|
389
|
+
serviceEndpoint: link,
|
|
390
|
+
proof: chainText(0, 300),
|
|
391
|
+
encrypted: boolean,
|
|
392
|
+
right: linkRight,
|
|
393
|
+
}),
|
|
394
|
+
}),
|
|
395
|
+
object({
|
|
396
|
+
type: { const: "ixo.iid.delete-linked-resource" },
|
|
397
|
+
did: ixoDid,
|
|
398
|
+
resourceId: removeId,
|
|
399
|
+
}),
|
|
400
|
+
object({
|
|
401
|
+
type: { const: "ixo.iid.add-linked-claim" },
|
|
402
|
+
did: ixoDid,
|
|
403
|
+
claim: object({
|
|
404
|
+
id: chainText(1, 256),
|
|
405
|
+
type: iidType,
|
|
406
|
+
description: linkDescription,
|
|
407
|
+
serviceEndpoint: link,
|
|
408
|
+
proof: chainText(0, 300),
|
|
409
|
+
encrypted: boolean,
|
|
410
|
+
right: linkRight,
|
|
411
|
+
}),
|
|
412
|
+
}),
|
|
413
|
+
object({
|
|
414
|
+
type: { const: "ixo.iid.delete-linked-claim" },
|
|
415
|
+
did: ixoDid,
|
|
416
|
+
claimId: removeId,
|
|
417
|
+
}),
|
|
418
|
+
object({
|
|
419
|
+
type: { const: "ixo.iid.add-linked-entity" },
|
|
420
|
+
did: ixoDid,
|
|
421
|
+
entity: object({
|
|
422
|
+
id: linkedEntityId,
|
|
423
|
+
type: iidType,
|
|
424
|
+
relationship: { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9_-]{0,63}$" },
|
|
425
|
+
service: optional({
|
|
426
|
+
...string(0, 233),
|
|
427
|
+
pattern:
|
|
428
|
+
"^(?:(?:(?:\\{id\\}|did:ixo:[A-Za-z0-9._:%-]{1,160})#)?[A-Za-z0-9._~:-]{1,64})?$",
|
|
429
|
+
}),
|
|
430
|
+
}),
|
|
431
|
+
}),
|
|
432
|
+
object({
|
|
433
|
+
type: { const: "ixo.iid.delete-linked-entity" },
|
|
434
|
+
did: ixoDid,
|
|
435
|
+
entityId: removeId,
|
|
436
|
+
}),
|
|
437
|
+
object({
|
|
438
|
+
type: { const: "ixo.iid.add-context" },
|
|
439
|
+
did: ixoDid,
|
|
440
|
+
context: object({ key: contextKey, val: ixoDidOrHttps }),
|
|
441
|
+
}),
|
|
442
|
+
object({
|
|
443
|
+
type: { const: "ixo.iid.delete-context" },
|
|
444
|
+
did: ixoDid,
|
|
445
|
+
key: removeId,
|
|
446
|
+
}),
|
|
107
447
|
],
|
|
108
448
|
};
|
|
109
449
|
const registry = {
|
|
@@ -197,6 +537,22 @@ const registry = {
|
|
|
197
537
|
memo: string(0, 256),
|
|
198
538
|
messages: { type: "array", items: chainTxMessage, minItems: 1, maxItems: 8 },
|
|
199
539
|
},
|
|
540
|
+
"ixo.bid.submit.v1": {
|
|
541
|
+
network,
|
|
542
|
+
collectionId: submissionCollectionId,
|
|
543
|
+
title: string(1, 120),
|
|
544
|
+
role: { const: "SA" },
|
|
545
|
+
summary,
|
|
546
|
+
data: string(2, 60000),
|
|
547
|
+
},
|
|
548
|
+
"ixo.claim.submit.v1": {
|
|
549
|
+
network,
|
|
550
|
+
collectionId: submissionCollectionId,
|
|
551
|
+
title: string(1, 120),
|
|
552
|
+
summary,
|
|
553
|
+
data: string(2, 60000),
|
|
554
|
+
evidence: { type: "array", items: evidence, maxItems: 30 },
|
|
555
|
+
},
|
|
200
556
|
};
|
|
201
557
|
export const operationKinds = Object.freeze(Object.keys(registry));
|
|
202
558
|
export const operationJsonSchema = Object.freeze({
|