@pollar/core 0.8.1 → 0.8.2

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/dist/index.rn.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var p256 = require('@noble/curves/p256');
3
+ var nist = require('@noble/curves/nist');
4
+ var sha2 = require('@noble/hashes/sha2');
4
5
 
5
6
  var __create = Object.create;
6
7
  var __defProp = Object.defineProperty;
@@ -186,11 +187,8 @@ function defaultKeyManager(storage, apiKey) {
186
187
  }
187
188
  return _factory(storage, apiKey);
188
189
  }
189
-
190
- // src/lib/sha256.ts
191
190
  async function sha256(data) {
192
- const buf = await crypto.subtle.digest("SHA-256", data);
193
- return new Uint8Array(buf);
191
+ return sha2.sha256(data);
194
192
  }
195
193
 
196
194
  // src/lib/api-key-hash.ts
@@ -325,14 +323,14 @@ var NobleKeyManager = class {
325
323
  priv = null;
326
324
  }
327
325
  if (!priv) {
328
- priv = p256.p256.utils.randomPrivateKey();
326
+ priv = nist.p256.utils.randomPrivateKey();
329
327
  try {
330
328
  await this.storage.set(this.storageKey, base64urlEncode(priv));
331
329
  } catch {
332
330
  }
333
331
  }
334
332
  this.privateKey = priv;
335
- const pub = p256.p256.getPublicKey(priv, false);
333
+ const pub = nist.p256.getPublicKey(priv, false);
336
334
  if (pub.length !== 65 || pub[0] !== 4) {
337
335
  throw new Error("[PollarClient:keys] Unexpected public key format from @noble/curves");
338
336
  }
@@ -374,7 +372,7 @@ var NobleKeyManager = class {
374
372
  throw new Error("[PollarClient:keys] Keypair initialization failed; sign unavailable");
375
373
  }
376
374
  const digest = await sha256(payload);
377
- const signature = p256.p256.sign(digest, this.privateKey, { prehash: false });
375
+ const signature = nist.p256.sign(digest, this.privateKey, { prehash: false });
378
376
  return signature.toCompactRawBytes();
379
377
  }
380
378
  };