@iblai/mcp 1.12.5 → 1.12.6
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.
|
@@ -127,7 +127,7 @@ const {
|
|
|
127
127
|
mode: 'advanced', // or 'default'
|
|
128
128
|
errorHandler: (error) => toast.error(error.message),
|
|
129
129
|
on402Error: () => showSubscriptionModal(),
|
|
130
|
-
// Expired
|
|
130
|
+
// Expired axd token: mint a fresh one, the rejected message is resent with it.
|
|
131
131
|
on401Error: handle401Error, // from use401TokenRefresh({ tenantKey })
|
|
132
132
|
});
|
|
133
133
|
\`\`\`
|
package/dist/tools/hook-info.js
CHANGED
|
@@ -103,7 +103,7 @@ const {
|
|
|
103
103
|
sendMessageToParentWebsite?: (payload: unknown) => void,
|
|
104
104
|
on402Error?: (message: Error402MessageData) => void,
|
|
105
105
|
onSpendCapError?: (message: SpendCapExceededMessageData) => void,
|
|
106
|
-
// Mint a fresh
|
|
106
|
+
// Mint a fresh axd token after a 401; the rejected message is resent with it.
|
|
107
107
|
on401Error?: (message: Auth401MessageData) => Promise<string | void> | string | void,
|
|
108
108
|
});
|
|
109
109
|
\`\`\`
|
|
@@ -151,17 +151,17 @@ const {
|
|
|
151
151
|
- Offline mode support with local LLM
|
|
152
152
|
- Message queue for pending messages
|
|
153
153
|
- 402 payment required error handling
|
|
154
|
-
- 401
|
|
154
|
+
- 401 axd token refresh with automatic message resend
|
|
155
155
|
|
|
156
|
-
## Recovering from an expired
|
|
156
|
+
## Recovering from an expired axd token (\`on401Error\`)
|
|
157
157
|
|
|
158
|
-
A \`{ error, status_code: 401 }\` frame means the
|
|
158
|
+
A \`{ error, status_code: 401 }\` frame means the axd token sent with the message
|
|
159
159
|
has expired. The refresh lives entirely in your callback — the hook holds no
|
|
160
160
|
token of its own. It reconnects the socket (the backend closes it after any
|
|
161
161
|
error frame) and resends the rejected message with the token you return.
|
|
162
162
|
|
|
163
163
|
\`\`\`typescript
|
|
164
|
-
// Ready-made handler: mints app tokens, persists them, returns the new
|
|
164
|
+
// Ready-made handler: mints app tokens, persists them, returns the new axd token
|
|
165
165
|
const { handle401Error } = use401TokenRefresh({ tenantKey });
|
|
166
166
|
// ...
|
|
167
167
|
on401Error: handle401Error,
|
|
@@ -173,7 +173,7 @@ abandoned: the 401 falls through to \`errorHandler\` like any other error frame.
|
|
|
173
173
|
Only ONE retry is attempted per sent message, so a token the backend still
|
|
174
174
|
rejects cannot loop. Later messages carry the \`wsToken\` prop, so update its
|
|
175
175
|
source in the callback too. A shareable-link frame (\`token_type: "link"\`)
|
|
176
|
-
keeps its own token — only the
|
|
176
|
+
keeps its own token — only the axd token is swapped.
|
|
177
177
|
|
|
178
178
|
**File Location**: \`packages/web-utils/src/hooks/chat/use-chat-v2.ts\``,
|
|
179
179
|
use401TokenRefresh: `# use401TokenRefresh Hook
|
|
@@ -191,7 +191,7 @@ useAdvancedChat({ ...rest, on401Error: handle401Error });
|
|
|
191
191
|
|
|
192
192
|
\`handle401Error()\` POSTs \`platform_key\` to the app-tokens endpoint, writes
|
|
193
193
|
\`axd_token\`/\`dm_token\` and their expiries to storage, and resolves with the new
|
|
194
|
-
|
|
194
|
+
axd token — the one the chat socket authenticates with, and what the rejected
|
|
195
195
|
message is resent with. The write also updates every \`useAxdToken()\` /
|
|
196
196
|
\`useDmToken()\` subscriber.
|
|
197
197
|
|