@ai-matrx/auth 0.3.3 → 0.3.5
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 +12 -0
- package/dist/credentials.d.cts +7 -0
- package/dist/credentials.d.ts +7 -0
- package/dist/matrx-oauth.cjs +2 -2
- package/dist/matrx-oauth.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/auth
|
|
2
2
|
|
|
3
|
+
## 0.3.5
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/auth/v0.3.4..npm/auth/v0.3.5 -- apps/shared/auth`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.3.4
|
|
10
|
+
|
|
11
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
12
|
+
`git diff npm/auth/v0.3.3..npm/auth/v0.3.4 -- apps/shared/auth`).
|
|
13
|
+
No source changes intended and no consumer action required.
|
|
14
|
+
|
|
3
15
|
## 0.3.3
|
|
4
16
|
|
|
5
17
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
package/dist/credentials.d.cts
CHANGED
|
@@ -60,10 +60,17 @@ type MatrxCredential = {
|
|
|
60
60
|
* The async source of the current credential. `get()` resolves when the host
|
|
61
61
|
* knows its auth state (null = anonymous); `onChange` lets transports refresh
|
|
62
62
|
* cached headers when the credential rotates.
|
|
63
|
+
*
|
|
64
|
+
* `ready()` is the session-ready signal: it resolves once sign-in has settled
|
|
65
|
+
* (a session attached, or the host knows there is none). Transports await it
|
|
66
|
+
* — bounded — before reading the credential, so a call issued while a session
|
|
67
|
+
* is still attaching never leaves anonymously. Omit it when `get()` already
|
|
68
|
+
* waits.
|
|
63
69
|
*/
|
|
64
70
|
interface CredentialsPort {
|
|
65
71
|
get(): Promise<MatrxCredential | null>;
|
|
66
72
|
onChange?(cb: () => void): () => void;
|
|
73
|
+
ready?(): Promise<void>;
|
|
67
74
|
}
|
|
68
75
|
/** Prefix that marks a bearer token as an AI Matrx API key, never a JWT. */
|
|
69
76
|
declare const API_KEY_PREFIX = "mx_";
|
package/dist/credentials.d.ts
CHANGED
|
@@ -60,10 +60,17 @@ type MatrxCredential = {
|
|
|
60
60
|
* The async source of the current credential. `get()` resolves when the host
|
|
61
61
|
* knows its auth state (null = anonymous); `onChange` lets transports refresh
|
|
62
62
|
* cached headers when the credential rotates.
|
|
63
|
+
*
|
|
64
|
+
* `ready()` is the session-ready signal: it resolves once sign-in has settled
|
|
65
|
+
* (a session attached, or the host knows there is none). Transports await it
|
|
66
|
+
* — bounded — before reading the credential, so a call issued while a session
|
|
67
|
+
* is still attaching never leaves anonymously. Omit it when `get()` already
|
|
68
|
+
* waits.
|
|
63
69
|
*/
|
|
64
70
|
interface CredentialsPort {
|
|
65
71
|
get(): Promise<MatrxCredential | null>;
|
|
66
72
|
onChange?(cb: () => void): () => void;
|
|
73
|
+
ready?(): Promise<void>;
|
|
67
74
|
}
|
|
68
75
|
/** Prefix that marks a bearer token as an AI Matrx API key, never a JWT. */
|
|
69
76
|
declare const API_KEY_PREFIX = "mx_";
|
package/dist/matrx-oauth.cjs
CHANGED
|
@@ -131,7 +131,7 @@ function personIdFromAccessToken(token) {
|
|
|
131
131
|
expiresAtMs: typeof payload.exp === "number" ? payload.exp * 1e3 : null
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function oauthErrorFromBody(raw) {
|
|
135
135
|
try {
|
|
136
136
|
const j = JSON.parse(raw);
|
|
137
137
|
for (const key of ["error_description", "error_message", "msg", "error", "code"]) {
|
|
@@ -268,7 +268,7 @@ function createMatrxOAuth(config, ports) {
|
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
270
|
const code = String(body["error"] ?? body["error_code"] ?? res.status);
|
|
271
|
-
const detail =
|
|
271
|
+
const detail = oauthErrorFromBody(text) ?? text.slice(0, 200);
|
|
272
272
|
if (isExchange) {
|
|
273
273
|
throw new MatrxOAuthError("token_exchange_failed", `Token exchange failed (${res.status}): ${detail}`);
|
|
274
274
|
}
|
package/dist/matrx-oauth.js
CHANGED
|
@@ -97,7 +97,7 @@ function personIdFromAccessToken(token) {
|
|
|
97
97
|
expiresAtMs: typeof payload.exp === "number" ? payload.exp * 1e3 : null
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function oauthErrorFromBody(raw) {
|
|
101
101
|
try {
|
|
102
102
|
const j = JSON.parse(raw);
|
|
103
103
|
for (const key of ["error_description", "error_message", "msg", "error", "code"]) {
|
|
@@ -234,7 +234,7 @@ function createMatrxOAuth(config, ports) {
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
const code = String(body["error"] ?? body["error_code"] ?? res.status);
|
|
237
|
-
const detail =
|
|
237
|
+
const detail = oauthErrorFromBody(text) ?? text.slice(0, 200);
|
|
238
238
|
if (isExchange) {
|
|
239
239
|
throw new MatrxOAuthError("token_exchange_failed", `Token exchange failed (${res.status}): ${detail}`);
|
|
240
240
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/auth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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",
|
|
@@ -211,5 +211,5 @@
|
|
|
211
211
|
"test": "vitest run",
|
|
212
212
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
213
213
|
},
|
|
214
|
-
"gitHead": "
|
|
214
|
+
"gitHead": "6bf5dc0d5ee5a5071f767405726c136bf7f5ab69"
|
|
215
215
|
}
|