@calimero-network/mero-js 19.5.0 → 19.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.cjs CHANGED
@@ -39,6 +39,8 @@ __export(index_exports, {
39
39
  WebHttpClient: () => WebHttpClient,
40
40
  WsClient: () => WsClient,
41
41
  accountForRoot: () => accountForRoot,
42
+ accountRootFromPhrase: () => accountRootFromPhrase,
43
+ accountRootFromSecret: () => accountRootFromSecret,
42
44
  buildAuthLoginUrl: () => buildAuthLoginUrl,
43
45
  combineSignals: () => combineSignals,
44
46
  compareSemver: () => compareSemver,
@@ -63,6 +65,7 @@ __export(index_exports, {
63
65
  deviceCertPayload: () => deviceCertPayload,
64
66
  discoverLocalNodes: () => discoverLocalNodes,
65
67
  encodeSignedInvitation: () => encodeSignedInvitation,
68
+ generateAccountRoot: () => generateAccountRoot,
66
69
  generateSessionKey: () => generateSessionKey,
67
70
  hasCap: () => hasCap,
68
71
  intentHash: () => intentHash,
@@ -73,6 +76,7 @@ __export(index_exports, {
73
76
  nodeEndpoint: () => nodeEndpoint,
74
77
  parseAuthCallback: () => parseAuthCallback,
75
78
  probeNodeHealth: () => probeNodeHealth,
79
+ signAccountLink: () => signAccountLink,
76
80
  signDeviceCert: () => signDeviceCert,
77
81
  signLoginStatement: () => signLoginStatement,
78
82
  signMemberJoinOp: () => signMemberJoinOp,
@@ -782,6 +786,41 @@ function createAuthApiClientFromHttpClient(httpClient, _config) {
782
786
  return new AuthApiClient(httpClient);
783
787
  }
784
788
 
789
+ // src/capabilities.ts
790
+ var CAPABILITIES = {
791
+ CAN_CREATE_CONTEXT: 1 << 0,
792
+ CAN_INVITE_MEMBERS: 1 << 1,
793
+ CAN_JOIN_OPEN_SUBGROUPS: 1 << 2,
794
+ MANAGE_MEMBERS: 1 << 3,
795
+ MANAGE_APPLICATION: 1 << 4,
796
+ CAN_CREATE_SUBGROUP: 1 << 5,
797
+ CAN_DELETE_SUBGROUP: 1 << 6,
798
+ CAN_MANAGE_VISIBILITY: 1 << 7,
799
+ CAN_MANAGE_METADATA: 1 << 8,
800
+ /**
801
+ * Publish writes attributed to ANOTHER member, under a warrant that member
802
+ * signed — the grant delegated execution runs on.
803
+ *
804
+ * Implied by nothing: not by membership, not by admin, and not propagated by
805
+ * the subgroup-admit cascade. So every group is authorship-closed until an
806
+ * admin sets this bit, and a relay without it is refused at
807
+ * `performIntent` before anything executes. That is why it is worth naming
808
+ * here rather than leaving callers to write `1 << 9`: a client granting it
809
+ * has to be able to say what it is granting.
810
+ */
811
+ CAN_AUTHOR_ON_BEHALF: 1 << 9
812
+ };
813
+ function hasCap(mask, cap) {
814
+ const capU32 = cap >>> 0;
815
+ return (mask & capU32) >>> 0 === capU32;
816
+ }
817
+ function withCap(mask, cap) {
818
+ return (mask | cap) >>> 0;
819
+ }
820
+ function withoutCap(mask, cap) {
821
+ return (mask & ~cap) >>> 0;
822
+ }
823
+
785
824
  // src/admin-api/admin-client.ts
786
825
  function unwrap(response) {
787
826
  return response?.data;
@@ -1540,6 +1579,85 @@ var AdminApiClient = class {
1540
1579
  async setDefaultCapabilities(groupId, request) {
1541
1580
  await this.httpClient.put(`/admin-api/groups/${groupId}/settings/default-capabilities`, request);
1542
1581
  }
1582
+ /**
1583
+ * Make every member admitted to `groupId` from now on able to relay a
1584
+ * delegated write, without a per-node governance op each time.
1585
+ *
1586
+ * `CAN_AUTHOR_ON_BEHALF` is implied by nothing — not membership, not admin —
1587
+ * so every group is authorship-closed and each fleet relay otherwise needs an
1588
+ * admin to grant it individually, at the moment the relay is assigned and the
1589
+ * admin is not watching. Setting it in the group's DEFAULT mask is core's own
1590
+ * answer to that: `add_member` seeds a non-admin's capability row from the
1591
+ * default, so an attested node admitted afterwards lands open.
1592
+ *
1593
+ * Call it on the NAMESPACE (the root group). A grant resolves through the
1594
+ * membership anchor, so one at the root reaches every Open subgroup beneath
1595
+ * it, which is where contexts actually live; a `Restricted` subgroup is a
1596
+ * membership boundary and needs its own call.
1597
+ *
1598
+ * ### Two things this does not do
1599
+ *
1600
+ * **It is not retroactive.** The default is copied into a member's row when
1601
+ * that member is admitted, so nodes already admitted keep the row they got.
1602
+ * Use {@link grantAuthorship} for those — or call this at namespace creation,
1603
+ * which is the only point that needs no backfill at all.
1604
+ *
1605
+ * **It does not reach admins.** Core seeds the default only for non-admin
1606
+ * roles, and `CAN_AUTHOR_ON_BEHALF` is deliberately not implied by admin. An
1607
+ * admin's own node therefore stays closed and needs {@link grantAuthorship}.
1608
+ *
1609
+ * ### What it widens
1610
+ *
1611
+ * Every future non-admin member of the group, not only attested TEE nodes, so
1612
+ * any of them may be named as a warrant's `executor`. The bound worth knowing
1613
+ * before deciding: an executor cannot FORGE. A delegated write is authorized
1614
+ * by the author's own warrant — signed by their device key, committed to one
1615
+ * context, method and exact arguments, with its nonce checked unspent — so a
1616
+ * holder can only spend a warrant it was deliberately handed. What it does
1617
+ * gain is the arguments in cleartext and the choice of when, or whether, to
1618
+ * publish.
1619
+ *
1620
+ * Read-modify-write rather than a blind set: core seeds a new group's default
1621
+ * with `CAN_JOIN_OPEN_SUBGROUPS`, and overwriting that would quietly stop
1622
+ * every later member inheriting into Open subgroups.
1623
+ *
1624
+ * Returns the resulting mask and whether an op was published — it is a no-op
1625
+ * when the bit is already set, so it is safe to call on every startup.
1626
+ */
1627
+ async openToDelegatedExecution(groupId) {
1628
+ const current = await this.getDefaultCapabilities(groupId);
1629
+ if (hasCap(current, CAPABILITIES.CAN_AUTHOR_ON_BEHALF)) {
1630
+ return { changed: false, defaultCapabilities: current };
1631
+ }
1632
+ const next = withCap(current, CAPABILITIES.CAN_AUTHOR_ON_BEHALF);
1633
+ await this.setDefaultCapabilities(groupId, { defaultCapabilities: next });
1634
+ return { changed: true, defaultCapabilities: next };
1635
+ }
1636
+ /**
1637
+ * Grant `account` the authorship bit on `groupId`, leaving its other
1638
+ * capabilities alone.
1639
+ *
1640
+ * The per-member counterpart to {@link openToDelegatedExecution}, and what
1641
+ * closes the gap that method cannot: a relay admitted BEFORE the default was
1642
+ * set, and an admin's own node, which never receives the default at all.
1643
+ *
1644
+ * `account` is the member's ACCOUNT id (64 hex) as `listGroupMembers` returns
1645
+ * it — for a fleet relay, the `account` the cloud reports for that node. Not
1646
+ * the signing key that added them; both are 64 hex, so nothing but the source
1647
+ * tells them apart.
1648
+ *
1649
+ * Read-modify-write, so it adds the bit rather than replacing the member's
1650
+ * mask. A no-op when the member already holds it.
1651
+ */
1652
+ async grantAuthorship(groupId, account) {
1653
+ const { capabilities } = await this.getMemberCapabilities(groupId, account);
1654
+ if (hasCap(capabilities, CAPABILITIES.CAN_AUTHOR_ON_BEHALF)) {
1655
+ return { changed: false, capabilities };
1656
+ }
1657
+ const next = withCap(capabilities, CAPABILITIES.CAN_AUTHOR_ON_BEHALF);
1658
+ await this.setMemberCapabilities(groupId, account, { capabilities: next });
1659
+ return { changed: true, capabilities: next };
1660
+ }
1543
1661
  async setSubgroupVisibility(groupId, request) {
1544
1662
  await this.httpClient.put(`/admin-api/groups/${groupId}/settings/subgroup-visibility`, request);
1545
1663
  }
@@ -2400,6 +2518,2326 @@ var EphemeralClient = class {
2400
2518
  }
2401
2519
  };
2402
2520
 
2521
+ // src/crypto/internal.ts
2522
+ var PKCS8_ED25519_PREFIX = new Uint8Array([
2523
+ 48,
2524
+ 46,
2525
+ 2,
2526
+ 1,
2527
+ 0,
2528
+ 48,
2529
+ 5,
2530
+ 6,
2531
+ 3,
2532
+ 43,
2533
+ 101,
2534
+ 112,
2535
+ 4,
2536
+ 34,
2537
+ 4,
2538
+ 32
2539
+ ]);
2540
+ function u32le(value) {
2541
+ const out = new Uint8Array(4);
2542
+ new DataView(out.buffer).setUint32(0, value, true);
2543
+ return out;
2544
+ }
2545
+ function hex(bytes) {
2546
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
2547
+ }
2548
+ function fromHex(value, label, expectedBytes) {
2549
+ const clean = value.trim();
2550
+ if (!/^[0-9a-fA-F]*$/.test(clean) || clean.length !== expectedBytes * 2) {
2551
+ throw new Error(
2552
+ `${label} must be ${expectedBytes * 2} hex characters, got ${clean.length}`
2553
+ );
2554
+ }
2555
+ const bytes = new Uint8Array(expectedBytes);
2556
+ for (let i = 0; i < expectedBytes; i += 1) {
2557
+ bytes[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
2558
+ }
2559
+ return bytes;
2560
+ }
2561
+ function u64le(value) {
2562
+ const out = new Uint8Array(8);
2563
+ new DataView(out.buffer).setBigUint64(0, BigInt(value), true);
2564
+ return out;
2565
+ }
2566
+ function concat(...parts) {
2567
+ const out = new Uint8Array(parts.reduce((total, p) => total + p.length, 0));
2568
+ let offset = 0;
2569
+ for (const part of parts) {
2570
+ out.set(part, offset);
2571
+ offset += part.length;
2572
+ }
2573
+ return out;
2574
+ }
2575
+ async function domainHash(domain, parts) {
2576
+ const chunks = [u64le(domain.length), domain];
2577
+ for (const part of parts) {
2578
+ chunks.push(u64le(part.length), part);
2579
+ }
2580
+ return new Uint8Array(
2581
+ await crypto.subtle.digest("SHA-256", concat(...chunks))
2582
+ );
2583
+ }
2584
+ async function importSigningKey(secretHex) {
2585
+ const seed = fromHex(secretHex, "deviceSecret", 32);
2586
+ const pkcs8 = concat(PKCS8_ED25519_PREFIX, seed);
2587
+ try {
2588
+ return await crypto.subtle.importKey(
2589
+ "pkcs8",
2590
+ pkcs8,
2591
+ { name: "Ed25519" },
2592
+ false,
2593
+ ["sign"]
2594
+ );
2595
+ } catch (cause) {
2596
+ const detail = cause instanceof Error ? `: ${cause.message}` : "";
2597
+ throw new Error(
2598
+ "this runtime has no WebCrypto Ed25519, so a warrant cannot be signed here. Node 18.4+, Safari 17+, Firefox 129+ and Chrome 137+ have it; otherwise mint the warrant with `merod account warrant`" + detail
2599
+ );
2600
+ }
2601
+ }
2602
+ async function derivePublicKey(secretHex) {
2603
+ const seed = fromHex(secretHex, "deviceSecret", 32);
2604
+ const pkcs8 = concat(PKCS8_ED25519_PREFIX, seed);
2605
+ const key = await crypto.subtle.importKey(
2606
+ "pkcs8",
2607
+ pkcs8,
2608
+ { name: "Ed25519" },
2609
+ true,
2610
+ ["sign"]
2611
+ );
2612
+ const jwk = await crypto.subtle.exportKey("jwk", key);
2613
+ const raw = jwk.x;
2614
+ return Uint8Array.from(
2615
+ atob(raw.replace(/-/g, "+").replace(/_/g, "/")),
2616
+ (c) => c.charCodeAt(0)
2617
+ );
2618
+ }
2619
+
2620
+ // src/device-cert/device-cert.ts
2621
+ var CERT_DOMAIN = new TextEncoder().encode("calimero.device.cert.v1");
2622
+ var ACCOUNT_ID_DOMAIN = new TextEncoder().encode("calimero.account.genesis.v1");
2623
+ var DEVICE_ID_DOMAIN = new TextEncoder().encode("calimero.device.id.v1");
2624
+ var ACCOUNT_GENESIS_VERSION = 2;
2625
+ async function mintDeviceId(account, nonce) {
2626
+ if (nonce.length !== 16) {
2627
+ throw new Error(`nonce must be 16 bytes, got ${nonce.length}`);
2628
+ }
2629
+ const accountBytes = fromHex(account, "account", 32);
2630
+ return hex(await domainHash(DEVICE_ID_DOMAIN, [accountBytes, nonce]));
2631
+ }
2632
+ async function deviceCertPayload(input) {
2633
+ return domainHash(CERT_DOMAIN, [
2634
+ fromHex(input.account, "account", 32),
2635
+ fromHex(input.device, "device", 32),
2636
+ fromHex(input.signPublicKey, "signPublicKey", 32),
2637
+ fromHex(input.kemPublicKey, "kemPublicKey", 32),
2638
+ u32le(input.keyEpoch),
2639
+ u32le(input.deviceEpoch)
2640
+ ]);
2641
+ }
2642
+ function accountProofBytes(input) {
2643
+ return concat(
2644
+ new Uint8Array([ACCOUNT_GENESIS_VERSION]),
2645
+ input.rootPublicKey,
2646
+ u32le(0),
2647
+ fromHex(input.account, "account", 32),
2648
+ fromHex(input.device, "device", 32),
2649
+ fromHex(input.signPublicKey, "signPublicKey", 32),
2650
+ fromHex(input.kemPublicKey, "kemPublicKey", 32),
2651
+ u32le(input.keyEpoch),
2652
+ u32le(input.deviceEpoch),
2653
+ input.signature
2654
+ );
2655
+ }
2656
+ async function signDeviceCert(input) {
2657
+ const rootPublicKey = await derivePublicKey(input.rootSecret);
2658
+ const account = hex(
2659
+ await domainHash(ACCOUNT_ID_DOMAIN, [
2660
+ concat(new Uint8Array([ACCOUNT_GENESIS_VERSION]), rootPublicKey)
2661
+ ])
2662
+ );
2663
+ const keyEpoch = 0;
2664
+ const payload = await deviceCertPayload({
2665
+ account,
2666
+ device: input.device,
2667
+ signPublicKey: input.signPublicKey,
2668
+ kemPublicKey: input.kemPublicKey,
2669
+ keyEpoch,
2670
+ deviceEpoch: input.deviceEpoch
2671
+ });
2672
+ const key = await importSigningKey(input.rootSecret);
2673
+ const signature = new Uint8Array(
2674
+ await crypto.subtle.sign("Ed25519", key, payload)
2675
+ );
2676
+ const credential = accountProofBytes({
2677
+ rootPublicKey,
2678
+ account,
2679
+ device: input.device,
2680
+ signPublicKey: input.signPublicKey,
2681
+ kemPublicKey: input.kemPublicKey,
2682
+ keyEpoch,
2683
+ deviceEpoch: input.deviceEpoch,
2684
+ signature
2685
+ });
2686
+ return hex(credential);
2687
+ }
2688
+ async function accountForRoot(rootSecret) {
2689
+ const rootPublicKey = await derivePublicKey(rootSecret);
2690
+ return hex(
2691
+ await domainHash(ACCOUNT_ID_DOMAIN, [
2692
+ concat(new Uint8Array([ACCOUNT_GENESIS_VERSION]), rootPublicKey)
2693
+ ])
2694
+ );
2695
+ }
2696
+
2697
+ // src/account/wordlist.ts
2698
+ var ENGLISH_WORDLIST = [
2699
+ "abandon",
2700
+ "ability",
2701
+ "able",
2702
+ "about",
2703
+ "above",
2704
+ "absent",
2705
+ "absorb",
2706
+ "abstract",
2707
+ "absurd",
2708
+ "abuse",
2709
+ "access",
2710
+ "accident",
2711
+ "account",
2712
+ "accuse",
2713
+ "achieve",
2714
+ "acid",
2715
+ "acoustic",
2716
+ "acquire",
2717
+ "across",
2718
+ "act",
2719
+ "action",
2720
+ "actor",
2721
+ "actress",
2722
+ "actual",
2723
+ "adapt",
2724
+ "add",
2725
+ "addict",
2726
+ "address",
2727
+ "adjust",
2728
+ "admit",
2729
+ "adult",
2730
+ "advance",
2731
+ "advice",
2732
+ "aerobic",
2733
+ "affair",
2734
+ "afford",
2735
+ "afraid",
2736
+ "again",
2737
+ "age",
2738
+ "agent",
2739
+ "agree",
2740
+ "ahead",
2741
+ "aim",
2742
+ "air",
2743
+ "airport",
2744
+ "aisle",
2745
+ "alarm",
2746
+ "album",
2747
+ "alcohol",
2748
+ "alert",
2749
+ "alien",
2750
+ "all",
2751
+ "alley",
2752
+ "allow",
2753
+ "almost",
2754
+ "alone",
2755
+ "alpha",
2756
+ "already",
2757
+ "also",
2758
+ "alter",
2759
+ "always",
2760
+ "amateur",
2761
+ "amazing",
2762
+ "among",
2763
+ "amount",
2764
+ "amused",
2765
+ "analyst",
2766
+ "anchor",
2767
+ "ancient",
2768
+ "anger",
2769
+ "angle",
2770
+ "angry",
2771
+ "animal",
2772
+ "ankle",
2773
+ "announce",
2774
+ "annual",
2775
+ "another",
2776
+ "answer",
2777
+ "antenna",
2778
+ "antique",
2779
+ "anxiety",
2780
+ "any",
2781
+ "apart",
2782
+ "apology",
2783
+ "appear",
2784
+ "apple",
2785
+ "approve",
2786
+ "april",
2787
+ "arch",
2788
+ "arctic",
2789
+ "area",
2790
+ "arena",
2791
+ "argue",
2792
+ "arm",
2793
+ "armed",
2794
+ "armor",
2795
+ "army",
2796
+ "around",
2797
+ "arrange",
2798
+ "arrest",
2799
+ "arrive",
2800
+ "arrow",
2801
+ "art",
2802
+ "artefact",
2803
+ "artist",
2804
+ "artwork",
2805
+ "ask",
2806
+ "aspect",
2807
+ "assault",
2808
+ "asset",
2809
+ "assist",
2810
+ "assume",
2811
+ "asthma",
2812
+ "athlete",
2813
+ "atom",
2814
+ "attack",
2815
+ "attend",
2816
+ "attitude",
2817
+ "attract",
2818
+ "auction",
2819
+ "audit",
2820
+ "august",
2821
+ "aunt",
2822
+ "author",
2823
+ "auto",
2824
+ "autumn",
2825
+ "average",
2826
+ "avocado",
2827
+ "avoid",
2828
+ "awake",
2829
+ "aware",
2830
+ "away",
2831
+ "awesome",
2832
+ "awful",
2833
+ "awkward",
2834
+ "axis",
2835
+ "baby",
2836
+ "bachelor",
2837
+ "bacon",
2838
+ "badge",
2839
+ "bag",
2840
+ "balance",
2841
+ "balcony",
2842
+ "ball",
2843
+ "bamboo",
2844
+ "banana",
2845
+ "banner",
2846
+ "bar",
2847
+ "barely",
2848
+ "bargain",
2849
+ "barrel",
2850
+ "base",
2851
+ "basic",
2852
+ "basket",
2853
+ "battle",
2854
+ "beach",
2855
+ "bean",
2856
+ "beauty",
2857
+ "because",
2858
+ "become",
2859
+ "beef",
2860
+ "before",
2861
+ "begin",
2862
+ "behave",
2863
+ "behind",
2864
+ "believe",
2865
+ "below",
2866
+ "belt",
2867
+ "bench",
2868
+ "benefit",
2869
+ "best",
2870
+ "betray",
2871
+ "better",
2872
+ "between",
2873
+ "beyond",
2874
+ "bicycle",
2875
+ "bid",
2876
+ "bike",
2877
+ "bind",
2878
+ "biology",
2879
+ "bird",
2880
+ "birth",
2881
+ "bitter",
2882
+ "black",
2883
+ "blade",
2884
+ "blame",
2885
+ "blanket",
2886
+ "blast",
2887
+ "bleak",
2888
+ "bless",
2889
+ "blind",
2890
+ "blood",
2891
+ "blossom",
2892
+ "blouse",
2893
+ "blue",
2894
+ "blur",
2895
+ "blush",
2896
+ "board",
2897
+ "boat",
2898
+ "body",
2899
+ "boil",
2900
+ "bomb",
2901
+ "bone",
2902
+ "bonus",
2903
+ "book",
2904
+ "boost",
2905
+ "border",
2906
+ "boring",
2907
+ "borrow",
2908
+ "boss",
2909
+ "bottom",
2910
+ "bounce",
2911
+ "box",
2912
+ "boy",
2913
+ "bracket",
2914
+ "brain",
2915
+ "brand",
2916
+ "brass",
2917
+ "brave",
2918
+ "bread",
2919
+ "breeze",
2920
+ "brick",
2921
+ "bridge",
2922
+ "brief",
2923
+ "bright",
2924
+ "bring",
2925
+ "brisk",
2926
+ "broccoli",
2927
+ "broken",
2928
+ "bronze",
2929
+ "broom",
2930
+ "brother",
2931
+ "brown",
2932
+ "brush",
2933
+ "bubble",
2934
+ "buddy",
2935
+ "budget",
2936
+ "buffalo",
2937
+ "build",
2938
+ "bulb",
2939
+ "bulk",
2940
+ "bullet",
2941
+ "bundle",
2942
+ "bunker",
2943
+ "burden",
2944
+ "burger",
2945
+ "burst",
2946
+ "bus",
2947
+ "business",
2948
+ "busy",
2949
+ "butter",
2950
+ "buyer",
2951
+ "buzz",
2952
+ "cabbage",
2953
+ "cabin",
2954
+ "cable",
2955
+ "cactus",
2956
+ "cage",
2957
+ "cake",
2958
+ "call",
2959
+ "calm",
2960
+ "camera",
2961
+ "camp",
2962
+ "can",
2963
+ "canal",
2964
+ "cancel",
2965
+ "candy",
2966
+ "cannon",
2967
+ "canoe",
2968
+ "canvas",
2969
+ "canyon",
2970
+ "capable",
2971
+ "capital",
2972
+ "captain",
2973
+ "car",
2974
+ "carbon",
2975
+ "card",
2976
+ "cargo",
2977
+ "carpet",
2978
+ "carry",
2979
+ "cart",
2980
+ "case",
2981
+ "cash",
2982
+ "casino",
2983
+ "castle",
2984
+ "casual",
2985
+ "cat",
2986
+ "catalog",
2987
+ "catch",
2988
+ "category",
2989
+ "cattle",
2990
+ "caught",
2991
+ "cause",
2992
+ "caution",
2993
+ "cave",
2994
+ "ceiling",
2995
+ "celery",
2996
+ "cement",
2997
+ "census",
2998
+ "century",
2999
+ "cereal",
3000
+ "certain",
3001
+ "chair",
3002
+ "chalk",
3003
+ "champion",
3004
+ "change",
3005
+ "chaos",
3006
+ "chapter",
3007
+ "charge",
3008
+ "chase",
3009
+ "chat",
3010
+ "cheap",
3011
+ "check",
3012
+ "cheese",
3013
+ "chef",
3014
+ "cherry",
3015
+ "chest",
3016
+ "chicken",
3017
+ "chief",
3018
+ "child",
3019
+ "chimney",
3020
+ "choice",
3021
+ "choose",
3022
+ "chronic",
3023
+ "chuckle",
3024
+ "chunk",
3025
+ "churn",
3026
+ "cigar",
3027
+ "cinnamon",
3028
+ "circle",
3029
+ "citizen",
3030
+ "city",
3031
+ "civil",
3032
+ "claim",
3033
+ "clap",
3034
+ "clarify",
3035
+ "claw",
3036
+ "clay",
3037
+ "clean",
3038
+ "clerk",
3039
+ "clever",
3040
+ "click",
3041
+ "client",
3042
+ "cliff",
3043
+ "climb",
3044
+ "clinic",
3045
+ "clip",
3046
+ "clock",
3047
+ "clog",
3048
+ "close",
3049
+ "cloth",
3050
+ "cloud",
3051
+ "clown",
3052
+ "club",
3053
+ "clump",
3054
+ "cluster",
3055
+ "clutch",
3056
+ "coach",
3057
+ "coast",
3058
+ "coconut",
3059
+ "code",
3060
+ "coffee",
3061
+ "coil",
3062
+ "coin",
3063
+ "collect",
3064
+ "color",
3065
+ "column",
3066
+ "combine",
3067
+ "come",
3068
+ "comfort",
3069
+ "comic",
3070
+ "common",
3071
+ "company",
3072
+ "concert",
3073
+ "conduct",
3074
+ "confirm",
3075
+ "congress",
3076
+ "connect",
3077
+ "consider",
3078
+ "control",
3079
+ "convince",
3080
+ "cook",
3081
+ "cool",
3082
+ "copper",
3083
+ "copy",
3084
+ "coral",
3085
+ "core",
3086
+ "corn",
3087
+ "correct",
3088
+ "cost",
3089
+ "cotton",
3090
+ "couch",
3091
+ "country",
3092
+ "couple",
3093
+ "course",
3094
+ "cousin",
3095
+ "cover",
3096
+ "coyote",
3097
+ "crack",
3098
+ "cradle",
3099
+ "craft",
3100
+ "cram",
3101
+ "crane",
3102
+ "crash",
3103
+ "crater",
3104
+ "crawl",
3105
+ "crazy",
3106
+ "cream",
3107
+ "credit",
3108
+ "creek",
3109
+ "crew",
3110
+ "cricket",
3111
+ "crime",
3112
+ "crisp",
3113
+ "critic",
3114
+ "crop",
3115
+ "cross",
3116
+ "crouch",
3117
+ "crowd",
3118
+ "crucial",
3119
+ "cruel",
3120
+ "cruise",
3121
+ "crumble",
3122
+ "crunch",
3123
+ "crush",
3124
+ "cry",
3125
+ "crystal",
3126
+ "cube",
3127
+ "culture",
3128
+ "cup",
3129
+ "cupboard",
3130
+ "curious",
3131
+ "current",
3132
+ "curtain",
3133
+ "curve",
3134
+ "cushion",
3135
+ "custom",
3136
+ "cute",
3137
+ "cycle",
3138
+ "dad",
3139
+ "damage",
3140
+ "damp",
3141
+ "dance",
3142
+ "danger",
3143
+ "daring",
3144
+ "dash",
3145
+ "daughter",
3146
+ "dawn",
3147
+ "day",
3148
+ "deal",
3149
+ "debate",
3150
+ "debris",
3151
+ "decade",
3152
+ "december",
3153
+ "decide",
3154
+ "decline",
3155
+ "decorate",
3156
+ "decrease",
3157
+ "deer",
3158
+ "defense",
3159
+ "define",
3160
+ "defy",
3161
+ "degree",
3162
+ "delay",
3163
+ "deliver",
3164
+ "demand",
3165
+ "demise",
3166
+ "denial",
3167
+ "dentist",
3168
+ "deny",
3169
+ "depart",
3170
+ "depend",
3171
+ "deposit",
3172
+ "depth",
3173
+ "deputy",
3174
+ "derive",
3175
+ "describe",
3176
+ "desert",
3177
+ "design",
3178
+ "desk",
3179
+ "despair",
3180
+ "destroy",
3181
+ "detail",
3182
+ "detect",
3183
+ "develop",
3184
+ "device",
3185
+ "devote",
3186
+ "diagram",
3187
+ "dial",
3188
+ "diamond",
3189
+ "diary",
3190
+ "dice",
3191
+ "diesel",
3192
+ "diet",
3193
+ "differ",
3194
+ "digital",
3195
+ "dignity",
3196
+ "dilemma",
3197
+ "dinner",
3198
+ "dinosaur",
3199
+ "direct",
3200
+ "dirt",
3201
+ "disagree",
3202
+ "discover",
3203
+ "disease",
3204
+ "dish",
3205
+ "dismiss",
3206
+ "disorder",
3207
+ "display",
3208
+ "distance",
3209
+ "divert",
3210
+ "divide",
3211
+ "divorce",
3212
+ "dizzy",
3213
+ "doctor",
3214
+ "document",
3215
+ "dog",
3216
+ "doll",
3217
+ "dolphin",
3218
+ "domain",
3219
+ "donate",
3220
+ "donkey",
3221
+ "donor",
3222
+ "door",
3223
+ "dose",
3224
+ "double",
3225
+ "dove",
3226
+ "draft",
3227
+ "dragon",
3228
+ "drama",
3229
+ "drastic",
3230
+ "draw",
3231
+ "dream",
3232
+ "dress",
3233
+ "drift",
3234
+ "drill",
3235
+ "drink",
3236
+ "drip",
3237
+ "drive",
3238
+ "drop",
3239
+ "drum",
3240
+ "dry",
3241
+ "duck",
3242
+ "dumb",
3243
+ "dune",
3244
+ "during",
3245
+ "dust",
3246
+ "dutch",
3247
+ "duty",
3248
+ "dwarf",
3249
+ "dynamic",
3250
+ "eager",
3251
+ "eagle",
3252
+ "early",
3253
+ "earn",
3254
+ "earth",
3255
+ "easily",
3256
+ "east",
3257
+ "easy",
3258
+ "echo",
3259
+ "ecology",
3260
+ "economy",
3261
+ "edge",
3262
+ "edit",
3263
+ "educate",
3264
+ "effort",
3265
+ "egg",
3266
+ "eight",
3267
+ "either",
3268
+ "elbow",
3269
+ "elder",
3270
+ "electric",
3271
+ "elegant",
3272
+ "element",
3273
+ "elephant",
3274
+ "elevator",
3275
+ "elite",
3276
+ "else",
3277
+ "embark",
3278
+ "embody",
3279
+ "embrace",
3280
+ "emerge",
3281
+ "emotion",
3282
+ "employ",
3283
+ "empower",
3284
+ "empty",
3285
+ "enable",
3286
+ "enact",
3287
+ "end",
3288
+ "endless",
3289
+ "endorse",
3290
+ "enemy",
3291
+ "energy",
3292
+ "enforce",
3293
+ "engage",
3294
+ "engine",
3295
+ "enhance",
3296
+ "enjoy",
3297
+ "enlist",
3298
+ "enough",
3299
+ "enrich",
3300
+ "enroll",
3301
+ "ensure",
3302
+ "enter",
3303
+ "entire",
3304
+ "entry",
3305
+ "envelope",
3306
+ "episode",
3307
+ "equal",
3308
+ "equip",
3309
+ "era",
3310
+ "erase",
3311
+ "erode",
3312
+ "erosion",
3313
+ "error",
3314
+ "erupt",
3315
+ "escape",
3316
+ "essay",
3317
+ "essence",
3318
+ "estate",
3319
+ "eternal",
3320
+ "ethics",
3321
+ "evidence",
3322
+ "evil",
3323
+ "evoke",
3324
+ "evolve",
3325
+ "exact",
3326
+ "example",
3327
+ "excess",
3328
+ "exchange",
3329
+ "excite",
3330
+ "exclude",
3331
+ "excuse",
3332
+ "execute",
3333
+ "exercise",
3334
+ "exhaust",
3335
+ "exhibit",
3336
+ "exile",
3337
+ "exist",
3338
+ "exit",
3339
+ "exotic",
3340
+ "expand",
3341
+ "expect",
3342
+ "expire",
3343
+ "explain",
3344
+ "expose",
3345
+ "express",
3346
+ "extend",
3347
+ "extra",
3348
+ "eye",
3349
+ "eyebrow",
3350
+ "fabric",
3351
+ "face",
3352
+ "faculty",
3353
+ "fade",
3354
+ "faint",
3355
+ "faith",
3356
+ "fall",
3357
+ "false",
3358
+ "fame",
3359
+ "family",
3360
+ "famous",
3361
+ "fan",
3362
+ "fancy",
3363
+ "fantasy",
3364
+ "farm",
3365
+ "fashion",
3366
+ "fat",
3367
+ "fatal",
3368
+ "father",
3369
+ "fatigue",
3370
+ "fault",
3371
+ "favorite",
3372
+ "feature",
3373
+ "february",
3374
+ "federal",
3375
+ "fee",
3376
+ "feed",
3377
+ "feel",
3378
+ "female",
3379
+ "fence",
3380
+ "festival",
3381
+ "fetch",
3382
+ "fever",
3383
+ "few",
3384
+ "fiber",
3385
+ "fiction",
3386
+ "field",
3387
+ "figure",
3388
+ "file",
3389
+ "film",
3390
+ "filter",
3391
+ "final",
3392
+ "find",
3393
+ "fine",
3394
+ "finger",
3395
+ "finish",
3396
+ "fire",
3397
+ "firm",
3398
+ "first",
3399
+ "fiscal",
3400
+ "fish",
3401
+ "fit",
3402
+ "fitness",
3403
+ "fix",
3404
+ "flag",
3405
+ "flame",
3406
+ "flash",
3407
+ "flat",
3408
+ "flavor",
3409
+ "flee",
3410
+ "flight",
3411
+ "flip",
3412
+ "float",
3413
+ "flock",
3414
+ "floor",
3415
+ "flower",
3416
+ "fluid",
3417
+ "flush",
3418
+ "fly",
3419
+ "foam",
3420
+ "focus",
3421
+ "fog",
3422
+ "foil",
3423
+ "fold",
3424
+ "follow",
3425
+ "food",
3426
+ "foot",
3427
+ "force",
3428
+ "forest",
3429
+ "forget",
3430
+ "fork",
3431
+ "fortune",
3432
+ "forum",
3433
+ "forward",
3434
+ "fossil",
3435
+ "foster",
3436
+ "found",
3437
+ "fox",
3438
+ "fragile",
3439
+ "frame",
3440
+ "frequent",
3441
+ "fresh",
3442
+ "friend",
3443
+ "fringe",
3444
+ "frog",
3445
+ "front",
3446
+ "frost",
3447
+ "frown",
3448
+ "frozen",
3449
+ "fruit",
3450
+ "fuel",
3451
+ "fun",
3452
+ "funny",
3453
+ "furnace",
3454
+ "fury",
3455
+ "future",
3456
+ "gadget",
3457
+ "gain",
3458
+ "galaxy",
3459
+ "gallery",
3460
+ "game",
3461
+ "gap",
3462
+ "garage",
3463
+ "garbage",
3464
+ "garden",
3465
+ "garlic",
3466
+ "garment",
3467
+ "gas",
3468
+ "gasp",
3469
+ "gate",
3470
+ "gather",
3471
+ "gauge",
3472
+ "gaze",
3473
+ "general",
3474
+ "genius",
3475
+ "genre",
3476
+ "gentle",
3477
+ "genuine",
3478
+ "gesture",
3479
+ "ghost",
3480
+ "giant",
3481
+ "gift",
3482
+ "giggle",
3483
+ "ginger",
3484
+ "giraffe",
3485
+ "girl",
3486
+ "give",
3487
+ "glad",
3488
+ "glance",
3489
+ "glare",
3490
+ "glass",
3491
+ "glide",
3492
+ "glimpse",
3493
+ "globe",
3494
+ "gloom",
3495
+ "glory",
3496
+ "glove",
3497
+ "glow",
3498
+ "glue",
3499
+ "goat",
3500
+ "goddess",
3501
+ "gold",
3502
+ "good",
3503
+ "goose",
3504
+ "gorilla",
3505
+ "gospel",
3506
+ "gossip",
3507
+ "govern",
3508
+ "gown",
3509
+ "grab",
3510
+ "grace",
3511
+ "grain",
3512
+ "grant",
3513
+ "grape",
3514
+ "grass",
3515
+ "gravity",
3516
+ "great",
3517
+ "green",
3518
+ "grid",
3519
+ "grief",
3520
+ "grit",
3521
+ "grocery",
3522
+ "group",
3523
+ "grow",
3524
+ "grunt",
3525
+ "guard",
3526
+ "guess",
3527
+ "guide",
3528
+ "guilt",
3529
+ "guitar",
3530
+ "gun",
3531
+ "gym",
3532
+ "habit",
3533
+ "hair",
3534
+ "half",
3535
+ "hammer",
3536
+ "hamster",
3537
+ "hand",
3538
+ "happy",
3539
+ "harbor",
3540
+ "hard",
3541
+ "harsh",
3542
+ "harvest",
3543
+ "hat",
3544
+ "have",
3545
+ "hawk",
3546
+ "hazard",
3547
+ "head",
3548
+ "health",
3549
+ "heart",
3550
+ "heavy",
3551
+ "hedgehog",
3552
+ "height",
3553
+ "hello",
3554
+ "helmet",
3555
+ "help",
3556
+ "hen",
3557
+ "hero",
3558
+ "hidden",
3559
+ "high",
3560
+ "hill",
3561
+ "hint",
3562
+ "hip",
3563
+ "hire",
3564
+ "history",
3565
+ "hobby",
3566
+ "hockey",
3567
+ "hold",
3568
+ "hole",
3569
+ "holiday",
3570
+ "hollow",
3571
+ "home",
3572
+ "honey",
3573
+ "hood",
3574
+ "hope",
3575
+ "horn",
3576
+ "horror",
3577
+ "horse",
3578
+ "hospital",
3579
+ "host",
3580
+ "hotel",
3581
+ "hour",
3582
+ "hover",
3583
+ "hub",
3584
+ "huge",
3585
+ "human",
3586
+ "humble",
3587
+ "humor",
3588
+ "hundred",
3589
+ "hungry",
3590
+ "hunt",
3591
+ "hurdle",
3592
+ "hurry",
3593
+ "hurt",
3594
+ "husband",
3595
+ "hybrid",
3596
+ "ice",
3597
+ "icon",
3598
+ "idea",
3599
+ "identify",
3600
+ "idle",
3601
+ "ignore",
3602
+ "ill",
3603
+ "illegal",
3604
+ "illness",
3605
+ "image",
3606
+ "imitate",
3607
+ "immense",
3608
+ "immune",
3609
+ "impact",
3610
+ "impose",
3611
+ "improve",
3612
+ "impulse",
3613
+ "inch",
3614
+ "include",
3615
+ "income",
3616
+ "increase",
3617
+ "index",
3618
+ "indicate",
3619
+ "indoor",
3620
+ "industry",
3621
+ "infant",
3622
+ "inflict",
3623
+ "inform",
3624
+ "inhale",
3625
+ "inherit",
3626
+ "initial",
3627
+ "inject",
3628
+ "injury",
3629
+ "inmate",
3630
+ "inner",
3631
+ "innocent",
3632
+ "input",
3633
+ "inquiry",
3634
+ "insane",
3635
+ "insect",
3636
+ "inside",
3637
+ "inspire",
3638
+ "install",
3639
+ "intact",
3640
+ "interest",
3641
+ "into",
3642
+ "invest",
3643
+ "invite",
3644
+ "involve",
3645
+ "iron",
3646
+ "island",
3647
+ "isolate",
3648
+ "issue",
3649
+ "item",
3650
+ "ivory",
3651
+ "jacket",
3652
+ "jaguar",
3653
+ "jar",
3654
+ "jazz",
3655
+ "jealous",
3656
+ "jeans",
3657
+ "jelly",
3658
+ "jewel",
3659
+ "job",
3660
+ "join",
3661
+ "joke",
3662
+ "journey",
3663
+ "joy",
3664
+ "judge",
3665
+ "juice",
3666
+ "jump",
3667
+ "jungle",
3668
+ "junior",
3669
+ "junk",
3670
+ "just",
3671
+ "kangaroo",
3672
+ "keen",
3673
+ "keep",
3674
+ "ketchup",
3675
+ "key",
3676
+ "kick",
3677
+ "kid",
3678
+ "kidney",
3679
+ "kind",
3680
+ "kingdom",
3681
+ "kiss",
3682
+ "kit",
3683
+ "kitchen",
3684
+ "kite",
3685
+ "kitten",
3686
+ "kiwi",
3687
+ "knee",
3688
+ "knife",
3689
+ "knock",
3690
+ "know",
3691
+ "lab",
3692
+ "label",
3693
+ "labor",
3694
+ "ladder",
3695
+ "lady",
3696
+ "lake",
3697
+ "lamp",
3698
+ "language",
3699
+ "laptop",
3700
+ "large",
3701
+ "later",
3702
+ "latin",
3703
+ "laugh",
3704
+ "laundry",
3705
+ "lava",
3706
+ "law",
3707
+ "lawn",
3708
+ "lawsuit",
3709
+ "layer",
3710
+ "lazy",
3711
+ "leader",
3712
+ "leaf",
3713
+ "learn",
3714
+ "leave",
3715
+ "lecture",
3716
+ "left",
3717
+ "leg",
3718
+ "legal",
3719
+ "legend",
3720
+ "leisure",
3721
+ "lemon",
3722
+ "lend",
3723
+ "length",
3724
+ "lens",
3725
+ "leopard",
3726
+ "lesson",
3727
+ "letter",
3728
+ "level",
3729
+ "liar",
3730
+ "liberty",
3731
+ "library",
3732
+ "license",
3733
+ "life",
3734
+ "lift",
3735
+ "light",
3736
+ "like",
3737
+ "limb",
3738
+ "limit",
3739
+ "link",
3740
+ "lion",
3741
+ "liquid",
3742
+ "list",
3743
+ "little",
3744
+ "live",
3745
+ "lizard",
3746
+ "load",
3747
+ "loan",
3748
+ "lobster",
3749
+ "local",
3750
+ "lock",
3751
+ "logic",
3752
+ "lonely",
3753
+ "long",
3754
+ "loop",
3755
+ "lottery",
3756
+ "loud",
3757
+ "lounge",
3758
+ "love",
3759
+ "loyal",
3760
+ "lucky",
3761
+ "luggage",
3762
+ "lumber",
3763
+ "lunar",
3764
+ "lunch",
3765
+ "luxury",
3766
+ "lyrics",
3767
+ "machine",
3768
+ "mad",
3769
+ "magic",
3770
+ "magnet",
3771
+ "maid",
3772
+ "mail",
3773
+ "main",
3774
+ "major",
3775
+ "make",
3776
+ "mammal",
3777
+ "man",
3778
+ "manage",
3779
+ "mandate",
3780
+ "mango",
3781
+ "mansion",
3782
+ "manual",
3783
+ "maple",
3784
+ "marble",
3785
+ "march",
3786
+ "margin",
3787
+ "marine",
3788
+ "market",
3789
+ "marriage",
3790
+ "mask",
3791
+ "mass",
3792
+ "master",
3793
+ "match",
3794
+ "material",
3795
+ "math",
3796
+ "matrix",
3797
+ "matter",
3798
+ "maximum",
3799
+ "maze",
3800
+ "meadow",
3801
+ "mean",
3802
+ "measure",
3803
+ "meat",
3804
+ "mechanic",
3805
+ "medal",
3806
+ "media",
3807
+ "melody",
3808
+ "melt",
3809
+ "member",
3810
+ "memory",
3811
+ "mention",
3812
+ "menu",
3813
+ "mercy",
3814
+ "merge",
3815
+ "merit",
3816
+ "merry",
3817
+ "mesh",
3818
+ "message",
3819
+ "metal",
3820
+ "method",
3821
+ "middle",
3822
+ "midnight",
3823
+ "milk",
3824
+ "million",
3825
+ "mimic",
3826
+ "mind",
3827
+ "minimum",
3828
+ "minor",
3829
+ "minute",
3830
+ "miracle",
3831
+ "mirror",
3832
+ "misery",
3833
+ "miss",
3834
+ "mistake",
3835
+ "mix",
3836
+ "mixed",
3837
+ "mixture",
3838
+ "mobile",
3839
+ "model",
3840
+ "modify",
3841
+ "mom",
3842
+ "moment",
3843
+ "monitor",
3844
+ "monkey",
3845
+ "monster",
3846
+ "month",
3847
+ "moon",
3848
+ "moral",
3849
+ "more",
3850
+ "morning",
3851
+ "mosquito",
3852
+ "mother",
3853
+ "motion",
3854
+ "motor",
3855
+ "mountain",
3856
+ "mouse",
3857
+ "move",
3858
+ "movie",
3859
+ "much",
3860
+ "muffin",
3861
+ "mule",
3862
+ "multiply",
3863
+ "muscle",
3864
+ "museum",
3865
+ "mushroom",
3866
+ "music",
3867
+ "must",
3868
+ "mutual",
3869
+ "myself",
3870
+ "mystery",
3871
+ "myth",
3872
+ "naive",
3873
+ "name",
3874
+ "napkin",
3875
+ "narrow",
3876
+ "nasty",
3877
+ "nation",
3878
+ "nature",
3879
+ "near",
3880
+ "neck",
3881
+ "need",
3882
+ "negative",
3883
+ "neglect",
3884
+ "neither",
3885
+ "nephew",
3886
+ "nerve",
3887
+ "nest",
3888
+ "net",
3889
+ "network",
3890
+ "neutral",
3891
+ "never",
3892
+ "news",
3893
+ "next",
3894
+ "nice",
3895
+ "night",
3896
+ "noble",
3897
+ "noise",
3898
+ "nominee",
3899
+ "noodle",
3900
+ "normal",
3901
+ "north",
3902
+ "nose",
3903
+ "notable",
3904
+ "note",
3905
+ "nothing",
3906
+ "notice",
3907
+ "novel",
3908
+ "now",
3909
+ "nuclear",
3910
+ "number",
3911
+ "nurse",
3912
+ "nut",
3913
+ "oak",
3914
+ "obey",
3915
+ "object",
3916
+ "oblige",
3917
+ "obscure",
3918
+ "observe",
3919
+ "obtain",
3920
+ "obvious",
3921
+ "occur",
3922
+ "ocean",
3923
+ "october",
3924
+ "odor",
3925
+ "off",
3926
+ "offer",
3927
+ "office",
3928
+ "often",
3929
+ "oil",
3930
+ "okay",
3931
+ "old",
3932
+ "olive",
3933
+ "olympic",
3934
+ "omit",
3935
+ "once",
3936
+ "one",
3937
+ "onion",
3938
+ "online",
3939
+ "only",
3940
+ "open",
3941
+ "opera",
3942
+ "opinion",
3943
+ "oppose",
3944
+ "option",
3945
+ "orange",
3946
+ "orbit",
3947
+ "orchard",
3948
+ "order",
3949
+ "ordinary",
3950
+ "organ",
3951
+ "orient",
3952
+ "original",
3953
+ "orphan",
3954
+ "ostrich",
3955
+ "other",
3956
+ "outdoor",
3957
+ "outer",
3958
+ "output",
3959
+ "outside",
3960
+ "oval",
3961
+ "oven",
3962
+ "over",
3963
+ "own",
3964
+ "owner",
3965
+ "oxygen",
3966
+ "oyster",
3967
+ "ozone",
3968
+ "pact",
3969
+ "paddle",
3970
+ "page",
3971
+ "pair",
3972
+ "palace",
3973
+ "palm",
3974
+ "panda",
3975
+ "panel",
3976
+ "panic",
3977
+ "panther",
3978
+ "paper",
3979
+ "parade",
3980
+ "parent",
3981
+ "park",
3982
+ "parrot",
3983
+ "party",
3984
+ "pass",
3985
+ "patch",
3986
+ "path",
3987
+ "patient",
3988
+ "patrol",
3989
+ "pattern",
3990
+ "pause",
3991
+ "pave",
3992
+ "payment",
3993
+ "peace",
3994
+ "peanut",
3995
+ "pear",
3996
+ "peasant",
3997
+ "pelican",
3998
+ "pen",
3999
+ "penalty",
4000
+ "pencil",
4001
+ "people",
4002
+ "pepper",
4003
+ "perfect",
4004
+ "permit",
4005
+ "person",
4006
+ "pet",
4007
+ "phone",
4008
+ "photo",
4009
+ "phrase",
4010
+ "physical",
4011
+ "piano",
4012
+ "picnic",
4013
+ "picture",
4014
+ "piece",
4015
+ "pig",
4016
+ "pigeon",
4017
+ "pill",
4018
+ "pilot",
4019
+ "pink",
4020
+ "pioneer",
4021
+ "pipe",
4022
+ "pistol",
4023
+ "pitch",
4024
+ "pizza",
4025
+ "place",
4026
+ "planet",
4027
+ "plastic",
4028
+ "plate",
4029
+ "play",
4030
+ "please",
4031
+ "pledge",
4032
+ "pluck",
4033
+ "plug",
4034
+ "plunge",
4035
+ "poem",
4036
+ "poet",
4037
+ "point",
4038
+ "polar",
4039
+ "pole",
4040
+ "police",
4041
+ "pond",
4042
+ "pony",
4043
+ "pool",
4044
+ "popular",
4045
+ "portion",
4046
+ "position",
4047
+ "possible",
4048
+ "post",
4049
+ "potato",
4050
+ "pottery",
4051
+ "poverty",
4052
+ "powder",
4053
+ "power",
4054
+ "practice",
4055
+ "praise",
4056
+ "predict",
4057
+ "prefer",
4058
+ "prepare",
4059
+ "present",
4060
+ "pretty",
4061
+ "prevent",
4062
+ "price",
4063
+ "pride",
4064
+ "primary",
4065
+ "print",
4066
+ "priority",
4067
+ "prison",
4068
+ "private",
4069
+ "prize",
4070
+ "problem",
4071
+ "process",
4072
+ "produce",
4073
+ "profit",
4074
+ "program",
4075
+ "project",
4076
+ "promote",
4077
+ "proof",
4078
+ "property",
4079
+ "prosper",
4080
+ "protect",
4081
+ "proud",
4082
+ "provide",
4083
+ "public",
4084
+ "pudding",
4085
+ "pull",
4086
+ "pulp",
4087
+ "pulse",
4088
+ "pumpkin",
4089
+ "punch",
4090
+ "pupil",
4091
+ "puppy",
4092
+ "purchase",
4093
+ "purity",
4094
+ "purpose",
4095
+ "purse",
4096
+ "push",
4097
+ "put",
4098
+ "puzzle",
4099
+ "pyramid",
4100
+ "quality",
4101
+ "quantum",
4102
+ "quarter",
4103
+ "question",
4104
+ "quick",
4105
+ "quit",
4106
+ "quiz",
4107
+ "quote",
4108
+ "rabbit",
4109
+ "raccoon",
4110
+ "race",
4111
+ "rack",
4112
+ "radar",
4113
+ "radio",
4114
+ "rail",
4115
+ "rain",
4116
+ "raise",
4117
+ "rally",
4118
+ "ramp",
4119
+ "ranch",
4120
+ "random",
4121
+ "range",
4122
+ "rapid",
4123
+ "rare",
4124
+ "rate",
4125
+ "rather",
4126
+ "raven",
4127
+ "raw",
4128
+ "razor",
4129
+ "ready",
4130
+ "real",
4131
+ "reason",
4132
+ "rebel",
4133
+ "rebuild",
4134
+ "recall",
4135
+ "receive",
4136
+ "recipe",
4137
+ "record",
4138
+ "recycle",
4139
+ "reduce",
4140
+ "reflect",
4141
+ "reform",
4142
+ "refuse",
4143
+ "region",
4144
+ "regret",
4145
+ "regular",
4146
+ "reject",
4147
+ "relax",
4148
+ "release",
4149
+ "relief",
4150
+ "rely",
4151
+ "remain",
4152
+ "remember",
4153
+ "remind",
4154
+ "remove",
4155
+ "render",
4156
+ "renew",
4157
+ "rent",
4158
+ "reopen",
4159
+ "repair",
4160
+ "repeat",
4161
+ "replace",
4162
+ "report",
4163
+ "require",
4164
+ "rescue",
4165
+ "resemble",
4166
+ "resist",
4167
+ "resource",
4168
+ "response",
4169
+ "result",
4170
+ "retire",
4171
+ "retreat",
4172
+ "return",
4173
+ "reunion",
4174
+ "reveal",
4175
+ "review",
4176
+ "reward",
4177
+ "rhythm",
4178
+ "rib",
4179
+ "ribbon",
4180
+ "rice",
4181
+ "rich",
4182
+ "ride",
4183
+ "ridge",
4184
+ "rifle",
4185
+ "right",
4186
+ "rigid",
4187
+ "ring",
4188
+ "riot",
4189
+ "ripple",
4190
+ "risk",
4191
+ "ritual",
4192
+ "rival",
4193
+ "river",
4194
+ "road",
4195
+ "roast",
4196
+ "robot",
4197
+ "robust",
4198
+ "rocket",
4199
+ "romance",
4200
+ "roof",
4201
+ "rookie",
4202
+ "room",
4203
+ "rose",
4204
+ "rotate",
4205
+ "rough",
4206
+ "round",
4207
+ "route",
4208
+ "royal",
4209
+ "rubber",
4210
+ "rude",
4211
+ "rug",
4212
+ "rule",
4213
+ "run",
4214
+ "runway",
4215
+ "rural",
4216
+ "sad",
4217
+ "saddle",
4218
+ "sadness",
4219
+ "safe",
4220
+ "sail",
4221
+ "salad",
4222
+ "salmon",
4223
+ "salon",
4224
+ "salt",
4225
+ "salute",
4226
+ "same",
4227
+ "sample",
4228
+ "sand",
4229
+ "satisfy",
4230
+ "satoshi",
4231
+ "sauce",
4232
+ "sausage",
4233
+ "save",
4234
+ "say",
4235
+ "scale",
4236
+ "scan",
4237
+ "scare",
4238
+ "scatter",
4239
+ "scene",
4240
+ "scheme",
4241
+ "school",
4242
+ "science",
4243
+ "scissors",
4244
+ "scorpion",
4245
+ "scout",
4246
+ "scrap",
4247
+ "screen",
4248
+ "script",
4249
+ "scrub",
4250
+ "sea",
4251
+ "search",
4252
+ "season",
4253
+ "seat",
4254
+ "second",
4255
+ "secret",
4256
+ "section",
4257
+ "security",
4258
+ "seed",
4259
+ "seek",
4260
+ "segment",
4261
+ "select",
4262
+ "sell",
4263
+ "seminar",
4264
+ "senior",
4265
+ "sense",
4266
+ "sentence",
4267
+ "series",
4268
+ "service",
4269
+ "session",
4270
+ "settle",
4271
+ "setup",
4272
+ "seven",
4273
+ "shadow",
4274
+ "shaft",
4275
+ "shallow",
4276
+ "share",
4277
+ "shed",
4278
+ "shell",
4279
+ "sheriff",
4280
+ "shield",
4281
+ "shift",
4282
+ "shine",
4283
+ "ship",
4284
+ "shiver",
4285
+ "shock",
4286
+ "shoe",
4287
+ "shoot",
4288
+ "shop",
4289
+ "short",
4290
+ "shoulder",
4291
+ "shove",
4292
+ "shrimp",
4293
+ "shrug",
4294
+ "shuffle",
4295
+ "shy",
4296
+ "sibling",
4297
+ "sick",
4298
+ "side",
4299
+ "siege",
4300
+ "sight",
4301
+ "sign",
4302
+ "silent",
4303
+ "silk",
4304
+ "silly",
4305
+ "silver",
4306
+ "similar",
4307
+ "simple",
4308
+ "since",
4309
+ "sing",
4310
+ "siren",
4311
+ "sister",
4312
+ "situate",
4313
+ "six",
4314
+ "size",
4315
+ "skate",
4316
+ "sketch",
4317
+ "ski",
4318
+ "skill",
4319
+ "skin",
4320
+ "skirt",
4321
+ "skull",
4322
+ "slab",
4323
+ "slam",
4324
+ "sleep",
4325
+ "slender",
4326
+ "slice",
4327
+ "slide",
4328
+ "slight",
4329
+ "slim",
4330
+ "slogan",
4331
+ "slot",
4332
+ "slow",
4333
+ "slush",
4334
+ "small",
4335
+ "smart",
4336
+ "smile",
4337
+ "smoke",
4338
+ "smooth",
4339
+ "snack",
4340
+ "snake",
4341
+ "snap",
4342
+ "sniff",
4343
+ "snow",
4344
+ "soap",
4345
+ "soccer",
4346
+ "social",
4347
+ "sock",
4348
+ "soda",
4349
+ "soft",
4350
+ "solar",
4351
+ "soldier",
4352
+ "solid",
4353
+ "solution",
4354
+ "solve",
4355
+ "someone",
4356
+ "song",
4357
+ "soon",
4358
+ "sorry",
4359
+ "sort",
4360
+ "soul",
4361
+ "sound",
4362
+ "soup",
4363
+ "source",
4364
+ "south",
4365
+ "space",
4366
+ "spare",
4367
+ "spatial",
4368
+ "spawn",
4369
+ "speak",
4370
+ "special",
4371
+ "speed",
4372
+ "spell",
4373
+ "spend",
4374
+ "sphere",
4375
+ "spice",
4376
+ "spider",
4377
+ "spike",
4378
+ "spin",
4379
+ "spirit",
4380
+ "split",
4381
+ "spoil",
4382
+ "sponsor",
4383
+ "spoon",
4384
+ "sport",
4385
+ "spot",
4386
+ "spray",
4387
+ "spread",
4388
+ "spring",
4389
+ "spy",
4390
+ "square",
4391
+ "squeeze",
4392
+ "squirrel",
4393
+ "stable",
4394
+ "stadium",
4395
+ "staff",
4396
+ "stage",
4397
+ "stairs",
4398
+ "stamp",
4399
+ "stand",
4400
+ "start",
4401
+ "state",
4402
+ "stay",
4403
+ "steak",
4404
+ "steel",
4405
+ "stem",
4406
+ "step",
4407
+ "stereo",
4408
+ "stick",
4409
+ "still",
4410
+ "sting",
4411
+ "stock",
4412
+ "stomach",
4413
+ "stone",
4414
+ "stool",
4415
+ "story",
4416
+ "stove",
4417
+ "strategy",
4418
+ "street",
4419
+ "strike",
4420
+ "strong",
4421
+ "struggle",
4422
+ "student",
4423
+ "stuff",
4424
+ "stumble",
4425
+ "style",
4426
+ "subject",
4427
+ "submit",
4428
+ "subway",
4429
+ "success",
4430
+ "such",
4431
+ "sudden",
4432
+ "suffer",
4433
+ "sugar",
4434
+ "suggest",
4435
+ "suit",
4436
+ "summer",
4437
+ "sun",
4438
+ "sunny",
4439
+ "sunset",
4440
+ "super",
4441
+ "supply",
4442
+ "supreme",
4443
+ "sure",
4444
+ "surface",
4445
+ "surge",
4446
+ "surprise",
4447
+ "surround",
4448
+ "survey",
4449
+ "suspect",
4450
+ "sustain",
4451
+ "swallow",
4452
+ "swamp",
4453
+ "swap",
4454
+ "swarm",
4455
+ "swear",
4456
+ "sweet",
4457
+ "swift",
4458
+ "swim",
4459
+ "swing",
4460
+ "switch",
4461
+ "sword",
4462
+ "symbol",
4463
+ "symptom",
4464
+ "syrup",
4465
+ "system",
4466
+ "table",
4467
+ "tackle",
4468
+ "tag",
4469
+ "tail",
4470
+ "talent",
4471
+ "talk",
4472
+ "tank",
4473
+ "tape",
4474
+ "target",
4475
+ "task",
4476
+ "taste",
4477
+ "tattoo",
4478
+ "taxi",
4479
+ "teach",
4480
+ "team",
4481
+ "tell",
4482
+ "ten",
4483
+ "tenant",
4484
+ "tennis",
4485
+ "tent",
4486
+ "term",
4487
+ "test",
4488
+ "text",
4489
+ "thank",
4490
+ "that",
4491
+ "theme",
4492
+ "then",
4493
+ "theory",
4494
+ "there",
4495
+ "they",
4496
+ "thing",
4497
+ "this",
4498
+ "thought",
4499
+ "three",
4500
+ "thrive",
4501
+ "throw",
4502
+ "thumb",
4503
+ "thunder",
4504
+ "ticket",
4505
+ "tide",
4506
+ "tiger",
4507
+ "tilt",
4508
+ "timber",
4509
+ "time",
4510
+ "tiny",
4511
+ "tip",
4512
+ "tired",
4513
+ "tissue",
4514
+ "title",
4515
+ "toast",
4516
+ "tobacco",
4517
+ "today",
4518
+ "toddler",
4519
+ "toe",
4520
+ "together",
4521
+ "toilet",
4522
+ "token",
4523
+ "tomato",
4524
+ "tomorrow",
4525
+ "tone",
4526
+ "tongue",
4527
+ "tonight",
4528
+ "tool",
4529
+ "tooth",
4530
+ "top",
4531
+ "topic",
4532
+ "topple",
4533
+ "torch",
4534
+ "tornado",
4535
+ "tortoise",
4536
+ "toss",
4537
+ "total",
4538
+ "tourist",
4539
+ "toward",
4540
+ "tower",
4541
+ "town",
4542
+ "toy",
4543
+ "track",
4544
+ "trade",
4545
+ "traffic",
4546
+ "tragic",
4547
+ "train",
4548
+ "transfer",
4549
+ "trap",
4550
+ "trash",
4551
+ "travel",
4552
+ "tray",
4553
+ "treat",
4554
+ "tree",
4555
+ "trend",
4556
+ "trial",
4557
+ "tribe",
4558
+ "trick",
4559
+ "trigger",
4560
+ "trim",
4561
+ "trip",
4562
+ "trophy",
4563
+ "trouble",
4564
+ "truck",
4565
+ "true",
4566
+ "truly",
4567
+ "trumpet",
4568
+ "trust",
4569
+ "truth",
4570
+ "try",
4571
+ "tube",
4572
+ "tuition",
4573
+ "tumble",
4574
+ "tuna",
4575
+ "tunnel",
4576
+ "turkey",
4577
+ "turn",
4578
+ "turtle",
4579
+ "twelve",
4580
+ "twenty",
4581
+ "twice",
4582
+ "twin",
4583
+ "twist",
4584
+ "two",
4585
+ "type",
4586
+ "typical",
4587
+ "ugly",
4588
+ "umbrella",
4589
+ "unable",
4590
+ "unaware",
4591
+ "uncle",
4592
+ "uncover",
4593
+ "under",
4594
+ "undo",
4595
+ "unfair",
4596
+ "unfold",
4597
+ "unhappy",
4598
+ "uniform",
4599
+ "unique",
4600
+ "unit",
4601
+ "universe",
4602
+ "unknown",
4603
+ "unlock",
4604
+ "until",
4605
+ "unusual",
4606
+ "unveil",
4607
+ "update",
4608
+ "upgrade",
4609
+ "uphold",
4610
+ "upon",
4611
+ "upper",
4612
+ "upset",
4613
+ "urban",
4614
+ "urge",
4615
+ "usage",
4616
+ "use",
4617
+ "used",
4618
+ "useful",
4619
+ "useless",
4620
+ "usual",
4621
+ "utility",
4622
+ "vacant",
4623
+ "vacuum",
4624
+ "vague",
4625
+ "valid",
4626
+ "valley",
4627
+ "valve",
4628
+ "van",
4629
+ "vanish",
4630
+ "vapor",
4631
+ "various",
4632
+ "vast",
4633
+ "vault",
4634
+ "vehicle",
4635
+ "velvet",
4636
+ "vendor",
4637
+ "venture",
4638
+ "venue",
4639
+ "verb",
4640
+ "verify",
4641
+ "version",
4642
+ "very",
4643
+ "vessel",
4644
+ "veteran",
4645
+ "viable",
4646
+ "vibrant",
4647
+ "vicious",
4648
+ "victory",
4649
+ "video",
4650
+ "view",
4651
+ "village",
4652
+ "vintage",
4653
+ "violin",
4654
+ "virtual",
4655
+ "virus",
4656
+ "visa",
4657
+ "visit",
4658
+ "visual",
4659
+ "vital",
4660
+ "vivid",
4661
+ "vocal",
4662
+ "voice",
4663
+ "void",
4664
+ "volcano",
4665
+ "volume",
4666
+ "vote",
4667
+ "voyage",
4668
+ "wage",
4669
+ "wagon",
4670
+ "wait",
4671
+ "walk",
4672
+ "wall",
4673
+ "walnut",
4674
+ "want",
4675
+ "warfare",
4676
+ "warm",
4677
+ "warrior",
4678
+ "wash",
4679
+ "wasp",
4680
+ "waste",
4681
+ "water",
4682
+ "wave",
4683
+ "way",
4684
+ "wealth",
4685
+ "weapon",
4686
+ "wear",
4687
+ "weasel",
4688
+ "weather",
4689
+ "web",
4690
+ "wedding",
4691
+ "weekend",
4692
+ "weird",
4693
+ "welcome",
4694
+ "west",
4695
+ "wet",
4696
+ "whale",
4697
+ "what",
4698
+ "wheat",
4699
+ "wheel",
4700
+ "when",
4701
+ "where",
4702
+ "whip",
4703
+ "whisper",
4704
+ "wide",
4705
+ "width",
4706
+ "wife",
4707
+ "wild",
4708
+ "will",
4709
+ "win",
4710
+ "window",
4711
+ "wine",
4712
+ "wing",
4713
+ "wink",
4714
+ "winner",
4715
+ "winter",
4716
+ "wire",
4717
+ "wisdom",
4718
+ "wise",
4719
+ "wish",
4720
+ "witness",
4721
+ "wolf",
4722
+ "woman",
4723
+ "wonder",
4724
+ "wood",
4725
+ "wool",
4726
+ "word",
4727
+ "work",
4728
+ "world",
4729
+ "worry",
4730
+ "worth",
4731
+ "wrap",
4732
+ "wreck",
4733
+ "wrestle",
4734
+ "wrist",
4735
+ "write",
4736
+ "wrong",
4737
+ "yard",
4738
+ "year",
4739
+ "yellow",
4740
+ "you",
4741
+ "young",
4742
+ "youth",
4743
+ "zebra",
4744
+ "zero",
4745
+ "zone",
4746
+ "zoo"
4747
+ ];
4748
+
4749
+ // src/account/account.ts
4750
+ var ACCOUNT_LINK_DOMAIN = new TextEncoder().encode(
4751
+ "calimero.mdma.account-link.v1\0"
4752
+ );
4753
+ var ENTROPY_BITS = 256;
4754
+ var CHECKSUM_BITS = ENTROPY_BITS / 32;
4755
+ var PHRASE_WORDS = (ENTROPY_BITS + CHECKSUM_BITS) / 11;
4756
+ async function generateAccountRoot() {
4757
+ const entropy = crypto.getRandomValues(new Uint8Array(ENTROPY_BITS / 8));
4758
+ return withPhrase(hex(entropy), await encodePhrase(entropy));
4759
+ }
4760
+ async function accountRootFromPhrase(phrase) {
4761
+ const words = normalisePhrase(phrase);
4762
+ return withPhrase(hex(await decodePhrase(words)), words.join(" "));
4763
+ }
4764
+ async function accountRootFromSecret(secret) {
4765
+ fromHex(secret, "secret", 32);
4766
+ return {
4767
+ secret,
4768
+ publicKey: hex(await derivePublicKey(secret)),
4769
+ accountId: await accountForRoot(secret)
4770
+ };
4771
+ }
4772
+ async function signAccountLink(input) {
4773
+ if (!input.nonce) throw new Error("nonce is required to sign an account link");
4774
+ const key = await importSigningKey(input.rootSecret);
4775
+ const signature = new Uint8Array(
4776
+ await crypto.subtle.sign(
4777
+ "Ed25519",
4778
+ key,
4779
+ concat(ACCOUNT_LINK_DOMAIN, new TextEncoder().encode(input.nonce))
4780
+ )
4781
+ );
4782
+ return base64(signature);
4783
+ }
4784
+ async function withPhrase(secret, phrase) {
4785
+ return { ...await accountRootFromSecret(secret), phrase };
4786
+ }
4787
+ function normalisePhrase(phrase) {
4788
+ const words = phrase.normalize("NFKD").toLowerCase().trim().split(/\s+/);
4789
+ const count = words[0] === "" ? 0 : words.length;
4790
+ if (count !== PHRASE_WORDS) {
4791
+ throw new Error(
4792
+ `recovery phrase must be ${PHRASE_WORDS} words, got ${count}`
4793
+ );
4794
+ }
4795
+ return words;
4796
+ }
4797
+ async function encodePhrase(entropy) {
4798
+ const bits = bitsOf(entropy) + await checksumBits(entropy);
4799
+ const words = [];
4800
+ for (let i = 0; i < PHRASE_WORDS; i += 1) {
4801
+ const index = Number.parseInt(bits.slice(i * 11, i * 11 + 11), 2);
4802
+ words.push(ENGLISH_WORDLIST[index]);
4803
+ }
4804
+ return words.join(" ");
4805
+ }
4806
+ async function decodePhrase(words) {
4807
+ let bits = "";
4808
+ for (const word of words) {
4809
+ const index = ENGLISH_WORDLIST.indexOf(word);
4810
+ if (index < 0) {
4811
+ throw new Error(`"${word}" is not a word in the recovery phrase list`);
4812
+ }
4813
+ bits += index.toString(2).padStart(11, "0");
4814
+ }
4815
+ const entropy = new Uint8Array(ENTROPY_BITS / 8);
4816
+ for (let i = 0; i < entropy.length; i += 1) {
4817
+ entropy[i] = Number.parseInt(bits.slice(i * 8, i * 8 + 8), 2);
4818
+ }
4819
+ if (bits.slice(ENTROPY_BITS) !== await checksumBits(entropy)) {
4820
+ throw new Error(
4821
+ "recovery phrase checksum failed \u2014 check for a mistyped or transposed word"
4822
+ );
4823
+ }
4824
+ return entropy;
4825
+ }
4826
+ async function checksumBits(entropy) {
4827
+ const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", entropy));
4828
+ return bitsOf(digest).slice(0, CHECKSUM_BITS);
4829
+ }
4830
+ function bitsOf(bytes) {
4831
+ let bits = "";
4832
+ for (const byte of bytes) bits += byte.toString(2).padStart(8, "0");
4833
+ return bits;
4834
+ }
4835
+ function base64(bytes) {
4836
+ let binary = "";
4837
+ for (const byte of bytes) binary += String.fromCharCode(byte);
4838
+ return btoa(binary);
4839
+ }
4840
+
2403
4841
  // src/cloud/cloud-client.ts
2404
4842
  var DEFAULT_CLOUD_BASE_URL = "https://cloud.calimero.network";
2405
4843
  var REFRESH_HEADER = "x-mdma-session-refresh";
@@ -2517,6 +4955,65 @@ var CloudClient = class {
2517
4955
  const relays = await this.getNamespaceRelays(namespaceId);
2518
4956
  return relays.find((r) => r.authorshipReady && r.relayUrl !== null && r.executorAccount !== null) ?? null;
2519
4957
  }
4958
+ /**
4959
+ * Where to reach a namespace without owning it: one read, both verbs.
4960
+ *
4961
+ * **Anonymous.** A joiner is by construction not the namespace owner and holds
4962
+ * no cloud session — needing one is exactly what this path exists to avoid.
4963
+ * Discovery is not authorization: merod refuses an `/admit` call unless the
4964
+ * relaying node's account is on the invitation's signed `admitters` list, and
4965
+ * refuses an intent unless the warrant is genuinely the member's, so naming a
4966
+ * node grants the caller nothing it did not already have.
4967
+ *
4968
+ * A keyholder resolves a namespace to a node ONCE and then admits, reads and
4969
+ * posts intents against that same node, which is why admission and writability
4970
+ * are answered together rather than across two endpoints — the per-context
4971
+ * read needs a context id a joiner does not yet have.
4972
+ *
4973
+ * An empty `nodes` list is a state, not an error: a namespace with no fleet
4974
+ * assignment has no cloud node, and the joiner must use one of the
4975
+ * invitation's other admitters — another admin's node, or a self-hosted peer.
4976
+ */
4977
+ async getNamespaceRouting(namespaceId) {
4978
+ const body = await this.request("GET", `/api/cloud/namespaces/${encodeURIComponent(namespaceId)}/admitters`, {
4979
+ anonymous: true
4980
+ });
4981
+ return {
4982
+ namespaceId: String(body.namespace_id ?? namespaceId),
4983
+ nodes: (body.admitters ?? []).map((row) => ({
4984
+ peerId: String(row.peer_id ?? ""),
4985
+ account: row.account ?? null,
4986
+ relayUrl: row.relay_url ?? null,
4987
+ admitUrl: row.admit_url ?? null,
4988
+ status: String(row.status ?? ""),
4989
+ fresh: row.fresh === true,
4990
+ canAdmit: row.can_admit === true,
4991
+ authorshipReady: row.authorship_ready === true,
4992
+ canExecute: row.can_execute === true
4993
+ })),
4994
+ servable: body.servable === true,
4995
+ writable: body.writable === true
4996
+ };
4997
+ }
4998
+ /**
4999
+ * The node to send a signed join to, chosen from those an invitation names.
5000
+ *
5001
+ * Pass the invitation's `admitters` and the intersection is done here, because
5002
+ * skipping it is the failure this method exists to prevent: the cloud lists
5003
+ * every node assigned to the namespace, while `admitters` is a snapshot signed
5004
+ * when the invitation was minted. A node added afterwards looks perfect in
5005
+ * every field here and answers 403.
5006
+ *
5007
+ * Omit `admitters` only for an invitation that names none — an empty list on
5008
+ * the wire authorises any node to admit.
5009
+ */
5010
+ async findAdmitter(namespaceId, admitters) {
5011
+ const { nodes } = await this.getNamespaceRouting(namespaceId);
5012
+ const allowed = admitters && admitters.length > 0 ? new Set(admitters.map((a) => a.toLowerCase())) : null;
5013
+ return nodes.find(
5014
+ (n) => n.canAdmit && (allowed === null || n.account !== null && allowed.has(n.account.toLowerCase()))
5015
+ ) ?? null;
5016
+ }
2520
5017
  /**
2521
5018
  * Every attested machine currently serving something this account owns.
2522
5019
  *
@@ -2643,6 +5140,93 @@ var CloudClient = class {
2643
5140
  window.open(`${this.baseUrl}/disable-ha?${params.toString()}`);
2644
5141
  }
2645
5142
  /** Record a freshly-issued session and tell the app to persist it. */
5143
+ /**
5144
+ * Link a Calimero account to this cloud login, proving possession of its root.
5145
+ *
5146
+ * Two hops, folded into one call because they are useless apart: fetch a
5147
+ * single-use challenge, then sign it with the account root and post the proof.
5148
+ * The secret never leaves this process — only a signature over a nonce the
5149
+ * cloud minted does.
5150
+ *
5151
+ * This is the binding the cloud bills against. A relay does not need it to run
5152
+ * an intent; the cloud needs it to know whose plan a hosted node is spending,
5153
+ * and to sign that account back in later.
5154
+ *
5155
+ * @param rootSecret the account root's signing secret, 64 hex — from
5156
+ * {@link generateAccountRoot}, from a restored recovery phrase, or from a
5157
+ * desktop app or hardware key that already holds one.
5158
+ *
5159
+ * Idempotent for the same login. An account already linked to a *different*
5160
+ * cloud login is a `409`; a replayed or expired challenge is a `403`; and
5161
+ * exceeding the plan's account limit is a `402`.
5162
+ */
5163
+ async linkAccount(rootSecret) {
5164
+ const root = await accountRootFromSecret(rootSecret);
5165
+ const { nonce } = await this.getAccountLinkChallenge();
5166
+ return this.submitAccountLink({
5167
+ accountId: root.accountId,
5168
+ rootPublicKey: root.publicKey,
5169
+ nonce,
5170
+ signature: await signAccountLink({ rootSecret, nonce })
5171
+ });
5172
+ }
5173
+ /**
5174
+ * Mint a single-use challenge for an account root to sign.
5175
+ *
5176
+ * The split half of {@link linkAccount}, for the case that call cannot serve:
5177
+ * a root held by a desktop app, a hardware key or an air-gapped machine, which
5178
+ * signs without the secret ever reaching this process. Fetch the challenge
5179
+ * here, have the holder sign it, then hand the proof to
5180
+ * {@link submitAccountLink}.
5181
+ *
5182
+ * Bound to the signed-in login and short-lived, so it is not a standing
5183
+ * capability if it leaks — but it IS single-use, so a challenge fetched and
5184
+ * abandoned is spent.
5185
+ */
5186
+ async getAccountLinkChallenge() {
5187
+ const body = await this.request("GET", "/api/cloud/me/accounts/challenge");
5188
+ return { nonce: body.nonce, expiresAtMs: body.expires_at_ms ?? null };
5189
+ }
5190
+ /**
5191
+ * Post a proof assembled elsewhere. The other half of
5192
+ * {@link getAccountLinkChallenge}.
5193
+ *
5194
+ * `accountId` must be the account `rootPublicKey` names — the cloud refuses a
5195
+ * valid signature by a key that names a different account, or a caller could
5196
+ * prove one root and link somebody else's account. Derive both from the same
5197
+ * key rather than letting a user type either.
5198
+ */
5199
+ async submitAccountLink(proof) {
5200
+ const body = await this.request(
5201
+ "POST",
5202
+ "/api/cloud/me/accounts",
5203
+ {
5204
+ body: {
5205
+ account_id: proof.accountId,
5206
+ root_public_key: proof.rootPublicKey,
5207
+ nonce: proof.nonce,
5208
+ signature: proof.signature
5209
+ }
5210
+ }
5211
+ );
5212
+ return {
5213
+ accountId: String(body.account_id ?? proof.accountId),
5214
+ linkedAt: body.linked_at ?? null,
5215
+ alreadyLinked: body.already_linked === true
5216
+ };
5217
+ }
5218
+ /** The accounts linked to this login, and how many the plan allows. */
5219
+ async getMyAccounts() {
5220
+ const body = await this.request("GET", "/api/cloud/me/accounts");
5221
+ return {
5222
+ accounts: (body.accounts ?? []).map((row) => ({
5223
+ accountId: String(row.account_id ?? ""),
5224
+ linkedAt: row.linked_at ?? null,
5225
+ hasRecoveryEnvelope: row.has_recovery_envelope === true
5226
+ })),
5227
+ limit: body.limit ?? null
5228
+ };
5229
+ }
2646
5230
  adoptSession(body) {
2647
5231
  this.session = {
2648
5232
  sessionToken: body.session_token,
@@ -3122,105 +5706,6 @@ var LocalStorageTokenStore = class {
3122
5706
  }
3123
5707
  };
3124
5708
 
3125
- // src/crypto/internal.ts
3126
- var PKCS8_ED25519_PREFIX = new Uint8Array([
3127
- 48,
3128
- 46,
3129
- 2,
3130
- 1,
3131
- 0,
3132
- 48,
3133
- 5,
3134
- 6,
3135
- 3,
3136
- 43,
3137
- 101,
3138
- 112,
3139
- 4,
3140
- 34,
3141
- 4,
3142
- 32
3143
- ]);
3144
- function u32le(value) {
3145
- const out = new Uint8Array(4);
3146
- new DataView(out.buffer).setUint32(0, value, true);
3147
- return out;
3148
- }
3149
- function hex(bytes) {
3150
- return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
3151
- }
3152
- function fromHex(value, label, expectedBytes) {
3153
- const clean = value.trim();
3154
- if (!/^[0-9a-fA-F]*$/.test(clean) || clean.length !== expectedBytes * 2) {
3155
- throw new Error(
3156
- `${label} must be ${expectedBytes * 2} hex characters, got ${clean.length}`
3157
- );
3158
- }
3159
- const bytes = new Uint8Array(expectedBytes);
3160
- for (let i = 0; i < expectedBytes; i += 1) {
3161
- bytes[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
3162
- }
3163
- return bytes;
3164
- }
3165
- function u64le(value) {
3166
- const out = new Uint8Array(8);
3167
- new DataView(out.buffer).setBigUint64(0, BigInt(value), true);
3168
- return out;
3169
- }
3170
- function concat(...parts) {
3171
- const out = new Uint8Array(parts.reduce((total, p) => total + p.length, 0));
3172
- let offset = 0;
3173
- for (const part of parts) {
3174
- out.set(part, offset);
3175
- offset += part.length;
3176
- }
3177
- return out;
3178
- }
3179
- async function domainHash(domain, parts) {
3180
- const chunks = [u64le(domain.length), domain];
3181
- for (const part of parts) {
3182
- chunks.push(u64le(part.length), part);
3183
- }
3184
- return new Uint8Array(
3185
- await crypto.subtle.digest("SHA-256", concat(...chunks))
3186
- );
3187
- }
3188
- async function importSigningKey(secretHex) {
3189
- const seed = fromHex(secretHex, "deviceSecret", 32);
3190
- const pkcs8 = concat(PKCS8_ED25519_PREFIX, seed);
3191
- try {
3192
- return await crypto.subtle.importKey(
3193
- "pkcs8",
3194
- pkcs8,
3195
- { name: "Ed25519" },
3196
- false,
3197
- ["sign"]
3198
- );
3199
- } catch (cause) {
3200
- const detail = cause instanceof Error ? `: ${cause.message}` : "";
3201
- throw new Error(
3202
- "this runtime has no WebCrypto Ed25519, so a warrant cannot be signed here. Node 18.4+, Safari 17+, Firefox 129+ and Chrome 137+ have it; otherwise mint the warrant with `merod account warrant`" + detail
3203
- );
3204
- }
3205
- }
3206
- async function derivePublicKey(secretHex) {
3207
- const seed = fromHex(secretHex, "deviceSecret", 32);
3208
- const pkcs8 = concat(PKCS8_ED25519_PREFIX, seed);
3209
- const key = await crypto.subtle.importKey(
3210
- "pkcs8",
3211
- pkcs8,
3212
- { name: "Ed25519" },
3213
- true,
3214
- ["sign"]
3215
- );
3216
- const jwk = await crypto.subtle.exportKey("jwk", key);
3217
- const raw = jwk.x;
3218
- return Uint8Array.from(
3219
- atob(raw.replace(/-/g, "+").replace(/_/g, "/")),
3220
- (c) => c.charCodeAt(0)
3221
- );
3222
- }
3223
-
3224
5709
  // src/warrant/warrant.ts
3225
5710
  var SIGN_DOMAIN = new TextEncoder().encode("calimero.warrant.v2");
3226
5711
  var INTENT_DOMAIN = new TextEncoder().encode("calimero.warrant.intent.v1");
@@ -3521,7 +6006,7 @@ function explainNoRelay(namespace, relays) {
3521
6006
  }
3522
6007
  const waitingOnGrant = relays.filter((r) => !r.authorshipReady);
3523
6008
  if (waitingOnGrant.length === relays.length) {
3524
- return `every relay on namespace ${namespace.namespaceId} is waiting for the authorship grant: an admin of the namespace must grant CAN_AUTHOR_ON_BEHALF to ${waitingOnGrant.map((r) => r.executorAccount ?? r.peerId).join(", ") || "the relay account"}`;
6009
+ return `every relay on namespace ${namespace.namespaceId} is waiting for the authorship grant: an admin of the namespace must grant CAN_AUTHOR_ON_BEHALF to ${waitingOnGrant.map((r) => r.executorAccount ?? r.peerId).join(", ") || "the relay account"} \u2014 with AdminClient.grantAuthorship(namespaceId, account) for these relays, and AdminClient.openToDelegatedExecution(namespaceId) so relays assigned later need no further op`;
3525
6010
  }
3526
6011
  return `namespace ${namespace.namespaceId} has ${relays.length} relay(s), but none reported both a URL and an executor account yet \u2014 retry shortly`;
3527
6012
  }
@@ -3534,83 +6019,6 @@ async function defaultNonceSource(deviceSecret) {
3534
6019
  }
3535
6020
  }
3536
6021
 
3537
- // src/device-cert/device-cert.ts
3538
- var CERT_DOMAIN = new TextEncoder().encode("calimero.device.cert.v1");
3539
- var ACCOUNT_ID_DOMAIN = new TextEncoder().encode("calimero.account.genesis.v1");
3540
- var DEVICE_ID_DOMAIN = new TextEncoder().encode("calimero.device.id.v1");
3541
- var ACCOUNT_GENESIS_VERSION = 2;
3542
- async function mintDeviceId(account, nonce) {
3543
- if (nonce.length !== 16) {
3544
- throw new Error(`nonce must be 16 bytes, got ${nonce.length}`);
3545
- }
3546
- const accountBytes = fromHex(account, "account", 32);
3547
- return hex(await domainHash(DEVICE_ID_DOMAIN, [accountBytes, nonce]));
3548
- }
3549
- async function deviceCertPayload(input) {
3550
- return domainHash(CERT_DOMAIN, [
3551
- fromHex(input.account, "account", 32),
3552
- fromHex(input.device, "device", 32),
3553
- fromHex(input.signPublicKey, "signPublicKey", 32),
3554
- fromHex(input.kemPublicKey, "kemPublicKey", 32),
3555
- u32le(input.keyEpoch),
3556
- u32le(input.deviceEpoch)
3557
- ]);
3558
- }
3559
- function accountProofBytes(input) {
3560
- return concat(
3561
- new Uint8Array([ACCOUNT_GENESIS_VERSION]),
3562
- input.rootPublicKey,
3563
- u32le(0),
3564
- fromHex(input.account, "account", 32),
3565
- fromHex(input.device, "device", 32),
3566
- fromHex(input.signPublicKey, "signPublicKey", 32),
3567
- fromHex(input.kemPublicKey, "kemPublicKey", 32),
3568
- u32le(input.keyEpoch),
3569
- u32le(input.deviceEpoch),
3570
- input.signature
3571
- );
3572
- }
3573
- async function signDeviceCert(input) {
3574
- const rootPublicKey = await derivePublicKey(input.rootSecret);
3575
- const account = hex(
3576
- await domainHash(ACCOUNT_ID_DOMAIN, [
3577
- concat(new Uint8Array([ACCOUNT_GENESIS_VERSION]), rootPublicKey)
3578
- ])
3579
- );
3580
- const keyEpoch = 0;
3581
- const payload = await deviceCertPayload({
3582
- account,
3583
- device: input.device,
3584
- signPublicKey: input.signPublicKey,
3585
- kemPublicKey: input.kemPublicKey,
3586
- keyEpoch,
3587
- deviceEpoch: input.deviceEpoch
3588
- });
3589
- const key = await importSigningKey(input.rootSecret);
3590
- const signature = new Uint8Array(
3591
- await crypto.subtle.sign("Ed25519", key, payload)
3592
- );
3593
- const credential = accountProofBytes({
3594
- rootPublicKey,
3595
- account,
3596
- device: input.device,
3597
- signPublicKey: input.signPublicKey,
3598
- kemPublicKey: input.kemPublicKey,
3599
- keyEpoch,
3600
- deviceEpoch: input.deviceEpoch,
3601
- signature
3602
- });
3603
- return hex(credential);
3604
- }
3605
- async function accountForRoot(rootSecret) {
3606
- const rootPublicKey = await derivePublicKey(rootSecret);
3607
- return hex(
3608
- await domainHash(ACCOUNT_ID_DOMAIN, [
3609
- concat(new Uint8Array([ACCOUNT_GENESIS_VERSION]), rootPublicKey)
3610
- ])
3611
- );
3612
- }
3613
-
3614
6022
  // src/namespace-op/namespace-op.ts
3615
6023
  var SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 8;
3616
6024
  var NAMESPACE_SIGN_DOMAIN = new TextEncoder().encode("calimero.namespace.v1");
@@ -3885,41 +6293,6 @@ async function login(config) {
3885
6293
  };
3886
6294
  }
3887
6295
 
3888
- // src/capabilities.ts
3889
- var CAPABILITIES = {
3890
- CAN_CREATE_CONTEXT: 1 << 0,
3891
- CAN_INVITE_MEMBERS: 1 << 1,
3892
- CAN_JOIN_OPEN_SUBGROUPS: 1 << 2,
3893
- MANAGE_MEMBERS: 1 << 3,
3894
- MANAGE_APPLICATION: 1 << 4,
3895
- CAN_CREATE_SUBGROUP: 1 << 5,
3896
- CAN_DELETE_SUBGROUP: 1 << 6,
3897
- CAN_MANAGE_VISIBILITY: 1 << 7,
3898
- CAN_MANAGE_METADATA: 1 << 8,
3899
- /**
3900
- * Publish writes attributed to ANOTHER member, under a warrant that member
3901
- * signed — the grant delegated execution runs on.
3902
- *
3903
- * Implied by nothing: not by membership, not by admin, and not propagated by
3904
- * the subgroup-admit cascade. So every group is authorship-closed until an
3905
- * admin sets this bit, and a relay without it is refused at
3906
- * `performIntent` before anything executes. That is why it is worth naming
3907
- * here rather than leaving callers to write `1 << 9`: a client granting it
3908
- * has to be able to say what it is granting.
3909
- */
3910
- CAN_AUTHOR_ON_BEHALF: 1 << 9
3911
- };
3912
- function hasCap(mask, cap) {
3913
- const capU32 = cap >>> 0;
3914
- return (mask & capU32) >>> 0 === capU32;
3915
- }
3916
- function withCap(mask, cap) {
3917
- return (mask | cap) >>> 0;
3918
- }
3919
- function withoutCap(mask, cap) {
3920
- return (mask & ~cap) >>> 0;
3921
- }
3922
-
3923
6296
  // src/nodeDiscovery.ts
3924
6297
  var DEFAULT_LOCAL_NODE_PORTS = [2428, 2429, 2528, 2529];
3925
6298
  var LOCAL_HOST = "localhost";