@neta-art/cohub 2.11.1 → 2.11.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/NOTICE +4 -0
- package/dist/chunks/http.d.ts +6 -1
- package/dist/chunks/http.js +3 -2
- package/dist/chunks/transport.js +5 -3
- package/package.json +4 -2
package/NOTICE
ADDED
package/dist/chunks/http.d.ts
CHANGED
|
@@ -293,6 +293,8 @@ declare const createWorkRuntime: (transport?: WorkRuntimeTransport, workId?: str
|
|
|
293
293
|
type Fetch = typeof globalThis.fetch;
|
|
294
294
|
type RequestInitWithFetch = RequestInit & {
|
|
295
295
|
fetch?: Fetch;
|
|
296
|
+
/** When true, 401 responses throw without invoking onUnauthorized (e.g. session bootstrap). */
|
|
297
|
+
skipUnauthorizedHandler?: boolean;
|
|
296
298
|
};
|
|
297
299
|
type RawHttpResponse = {
|
|
298
300
|
response: Response;
|
|
@@ -1420,7 +1422,10 @@ declare class UserApi {
|
|
|
1420
1422
|
private readonly setStoredAuthToken?;
|
|
1421
1423
|
private readonly clearStoredAuthToken?;
|
|
1422
1424
|
constructor(transport: HttpTransport, transportBaseUrl: string, setStoredAuthToken?: ((token: string) => void) | undefined, clearStoredAuthToken?: (() => void) | undefined);
|
|
1423
|
-
getMe(
|
|
1425
|
+
getMe(options?: Fetch | {
|
|
1426
|
+
fetch?: Fetch;
|
|
1427
|
+
skipUnauthorizedHandler?: boolean;
|
|
1428
|
+
}): Promise<MeResponse>;
|
|
1424
1429
|
updateProfile(input: {
|
|
1425
1430
|
displayName?: string;
|
|
1426
1431
|
avatarUrl?: string | null;
|
package/dist/chunks/http.js
CHANGED
|
@@ -2564,8 +2564,9 @@ var UserApi = class {
|
|
|
2564
2564
|
this.setStoredAuthToken = setStoredAuthToken;
|
|
2565
2565
|
this.clearStoredAuthToken = clearStoredAuthToken;
|
|
2566
2566
|
}
|
|
2567
|
-
getMe(
|
|
2568
|
-
|
|
2567
|
+
getMe(options) {
|
|
2568
|
+
const init = typeof options === "function" ? { fetch: options } : options;
|
|
2569
|
+
return this.transport.request("/api/me", init);
|
|
2569
2570
|
}
|
|
2570
2571
|
updateProfile(input) {
|
|
2571
2572
|
return this.transport.request("/api/me/profile", {
|
package/dist/chunks/transport.js
CHANGED
|
@@ -102,18 +102,20 @@ var HttpTransport = class {
|
|
|
102
102
|
this.onUnauthorized = options.onUnauthorized;
|
|
103
103
|
}
|
|
104
104
|
async withAuthorization(init, tokenOverride) {
|
|
105
|
-
const
|
|
105
|
+
const { fetch: _fetch, skipUnauthorizedHandler: _skip, ...requestInit } = init ?? {};
|
|
106
|
+
const headers = new Headers(requestInit.headers);
|
|
106
107
|
const token = sanitizeAccessToken(tokenOverride !== void 0 ? tokenOverride : this.getAccessToken ? await this.getAccessToken() : null);
|
|
107
108
|
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
108
109
|
else headers.delete("Authorization");
|
|
109
110
|
return {
|
|
110
|
-
...
|
|
111
|
+
...requestInit,
|
|
111
112
|
headers
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
async send(path, init) {
|
|
115
116
|
const fetcher = init?.fetch ?? this.fetcher;
|
|
116
117
|
const url = joinApiUrl(this.baseUrl, path);
|
|
118
|
+
const skipUnauthorizedHandler = Boolean(init?.skipUnauthorizedHandler);
|
|
117
119
|
let response;
|
|
118
120
|
try {
|
|
119
121
|
response = await fetcher(url, await this.withAuthorization(init));
|
|
@@ -148,7 +150,7 @@ var HttpTransport = class {
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
if (response.status === 401) {
|
|
151
|
-
await this.onUnauthorized?.();
|
|
153
|
+
if (!skipUnauthorizedHandler) await this.onUnauthorized?.();
|
|
152
154
|
throw new HttpError("unauthorized", 401, null);
|
|
153
155
|
}
|
|
154
156
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"description": "Cohub SDK for spaces, sessions, checkpoints, and realtime agent collaboration.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -50,7 +50,9 @@
|
|
|
50
50
|
"files": [
|
|
51
51
|
"dist",
|
|
52
52
|
"README.md",
|
|
53
|
-
"docs"
|
|
53
|
+
"docs",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"NOTICE"
|
|
54
56
|
],
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"tsdown": "^0.22.7",
|