@johnhenry/browsermesh-apps 0.7.1 → 0.8.0
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 +2 -2
- package/src/grant-log.mjs +2 -2
- package/src/key-distribution.mjs +1 -1
- package/src/payments.mjs +3 -3
- package/src/peer-chat.mjs +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/browsermesh-apps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Application layer: marketplace, chat, payments, compute, orchestration, and agent tools for BrowserMesh",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@johnhenry/browsermesh-primitives": ">=0.0.1 <1.0.0",
|
|
31
|
-
"@johnhenry/browsermesh-core": ">=0.
|
|
31
|
+
"@johnhenry/browsermesh-core": ">=0.5.0 <1.0.0",
|
|
32
32
|
"@johnhenry/browsermesh-transport": ">=0.1.0 <1.0.0",
|
|
33
33
|
"@johnhenry/browsermesh-sync": ">=0.0.0 <1.0.0",
|
|
34
34
|
"@johnhenry/browsermesh-discovery": ">=0.0.1 <1.0.0",
|
package/src/grant-log.mjs
CHANGED
|
@@ -304,7 +304,7 @@ export class GrantLog {
|
|
|
304
304
|
#localPodId
|
|
305
305
|
|
|
306
306
|
/** @type {import('@johnhenry/browsermesh-core').IdentityWallet} Duck-typed:
|
|
307
|
-
* only `.sign(podId, data)`, `.verify(pubKeyBytes,
|
|
307
|
+
* only `.sign(podId, data)`, `.verify(pubKeyBytes, sig, data)`,
|
|
308
308
|
* `.getPublicKeyBytes(podId)` are used (the real `IdentityWallet`'s
|
|
309
309
|
* confirmed API, see identity-wallet.mjs / identity.mjs). */
|
|
310
310
|
#wallet
|
|
@@ -550,7 +550,7 @@ export class GrantLog {
|
|
|
550
550
|
if (derivedPodId !== signedBy) return false
|
|
551
551
|
|
|
552
552
|
const payload = new TextEncoder().encode(signedPayloadOf({ pubKey, scope, action, at, signedBy }))
|
|
553
|
-
return await this.#wallet.verify(rawPubKeyBytes,
|
|
553
|
+
return await this.#wallet.verify(rawPubKeyBytes, sigBytes, payload)
|
|
554
554
|
} catch {
|
|
555
555
|
// Malformed base64url, wrong-length keys/signatures, etc. are all
|
|
556
556
|
// "reject", never a thrown error the caller has to remember to catch.
|
package/src/key-distribution.mjs
CHANGED
|
@@ -452,7 +452,7 @@ export function createKeyDistributionService({
|
|
|
452
452
|
const payload = new TextEncoder().encode(signedPayloadOf({ resource, ephemeralPublicKey: envelope.ephemeralPublicKey, wrappedKey: envelope.wrappedKey, iv: envelope.iv, at, signedBy }))
|
|
453
453
|
let validSig = false
|
|
454
454
|
try {
|
|
455
|
-
validSig = await peerNode.wallet.verify(rawPubKeyBytes,
|
|
455
|
+
validSig = await peerNode.wallet.verify(rawPubKeyBytes, sigBytes, payload)
|
|
456
456
|
} catch {
|
|
457
457
|
validSig = false
|
|
458
458
|
}
|
package/src/payments.mjs
CHANGED
|
@@ -63,7 +63,7 @@ function generateEscrowId() {
|
|
|
63
63
|
// in without this published, general-purpose package taking a hard
|
|
64
64
|
// dependency on it. Shape matches peer-chat.mjs's convention:
|
|
65
65
|
// signFn: async (data: Uint8Array) => Uint8Array
|
|
66
|
-
// verifyFn: async (pubKey: Uint8Array,
|
|
66
|
+
// verifyFn: async (pubKey: Uint8Array, sig: Uint8Array, data: Uint8Array) => boolean
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Encode a Uint8Array to a base64 string.
|
|
@@ -436,7 +436,7 @@ export class PaymentChannel {
|
|
|
436
436
|
* @param {Function} [opts.signFn] - async (data: Uint8Array) => Uint8Array.
|
|
437
437
|
* When omitted, PaymentUpdate/close signatures stay `null` and close()
|
|
438
438
|
* stays unilateral -- fully backward compatible.
|
|
439
|
-
* @param {Function} [opts.verifyFn] - async (pubKey,
|
|
439
|
+
* @param {Function} [opts.verifyFn] - async (pubKey, sig, data) => boolean
|
|
440
440
|
* @param {Uint8Array} [opts.remotePublicKey] - Remote pod's raw public key,
|
|
441
441
|
* required alongside verifyFn to verify incoming updates/claims.
|
|
442
442
|
* @param {string} [opts.channelId] - Use this exact channel ID instead of
|
|
@@ -682,7 +682,7 @@ export class PaymentChannel {
|
|
|
682
682
|
try {
|
|
683
683
|
const data = canonicalBytes(fields);
|
|
684
684
|
const sigBytes = base64ToBytes(signatureB64);
|
|
685
|
-
return await this.#verifyFn(this.#remotePublicKey,
|
|
685
|
+
return await this.#verifyFn(this.#remotePublicKey, sigBytes, data);
|
|
686
686
|
} catch {
|
|
687
687
|
return false;
|
|
688
688
|
}
|
package/src/peer-chat.mjs
CHANGED
|
@@ -195,7 +195,7 @@ export class PeerChat {
|
|
|
195
195
|
* an envelope -- the caller, typically `createChatService()`, adds
|
|
196
196
|
* whatever envelope shape its own transport needs).
|
|
197
197
|
* @param {Function} [opts.signFn] - async (data: Uint8Array) => Uint8Array
|
|
198
|
-
* @param {Function} [opts.verifyFn] - async (fromPubKey,
|
|
198
|
+
* @param {Function} [opts.verifyFn] - async (fromPubKey, sig, data) => boolean
|
|
199
199
|
* @param {number} [opts.maxHistory=1000] - Maximum messages to retain
|
|
200
200
|
* @param {Function} [opts.autoResponder] - async (message) => string|null
|
|
201
201
|
* @param {Function} [opts.onLog] - Logging callback
|
|
@@ -349,7 +349,7 @@ export class PeerChat {
|
|
|
349
349
|
timestamp: message.timestamp,
|
|
350
350
|
}))
|
|
351
351
|
const sigBytes = base64ToBytes(message.signature)
|
|
352
|
-
message.verified = await this.#verifyFn(fromPubKey,
|
|
352
|
+
message.verified = await this.#verifyFn(fromPubKey, sigBytes, data)
|
|
353
353
|
} catch (err) {
|
|
354
354
|
this.#onLog(1, `Signature verification failed: ${err.message}`)
|
|
355
355
|
message.verified = false
|
|
@@ -498,7 +498,7 @@ export class PeerChat {
|
|
|
498
498
|
* @param {object} [opts]
|
|
499
499
|
* @param {Function} [opts.signFn] - async (data: Uint8Array) => Uint8Array.
|
|
500
500
|
* Passed straight through to `PeerChat`; omit to send unsigned messages.
|
|
501
|
-
* @param {Function} [opts.verifyFn] - async (fromPubKey,
|
|
501
|
+
* @param {Function} [opts.verifyFn] - async (fromPubKey, sig, data) => boolean.
|
|
502
502
|
* Passed straight through to `PeerChat`; called with each message's real
|
|
503
503
|
* sender, not a fixed key -- see module doc comment's point 2.
|
|
504
504
|
* @param {number} [opts.maxHistory=1000]
|