@sockethub/util 1.0.0-alpha.8 → 1.0.0-alpha.9

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.
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- export declare function getPlatformId(platform: string, actor?: string, _crypto?: Crypto): string;
2
+ export declare function getPlatformId(platform: string, actor?: string, scope?: string, _crypto?: Crypto): string;
3
3
  export declare class Crypto {
4
4
  randomBytes: typeof randomBytes;
5
5
  constructor();
@@ -15,6 +15,16 @@ export declare class Crypto {
15
15
  * different (platform, actor) pairs to the same instance.
16
16
  */
17
17
  hashFull(text: string): string;
18
+ /**
19
+ * Stable hash of a credential object, used as the verifier that decides
20
+ * whether a session may reuse an existing platform connection.
21
+ *
22
+ * `object-hash` defaults to SHA-1; pinned to SHA-256 instead, since this
23
+ * backs an authorization decision. Not an exploit fix — the value is never
24
+ * exposed to clients, and forging a match needs a second preimage of an
25
+ * unknown credential object, which SHA-1 does not give you — but a new
26
+ * security-sensitive verifier should not be built on a deprecated digest.
27
+ */
18
28
  objectHash(object: object): string;
19
29
  /**
20
30
  * Derive a high-entropy secret from multiple input secrets.
@@ -19,12 +19,14 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  }
20
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
21
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
22
+ if (mod && typeof mod === "object" || typeof mod === "function") {
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ }
28
30
  if (canCache)
29
31
  cache.set(mod, to);
30
32
  return to;
@@ -33,7 +35,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
33
35
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
36
 
35
37
  // ../../node_modules/object-hash/index.js
36
- var require_object_hash = __commonJS((exports, module) => {
38
+ var require_object_hash = __commonJS(function(exports, module) {
37
39
  var crypto = __require("crypto");
38
40
  exports = module.exports = objectHash;
39
41
  function objectHash(object, options) {
@@ -10646,9 +10648,12 @@ class SecretValidator {
10646
10648
  // src/crypto/index.ts
10647
10649
  var ALGORITHM = "aes-256-cbc";
10648
10650
  var IV_LENGTH = 16;
10649
- function getPlatformId(platform, actor, _crypto = crypto) {
10651
+ function encodeIdComponents(parts) {
10652
+ return JSON.stringify(parts);
10653
+ }
10654
+ function getPlatformId(platform, actor, scope, _crypto = crypto) {
10650
10655
  if (actor) {
10651
- return _crypto.hashFull(platform + actor);
10656
+ return _crypto.hashFull(encodeIdComponents([platform, actor, scope ?? ""]));
10652
10657
  }
10653
10658
  return _crypto.hashFull(platform);
10654
10659
  }
@@ -10688,7 +10693,7 @@ class Crypto {
10688
10693
  return createHash2("sha256").update(text).digest("hex");
10689
10694
  }
10690
10695
  objectHash(object) {
10691
- return import_object_hash.default(object);
10696
+ return import_object_hash.default(object, { algorithm: "sha256" });
10692
10697
  }
10693
10698
  deriveSecret(...secrets) {
10694
10699
  const chars = "JDOwSa4kUbA6ixneEfHcBzC7&dIWZvqYPh8N1mG!05loQ2RjXF9*p@MgKuT$y#3L^s%rVt";
@@ -10743,9 +10748,9 @@ class Crypto {
10743
10748
  }
10744
10749
  var crypto = new Crypto;
10745
10750
  export {
10746
- getPlatformId,
10751
+ Crypto,
10747
10752
  crypto,
10748
- Crypto
10753
+ getPlatformId
10749
10754
  };
10750
10755
 
10751
- //# debugId=33D2E85F0FED3EA364756E2164756E21
10756
+ //# debugId=B2B82CA1D12BCFD164756E2164756E21