@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.34
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/README.md +13 -1
- package/build.mjs +18 -1
- package/dist/activity-B8k9Sa_a.d.ts +9112 -0
- package/dist/authoring.d.ts +1355 -182
- package/dist/authoring.js +658 -225
- package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
- package/dist/avatar.d.ts +29 -0
- package/dist/avatar.js +21 -0
- package/dist/browser-J7tUpXxy.d.ts +4154 -0
- package/dist/browser.d.ts +11 -4580
- package/dist/browser.js +8 -6
- package/dist/capability-error-DNMwKmlL.d.ts +458 -0
- package/dist/chunk-36HTX2BM.js +1223 -0
- package/dist/chunk-6QJ3LADK.js +112 -0
- package/dist/chunk-BGGKNIRP.js +171 -0
- package/dist/chunk-EYH5RDIE.js +496 -0
- package/dist/chunk-GQKYAQM6.js +84 -0
- package/dist/chunk-GUP7YRR4.js +42 -0
- package/dist/chunk-GZ6FJAXN.js +1659 -0
- package/dist/chunk-JON5SESL.js +2986 -0
- package/dist/chunk-MC6V6VMG.js +49 -0
- package/dist/chunk-NPGENI7K.js +37 -0
- package/dist/chunk-V7UKZLHA.js +35 -0
- package/dist/chunk-VFHHLN6A.js +284 -0
- package/dist/chunk-WJSSJ7AF.js +151 -0
- package/dist/{chunk-VH4OQ5VX.js → chunk-XFMSUPNS.js} +26 -5
- package/dist/{chunk-FDWRBMB3.js → chunk-ZVIRG24J.js} +150 -33
- package/dist/client-XiuFnug_.d.ts +4262 -0
- package/dist/groups-Ck-OxzjD.d.ts +2449 -0
- package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
- package/dist/images-Dv-P5VBw.d.ts +234 -0
- package/dist/index.d.ts +15 -13115
- package/dist/index.js +30 -689
- package/dist/internal.d.ts +159 -0
- package/dist/internal.js +79 -0
- package/dist/offers-Cy-e4o5x.d.ts +431 -0
- package/dist/outcomes-kVB-Juzs.d.ts +4902 -0
- package/dist/pages-BBYD21IE.d.ts +359 -0
- package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
- package/dist/portal-proxy.js +26 -9
- package/dist/profiles-D2aFcOxu.d.ts +297 -0
- package/dist/react/index.d.ts +3378 -3318
- package/dist/react/index.js +1635 -783
- package/dist/request-error-DWduJCGV.d.ts +62 -0
- package/dist/schema-DfJzH2ci.d.ts +5644 -0
- package/dist/schema.d.ts +15 -3388
- package/dist/schema.js +790 -3
- package/dist/server/index.d.ts +81498 -0
- package/dist/server/index.js +2520 -0
- package/dist/streaks-CWyq8Px5.d.ts +71 -0
- package/dist/submission-input-BZkm6ohU.d.ts +290 -0
- package/dist/units-CwgsPB_r.d.ts +9 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -0
- package/dist/wallet-YssWxGg8.d.ts +228 -0
- package/package.json +24 -5
- package/dist/chunk-4KNTMNXA.js +0 -1847
- package/dist/chunk-B76BAJ25.js +0 -624
- package/dist/chunk-NKGJEYZM.js +0 -1833
- package/dist/chunk-ONDBQSMU.js +0 -373
- package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GZ6FJAXN.js";
|
|
4
4
|
import {
|
|
5
|
+
RelayErrorCode,
|
|
6
|
+
asRelayError,
|
|
7
|
+
clientError,
|
|
5
8
|
cosmosChain
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-36HTX2BM.js";
|
|
7
10
|
|
|
8
11
|
// src/base58.ts
|
|
9
12
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -446,7 +449,10 @@ async function readSignInMethods(relay) {
|
|
|
446
449
|
providers: [],
|
|
447
450
|
email: true,
|
|
448
451
|
wallets: [],
|
|
449
|
-
error:
|
|
452
|
+
error: asRelayError(
|
|
453
|
+
cause,
|
|
454
|
+
"Couldn't read the project's sign-in methods."
|
|
455
|
+
)
|
|
450
456
|
};
|
|
451
457
|
}
|
|
452
458
|
}
|
|
@@ -490,47 +496,158 @@ function createBrowserRelayClient(options) {
|
|
|
490
496
|
submissionStore: options.submissionStore ?? browserSubmissionStore()
|
|
491
497
|
});
|
|
492
498
|
}
|
|
499
|
+
var DATABASE = "domino-relay-submissions";
|
|
500
|
+
var STORE = "submissions";
|
|
501
|
+
var BLOCKED_GRACE_MS = 1e3;
|
|
502
|
+
function errorName(error) {
|
|
503
|
+
return typeof error === "object" && error !== null && "name" in error ? String(error.name) : void 0;
|
|
504
|
+
}
|
|
505
|
+
function storageError(error, action) {
|
|
506
|
+
const name = errorName(error);
|
|
507
|
+
if (name === "QuotaExceededError") {
|
|
508
|
+
return clientError(
|
|
509
|
+
"Browser storage is full, so submission progress could not be saved. Free some space, then resume the saved submission.",
|
|
510
|
+
RelayErrorCode.SubmissionStorageQuota,
|
|
511
|
+
{ cause: error }
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
if (name === "VersionError") {
|
|
515
|
+
return clientError(
|
|
516
|
+
"Another tab upgraded submission storage. Reload this page to continue.",
|
|
517
|
+
RelayErrorCode.SubmissionStorage,
|
|
518
|
+
{ cause: error }
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
return clientError(
|
|
522
|
+
action === "open" ? "Could not open submission storage. Try again, and check that this browser allows site storage (private browsing can turn it off)." : action === "read" ? "Could not read the saved submission. Do not start another claim; try again when browser storage is available." : "Could not save submission progress. Resume the saved submission when browser storage is available.",
|
|
523
|
+
RelayErrorCode.SubmissionStorage,
|
|
524
|
+
{ cause: error }
|
|
525
|
+
);
|
|
526
|
+
}
|
|
493
527
|
function browserSubmissionStore() {
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
);
|
|
528
|
+
let opening;
|
|
529
|
+
function release(db) {
|
|
530
|
+
db.close();
|
|
531
|
+
if (opening?.db === db) {
|
|
532
|
+
opening = void 0;
|
|
500
533
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
534
|
+
}
|
|
535
|
+
function start() {
|
|
536
|
+
let unblock;
|
|
537
|
+
const current = {
|
|
538
|
+
blocked: new Promise((resolve) => unblock = resolve),
|
|
539
|
+
done: new Promise((resolve, reject) => {
|
|
540
|
+
let request;
|
|
541
|
+
try {
|
|
542
|
+
request = indexedDB.open(DATABASE, 1);
|
|
543
|
+
} catch (error) {
|
|
544
|
+
reject(storageError(error, "open"));
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
request.onupgradeneeded = () => {
|
|
548
|
+
if (!request.result.objectStoreNames.contains(STORE)) {
|
|
549
|
+
request.result.createObjectStore(STORE);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
request.onblocked = unblock;
|
|
553
|
+
request.onerror = () => reject(storageError(request.error, "open"));
|
|
554
|
+
request.onsuccess = () => {
|
|
555
|
+
const db = request.result;
|
|
556
|
+
db.onversionchange = () => release(db);
|
|
557
|
+
db.onclose = () => release(db);
|
|
558
|
+
current.db = db;
|
|
559
|
+
resolve(db);
|
|
560
|
+
};
|
|
561
|
+
})
|
|
562
|
+
};
|
|
563
|
+
current.done.catch(() => {
|
|
564
|
+
if (opening === current) {
|
|
565
|
+
opening = void 0;
|
|
566
|
+
}
|
|
507
567
|
});
|
|
568
|
+
return current;
|
|
508
569
|
}
|
|
509
|
-
async function
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
value === void 0 ? "readonly" : "readwrite",
|
|
515
|
-
{ durability: "strict" }
|
|
570
|
+
async function connect() {
|
|
571
|
+
if (!globalThis.indexedDB || !globalThis.navigator?.locks) {
|
|
572
|
+
throw clientError(
|
|
573
|
+
"This browser cannot safely save submissions. Use a browser with IndexedDB and Web Locks enabled.",
|
|
574
|
+
RelayErrorCode.SubmissionStorage
|
|
516
575
|
);
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
576
|
+
}
|
|
577
|
+
if (opening?.db) {
|
|
578
|
+
return opening.db;
|
|
579
|
+
}
|
|
580
|
+
const attempt = opening ??= start();
|
|
581
|
+
let timer;
|
|
582
|
+
try {
|
|
583
|
+
return await Promise.race([
|
|
584
|
+
attempt.done,
|
|
585
|
+
attempt.blocked.then(
|
|
586
|
+
() => new Promise((_, reject) => {
|
|
587
|
+
timer = setTimeout(
|
|
588
|
+
() => reject(
|
|
589
|
+
clientError(
|
|
590
|
+
"Submission storage is blocked by another Relay tab. Close or reload other Relay tabs, then try again.",
|
|
591
|
+
RelayErrorCode.SubmissionStorage
|
|
592
|
+
)
|
|
593
|
+
),
|
|
594
|
+
BLOCKED_GRACE_MS
|
|
595
|
+
);
|
|
596
|
+
})
|
|
523
597
|
)
|
|
524
|
-
);
|
|
525
|
-
}
|
|
598
|
+
]);
|
|
599
|
+
} finally {
|
|
600
|
+
clearTimeout(timer);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
async function transact(key, action, value) {
|
|
604
|
+
for (let retry = true; ; retry = false) {
|
|
605
|
+
const db = await connect();
|
|
606
|
+
let transaction;
|
|
607
|
+
try {
|
|
608
|
+
transaction = db.transaction(
|
|
609
|
+
STORE,
|
|
610
|
+
action === "read" ? "readonly" : "readwrite",
|
|
611
|
+
{ durability: "strict" }
|
|
612
|
+
);
|
|
613
|
+
} catch (error) {
|
|
614
|
+
release(db);
|
|
615
|
+
if (retry && errorName(error) === "InvalidStateError") {
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
throw storageError(error, action);
|
|
619
|
+
}
|
|
620
|
+
return new Promise((resolve, reject) => {
|
|
621
|
+
let request;
|
|
622
|
+
function fail(error) {
|
|
623
|
+
if (errorName(error) !== "QuotaExceededError") {
|
|
624
|
+
release(db);
|
|
625
|
+
}
|
|
626
|
+
reject(storageError(error, action));
|
|
627
|
+
}
|
|
628
|
+
try {
|
|
629
|
+
const objects = transaction.objectStore(STORE);
|
|
630
|
+
request = action === "read" ? objects.get(key) : objects.put(value, key);
|
|
631
|
+
} catch (error) {
|
|
632
|
+
try {
|
|
633
|
+
transaction.abort();
|
|
634
|
+
} catch {
|
|
635
|
+
}
|
|
636
|
+
fail(error);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
transaction.oncomplete = () => resolve(request.result);
|
|
640
|
+
transaction.onabort = () => fail(transaction.error ?? request.error);
|
|
641
|
+
});
|
|
642
|
+
}
|
|
526
643
|
}
|
|
527
644
|
return {
|
|
528
|
-
read: (key) => transact(key),
|
|
645
|
+
read: (key) => transact(key, "read"),
|
|
529
646
|
write: async (key, value) => {
|
|
530
|
-
await transact(key, value);
|
|
647
|
+
await transact(key, "write", value);
|
|
531
648
|
},
|
|
532
649
|
exclusive: async (key, task) => {
|
|
533
|
-
await
|
|
650
|
+
await connect();
|
|
534
651
|
return navigator.locks.request(key, task);
|
|
535
652
|
}
|
|
536
653
|
};
|