@zapier/zapier-sdk 0.9.0 → 0.11.0

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 (187) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +7 -7
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +14 -0
  5. package/dist/api/debug.d.ts +1 -0
  6. package/dist/api/debug.d.ts.map +1 -1
  7. package/dist/api/debug.js +42 -1
  8. package/dist/api/debug.test.d.ts +2 -0
  9. package/dist/api/debug.test.d.ts.map +1 -0
  10. package/dist/api/debug.test.js +59 -0
  11. package/dist/api/schemas.d.ts +451 -251
  12. package/dist/api/schemas.d.ts.map +1 -1
  13. package/dist/api/schemas.js +51 -29
  14. package/dist/index.cjs +968 -582
  15. package/dist/index.d.mts +2537 -2229
  16. package/dist/index.d.ts +2 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -3
  19. package/dist/index.mjs +966 -576
  20. package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  22. package/dist/plugins/findFirstAuthentication/index.js +9 -1
  23. package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
  24. package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
  25. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
  26. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  27. package/dist/plugins/findUniqueAuthentication/index.js +4 -0
  28. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
  29. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
  30. package/dist/plugins/getAction/index.d.ts.map +1 -1
  31. package/dist/plugins/getAction/index.js +10 -0
  32. package/dist/plugins/getAction/schemas.d.ts +5 -3
  33. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  34. package/dist/plugins/getApp/index.d.ts.map +1 -1
  35. package/dist/plugins/getApp/index.js +8 -0
  36. package/dist/plugins/getApp/index.test.js +2 -2
  37. package/dist/plugins/getApp/schemas.d.ts +3 -1
  38. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  39. package/dist/plugins/getApp/schemas.js +2 -4
  40. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  41. package/dist/plugins/getAuthentication/index.js +8 -0
  42. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  43. package/dist/plugins/getProfile/index.js +4 -0
  44. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  45. package/dist/plugins/getProfile/schemas.js +4 -3
  46. package/dist/plugins/listActions/index.d.ts.map +1 -1
  47. package/dist/plugins/listActions/index.js +9 -0
  48. package/dist/plugins/listActions/schemas.d.ts +5 -3
  49. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  50. package/dist/plugins/listActions/schemas.js +2 -4
  51. package/dist/plugins/listApps/index.d.ts.map +1 -1
  52. package/dist/plugins/listApps/index.js +4 -0
  53. package/dist/plugins/listApps/index.test.js +1 -1
  54. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listApps/schemas.js +3 -9
  56. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  57. package/dist/plugins/listAuthentications/index.js +8 -0
  58. package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
  59. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  60. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  61. package/dist/plugins/listInputFieldChoices/index.js +14 -2
  62. package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
  63. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  64. package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
  65. package/dist/plugins/listInputFields/index.d.ts +4 -4
  66. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  67. package/dist/plugins/listInputFields/index.js +71 -5
  68. package/dist/plugins/listInputFields/index.test.js +5 -9
  69. package/dist/plugins/listInputFields/schemas.d.ts +8 -6
  70. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  71. package/dist/plugins/registry/index.d.ts.map +1 -1
  72. package/dist/plugins/registry/index.js +8 -2
  73. package/dist/plugins/request/index.d.ts.map +1 -1
  74. package/dist/plugins/request/index.js +1 -0
  75. package/dist/plugins/runAction/index.d.ts.map +1 -1
  76. package/dist/plugins/runAction/index.js +12 -0
  77. package/dist/plugins/runAction/schemas.d.ts +5 -3
  78. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  79. package/dist/resolvers/actionKey.d.ts +13 -7
  80. package/dist/resolvers/actionKey.d.ts.map +1 -1
  81. package/dist/resolvers/actionType.d.ts +8 -7
  82. package/dist/resolvers/actionType.d.ts.map +1 -1
  83. package/dist/resolvers/appKey.d.ts +2 -6
  84. package/dist/resolvers/appKey.d.ts.map +1 -1
  85. package/dist/resolvers/authenticationId.d.ts +7 -7
  86. package/dist/resolvers/authenticationId.d.ts.map +1 -1
  87. package/dist/resolvers/authenticationId.js +16 -7
  88. package/dist/resolvers/index.d.ts +3 -35
  89. package/dist/resolvers/index.d.ts.map +1 -1
  90. package/dist/resolvers/index.js +4 -87
  91. package/dist/resolvers/inputFieldKey.d.ts +11 -0
  92. package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
  93. package/dist/resolvers/inputFieldKey.js +47 -0
  94. package/dist/resolvers/inputs.d.ts +13 -4
  95. package/dist/resolvers/inputs.d.ts.map +1 -1
  96. package/dist/resolvers/inputs.js +36 -0
  97. package/dist/schemas/Action.d.ts +8 -8
  98. package/dist/schemas/Action.d.ts.map +1 -1
  99. package/dist/schemas/Action.js +8 -3
  100. package/dist/schemas/App.d.ts +183 -11
  101. package/dist/schemas/App.d.ts.map +1 -1
  102. package/dist/schemas/App.js +7 -9
  103. package/dist/schemas/Auth.d.ts +12 -12
  104. package/dist/schemas/Auth.js +1 -1
  105. package/dist/schemas/Field.d.ts +112 -97
  106. package/dist/schemas/Field.d.ts.map +1 -1
  107. package/dist/schemas/Field.js +63 -52
  108. package/dist/schemas/Run.d.ts +3 -0
  109. package/dist/schemas/Run.d.ts.map +1 -0
  110. package/dist/schemas/Run.js +31 -0
  111. package/dist/schemas/UserProfile.d.ts +11 -11
  112. package/dist/schemas/UserProfile.d.ts.map +1 -1
  113. package/dist/schemas/UserProfile.js +21 -7
  114. package/dist/sdk.d.ts +11 -4
  115. package/dist/sdk.d.ts.map +1 -1
  116. package/dist/types/domain.d.ts +17 -1
  117. package/dist/types/domain.d.ts.map +1 -1
  118. package/dist/types/plugin.d.ts +5 -0
  119. package/dist/types/plugin.d.ts.map +1 -1
  120. package/dist/types/properties.d.ts +3 -1
  121. package/dist/types/properties.d.ts.map +1 -1
  122. package/dist/types/sdk.d.ts +5 -0
  123. package/dist/types/sdk.d.ts.map +1 -1
  124. package/dist/utils/domain-utils.d.ts +1 -16
  125. package/dist/utils/domain-utils.d.ts.map +1 -1
  126. package/dist/utils/domain-utils.js +7 -51
  127. package/dist/utils/schema-utils.d.ts +44 -21
  128. package/dist/utils/schema-utils.d.ts.map +1 -1
  129. package/dist/utils/schema-utils.js +17 -11
  130. package/dist/utils/string-utils.d.ts +12 -0
  131. package/dist/utils/string-utils.d.ts.map +1 -0
  132. package/dist/utils/string-utils.js +23 -0
  133. package/dist/utils/string-utils.test.d.ts +2 -0
  134. package/dist/utils/string-utils.test.d.ts.map +1 -0
  135. package/dist/utils/string-utils.test.js +36 -0
  136. package/package.json +1 -1
  137. package/src/api/client.ts +12 -0
  138. package/src/api/debug.test.ts +76 -0
  139. package/src/api/debug.ts +46 -2
  140. package/src/api/schemas.ts +51 -29
  141. package/src/index.ts +4 -5
  142. package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
  143. package/src/plugins/findFirstAuthentication/index.ts +14 -2
  144. package/src/plugins/findUniqueAuthentication/index.ts +4 -0
  145. package/src/plugins/getAction/index.ts +14 -0
  146. package/src/plugins/getApp/index.test.ts +2 -2
  147. package/src/plugins/getApp/index.ts +8 -0
  148. package/src/plugins/getApp/schemas.ts +7 -12
  149. package/src/plugins/getAuthentication/index.ts +8 -0
  150. package/src/plugins/getProfile/index.ts +4 -0
  151. package/src/plugins/getProfile/schemas.ts +4 -6
  152. package/src/plugins/listActions/index.ts +9 -0
  153. package/src/plugins/listActions/schemas.ts +20 -25
  154. package/src/plugins/listApps/index.test.ts +1 -1
  155. package/src/plugins/listApps/index.ts +4 -0
  156. package/src/plugins/listApps/schemas.ts +17 -26
  157. package/src/plugins/listAuthentications/index.ts +8 -0
  158. package/src/plugins/listInputFieldChoices/index.ts +21 -1
  159. package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
  160. package/src/plugins/listInputFields/index.test.ts +5 -9
  161. package/src/plugins/listInputFields/index.ts +89 -11
  162. package/src/plugins/listInputFields/schemas.ts +6 -3
  163. package/src/plugins/registry/index.ts +8 -2
  164. package/src/plugins/request/index.ts +1 -0
  165. package/src/plugins/runAction/index.ts +18 -0
  166. package/src/resolvers/actionKey.ts +15 -13
  167. package/src/resolvers/actionType.ts +10 -12
  168. package/src/resolvers/appKey.ts +2 -6
  169. package/src/resolvers/authenticationId.ts +25 -19
  170. package/src/resolvers/index.ts +7 -113
  171. package/src/resolvers/inputFieldKey.ts +70 -0
  172. package/src/resolvers/inputs.ts +51 -7
  173. package/src/schemas/Action.ts +8 -3
  174. package/src/schemas/App.ts +7 -9
  175. package/src/schemas/Auth.ts +1 -1
  176. package/src/schemas/Field.ts +97 -60
  177. package/src/schemas/Run.ts +40 -0
  178. package/src/schemas/UserProfile.ts +24 -7
  179. package/src/sdk.ts +17 -7
  180. package/src/types/domain.ts +24 -1
  181. package/src/types/plugin.ts +5 -0
  182. package/src/types/sdk.ts +5 -0
  183. package/src/utils/domain-utils.ts +9 -67
  184. package/src/utils/schema-utils.ts +96 -44
  185. package/src/utils/string-utils.test.ts +45 -0
  186. package/src/utils/string-utils.ts +26 -0
  187. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 12c6d3d: Return nested fields with fieldsets instead of flat fields. Also have CLI properly create line items from fieldsets for run-action.
