monoidentity 0.29.1 → 0.30.1
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/+client.d.ts +4 -4
- package/dist/+client.js +2 -2
- package/dist/+receive-callback.d.ts +1 -0
- package/dist/+receive-callback.js +2 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +19 -19
- package/package.json +1 -1
package/dist/+client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { encode, decode } from
|
|
2
|
-
export { getLoginRecognized,
|
|
3
|
-
export type { SyncStrategy } from
|
|
4
|
-
export type { Bucket, StorageSetup } from
|
|
1
|
+
export { encode, decode } from './utils-base36.js';
|
|
2
|
+
export { getLoginRecognized, openHub, getStorage, getScopedFS, VERIFICATION_PATH, } from './storage.js';
|
|
3
|
+
export type { SyncStrategy } from './client.js';
|
|
4
|
+
export type { Bucket, StorageSetup } from './utils-transport.js';
|
package/dist/+client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// common
|
|
2
|
-
export { encode, decode } from
|
|
2
|
+
export { encode, decode } from './utils-base36.js';
|
|
3
3
|
// storage
|
|
4
|
-
export { getLoginRecognized,
|
|
4
|
+
export { getLoginRecognized, openHub, getStorage, getScopedFS, VERIFICATION_PATH, } from './storage.js';
|
|
@@ -4,7 +4,8 @@ const monoidentityloginrecognized = params.get('monoidentityloginrecognized');
|
|
|
4
4
|
if (monoidentityloginrecognized) {
|
|
5
5
|
setLoginRecognized(monoidentityloginrecognized);
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
export const loaded = Boolean(params.size);
|
|
8
|
+
if (loaded) {
|
|
8
9
|
history.replaceState(null, '', location.pathname);
|
|
9
10
|
}
|
|
10
11
|
export const monoidentitysync = params.get('monoidentitysync') || undefined;
|
package/dist/storage.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const getLoginRecognized: () => {
|
|
|
3
3
|
password: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const setLoginRecognized: (login: string) => void;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const openHub: (path: string) => never;
|
|
7
7
|
export declare const VERIFICATION_PATH = ".local/verification.jwt";
|
|
8
8
|
export declare const getStorage: (realm: "config" | "userdata" | "cache" | (string & {})) => Record<string, any>;
|
|
9
9
|
export declare const getScopedFS: (dir: string) => Record<string, any>;
|
package/dist/storage.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { stringify, parse } from
|
|
2
|
-
import { parse as useSchema } from
|
|
3
|
-
import { decode } from
|
|
4
|
-
import { login as loginSchema } from
|
|
5
|
-
import { storageClient } from
|
|
6
|
-
const LOGIN_RECOGNIZED_PATH =
|
|
1
|
+
import { stringify, parse } from 'devalue';
|
|
2
|
+
import { parse as useSchema } from 'valibot';
|
|
3
|
+
import { decode } from './utils-base36.js';
|
|
4
|
+
import { login as loginSchema } from './utils-transport.js';
|
|
5
|
+
import { storageClient } from './storageclient.svelte.js';
|
|
6
|
+
const LOGIN_RECOGNIZED_PATH = '.local/login.encjson';
|
|
7
7
|
export const getLoginRecognized = () => {
|
|
8
8
|
const client = storageClient();
|
|
9
9
|
const login = client[LOGIN_RECOGNIZED_PATH];
|
|
10
10
|
if (!login)
|
|
11
|
-
throw new Error(
|
|
11
|
+
throw new Error('No login found');
|
|
12
12
|
return useSchema(loginSchema, JSON.parse(decode(login)));
|
|
13
13
|
};
|
|
14
14
|
export const setLoginRecognized = (login) => {
|
|
15
15
|
const client = storageClient();
|
|
16
16
|
client[LOGIN_RECOGNIZED_PATH] = login;
|
|
17
17
|
};
|
|
18
|
-
const isLocalhostHost = (host) => host ==
|
|
19
|
-
host ==
|
|
20
|
-
host ==
|
|
21
|
-
host ==
|
|
22
|
-
host.endsWith(
|
|
23
|
-
export const
|
|
24
|
-
const target = new URL(`https://monoidentity.web.app/${
|
|
18
|
+
const isLocalhostHost = (host) => host == 'localhost' ||
|
|
19
|
+
host == '127.0.0.1' ||
|
|
20
|
+
host == '0.0.0.0' ||
|
|
21
|
+
host == '[::1]' ||
|
|
22
|
+
host.endsWith('.localhost');
|
|
23
|
+
export const openHub = (path) => {
|
|
24
|
+
const target = new URL(`https://monoidentity.web.app/${path}`);
|
|
25
25
|
if (isLocalhostHost(location.hostname)) {
|
|
26
26
|
const redirectParams = new URLSearchParams();
|
|
27
|
-
redirectParams.set(
|
|
27
|
+
redirectParams.set('redirect', location.origin);
|
|
28
28
|
target.hash = redirectParams.toString();
|
|
29
29
|
}
|
|
30
30
|
location.href = target.toString();
|
|
31
|
-
throw new Error(
|
|
31
|
+
throw new Error('relogging');
|
|
32
32
|
};
|
|
33
|
-
export const VERIFICATION_PATH =
|
|
33
|
+
export const VERIFICATION_PATH = '.local/verification.jwt';
|
|
34
34
|
export const getStorage = (realm) => {
|
|
35
35
|
const prefix = `.${realm}/${MONOIDENTITY_APP_ID}/`;
|
|
36
|
-
return storageClient((key) => `${prefix}${key}.devalue`, (key) => (key.startsWith(prefix) ? key.slice(prefix.length, -
|
|
36
|
+
return storageClient((key) => `${prefix}${key}.devalue`, (key) => (key.startsWith(prefix) ? key.slice(prefix.length, -'.devalue'.length) : undefined), stringify, parse);
|
|
37
37
|
};
|
|
38
|
-
export const getScopedFS = (dir) => storageClient((key) => `${dir}/${key}`, (key) => (key.startsWith(dir +
|
|
38
|
+
export const getScopedFS = (dir) => storageClient((key) => `${dir}/${key}`, (key) => (key.startsWith(dir + '/') ? key.slice(dir.length + 1) : undefined));
|