@cero-base/core 2.1.1 → 2.1.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The building blocks `cero` is made of. Use them when `cero` is too high-level — when you want just an autobee, just a swarm, or just signed pairing.
4
4
 
5
- Each subpath is a small, independent primitive. `ReadyResource`-shaped where it makes sense (`.ready()` + `.close()`).
5
+ Seven primitives, one subpath each: identity, storage, network, database, blobs, pairing, rpc. `ReadyResource`-shaped where it makes sense (`.ready()` + `.close()`).
6
6
 
7
7
  ```js
8
8
  // Barrel import — everything in one place
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cero-base/core",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -18,7 +18,8 @@
18
18
  "src",
19
19
  "types",
20
20
  "README.md",
21
- "LICENSE"
21
+ "LICENSE",
22
+ "!src/**/CLAUDE.md"
22
23
  ],
23
24
  "publishConfig": {
24
25
  "access": "public"
@@ -139,7 +140,7 @@
139
140
  },
140
141
  "dependencies": {
141
142
  "@hyperswarm/secret-stream": "^6.9.1",
142
- "autobee": "^2.1.1",
143
+ "autobee": "^2.2.1",
143
144
  "autobee-encryption": "0.1.3",
144
145
  "b4a": "^1.8.1",
145
146
  "bare-crypto": "^1.15.3",
@@ -8,7 +8,8 @@ import b4a from 'b4a'
8
8
  import hid from 'hypercore-id-encoding'
9
9
 
10
10
  import { NAMESPACE, SINGLE, COLLECTION, ACTION, QUERY_RESERVED } from '../lib/constants.js'
11
- import { genId, subscribe, admission, ownership, filter } from '../lib/utils.js'
11
+ import { genId } from '../lib/ids.js'
12
+ import { subscribe, admission, ownership, filter } from '../lib/utils.js'
12
13
  import { wrap, unwrap } from './envelope.js'
13
14
  import { EpochAutobee, Keyring, loadEpochs } from './encryption.js'
14
15
  import { CeroError } from '../lib/errors.js'
package/src/lib/ids.js ADDED
@@ -0,0 +1,11 @@
1
+ import crypto from 'crypto'
2
+ import z32 from 'z32'
3
+
4
+ /**
5
+ * Generate a short opaque id (z32-encoded 16 random bytes).
6
+ *
7
+ * @returns {string}
8
+ */
9
+ export function genId() {
10
+ return z32.encode(crypto.randomBytes(16))
11
+ }
package/src/lib/utils.js CHANGED
@@ -1,25 +1,14 @@
1
- import crypto from 'crypto'
2
1
  import b4a from 'b4a'
3
2
  import { Readable } from 'streamx'
4
- import z32 from 'z32'
5
3
 
6
4
  import { ROLE_PERMS, RANK, QUERY_RESERVED } from './constants.js'
7
5
 
8
6
  // can() callers need the capability names, and constants.js is not public
9
7
  export { WRITE, INVITE, ASSIGN, REMOVE } from './constants.js'
10
8
 
11
- /**
12
- * Generate a short opaque id (z32-encoded 16 random bytes).
13
- *
14
- * @returns {string}
15
- */
16
- export function genId() {
17
- return z32.encode(crypto.randomBytes(16))
18
- }
19
-
20
9
  // binding the db key makes an admission unreplayable across rooms
21
- const ADD_WRITER_TAG = b4a.from('cero/add-writer/v2')
22
- const CLAIM_WRITER_TAG = b4a.from('cero/claim-writer/v2')
10
+ const ADD_WRITER_TAG = b4a.from('cero/add-writer')
11
+ const CLAIM_WRITER_TAG = b4a.from('cero/claim-writer')
23
12
 
24
13
  /** @type {(dbKey: Uint8Array, writer: Uint8Array, appender: Uint8Array) => Uint8Array} */
25
14
  export function admission(dbKey, writer, appender) {
@@ -6,7 +6,8 @@ import HyperDB from 'hyperdb'
6
6
  import ReadyResource from 'ready-resource'
7
7
 
8
8
  import { ROCKS, BEE, SINGLE, COLLECTION, QUERY_RESERVED } from '../lib/constants.js'
9
- import { genId, subscribe, filter } from '../lib/utils.js'
9
+ import { genId } from '../lib/ids.js'
10
+ import { subscribe, filter } from '../lib/utils.js'
10
11
  import { CeroError } from '../lib/errors.js'
11
12
 
12
13
  /**
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a short opaque id (z32-encoded 16 random bytes).
3
+ *
4
+ * @returns {string}
5
+ */
6
+ export declare function genId(): string;
@@ -1,10 +1,4 @@
1
1
  export { WRITE, INVITE, ASSIGN, REMOVE } from './constants.js';
2
- /**
3
- * Generate a short opaque id (z32-encoded 16 random bytes).
4
- *
5
- * @returns {string}
6
- */
7
- export declare function genId(): string;
8
2
  /** @type {(dbKey: Uint8Array, writer: Uint8Array, appender: Uint8Array) => Uint8Array} */
9
3
  export declare function admission(dbKey: Uint8Array<ArrayBufferLike>, writer: Uint8Array<ArrayBufferLike>, appender: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>;
10
4
  /** @type {(dbKey: Uint8Array, writer: Uint8Array) => Uint8Array} */