@cero-base/core 0.4.0 → 0.4.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/package.json +49 -13
- package/src/pairing/index.js +16 -0
- package/types/pairing/index.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -15,18 +15,54 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
|
-
".":
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"./
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"./
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
20
|
+
"default": "./src/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./identity": {
|
|
23
|
+
"types": "./types/identity/index.d.ts",
|
|
24
|
+
"default": "./src/identity/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./storage": {
|
|
27
|
+
"types": "./types/storage/index.d.ts",
|
|
28
|
+
"default": "./src/storage/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./network": {
|
|
31
|
+
"types": "./types/network/index.d.ts",
|
|
32
|
+
"default": "./src/network/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./database": {
|
|
35
|
+
"types": "./types/database/index.d.ts",
|
|
36
|
+
"default": "./src/database/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./blobs": {
|
|
39
|
+
"types": "./types/blobs/index.d.ts",
|
|
40
|
+
"default": "./src/blobs/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./rpc": {
|
|
43
|
+
"types": "./types/rpc/index.d.ts",
|
|
44
|
+
"default": "./src/rpc/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./pairing": {
|
|
47
|
+
"types": "./types/pairing/index.d.ts",
|
|
48
|
+
"default": "./src/pairing/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./invite": {
|
|
51
|
+
"types": "./types/pairing/invite.d.ts",
|
|
52
|
+
"default": "./src/pairing/invite.js"
|
|
53
|
+
},
|
|
54
|
+
"./schema": {
|
|
55
|
+
"types": "./types/lib/schema.d.ts",
|
|
56
|
+
"default": "./src/lib/schema.js"
|
|
57
|
+
},
|
|
58
|
+
"./utils": {
|
|
59
|
+
"types": "./types/lib/utils.d.ts",
|
|
60
|
+
"default": "./src/lib/utils.js"
|
|
61
|
+
},
|
|
62
|
+
"./errors": {
|
|
63
|
+
"types": "./types/lib/errors.d.ts",
|
|
64
|
+
"default": "./src/lib/errors.js"
|
|
65
|
+
}
|
|
30
66
|
},
|
|
31
67
|
"typesVersions": {
|
|
32
68
|
"*": {
|
package/src/pairing/index.js
CHANGED
|
@@ -102,6 +102,22 @@ export class Pairing extends ReadyResource {
|
|
|
102
102
|
this._invites.clear()
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the resource discovery key an invite targets — without pairing.
|
|
107
|
+
* Lets callers detect "already joined" before any handshake. Returns `null`
|
|
108
|
+
* for an unparseable invite.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} inviteStr
|
|
111
|
+
* @returns {Uint8Array | null}
|
|
112
|
+
*/
|
|
113
|
+
static inviteTopic(inviteStr) {
|
|
114
|
+
try {
|
|
115
|
+
return Invite.parse(inviteStr).blind.discoveryKey
|
|
116
|
+
} catch {
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
105
121
|
/**
|
|
106
122
|
* Mint a new pairing invite. Returns its canonical wire form (z32 string).
|
|
107
123
|
*
|
package/types/pairing/index.d.ts
CHANGED
|
@@ -37,6 +37,15 @@
|
|
|
37
37
|
* the supplied network.
|
|
38
38
|
*/
|
|
39
39
|
export class Pairing extends ReadyResource {
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the resource discovery key an invite targets — without pairing.
|
|
42
|
+
* Lets callers detect "already joined" before any handshake. Returns `null`
|
|
43
|
+
* for an unparseable invite.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} inviteStr
|
|
46
|
+
* @returns {Uint8Array | null}
|
|
47
|
+
*/
|
|
48
|
+
static inviteTopic(inviteStr: string): Uint8Array | null;
|
|
40
49
|
/**
|
|
41
50
|
* Cheap structural test for a candidate invite string.
|
|
42
51
|
*
|