@ai-matrx/auth 0.1.4 → 0.2.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/CHANGELOG.md +22 -0
- package/README.md +11 -0
- package/dist/claims-DXdbe3cW.d.cts +138 -0
- package/dist/claims-DXdbe3cW.d.ts +138 -0
- package/dist/index.cjs +135 -1
- package/dist/index.d.cts +4 -51
- package/dist/index.d.ts +4 -51
- package/dist/index.js +138 -1
- package/dist/matrx-oauth.cjs +458 -0
- package/dist/matrx-oauth.d.cts +181 -0
- package/dist/matrx-oauth.d.ts +181 -0
- package/dist/matrx-oauth.js +437 -0
- package/dist/next.cjs +133 -1
- package/dist/next.d.cts +77 -1
- package/dist/next.d.ts +77 -1
- package/dist/next.js +136 -1
- package/dist/node.cjs +139 -2
- package/dist/node.d.cts +117 -1
- package/dist/node.d.ts +117 -1
- package/dist/node.js +136 -1
- package/dist/organizations.cjs +94 -0
- package/dist/organizations.d.cts +107 -1
- package/dist/organizations.d.ts +107 -1
- package/dist/organizations.js +94 -0
- package/dist/storage-Dqnye4KF.d.cts +51 -0
- package/dist/storage-Dqnye4KF.d.ts +51 -0
- package/package.json +12 -2
|
@@ -0,0 +1,51 @@
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -122,6 +122,16 @@
|
|
|
122
122
|
"default": "./dist/testing.cjs"
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
|
+
"./matrx-oauth": {
|
|
126
|
+
"import": {
|
|
127
|
+
"types": "./dist/matrx-oauth.d.ts",
|
|
128
|
+
"default": "./dist/matrx-oauth.js"
|
|
129
|
+
},
|
|
130
|
+
"require": {
|
|
131
|
+
"types": "./dist/matrx-oauth.d.cts",
|
|
132
|
+
"default": "./dist/matrx-oauth.cjs"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
125
135
|
"./package.json": "./package.json"
|
|
126
136
|
},
|
|
127
137
|
"devDependencies": {
|
|
@@ -191,5 +201,5 @@
|
|
|
191
201
|
"test": "vitest run",
|
|
192
202
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
193
203
|
},
|
|
194
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "eeeafb1ae105f78c584681829e13dd69b200abc6"
|
|
195
205
|
}
|