@zapier/zapier-sdk 0.32.5 → 0.33.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 (129) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +1 -0
  4. package/dist/constants.d.ts +0 -14
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +0 -14
  7. package/dist/credentials.d.ts.map +1 -1
  8. package/dist/credentials.js +19 -20
  9. package/dist/index.cjs +22 -37
  10. package/dist/index.d.mts +1 -15
  11. package/dist/index.mjs +23 -30
  12. package/package.json +2 -2
  13. package/dist/api/auth.test.d.ts +0 -2
  14. package/dist/api/auth.test.d.ts.map +0 -1
  15. package/dist/api/auth.test.js +0 -220
  16. package/dist/api/client.test.d.ts +0 -2
  17. package/dist/api/client.test.d.ts.map +0 -1
  18. package/dist/api/client.test.js +0 -611
  19. package/dist/api/debug.test.d.ts +0 -2
  20. package/dist/api/debug.test.d.ts.map +0 -1
  21. package/dist/api/debug.test.js +0 -59
  22. package/dist/api/polling.test.d.ts +0 -2
  23. package/dist/api/polling.test.d.ts.map +0 -1
  24. package/dist/api/polling.test.js +0 -360
  25. package/dist/auth.test.d.ts +0 -2
  26. package/dist/auth.test.d.ts.map +0 -1
  27. package/dist/auth.test.js +0 -480
  28. package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
  29. package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
  30. package/dist/plugins/eventEmission/builders.test.js +0 -138
  31. package/dist/plugins/eventEmission/index.test.d.ts +0 -5
  32. package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
  33. package/dist/plugins/eventEmission/index.test.js +0 -704
  34. package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
  35. package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
  36. package/dist/plugins/eventEmission/transport.test.js +0 -164
  37. package/dist/plugins/fetch/index.test.d.ts +0 -2
  38. package/dist/plugins/fetch/index.test.d.ts.map +0 -1
  39. package/dist/plugins/fetch/index.test.js +0 -428
  40. package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
  41. package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
  42. package/dist/plugins/findFirstConnection/index.test.js +0 -177
  43. package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
  44. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
  45. package/dist/plugins/findUniqueConnection/index.test.js +0 -159
  46. package/dist/plugins/getAction/index.test.d.ts +0 -2
  47. package/dist/plugins/getAction/index.test.d.ts.map +0 -1
  48. package/dist/plugins/getAction/index.test.js +0 -211
  49. package/dist/plugins/getApp/index.test.d.ts +0 -2
  50. package/dist/plugins/getApp/index.test.d.ts.map +0 -1
  51. package/dist/plugins/getApp/index.test.js +0 -157
  52. package/dist/plugins/getConnection/index.test.d.ts +0 -2
  53. package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
  54. package/dist/plugins/getConnection/index.test.js +0 -124
  55. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
  56. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
  57. package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
  58. package/dist/plugins/listActions/index.test.d.ts +0 -2
  59. package/dist/plugins/listActions/index.test.d.ts.map +0 -1
  60. package/dist/plugins/listActions/index.test.js +0 -454
  61. package/dist/plugins/listApps/index.test.d.ts +0 -2
  62. package/dist/plugins/listApps/index.test.d.ts.map +0 -1
  63. package/dist/plugins/listApps/index.test.js +0 -124
  64. package/dist/plugins/listConnections/index.test.d.ts +0 -2
  65. package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
  66. package/dist/plugins/listConnections/index.test.js +0 -920
  67. package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
  68. package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
  69. package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
  70. package/dist/plugins/listInputFields/index.test.d.ts +0 -2
  71. package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
  72. package/dist/plugins/listInputFields/index.test.js +0 -359
  73. package/dist/plugins/manifest/index.test.d.ts +0 -2
  74. package/dist/plugins/manifest/index.test.d.ts.map +0 -1
  75. package/dist/plugins/manifest/index.test.js +0 -1179
  76. package/dist/plugins/request/index.test.d.ts +0 -2
  77. package/dist/plugins/request/index.test.d.ts.map +0 -1
  78. package/dist/plugins/request/index.test.js +0 -458
  79. package/dist/plugins/runAction/index.test.d.ts +0 -2
  80. package/dist/plugins/runAction/index.test.d.ts.map +0 -1
  81. package/dist/plugins/runAction/index.test.js +0 -350
  82. package/dist/resolvers/connectionId.test.d.ts +0 -2
  83. package/dist/resolvers/connectionId.test.d.ts.map +0 -1
  84. package/dist/resolvers/connectionId.test.js +0 -61
  85. package/dist/sdk.test.d.ts +0 -2
  86. package/dist/sdk.test.d.ts.map +0 -1
  87. package/dist/sdk.test.js +0 -260
  88. package/dist/types/domain.test.d.ts +0 -2
  89. package/dist/types/domain.test.d.ts.map +0 -1
  90. package/dist/types/domain.test.js +0 -39
  91. package/dist/utils/array-utils.test.d.ts +0 -2
  92. package/dist/utils/array-utils.test.d.ts.map +0 -1
  93. package/dist/utils/array-utils.test.js +0 -107
  94. package/dist/utils/batch-utils.test.d.ts +0 -2
  95. package/dist/utils/batch-utils.test.d.ts.map +0 -1
  96. package/dist/utils/batch-utils.test.js +0 -476
  97. package/dist/utils/domain-utils.test.d.ts +0 -2
  98. package/dist/utils/domain-utils.test.d.ts.map +0 -1
  99. package/dist/utils/domain-utils.test.js +0 -346
  100. package/dist/utils/file-utils.test.d.ts +0 -2
  101. package/dist/utils/file-utils.test.d.ts.map +0 -1
  102. package/dist/utils/file-utils.test.js +0 -51
  103. package/dist/utils/function-utils.test.d.ts +0 -2
  104. package/dist/utils/function-utils.test.d.ts.map +0 -1
  105. package/dist/utils/function-utils.test.js +0 -188
  106. package/dist/utils/id-utils.test.d.ts +0 -2
  107. package/dist/utils/id-utils.test.d.ts.map +0 -1
  108. package/dist/utils/id-utils.test.js +0 -22
  109. package/dist/utils/pagination-utils.test.d.ts +0 -17
  110. package/dist/utils/pagination-utils.test.d.ts.map +0 -1
  111. package/dist/utils/pagination-utils.test.js +0 -461
  112. package/dist/utils/retry-utils.test.d.ts +0 -2
  113. package/dist/utils/retry-utils.test.d.ts.map +0 -1
  114. package/dist/utils/retry-utils.test.js +0 -90
  115. package/dist/utils/string-utils.test.d.ts +0 -2
  116. package/dist/utils/string-utils.test.d.ts.map +0 -1
  117. package/dist/utils/string-utils.test.js +0 -59
  118. package/dist/utils/telemetry-context.test.d.ts +0 -2
  119. package/dist/utils/telemetry-context.test.d.ts.map +0 -1
  120. package/dist/utils/telemetry-context.test.js +0 -154
  121. package/dist/utils/telemetry-utils.test.d.ts +0 -2
  122. package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
  123. package/dist/utils/telemetry-utils.test.js +0 -155
  124. package/dist/utils/url-utils.test.d.ts +0 -2
  125. package/dist/utils/url-utils.test.d.ts.map +0 -1
  126. package/dist/utils/url-utils.test.js +0 -103
  127. package/dist/utils/validation.test.d.ts +0 -2
  128. package/dist/utils/validation.test.d.ts.map +0 -1
  129. package/dist/utils/validation.test.js +0 -44
