@vailix/mask 0.2.4 → 0.2.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @vailix/mask
2
2
 
3
+ ## 0.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - a48760e: Fix master key generation to use cryptographically secure random bytes
8
+
9
+ Changed master key generation from `randomUUID()` to `randomBytes(32).toString('hex')`.
10
+ This fixes the "Invalid master key format" error caused by UUID hyphens failing hex validation,
11
+ and provides proper 256-bit cryptographic randomness following security best practices.
12
+
3
13
  ## 0.2.4
4
14
 
5
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ var IdentityManager = class {
73
73
  try {
74
74
  let key = await this.keyStorage.getKey();
75
75
  if (!key) {
76
- key = (0, import_react_native_quick_crypto.randomUUID)();
76
+ key = (0, import_react_native_quick_crypto.randomBytes)(32).toString("hex");
77
77
  await this.keyStorage.setKey(key);
78
78
  }
79
79
  this.masterKey = key;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/index.ts
2
- import { createCipheriv, randomBytes } from "react-native-quick-crypto";
2
+ import { createCipheriv, randomBytes as randomBytes2 } from "react-native-quick-crypto";
3
3
 
4
4
  // src/identity.ts
5
- import { createHmac, randomUUID } from "react-native-quick-crypto";
5
+ import { createHmac, randomBytes } from "react-native-quick-crypto";
6
6
  import * as SecureStore from "expo-secure-store";
7
7
 
8
8
  // src/utils.ts
@@ -37,7 +37,7 @@ var IdentityManager = class {
37
37
  try {
38
38
  let key = await this.keyStorage.getKey();
39
39
  if (!key) {
40
- key = randomUUID();
40
+ key = randomBytes(32).toString("hex");
41
41
  await this.keyStorage.setKey(key);
42
42
  }
43
43
  this.masterKey = key;
@@ -89,7 +89,7 @@ var IdentityManager = class {
89
89
  // src/storage.ts
90
90
  import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
91
91
  import { lt, gt, inArray } from "drizzle-orm";
92
- import { randomUUID as randomUUID2 } from "react-native-quick-crypto";
92
+ import { randomUUID } from "react-native-quick-crypto";
93
93
  import AsyncStorage from "@react-native-async-storage/async-storage";
94
94
  var SCAN_HISTORY_KEY = "vailix_scan_history";
95
95
  var scannedEvents = sqliteTable("scanned_events", {
@@ -123,7 +123,7 @@ var StorageService = class _StorageService {
123
123
  return Date.now() - lastScan >= this.rescanIntervalMs;
124
124
  }
125
125
  async logScan(rpi, metadataKey, timestamp) {
126
- await this.db.insert(scannedEvents).values({ id: randomUUID2(), rpi, metadataKey, timestamp });
126
+ await this.db.insert(scannedEvents).values({ id: randomUUID(), rpi, metadataKey, timestamp });
127
127
  this.lastScanByRpi.set(rpi, Date.now());
128
128
  if (this.lastScanByRpi.size > _StorageService.MAX_SCAN_HISTORY_SIZE) {
129
129
  const entries2 = Array.from(this.lastScanByRpi.entries());
@@ -1055,7 +1055,7 @@ var VailixSDK = class _VailixSDK {
1055
1055
  throw new Error(`Metadata exceeds maximum size of ${_VailixSDK.MAX_METADATA_SIZE} bytes`);
1056
1056
  }
1057
1057
  const key = Buffer.from(keyHex, "hex");
1058
- const iv = randomBytes(12);
1058
+ const iv = randomBytes2(12);
1059
1059
  const cipher = createCipheriv("aes-256-gcm", key, iv);
1060
1060
  let encrypted = cipher.update(jsonStr, "utf8", "base64");
1061
1061
  encrypted += cipher.final("base64");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vailix/mask",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Privacy-preserving proximity tracing SDK for React Native & Expo",
5
5
  "author": "Gil Eyni",
6
6
  "keywords": [
package/src/identity.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { createHmac, randomUUID } from 'react-native-quick-crypto';
1
+ import { createHmac, randomBytes } from 'react-native-quick-crypto';
2
2
  import * as SecureStore from 'expo-secure-store';
3
3
  import type { KeyStorage } from './types';
4
4
  import { generateDisplayName } from './utils';
@@ -30,7 +30,7 @@ export class IdentityManager {
30
30
  try {
31
31
  let key = await this.keyStorage.getKey();
32
32
  if (!key) {
33
- key = randomUUID();
33
+ key = randomBytes(32).toString('hex');
34
34
  await this.keyStorage.setKey(key);
35
35
  }
36
36
  this.masterKey = key;