@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/README.md +24 -16
- package/dist/adapters/expo-secure-store.d.mts +11 -1
- package/dist/adapters/expo-secure-store.d.ts +11 -1
- package/dist/adapters/expo-secure-store.js +11 -3
- package/dist/adapters/expo-secure-store.js.map +1 -1
- package/dist/adapters/expo-secure-store.mjs +11 -4
- package/dist/adapters/expo-secure-store.mjs.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.js +6 -8
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +3 -5
- package/dist/index.rn.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.rn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
375
|
+
const signature = nist.p256.sign(digest, this.privateKey, { prehash: false });
|
|
378
376
|
return signature.toCompactRawBytes();
|
|
379
377
|
}
|
|
380
378
|
};
|