@roundtable-bb/sdk 0.1.28 → 0.1.33

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/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { AcpClient, TenantClient } from './generated/client.js';
1
+ export { RoundtableClient } from './generated/client.js';
package/dist/request.js CHANGED
@@ -1,21 +1,33 @@
1
1
  export async function request(opts, method, path, options) {
2
2
  const routeAuth = options?.routeAuth;
3
- let useCredentials = options?.useCredentials ?? false;
4
- // Decide auth strategy
5
- if (routeAuth) {
6
- // TenantClient: use credentials if explicitly required by route
7
- if (routeAuth.tenantUseCredentials) {
3
+ const authMethod = options?.authMethod;
4
+ let token;
5
+ let useCredentials = false;
6
+ if (authMethod) {
7
+ if (authMethod === 'apiKey') {
8
+ if (!opts.apiKey)
9
+ throw new Error('authMethod: apiKey is not configured');
10
+ token = opts.apiKey;
11
+ }
12
+ else if (authMethod === 'tenantToken') {
13
+ if (!opts.tenantToken)
14
+ throw new Error('authMethod: tenantToken is not configured');
15
+ token = opts.tenantToken;
16
+ }
17
+ else if (authMethod === 'betterAuth') {
8
18
  useCredentials = true;
9
19
  }
10
- // If token is available, use it (prefer token over credentials)
11
- else if (opts.token && routeAuth.acceptsApiKey) {
12
- useCredentials = false;
20
+ }
21
+ else if (routeAuth) {
22
+ if (opts.apiKey && routeAuth.acceptsApiKey) {
23
+ token = opts.apiKey;
24
+ }
25
+ else if (opts.tenantToken && routeAuth.acceptsTenantJwt) {
26
+ token = opts.tenantToken;
13
27
  }
14
- // If no token but route accepts better-auth: use credentials
15
- else if (!opts.token && routeAuth.acceptsBetterAuth) {
28
+ else if (routeAuth.acceptsBetterAuth) {
16
29
  useCredentials = true;
17
30
  }
18
- // Otherwise: make request without auth (backend will respond 401/403 if needed)
19
31
  }
20
32
  const url = new URL(`${opts.baseURL}${path}`);
21
33
  if (options?.query) {
@@ -28,12 +40,8 @@ export async function request(opts, method, path, options) {
28
40
  method,
29
41
  credentials: useCredentials ? 'include' : undefined,
30
42
  headers: {
31
- ...(options?.body !== undefined
32
- ? { 'Content-Type': 'application/json' }
33
- : {}),
34
- ...(opts.token && !useCredentials
35
- ? { Authorization: `Bearer ${opts.token}` }
36
- : {}),
43
+ ...(options?.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
44
+ ...(token ? { Authorization: `Bearer ${token}` } : {}),
37
45
  },
38
46
  body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
39
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roundtable-bb/sdk",
3
- "version": "0.1.28",
3
+ "version": "0.1.33",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"