8
+
9
+ ## 0.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 3184903: No more global resolver registry, each plugin function has its own resolvers. Plugin function meta also stores output schema and some function type info to avoid some special case code for handling lists, documenting functions, etc. findFirstAuthentication throws an error to make all item functions consistent. Various other schema and output cleanup.
14
+
15
+ ## 0.9.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 3cfed98: Reducing any usages
20
+
3
21
  ## 0.9.0
4
22
 
5
23
  ### Minor Changes
package/README.md CHANGED
@@ -66,7 +66,7 @@ Get current user's profile information
66
66
 
67
67
  **Parameters:** None
68
68
 
69
- **Returns:** `Promise<UserProfile>`
69
+ **Returns:** `Promise<ProfileItem>`
70
70
 
71
71
  **Example:**
72
72
 
@@ -170,7 +170,7 @@ Get the input fields required for a specific action
170
170
  | `pageSize` | `number` | ❌ | — | — | Number of input fields per page |
171
171
  | `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
172
172
 
173
- **Returns:** `Promise<PaginatedResult<ActionField>>`
173
+ **Returns:** `Promise<PaginatedResult<RootFieldItemItem>>`
174
174
 
175
175
  **Example:**
176
176
 
@@ -198,7 +198,7 @@ Execute an action with the given inputs
198
198
  | `pageSize` | `number` | ❌ | — | — | Number of results per page |
199
199
  | `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
