monoidentity 0.8.0 → 0.9.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/storage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const setup: (i: Record<string, string>, a: string) => void;
1
+ export declare const conf: (i: Record<string, string>, a: string) => void;
2
2
  export declare const LOGIN_RECOGNIZED_PATH = ".core/login.encjson";
3
3
  export declare const getLoginRecognized: () => {
4
4
  email: string;
@@ -7,5 +7,5 @@ export declare const getLoginRecognized: () => {
7
7
  export declare const VERIFICATION_PATH = ".core/verification.jwt";
8
8
  export declare const getVerification: () => Promise<string>;
9
9
  export declare const retrieveVerification: () => Promise<any>;
10
- export declare const useVerification: (jwt: string) => Promise<import("@tsndr/cloudflare-worker-jwt").JwtData<{}, {}> | undefined>;
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>;
package/dist/storage.js CHANGED
@@ -8,7 +8,7 @@ import publicKey from "./verification/public-key.js";
8
8
  import attest from "./verification/attest-remote.js";
9
9
  let implementation;
10
10
  let app = "";
11
- export const setup = (i, a) => {
11
+ export const conf = (i, a) => {
12
12
  implementation = i;
13
13
  app = a;
14
14
  };
@@ -44,7 +44,10 @@ export const retrieveVerification = async () => {
44
44
  }
45
45
  return jwt;
46
46
  };
47
- export const useVerification = (jwt) => verify(jwt, publicKey, { algorithm: "ES256", throwError: true });
47
+ export const useVerification = async (jwt) => {
48
+ const result = await verify(jwt, publicKey, { algorithm: "ES256", throwError: true });
49
+ return result;
50
+ };
48
51
  export const getStorage = (realm) => {
49
52
  const prefix = (text) => `.${realm}/${app}/${text}.devalue`;
50
53
  if (!app)
@@ -1,10 +1,10 @@
1
1
  import {} from "./utils-transport.js";
2
2
  import { init as initLocal, wrapWithBackup } from "./storage/localstorage.js";
3
- import { LOGIN_RECOGNIZED_PATH, setup } from "./storage.js";
3
+ import { LOGIN_RECOGNIZED_PATH, conf } from "./storage.js";
4
4
  export const trackReady = (app, intents, requestBackup, ready) => {
5
5
  const params = new URLSearchParams(location.hash.slice(1));
6
- let memory = localStorage.monoidentityMemory
7
- ? JSON.parse(localStorage.monoidentityMemory)
6
+ let setup = localStorage["monoidentity-x/setup"]
7
+ ? JSON.parse(localStorage["monoidentity-x/setup"])
8
8
  : undefined;
9
9
  let provisions = [];
10
10
  const cb = params.get("monoidentitycallback");
@@ -14,11 +14,11 @@ export const trackReady = (app, intents, requestBackup, ready) => {
14
14
  }
15
15
  for (const provision of provisions) {
16
16
  if ("setup" in provision) {
17
- memory = provision.setup;
18
- localStorage.monoidentityMemory = JSON.stringify(memory);
17
+ setup = provision.setup;
18
+ localStorage["monoidentity-x/setup"] = JSON.stringify(setup);
19
19
  }
20
20
  }
21
- if (!memory) {
21
+ if (!setup) {
22
22
  const target = new URL("https://usemonoidentity.web.app");
23
23
  target.hash = JSON.stringify({
24
24
  intents: [{ storage: true }, ...intents],
@@ -28,18 +28,18 @@ export const trackReady = (app, intents, requestBackup, ready) => {
28
28
  return;
29
29
  }
30
30
  let storage;
31
- if (memory.method == "cloud") {
31
+ if (setup.method == "cloud") {
32
32
  // TODO
33
33
  throw new Error("unimplemented");
34
34
  }
35
- else if (memory.method == "localStorage") {
35
+ else if (setup.method == "localStorage") {
36
36
  storage = initLocal();
37
37
  storage = wrapWithBackup(storage, requestBackup);
38
38
  }
39
39
  else {
40
40
  throw new Error("unreachable");
41
41
  }
42
- setup(storage, app);
42
+ conf(storage, app);
43
43
  for (const provision of provisions) {
44
44
  if ("createLoginRecognized" in provision) {
45
45
  storage[LOGIN_RECOGNIZED_PATH] = provision.createLoginRecognized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monoidentity",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "repository": "KTibow/monoidentity",
5
5
  "author": {
6
6
  "name": "KTibow"