@calimero-network/mero-js 25.0.4 → 25.0.6

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.
@@ -27,7 +27,9 @@ export declare function applicationIdForBundle(pkg: string, signerId: string): P
27
27
  * one rule for "latest", shared by the version lookup and the id derivation so
28
28
  * the two cannot disagree about which bundle an account is founding on.
29
29
  */
30
- export declare function selectLatestBundle<B extends RegistryBundle>(bundles: readonly B[]): B | undefined;
30
+ export declare function selectLatestBundle<B extends RegistryBundle>(bundles: readonly B[]): (B & {
31
+ appVersion: string;
32
+ }) | undefined;
31
33
  /** The registry's listing of `pkg`, every version. */
32
34
  export declare function fetchRegistryBundles(registryUrl: string, pkg: string, fetchFn?: typeof fetch): Promise<RegistryBundle[]>;
33
35
  export interface ResolvedApplication {
@@ -42,6 +42,7 @@
42
42
  */
43
43
  import { createLocalStorageNonceSource, } from '../relay/index.js';
44
44
  import { signMemberJoinOp, } from '../namespace-op/index.js';
45
+ import { pathSegment } from '../http-client/path-segment.js';
45
46
  /**
46
47
  * Turn an admit refusal into the thing to go and do about it.
47
48
  *
@@ -116,7 +117,7 @@ export async function joinWithNode(input) {
116
117
  // at the typecheck rather than as a 400 from a node.
117
118
  const body = { invitation: input.invitation, signedOp };
118
119
  const url = input.admitUrl ??
119
- `${origin(input.nodeUrl)}/admin-api/namespaces/${input.namespaceId}/admit`;
120
+ `${origin(input.nodeUrl)}/admin-api/namespaces/${pathSegment(input.namespaceId)}/admit`;
120
121
  const doFetch = input.deps?.fetch ?? fetch;
121
122
  let response;
122
123
  try {
@@ -50,6 +50,7 @@
50
50
  * sends the user to the wrong place.
51
51
  */
52
52
  import { CloudClient, } from '../cloud/index.js';
53
+ import { pathSegment } from '../http-client/path-segment.js';
53
54
  /**
54
55
  * Normalise a hex account for comparison: lower-cased, `0x` stripped.
55
56
  *
@@ -146,7 +147,8 @@ export async function resolveRelayFromInvitation(input) {
146
147
  const candidates = usable.length > 0 ? usable : named;
147
148
  const advisory = usable.length === 0 || !servable;
148
149
  const addressable = candidates.filter((n) => typeof n.relayUrl === 'string' && n.relayUrl.length > 0);
149
- if (addressable.length === 0) {
150
+ const [firstAddressable] = addressable;
151
+ if (firstAddressable === undefined) {
150
152
  return {
151
153
  ok: false,
152
154
  step: 'no-relay-url',
@@ -159,14 +161,14 @@ export async function resolveRelayFromInvitation(input) {
159
161
  // step that cannot proceed without a node, and authorship is not on the
160
162
  // invitation's list at all, so insisting would refuse a perfectly good
161
163
  // admitter for a permission admission never needed.
162
- const chosen = addressable.find((n) => n.canExecute) ?? addressable.find((n) => n.fresh) ?? addressable[0];
164
+ const chosen = addressable.find((n) => n.canExecute) ?? addressable.find((n) => n.fresh) ?? firstAddressable;
163
165
  return {
164
166
  ok: true,
165
167
  relayUrl: chosen.relayUrl,
166
168
  // The cloud's ready-made URL when it gave one, so the path is never rebuilt
167
169
  // from a guess; the fallback is the documented route on the same origin.
168
170
  admitUrl: chosen.admitUrl ??
169
- `${chosen.relayUrl.replace(/\/+$/, '')}/admin-api/namespaces/${input.namespaceId}/admit`,
171
+ `${chosen.relayUrl.replace(/\/+$/, '')}/admin-api/namespaces/${pathSegment(input.namespaceId)}/admit`,
170
172
  admitterAccount: chosen.account,
171
173
  peerId: chosen.peerId,
172
174
  writable: chosen.canExecute,