monoidentity 0.6.0 → 0.7.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/Monoidentity.svelte +7 -8
- package/dist/Monoidentity.svelte.d.ts +2 -2
- package/dist/_localstorage.d.ts +1 -1
- package/dist/_localstorage.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/storage.d.ts +1 -1
- package/dist/trackready.d.ts +2 -2
- package/dist/trackready.js +21 -21
- package/dist/utils-transport.d.ts +31 -0
- package/package.json +1 -1
- package/dist/utils-callback.d.ts +0 -20
- package/dist/utils-scope.d.ts +0 -6
- package/dist/utils-scope.js +0 -5
- /package/dist/{utils-callback.js → utils-transport.js} +0 -0
package/dist/Monoidentity.svelte
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
-
import type { Scope } from "./utils-scope.js";
|
|
4
3
|
import { trackReady } from "./trackready.js";
|
|
4
|
+
import type { Intent } from "./utils-transport.js";
|
|
5
5
|
|
|
6
|
-
let { app,
|
|
6
|
+
let { app, intents, children }: { app: string; intents?: Intent[]; children: Snippet } = $props();
|
|
7
7
|
|
|
8
8
|
let ready = $state(false);
|
|
9
9
|
let backup: (() => void) | undefined = $state();
|
|
10
10
|
trackReady(
|
|
11
11
|
app,
|
|
12
|
-
|
|
13
|
-
(
|
|
14
|
-
backup = () => {
|
|
15
|
-
|
|
12
|
+
intents || [],
|
|
13
|
+
(startBackup) =>
|
|
14
|
+
(backup = () => {
|
|
15
|
+
startBackup();
|
|
16
16
|
backup = undefined;
|
|
17
|
-
}
|
|
18
|
-
},
|
|
17
|
+
}),
|
|
19
18
|
() => (ready = true),
|
|
20
19
|
);
|
|
21
20
|
</script>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Intent } from "./utils-transport.js";
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
app: string;
|
|
5
|
-
|
|
5
|
+
intents?: Intent[];
|
|
6
6
|
children: Snippet;
|
|
7
7
|
};
|
|
8
8
|
declare const Monoidentity: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/dist/_localstorage.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Dict } from "./_createstore.js";
|
|
2
2
|
export declare const init: () => Record<string, string>;
|
|
3
|
-
export declare const wrapWithBackup: (storage: Dict, requestBackup: (
|
|
3
|
+
export declare const wrapWithBackup: (storage: Dict, requestBackup: (startBackup: () => void) => void) => Dict;
|
package/dist/_localstorage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStore } from "./_createstore.js";
|
|
2
2
|
import { wrapWithReplay } from "./_replay.js";
|
|
3
|
-
import { canBackup } from "./utils-
|
|
3
|
+
import { canBackup } from "./utils-transport.js";
|
|
4
4
|
import { openDB } from "idb";
|
|
5
5
|
const prefix = "monoidentity/";
|
|
6
6
|
const prefixed = (key) => `${prefix}${key}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { getLoginRecognized, getStorage } from "./storage.js";
|
|
2
|
+
export { trackReady } from "./trackready.js";
|
|
3
3
|
export { encode, decode } from "./utils-base36.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { getLoginRecognized, getStorage } from "./storage.js";
|
|
2
|
+
export { trackReady } from "./trackready.js";
|
|
3
3
|
export { encode, decode } from "./utils-base36.js";
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Login } from "./utils-
|
|
1
|
+
import type { Login } from "./utils-transport.js";
|
|
2
2
|
export declare const setup: (i: Record<string, string>, a: string) => void;
|
|
3
3
|
export declare const LOGIN_RECOGNIZED_PATH = ".core/login.encjson";
|
|
4
4
|
export declare const getLoginRecognized: () => Login;
|
package/dist/trackready.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const trackReady: (app: string,
|
|
1
|
+
import { type Intent } from "./utils-transport.js";
|
|
2
|
+
export declare const trackReady: (app: string, intents: Intent[], requestBackup: (startBackup: () => void) => void, ready: () => void) => void;
|
package/dist/trackready.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {} from "./utils-
|
|
2
|
-
import {} from "./utils-scope.js";
|
|
1
|
+
import {} from "./utils-transport.js";
|
|
3
2
|
import { init as initLocal, wrapWithBackup } from "./_localstorage.js";
|
|
4
3
|
import { LOGIN_RECOGNIZED_PATH, setup } from "./storage.js";
|
|
5
|
-
export const trackReady = (app,
|
|
4
|
+
export const trackReady = (app, intents, requestBackup, ready) => {
|
|
6
5
|
const params = new URLSearchParams(location.hash.slice(1));
|
|
7
6
|
let memory = localStorage.monoidentityMemory
|
|
8
7
|
? JSON.parse(localStorage.monoidentityMemory)
|
|
9
8
|
: undefined;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
9
|
+
let provisions = [];
|
|
10
|
+
const cb = params.get("monoidentitycallback");
|
|
11
|
+
if (cb) {
|
|
13
12
|
history.replaceState(null, "", location.pathname);
|
|
14
|
-
|
|
13
|
+
({ provisions } = JSON.parse(cb));
|
|
15
14
|
}
|
|
16
|
-
for (const
|
|
17
|
-
if ("setup" in
|
|
18
|
-
memory =
|
|
15
|
+
for (const provision of provisions) {
|
|
16
|
+
if ("setup" in provision) {
|
|
17
|
+
memory = provision.setup;
|
|
19
18
|
localStorage.monoidentityMemory = JSON.stringify(memory);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
if (!memory) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const target = new URL("https://usemonoidentity.web.app");
|
|
23
|
+
target.hash = JSON.stringify({
|
|
24
|
+
intents: [{ storage: true }, ...intents],
|
|
25
|
+
redirectURI: location.origin,
|
|
26
|
+
});
|
|
27
|
+
location.href = target.toString();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
let storage;
|
|
@@ -40,13 +40,13 @@ export const trackReady = (app, scopes, requestBackup, callback) => {
|
|
|
40
40
|
throw new Error("unreachable");
|
|
41
41
|
}
|
|
42
42
|
setup(storage, app);
|
|
43
|
-
for (const
|
|
44
|
-
if ("createLoginRecognized" in
|
|
45
|
-
storage[LOGIN_RECOGNIZED_PATH] =
|
|
43
|
+
for (const provision of provisions) {
|
|
44
|
+
if ("createLoginRecognized" in provision) {
|
|
45
|
+
storage[LOGIN_RECOGNIZED_PATH] = provision.createLoginRecognized;
|
|
46
46
|
}
|
|
47
|
-
else if ("createVerification" in
|
|
48
|
-
storage[".core/verification.jwt"] =
|
|
47
|
+
else if ("createVerification" in provision) {
|
|
48
|
+
storage[".core/verification.jwt"] = provision.createVerification;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
ready();
|
|
52
52
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type Intent = {
|
|
2
|
+
storage: true;
|
|
3
|
+
} | {
|
|
4
|
+
loginRecognized: true;
|
|
5
|
+
};
|
|
6
|
+
export type IntentEnvelope = {
|
|
7
|
+
intents: Intent[];
|
|
8
|
+
redirectURI: string;
|
|
9
|
+
};
|
|
10
|
+
export type StorageSetup = {
|
|
11
|
+
method: "cloud";
|
|
12
|
+
jwt: string;
|
|
13
|
+
} | {
|
|
14
|
+
method: "localStorage";
|
|
15
|
+
};
|
|
16
|
+
export type Provision = {
|
|
17
|
+
setup: StorageSetup;
|
|
18
|
+
} | {
|
|
19
|
+
createLoginRecognized: string;
|
|
20
|
+
} | {
|
|
21
|
+
createVerification: string;
|
|
22
|
+
};
|
|
23
|
+
/** @knipexternal */
|
|
24
|
+
export type ProvisionEnvelope = {
|
|
25
|
+
provisions: Provision[];
|
|
26
|
+
};
|
|
27
|
+
export type Login = {
|
|
28
|
+
email: string;
|
|
29
|
+
password: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const canBackup: boolean;
|
package/package.json
CHANGED
package/dist/utils-callback.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type Setup = {
|
|
2
|
-
method: "cloud";
|
|
3
|
-
jwt: string;
|
|
4
|
-
} | {
|
|
5
|
-
method: "localStorage";
|
|
6
|
-
};
|
|
7
|
-
type CallbackTask = {
|
|
8
|
-
setup: Setup;
|
|
9
|
-
} | {
|
|
10
|
-
createLoginRecognized: string;
|
|
11
|
-
} | {
|
|
12
|
-
createVerification: string;
|
|
13
|
-
};
|
|
14
|
-
export type Callback = CallbackTask[];
|
|
15
|
-
export type Login = {
|
|
16
|
-
email: string;
|
|
17
|
-
password: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const canBackup: boolean;
|
|
20
|
-
export {};
|
package/dist/utils-scope.d.ts
DELETED
package/dist/utils-scope.js
DELETED
|
File without changes
|