@johnhenry/browsermesh-objects 0.0.0 → 0.1.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/package.json +14 -2
- package/src/who.mjs +13 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/browsermesh-objects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "wsh's remote-object layer (values, events, handles, callbacks) over a BrowserMesh protocol channel, authorised per root and per action for the channel's verified peer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"LICENSE",
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "node --test test/*.test.mjs",
|
|
17
|
+
"test:real-peer": "node --test --test-concurrency=1 test/real-peer/*.test.mjs"
|
|
18
|
+
},
|
|
15
19
|
"keywords": [
|
|
16
20
|
"wsh",
|
|
17
21
|
"remote-objects",
|
|
@@ -31,6 +35,14 @@
|
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
33
37
|
"@johnhenry/browsermesh-apps": ">=0.21.0 <1.0.0",
|
|
34
|
-
"@johnhenry/wsh": ">=0.
|
|
38
|
+
"@johnhenry/wsh": ">=0.49.0 <1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@johnhenry/browsermesh-apps": "^0.21.1",
|
|
42
|
+
"@johnhenry/browsermesh-core": "^0.13.0",
|
|
43
|
+
"@johnhenry/browsermesh-primitives": "^0.6.1",
|
|
44
|
+
"@johnhenry/browsermesh-transport": "^0.9.0",
|
|
45
|
+
"@johnhenry/wsh": "^0.50.0",
|
|
46
|
+
"node-datachannel": "^0.33.4"
|
|
35
47
|
}
|
|
36
48
|
}
|
package/src/who.mjs
CHANGED
|
@@ -3,23 +3,26 @@
|
|
|
3
3
|
* where a mesh peer is turned into the layer's notion of "who".
|
|
4
4
|
*
|
|
5
5
|
* Over a mesh channel the caller is the channel's VERIFIED peer: a pod id, the
|
|
6
|
-
* key the session is bound to, never a field of a message. wsh's layer
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 0.48 the layer passes the object it was given through to `authorize`
|
|
13
|
-
* untouched, which is how this adapter reads it back).
|
|
6
|
+
* key the session is bound to, never a field of a message. wsh's layer takes
|
|
7
|
+
* `who: { username, fingerprint, podId }` (@johnhenry/wsh >= 0.49): the pod id
|
|
8
|
+
* goes in `podId`, and wsh derives the fingerprint of the same key from it
|
|
9
|
+
* (`normalizeIdentity`, strict: exactly 43 canonical base64url characters, the
|
|
10
|
+
* SHA-256 of a public key). Nothing is spelled here that wsh already knows how
|
|
11
|
+
* to spell.
|
|
14
12
|
*
|
|
15
13
|
* Every decision of this package is made from `who.podId` and from nothing
|
|
16
14
|
* else; the layer's own `fingerprint` is never consulted.
|
|
17
15
|
*/
|
|
16
|
+
import { normalizeIdentity } from '@johnhenry/wsh/identity'
|
|
18
17
|
|
|
19
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} podId the channel's verified peer
|
|
20
|
+
* @returns {Readonly<{ username: null, fingerprint: string, podId: string }>}
|
|
21
|
+
* @throws {TypeError} when the channel has no verified peer, or what it names is not a pod id
|
|
22
|
+
*/
|
|
20
23
|
export function whoFor(podId) {
|
|
21
24
|
if (typeof podId !== 'string' || !podId) throw new TypeError('whoFor: the channel has no verified peer')
|
|
22
|
-
return Object.freeze({ username: null,
|
|
25
|
+
return Object.freeze(normalizeIdentity({ username: null, podId }))
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** The pod id a `who` names, or null when it names none (then nothing is allowed). */
|