200
200
 
201
- **Returns:** `Promise<ActionExecutionResult>`
201
+ **Returns:** `Promise<PaginatedResult<ActionResultItem>>`
202
202
 
203
203
  **Example:**
204
204
 
@@ -269,7 +269,7 @@ Find the first authentication matching the criteria
269
269
  | `accountId` | `string` | ❌ | — | — | Filter by account ID |
270
270
  | `owner` | `string` | ❌ | — | — | Filter by owner |
271
271
 
272
- **Returns:** `Promise<Authentication | null>`
272
+ **Returns:** `Promise<AuthenticationItem>`
273
273
 
274
274
  **Example:**
275
275
 
@@ -291,7 +291,7 @@ Find a unique authentication matching the criteria
291
291
  | `accountId` | `string` | ❌ | — | — | Filter by account ID |
292
292
  | `owner` | `string` | ❌ | — | — | Filter by owner |
293
293
 
294
- **Returns:** `Promise<Authentication | null>`
294
+ **Returns:** `Promise<AuthenticationItem>`
295
295
 
296
296
  **Example:**
297
297
 
@@ -309,7 +309,7 @@ Get a specific authentication by ID
309
309
  | ------------------ | -------- | -------- | ------- | --------------- | ----------------------------- |
310
310
  | `authenticationId` | `number` | ✅ | — | — | Authentication ID to retrieve |
