@unicitylabs/sphere-sdk 0.17.6 → 0.18.0-dev.2
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/dist/connect/chunks/{chunk-T4DZCXWS.js → chunk-FGQ6CKKK.js} +2 -2
- package/dist/connect/chunks/{chunk-T4DZCXWS.js.map → chunk-FGQ6CKKK.js.map} +1 -1
- package/dist/connect/chunks/{chunk-BRYRG2TL.js → chunk-JYBI36GK.js} +2 -2
- package/dist/connect/chunks/{chunk-MA32MTCD.js → chunk-OAAY2JEA.js} +2 -2
- package/dist/connect/index.cjs +1 -1
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +3 -3
- package/dist/connect/internal/host.js +2 -2
- package/dist/core/index.cjs +304 -47
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +392 -320
- package/dist/core/index.d.ts +392 -320
- package/dist/core/index.js +304 -47
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +2 -2
- package/dist/impl/wallet-api-v2/index.cjs +2 -0
- package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.d.cts +30 -30
- package/dist/impl/wallet-api-v2/index.d.ts +30 -30
- package/dist/impl/wallet-api-v2/index.js +2 -0
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +304 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +279 -154
- package/dist/index.d.ts +279 -154
- package/dist/index.js +304 -47
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +249 -28
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +252 -166
- package/dist/modules/payments-v2/index.d.ts +252 -166
- package/dist/modules/payments-v2/index.js +249 -28
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +455 -427
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.d.cts +26 -1
- package/dist/token-engine/index.d.ts +26 -1
- package/dist/token-engine/index.js +455 -427
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +1 -1
- /package/dist/connect/chunks/{chunk-BRYRG2TL.js.map → chunk-JYBI36GK.js.map} +0 -0
- /package/dist/connect/chunks/{chunk-MA32MTCD.js.map → chunk-OAAY2JEA.js.map} +0 -0
|
@@ -340,6 +340,350 @@ function decodeSpherePaymentData(bytes) {
|
|
|
340
340
|
return Promise.resolve(SpherePaymentData.fromCBOR(bytes));
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
// node_modules/@noble/hashes/utils.js
|
|
344
|
+
function isBytes(a) {
|
|
345
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
346
|
+
}
|
|
347
|
+
function anumber(n, title = "") {
|
|
348
|
+
if (typeof n !== "number") {
|
|
349
|
+
const prefix = title && `"${title}" `;
|
|
350
|
+
throw new TypeError(`${prefix}expected number, got ${typeof n}`);
|
|
351
|
+
}
|
|
352
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
353
|
+
const prefix = title && `"${title}" `;
|
|
354
|
+
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function abytes(value, length, title = "") {
|
|
358
|
+
const bytes = isBytes(value);
|
|
359
|
+
const len = value?.length;
|
|
360
|
+
const needsLen = length !== void 0;
|
|
361
|
+
if (!bytes || needsLen && len !== length) {
|
|
362
|
+
const prefix = title && `"${title}" `;
|
|
363
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
364
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
365
|
+
const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
366
|
+
if (!bytes)
|
|
367
|
+
throw new TypeError(message);
|
|
368
|
+
throw new RangeError(message);
|
|
369
|
+
}
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
function ahash(h) {
|
|
373
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
374
|
+
throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
375
|
+
anumber(h.outputLen);
|
|
376
|
+
anumber(h.blockLen);
|
|
377
|
+
if (h.outputLen < 1)
|
|
378
|
+
throw new Error('"outputLen" must be >= 1');
|
|
379
|
+
if (h.blockLen < 1)
|
|
380
|
+
throw new Error('"blockLen" must be >= 1');
|
|
381
|
+
}
|
|
382
|
+
function aexists(instance, checkFinished = true) {
|
|
383
|
+
if (instance.destroyed)
|
|
384
|
+
throw new Error("Hash instance has been destroyed");
|
|
385
|
+
if (checkFinished && instance.finished)
|
|
386
|
+
throw new Error("Hash#digest() has already been called");
|
|
387
|
+
}
|
|
388
|
+
function aoutput(out, instance) {
|
|
389
|
+
abytes(out, void 0, "digestInto() output");
|
|
390
|
+
const min = instance.outputLen;
|
|
391
|
+
if (out.length < min) {
|
|
392
|
+
throw new RangeError('"digestInto() output" expected to be of length >=' + min);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function clean(...arrays) {
|
|
396
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
397
|
+
arrays[i].fill(0);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function createView(arr) {
|
|
401
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
402
|
+
}
|
|
403
|
+
function rotr(word, shift) {
|
|
404
|
+
return word << 32 - shift | word >>> shift;
|
|
405
|
+
}
|
|
406
|
+
function createHasher(hashCons, info = {}) {
|
|
407
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
408
|
+
const tmp = hashCons(void 0);
|
|
409
|
+
hashC.outputLen = tmp.outputLen;
|
|
410
|
+
hashC.blockLen = tmp.blockLen;
|
|
411
|
+
hashC.canXOF = tmp.canXOF;
|
|
412
|
+
hashC.create = (opts) => hashCons(opts);
|
|
413
|
+
Object.assign(hashC, info);
|
|
414
|
+
return Object.freeze(hashC);
|
|
415
|
+
}
|
|
416
|
+
var oidNist = (suffix) => ({
|
|
417
|
+
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
418
|
+
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
419
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// node_modules/@noble/hashes/_md.js
|
|
423
|
+
function Chi(a, b, c) {
|
|
424
|
+
return a & b ^ ~a & c;
|
|
425
|
+
}
|
|
426
|
+
function Maj(a, b, c) {
|
|
427
|
+
return a & b ^ a & c ^ b & c;
|
|
428
|
+
}
|
|
429
|
+
var HashMD = class {
|
|
430
|
+
blockLen;
|
|
431
|
+
outputLen;
|
|
432
|
+
canXOF = false;
|
|
433
|
+
padOffset;
|
|
434
|
+
isLE;
|
|
435
|
+
// For partial updates less than block size
|
|
436
|
+
buffer;
|
|
437
|
+
view;
|
|
438
|
+
finished = false;
|
|
439
|
+
length = 0;
|
|
440
|
+
pos = 0;
|
|
441
|
+
destroyed = false;
|
|
442
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
443
|
+
this.blockLen = blockLen;
|
|
444
|
+
this.outputLen = outputLen;
|
|
445
|
+
this.padOffset = padOffset;
|
|
446
|
+
this.isLE = isLE;
|
|
447
|
+
this.buffer = new Uint8Array(blockLen);
|
|
448
|
+
this.view = createView(this.buffer);
|
|
449
|
+
}
|
|
450
|
+
update(data) {
|
|
451
|
+
aexists(this);
|
|
452
|
+
abytes(data);
|
|
453
|
+
const { view, buffer, blockLen } = this;
|
|
454
|
+
const len = data.length;
|
|
455
|
+
for (let pos = 0; pos < len; ) {
|
|
456
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
457
|
+
if (take === blockLen) {
|
|
458
|
+
const dataView = createView(data);
|
|
459
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
460
|
+
this.process(dataView, pos);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
464
|
+
this.pos += take;
|
|
465
|
+
pos += take;
|
|
466
|
+
if (this.pos === blockLen) {
|
|
467
|
+
this.process(view, 0);
|
|
468
|
+
this.pos = 0;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
this.length += data.length;
|
|
472
|
+
this.roundClean();
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
digestInto(out) {
|
|
476
|
+
aexists(this);
|
|
477
|
+
aoutput(out, this);
|
|
478
|
+
this.finished = true;
|
|
479
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
480
|
+
let { pos } = this;
|
|
481
|
+
buffer[pos++] = 128;
|
|
482
|
+
clean(this.buffer.subarray(pos));
|
|
483
|
+
if (this.padOffset > blockLen - pos) {
|
|
484
|
+
this.process(view, 0);
|
|
485
|
+
pos = 0;
|
|
486
|
+
}
|
|
487
|
+
for (let i = pos; i < blockLen; i++)
|
|
488
|
+
buffer[i] = 0;
|
|
489
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
490
|
+
this.process(view, 0);
|
|
491
|
+
const oview = createView(out);
|
|
492
|
+
const len = this.outputLen;
|
|
493
|
+
if (len % 4)
|
|
494
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
495
|
+
const outLen = len / 4;
|
|
496
|
+
const state = this.get();
|
|
497
|
+
if (outLen > state.length)
|
|
498
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
499
|
+
for (let i = 0; i < outLen; i++)
|
|
500
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
501
|
+
}
|
|
502
|
+
digest() {
|
|
503
|
+
const { buffer, outputLen } = this;
|
|
504
|
+
this.digestInto(buffer);
|
|
505
|
+
const res = buffer.slice(0, outputLen);
|
|
506
|
+
this.destroy();
|
|
507
|
+
return res;
|
|
508
|
+
}
|
|
509
|
+
_cloneInto(to) {
|
|
510
|
+
to ||= new this.constructor();
|
|
511
|
+
to.set(...this.get());
|
|
512
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
513
|
+
to.destroyed = destroyed;
|
|
514
|
+
to.finished = finished;
|
|
515
|
+
to.length = length;
|
|
516
|
+
to.pos = pos;
|
|
517
|
+
if (length % blockLen)
|
|
518
|
+
to.buffer.set(buffer);
|
|
519
|
+
return to;
|
|
520
|
+
}
|
|
521
|
+
clone() {
|
|
522
|
+
return this._cloneInto();
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
526
|
+
1779033703,
|
|
527
|
+
3144134277,
|
|
528
|
+
1013904242,
|
|
529
|
+
2773480762,
|
|
530
|
+
1359893119,
|
|
531
|
+
2600822924,
|
|
532
|
+
528734635,
|
|
533
|
+
1541459225
|
|
534
|
+
]);
|
|
535
|
+
|
|
536
|
+
// node_modules/@noble/hashes/sha2.js
|
|
537
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
538
|
+
1116352408,
|
|
539
|
+
1899447441,
|
|
540
|
+
3049323471,
|
|
541
|
+
3921009573,
|
|
542
|
+
961987163,
|
|
543
|
+
1508970993,
|
|
544
|
+
2453635748,
|
|
545
|
+
2870763221,
|
|
546
|
+
3624381080,
|
|
547
|
+
310598401,
|
|
548
|
+
607225278,
|
|
549
|
+
1426881987,
|
|
550
|
+
1925078388,
|
|
551
|
+
2162078206,
|
|
552
|
+
2614888103,
|
|
553
|
+
3248222580,
|
|
554
|
+
3835390401,
|
|
555
|
+
4022224774,
|
|
556
|
+
264347078,
|
|
557
|
+
604807628,
|
|
558
|
+
770255983,
|
|
559
|
+
1249150122,
|
|
560
|
+
1555081692,
|
|
561
|
+
1996064986,
|
|
562
|
+
2554220882,
|
|
563
|
+
2821834349,
|
|
564
|
+
2952996808,
|
|
565
|
+
3210313671,
|
|
566
|
+
3336571891,
|
|
567
|
+
3584528711,
|
|
568
|
+
113926993,
|
|
569
|
+
338241895,
|
|
570
|
+
666307205,
|
|
571
|
+
773529912,
|
|
572
|
+
1294757372,
|
|
573
|
+
1396182291,
|
|
574
|
+
1695183700,
|
|
575
|
+
1986661051,
|
|
576
|
+
2177026350,
|
|
577
|
+
2456956037,
|
|
578
|
+
2730485921,
|
|
579
|
+
2820302411,
|
|
580
|
+
3259730800,
|
|
581
|
+
3345764771,
|
|
582
|
+
3516065817,
|
|
583
|
+
3600352804,
|
|
584
|
+
4094571909,
|
|
585
|
+
275423344,
|
|
586
|
+
430227734,
|
|
587
|
+
506948616,
|
|
588
|
+
659060556,
|
|
589
|
+
883997877,
|
|
590
|
+
958139571,
|
|
591
|
+
1322822218,
|
|
592
|
+
1537002063,
|
|
593
|
+
1747873779,
|
|
594
|
+
1955562222,
|
|
595
|
+
2024104815,
|
|
596
|
+
2227730452,
|
|
597
|
+
2361852424,
|
|
598
|
+
2428436474,
|
|
599
|
+
2756734187,
|
|
600
|
+
3204031479,
|
|
601
|
+
3329325298
|
|
602
|
+
]);
|
|
603
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
604
|
+
var SHA2_32B = class extends HashMD {
|
|
605
|
+
constructor(outputLen) {
|
|
606
|
+
super(64, outputLen, 8, false);
|
|
607
|
+
}
|
|
608
|
+
get() {
|
|
609
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
610
|
+
return [A, B, C, D, E, F, G, H];
|
|
611
|
+
}
|
|
612
|
+
// prettier-ignore
|
|
613
|
+
set(A, B, C, D, E, F, G, H) {
|
|
614
|
+
this.A = A | 0;
|
|
615
|
+
this.B = B | 0;
|
|
616
|
+
this.C = C | 0;
|
|
617
|
+
this.D = D | 0;
|
|
618
|
+
this.E = E | 0;
|
|
619
|
+
this.F = F | 0;
|
|
620
|
+
this.G = G | 0;
|
|
621
|
+
this.H = H | 0;
|
|
622
|
+
}
|
|
623
|
+
process(view, offset) {
|
|
624
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
625
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
626
|
+
for (let i = 16; i < 64; i++) {
|
|
627
|
+
const W15 = SHA256_W[i - 15];
|
|
628
|
+
const W2 = SHA256_W[i - 2];
|
|
629
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
630
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
631
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
632
|
+
}
|
|
633
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
634
|
+
for (let i = 0; i < 64; i++) {
|
|
635
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
636
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
637
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
638
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
639
|
+
H = G;
|
|
640
|
+
G = F;
|
|
641
|
+
F = E;
|
|
642
|
+
E = D + T1 | 0;
|
|
643
|
+
D = C;
|
|
644
|
+
C = B;
|
|
645
|
+
B = A;
|
|
646
|
+
A = T1 + T2 | 0;
|
|
647
|
+
}
|
|
648
|
+
A = A + this.A | 0;
|
|
649
|
+
B = B + this.B | 0;
|
|
650
|
+
C = C + this.C | 0;
|
|
651
|
+
D = D + this.D | 0;
|
|
652
|
+
E = E + this.E | 0;
|
|
653
|
+
F = F + this.F | 0;
|
|
654
|
+
G = G + this.G | 0;
|
|
655
|
+
H = H + this.H | 0;
|
|
656
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
657
|
+
}
|
|
658
|
+
roundClean() {
|
|
659
|
+
clean(SHA256_W);
|
|
660
|
+
}
|
|
661
|
+
destroy() {
|
|
662
|
+
this.destroyed = true;
|
|
663
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
664
|
+
clean(this.buffer);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
var _SHA256 = class extends SHA2_32B {
|
|
668
|
+
// We cannot use array here since array allows indexing by variable
|
|
669
|
+
// which means optimizer/compiler cannot use registers.
|
|
670
|
+
A = SHA256_IV[0] | 0;
|
|
671
|
+
B = SHA256_IV[1] | 0;
|
|
672
|
+
C = SHA256_IV[2] | 0;
|
|
673
|
+
D = SHA256_IV[3] | 0;
|
|
674
|
+
E = SHA256_IV[4] | 0;
|
|
675
|
+
F = SHA256_IV[5] | 0;
|
|
676
|
+
G = SHA256_IV[6] | 0;
|
|
677
|
+
H = SHA256_IV[7] | 0;
|
|
678
|
+
constructor() {
|
|
679
|
+
super(32);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
var sha2562 = /* @__PURE__ */ createHasher(
|
|
683
|
+
() => new _SHA256(),
|
|
684
|
+
/* @__PURE__ */ oidNist(1)
|
|
685
|
+
);
|
|
686
|
+
|
|
343
687
|
// token-engine/proof-wait.ts
|
|
344
688
|
var DEFAULT_PROOF_TIMEOUT_MS = 1e4;
|
|
345
689
|
function resolveProofTimeoutMs(configured) {
|
|
@@ -502,85 +846,6 @@ async function deriveDeliveryKeys(blobBytes) {
|
|
|
502
846
|
return { tokenId: import_HexConverter.HexConverter.encode(token.id.bytes), stateHash };
|
|
503
847
|
}
|
|
504
848
|
|
|
505
|
-
// node_modules/@noble/hashes/utils.js
|
|
506
|
-
function isBytes(a) {
|
|
507
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
508
|
-
}
|
|
509
|
-
function anumber(n, title = "") {
|
|
510
|
-
if (typeof n !== "number") {
|
|
511
|
-
const prefix = title && `"${title}" `;
|
|
512
|
-
throw new TypeError(`${prefix}expected number, got ${typeof n}`);
|
|
513
|
-
}
|
|
514
|
-
if (!Number.isSafeInteger(n) || n < 0) {
|
|
515
|
-
const prefix = title && `"${title}" `;
|
|
516
|
-
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
function abytes(value, length, title = "") {
|
|
520
|
-
const bytes = isBytes(value);
|
|
521
|
-
const len = value?.length;
|
|
522
|
-
const needsLen = length !== void 0;
|
|
523
|
-
if (!bytes || needsLen && len !== length) {
|
|
524
|
-
const prefix = title && `"${title}" `;
|
|
525
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
526
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
527
|
-
const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
528
|
-
if (!bytes)
|
|
529
|
-
throw new TypeError(message);
|
|
530
|
-
throw new RangeError(message);
|
|
531
|
-
}
|
|
532
|
-
return value;
|
|
533
|
-
}
|
|
534
|
-
function ahash(h) {
|
|
535
|
-
if (typeof h !== "function" || typeof h.create !== "function")
|
|
536
|
-
throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
537
|
-
anumber(h.outputLen);
|
|
538
|
-
anumber(h.blockLen);
|
|
539
|
-
if (h.outputLen < 1)
|
|
540
|
-
throw new Error('"outputLen" must be >= 1');
|
|
541
|
-
if (h.blockLen < 1)
|
|
542
|
-
throw new Error('"blockLen" must be >= 1');
|
|
543
|
-
}
|
|
544
|
-
function aexists(instance, checkFinished = true) {
|
|
545
|
-
if (instance.destroyed)
|
|
546
|
-
throw new Error("Hash instance has been destroyed");
|
|
547
|
-
if (checkFinished && instance.finished)
|
|
548
|
-
throw new Error("Hash#digest() has already been called");
|
|
549
|
-
}
|
|
550
|
-
function aoutput(out, instance) {
|
|
551
|
-
abytes(out, void 0, "digestInto() output");
|
|
552
|
-
const min = instance.outputLen;
|
|
553
|
-
if (out.length < min) {
|
|
554
|
-
throw new RangeError('"digestInto() output" expected to be of length >=' + min);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
function clean(...arrays) {
|
|
558
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
559
|
-
arrays[i].fill(0);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function createView(arr) {
|
|
563
|
-
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
564
|
-
}
|
|
565
|
-
function rotr(word, shift) {
|
|
566
|
-
return word << 32 - shift | word >>> shift;
|
|
567
|
-
}
|
|
568
|
-
function createHasher(hashCons, info = {}) {
|
|
569
|
-
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
570
|
-
const tmp = hashCons(void 0);
|
|
571
|
-
hashC.outputLen = tmp.outputLen;
|
|
572
|
-
hashC.blockLen = tmp.blockLen;
|
|
573
|
-
hashC.canXOF = tmp.canXOF;
|
|
574
|
-
hashC.create = (opts) => hashCons(opts);
|
|
575
|
-
Object.assign(hashC, info);
|
|
576
|
-
return Object.freeze(hashC);
|
|
577
|
-
}
|
|
578
|
-
var oidNist = (suffix) => ({
|
|
579
|
-
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
580
|
-
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
581
|
-
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
582
|
-
});
|
|
583
|
-
|
|
584
849
|
// node_modules/@noble/hashes/hmac.js
|
|
585
850
|
var _HMAC = class {
|
|
586
851
|
oHash;
|
|
@@ -616,351 +881,86 @@ var _HMAC = class {
|
|
|
616
881
|
return this;
|
|
617
882
|
}
|
|
618
883
|
digestInto(out) {
|
|
619
|
-
aexists(this);
|
|
620
|
-
aoutput(out, this);
|
|
621
|
-
this.finished = true;
|
|
622
|
-
const buf = out.subarray(0, this.outputLen);
|
|
623
|
-
this.iHash.digestInto(buf);
|
|
624
|
-
this.oHash.update(buf);
|
|
625
|
-
this.oHash.digestInto(buf);
|
|
626
|
-
this.destroy();
|
|
627
|
-
}
|
|
628
|
-
digest() {
|
|
629
|
-
const out = new Uint8Array(this.oHash.outputLen);
|
|
630
|
-
this.digestInto(out);
|
|
631
|
-
return out;
|
|
632
|
-
}
|
|
633
|
-
_cloneInto(to) {
|
|
634
|
-
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
635
|
-
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
636
|
-
to = to;
|
|
637
|
-
to.finished = finished;
|
|
638
|
-
to.destroyed = destroyed;
|
|
639
|
-
to.blockLen = blockLen;
|
|
640
|
-
to.outputLen = outputLen;
|
|
641
|
-
to.oHash = oHash._cloneInto(to.oHash);
|
|
642
|
-
to.iHash = iHash._cloneInto(to.iHash);
|
|
643
|
-
return to;
|
|
644
|
-
}
|
|
645
|
-
clone() {
|
|
646
|
-
return this._cloneInto();
|
|
647
|
-
}
|
|
648
|
-
destroy() {
|
|
649
|
-
this.destroyed = true;
|
|
650
|
-
this.oHash.destroy();
|
|
651
|
-
this.iHash.destroy();
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
var hmac = /* @__PURE__ */ (() => {
|
|
655
|
-
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
656
|
-
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
657
|
-
return hmac_;
|
|
658
|
-
})();
|
|
659
|
-
|
|
660
|
-
// node_modules/@noble/hashes/hkdf.js
|
|
661
|
-
function extract(hash, ikm, salt) {
|
|
662
|
-
ahash(hash);
|
|
663
|
-
if (salt === void 0)
|
|
664
|
-
salt = new Uint8Array(hash.outputLen);
|
|
665
|
-
return hmac(hash, salt, ikm);
|
|
666
|
-
}
|
|
667
|
-
var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
668
|
-
var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
669
|
-
function expand(hash, prk, info, length = 32) {
|
|
670
|
-
ahash(hash);
|
|
671
|
-
anumber(length, "length");
|
|
672
|
-
abytes(prk, void 0, "prk");
|
|
673
|
-
const olen = hash.outputLen;
|
|
674
|
-
if (prk.length < olen)
|
|
675
|
-
throw new Error('"prk" must be at least HashLen octets');
|
|
676
|
-
if (length > 255 * olen)
|
|
677
|
-
throw new Error("Length must be <= 255*HashLen");
|
|
678
|
-
const blocks = Math.ceil(length / olen);
|
|
679
|
-
if (info === void 0)
|
|
680
|
-
info = EMPTY_BUFFER;
|
|
681
|
-
else
|
|
682
|
-
abytes(info, void 0, "info");
|
|
683
|
-
const okm = new Uint8Array(blocks * olen);
|
|
684
|
-
const HMAC = hmac.create(hash, prk);
|
|
685
|
-
const HMACTmp = HMAC._cloneInto();
|
|
686
|
-
const T = new Uint8Array(HMAC.outputLen);
|
|
687
|
-
for (let counter = 0; counter < blocks; counter++) {
|
|
688
|
-
HKDF_COUNTER[0] = counter + 1;
|
|
689
|
-
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T).update(info).update(HKDF_COUNTER).digestInto(T);
|
|
690
|
-
okm.set(T, olen * counter);
|
|
691
|
-
HMAC._cloneInto(HMACTmp);
|
|
692
|
-
}
|
|
693
|
-
HMAC.destroy();
|
|
694
|
-
HMACTmp.destroy();
|
|
695
|
-
clean(T, HKDF_COUNTER);
|
|
696
|
-
return okm.slice(0, length);
|
|
697
|
-
}
|
|
698
|
-
var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
699
|
-
|
|
700
|
-
// node_modules/@noble/hashes/_md.js
|
|
701
|
-
function Chi(a, b, c) {
|
|
702
|
-
return a & b ^ ~a & c;
|
|
703
|
-
}
|
|
704
|
-
function Maj(a, b, c) {
|
|
705
|
-
return a & b ^ a & c ^ b & c;
|
|
706
|
-
}
|
|
707
|
-
var HashMD = class {
|
|
708
|
-
blockLen;
|
|
709
|
-
outputLen;
|
|
710
|
-
canXOF = false;
|
|
711
|
-
padOffset;
|
|
712
|
-
isLE;
|
|
713
|
-
// For partial updates less than block size
|
|
714
|
-
buffer;
|
|
715
|
-
view;
|
|
716
|
-
finished = false;
|
|
717
|
-
length = 0;
|
|
718
|
-
pos = 0;
|
|
719
|
-
destroyed = false;
|
|
720
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
721
|
-
this.blockLen = blockLen;
|
|
722
|
-
this.outputLen = outputLen;
|
|
723
|
-
this.padOffset = padOffset;
|
|
724
|
-
this.isLE = isLE;
|
|
725
|
-
this.buffer = new Uint8Array(blockLen);
|
|
726
|
-
this.view = createView(this.buffer);
|
|
727
|
-
}
|
|
728
|
-
update(data) {
|
|
729
|
-
aexists(this);
|
|
730
|
-
abytes(data);
|
|
731
|
-
const { view, buffer, blockLen } = this;
|
|
732
|
-
const len = data.length;
|
|
733
|
-
for (let pos = 0; pos < len; ) {
|
|
734
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
735
|
-
if (take === blockLen) {
|
|
736
|
-
const dataView = createView(data);
|
|
737
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
738
|
-
this.process(dataView, pos);
|
|
739
|
-
continue;
|
|
740
|
-
}
|
|
741
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
742
|
-
this.pos += take;
|
|
743
|
-
pos += take;
|
|
744
|
-
if (this.pos === blockLen) {
|
|
745
|
-
this.process(view, 0);
|
|
746
|
-
this.pos = 0;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
this.length += data.length;
|
|
750
|
-
this.roundClean();
|
|
751
|
-
return this;
|
|
752
|
-
}
|
|
753
|
-
digestInto(out) {
|
|
754
|
-
aexists(this);
|
|
755
|
-
aoutput(out, this);
|
|
756
|
-
this.finished = true;
|
|
757
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
758
|
-
let { pos } = this;
|
|
759
|
-
buffer[pos++] = 128;
|
|
760
|
-
clean(this.buffer.subarray(pos));
|
|
761
|
-
if (this.padOffset > blockLen - pos) {
|
|
762
|
-
this.process(view, 0);
|
|
763
|
-
pos = 0;
|
|
764
|
-
}
|
|
765
|
-
for (let i = pos; i < blockLen; i++)
|
|
766
|
-
buffer[i] = 0;
|
|
767
|
-
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
768
|
-
this.process(view, 0);
|
|
769
|
-
const oview = createView(out);
|
|
770
|
-
const len = this.outputLen;
|
|
771
|
-
if (len % 4)
|
|
772
|
-
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
773
|
-
const outLen = len / 4;
|
|
774
|
-
const state = this.get();
|
|
775
|
-
if (outLen > state.length)
|
|
776
|
-
throw new Error("_sha2: outputLen bigger than state");
|
|
777
|
-
for (let i = 0; i < outLen; i++)
|
|
778
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
884
|
+
aexists(this);
|
|
885
|
+
aoutput(out, this);
|
|
886
|
+
this.finished = true;
|
|
887
|
+
const buf = out.subarray(0, this.outputLen);
|
|
888
|
+
this.iHash.digestInto(buf);
|
|
889
|
+
this.oHash.update(buf);
|
|
890
|
+
this.oHash.digestInto(buf);
|
|
891
|
+
this.destroy();
|
|
779
892
|
}
|
|
780
893
|
digest() {
|
|
781
|
-
const
|
|
782
|
-
this.digestInto(
|
|
783
|
-
|
|
784
|
-
this.destroy();
|
|
785
|
-
return res;
|
|
894
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
895
|
+
this.digestInto(out);
|
|
896
|
+
return out;
|
|
786
897
|
}
|
|
787
898
|
_cloneInto(to) {
|
|
788
|
-
to ||=
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
to.destroyed = destroyed;
|
|
899
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
900
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
901
|
+
to = to;
|
|
792
902
|
to.finished = finished;
|
|
793
|
-
to.
|
|
794
|
-
to.
|
|
795
|
-
|
|
796
|
-
|
|
903
|
+
to.destroyed = destroyed;
|
|
904
|
+
to.blockLen = blockLen;
|
|
905
|
+
to.outputLen = outputLen;
|
|
906
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
907
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
797
908
|
return to;
|
|
798
909
|
}
|
|
799
910
|
clone() {
|
|
800
911
|
return this._cloneInto();
|
|
801
912
|
}
|
|
802
|
-
};
|
|
803
|
-
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
804
|
-
1779033703,
|
|
805
|
-
3144134277,
|
|
806
|
-
1013904242,
|
|
807
|
-
2773480762,
|
|
808
|
-
1359893119,
|
|
809
|
-
2600822924,
|
|
810
|
-
528734635,
|
|
811
|
-
1541459225
|
|
812
|
-
]);
|
|
813
|
-
|
|
814
|
-
// node_modules/@noble/hashes/sha2.js
|
|
815
|
-
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
816
|
-
1116352408,
|
|
817
|
-
1899447441,
|
|
818
|
-
3049323471,
|
|
819
|
-
3921009573,
|
|
820
|
-
961987163,
|
|
821
|
-
1508970993,
|
|
822
|
-
2453635748,
|
|
823
|
-
2870763221,
|
|
824
|
-
3624381080,
|
|
825
|
-
310598401,
|
|
826
|
-
607225278,
|
|
827
|
-
1426881987,
|
|
828
|
-
1925078388,
|
|
829
|
-
2162078206,
|
|
830
|
-
2614888103,
|
|
831
|
-
3248222580,
|
|
832
|
-
3835390401,
|
|
833
|
-
4022224774,
|
|
834
|
-
264347078,
|
|
835
|
-
604807628,
|
|
836
|
-
770255983,
|
|
837
|
-
1249150122,
|
|
838
|
-
1555081692,
|
|
839
|
-
1996064986,
|
|
840
|
-
2554220882,
|
|
841
|
-
2821834349,
|
|
842
|
-
2952996808,
|
|
843
|
-
3210313671,
|
|
844
|
-
3336571891,
|
|
845
|
-
3584528711,
|
|
846
|
-
113926993,
|
|
847
|
-
338241895,
|
|
848
|
-
666307205,
|
|
849
|
-
773529912,
|
|
850
|
-
1294757372,
|
|
851
|
-
1396182291,
|
|
852
|
-
1695183700,
|
|
853
|
-
1986661051,
|
|
854
|
-
2177026350,
|
|
855
|
-
2456956037,
|
|
856
|
-
2730485921,
|
|
857
|
-
2820302411,
|
|
858
|
-
3259730800,
|
|
859
|
-
3345764771,
|
|
860
|
-
3516065817,
|
|
861
|
-
3600352804,
|
|
862
|
-
4094571909,
|
|
863
|
-
275423344,
|
|
864
|
-
430227734,
|
|
865
|
-
506948616,
|
|
866
|
-
659060556,
|
|
867
|
-
883997877,
|
|
868
|
-
958139571,
|
|
869
|
-
1322822218,
|
|
870
|
-
1537002063,
|
|
871
|
-
1747873779,
|
|
872
|
-
1955562222,
|
|
873
|
-
2024104815,
|
|
874
|
-
2227730452,
|
|
875
|
-
2361852424,
|
|
876
|
-
2428436474,
|
|
877
|
-
2756734187,
|
|
878
|
-
3204031479,
|
|
879
|
-
3329325298
|
|
880
|
-
]);
|
|
881
|
-
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
882
|
-
var SHA2_32B = class extends HashMD {
|
|
883
|
-
constructor(outputLen) {
|
|
884
|
-
super(64, outputLen, 8, false);
|
|
885
|
-
}
|
|
886
|
-
get() {
|
|
887
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
888
|
-
return [A, B, C, D, E, F, G, H];
|
|
889
|
-
}
|
|
890
|
-
// prettier-ignore
|
|
891
|
-
set(A, B, C, D, E, F, G, H) {
|
|
892
|
-
this.A = A | 0;
|
|
893
|
-
this.B = B | 0;
|
|
894
|
-
this.C = C | 0;
|
|
895
|
-
this.D = D | 0;
|
|
896
|
-
this.E = E | 0;
|
|
897
|
-
this.F = F | 0;
|
|
898
|
-
this.G = G | 0;
|
|
899
|
-
this.H = H | 0;
|
|
900
|
-
}
|
|
901
|
-
process(view, offset) {
|
|
902
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
903
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
904
|
-
for (let i = 16; i < 64; i++) {
|
|
905
|
-
const W15 = SHA256_W[i - 15];
|
|
906
|
-
const W2 = SHA256_W[i - 2];
|
|
907
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
908
|
-
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
909
|
-
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
910
|
-
}
|
|
911
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
912
|
-
for (let i = 0; i < 64; i++) {
|
|
913
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
914
|
-
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
915
|
-
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
916
|
-
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
917
|
-
H = G;
|
|
918
|
-
G = F;
|
|
919
|
-
F = E;
|
|
920
|
-
E = D + T1 | 0;
|
|
921
|
-
D = C;
|
|
922
|
-
C = B;
|
|
923
|
-
B = A;
|
|
924
|
-
A = T1 + T2 | 0;
|
|
925
|
-
}
|
|
926
|
-
A = A + this.A | 0;
|
|
927
|
-
B = B + this.B | 0;
|
|
928
|
-
C = C + this.C | 0;
|
|
929
|
-
D = D + this.D | 0;
|
|
930
|
-
E = E + this.E | 0;
|
|
931
|
-
F = F + this.F | 0;
|
|
932
|
-
G = G + this.G | 0;
|
|
933
|
-
H = H + this.H | 0;
|
|
934
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
935
|
-
}
|
|
936
|
-
roundClean() {
|
|
937
|
-
clean(SHA256_W);
|
|
938
|
-
}
|
|
939
913
|
destroy() {
|
|
940
914
|
this.destroyed = true;
|
|
941
|
-
this.
|
|
942
|
-
|
|
915
|
+
this.oHash.destroy();
|
|
916
|
+
this.iHash.destroy();
|
|
943
917
|
}
|
|
944
918
|
};
|
|
945
|
-
var
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
919
|
+
var hmac = /* @__PURE__ */ (() => {
|
|
920
|
+
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
921
|
+
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
922
|
+
return hmac_;
|
|
923
|
+
})();
|
|
924
|
+
|
|
925
|
+
// node_modules/@noble/hashes/hkdf.js
|
|
926
|
+
function extract(hash, ikm, salt) {
|
|
927
|
+
ahash(hash);
|
|
928
|
+
if (salt === void 0)
|
|
929
|
+
salt = new Uint8Array(hash.outputLen);
|
|
930
|
+
return hmac(hash, salt, ikm);
|
|
931
|
+
}
|
|
932
|
+
var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
933
|
+
var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
934
|
+
function expand(hash, prk, info, length = 32) {
|
|
935
|
+
ahash(hash);
|
|
936
|
+
anumber(length, "length");
|
|
937
|
+
abytes(prk, void 0, "prk");
|
|
938
|
+
const olen = hash.outputLen;
|
|
939
|
+
if (prk.length < olen)
|
|
940
|
+
throw new Error('"prk" must be at least HashLen octets');
|
|
941
|
+
if (length > 255 * olen)
|
|
942
|
+
throw new Error("Length must be <= 255*HashLen");
|
|
943
|
+
const blocks = Math.ceil(length / olen);
|
|
944
|
+
if (info === void 0)
|
|
945
|
+
info = EMPTY_BUFFER;
|
|
946
|
+
else
|
|
947
|
+
abytes(info, void 0, "info");
|
|
948
|
+
const okm = new Uint8Array(blocks * olen);
|
|
949
|
+
const HMAC = hmac.create(hash, prk);
|
|
950
|
+
const HMACTmp = HMAC._cloneInto();
|
|
951
|
+
const T = new Uint8Array(HMAC.outputLen);
|
|
952
|
+
for (let counter = 0; counter < blocks; counter++) {
|
|
953
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
954
|
+
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T).update(info).update(HKDF_COUNTER).digestInto(T);
|
|
955
|
+
okm.set(T, olen * counter);
|
|
956
|
+
HMAC._cloneInto(HMACTmp);
|
|
958
957
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
(
|
|
962
|
-
|
|
963
|
-
|
|
958
|
+
HMAC.destroy();
|
|
959
|
+
HMACTmp.destroy();
|
|
960
|
+
clean(T, HKDF_COUNTER);
|
|
961
|
+
return okm.slice(0, length);
|
|
962
|
+
}
|
|
963
|
+
var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
964
964
|
|
|
965
965
|
// token-engine/realization.ts
|
|
966
966
|
var REALIZATION_HKDF_INFO_PREFIX = "sphere-realization-v1";
|
|
@@ -1474,6 +1474,19 @@ async function readTokenNft(token) {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
1476
|
|
|
1477
|
+
// token-engine/plugin-ops.ts
|
|
1478
|
+
function contextWithMintVerifiers(base, verifiers) {
|
|
1479
|
+
const registry = new import_MintJustificationVerifierService.MintJustificationVerifierService();
|
|
1480
|
+
for (const verifier of verifiers) registry.register(verifier);
|
|
1481
|
+
return new import_VerificationContext.VerificationContext(
|
|
1482
|
+
base.trustBase,
|
|
1483
|
+
base.predicateVerifier,
|
|
1484
|
+
base.unicityCertificateVerifier,
|
|
1485
|
+
registry,
|
|
1486
|
+
new import_TokenIssuanceVerifierService.TokenIssuanceVerifierService(false)
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1477
1490
|
// token-engine/split-checkpoint.ts
|
|
1478
1491
|
var CHECKPOINT_VERSION = 2;
|
|
1479
1492
|
var CHECKPOINT_SDK_VERSION = "@unicitylabs/state-transition-sdk@3.0.1";
|
|
@@ -1620,6 +1633,10 @@ var SphereTokenEngine = class {
|
|
|
1620
1633
|
const data = token.sdkToken.genesis.data;
|
|
1621
1634
|
return data ? new Uint8Array(data) : null;
|
|
1622
1635
|
}
|
|
1636
|
+
readTokenJustification(token) {
|
|
1637
|
+
const justification = token.sdkToken.genesis.justification;
|
|
1638
|
+
return justification ? new Uint8Array(justification) : null;
|
|
1639
|
+
}
|
|
1623
1640
|
readNft(token) {
|
|
1624
1641
|
return readTokenNft(token);
|
|
1625
1642
|
}
|
|
@@ -1651,7 +1668,7 @@ var SphereTokenEngine = class {
|
|
|
1651
1668
|
const recipient = import_SignaturePredicate.SignaturePredicate.create(params.recipientPubkey);
|
|
1652
1669
|
const tokenType = params.tokenType ? new import_TokenType.TokenType(params.tokenType) : import_TokenType.TokenType.generate();
|
|
1653
1670
|
const salt = params.salt ? import_TokenSalt.TokenSalt.fromBytes(params.salt) : import_TokenSalt.TokenSalt.generate();
|
|
1654
|
-
const mintTx = await import_MintTransaction.MintTransaction.create(this.deps.networkId, recipient, { data: params.data, tokenType, salt });
|
|
1671
|
+
const mintTx = await import_MintTransaction.MintTransaction.create(this.deps.networkId, recipient, { data: params.data, tokenType, salt, justification: params.justification ?? null });
|
|
1655
1672
|
const certificationData = await import_CertificationData.CertificationData.fromMintTransaction(mintTx);
|
|
1656
1673
|
const proof = await this.submitAndAwaitProof(
|
|
1657
1674
|
certificationData,
|
|
@@ -1661,34 +1678,30 @@ var SphereTokenEngine = class {
|
|
|
1661
1678
|
options
|
|
1662
1679
|
);
|
|
1663
1680
|
const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
|
|
1664
|
-
const
|
|
1665
|
-
return wrapToken(
|
|
1681
|
+
const verifiers = params.mintJustificationVerifiers;
|
|
1682
|
+
return wrapToken(await import_Token.Token.mint(certified, verifiers ? contextWithMintVerifiers(this.deps, verifiers) : this.deps.verificationContext));
|
|
1666
1683
|
}
|
|
1667
1684
|
buildNftMint(params) {
|
|
1668
1685
|
return planNftMint(this.deps, params);
|
|
1669
1686
|
}
|
|
1670
1687
|
async transfer(params, options) {
|
|
1671
1688
|
this.assertOwned(params.token);
|
|
1672
|
-
|
|
1673
|
-
|
|
1689
|
+
return this.spend(params.token, import_SignaturePredicate.SignaturePredicate.create(params.recipientPubkey), params.data ?? null, options, "Transfer certification failed");
|
|
1690
|
+
}
|
|
1691
|
+
async burn(params, options) {
|
|
1692
|
+
this.assertOwned(params.token);
|
|
1693
|
+
return this.spend(params.token, import_BurnPredicate.BurnPredicate.create(sha2562(params.reasonBytes)), params.reasonBytes, options, "Burn certification failed");
|
|
1694
|
+
}
|
|
1695
|
+
async spend(token, recipient, data, options, failLabel) {
|
|
1674
1696
|
const stateMask = import_StateMask.StateMask.fromBytes(
|
|
1675
|
-
deriveRealization(this.privateKeyHex,
|
|
1697
|
+
deriveRealization(this.privateKeyHex, this.resolveTransferId(options), this.resolveOpIndex(options), "stateMask")
|
|
1676
1698
|
);
|
|
1677
|
-
const transferTx = await import_TransferTransaction.TransferTransaction.create(
|
|
1678
|
-
data: params.data ?? null
|
|
1679
|
-
});
|
|
1699
|
+
const transferTx = await import_TransferTransaction.TransferTransaction.create(token.sdkToken, recipient, stateMask, { data });
|
|
1680
1700
|
const unlockScript = await import_SignaturePredicateUnlockScript.SignaturePredicateUnlockScript.create(transferTx, this.deps.signingService);
|
|
1681
1701
|
const certificationData = await import_CertificationData.CertificationData.fromTransaction(transferTx, unlockScript);
|
|
1682
|
-
const proof = await this.submitAndAwaitProof(
|
|
1683
|
-
certificationData,
|
|
1684
|
-
transferTx,
|
|
1685
|
-
"Transfer certification failed",
|
|
1686
|
-
"TRANSFER_FAILED",
|
|
1687
|
-
options
|
|
1688
|
-
);
|
|
1702
|
+
const proof = await this.submitAndAwaitProof(certificationData, transferTx, failLabel, "TRANSFER_FAILED", options);
|
|
1689
1703
|
const certified = await transferTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
|
|
1690
|
-
|
|
1691
|
-
return wrapToken(transferred);
|
|
1704
|
+
return wrapToken(await token.sdkToken.transfer(certified, this.deps.verificationContext));
|
|
1692
1705
|
}
|
|
1693
1706
|
async split(params, options) {
|
|
1694
1707
|
this.assertOwned(params.token);
|
|
@@ -2003,6 +2016,20 @@ var SphereTokenEngine = class {
|
|
|
2003
2016
|
|
|
2004
2017
|
// token-engine/factory.ts
|
|
2005
2018
|
var DEFAULT_VERIFICATION_POOL_SIZE = 4;
|
|
2019
|
+
function registerPluginVerifiers(registry, plugins) {
|
|
2020
|
+
for (const plugin of plugins ?? []) {
|
|
2021
|
+
for (const verifier of plugin.mintJustificationVerifiers ?? []) {
|
|
2022
|
+
try {
|
|
2023
|
+
registry.register(verifier);
|
|
2024
|
+
} catch (err) {
|
|
2025
|
+
throw new SphereError(
|
|
2026
|
+
`Token plugin '${plugin.id}' registers mint-reason tag ${verifier.tag} twice or over another plugin's: ` + (err instanceof Error ? err.message : String(err)),
|
|
2027
|
+
"INVALID_CONFIG"
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2006
2033
|
function disposedError() {
|
|
2007
2034
|
return new SphereError(
|
|
2008
2035
|
"Verification worker pool disposed \u2014 the in-flight verification was cancelled",
|
|
@@ -2084,6 +2111,7 @@ async function createSphereTokenEngine(config) {
|
|
|
2084
2111
|
mintJustificationVerifier.register(
|
|
2085
2112
|
new import_SplitMintJustificationVerifier.SplitMintJustificationVerifier(decodeSpherePaymentData)
|
|
2086
2113
|
);
|
|
2114
|
+
registerPluginVerifiers(mintJustificationVerifier, config.plugins);
|
|
2087
2115
|
const deps = {
|
|
2088
2116
|
client: new import_StateTransitionClient.StateTransitionClient(new import_AggregatorClient.AggregatorClient(config.aggregatorUrl, config.apiKey ?? null)),
|
|
2089
2117
|
trustBase,
|