monoidentity 0.10.2 → 0.11.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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/storage/createlocalstorage.js +4 -4
- package/dist/storage/createstore.d.ts +1 -0
- package/dist/storage.d.ts +1 -0
- package/dist/storage.js +87 -34
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getLoginRecognized, getVerification, useVerification, getStorage } from "./storage.js";
|
|
1
|
+
export { getLoginRecognized, getVerification, useVerification, getStorage, getScopedFS, } from "./storage.js";
|
|
2
2
|
export { retrieveVerification } from "./storage-attest.js";
|
|
3
3
|
export { default as rawAttest } from "./verification/attest-remote.js";
|
|
4
4
|
export { trackReady } from "./trackready.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getLoginRecognized, getVerification, useVerification, getStorage } from "./storage.js";
|
|
1
|
+
export { getLoginRecognized, getVerification, useVerification, getStorage, getScopedFS, } from "./storage.js";
|
|
2
2
|
export { retrieveVerification } from "./storage-attest.js";
|
|
3
3
|
export { default as rawAttest } from "./verification/attest-remote.js";
|
|
4
4
|
export { trackReady } from "./trackready.js";
|
|
@@ -13,10 +13,7 @@ export const createLocalStorage = () => createStore({
|
|
|
13
13
|
get(key) {
|
|
14
14
|
if (typeof key != "string")
|
|
15
15
|
return undefined;
|
|
16
|
-
|
|
17
|
-
if (value == null)
|
|
18
|
-
return undefined;
|
|
19
|
-
return value;
|
|
16
|
+
return localStorage[prefixed(key)];
|
|
20
17
|
},
|
|
21
18
|
set(key, value) {
|
|
22
19
|
if (typeof key == "string") {
|
|
@@ -42,4 +39,7 @@ export const createLocalStorage = () => createStore({
|
|
|
42
39
|
}
|
|
43
40
|
return keys;
|
|
44
41
|
},
|
|
42
|
+
getOwnPropertyDescriptor(key) {
|
|
43
|
+
return Reflect.getOwnPropertyDescriptor(localStorage, prefixed(key));
|
|
44
|
+
},
|
|
45
45
|
});
|
|
@@ -5,6 +5,7 @@ type ProxyHandlerWithoutTarget = {
|
|
|
5
5
|
set?(p: string | symbol, newValue: any, receiver: any): boolean;
|
|
6
6
|
deleteProperty?(p: string | symbol): boolean;
|
|
7
7
|
ownKeys?(): ArrayLike<string | symbol>;
|
|
8
|
+
getOwnPropertyDescriptor?(p: string | symbol): PropertyDescriptor | undefined;
|
|
8
9
|
};
|
|
9
10
|
export declare const createStore: <T>(implementation: ProxyHandlerWithoutTarget) => Record<string, T>;
|
|
10
11
|
export {};
|
package/dist/storage.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export declare const getVerification: () => Promise<string>;
|
|
|
9
9
|
export declare const setVerification: (jwt: string) => void;
|
|
10
10
|
export declare const useVerification: (jwt: string) => Promise<import("@tsndr/cloudflare-worker-jwt").JwtData<{}, {}>>;
|
|
11
11
|
export declare const getStorage: (realm: "config" | "cache") => Record<string, any>;
|
|
12
|
+
export declare const getScopedFS: (dir: string) => Record<string, string>;
|
package/dist/storage.js
CHANGED
|
@@ -39,37 +39,90 @@ export const useVerification = async (jwt) => {
|
|
|
39
39
|
const result = await verify(jwt, publicKey, { algorithm: "ES256", throwError: true });
|
|
40
40
|
return result;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
42
|
+
const withPrefix = (obj, prefix, unprefix) => new Proxy(obj, {
|
|
43
|
+
get(target, prop) {
|
|
44
|
+
return target[prefix(prop)];
|
|
45
|
+
},
|
|
46
|
+
set(target, prop, value) {
|
|
47
|
+
target[prefix(prop)] = value;
|
|
48
|
+
return true;
|
|
49
|
+
},
|
|
50
|
+
has(target, prop) {
|
|
51
|
+
return prefix(prop) in target;
|
|
52
|
+
},
|
|
53
|
+
deleteProperty(target, prop) {
|
|
54
|
+
return delete target[prefix(prop)];
|
|
55
|
+
},
|
|
56
|
+
ownKeys(target) {
|
|
57
|
+
if (typeof unprefix != "function") {
|
|
58
|
+
throw new Error("unprefix must be a function");
|
|
59
|
+
}
|
|
60
|
+
return Object.keys(target)
|
|
61
|
+
.map((key) => unprefix(key))
|
|
62
|
+
.filter((key) => typeof key == "string");
|
|
63
|
+
},
|
|
64
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
65
|
+
return Reflect.getOwnPropertyDescriptor(target, prefix(prop));
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
export const getStorage = (realm) => withPrefix(createStore({
|
|
69
|
+
get(key) {
|
|
70
|
+
if (!implementation)
|
|
71
|
+
throw new Error("No implementation set");
|
|
72
|
+
const item = implementation[key];
|
|
73
|
+
return item ? parse(item) : undefined;
|
|
74
|
+
},
|
|
75
|
+
set(key, value) {
|
|
76
|
+
if (!implementation)
|
|
77
|
+
throw new Error("No implementation set");
|
|
78
|
+
implementation[key] = stringify(value);
|
|
79
|
+
return true;
|
|
80
|
+
},
|
|
81
|
+
has(key) {
|
|
82
|
+
if (!implementation)
|
|
83
|
+
throw new Error("No implementation set");
|
|
84
|
+
return key in implementation;
|
|
85
|
+
},
|
|
86
|
+
deleteProperty(key) {
|
|
87
|
+
if (!implementation)
|
|
88
|
+
throw new Error("No implementation set");
|
|
89
|
+
return delete implementation[key];
|
|
90
|
+
},
|
|
91
|
+
}), (text) => {
|
|
92
|
+
if (!app)
|
|
93
|
+
throw new Error("No app set");
|
|
94
|
+
return `.${realm}/${app}/${text}.devalue`;
|
|
95
|
+
});
|
|
96
|
+
export const getScopedFS = (dir) => withPrefix(createStore({
|
|
97
|
+
get(key) {
|
|
98
|
+
if (!implementation)
|
|
99
|
+
throw new Error("No implementation set");
|
|
100
|
+
return implementation[key];
|
|
101
|
+
},
|
|
102
|
+
set(key, value) {
|
|
103
|
+
if (!implementation)
|
|
104
|
+
throw new Error("No implementation set");
|
|
105
|
+
implementation[key] = value;
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
has(key) {
|
|
109
|
+
if (!implementation)
|
|
110
|
+
throw new Error("No implementation set");
|
|
111
|
+
return key in implementation;
|
|
112
|
+
},
|
|
113
|
+
deleteProperty(key) {
|
|
114
|
+
if (!implementation)
|
|
115
|
+
throw new Error("No implementation set");
|
|
116
|
+
return delete implementation[key];
|
|
117
|
+
},
|
|
118
|
+
ownKeys() {
|
|
119
|
+
if (!implementation)
|
|
120
|
+
throw new Error("No implementation set");
|
|
121
|
+
return Object.keys(implementation);
|
|
122
|
+
},
|
|
123
|
+
getOwnPropertyDescriptor(key) {
|
|
124
|
+
if (!implementation)
|
|
125
|
+
throw new Error("No implementation set");
|
|
126
|
+
return Reflect.getOwnPropertyDescriptor(implementation, key);
|
|
127
|
+
},
|
|
128
|
+
}), (text) => `${dir}/${text}`, (text) => (text.startsWith(`${dir}/`) ? text.slice(dir.length + 1) : undefined));
|