311
311
 
312
- **Returns:** `Promise<Authentication>`
312
+ **Returns:** `Promise<AuthenticationItem>`
313
313
 
314
314
  **Example:**
315
315
 
@@ -336,7 +336,7 @@ List available authentications with optional filtering
336
336
  | `pageSize` | `number` | ❌ | — | — | Number of authentications per page |
337
337
  | `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
338
338
 
339
- **Returns:** `Promise<PaginatedResult<Authentication>>`
339
+ **Returns:** `Promise<PaginatedResult<AuthenticationItem>>`
340
340
 
341
341
  **Example:**
342
342
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AA6bjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAqB3D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAycjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAqB3D,CAAC"}
@@ -167,6 +167,20 @@ class ZapierApiClient {
167
167
  if (this.isApiErrorArray(data.errors)) {
168
168
  return data.errors[0].detail || data.errors[0].title;
169
169
  }
170
+ else if (data.errors.length > 0) {
171
+ // Handle simple string errors array
172
+ const firstError = data.errors[0];
173
+ if (typeof firstError === "string") {
174
+ return firstError;
175
+ }
176
+ // For non-string errors, stringify them
177
+ try {
178
+ return JSON.stringify(firstError);
179
+ }
180
+ catch {
181
+ return String(firstError);
182
+ }
183
+ }
170
184
  }
171
185
  }
172
186
  return undefined;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { DebugLogger } from "./types";
8
8
  export declare function createDebugLogger(enabled: boolean): DebugLogger;
9
+ export declare function censorHeaders(headers?: HeadersInit): Record<string, string> | undefined;
9
10
  export declare function createDebugFetch(options: {
10
11
  originalFetch: typeof globalThis.fetch;
11
12
  debugLog: DebugLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ/D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,aAAa,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACvC,QAAQ,EAAE,WAAW,CAAC;CACvB,IAEe,OAAO,WAAW,GAAG,GAAG,EAAE,UAAU,WAAW,uBA0C9D"}
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ/D;AAED,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAwCpC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,aAAa,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACvC,QAAQ,EAAE,WAAW,CAAC;CACvB,IAEe,OAAO,WAAW,GAAG,GAAG,EAAE,UAAU,WAAW,uBA0C9D"}
package/dist/api/debug.js CHANGED
@@ -12,6 +12,47 @@ export function createDebugLogger(enabled) {
12
12
  console.log(`[Zapier SDK] ${message}`, data || "");
13
13
  };
14
14
  }
15
+ export function censorHeaders(headers) {
16
+ if (!headers)
17
+ return headers;
18
+ const headersObj = new Headers(headers);
19
+ const authKeys = ["authorization", "x-api-key"];
20
+ for (const [key, value] of headersObj.entries()) {
21
+ if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
22
+ // Find space after prefix (like "Bearer ")
23
+ const spaceIndex = value.indexOf(" ");
24
+ if (spaceIndex > 0 && spaceIndex < value.length - 1) {
25
+ const prefix = value.substring(0, spaceIndex + 1); // Include the space
26
+ const token = value.substring(spaceIndex + 1);
27
+ if (token.length > 12) {
28
+ // Show first 4 and last 4 chars, truncate middle
29
+ const start = token.substring(0, 4);
30
+ const end = token.substring(token.length - 4);
31
+ headersObj.set(key, `${prefix}${start}...${end}`);
32
+ }
33
+ else {
34
+ // Short token, use first character + three dots
35
+ const firstChar = token.charAt(0);
36
+ headersObj.set(key, `${prefix}${firstChar}...`);
37
+ }
38
+ }
39
+ else {
40
+ // No prefix found, truncate the whole value
41
+ if (value.length > 12) {
42
+ const start = value.substring(0, 4);
43
+ const end = value.substring(value.length - 4);
44
+ headersObj.set(key, `${start}...${end}`);
45
+ }
46
+ else {
47
+ // Short token, use first character + three dots
48
+ const firstChar = value.charAt(0);
49
+ headersObj.set(key, `${firstChar}...`);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ return Object.fromEntries(headersObj);
55
+ }
15
56
  export function createDebugFetch(options) {
16
57
  const { originalFetch, debugLog } = options;
17
58
  return async (input, options) => {
@@ -20,7 +61,7 @@ export function createDebugFetch(options) {
20
61
  const url = typeof input === "string" ? input : input.toString();
21
62
  const method = options?.method || "GET";
22
63
  debugLog(`→ ${method} ${url}`, {
23
- headers: options?.headers,
64
+ headers: censorHeaders(options?.headers),
24
65
  body: options?.body && typeof options.body === "string"
25
66
  ? (() => {
26
67
  try {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=debug.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.test.d.ts","sourceRoot":"","sources":["../../src/api/debug.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { censorHeaders } from "./debug";
3
+ describe("censorHeaders", () => {
4
+ it("should return undefined for undefined headers", () => {
5
+ expect(censorHeaders(undefined)).toBeUndefined();
6
+ });
7
+ it("should return headers unchanged for non-auth headers", () => {
8
+ const headers = {
9
+ "Content-Type": "application/json",
10
+ "User-Agent": "test",
11
+ };
12
+ const result = censorHeaders(headers);
13
+ // Headers API normalizes header names to lowercase
14
+ expect(result["content-type"]).toBe("application/json");
15
+ expect(result["user-agent"]).toBe("test");
16
+ });
17
+ it("should censor authorization header with Bearer prefix - long token", () => {
18
+ const headers = { authorization: "Bearer abcdef1234567890xyz" };
19
+ const result = censorHeaders(headers);
20
+ expect(result.authorization).toBe("Bearer abcd...0xyz");
21
+ });
22
+ it("should censor authorization header with Bearer prefix - short token", () => {
23
+ const headers = { authorization: "Bearer short123" };
24
+ const result = censorHeaders(headers);
25
+ expect(result.authorization).toBe("Bearer s...");
26
+ });
27
+ it("should censor x-api-key header - long token", () => {
28
+ const headers = { "x-api-key": "sk-1234567890abcdefghij" };
29
+ const result = censorHeaders(headers);
30
+ expect(result["x-api-key"]).toBe("sk-1...ghij");
31
+ });
32
+ it("should censor x-api-key header - short token", () => {
33
+ const headers = { "x-api-key": "short" };
34
+ const result = censorHeaders(headers);
35
+ expect(result["x-api-key"]).toBe("s...");
36
+ });
37
+ it("should handle Headers object input", () => {
38
+ const headers = new Headers();
39
+ headers.set("authorization", "Bearer verylongtoken123456789");
40
+ const result = censorHeaders(headers);
41
+ expect(result.authorization).toBe("Bearer very...6789");
42
+ });
43
+ it("should handle mixed case authorization headers", () => {
44
+ const headers = { Authorization: "Bearer mixedcasetoken123" };
45
+ const result = censorHeaders(headers);
46
+ expect(result.authorization).toBe("Bearer mixe...n123");
47
+ });
48
+ it("should preserve non-auth headers while censoring auth headers", () => {
49
+ const headers = {
50
+ "Content-Type": "application/json",
51
+ authorization: "Bearer shouldbecensored123456789",
52
+ "User-Agent": "test-agent",
53
+ };
54
+ const result = censorHeaders(headers);
55
+ expect(result["content-type"]).toBe("application/json");
56
+ expect(result["user-agent"]).toBe("test-agent");
57
+ expect(result.authorization).toBe("Bearer shou...6789");
58
+ });
59
+ });