@spooky-sync/core 0.0.1-canary.320 → 0.0.1-canary.322

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.
@@ -51,6 +51,17 @@ export function generateId(): string {
51
51
  return Uuid.v4().toString().replace(/-/g, '');
52
52
  }
53
53
 
54
+ /**
55
+ * 32 random bytes, hex: the secret a page proves it owns its anonymous views
56
+ * with (`$config.owner` on `fn::query::register`). `getRandomValues` rather
57
+ * than `randomUUID`, which a page served over plain http does not have.
58
+ */
59
+ export function mintOwnerSecret(): string {
60
+ const bytes = new Uint8Array(32);
61
+ globalThis.crypto.getRandomValues(bytes);
62
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
63
+ }
64
+
54
65
  export function generateNewTableId<S extends SchemaStructure, T extends TableNames<S>>(
55
66
  tableName: T
56
67
  ): RecordId {