@johnhenry/browsermesh-core 0.3.1 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/browsermesh-core",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Identity, crypto, peer management, and trust primitives for BrowserMesh",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -20,7 +20,7 @@
20
20
  "directory": "packages/browsermesh-core"
21
21
  },
22
22
  "peerDependencies": {
23
- "@johnhenry/browsermesh-primitives": ">=0.0.1 <1.0.0",
23
+ "@johnhenry/browsermesh-primitives": ">=0.2.0 <1.0.0",
24
24
  "@johnhenry/browsermesh-apps": ">=0.4.0 <1.0.0"
25
25
  },
26
26
  "peerDependenciesMeta": {
@@ -405,12 +405,15 @@ export class IdentityWallet {
405
405
  * Verify a signature against a public key (raw bytes).
406
406
  *
407
407
  * @param {Uint8Array} pubKeyBytes
408
- * @param {BufferSource} data
408
+ * Argument order is `(publicKey, signature, data)`, like WebCrypto.
409
+ * BREAKING in core 0.5.0: previously `(publicKey, data, signature)`.
410
+ *
409
411
  * @param {BufferSource} sig
412
+ * @param {BufferSource} data
410
413
  * @returns {Promise<boolean>}
411
414
  */
412
- async verify(pubKeyBytes, data, sig) {
413
- return this.#identityManager.verify(pubKeyBytes, data, sig);
415
+ async verify(pubKeyBytes, sig, data) {
416
+ return this.#identityManager.verify(pubKeyBytes, sig, data);
414
417
  }
415
418
 
416
419
  /**
package/src/identity.mjs CHANGED
@@ -614,12 +614,17 @@ export class MeshIdentityManager {
614
614
  /**
615
615
  * Verify a signature against a public key (raw bytes).
616
616
  *
617
+ * Argument order is `(publicKey, signature, data)`, the same as
618
+ * `crypto.subtle.verify`. BREAKING in core 0.5.0: previously
619
+ * `(publicKey, data, signature)`. Throws a TypeError when the old order is
620
+ * detected (64-byte data with a non-64-byte signature).
621
+ *
617
622
  * @param {Uint8Array} publicKeyBytes - Raw Ed25519 public key (32 bytes)
623
+ * @param {BufferSource} signature - Ed25519 signature (64 bytes)
618
624
  * @param {BufferSource} data
619
- * @param {BufferSource} signature
620
625
  * @returns {Promise<boolean>}
621
626
  */
622
- async verify(publicKeyBytes, data, signature) {
627
+ async verify(publicKeyBytes, signature, data) {
623
628
  const publicKey = await crypto.subtle.importKey(
624
629
  'raw',
625
630
  publicKeyBytes,
@@ -627,7 +632,7 @@ export class MeshIdentityManager {
627
632
  false,
628
633
  ['verify']
629
634
  );
630
- return PodIdentity.verify(publicKey, data, signature);
635
+ return PodIdentity.verify(publicKey, signature, data);
631
636
  }
632
637
 
633
638
  /**