@serfab/cadre-core 0.6.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/authority-key.d.ts +41 -0
- package/dist/authority-key.js +52 -0
- package/dist/authority-key.js.map +1 -0
- package/dist/cadre-node.d.ts +777 -11
- package/dist/cadre-node.js +1912 -82
- package/dist/cadre-node.js.map +1 -1
- package/dist/canonical-datetime.d.ts +33 -0
- package/dist/canonical-datetime.js +38 -0
- package/dist/canonical-datetime.js.map +1 -0
- package/dist/canonical-json.d.ts +12 -0
- package/dist/canonical-json.js +33 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/control-cohort.d.ts +63 -0
- package/dist/control-cohort.js +80 -0
- package/dist/control-cohort.js.map +1 -0
- package/dist/control-database.d.ts +259 -5
- package/dist/control-database.js +541 -128
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +89 -0
- package/dist/control-formation-recorder.js +139 -0
- package/dist/control-formation-recorder.js.map +1 -0
- package/dist/control-schema.d.ts +12 -0
- package/dist/control-schema.js +199 -0
- package/dist/control-schema.js.map +1 -0
- package/dist/control-stream.d.ts +54 -0
- package/dist/control-stream.js +104 -0
- package/dist/control-stream.js.map +1 -0
- package/dist/device-token.d.ts +50 -0
- package/dist/device-token.js +66 -0
- package/dist/device-token.js.map +1 -0
- package/dist/diagnostics/connection-path.d.ts +118 -0
- package/dist/diagnostics/connection-path.js +204 -0
- package/dist/diagnostics/connection-path.js.map +1 -0
- package/dist/diagnostics/webrtc-turn-tracker.d.ts +50 -0
- package/dist/diagnostics/webrtc-turn-tracker.js +196 -0
- package/dist/diagnostics/webrtc-turn-tracker.js.map +1 -0
- package/dist/hibernation-manager.d.ts +79 -0
- package/dist/hibernation-manager.js +173 -23
- package/dist/hibernation-manager.js.map +1 -1
- package/dist/index.d.ts +25 -4
- package/dist/index.js +59 -4
- package/dist/index.js.map +1 -1
- package/dist/key-store-file.d.ts +52 -0
- package/dist/key-store-file.js +194 -0
- package/dist/key-store-file.js.map +1 -0
- package/dist/key-store.d.ts +75 -0
- package/dist/key-store.js +66 -0
- package/dist/key-store.js.map +1 -0
- package/dist/peer-authorization.d.ts +26 -0
- package/dist/peer-authorization.js +40 -0
- package/dist/peer-authorization.js.map +1 -0
- package/dist/peer-record.d.ts +89 -0
- package/dist/peer-record.js +117 -0
- package/dist/peer-record.js.map +1 -0
- package/dist/push-credentials.d.ts +34 -0
- package/dist/push-credentials.js +81 -0
- package/dist/push-credentials.js.map +1 -0
- package/dist/push-fanout.d.ts +137 -0
- package/dist/push-fanout.js +197 -0
- package/dist/push-fanout.js.map +1 -0
- package/dist/push-notifier-apns.d.ts +53 -0
- package/dist/push-notifier-apns.js +195 -0
- package/dist/push-notifier-apns.js.map +1 -0
- package/dist/push-notifier-fcm.d.ts +38 -0
- package/dist/push-notifier-fcm.js +183 -0
- package/dist/push-notifier-fcm.js.map +1 -0
- package/dist/push-notifier-shared.d.ts +18 -0
- package/dist/push-notifier-shared.js +25 -0
- package/dist/push-notifier-shared.js.map +1 -0
- package/dist/push-notifier.d.ts +71 -0
- package/dist/push-notifier.js +50 -0
- package/dist/push-notifier.js.map +1 -0
- package/dist/schema-verification.d.ts +11 -2
- package/dist/schema-verification.js +15 -4
- package/dist/schema-verification.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +210 -7
- package/dist/seed-bootstrap.js +429 -131
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +63 -0
- package/dist/seed-trust-policy.js +56 -0
- package/dist/seed-trust-policy.js.map +1 -0
- package/dist/strand-addr-protocol.d.ts +132 -0
- package/dist/strand-addr-protocol.js +313 -0
- package/dist/strand-addr-protocol.js.map +1 -0
- package/dist/strand-cohort.d.ts +54 -0
- package/dist/strand-cohort.js +38 -0
- package/dist/strand-cohort.js.map +1 -0
- package/dist/strand-database.d.ts +54 -6
- package/dist/strand-database.js +88 -89
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-formation-manager.d.ts +79 -19
- package/dist/strand-formation-manager.js +196 -104
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +162 -0
- package/dist/strand-formation-protocol.js +279 -0
- package/dist/strand-formation-protocol.js.map +1 -0
- package/dist/strand-instance-manager.d.ts +73 -4
- package/dist/strand-instance-manager.js +167 -41
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-key.d.ts +29 -0
- package/dist/strand-member-key.js +38 -0
- package/dist/strand-member-key.js.map +1 -0
- package/dist/strand-member-registry.d.ts +98 -0
- package/dist/strand-member-registry.js +129 -0
- package/dist/strand-member-registry.js.map +1 -0
- package/dist/strand-membership-writer.d.ts +361 -0
- package/dist/strand-membership-writer.js +449 -0
- package/dist/strand-membership-writer.js.map +1 -0
- package/dist/strand-solicitation.d.ts +77 -2
- package/dist/strand-solicitation.js +25 -4
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-payload.d.ts +30 -0
- package/dist/strand-wake-payload.js +20 -0
- package/dist/strand-wake-payload.js.map +1 -0
- package/dist/strand-wake-protocol.d.ts +114 -0
- package/dist/strand-wake-protocol.js +257 -0
- package/dist/strand-wake-protocol.js.map +1 -0
- package/dist/strand-watcher.d.ts +6 -2
- package/dist/strand-watcher.js +57 -17
- package/dist/strand-watcher.js.map +1 -1
- package/dist/types.d.ts +413 -23
- package/dist/types.js +22 -5
- package/dist/types.js.map +1 -1
- package/package.json +14 -8
- package/src/authority-key.ts +68 -0
- package/src/cadre-node.ts +2937 -929
- package/src/canonical-datetime.ts +39 -0
- package/src/canonical-json.ts +30 -0
- package/src/control-cohort.ts +103 -0
- package/src/control-database.ts +931 -383
- package/src/control-formation-recorder.ts +151 -0
- package/src/control-schema.ts +198 -0
- package/src/control-stream.ts +128 -0
- package/src/device-token.ts +89 -0
- package/src/diagnostics/connection-path.ts +277 -0
- package/src/diagnostics/webrtc-turn-tracker.ts +222 -0
- package/src/hibernation-manager.ts +197 -28
- package/src/index.ts +273 -79
- package/src/key-store-file.ts +203 -0
- package/src/key-store.ts +99 -0
- package/src/peer-authorization.ts +53 -0
- package/src/peer-record.ts +146 -0
- package/src/push-credentials.ts +84 -0
- package/src/push-fanout.ts +272 -0
- package/src/push-notifier-apns.ts +243 -0
- package/src/push-notifier-fcm.ts +221 -0
- package/src/push-notifier-shared.ts +28 -0
- package/src/push-notifier.ts +93 -0
- package/src/schema-verification.ts +18 -4
- package/src/seed-bootstrap.ts +504 -171
- package/src/seed-trust-policy.ts +107 -0
- package/src/strand-addr-protocol.ts +410 -0
- package/src/strand-cohort.ts +77 -0
- package/src/strand-database.ts +113 -126
- package/src/strand-formation-manager.ts +233 -142
- package/src/strand-formation-protocol.ts +391 -0
- package/src/strand-instance-manager.ts +207 -56
- package/src/strand-member-key.ts +39 -0
- package/src/strand-member-registry.ts +177 -0
- package/src/strand-membership-writer.ts +640 -0
- package/src/strand-solicitation.ts +93 -4
- package/src/strand-wake-payload.ts +32 -0
- package/src/strand-wake-protocol.ts +331 -0
- package/src/strand-watcher.ts +61 -17
- package/src/types.ts +1012 -575
package/README.md
CHANGED
|
@@ -91,12 +91,14 @@ await node.stop();
|
|
|
91
91
|
|
|
92
92
|
## Node Profiles
|
|
93
93
|
|
|
94
|
-
| Profile | Storage Role | Use Case | Ring
|
|
95
|
-
|
|
96
|
-
| **transaction** |
|
|
97
|
-
| **storage** | Ring Zulu +
|
|
94
|
+
| Profile | Storage Role | Use Case | Ring Zulu |
|
|
95
|
+
|---------|--------------|----------|-----------|
|
|
96
|
+
| **transaction** | Arachnode disabled; transaction verification via FRET only | Mobile devices, intermittent connectivity | No |
|
|
97
|
+
| **storage** | Ring Zulu + storage rings (storage rings not yet implemented — stub) | Servers, NAS, always-on nodes | Yes |
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Transaction-profile nodes verify transactions via FRET only, with Arachnode disabled. Storage-profile nodes additionally join Ring Zulu and (when implemented) the concentric storage rings.
|
|
100
|
+
|
|
101
|
+
> **Note:** The storage-ring subsystem is currently a no-op stub (`arachnode-stub.ts`). See [Node Profiles in `docs/architecture.md`](../../docs/architecture.md#node-profiles) for the full design.
|
|
100
102
|
|
|
101
103
|
## Strand Filtering
|
|
102
104
|
|
|
@@ -104,7 +106,7 @@ Mobile apps typically shouldn't participate in all strands. Use filters to contr
|
|
|
104
106
|
|
|
105
107
|
```typescript
|
|
106
108
|
// Only participate in strands for a specific app
|
|
107
|
-
strandFilter: { mode: '
|
|
109
|
+
strandFilter: { mode: 'sAppId', sAppId: 'com.example.chat' }
|
|
108
110
|
|
|
109
111
|
// Only participate in one specific strand
|
|
110
112
|
strandFilter: { mode: 'strandId', strandId: 'strand-abc123' }
|
|
@@ -151,7 +153,7 @@ const { seed, encodedSeed } = await node.addDrone({
|
|
|
151
153
|
});
|
|
152
154
|
|
|
153
155
|
// Send to provider for drone initialization
|
|
154
|
-
await provider.
|
|
156
|
+
await provider.initializeNode(droneInfo.containerId, encodedSeed);
|
|
155
157
|
```
|
|
156
158
|
|
|
157
159
|
## API Reference
|
|
@@ -240,7 +242,6 @@ Available storage implementations:
|
|
|
240
242
|
|
|
241
243
|
## Related Packages
|
|
242
244
|
|
|
243
|
-
- **[@serfab/strand-proto](../strand-proto/)** - Strand initialization protocol
|
|
244
245
|
- **[@optimystic/db-core](https://github.com/gotchoices/optimystic)** - Distributed database core
|
|
245
246
|
- **[@optimystic/db-p2p](https://github.com/gotchoices/optimystic)** - libp2p integration for Optimystic
|
|
246
247
|
- **[@optimystic/db-p2p-storage-fs](https://github.com/gotchoices/optimystic)** - File system storage (Node.js)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PrivateKey } from '@libp2p/interface';
|
|
2
|
+
/**
|
|
3
|
+
* A household authority keypair expressed in the base64url Ed25519 form that
|
|
4
|
+
* `@optimystic/quereus-plugin-crypto` (`sign`/`verify`/`getPublicKey`) consumes.
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthorityKeyPair {
|
|
7
|
+
/** 32-byte Ed25519 seed, base64url-encoded — the crypto-plugin private key. */
|
|
8
|
+
privateKeyB64: string;
|
|
9
|
+
/** 32-byte Ed25519 public key, base64url-encoded. */
|
|
10
|
+
publicKeyB64: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Bridge a libp2p Ed25519 private key into the base64url keypair used by the
|
|
14
|
+
* control-database authority constraints.
|
|
15
|
+
*
|
|
16
|
+
* libp2p stores an Ed25519 private key as 64 raw bytes: the first 32 are the
|
|
17
|
+
* seed (the actual scalar source), the last 32 are the public key — see
|
|
18
|
+
* `@libp2p/crypto`'s `Ed25519PrivateKey`. `@optimystic/quereus-plugin-crypto`
|
|
19
|
+
* (via `@noble/curves`) treats the 32-byte seed *as* the private key and
|
|
20
|
+
* derives the public key from it with standard Ed25519. The two derivations
|
|
21
|
+
* agree, so the node's peer identity and its authority key are one keypair:
|
|
22
|
+
* `getPublicKey(privateKeyB64)` === `publicKeyB64`.
|
|
23
|
+
*
|
|
24
|
+
* @param privateKey - The node's libp2p Ed25519 private key.
|
|
25
|
+
* @returns The base64url seed/public-key pair for authority operations.
|
|
26
|
+
* @throws If the key is not Ed25519 or the raw bytes aren't the expected length.
|
|
27
|
+
*/
|
|
28
|
+
export declare function authorityKeyFromLibp2p(privateKey: PrivateKey): AuthorityKeyPair;
|
|
29
|
+
/**
|
|
30
|
+
* Derive the base64url Ed25519 public key from a base64url 32-byte private seed
|
|
31
|
+
* — the same derivation the seed-bootstrap signer uses internally
|
|
32
|
+
* (`SeedBootstrapService` constructor). Use this to enroll a standalone
|
|
33
|
+
* (non-libp2p) authority key into the control DB via
|
|
34
|
+
* `ControlDatabase.ensureAuthorityKey` before minting an invite, when the
|
|
35
|
+
* authority key is *not* the node's peer identity (so `authorityKeyFromLibp2p`,
|
|
36
|
+
* which needs a libp2p key object, does not apply).
|
|
37
|
+
*
|
|
38
|
+
* @param privateKeyB64 - The base64url-encoded 32-byte Ed25519 seed.
|
|
39
|
+
* @returns The base64url-encoded Ed25519 public key.
|
|
40
|
+
*/
|
|
41
|
+
export declare function authorityPublicKeyFromPrivate(privateKeyB64: string): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { toString as uint8ArrayToString } from 'uint8arrays';
|
|
2
|
+
import { getPublicKey } from '@optimystic/quereus-plugin-crypto';
|
|
3
|
+
/**
|
|
4
|
+
* Bridge a libp2p Ed25519 private key into the base64url keypair used by the
|
|
5
|
+
* control-database authority constraints.
|
|
6
|
+
*
|
|
7
|
+
* libp2p stores an Ed25519 private key as 64 raw bytes: the first 32 are the
|
|
8
|
+
* seed (the actual scalar source), the last 32 are the public key — see
|
|
9
|
+
* `@libp2p/crypto`'s `Ed25519PrivateKey`. `@optimystic/quereus-plugin-crypto`
|
|
10
|
+
* (via `@noble/curves`) treats the 32-byte seed *as* the private key and
|
|
11
|
+
* derives the public key from it with standard Ed25519. The two derivations
|
|
12
|
+
* agree, so the node's peer identity and its authority key are one keypair:
|
|
13
|
+
* `getPublicKey(privateKeyB64)` === `publicKeyB64`.
|
|
14
|
+
*
|
|
15
|
+
* @param privateKey - The node's libp2p Ed25519 private key.
|
|
16
|
+
* @returns The base64url seed/public-key pair for authority operations.
|
|
17
|
+
* @throws If the key is not Ed25519 or the raw bytes aren't the expected length.
|
|
18
|
+
*/
|
|
19
|
+
export function authorityKeyFromLibp2p(privateKey) {
|
|
20
|
+
if (privateKey.type !== 'Ed25519') {
|
|
21
|
+
throw new Error(`authorityKeyFromLibp2p requires an Ed25519 key, got ${privateKey.type}`);
|
|
22
|
+
}
|
|
23
|
+
const raw = privateKey.raw;
|
|
24
|
+
if (raw.length !== 64) {
|
|
25
|
+
throw new Error(`Expected a 64-byte Ed25519 raw private key (seed||public), got ${raw.length} bytes`);
|
|
26
|
+
}
|
|
27
|
+
const seed = raw.subarray(0, 32);
|
|
28
|
+
const publicKeyRaw = privateKey.publicKey.raw;
|
|
29
|
+
if (publicKeyRaw.length !== 32) {
|
|
30
|
+
throw new Error(`Expected a 32-byte Ed25519 public key, got ${publicKeyRaw.length} bytes`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
privateKeyB64: uint8ArrayToString(seed, 'base64url'),
|
|
34
|
+
publicKeyB64: uint8ArrayToString(publicKeyRaw, 'base64url'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Derive the base64url Ed25519 public key from a base64url 32-byte private seed
|
|
39
|
+
* — the same derivation the seed-bootstrap signer uses internally
|
|
40
|
+
* (`SeedBootstrapService` constructor). Use this to enroll a standalone
|
|
41
|
+
* (non-libp2p) authority key into the control DB via
|
|
42
|
+
* `ControlDatabase.ensureAuthorityKey` before minting an invite, when the
|
|
43
|
+
* authority key is *not* the node's peer identity (so `authorityKeyFromLibp2p`,
|
|
44
|
+
* which needs a libp2p key object, does not apply).
|
|
45
|
+
*
|
|
46
|
+
* @param privateKeyB64 - The base64url-encoded 32-byte Ed25519 seed.
|
|
47
|
+
* @returns The base64url-encoded Ed25519 public key.
|
|
48
|
+
*/
|
|
49
|
+
export function authorityPublicKeyFromPrivate(privateKeyB64) {
|
|
50
|
+
return getPublicKey(privateKeyB64, 'ed25519', 'base64url', 'base64url');
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=authority-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-key.js","sourceRoot":"","sources":["../src/authority-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAcjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAsB;IAC3D,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,uDAAuD,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kEAAkE,GAAG,CAAC,MAAM,QAAQ,CAAC,CAAC;IACxG,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC;IAC9C,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,8CAA8C,YAAY,CAAC,MAAM,QAAQ,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO;QACL,aAAa,EAAE,kBAAkB,CAAC,IAAI,EAAE,WAAW,CAAC;QACpD,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,WAAW,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,6BAA6B,CAAC,aAAqB;IACjE,OAAO,YAAY,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAW,CAAC;AACpF,CAAC"}
|