@zapier/zapier-sdk 0.33.0 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/api/auth.test.d.ts +0 -2
- package/dist/api/auth.test.d.ts.map +0 -1
- package/dist/api/auth.test.js +0 -220
- package/dist/api/client.test.d.ts +0 -2
- package/dist/api/client.test.d.ts.map +0 -1
- package/dist/api/client.test.js +0 -611
- package/dist/api/debug.test.d.ts +0 -2
- package/dist/api/debug.test.d.ts.map +0 -1
- package/dist/api/debug.test.js +0 -59
- package/dist/api/polling.test.d.ts +0 -2
- package/dist/api/polling.test.d.ts.map +0 -1
- package/dist/api/polling.test.js +0 -360
- package/dist/auth.test.d.ts +0 -2
- package/dist/auth.test.d.ts.map +0 -1
- package/dist/auth.test.js +0 -480
- package/dist/plugins/eventEmission/builders.test.d.ts +0 -2
- package/dist/plugins/eventEmission/builders.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/builders.test.js +0 -138
- package/dist/plugins/eventEmission/index.test.d.ts +0 -5
- package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.test.js +0 -712
- package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
- package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.test.js +0 -164
- package/dist/plugins/fetch/index.test.d.ts +0 -2
- package/dist/plugins/fetch/index.test.d.ts.map +0 -1
- package/dist/plugins/fetch/index.test.js +0 -428
- package/dist/plugins/findFirstConnection/index.test.d.ts +0 -2
- package/dist/plugins/findFirstConnection/index.test.d.ts.map +0 -1
- package/dist/plugins/findFirstConnection/index.test.js +0 -177
- package/dist/plugins/findUniqueConnection/index.test.d.ts +0 -2
- package/dist/plugins/findUniqueConnection/index.test.d.ts.map +0 -1
- package/dist/plugins/findUniqueConnection/index.test.js +0 -159
- package/dist/plugins/getAction/index.test.d.ts +0 -2
- package/dist/plugins/getAction/index.test.d.ts.map +0 -1
- package/dist/plugins/getAction/index.test.js +0 -211
- package/dist/plugins/getApp/index.test.d.ts +0 -2
- package/dist/plugins/getApp/index.test.d.ts.map +0 -1
- package/dist/plugins/getApp/index.test.js +0 -157
- package/dist/plugins/getConnection/index.test.d.ts +0 -2
- package/dist/plugins/getConnection/index.test.d.ts.map +0 -1
- package/dist/plugins/getConnection/index.test.js +0 -124
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
- package/dist/plugins/listActions/index.test.d.ts +0 -2
- package/dist/plugins/listActions/index.test.d.ts.map +0 -1
- package/dist/plugins/listActions/index.test.js +0 -454
- package/dist/plugins/listApps/index.test.d.ts +0 -2
- package/dist/plugins/listApps/index.test.d.ts.map +0 -1
- package/dist/plugins/listApps/index.test.js +0 -124
- package/dist/plugins/listConnections/index.test.d.ts +0 -2
- package/dist/plugins/listConnections/index.test.d.ts.map +0 -1
- package/dist/plugins/listConnections/index.test.js +0 -920
- package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
- package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
- package/dist/plugins/listInputFields/index.test.d.ts +0 -2
- package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.test.js +0 -359
- package/dist/plugins/manifest/index.test.d.ts +0 -2
- package/dist/plugins/manifest/index.test.d.ts.map +0 -1
- package/dist/plugins/manifest/index.test.js +0 -1179
- package/dist/plugins/request/index.test.d.ts +0 -2
- package/dist/plugins/request/index.test.d.ts.map +0 -1
- package/dist/plugins/request/index.test.js +0 -458
- package/dist/plugins/runAction/index.test.d.ts +0 -2
- package/dist/plugins/runAction/index.test.d.ts.map +0 -1
- package/dist/plugins/runAction/index.test.js +0 -350
- package/dist/resolvers/connectionId.test.d.ts +0 -2
- package/dist/resolvers/connectionId.test.d.ts.map +0 -1
- package/dist/resolvers/connectionId.test.js +0 -61
- package/dist/sdk.test.d.ts +0 -2
- package/dist/sdk.test.d.ts.map +0 -1
- package/dist/sdk.test.js +0 -260
- package/dist/types/domain.test.d.ts +0 -2
- package/dist/types/domain.test.d.ts.map +0 -1
- package/dist/types/domain.test.js +0 -39
- package/dist/utils/array-utils.test.d.ts +0 -2
- package/dist/utils/array-utils.test.d.ts.map +0 -1
- package/dist/utils/array-utils.test.js +0 -107
- package/dist/utils/batch-utils.test.d.ts +0 -2
- package/dist/utils/batch-utils.test.d.ts.map +0 -1
- package/dist/utils/batch-utils.test.js +0 -476
- package/dist/utils/domain-utils.test.d.ts +0 -2
- package/dist/utils/domain-utils.test.d.ts.map +0 -1
- package/dist/utils/domain-utils.test.js +0 -346
- package/dist/utils/file-utils.test.d.ts +0 -2
- package/dist/utils/file-utils.test.d.ts.map +0 -1
- package/dist/utils/file-utils.test.js +0 -51
- package/dist/utils/function-utils.test.d.ts +0 -2
- package/dist/utils/function-utils.test.d.ts.map +0 -1
- package/dist/utils/function-utils.test.js +0 -188
- package/dist/utils/id-utils.test.d.ts +0 -2
- package/dist/utils/id-utils.test.d.ts.map +0 -1
- package/dist/utils/id-utils.test.js +0 -22
- package/dist/utils/pagination-utils.test.d.ts +0 -17
- package/dist/utils/pagination-utils.test.d.ts.map +0 -1
- package/dist/utils/pagination-utils.test.js +0 -461
- package/dist/utils/retry-utils.test.d.ts +0 -2
- package/dist/utils/retry-utils.test.d.ts.map +0 -1
- package/dist/utils/retry-utils.test.js +0 -90
- package/dist/utils/string-utils.test.d.ts +0 -2
- package/dist/utils/string-utils.test.d.ts.map +0 -1
- package/dist/utils/string-utils.test.js +0 -59
- package/dist/utils/telemetry-context.test.d.ts +0 -2
- package/dist/utils/telemetry-context.test.d.ts.map +0 -1
- package/dist/utils/telemetry-context.test.js +0 -154
- package/dist/utils/telemetry-utils.test.d.ts +0 -2
- package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.test.js +0 -155
- package/dist/utils/url-utils.test.d.ts +0 -2
- package/dist/utils/url-utils.test.d.ts.map +0 -1
- package/dist/utils/url-utils.test.js +0 -103
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/dist/utils/validation.test.js +0 -44
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"tsup": "^8.5.0",
|
|
47
47
|
"typescript": "^5.8.3",
|
|
48
48
|
"vitest": "^3.2.3",
|
|
49
|
-
"@zapier/zapier-sdk-cli-login": "0.8.
|
|
49
|
+
"@zapier/zapier-sdk-cli-login": "0.8.2"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup",
|
package/dist/api/auth.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.test.d.ts","sourceRoot":"","sources":["../../src/api/auth.test.ts"],"names":[],"mappings":""}
|
package/dist/api/auth.test.js
DELETED
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/api/client.test.ts"],"names":[],"mappings":""}
|