@doany-ai/sdk 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/client.js +9 -1
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -93,9 +93,17 @@ export function createClient(config) {
93
93
  interceptResponses: false,
94
94
  onError: options === null || options === void 0 ? void 0 : options.onError,
95
95
  });
96
+ // `on-behalf-of` names the USER a service-role call acts for, so only a user
97
+ // token belongs in it. In a backend function invoked with the app's own key,
98
+ // createClientFromRequest puts that key in `token` (the caller's
99
+ // Authorization is the user slot) — copying it here made the backend try to
100
+ // decode an app key as a JWT and answer 401 "Invalid token" on a request its
101
+ // Authorization had already authenticated. An app key names no user, so
102
+ // there is nobody to act on behalf of.
103
+ const actsForAUser = Boolean(token) && !token.startsWith("ak_");
96
104
  const serviceRoleHeaders = {
97
105
  ...headers,
98
- ...(token ? { "on-behalf-of": `Bearer ${token}` } : {}),
106
+ ...(actsForAUser ? { "on-behalf-of": `Bearer ${token}` } : {}),
99
107
  };
100
108
  const serviceRoleAxiosClient = createAxiosClient({
101
109
  baseURL: `${serverUrl}/api`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doany-ai/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "JavaScript SDK for the doany app platform (API-compatible fork of @base44/sdk)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",