@weaveprotocol/cli 0.2.1 → 0.2.2
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 +2 -2
- package/dist/weave.mjs +107 -102
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ To have `weave` everywhere:
|
|
|
30
30
|
npm install -g @weaveprotocol/cli # or run it without installing: npx @weaveprotocol/cli <command>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
From this repo: `npm install` at the repo root (the CLI is a workspace), then `cd cli && npm run bundle && npm link`, or a
|
|
33
|
+
From this repo: `npm install` at the repo root (the CLI is a workspace), then `cd packages/cli && npm run bundle && npm link`, or a
|
|
34
34
|
binary with no Node at all: `bun build.ts --native`.
|
|
35
35
|
|
|
36
36
|
```bash
|
|
@@ -230,5 +230,5 @@ space anywhere leaves it everywhere.
|
|
|
230
230
|
across real networks, behind a strict NAT, in Safari, and on a phone
|
|
231
231
|
switching apps.
|
|
232
232
|
|
|
233
|
-
What the protocol still has planned is in [the spec](
|
|
233
|
+
What the protocol still has planned is in [the spec](../../spec/README.md),
|
|
234
234
|
under **Planned** in each part.
|
package/dist/weave.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import path6 from "node:path";
|
|
|
6
6
|
import { createInterface as createInterface2 } from "node:readline";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
8
|
|
|
9
|
-
// ../src/utils/encoding.ts
|
|
9
|
+
// ../core/src/utils/encoding.ts
|
|
10
10
|
var encoder = new TextEncoder();
|
|
11
11
|
var decoder = new TextDecoder();
|
|
12
12
|
function utf8Encode(str2) {
|
|
@@ -46,7 +46,7 @@ function bytesToHex(bytes) {
|
|
|
46
46
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
//
|
|
49
|
+
// ../../node_modules/@noble/hashes/_u64.js
|
|
50
50
|
var fromNumH = (n) => n / 2 ** 32 | 0;
|
|
51
51
|
var fromNumL = (n) => n >>> 0;
|
|
52
52
|
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
@@ -56,7 +56,7 @@ function setU64FromNum(view, byteOffset, n, isLE) {
|
|
|
56
56
|
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
//
|
|
59
|
+
// ../../node_modules/@noble/hashes/utils.js
|
|
60
60
|
function isBytes(a) {
|
|
61
61
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
62
62
|
}
|
|
@@ -221,7 +221,7 @@ var oidNist = (suffix) => ({
|
|
|
221
221
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
//
|
|
224
|
+
// ../../node_modules/@noble/hashes/_md.js
|
|
225
225
|
function Chi(a, b, c) {
|
|
226
226
|
return a & b ^ ~a & c;
|
|
227
227
|
}
|
|
@@ -334,7 +334,7 @@ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
|
334
334
|
1541459225
|
|
335
335
|
]);
|
|
336
336
|
|
|
337
|
-
//
|
|
337
|
+
// ../../node_modules/@noble/hashes/sha2.js
|
|
338
338
|
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
339
339
|
1116352408,
|
|
340
340
|
1899447441,
|
|
@@ -499,7 +499,7 @@ var sha256 = /* @__PURE__ */ createHasher(
|
|
|
499
499
|
/* @__PURE__ */ oidNist(1)
|
|
500
500
|
);
|
|
501
501
|
|
|
502
|
-
//
|
|
502
|
+
// ../../node_modules/@noble/curves/utils.js
|
|
503
503
|
function aarray(item, title, inner = () => {
|
|
504
504
|
}) {
|
|
505
505
|
if (!Array.isArray(item))
|
|
@@ -681,7 +681,7 @@ function validateObject(object, fields = {}, optFields = {}, title = "object") {
|
|
|
681
681
|
iter(optFields, true);
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
//
|
|
684
|
+
// ../../node_modules/@noble/curves/abstract/modular.js
|
|
685
685
|
var _0n2 = /* @__PURE__ */ BigInt(0);
|
|
686
686
|
var _1n2 = /* @__PURE__ */ BigInt(1);
|
|
687
687
|
var _2n = /* @__PURE__ */ BigInt(2);
|
|
@@ -1131,7 +1131,7 @@ function mapHashToField(key3, fieldOrder, isLE = false) {
|
|
|
1131
1131
|
return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
-
//
|
|
1134
|
+
// ../../node_modules/@noble/curves/abstract/curve.js
|
|
1135
1135
|
var _0n3 = /* @__PURE__ */ BigInt(0);
|
|
1136
1136
|
var _1n3 = /* @__PURE__ */ BigInt(1);
|
|
1137
1137
|
var _4n2 = /* @__PURE__ */ BigInt(4);
|
|
@@ -1518,7 +1518,7 @@ function createKeygen(randomSecretKey, getPublicKey) {
|
|
|
1518
1518
|
};
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
1521
|
-
//
|
|
1521
|
+
// ../../node_modules/@noble/hashes/hmac.js
|
|
1522
1522
|
var _HMAC = class {
|
|
1523
1523
|
oHash;
|
|
1524
1524
|
iHash;
|
|
@@ -1595,7 +1595,7 @@ var hmac = /* @__PURE__ */ (() => {
|
|
|
1595
1595
|
return hmac_;
|
|
1596
1596
|
})();
|
|
1597
1597
|
|
|
1598
|
-
//
|
|
1598
|
+
// ../../node_modules/@noble/curves/abstract/der.js
|
|
1599
1599
|
var _0n4 = /* @__PURE__ */ BigInt(0);
|
|
1600
1600
|
var DERErr = class extends Error {
|
|
1601
1601
|
constructor(m = "") {
|
|
@@ -1722,7 +1722,7 @@ var DER = /* @__PURE__ */ (() => {
|
|
|
1722
1722
|
return Object.freeze(_DER);
|
|
1723
1723
|
})();
|
|
1724
1724
|
|
|
1725
|
-
//
|
|
1725
|
+
// ../../node_modules/@noble/curves/abstract/weierstrass.js
|
|
1726
1726
|
var divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n2) / den;
|
|
1727
1727
|
function _splitEndoScalar(k, basis, n) {
|
|
1728
1728
|
aInRange("scalar", k, _0n5, n);
|
|
@@ -2554,7 +2554,7 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
2554
2554
|
});
|
|
2555
2555
|
}
|
|
2556
2556
|
|
|
2557
|
-
//
|
|
2557
|
+
// ../../node_modules/@noble/curves/nist.js
|
|
2558
2558
|
var p256_CURVE = /* @__PURE__ */ (() => ({
|
|
2559
2559
|
p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
|
|
2560
2560
|
n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
|
|
@@ -2567,7 +2567,7 @@ var p256_CURVE = /* @__PURE__ */ (() => ({
|
|
|
2567
2567
|
var p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
|
|
2568
2568
|
var p256 = /* @__PURE__ */ ecdsa(p256_Point, sha256);
|
|
2569
2569
|
|
|
2570
|
-
// ../src/identity/crypto-p256.ts
|
|
2570
|
+
// ../core/src/identity/crypto-p256.ts
|
|
2571
2571
|
var P256_SEED_BYTES = 48;
|
|
2572
2572
|
var P256_KEY_INFO = new TextEncoder().encode("weave/p256-identity-key/v1");
|
|
2573
2573
|
async function hkdf(ikm, info, length) {
|
|
@@ -2679,12 +2679,12 @@ function createP256Provider() {
|
|
|
2679
2679
|
});
|
|
2680
2680
|
}
|
|
2681
2681
|
|
|
2682
|
-
// ../src/utils/errors.ts
|
|
2682
|
+
// ../core/src/utils/errors.ts
|
|
2683
2683
|
function protocolError(code, message, hint) {
|
|
2684
2684
|
return Object.assign(new Error(message), { code, ...hint ? { hint } : {} });
|
|
2685
2685
|
}
|
|
2686
2686
|
|
|
2687
|
-
// ../src/identity/webauthn.ts
|
|
2687
|
+
// ../core/src/identity/webauthn.ts
|
|
2688
2688
|
var PRF_SALT = new TextEncoder().encode("weave-protocol-key-v1");
|
|
2689
2689
|
async function registerPasskey(options) {
|
|
2690
2690
|
if (!globalThis.navigator?.credentials) {
|
|
@@ -2780,10 +2780,10 @@ async function authenticatePasskey(credentialId, options) {
|
|
|
2780
2780
|
});
|
|
2781
2781
|
}
|
|
2782
2782
|
|
|
2783
|
-
// ../src/identity/passkey-diagnostics.ts
|
|
2783
|
+
// ../core/src/identity/passkey-diagnostics.ts
|
|
2784
2784
|
var PRF_SALT2 = new TextEncoder().encode("weave-protocol-key-v1");
|
|
2785
2785
|
|
|
2786
|
-
// ../src/identity/keys.ts
|
|
2786
|
+
// ../core/src/identity/keys.ts
|
|
2787
2787
|
async function deriveKeyPair(seed, provider) {
|
|
2788
2788
|
const keyPair = await provider.deriveKeyPairFromSeed(seed);
|
|
2789
2789
|
const publicKeyBytes = await provider.exportPublicKey(keyPair.publicKey);
|
|
@@ -2815,7 +2815,7 @@ async function deriveKeyFromPassword(password, salt, provider) {
|
|
|
2815
2815
|
return deriveKeyPair(new Uint8Array(derivedBits), provider);
|
|
2816
2816
|
}
|
|
2817
2817
|
|
|
2818
|
-
// ../src/identity/recovery-code.ts
|
|
2818
|
+
// ../core/src/identity/recovery-code.ts
|
|
2819
2819
|
var ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
2820
2820
|
var SUBSTITUTIONS = { O: "0", I: "1", L: "1", U: "V" };
|
|
2821
2821
|
var SEED_BYTES = 16;
|
|
@@ -2876,7 +2876,7 @@ function encodeBase32(bytes) {
|
|
|
2876
2876
|
return out;
|
|
2877
2877
|
}
|
|
2878
2878
|
|
|
2879
|
-
//
|
|
2879
|
+
// ../../node_modules/@scure/base/index.js
|
|
2880
2880
|
var freeze = (fn) => Object.freeze(fn());
|
|
2881
2881
|
function isBytes3(a) {
|
|
2882
2882
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
@@ -3082,7 +3082,7 @@ var radix58 = /* @__PURE__ */ radixBaseN(58, B58_GROUP);
|
|
|
3082
3082
|
var genBase58 = (abc) => genBaseN(radix58, abc);
|
|
3083
3083
|
var base58 = /* @__PURE__ */ freeze(() => genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));
|
|
3084
3084
|
|
|
3085
|
-
// ../src/identity/did.ts
|
|
3085
|
+
// ../core/src/identity/did.ts
|
|
3086
3086
|
var P256_MULTICODEC = new Uint8Array([128, 36]);
|
|
3087
3087
|
function publicKeyToDid(publicKeyBytes, multicodecPrefix) {
|
|
3088
3088
|
const prefixedKey = concatBytes(multicodecPrefix, publicKeyBytes);
|
|
@@ -3103,7 +3103,7 @@ function didToPublicKey(did) {
|
|
|
3103
3103
|
return { multicodecPrefix, publicKeyBytes };
|
|
3104
3104
|
}
|
|
3105
3105
|
|
|
3106
|
-
// ../src/identity/identity-manager.ts
|
|
3106
|
+
// ../core/src/identity/identity-manager.ts
|
|
3107
3107
|
function prfUnsupported() {
|
|
3108
3108
|
return protocolError(
|
|
3109
3109
|
"PRF_UNSUPPORTED",
|
|
@@ -3194,7 +3194,7 @@ function createIdentityManager(config) {
|
|
|
3194
3194
|
});
|
|
3195
3195
|
}
|
|
3196
3196
|
|
|
3197
|
-
// ../src/storage/folder-adapter.ts
|
|
3197
|
+
// ../core/src/storage/folder-adapter.ts
|
|
3198
3198
|
var EXPRESSION_SUFFIX = ".json";
|
|
3199
3199
|
function encodeKey(key3) {
|
|
3200
3200
|
let out = "";
|
|
@@ -3365,7 +3365,7 @@ async function createFolderAdapter(root, path7) {
|
|
|
3365
3365
|
});
|
|
3366
3366
|
}
|
|
3367
3367
|
|
|
3368
|
-
// ../src/identity/folder-account.ts
|
|
3368
|
+
// ../core/src/identity/folder-account.ts
|
|
3369
3369
|
function createVault(params) {
|
|
3370
3370
|
return {
|
|
3371
3371
|
version: 2,
|
|
@@ -3376,7 +3376,7 @@ function createVault(params) {
|
|
|
3376
3376
|
};
|
|
3377
3377
|
}
|
|
3378
3378
|
|
|
3379
|
-
// ../src/identity/account-store.ts
|
|
3379
|
+
// ../core/src/identity/account-store.ts
|
|
3380
3380
|
var LIST_FILE = "accounts.json";
|
|
3381
3381
|
var ACCOUNTS_DIR = "accounts";
|
|
3382
3382
|
var VAULT_FILE = "account.json";
|
|
@@ -3491,7 +3491,7 @@ function createFolderAccountStore(dir) {
|
|
|
3491
3491
|
});
|
|
3492
3492
|
}
|
|
3493
3493
|
|
|
3494
|
-
// ../src/identity/account-vault.ts
|
|
3494
|
+
// ../core/src/identity/account-vault.ts
|
|
3495
3495
|
var IV_BYTES = 12;
|
|
3496
3496
|
var SALT_BYTES = 16;
|
|
3497
3497
|
var PASSPHRASE_ITERATIONS = 6e5;
|
|
@@ -3601,12 +3601,13 @@ async function deriveVaultKey(seed) {
|
|
|
3601
3601
|
["encrypt", "decrypt"]
|
|
3602
3602
|
);
|
|
3603
3603
|
}
|
|
3604
|
+
var CLI_PASSPHRASE_LABEL = "CLI passphrase";
|
|
3604
3605
|
function withWrap(vault, wrap) {
|
|
3605
3606
|
const superseded = (existing) => existing.kind === "device" && wrap.kind === "device" && existing.rpId === wrap.rpId;
|
|
3606
3607
|
return { ...vault, wraps: [...vault.wraps.filter((existing) => !superseded(existing)), wrap] };
|
|
3607
3608
|
}
|
|
3608
3609
|
|
|
3609
|
-
// ../src/identity/contact-key.ts
|
|
3610
|
+
// ../core/src/identity/contact-key.ts
|
|
3610
3611
|
var CONTACT_KEY_INFO = "weave/p256-contact-key/v1";
|
|
3611
3612
|
var SEAL_INFO = "weave/contact-seal/v1";
|
|
3612
3613
|
var MEMBER_KEY_INFO = "weave/p256-member-key/v1";
|
|
@@ -3749,7 +3750,7 @@ async function openSealed(privateKey, sealed, context) {
|
|
|
3749
3750
|
}
|
|
3750
3751
|
}
|
|
3751
3752
|
|
|
3752
|
-
// ../src/utils/hash.ts
|
|
3753
|
+
// ../core/src/utils/hash.ts
|
|
3753
3754
|
async function sha2562(data) {
|
|
3754
3755
|
const buffer = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
3755
3756
|
return new Uint8Array(buffer);
|
|
@@ -3800,7 +3801,7 @@ async function cidFromBytes(data) {
|
|
|
3800
3801
|
return "b" + base32Encode(hashBytes);
|
|
3801
3802
|
}
|
|
3802
3803
|
|
|
3803
|
-
// ../src/records/links.ts
|
|
3804
|
+
// ../core/src/records/links.ts
|
|
3804
3805
|
var LINK_REL_PATTERN = /^[a-z][a-zA-Z0-9]{0,63}$/;
|
|
3805
3806
|
var MAX_LINKS = 32;
|
|
3806
3807
|
function checkLinks(links2) {
|
|
@@ -3818,7 +3819,7 @@ function checkLinks(links2) {
|
|
|
3818
3819
|
return null;
|
|
3819
3820
|
}
|
|
3820
3821
|
|
|
3821
|
-
// ../src/records/version.ts
|
|
3822
|
+
// ../core/src/records/version.ts
|
|
3822
3823
|
var MAX_SEEN = 64;
|
|
3823
3824
|
var RECORD_KEY_PATTERN = /^[a-z0-9:._-]{1,128}$/;
|
|
3824
3825
|
function newRecordKey() {
|
|
@@ -3859,7 +3860,7 @@ function checkVersionShape(expression) {
|
|
|
3859
3860
|
return null;
|
|
3860
3861
|
}
|
|
3861
3862
|
|
|
3862
|
-
// ../src/schema/expression.ts
|
|
3863
|
+
// ../core/src/schema/expression.ts
|
|
3863
3864
|
function canonicalize(obj) {
|
|
3864
3865
|
if (obj === null || typeof obj !== "object") {
|
|
3865
3866
|
return JSON.stringify(obj) ?? "null";
|
|
@@ -3904,7 +3905,7 @@ async function getExpressionId(expr) {
|
|
|
3904
3905
|
return await cidFromBytes(bytes);
|
|
3905
3906
|
}
|
|
3906
3907
|
|
|
3907
|
-
// ../src/identity/ucan.ts
|
|
3908
|
+
// ../core/src/identity/ucan.ts
|
|
3908
3909
|
var UCAN_CLOCK_SKEW_SECONDS = 300;
|
|
3909
3910
|
async function issueUCAN(options, provider) {
|
|
3910
3911
|
const header = { alg: "ES256", typ: "JWT", ucv: "0.10.0" };
|
|
@@ -4095,7 +4096,7 @@ async function resolveDelegationRoot(encoded, resolveProof, provider, options =
|
|
|
4095
4096
|
return { valid: false, rootDid: null, capabilities: [], audience: null, reason: `Delegation chain deeper than ${MAX_CHAIN_DEPTH} links` };
|
|
4096
4097
|
}
|
|
4097
4098
|
|
|
4098
|
-
// ../src/identity/root-signer.ts
|
|
4099
|
+
// ../core/src/identity/root-signer.ts
|
|
4099
4100
|
function createLocalRootSigner(identity, provider) {
|
|
4100
4101
|
return Object.freeze({
|
|
4101
4102
|
did: identity.did,
|
|
@@ -4115,7 +4116,7 @@ function createLocalRootSigner(identity, provider) {
|
|
|
4115
4116
|
});
|
|
4116
4117
|
}
|
|
4117
4118
|
|
|
4118
|
-
// ../src/identity/pairing.ts
|
|
4119
|
+
// ../core/src/identity/pairing.ts
|
|
4119
4120
|
var ROOM_PREFIX = utf8Encode("weave-pairing-room-v1");
|
|
4120
4121
|
var PAIRING_KEY_INFO = utf8Encode("weave-pairing-key-v1");
|
|
4121
4122
|
var IV_BYTES3 = 12;
|
|
@@ -4147,7 +4148,7 @@ async function openPairingPayload(sealed, key3) {
|
|
|
4147
4148
|
}
|
|
4148
4149
|
}
|
|
4149
4150
|
|
|
4150
|
-
// ../src/identity/agent-note.ts
|
|
4151
|
+
// ../core/src/identity/agent-note.ts
|
|
4151
4152
|
var AGENT_FACT = Object.freeze({ weave: "agent" });
|
|
4152
4153
|
function isAgentNote(encoded) {
|
|
4153
4154
|
if (!encoded) return false;
|
|
@@ -4159,7 +4160,7 @@ function isAgentNote(encoded) {
|
|
|
4159
4160
|
}
|
|
4160
4161
|
}
|
|
4161
4162
|
|
|
4162
|
-
// ../src/schema/schema-engine.ts
|
|
4163
|
+
// ../core/src/schema/schema-engine.ts
|
|
4163
4164
|
function createSchemaEngine() {
|
|
4164
4165
|
const collections = /* @__PURE__ */ new Map();
|
|
4165
4166
|
return Object.freeze({
|
|
@@ -4192,7 +4193,7 @@ function createSchemaEngine() {
|
|
|
4192
4193
|
});
|
|
4193
4194
|
}
|
|
4194
4195
|
|
|
4195
|
-
// ../src/schema/signer.ts
|
|
4196
|
+
// ../core/src/schema/signer.ts
|
|
4196
4197
|
function createSigner(provider) {
|
|
4197
4198
|
return Object.freeze({
|
|
4198
4199
|
async sign(payload, privateKey) {
|
|
@@ -4218,7 +4219,7 @@ function createSigner(provider) {
|
|
|
4218
4219
|
});
|
|
4219
4220
|
}
|
|
4220
4221
|
|
|
4221
|
-
// ../src/sync/negentropy.ts
|
|
4222
|
+
// ../core/src/sync/negentropy.ts
|
|
4222
4223
|
var NEGENTROPY_VERSION = 97;
|
|
4223
4224
|
var ID_SIZE = 32;
|
|
4224
4225
|
var FINGERPRINT_SIZE = 16;
|
|
@@ -4508,7 +4509,7 @@ function createReconciler(set, options) {
|
|
|
4508
4509
|
}
|
|
4509
4510
|
var key = (id) => String.fromCharCode(...id);
|
|
4510
4511
|
|
|
4511
|
-
// ../src/storage/storage-provider.ts
|
|
4512
|
+
// ../core/src/storage/storage-provider.ts
|
|
4512
4513
|
var CURRENT_PREFIX = "r/";
|
|
4513
4514
|
var GENESIS_PREFIX = "g/";
|
|
4514
4515
|
var HISTORY_PREFIX = "h/";
|
|
@@ -4733,7 +4734,7 @@ function createStorageProvider(adapter) {
|
|
|
4733
4734
|
});
|
|
4734
4735
|
}
|
|
4735
4736
|
|
|
4736
|
-
// ../src/storage/encrypted-adapter.ts
|
|
4737
|
+
// ../core/src/storage/encrypted-adapter.ts
|
|
4737
4738
|
var MAGIC = new Uint8Array([119, 101, 97, 118, 101, 101, 2, 0]);
|
|
4738
4739
|
var IV_BYTES4 = 12;
|
|
4739
4740
|
var DEFAULT_ENCRYPTED_PREFIXES = ["space:", "spacekey:", "spaceinvite:", "spacerole:"];
|
|
@@ -4797,7 +4798,7 @@ function createEncryptedAdapter(inner, key3, options) {
|
|
|
4797
4798
|
});
|
|
4798
4799
|
}
|
|
4799
4800
|
|
|
4800
|
-
// ../src/storage/folder-reconcile.ts
|
|
4801
|
+
// ../core/src/storage/folder-reconcile.ts
|
|
4801
4802
|
async function reconcileFolder(storage, adapter, accept = async () => true) {
|
|
4802
4803
|
const disk = await adapter.reload();
|
|
4803
4804
|
if (disk.added.length > 0 || disk.removed.length > 0) storage.invalidate();
|
|
@@ -4826,7 +4827,7 @@ async function reconcileFolder(storage, adapter, accept = async () => true) {
|
|
|
4826
4827
|
};
|
|
4827
4828
|
}
|
|
4828
4829
|
|
|
4829
|
-
// ../src/privacy/space-encryption.ts
|
|
4830
|
+
// ../core/src/privacy/space-encryption.ts
|
|
4830
4831
|
async function generateSpaceKey() {
|
|
4831
4832
|
const key3 = await globalThis.crypto.subtle.generateKey(
|
|
4832
4833
|
{ name: "AES-GCM", length: 256 },
|
|
@@ -4912,7 +4913,7 @@ async function openWith(spaceKey, sealed, context) {
|
|
|
4912
4913
|
}
|
|
4913
4914
|
}
|
|
4914
4915
|
|
|
4915
|
-
// ../src/space/roles.ts
|
|
4916
|
+
// ../core/src/space/roles.ts
|
|
4916
4917
|
var MANAGE = "manage";
|
|
4917
4918
|
var INVITE = "invite";
|
|
4918
4919
|
var DEFINE = "define";
|
|
@@ -5331,7 +5332,7 @@ function replayAccess(genesis, events) {
|
|
|
5331
5332
|
}
|
|
5332
5333
|
}
|
|
5333
5334
|
|
|
5334
|
-
// ../src/space/space-access.ts
|
|
5335
|
+
// ../core/src/space/space-access.ts
|
|
5335
5336
|
var READ_INFO = "weave/space-read/v1";
|
|
5336
5337
|
var INVITE_INFO = "weave/space-invite/v1";
|
|
5337
5338
|
function generateInviteSecret() {
|
|
@@ -5435,7 +5436,7 @@ async function verifyInvite(spaceId, did, inviteDid, signature, provider) {
|
|
|
5435
5436
|
}
|
|
5436
5437
|
}
|
|
5437
5438
|
|
|
5438
|
-
// ../src/space/presets.ts
|
|
5439
|
+
// ../core/src/space/presets.ts
|
|
5439
5440
|
var solo = Object.freeze({
|
|
5440
5441
|
roles: Object.freeze([{ name: "owner", title: "Owner", rank: 100, permissions: ["*"] }]),
|
|
5441
5442
|
creatorRole: "owner"
|
|
@@ -5457,7 +5458,7 @@ var community = Object.freeze({
|
|
|
5457
5458
|
});
|
|
5458
5459
|
var rolePresets = Object.freeze({ solo, team, community });
|
|
5459
5460
|
|
|
5460
|
-
// ../src/space/space-manager.ts
|
|
5461
|
+
// ../core/src/space/space-manager.ts
|
|
5461
5462
|
var SPACE_PREFIX = "space:";
|
|
5462
5463
|
var KEY_PREFIX = "spacekey:";
|
|
5463
5464
|
var INVITE_PREFIX = "spaceinvite:";
|
|
@@ -5635,7 +5636,7 @@ function parseSpaceInvite(invite) {
|
|
|
5635
5636
|
}
|
|
5636
5637
|
}
|
|
5637
5638
|
|
|
5638
|
-
// ../src/space/account-registry.ts
|
|
5639
|
+
// ../core/src/space/account-registry.ts
|
|
5639
5640
|
var MEMBERSHIP_COLLECTION = "sys.joined";
|
|
5640
5641
|
var PROFILE_COLLECTION = "sys.profile";
|
|
5641
5642
|
var PROFILE_KEY = "profile";
|
|
@@ -5687,7 +5688,7 @@ async function deriveAccountSpace(accountKey, owner, label, name, provider) {
|
|
|
5687
5688
|
return { space: space2, key: key3, invite: null, role: solo.creatorRole };
|
|
5688
5689
|
}
|
|
5689
5690
|
|
|
5690
|
-
//
|
|
5691
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
5691
5692
|
function deepCompareStrict(a, b) {
|
|
5692
5693
|
const typeofa = typeof a;
|
|
5693
5694
|
if (typeofa !== typeof b) {
|
|
@@ -5728,7 +5729,7 @@ function deepCompareStrict(a, b) {
|
|
|
5728
5729
|
return a === b;
|
|
5729
5730
|
}
|
|
5730
5731
|
|
|
5731
|
-
//
|
|
5732
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/pointer.js
|
|
5732
5733
|
function encodePointer(p) {
|
|
5733
5734
|
return encodeURI(escapePointer(p));
|
|
5734
5735
|
}
|
|
@@ -5736,7 +5737,7 @@ function escapePointer(p) {
|
|
|
5736
5737
|
return p.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
5737
5738
|
}
|
|
5738
5739
|
|
|
5739
|
-
//
|
|
5740
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/dereference.js
|
|
5740
5741
|
var schemaArrayKeyword = {
|
|
5741
5742
|
prefixItems: true,
|
|
5742
5743
|
items: true,
|
|
@@ -5857,7 +5858,7 @@ function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseU
|
|
|
5857
5858
|
return lookup;
|
|
5858
5859
|
}
|
|
5859
5860
|
|
|
5860
|
-
//
|
|
5861
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/format.js
|
|
5861
5862
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
5862
5863
|
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
5863
5864
|
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
@@ -5950,7 +5951,7 @@ function regex(str2) {
|
|
|
5950
5951
|
}
|
|
5951
5952
|
}
|
|
5952
5953
|
|
|
5953
|
-
//
|
|
5954
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/types.js
|
|
5954
5955
|
var OutputFormat;
|
|
5955
5956
|
(function(OutputFormat2) {
|
|
5956
5957
|
OutputFormat2[OutputFormat2["Flag"] = 1] = "Flag";
|
|
@@ -5958,7 +5959,7 @@ var OutputFormat;
|
|
|
5958
5959
|
OutputFormat2[OutputFormat2["Detailed"] = 4] = "Detailed";
|
|
5959
5960
|
})(OutputFormat || (OutputFormat = {}));
|
|
5960
5961
|
|
|
5961
|
-
//
|
|
5962
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js
|
|
5962
5963
|
function ucs2length(s) {
|
|
5963
5964
|
let result = 0;
|
|
5964
5965
|
let length = s.length;
|
|
@@ -5977,7 +5978,7 @@ function ucs2length(s) {
|
|
|
5977
5978
|
return result;
|
|
5978
5979
|
}
|
|
5979
5980
|
|
|
5980
|
-
//
|
|
5981
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/validate.js
|
|
5981
5982
|
function validate(instance, schema, draft = "2019-09", lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = "#", schemaLocation = "#", evaluated = /* @__PURE__ */ Object.create(null)) {
|
|
5982
5983
|
if (schema === true) {
|
|
5983
5984
|
return { valid: true, errors: [] };
|
|
@@ -6735,7 +6736,7 @@ Known schemas:
|
|
|
6735
6736
|
return { valid: errors.length === 0, errors };
|
|
6736
6737
|
}
|
|
6737
6738
|
|
|
6738
|
-
//
|
|
6739
|
+
// ../../node_modules/@cfworker/json-schema/dist/esm/validator.js
|
|
6739
6740
|
var Validator = class {
|
|
6740
6741
|
schema;
|
|
6741
6742
|
draft;
|
|
@@ -6758,7 +6759,7 @@ var Validator = class {
|
|
|
6758
6759
|
}
|
|
6759
6760
|
};
|
|
6760
6761
|
|
|
6761
|
-
// ../src/records/rules.ts
|
|
6762
|
+
// ../core/src/records/rules.ts
|
|
6762
6763
|
var PERMISSION_PATTERN = /^[a-z][a-zA-Z0-9]{0,39}$/;
|
|
6763
6764
|
var permissionName = (collection2, permission) => `${collection2}/${permission}`;
|
|
6764
6765
|
var isWho = (w) => w === "member" || w === "creator" || typeof w === "string" && w.startsWith("can:") && PERMISSION_PATTERN.test(w.slice(4));
|
|
@@ -6828,7 +6829,7 @@ function changedFixedField(fixed, first, next) {
|
|
|
6828
6829
|
return null;
|
|
6829
6830
|
}
|
|
6830
6831
|
|
|
6831
|
-
// ../src/records/topics.ts
|
|
6832
|
+
// ../core/src/records/topics.ts
|
|
6832
6833
|
var MAX_TOPICS = 8;
|
|
6833
6834
|
var MAX_TAGS = 64;
|
|
6834
6835
|
var TAG_BYTES = 16;
|
|
@@ -6880,7 +6881,7 @@ function sameTags(a, b) {
|
|
|
6880
6881
|
return left.length === right.length && left.every((tag, i) => tag === right[i]);
|
|
6881
6882
|
}
|
|
6882
6883
|
|
|
6883
|
-
// ../src/schema/collection-def.ts
|
|
6884
|
+
// ../core/src/schema/collection-def.ts
|
|
6884
6885
|
function toJsonSchema(schema) {
|
|
6885
6886
|
const standard = schema["~standard"];
|
|
6886
6887
|
if (!standard) return schema;
|
|
@@ -7041,7 +7042,7 @@ function validateJsonSchema(schema, value) {
|
|
|
7041
7042
|
}));
|
|
7042
7043
|
}
|
|
7043
7044
|
|
|
7044
|
-
// ../src/utils/events.ts
|
|
7045
|
+
// ../core/src/utils/events.ts
|
|
7045
7046
|
function createEmitter() {
|
|
7046
7047
|
const listeners = /* @__PURE__ */ new Map();
|
|
7047
7048
|
return {
|
|
@@ -7063,7 +7064,7 @@ function createEmitter() {
|
|
|
7063
7064
|
};
|
|
7064
7065
|
}
|
|
7065
7066
|
|
|
7066
|
-
// ../src/network/signaling.ts
|
|
7067
|
+
// ../core/src/network/signaling.ts
|
|
7067
7068
|
var SIGNAL_KINDS = /* @__PURE__ */ new Set(["offer", "answer", "candidate"]);
|
|
7068
7069
|
function iceFrom(payload) {
|
|
7069
7070
|
const { servers, expiresAt } = payload ?? {};
|
|
@@ -7180,7 +7181,7 @@ function createSignalingClient(url, did) {
|
|
|
7180
7181
|
});
|
|
7181
7182
|
}
|
|
7182
7183
|
|
|
7183
|
-
// ../src/network/multi-signaling.ts
|
|
7184
|
+
// ../core/src/network/multi-signaling.ts
|
|
7184
7185
|
function createMultiSignalingClient(urls, did) {
|
|
7185
7186
|
if (urls.length === 0) {
|
|
7186
7187
|
throw new Error("At least one relay is needed to introduce peers.");
|
|
@@ -7314,7 +7315,7 @@ function createMultiSignalingClient(urls, did) {
|
|
|
7314
7315
|
});
|
|
7315
7316
|
}
|
|
7316
7317
|
|
|
7317
|
-
// ../src/network/introductions.ts
|
|
7318
|
+
// ../core/src/network/introductions.ts
|
|
7318
7319
|
var PEERS_MESSAGE = "__peers";
|
|
7319
7320
|
var SIGNAL_MESSAGE = "__signal";
|
|
7320
7321
|
var AUTH_HELLO_MESSAGE = "__auth-hello";
|
|
@@ -7353,7 +7354,7 @@ function signalId() {
|
|
|
7353
7354
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7354
7355
|
}
|
|
7355
7356
|
|
|
7356
|
-
// ../src/network/rtc-transport.ts
|
|
7357
|
+
// ../core/src/network/rtc-transport.ts
|
|
7357
7358
|
function fingerprintOf2(description) {
|
|
7358
7359
|
const match = description?.sdp?.match(/^a=fingerprint:\s*(\S+)\s+(\S+)/im);
|
|
7359
7360
|
return match ? `${match[1].toLowerCase()} ${match[2].toUpperCase()}` : null;
|
|
@@ -7489,7 +7490,7 @@ function createRTCTransport(config) {
|
|
|
7489
7490
|
});
|
|
7490
7491
|
}
|
|
7491
7492
|
|
|
7492
|
-
// ../src/network/peer-auth.ts
|
|
7493
|
+
// ../core/src/network/peer-auth.ts
|
|
7493
7494
|
function readAccessOf(read) {
|
|
7494
7495
|
if (!read) return null;
|
|
7495
7496
|
if ("current" in read) return read;
|
|
@@ -7575,7 +7576,7 @@ function createMeshAuth(spaceId, session, read, provider) {
|
|
|
7575
7576
|
});
|
|
7576
7577
|
}
|
|
7577
7578
|
|
|
7578
|
-
// ../src/network/ws-transport.ts
|
|
7579
|
+
// ../core/src/network/ws-transport.ts
|
|
7579
7580
|
function parseFrame(data, type) {
|
|
7580
7581
|
if (typeof data !== "string") return null;
|
|
7581
7582
|
try {
|
|
@@ -7721,7 +7722,7 @@ function createWebSocketTransport(config) {
|
|
|
7721
7722
|
});
|
|
7722
7723
|
}
|
|
7723
7724
|
|
|
7724
|
-
// ../src/network/mesh.ts
|
|
7725
|
+
// ../core/src/network/mesh.ts
|
|
7725
7726
|
var ICE_REFRESH_MS = 10 * 6e4;
|
|
7726
7727
|
var ICE_WAIT_MS = 1500;
|
|
7727
7728
|
function createMesh(config) {
|
|
@@ -8002,7 +8003,7 @@ function createMesh(config) {
|
|
|
8002
8003
|
};
|
|
8003
8004
|
}
|
|
8004
8005
|
|
|
8005
|
-
// ../src/network/network-manager.ts
|
|
8006
|
+
// ../core/src/network/network-manager.ts
|
|
8006
8007
|
function createNetworkManager(config) {
|
|
8007
8008
|
const transport = config.createTransport();
|
|
8008
8009
|
const peers = /* @__PURE__ */ new Map();
|
|
@@ -8048,7 +8049,7 @@ function createNetworkManager(config) {
|
|
|
8048
8049
|
});
|
|
8049
8050
|
}
|
|
8050
8051
|
|
|
8051
|
-
// ../src/sync/sync-messages.ts
|
|
8052
|
+
// ../core/src/sync/sync-messages.ts
|
|
8052
8053
|
var SYNC_PROTOCOL_VERSION = 4;
|
|
8053
8054
|
function parseSyncMessage(value) {
|
|
8054
8055
|
const message = value;
|
|
@@ -8056,7 +8057,7 @@ function parseSyncMessage(value) {
|
|
|
8056
8057
|
return message;
|
|
8057
8058
|
}
|
|
8058
8059
|
|
|
8059
|
-
// ../src/sync/sync-engine.ts
|
|
8060
|
+
// ../core/src/sync/sync-engine.ts
|
|
8060
8061
|
var MAX_WAITING = 1e3;
|
|
8061
8062
|
var MAX_REFUSED = 1e4;
|
|
8062
8063
|
var holdsCollection = (holds2, collection2) => collection2.startsWith("sys.") || holds2 === "all" || holds2.has(collection2);
|
|
@@ -8344,7 +8345,7 @@ ${id}`;
|
|
|
8344
8345
|
};
|
|
8345
8346
|
}
|
|
8346
8347
|
|
|
8347
|
-
// ../src/validation/crypto-gate.ts
|
|
8348
|
+
// ../core/src/validation/crypto-gate.ts
|
|
8348
8349
|
function createCryptoGate(provider) {
|
|
8349
8350
|
return {
|
|
8350
8351
|
async validate(expression, resolvePublicKey) {
|
|
@@ -8371,7 +8372,7 @@ function createCryptoGate(provider) {
|
|
|
8371
8372
|
};
|
|
8372
8373
|
}
|
|
8373
8374
|
|
|
8374
|
-
// ../src/validation/structural-gate.ts
|
|
8375
|
+
// ../core/src/validation/structural-gate.ts
|
|
8375
8376
|
function isEncryptedBody(body) {
|
|
8376
8377
|
if (!body || typeof body !== "object") return false;
|
|
8377
8378
|
const envelope = body;
|
|
@@ -8405,7 +8406,7 @@ function createStructuralGate(schemaEngine, options = {}) {
|
|
|
8405
8406
|
};
|
|
8406
8407
|
}
|
|
8407
8408
|
|
|
8408
|
-
// ../src/validation/stateful-gate.ts
|
|
8409
|
+
// ../core/src/validation/stateful-gate.ts
|
|
8409
8410
|
function createStatefulGate() {
|
|
8410
8411
|
const rules = /* @__PURE__ */ new Map();
|
|
8411
8412
|
return {
|
|
@@ -8451,7 +8452,7 @@ function createStatefulGate() {
|
|
|
8451
8452
|
};
|
|
8452
8453
|
}
|
|
8453
8454
|
|
|
8454
|
-
// ../src/validation/capability-gate.ts
|
|
8455
|
+
// ../core/src/validation/capability-gate.ts
|
|
8455
8456
|
var fail = (reason) => ({ passed: false, gate: "capability", reason });
|
|
8456
8457
|
var MAX_CLOCK_SKEW_SECONDS = 300;
|
|
8457
8458
|
function createCapabilityGate(config) {
|
|
@@ -8494,7 +8495,7 @@ function createCapabilityGate(config) {
|
|
|
8494
8495
|
};
|
|
8495
8496
|
}
|
|
8496
8497
|
|
|
8497
|
-
// ../src/validation/validation-engine.ts
|
|
8498
|
+
// ../core/src/validation/validation-engine.ts
|
|
8498
8499
|
function createValidationEngine(config) {
|
|
8499
8500
|
const { cryptoGate, structuralGate, statefulGate, capabilityGate, resolvePublicKey, getExpression } = config;
|
|
8500
8501
|
return {
|
|
@@ -8520,7 +8521,7 @@ function createValidationEngine(config) {
|
|
|
8520
8521
|
};
|
|
8521
8522
|
}
|
|
8522
8523
|
|
|
8523
|
-
// ../src/query/filter.ts
|
|
8524
|
+
// ../core/src/query/filter.ts
|
|
8524
8525
|
var MAX_INCLUDE_DEPTH = 3;
|
|
8525
8526
|
var META = {
|
|
8526
8527
|
"@key": (r) => r.key,
|
|
@@ -8684,7 +8685,7 @@ function checkQuery(query) {
|
|
|
8684
8685
|
return null;
|
|
8685
8686
|
}
|
|
8686
8687
|
|
|
8687
|
-
// ../src/query/types.ts
|
|
8688
|
+
// ../core/src/query/types.ts
|
|
8688
8689
|
var nameOf = (ref) => typeof ref === "object" && ref !== null && typeof ref.name === "string" ? ref.name : ref;
|
|
8689
8690
|
function plainQuery(query) {
|
|
8690
8691
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -8698,7 +8699,7 @@ function plainQuery(query) {
|
|
|
8698
8699
|
return { ...query, collection: nameOf(query.collection), ...query.include !== void 0 ? { include: includes(query.include) } : {} };
|
|
8699
8700
|
}
|
|
8700
8701
|
|
|
8701
|
-
// ../src/query/engine.ts
|
|
8702
|
+
// ../core/src/query/engine.ts
|
|
8702
8703
|
function compareValues(a, b) {
|
|
8703
8704
|
if (a === b) return 0;
|
|
8704
8705
|
if (a === void 0 || a === null) return -1;
|
|
@@ -8758,7 +8759,7 @@ async function runQuery(source, given) {
|
|
|
8758
8759
|
return { records, cursor: more ? page[page.length - 1].key : null, complete: true };
|
|
8759
8760
|
}
|
|
8760
8761
|
|
|
8761
|
-
// ../src/storage/segment.ts
|
|
8762
|
+
// ../core/src/storage/segment.ts
|
|
8762
8763
|
var SEGMENT_SUFFIX = ".seg";
|
|
8763
8764
|
function packSegment(versions) {
|
|
8764
8765
|
return utf8Encode(JSON.stringify({ v: 1, versions }));
|
|
@@ -8778,7 +8779,7 @@ async function segmentName(counter, bytes) {
|
|
|
8778
8779
|
}
|
|
8779
8780
|
var versionSize = (version) => utf8Encode(JSON.stringify(version)).length;
|
|
8780
8781
|
|
|
8781
|
-
// ../src/storage/mirror.ts
|
|
8782
|
+
// ../core/src/storage/mirror.ts
|
|
8782
8783
|
var WRITER_KEY = "mirror:writer";
|
|
8783
8784
|
var COUNTER_KEY = "mirror:counter";
|
|
8784
8785
|
var readKey = (name) => `mirror:read:${name}`;
|
|
@@ -8924,7 +8925,7 @@ async function createMirror(config) {
|
|
|
8924
8925
|
});
|
|
8925
8926
|
}
|
|
8926
8927
|
|
|
8927
|
-
// ../src/space/pass.ts
|
|
8928
|
+
// ../core/src/space/pass.ts
|
|
8928
8929
|
var PASS_COLLECTION = "sys.pass";
|
|
8929
8930
|
var CARRY_CLOSED_KEY = "carry:closed";
|
|
8930
8931
|
async function passKey(spaceId) {
|
|
@@ -8955,7 +8956,7 @@ function carriedRecord(pass) {
|
|
|
8955
8956
|
return { space: pass.space, key: null, invite: null, role: null, read: pass.read };
|
|
8956
8957
|
}
|
|
8957
8958
|
|
|
8958
|
-
// ../src/node/space-runtime.ts
|
|
8959
|
+
// ../core/src/node/space-runtime.ts
|
|
8959
8960
|
var MANAGED = /* @__PURE__ */ new Set([MEMBERSHIP_COLLECTION, PROFILE_COLLECTION, CARRIER_COLLECTION, PASS_COLLECTION, BOX_COLLECTION, MEMBER_KEY_COLLECTION, ...ACCESS_COLLECTIONS]);
|
|
8960
8961
|
var IN_THE_CLEAR = /* @__PURE__ */ new Set([ROLE_COLLECTION, MEMBER_COLLECTION, INVITE_COLLECTION, REVOKE_COLLECTION, KEY_COLLECTION, BOX_COLLECTION, MEMBER_KEY_COLLECTION, RELAYS_COLLECTION, KEEPERS_COLLECTION]);
|
|
8961
8962
|
var ACCESS_KEYS = [
|
|
@@ -9898,7 +9899,7 @@ async function openSpaceRuntime(deps) {
|
|
|
9898
9899
|
channel.unref?.();
|
|
9899
9900
|
}
|
|
9900
9901
|
const HOUR = 36e5;
|
|
9901
|
-
const
|
|
9902
|
+
const DAY3 = 24 * HOUR;
|
|
9902
9903
|
const declared = new Set((cache?.collections ?? []).filter((c) => !c.startsWith("sys.")));
|
|
9903
9904
|
let cacheTimer = null;
|
|
9904
9905
|
const saveCache = () => {
|
|
@@ -9986,7 +9987,7 @@ async function openSpaceRuntime(deps) {
|
|
|
9986
9987
|
});
|
|
9987
9988
|
async function dropUnused() {
|
|
9988
9989
|
if (!cache || !partial || closed) return;
|
|
9989
|
-
const cutoff = Date.now() - (cache.unusedAfterDays ?? 30) *
|
|
9990
|
+
const cutoff = Date.now() - (cache.unusedAfterDays ?? 30) * DAY3;
|
|
9990
9991
|
const waiting = /* @__PURE__ */ new Set();
|
|
9991
9992
|
for (const name of await adapter.list(PENDING_PREFIX)) {
|
|
9992
9993
|
const bytes = await adapter.get(name);
|
|
@@ -10414,7 +10415,7 @@ async function openSpaceRuntime(deps) {
|
|
|
10414
10415
|
});
|
|
10415
10416
|
}
|
|
10416
10417
|
|
|
10417
|
-
// ../src/schemas/contacts.ts
|
|
10418
|
+
// ../core/src/schemas/contacts.ts
|
|
10418
10419
|
var typed = () => (definition) => definition;
|
|
10419
10420
|
var contact = typed()({
|
|
10420
10421
|
name: "std.contact",
|
|
@@ -10495,7 +10496,7 @@ var knockAnswer = typed()({
|
|
|
10495
10496
|
rules: { edit: "creator", delete: "creator" }
|
|
10496
10497
|
});
|
|
10497
10498
|
|
|
10498
|
-
// ../src/doors/doors.ts
|
|
10499
|
+
// ../core/src/doors/doors.ts
|
|
10499
10500
|
var MAX_DOOR_RELAYS = 3;
|
|
10500
10501
|
var KNOCK_TTL_SECONDS = 14 * 24 * 3600;
|
|
10501
10502
|
var KNOCK_DROP_WINDOW_SECONDS = 600;
|
|
@@ -10622,7 +10623,7 @@ async function openKnock(doorKey, blob, receivedAt, provider) {
|
|
|
10622
10623
|
});
|
|
10623
10624
|
}
|
|
10624
10625
|
|
|
10625
|
-
// ../src/network/mailbox.ts
|
|
10626
|
+
// ../core/src/network/mailbox.ts
|
|
10626
10627
|
var MAX_PAGES = 8;
|
|
10627
10628
|
function createMailboxClient(options = {}) {
|
|
10628
10629
|
const timeoutMs = options.timeoutMs ?? 8e3;
|
|
@@ -10716,7 +10717,7 @@ function isMailItem(value) {
|
|
|
10716
10717
|
return !!item && Number.isSafeInteger(item.seq) && typeof item.id === "string" && typeof item.at === "number" && typeof item.blob === "string";
|
|
10717
10718
|
}
|
|
10718
10719
|
|
|
10719
|
-
// ../src/space/notify.ts
|
|
10720
|
+
// ../core/src/space/notify.ts
|
|
10720
10721
|
var NOTIFY_COLLECTION = "sys.notify";
|
|
10721
10722
|
var SUBSCRIPTION_COLLECTION = "sys.subscription";
|
|
10722
10723
|
var COLLECTION = /^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/;
|
|
@@ -10803,7 +10804,7 @@ function matchesSubscription(sub, spaceId, version, account, now = Date.now()) {
|
|
|
10803
10804
|
return true;
|
|
10804
10805
|
}
|
|
10805
10806
|
|
|
10806
|
-
// ../src/session/hosting.ts
|
|
10807
|
+
// ../core/src/session/hosting.ts
|
|
10807
10808
|
var HOSTING_COLLECTION = "sys.hosting";
|
|
10808
10809
|
var REQUEST_WINDOW_SECONDS = 300;
|
|
10809
10810
|
function newSubscriptionSeed() {
|
|
@@ -10919,7 +10920,7 @@ function createHostClient(url, host, key3, provider = createP256Provider()) {
|
|
|
10919
10920
|
});
|
|
10920
10921
|
}
|
|
10921
10922
|
|
|
10922
|
-
// ../src/node/node.ts
|
|
10923
|
+
// ../core/src/node/node.ts
|
|
10923
10924
|
var SESSION_CAPABILITY = { with: "*", can: "expression/*" };
|
|
10924
10925
|
var DEFAULT_TTL_SECONDS = 3600;
|
|
10925
10926
|
var FORGET_CARRIER_AFTER_MS = 30 * 24 * 3600 * 1e3;
|
|
@@ -12344,7 +12345,7 @@ async function createNode(config) {
|
|
|
12344
12345
|
return node;
|
|
12345
12346
|
}
|
|
12346
12347
|
|
|
12347
|
-
// ../src/node/stores.ts
|
|
12348
|
+
// ../core/src/node/stores.ts
|
|
12348
12349
|
function folderStores(directory2, options = {}) {
|
|
12349
12350
|
return async (path7, storeOptions) => {
|
|
12350
12351
|
const full = options.basePath ? `${options.basePath}/${path7}` : path7;
|
|
@@ -12353,7 +12354,7 @@ function folderStores(directory2, options = {}) {
|
|
|
12353
12354
|
};
|
|
12354
12355
|
}
|
|
12355
12356
|
|
|
12356
|
-
// ../src/network/local-transport.ts
|
|
12357
|
+
// ../core/src/network/local-transport.ts
|
|
12357
12358
|
var later = (fn) => void setTimeout(fn, 0);
|
|
12358
12359
|
function createLocalHub() {
|
|
12359
12360
|
const connected = /* @__PURE__ */ new Map();
|
|
@@ -12399,7 +12400,7 @@ function createLocalHub() {
|
|
|
12399
12400
|
};
|
|
12400
12401
|
}
|
|
12401
12402
|
|
|
12402
|
-
// ../src/node/carrier.ts
|
|
12403
|
+
// ../core/src/node/carrier.ts
|
|
12403
12404
|
async function createCarryCore(config) {
|
|
12404
12405
|
const provider = config.provider ?? createP256Provider();
|
|
12405
12406
|
const signer = createSigner(provider);
|
|
@@ -12630,7 +12631,7 @@ async function createCarryCore(config) {
|
|
|
12630
12631
|
};
|
|
12631
12632
|
}
|
|
12632
12633
|
|
|
12633
|
-
// ../src/node/host.ts
|
|
12634
|
+
// ../core/src/node/host.ts
|
|
12634
12635
|
var SUBSCRIPTION_PREFIX = "subscription:";
|
|
12635
12636
|
var NotAllowedError = class extends Error {
|
|
12636
12637
|
constructor() {
|
|
@@ -12792,7 +12793,7 @@ async function createHostNode(config) {
|
|
|
12792
12793
|
return Object.freeze(host);
|
|
12793
12794
|
}
|
|
12794
12795
|
|
|
12795
|
-
// ../src/records/describe.ts
|
|
12796
|
+
// ../core/src/records/describe.ts
|
|
12796
12797
|
var KNOWN_RULES = ["create", "edit", "delete", "onePer", "fixed"];
|
|
12797
12798
|
var words = (name) => name.replace(/^.*\./, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase();
|
|
12798
12799
|
var article = (noun) => /^[aeiou]/.test(noun) ? `an ${noun}` : `a ${noun}`;
|
|
@@ -12870,7 +12871,7 @@ function describeCollection(definition) {
|
|
|
12870
12871
|
return sentences;
|
|
12871
12872
|
}
|
|
12872
12873
|
|
|
12873
|
-
// ../src/schemas/apps.ts
|
|
12874
|
+
// ../core/src/schemas/apps.ts
|
|
12874
12875
|
var MAX_APP_COLLECTIONS = 10;
|
|
12875
12876
|
var app = {
|
|
12876
12877
|
name: "std.app",
|
|
@@ -12971,7 +12972,7 @@ async function proposeApp(node, spaceId, body) {
|
|
|
12971
12972
|
return node.records.put(spaceId, app.name, body);
|
|
12972
12973
|
}
|
|
12973
12974
|
|
|
12974
|
-
// ../src/schemas/screens.ts
|
|
12975
|
+
// ../core/src/schemas/screens.ts
|
|
12975
12976
|
var SCREEN_GUIDE = `A screen is one HTML document (scripts and styles inline, at most 48 KB) put on a collection definition as "screen".
|
|
12976
12977
|
When the app is added, apps in the space can show it instead of plain lists. It runs sealed: no network (no fetch, no
|
|
12977
12978
|
images from URLs, no fonts from URLs), no storage, no popups, no forms that submit. Keep state in records, never in the page.
|
|
@@ -12997,7 +12998,7 @@ Draw everything from weave.list(...) and redraw on weave.onChange \u2014 other p
|
|
|
12997
12998
|
Two people can write at once: design collections so that clashes resolve by the rules (onePer, creator-only edits), not by the screen.
|
|
12998
12999
|
Use plain DOM; no libraries can be loaded. Prefer system fonts and simple, readable styling that works in light and dark.`;
|
|
12999
13000
|
|
|
13000
|
-
// ../src/node/actions.ts
|
|
13001
|
+
// ../core/src/node/actions.ts
|
|
13001
13002
|
var space = { type: "string", description: "Space id, from spaces_list" };
|
|
13002
13003
|
var key2 = { type: "string", description: "Record key \u2014 stays the same when the record is edited" };
|
|
13003
13004
|
var str = (input, key3) => input[key3];
|
|
@@ -13438,7 +13439,7 @@ async function runAction(node, name, input = {}) {
|
|
|
13438
13439
|
return action.run(node, input);
|
|
13439
13440
|
}
|
|
13440
13441
|
|
|
13441
|
-
//
|
|
13442
|
+
// ../../node_modules/aws4fetch/dist/aws4fetch.esm.mjs
|
|
13442
13443
|
var encoder2 = new TextEncoder();
|
|
13443
13444
|
var HOST_SERVICES = {
|
|
13444
13445
|
appstream2: "appstream",
|
|
@@ -13717,7 +13718,7 @@ function guessServiceRegion(url, headers) {
|
|
|
13717
13718
|
return [HOST_SERVICES[service] || service, region || ""];
|
|
13718
13719
|
}
|
|
13719
13720
|
|
|
13720
|
-
// ../src/storage/blob/s3.ts
|
|
13721
|
+
// ../core/src/storage/blob/s3.ts
|
|
13721
13722
|
var ATTEMPTS = 5;
|
|
13722
13723
|
function createS3BlobStore(config) {
|
|
13723
13724
|
const client = new AwsClient({
|
|
@@ -13893,7 +13894,7 @@ async function createAccount(home, options) {
|
|
|
13893
13894
|
throw new Error(`This home already has an account for ${did}`);
|
|
13894
13895
|
}
|
|
13895
13896
|
let vault = createVault({ did, label: options.name, wraps: [] });
|
|
13896
|
-
if (options.passphrase) vault = withWrap(vault, await wrapSeedWithPassphrase(seed, options.passphrase,
|
|
13897
|
+
if (options.passphrase) vault = withWrap(vault, await wrapSeedWithPassphrase(seed, options.passphrase, CLI_PASSPHRASE_LABEL));
|
|
13897
13898
|
const id = newAccountId();
|
|
13898
13899
|
const account = {
|
|
13899
13900
|
id,
|
|
@@ -13954,7 +13955,7 @@ async function unlock(home, account, secret) {
|
|
|
13954
13955
|
import { createServer } from "node:http";
|
|
13955
13956
|
import { WebSocketServer } from "ws";
|
|
13956
13957
|
|
|
13957
|
-
// ../
|
|
13958
|
+
// ../relay/relay.mjs
|
|
13958
13959
|
import { createHash, createHmac, createPublicKey, randomBytes as randomBytes4, verify } from "node:crypto";
|
|
13959
13960
|
var MAX_MESSAGE_BYTES = 64 * 1024;
|
|
13960
13961
|
var MAX_CONNECTIONS = 5e3;
|
|
@@ -15541,7 +15542,11 @@ import { mkdir as mkdir2, readFile as readFile3, rm, writeFile as writeFile2 } f
|
|
|
15541
15542
|
import os3 from "node:os";
|
|
15542
15543
|
import path4 from "node:path";
|
|
15543
15544
|
|
|
15544
|
-
// ../src/session/
|
|
15545
|
+
// ../core/src/session/stay-signed-in.ts
|
|
15546
|
+
var DAY2 = 24 * 60 * 60 * 1e3;
|
|
15547
|
+
var DURATION2 = { never: 0, "1d": DAY2, "7d": 7 * DAY2, "30d": 30 * DAY2 };
|
|
15548
|
+
|
|
15549
|
+
// ../core/src/session/connect.ts
|
|
15545
15550
|
function grantSigner(grant) {
|
|
15546
15551
|
let token = null;
|
|
15547
15552
|
return {
|
|
@@ -15557,7 +15562,7 @@ function grantSigner(grant) {
|
|
|
15557
15562
|
};
|
|
15558
15563
|
}
|
|
15559
15564
|
|
|
15560
|
-
// ../src/session/agent-link.ts
|
|
15565
|
+
// ../core/src/session/agent-link.ts
|
|
15561
15566
|
var SECRET_BYTES = 16;
|
|
15562
15567
|
var ROOM_PREFIX2 = utf8Encode("weave-agent-link-room-v1");
|
|
15563
15568
|
var KEY_INFO = utf8Encode("weave-agent-link-key-v1");
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weaveprotocol/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "The Weave protocol from a terminal: manage spaces, run an always-on node, serve MCP to agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"weave": "dist/weave.mjs"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"start": "node --import tsx src/main.ts",
|
|
11
|
-
"
|
|
10
|
+
"start": "node --conditions=@weaveprotocol/source --import tsx src/main.ts",
|
|
11
|
+
"test": "node --conditions=@weaveprotocol/source --import tsx --test tests/*.test.ts",
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"bundle": "esbuild src/main.ts --bundle --platform=node --format=esm --target=node22 --conditions=@weaveprotocol/source --outfile=dist/weave.mjs --external:ws --external:node-datachannel --banner:js='#!/usr/bin/env node'",
|
|
14
|
+
"bundle:pay": "esbuild pay/walletconnect.ts --bundle --format=esm --minify --platform=browser --target=es2022 --outfile=pay/dist/walletconnect.js --define:process.env.NODE_ENV='\"production\"'",
|
|
12
15
|
"build": "bun build.ts",
|
|
13
|
-
"prepublishOnly": "npm run bundle && npm run bundle:pay"
|
|
14
|
-
"bundle:pay": "esbuild pay/walletconnect.ts --bundle --format=esm --minify --platform=browser --target=es2022 --outfile=pay/dist/walletconnect.js --define:process.env.NODE_ENV='\"production\"'"
|
|
16
|
+
"prepublishOnly": "npm run bundle && npm run bundle:pay"
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"node-datachannel": "^0.33.4",
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
"repository": {
|
|
25
27
|
"type": "git",
|
|
26
28
|
"url": "git+https://github.com/leifriksheim/weave.git",
|
|
27
|
-
"directory": "cli"
|
|
29
|
+
"directory": "packages/cli"
|
|
28
30
|
},
|
|
29
31
|
"files": [
|
|
30
32
|
"dist/weave.mjs",
|
|
@@ -33,6 +35,9 @@
|
|
|
33
35
|
],
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@reown/appkit": "^1.8.24",
|
|
38
|
+
"@types/node": "^26.6.3",
|
|
39
|
+
"@weaveprotocol/core": "*",
|
|
40
|
+
"@weaveprotocol/relay": "*",
|
|
36
41
|
"esbuild": "^0.28.0",
|
|
37
42
|
"tsx": "^4.19.0"
|
|
38
43
|
},
|