@crosslink/sdk-browser 0.1.0
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/LICENSE +163 -0
- package/README.md +11 -0
- package/dist/chunk-FKNR6EFT.js +54 -0
- package/dist/chunk-RCHT4DYR.js +221 -0
- package/dist/crosslink.global.js +1123 -0
- package/dist/device-crypto-storage-NEJ3IT2Z.js +42 -0
- package/dist/index.d.ts +1491 -0
- package/dist/index.js +4520 -0
- package/dist/storage-FHFZA2HW.js +10 -0
- package/package.json +37 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSecureStorage
|
|
3
|
+
} from "./chunk-RCHT4DYR.js";
|
|
4
|
+
|
|
5
|
+
// src/device-crypto-storage.ts
|
|
6
|
+
var SecureDeviceCryptoStorage = class _SecureDeviceCryptoStorage {
|
|
7
|
+
storage;
|
|
8
|
+
constructor(storage) {
|
|
9
|
+
this.storage = storage;
|
|
10
|
+
}
|
|
11
|
+
static async open() {
|
|
12
|
+
const { storage } = await createSecureStorage({ allowPlaintextFallback: false });
|
|
13
|
+
return new _SecureDeviceCryptoStorage(storage);
|
|
14
|
+
}
|
|
15
|
+
storageKey(appId) {
|
|
16
|
+
return `crosslink.device-crypto.${appId}`;
|
|
17
|
+
}
|
|
18
|
+
async load(appId) {
|
|
19
|
+
const key = this.storageKey(appId ?? "default");
|
|
20
|
+
const value = this.storage.get(key);
|
|
21
|
+
if (!value) return null;
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(value);
|
|
24
|
+
if (parsed && typeof parsed.deviceId === "string" && typeof parsed.edPrivateSeedB64 === "string") {
|
|
25
|
+
return { deviceId: parsed.deviceId, edPrivateSeedB64: parsed.edPrivateSeedB64 };
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
async save(record, appId) {
|
|
32
|
+
const key = this.storageKey(appId ?? "default");
|
|
33
|
+
this.storage.set(key, JSON.stringify(record));
|
|
34
|
+
}
|
|
35
|
+
async clear(appId) {
|
|
36
|
+
const key = this.storageKey(appId ?? "default");
|
|
37
|
+
this.storage.delete(key);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
SecureDeviceCryptoStorage
|
|
42
|
+
};
|