@calimero-network/mero-react 9.8.0 → 9.8.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/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -461,6 +461,22 @@ async function foundDelegatedNamespace(s, req = {}, deps = {}) {
|
|
|
461
461
|
return { namespaceId: founded.namespaceId, teeEnabled: founded.teeEnabled, ...ha };
|
|
462
462
|
}
|
|
463
463
|
var HA_ACCOUNT_NOT_LINKED_MESSAGE = "link this account to your cloud user in the wallet so invitees can find this namespace";
|
|
464
|
+
var HA_REFUSAL_MESSAGES = {
|
|
465
|
+
account_not_linked: HA_ACCOUNT_NOT_LINKED_MESSAGE,
|
|
466
|
+
account_linked_to_several_users: "this account is linked to more than one cloud user, so the cloud cannot tell whose plan hosts the namespace: unlink it from all but one in the wallet",
|
|
467
|
+
ha_request_pending: "another namespace of this account is still waiting to be hosted; the cloud hosts one new namespace at a time without a cloud sign-in. Sign in to the cloud and turn off hosting for the waiting namespace, or wait until it is hosted",
|
|
468
|
+
unknown_relay: "the cloud does not run the relay this namespace was founded on, so it cannot host it",
|
|
469
|
+
relay_not_dialable: "the relay this namespace was founded on has not reported its address to the cloud yet; try enabling hosting again shortly"
|
|
470
|
+
};
|
|
471
|
+
function blockingNamespace(e) {
|
|
472
|
+
try {
|
|
473
|
+
const body = JSON.parse(e.bodyText ?? "");
|
|
474
|
+
const id = body?.detail?.namespace_id ?? body?.namespace_id;
|
|
475
|
+
return typeof id === "string" && /^[0-9a-f]{64}$/i.test(id) ? id.toLowerCase() : null;
|
|
476
|
+
} catch {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
464
480
|
async function enableHaBestEffort(s, namespaceId, salt, relayUrl, deps) {
|
|
465
481
|
try {
|
|
466
482
|
await new meroJs.CloudClient({ cloudBaseUrl: deps.cloudBaseUrl, fetch: deps.fetch }).enableHaAsAccount({
|
|
@@ -476,6 +492,11 @@ async function enableHaBestEffort(s, namespaceId, salt, relayUrl, deps) {
|
|
|
476
492
|
return { haEnabled: true };
|
|
477
493
|
} catch (e) {
|
|
478
494
|
if (e instanceof meroJs.AccountNotLinkedError) return { haEnabled: false, haError: HA_ACCOUNT_NOT_LINKED_MESSAGE };
|
|
495
|
+
if (e instanceof meroJs.AccountHaRefusedError && HA_REFUSAL_MESSAGES[e.code]) {
|
|
496
|
+
const blocking = e.code === "ha_request_pending" ? blockingNamespace(e) : null;
|
|
497
|
+
const message = HA_REFUSAL_MESSAGES[e.code];
|
|
498
|
+
return { haEnabled: false, haError: blocking ? `${message} (waiting: ${blocking})` : message };
|
|
499
|
+
}
|
|
479
500
|
return { haEnabled: false, haError: e instanceof Error ? e.message : String(e) };
|
|
480
501
|
}
|
|
481
502
|
}
|
|
@@ -4974,6 +4995,7 @@ exports.ConnectButtonAccount = ConnectButtonAccount;
|
|
|
4974
4995
|
exports.ConnectionType = ConnectionType;
|
|
4975
4996
|
exports.DEFAULT_MIGRATION_POLL_INTERVAL_MS = DEFAULT_MIGRATION_POLL_INTERVAL_MS;
|
|
4976
4997
|
exports.HA_ACCOUNT_NOT_LINKED_MESSAGE = HA_ACCOUNT_NOT_LINKED_MESSAGE;
|
|
4998
|
+
exports.HA_REFUSAL_MESSAGES = HA_REFUSAL_MESSAGES;
|
|
4977
4999
|
exports.InvitationNotClaimableError = InvitationNotClaimableError;
|
|
4978
5000
|
exports.LoginModal = LoginModal;
|
|
4979
5001
|
exports.MERO_CSS_VARS = MERO_CSS_VARS;
|