@ixo/action-protocol 0.7.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 +269 -0
- package/README.md +18 -3
- package/package.json +1 -1
- package/src/index.d.ts +559 -3
- package/src/index.js +816 -29
- package/src/operation-schema.js +311 -0
package/src/operation-schema.js
CHANGED
|
@@ -92,6 +92,95 @@ const chainText = (min, max) => ({
|
|
|
92
92
|
...string(min, max),
|
|
93
93
|
pattern: min > 0 ? "^[A-Za-z0-9:._/-]+$" : "^[A-Za-z0-9:._/-]*$",
|
|
94
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
|
+
};
|
|
95
184
|
const chainTxMessage = {
|
|
96
185
|
anyOf: [
|
|
97
186
|
object({
|
|
@@ -133,6 +222,228 @@ const chainTxMessage = {
|
|
|
133
222
|
maxItems: 32,
|
|
134
223
|
},
|
|
135
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
|
+
}),
|
|
136
447
|
],
|
|
137
448
|
};
|
|
138
449
|
const registry = {
|