@ai-matrx/auth 0.2.0 → 0.2.2
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/CHANGELOG.md +47 -0
- package/dist/active-organization-Dy4UtiyR.d.cts +594 -0
- package/dist/active-organization-Dy4UtiyR.d.ts +594 -0
- package/dist/guest.cjs +213 -0
- package/dist/guest.d.cts +189 -0
- package/dist/guest.d.ts +189 -0
- package/dist/guest.js +192 -0
- package/dist/index.cjs +514 -112
- package/dist/index.d.cts +161 -5
- package/dist/index.d.ts +161 -5
- package/dist/index.js +515 -113
- package/dist/matrx-oauth-_Ji8X5Wm.d.cts +264 -0
- package/dist/matrx-oauth-_Ji8X5Wm.d.ts +264 -0
- package/dist/matrx-oauth.cjs +77 -10
- package/dist/matrx-oauth.d.cts +1 -181
- package/dist/matrx-oauth.d.ts +1 -181
- package/dist/matrx-oauth.js +77 -10
- package/dist/organizations.cjs +269 -13
- package/dist/organizations.d.cts +3 -225
- package/dist/organizations.d.ts +3 -225
- package/dist/organizations.js +269 -13
- package/dist/react.d.cts +3 -1
- package/dist/react.d.ts +3 -1
- package/package.json +12 -2
- package/dist/session-DdQiStp6.d.cts +0 -112
- package/dist/session-DdQiStp6.d.ts +0 -112
- package/dist/storage-Dqnye4KF.d.cts +0 -51
- package/dist/storage-Dqnye4KF.d.ts +0 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "AI Matrx sign-in, session and organizations for every app: sign in/out, session storage and refresh per platform (browser, Next.js, extension, desktop, Node), the current person, their organizations and favourites, the one active organization (held requests, never a list filter), and the credentials @ai-matrx/data and @ai-matrx/api read.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -132,6 +132,16 @@
|
|
|
132
132
|
"default": "./dist/matrx-oauth.cjs"
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
|
+
"./guest": {
|
|
136
|
+
"import": {
|
|
137
|
+
"types": "./dist/guest.d.ts",
|
|
138
|
+
"default": "./dist/guest.js"
|
|
139
|
+
},
|
|
140
|
+
"require": {
|
|
141
|
+
"types": "./dist/guest.d.cts",
|
|
142
|
+
"default": "./dist/guest.cjs"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
135
145
|
"./package.json": "./package.json"
|
|
136
146
|
},
|
|
137
147
|
"devDependencies": {
|
|
@@ -201,5 +211,5 @@
|
|
|
201
211
|
"test": "vitest run",
|
|
202
212
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
203
213
|
},
|
|
204
|
-
"gitHead": "
|
|
214
|
+
"gitHead": "09da8756d7c80a6f2e611b1dd2d713efee4b0858"
|
|
205
215
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient, User, Session, AuthChangeEvent, Provider, UserAttributes } from '@supabase/supabase-js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @ai-matrx/auth — sign-in and session doors (moved from @ai-matrx/data/auth, 2026-10-09).
|
|
5
|
-
*
|
|
6
|
-
* auth owns Supabase sign-in; @ai-matrx/data reads the same client and session for its doors. A package or app asks these doors instead of reaching into
|
|
7
|
-
* `client.auth.*`; the session leaves for `@ai-matrx/api` only as the `user` credential
|
|
8
|
-
* (`sessionCredentials(client)`, the shape api's `CredentialsPort` takes, and the same port
|
|
9
|
-
* `@ai-matrx/data`'s `createDb(...).credentials` returns), so api reads the token and never
|
|
10
|
-
* signs anyone in.
|
|
11
|
-
*
|
|
12
|
-
* const session = await getSession(supabase); // Session | null
|
|
13
|
-
* const person = await getPerson(supabase); // User | null (verified by the server)
|
|
14
|
-
* const stop = onSessionChange(supabase, (event, session) => …);
|
|
15
|
-
* await signInWithPassword(supabase, { email, password }); // throws SignInError
|
|
16
|
-
* const { url } = await signInWithOAuth(supabase, { provider: "google", redirectTo });
|
|
17
|
-
* await signOut(supabase);
|
|
18
|
-
* await updatePerson(supabase, { data: { full_name } });
|
|
19
|
-
*
|
|
20
|
-
* Every refusal throws `SignInError` carrying the auth server's own message, status and code.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** Any supabase-js client (browser, server, route, extension) — only its `auth` is used here. */
|
|
24
|
-
type AuthClient = Pick<SupabaseClient<any, any, any>, "auth">;
|
|
25
|
-
/** A refusal from the auth server — its own message, plus status/code when it sent them. */
|
|
26
|
-
declare class SignInError extends Error {
|
|
27
|
-
readonly door: string;
|
|
28
|
-
readonly status?: number;
|
|
29
|
-
readonly code?: string;
|
|
30
|
-
constructor(door: string, message: string, status?: number, code?: string);
|
|
31
|
-
}
|
|
32
|
-
/** The stored session (no network unless a refresh is due), or null when signed out. */
|
|
33
|
-
declare function getSession(client: AuthClient): Promise<Session | null>;
|
|
34
|
-
/**
|
|
35
|
-
* Forget the cached person for this client, so the next {@link getPerson} asks the auth server.
|
|
36
|
-
* Sign-in, sign-out, a profile edit and an organization switch already call this; call it yourself
|
|
37
|
-
* only after changing the person outside this package.
|
|
38
|
-
*/
|
|
39
|
-
declare function invalidatePerson(client: AuthClient): void;
|
|
40
|
-
/**
|
|
41
|
-
* The signed-in person, verified by the auth server, or null when signed out. The verified read is
|
|
42
|
-
* kept per client until the session changes (sign-in, sign-out, profile edit, organization switch),
|
|
43
|
-
* so repeated access checks cost zero extra auth-server calls; concurrent callers share one read.
|
|
44
|
-
*/
|
|
45
|
-
declare function getPerson(client: AuthClient): Promise<User | null>;
|
|
46
|
-
/** Hear every session change (sign-in, refresh, sign-out). Returns the unsubscribe. */
|
|
47
|
-
declare function onSessionChange(client: AuthClient, cb: (event: AuthChangeEvent, session: Session | null) => void): () => void;
|
|
48
|
-
declare function signInWithPassword(client: AuthClient, credentials: {
|
|
49
|
-
email: string;
|
|
50
|
-
password: string;
|
|
51
|
-
} | {
|
|
52
|
-
phone: string;
|
|
53
|
-
password: string;
|
|
54
|
-
}): Promise<{
|
|
55
|
-
session: Session;
|
|
56
|
-
person: User;
|
|
57
|
-
}>;
|
|
58
|
-
declare function signInWithOAuth(client: AuthClient, options: {
|
|
59
|
-
provider: Provider;
|
|
60
|
-
redirectTo?: string;
|
|
61
|
-
scopes?: string;
|
|
62
|
-
queryParams?: Record<string, string>;
|
|
63
|
-
skipBrowserRedirect?: boolean;
|
|
64
|
-
}): Promise<{
|
|
65
|
-
provider: Provider;
|
|
66
|
-
url: string | null;
|
|
67
|
-
}>;
|
|
68
|
-
declare function signOut(client: AuthClient, scope?: "global" | "local" | "others"): Promise<void>;
|
|
69
|
-
/** Change the signed-in person's email, phone, password or metadata. */
|
|
70
|
-
declare function updatePerson(client: AuthClient, attributes: UserAttributes): Promise<User>;
|
|
71
|
-
/** The slice of a client the session credential reads: its `auth`, when it has one. */
|
|
72
|
-
interface SessionSourceLike {
|
|
73
|
-
auth?: {
|
|
74
|
-
getSession(): PromiseLike<{
|
|
75
|
-
data: {
|
|
76
|
-
session: {
|
|
77
|
-
access_token: string;
|
|
78
|
-
} | null;
|
|
79
|
-
};
|
|
80
|
-
}>;
|
|
81
|
-
onAuthStateChange(cb: (event: string, session: unknown) => void): {
|
|
82
|
-
data: {
|
|
83
|
-
subscription: {
|
|
84
|
-
unsubscribe(): void;
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
} | undefined;
|
|
89
|
-
}
|
|
90
|
-
/** The `user` credential port (structural; the shape `@ai-matrx/api`'s `CredentialsPort` takes). */
|
|
91
|
-
interface UserCredentialsPort {
|
|
92
|
-
get(): Promise<{
|
|
93
|
-
kind: "user";
|
|
94
|
-
accessToken: string;
|
|
95
|
-
} | null>;
|
|
96
|
-
onChange?(cb: () => void): () => void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* THE ONE session → credential mapping: the current access token as api's `user` credential,
|
|
100
|
-
* re-read on every call (a refresh rotates it), with `onChange` on every session change.
|
|
101
|
-
* A client with no `auth` is anonymous (null), never an error.
|
|
102
|
-
*/
|
|
103
|
-
declare function sessionCredentials(client: SessionSourceLike): UserCredentialsPort;
|
|
104
|
-
/** The session as `@ai-matrx/api`'s `user` credential — the name `@ai-matrx/data/auth` shipped. */
|
|
105
|
-
declare const userCredentials: typeof sessionCredentials;
|
|
106
|
-
/**
|
|
107
|
-
* Refresh the session now (a long-lived script, a desktop app waking from sleep, a tab that was
|
|
108
|
-
* frozen). Returns the new session; throws `SignInError` when the refresh token is refused.
|
|
109
|
-
*/
|
|
110
|
-
declare function refreshSession(client: AuthClient): Promise<Session>;
|
|
111
|
-
|
|
112
|
-
export { type AuthClient as A, type SessionSourceLike as S, type UserCredentialsPort as U, SignInError as a, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, invalidatePerson as i, onSessionChange as o, refreshSession as r, sessionCredentials as s, updatePerson as u };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient, User, Session, AuthChangeEvent, Provider, UserAttributes } from '@supabase/supabase-js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @ai-matrx/auth — sign-in and session doors (moved from @ai-matrx/data/auth, 2026-10-09).
|
|
5
|
-
*
|
|
6
|
-
* auth owns Supabase sign-in; @ai-matrx/data reads the same client and session for its doors. A package or app asks these doors instead of reaching into
|
|
7
|
-
* `client.auth.*`; the session leaves for `@ai-matrx/api` only as the `user` credential
|
|
8
|
-
* (`sessionCredentials(client)`, the shape api's `CredentialsPort` takes, and the same port
|
|
9
|
-
* `@ai-matrx/data`'s `createDb(...).credentials` returns), so api reads the token and never
|
|
10
|
-
* signs anyone in.
|
|
11
|
-
*
|
|
12
|
-
* const session = await getSession(supabase); // Session | null
|
|
13
|
-
* const person = await getPerson(supabase); // User | null (verified by the server)
|
|
14
|
-
* const stop = onSessionChange(supabase, (event, session) => …);
|
|
15
|
-
* await signInWithPassword(supabase, { email, password }); // throws SignInError
|
|
16
|
-
* const { url } = await signInWithOAuth(supabase, { provider: "google", redirectTo });
|
|
17
|
-
* await signOut(supabase);
|
|
18
|
-
* await updatePerson(supabase, { data: { full_name } });
|
|
19
|
-
*
|
|
20
|
-
* Every refusal throws `SignInError` carrying the auth server's own message, status and code.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** Any supabase-js client (browser, server, route, extension) — only its `auth` is used here. */
|
|
24
|
-
type AuthClient = Pick<SupabaseClient<any, any, any>, "auth">;
|
|
25
|
-
/** A refusal from the auth server — its own message, plus status/code when it sent them. */
|
|
26
|
-
declare class SignInError extends Error {
|
|
27
|
-
readonly door: string;
|
|
28
|
-
readonly status?: number;
|
|
29
|
-
readonly code?: string;
|
|
30
|
-
constructor(door: string, message: string, status?: number, code?: string);
|
|
31
|
-
}
|
|
32
|
-
/** The stored session (no network unless a refresh is due), or null when signed out. */
|
|
33
|
-
declare function getSession(client: AuthClient): Promise<Session | null>;
|
|
34
|
-
/**
|
|
35
|
-
* Forget the cached person for this client, so the next {@link getPerson} asks the auth server.
|
|
36
|
-
* Sign-in, sign-out, a profile edit and an organization switch already call this; call it yourself
|
|
37
|
-
* only after changing the person outside this package.
|
|
38
|
-
*/
|
|
39
|
-
declare function invalidatePerson(client: AuthClient): void;
|
|
40
|
-
/**
|
|
41
|
-
* The signed-in person, verified by the auth server, or null when signed out. The verified read is
|
|
42
|
-
* kept per client until the session changes (sign-in, sign-out, profile edit, organization switch),
|
|
43
|
-
* so repeated access checks cost zero extra auth-server calls; concurrent callers share one read.
|
|
44
|
-
*/
|
|
45
|
-
declare function getPerson(client: AuthClient): Promise<User | null>;
|
|
46
|
-
/** Hear every session change (sign-in, refresh, sign-out). Returns the unsubscribe. */
|
|
47
|
-
declare function onSessionChange(client: AuthClient, cb: (event: AuthChangeEvent, session: Session | null) => void): () => void;
|
|
48
|
-
declare function signInWithPassword(client: AuthClient, credentials: {
|
|
49
|
-
email: string;
|
|
50
|
-
password: string;
|
|
51
|
-
} | {
|
|
52
|
-
phone: string;
|
|
53
|
-
password: string;
|
|
54
|
-
}): Promise<{
|
|
55
|
-
session: Session;
|
|
56
|
-
person: User;
|
|
57
|
-
}>;
|
|
58
|
-
declare function signInWithOAuth(client: AuthClient, options: {
|
|
59
|
-
provider: Provider;
|
|
60
|
-
redirectTo?: string;
|
|
61
|
-
scopes?: string;
|
|
62
|
-
queryParams?: Record<string, string>;
|
|
63
|
-
skipBrowserRedirect?: boolean;
|
|
64
|
-
}): Promise<{
|
|
65
|
-
provider: Provider;
|
|
66
|
-
url: string | null;
|
|
67
|
-
}>;
|
|
68
|
-
declare function signOut(client: AuthClient, scope?: "global" | "local" | "others"): Promise<void>;
|
|
69
|
-
/** Change the signed-in person's email, phone, password or metadata. */
|
|
70
|
-
declare function updatePerson(client: AuthClient, attributes: UserAttributes): Promise<User>;
|
|
71
|
-
/** The slice of a client the session credential reads: its `auth`, when it has one. */
|
|
72
|
-
interface SessionSourceLike {
|
|
73
|
-
auth?: {
|
|
74
|
-
getSession(): PromiseLike<{
|
|
75
|
-
data: {
|
|
76
|
-
session: {
|
|
77
|
-
access_token: string;
|
|
78
|
-
} | null;
|
|
79
|
-
};
|
|
80
|
-
}>;
|
|
81
|
-
onAuthStateChange(cb: (event: string, session: unknown) => void): {
|
|
82
|
-
data: {
|
|
83
|
-
subscription: {
|
|
84
|
-
unsubscribe(): void;
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
} | undefined;
|
|
89
|
-
}
|
|
90
|
-
/** The `user` credential port (structural; the shape `@ai-matrx/api`'s `CredentialsPort` takes). */
|
|
91
|
-
interface UserCredentialsPort {
|
|
92
|
-
get(): Promise<{
|
|
93
|
-
kind: "user";
|
|
94
|
-
accessToken: string;
|
|
95
|
-
} | null>;
|
|
96
|
-
onChange?(cb: () => void): () => void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* THE ONE session → credential mapping: the current access token as api's `user` credential,
|
|
100
|
-
* re-read on every call (a refresh rotates it), with `onChange` on every session change.
|
|
101
|
-
* A client with no `auth` is anonymous (null), never an error.
|
|
102
|
-
*/
|
|
103
|
-
declare function sessionCredentials(client: SessionSourceLike): UserCredentialsPort;
|
|
104
|
-
/** The session as `@ai-matrx/api`'s `user` credential — the name `@ai-matrx/data/auth` shipped. */
|
|
105
|
-
declare const userCredentials: typeof sessionCredentials;
|
|
106
|
-
/**
|
|
107
|
-
* Refresh the session now (a long-lived script, a desktop app waking from sleep, a tab that was
|
|
108
|
-
* frozen). Returns the new session; throws `SignInError` when the refresh token is refused.
|
|
109
|
-
*/
|
|
110
|
-
declare function refreshSession(client: AuthClient): Promise<Session>;
|
|
111
|
-
|
|
112
|
-
export { type AuthClient as A, type SessionSourceLike as S, type UserCredentialsPort as U, SignInError as a, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, invalidatePerson as i, onSessionChange as o, refreshSession as r, sessionCredentials as s, updatePerson as u };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session storage per platform — where a Supabase session lives between runs.
|
|
3
|
-
*
|
|
4
|
-
* supabase-js takes any `{ getItem, setItem, removeItem }` (sync or async). These are the ones
|
|
5
|
-
* every Matrx client needs, written once:
|
|
6
|
-
*
|
|
7
|
-
* browser — `browserStorage("local")` (supabase-js's own default; `"session"` = this tab only)
|
|
8
|
-
* Next.js — the cookie-backed clients in `@ai-matrx/auth/next` (the domain-wide auth cookie)
|
|
9
|
-
* extension — `extensionStorage()` over `chrome.storage.local` (shared by popup, side panel and
|
|
10
|
-
* service worker; `localStorage` does not exist in a service worker)
|
|
11
|
-
* desktop — `keyValueStorage({ get, set, remove })` over the host's store (Tauri store, keychain)
|
|
12
|
-
* Node — `fileStorage(path)` in `@ai-matrx/auth/node`, or `memoryStorage()` for a one-shot run
|
|
13
|
-
*
|
|
14
|
-
* None of these is ever silently swapped for another: a storage the platform does not have throws
|
|
15
|
-
* a named error at creation, never a quiet in-memory fallback that signs the person out on reload.
|
|
16
|
-
*/
|
|
17
|
-
/** The storage contract supabase-js reads (sync or async methods). */
|
|
18
|
-
interface SessionStorage {
|
|
19
|
-
getItem(key: string): string | null | Promise<string | null>;
|
|
20
|
-
setItem(key: string, value: string): void | Promise<void>;
|
|
21
|
-
removeItem(key: string): void | Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
declare class StorageUnavailableError extends Error {
|
|
24
|
-
readonly storage: string;
|
|
25
|
-
constructor(storage: string, reason: string);
|
|
26
|
-
}
|
|
27
|
-
/** In memory only: the session ends with the process (one-shot scripts, tests, server renders). */
|
|
28
|
-
declare function memoryStorage(): SessionStorage & {
|
|
29
|
-
readonly size: () => number;
|
|
30
|
-
};
|
|
31
|
-
/** The browser's `localStorage` (shared by every tab of the origin) or `sessionStorage` (this tab). */
|
|
32
|
-
declare function browserStorage(kind?: "local" | "session"): SessionStorage;
|
|
33
|
-
/** The structural slice of `chrome.storage.<area>` read here (MV3 promise API). */
|
|
34
|
-
interface ChromeStorageAreaLike {
|
|
35
|
-
get(keys: string): Promise<Record<string, unknown>>;
|
|
36
|
-
set(items: Record<string, unknown>): Promise<void>;
|
|
37
|
-
remove(keys: string): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A browser extension's `chrome.storage` area (default `local`): one session for the popup, side
|
|
41
|
-
* panel, content scripts' relay and the service worker. Pass `area` to inject one (tests, Firefox).
|
|
42
|
-
*/
|
|
43
|
-
declare function extensionStorage(area?: ChromeStorageAreaLike): SessionStorage;
|
|
44
|
-
/** Any async key-value store the host owns (a desktop app's Tauri store or keychain). */
|
|
45
|
-
declare function keyValueStorage(store: {
|
|
46
|
-
get(key: string): Promise<string | null | undefined>;
|
|
47
|
-
set(key: string, value: string): Promise<void>;
|
|
48
|
-
remove(key: string): Promise<void>;
|
|
49
|
-
}): SessionStorage;
|
|
50
|
-
|
|
51
|
-
export { type ChromeStorageAreaLike as C, type SessionStorage as S, StorageUnavailableError as a, browserStorage as b, extensionStorage as e, keyValueStorage as k, memoryStorage as m };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session storage per platform — where a Supabase session lives between runs.
|
|
3
|
-
*
|
|
4
|
-
* supabase-js takes any `{ getItem, setItem, removeItem }` (sync or async). These are the ones
|
|
5
|
-
* every Matrx client needs, written once:
|
|
6
|
-
*
|
|
7
|
-
* browser — `browserStorage("local")` (supabase-js's own default; `"session"` = this tab only)
|
|
8
|
-
* Next.js — the cookie-backed clients in `@ai-matrx/auth/next` (the domain-wide auth cookie)
|
|
9
|
-
* extension — `extensionStorage()` over `chrome.storage.local` (shared by popup, side panel and
|
|
10
|
-
* service worker; `localStorage` does not exist in a service worker)
|
|
11
|
-
* desktop — `keyValueStorage({ get, set, remove })` over the host's store (Tauri store, keychain)
|
|
12
|
-
* Node — `fileStorage(path)` in `@ai-matrx/auth/node`, or `memoryStorage()` for a one-shot run
|
|
13
|
-
*
|
|
14
|
-
* None of these is ever silently swapped for another: a storage the platform does not have throws
|
|
15
|
-
* a named error at creation, never a quiet in-memory fallback that signs the person out on reload.
|
|
16
|
-
*/
|
|
17
|
-
/** The storage contract supabase-js reads (sync or async methods). */
|
|
18
|
-
interface SessionStorage {
|
|
19
|
-
getItem(key: string): string | null | Promise<string | null>;
|
|
20
|
-
setItem(key: string, value: string): void | Promise<void>;
|
|
21
|
-
removeItem(key: string): void | Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
declare class StorageUnavailableError extends Error {
|
|
24
|
-
readonly storage: string;
|
|
25
|
-
constructor(storage: string, reason: string);
|
|
26
|
-
}
|
|
27
|
-
/** In memory only: the session ends with the process (one-shot scripts, tests, server renders). */
|
|
28
|
-
declare function memoryStorage(): SessionStorage & {
|
|
29
|
-
readonly size: () => number;
|
|
30
|
-
};
|
|
31
|
-
/** The browser's `localStorage` (shared by every tab of the origin) or `sessionStorage` (this tab). */
|
|
32
|
-
declare function browserStorage(kind?: "local" | "session"): SessionStorage;
|
|
33
|
-
/** The structural slice of `chrome.storage.<area>` read here (MV3 promise API). */
|
|
34
|
-
interface ChromeStorageAreaLike {
|
|
35
|
-
get(keys: string): Promise<Record<string, unknown>>;
|
|
36
|
-
set(items: Record<string, unknown>): Promise<void>;
|
|
37
|
-
remove(keys: string): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A browser extension's `chrome.storage` area (default `local`): one session for the popup, side
|
|
41
|
-
* panel, content scripts' relay and the service worker. Pass `area` to inject one (tests, Firefox).
|
|
42
|
-
*/
|
|
43
|
-
declare function extensionStorage(area?: ChromeStorageAreaLike): SessionStorage;
|
|
44
|
-
/** Any async key-value store the host owns (a desktop app's Tauri store or keychain). */
|
|
45
|
-
declare function keyValueStorage(store: {
|
|
46
|
-
get(key: string): Promise<string | null | undefined>;
|
|
47
|
-
set(key: string, value: string): Promise<void>;
|
|
48
|
-
remove(key: string): Promise<void>;
|
|
49
|
-
}): SessionStorage;
|
|
50
|
-
|
|
51
|
-
export { type ChromeStorageAreaLike as C, type SessionStorage as S, StorageUnavailableError as a, browserStorage as b, extensionStorage as e, keyValueStorage as k, memoryStorage as m };
|