@@ -1,220 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { isJwt, getAuthorizationHeader, extractUserIdsFromJwt } from "./auth";
3
- describe("api/auth", () => {
4
- describe("isJwt", () => {
5
- it("should return true for valid JWT tokens", () => {
6
- const validJwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
7
- expect(isJwt(validJwt)).toBe(true);
8
- });
9
- it("should return true for JWT with minimal valid parts", () => {
10
- const minimalJwt = "a.b.c";
11
- expect(isJwt(minimalJwt)).toBe(true);
12
- });
13
- it("should return false for tokens with fewer than 3 parts", () => {
14
- expect(isJwt("header.payload")).toBe(false);
15
- expect(isJwt("onlyonepart")).toBe(false);
16
- expect(isJwt("")).toBe(false);
17
- });
18
- it("should return false for tokens with more than 3 parts", () => {
19
- expect(isJwt("part1.part2.part3.part4")).toBe(false);
20
- });
21
- it("should return false for tokens with empty parts", () => {
22
- expect(isJwt("..")).toBe(false);
23
- expect(isJwt(".payload.signature")).toBe(false);
24
- expect(isJwt("header..signature")).toBe(false);
25
- expect(isJwt("header.payload.")).toBe(false);
26
- });
27
- it("should return false for tokens with invalid base64url characters", () => {
28
- expect(isJwt("header+plus.payload.signature")).toBe(false);
29
- expect(isJwt("header.payload/slash.signature")).toBe(false);
30
- expect(isJwt("header.payload=padding.signature")).toBe(false);
31
- expect(isJwt("header.payload with space.signature")).toBe(false);
32
- });
33
- it("should accept valid base64url characters including dashes and underscores", () => {
34
- const validBase64Url = "abc-123_XYZ.def-456_UVW.ghi-789_RST";
35
- expect(isJwt(validBase64Url)).toBe(true);
36
- });
37
- });
38
- describe("getAuthorizationHeader", () => {
39
- it("should return JWT prefix for valid JWT tokens", () => {
40
- const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U";
41
- expect(getAuthorizationHeader(jwt)).toBe(`JWT ${jwt}`);
42
- });
43
- it("should return Bearer prefix for non-JWT tokens", () => {
44
- const apiKey = "sk_test_1234567890abcdef";
45
- expect(getAuthorizationHeader(apiKey)).toBe(`Bearer ${apiKey}`);
46
- });
47
- it("should return Bearer prefix for tokens with wrong number of parts", () => {
48
- expect(getAuthorizationHeader("header.payload")).toBe("Bearer header.payload");
49
- });
50
- it("should return Bearer prefix for empty string", () => {
51
- expect(getAuthorizationHeader("")).toBe("Bearer ");
52
- });
53
- });
54
- describe("extractUserIdsFromJwt", () => {
55
- function createJwt(payload) {
56
- const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
57
- const payloadEncoded = Buffer.from(JSON.stringify(payload)).toString("base64url");
58
- const signature = "fake_signature_for_testing";
59
- return `${header}.${payloadEncoded}.${signature}`;
60
- }
61
- it("should return null values for invalid JWT tokens", () => {
62
- expect(extractUserIdsFromJwt("not-a-jwt")).toEqual({
63
- customuser_id: null,
64
- account_id: null,
65
- });
66
- });
67
- it("should return null values for JWT with invalid payload", () => {
68
- const invalidJwt = "header.not-valid-base64!.signature";
69
- expect(extractUserIdsFromJwt(invalidJwt)).toEqual({
70
- customuser_id: null,
71
- account_id: null,
72
- });
73
- });
74
- it("should extract customuser_id and account_id from regular JWT", () => {
75
- const payload = {
76
- sub: "12345",
77
- sub_type: "customuser",
78
- "zap:acc": "67890",
79
- };
80
- const jwt = createJwt(payload);
81
- expect(extractUserIdsFromJwt(jwt)).toEqual({
82
- customuser_id: 12345,
83
- account_id: 67890,
84
- });
85
- });
86
- it("should handle numeric sub and zap:acc values", () => {
87
- const payload = {
88
- sub: 99999,
89
- sub_type: "customuser",
90
- "zap:acc": 11111,
91
- };
92
- const jwt = createJwt(payload);
93
- expect(extractUserIdsFromJwt(jwt)).toEqual({
94
- customuser_id: 99999,
95
- account_id: 11111,
96
- });
97
- });
98
- it("should return null customuser_id when sub_type is not customuser", () => {
99
- const payload = {
100
- sub: "12345",
101
- sub_type: "other",
102
- "zap:acc": "67890",
103
- };
104
- const jwt = createJwt(payload);
105
- expect(extractUserIdsFromJwt(jwt)).toEqual({
106
- customuser_id: null,
107
- account_id: 67890,
108
- });
109
- });
110
- it("should return null customuser_id when sub is missing", () => {
111
- const payload = {
112
- sub_type: "customuser",
113
- "zap:acc": "67890",
114
- };
115
- const jwt = createJwt(payload);
116
- expect(extractUserIdsFromJwt(jwt)).toEqual({
117
- customuser_id: null,
118
- account_id: 67890,
119
- });
120
- });
121
- it("should return null account_id when zap:acc is missing", () => {
122
- const payload = {
123
- sub: "12345",
124
- sub_type: "customuser",
125
- };
126
- const jwt = createJwt(payload);
127
- expect(extractUserIdsFromJwt(jwt)).toEqual({
128
- customuser_id: 12345,
129
- account_id: null,
130
- });
131
- });
132
- it("should return null values when both fields are missing", () => {
133
- const payload = {
134
- other_field: "value",
135
- };
136
- const jwt = createJwt(payload);
137
- expect(extractUserIdsFromJwt(jwt)).toEqual({
138
- customuser_id: null,
139
- account_id: null,
140
- });
141
- });
142
- it("should handle nested JWT for service tokens", () => {
143
- const nestedPayload = {
144
- sub: "12345",
145
- sub_type: "customuser",
146
- "zap:acc": "67890",
147
- };
148
- const nestedJwt = createJwt(nestedPayload);
149
- const servicePayload = {
150
- sub_type: "service",
151
- njwt: nestedJwt,
152
- };
153
- const serviceJwt = createJwt(servicePayload);
154
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
155
- customuser_id: 12345,
156
- account_id: 67890,
157
- });
158
- });
159
- it("should fall back to outer payload when nested JWT is invalid", () => {
160
- const servicePayload = {
161
- sub_type: "service",
162
- njwt: "invalid.jwt",
163
- "zap:acc": "99999",
164
- };
165
- const serviceJwt = createJwt(servicePayload);
166
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
167
- customuser_id: null,
168
- account_id: 99999,
169
- });
170
- });
171
- it("should use outer payload when sub_type is service but njwt is missing", () => {
172
- const servicePayload = {
173
- sub: "12345",
174
- sub_type: "service",
175
- "zap:acc": "67890",
176
- };
177
- const serviceJwt = createJwt(servicePayload);
178
- expect(extractUserIdsFromJwt(serviceJwt)).toEqual({
179
- customuser_id: null,
180
- account_id: 67890,
181
- });
182
- });
183
- it("should return null for non-numeric sub values", () => {
184
- const payload = {
185
- sub: "not-a-number",
186
- sub_type: "customuser",
187
- "zap:acc": "67890",
188
- };
189
- const jwt = createJwt(payload);
190
- expect(extractUserIdsFromJwt(jwt)).toEqual({
191
- customuser_id: null,
192
- account_id: 67890,
193
- });
194
- });
195
- it("should return null for non-numeric zap:acc values", () => {
196
- const payload = {
197
- sub: "12345",
198
- sub_type: "customuser",
199
- "zap:acc": "not-a-number",
200
- };
201
- const jwt = createJwt(payload);
202
- expect(extractUserIdsFromJwt(jwt)).toEqual({
203
- customuser_id: 12345,
204
- account_id: null,
205
- });
206
- });
207
- it("should return null for values that parse to NaN", () => {
208
- const payload = {
209
- sub: "abc",
210
- sub_type: "customuser",
211
- "zap:acc": "xyz",
212
- };
213
- const jwt = createJwt(payload);
214
- expect(extractUserIdsFromJwt(jwt)).toEqual({
215
- customuser_id: null,
216
- account_id: null,
217
- });
218
- });
219
- });
220
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/api/client.test.ts"],"names":[],"mappings":""}