@calimero-network/mero-react 9.6.3 → 9.7.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/dist/index.d.cts CHANGED
@@ -66,6 +66,17 @@ interface DelegatedSession extends DelegatedCredential {
66
66
  * warrant.
67
67
  */
68
68
  relayUrl: string | null;
69
+ /**
70
+ * The relay's executor account, hex, when the app knows it — the cloud's
71
+ * machine page names it beside the relay's address.
72
+ *
73
+ * Founding a namespace through a relay names the relay's account in the
74
+ * warrant, and a namespace that does not exist yet cannot be asked for it.
75
+ * Without this the account learns it from a namespace it is already in, so a
76
+ * brand-new account would have to join one first; with it, the account founds
77
+ * on `relayUrl` directly.
78
+ */
79
+ executorAccount?: string | null;
69
80
  }
70
81
  /**
71
82
  * The enrolled credential, whether or not a relay was ever found for it.
@@ -1061,8 +1072,9 @@ declare function createDelegatedContext(s: DelegatedSession, req: CreateDelegate
1061
1072
  * through the same relay straight away.
1062
1073
  *
1063
1074
  * The relay's executor account cannot be asked about a namespace that does
1064
- * not exist yet, so it is learned from one the account already has on that
1065
- * relay. A brand-new account, in nothing yet, is told to join one first.
1075
+ * not exist yet, so it is the session's `executorAccount` when the app named
1076
+ * one, else learned from a namespace the account already has on that relay. A
1077
+ * brand-new account with neither is told how to get one.
1066
1078
  */
1067
1079
  declare function foundDelegatedNamespace(s: DelegatedSession, req?: {
1068
1080
  readonly defaultCapabilities?: number;
package/dist/index.d.ts CHANGED
@@ -66,6 +66,17 @@ interface DelegatedSession extends DelegatedCredential {
66
66
  * warrant.
67
67
  */
68
68
  relayUrl: string | null;
69
+ /**
70
+ * The relay's executor account, hex, when the app knows it — the cloud's
71
+ * machine page names it beside the relay's address.
72
+ *
73
+ * Founding a namespace through a relay names the relay's account in the
74
+ * warrant, and a namespace that does not exist yet cannot be asked for it.
75
+ * Without this the account learns it from a namespace it is already in, so a
76
+ * brand-new account would have to join one first; with it, the account founds
77
+ * on `relayUrl` directly.
78
+ */
79
+ executorAccount?: string | null;
69
80
  }
70
81
  /**
71
82
  * The enrolled credential, whether or not a relay was ever found for it.
@@ -1061,8 +1072,9 @@ declare function createDelegatedContext(s: DelegatedSession, req: CreateDelegate
1061
1072
  * through the same relay straight away.
1062
1073
  *
1063
1074
  * The relay's executor account cannot be asked about a namespace that does
1064
- * not exist yet, so it is learned from one the account already has on that
1065
- * relay. A brand-new account, in nothing yet, is told to join one first.
1075
+ * not exist yet, so it is the session's `executorAccount` when the app named
1076
+ * one, else learned from a namespace the account already has on that relay. A
1077
+ * brand-new account with neither is told how to get one.
1066
1078
  */
1067
1079
  declare function foundDelegatedNamespace(s: DelegatedSession, req?: {
1068
1080
  readonly defaultCapabilities?: number;
package/dist/index.js CHANGED
@@ -423,10 +423,13 @@ async function foundDelegatedNamespace(s, req = {}, deps = {}) {
423
423
  const known = Object.entries(readRelayMap(s.account).namespaces).find(
424
424
  ([, url]) => url.replace(/\/+$/, "") === relay
425
425
  )?.[0];
426
- if (!known) {
427
- throw new Error("join a namespace on this relay first: its executor account is learned from one you are in");
426
+ const named = s.executorAccount && s.relayUrl && s.relayUrl.replace(/\/+$/, "") === relay ? s.executorAccount : null;
427
+ if (!named && !known) {
428
+ throw new Error(
429
+ "the executor account of this relay is not known: join a namespace on it first, or connect with the relay's executor account (the cloud shows it beside the relay)"
430
+ );
428
431
  }
429
- const { executorAccount } = await client(s, relay, governanceNonce(relay, known), deps.fetch).describeGovernance(known);
432
+ const executorAccount = named ?? (await client(s, relay, governanceNonce(relay, known), deps.fetch).describeGovernance(known)).executorAccount;
430
433
  let next = BigInt(Date.now());
431
434
  const founded = await client(s, relay, { next: async () => next++ }, deps.fetch).foundNamespace({
432
435
  executorAccount,
@@ -585,11 +588,7 @@ var NODE_ONLY = /* @__PURE__ */ new Set([
585
588
  "getTeeAdmissionPolicy",
586
589
  "deleteBlob",
587
590
  "listAccountDevices",
588
- "revokeAccountDevice",
589
- // Core rc.76 asks the NODE to be the namespace admin for this read, which a
590
- // relay is not, so an account that is the admin is answered a bare 403.
591
- // Refused by name until core checks the caller, as it does for the other two.
592
- "getMigrationStatus"
591
+ "revokeAccountDevice"
593
592
  ]);
594
593
  function isAlreadyDirectMember(e) {
595
594
  if (!(e instanceof Error)) return false;