@johnhenry/browsermesh-objects 0.1.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  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.1.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",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@johnhenry/browsermesh-apps": ">=0.21.0 <1.0.0",
38
- "@johnhenry/wsh": ">=0.48.0 <1.0.0"
38
+ "@johnhenry/wsh": ">=0.49.0 <1.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@johnhenry/browsermesh-apps": "^0.21.1",
42
42
  "@johnhenry/browsermesh-core": "^0.13.0",
43
- "@johnhenry/browsermesh-primitives": "^0.6.0",
44
- "@johnhenry/browsermesh-transport": "^0.8.0",
45
- "@johnhenry/wsh": "^0.48.0",
43
+ "@johnhenry/browsermesh-primitives": "^0.6.1",
44
+ "@johnhenry/browsermesh-transport": "^0.9.0",
45
+ "@johnhenry/wsh": "^0.50.0",
46
46
  "node-datachannel": "^0.33.4"
47
47
  }
48
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 asks
7
- * for `who: { username, fingerprint }` (the shape of a wsh key login). A pod id
8
- * is not a wsh fingerprint, and putting one in `fingerprint` would be a lie
9
- * that other code may rely on (a log line, a revocation by fingerprint), so
10
- * this adapter does not: `username` and `fingerprint` stay null and the pod id
11
- * travels in `podId`, the neutral slot (@johnhenry/wsh >= 0.49 names it; on
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
- /** @param {string} podId the channel's verified peer @returns {{ username: null, fingerprint: null, podId: string }} */
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, fingerprint: null, podId })
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). */