webflow-api 2.0.0-beta → 2.0.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.
- package/README.md +30 -2
- package/api/resources/accessGroups/client/Client.d.ts +1 -1
- package/api/resources/accessGroups/client/Client.js +1 -1
- package/api/resources/assets/client/Client.d.ts +7 -7
- package/api/resources/assets/client/Client.js +7 -7
- package/api/resources/collections/client/Client.d.ts +11 -4
- package/api/resources/collections/client/Client.js +11 -4
- package/api/resources/collections/client/requests/CollectionsCreateRequest.d.ts +8 -0
- package/api/resources/collections/resources/fields/client/Client.d.ts +11 -0
- package/api/resources/collections/resources/fields/client/Client.js +11 -0
- package/api/resources/collections/resources/fields/client/requests/FieldUpdate.d.ts +4 -0
- package/api/resources/collections/resources/items/client/Client.d.ts +10 -8
- package/api/resources/collections/resources/items/client/Client.js +10 -8
- package/api/resources/ecommerce/client/Client.d.ts +1 -1
- package/api/resources/ecommerce/client/Client.js +1 -1
- package/api/resources/forms/client/Client.d.ts +5 -5
- package/api/resources/forms/client/Client.js +5 -5
- package/api/resources/inventory/client/Client.d.ts +2 -2
- package/api/resources/inventory/client/Client.js +2 -2
- package/api/resources/orders/client/Client.d.ts +6 -6
- package/api/resources/orders/client/Client.js +6 -6
- package/api/resources/pages/client/Client.d.ts +2 -2
- package/api/resources/pages/client/Client.js +2 -2
- package/api/resources/pages/resources/scripts/client/Client.d.ts +12 -3
- package/api/resources/pages/resources/scripts/client/Client.js +12 -3
- package/api/resources/products/client/Client.d.ts +6 -6
- package/api/resources/products/client/Client.js +6 -6
- package/api/resources/scripts/client/Client.d.ts +16 -1
- package/api/resources/scripts/client/Client.js +16 -1
- package/api/resources/scripts/client/requests/CustomCodeHostedRequest.d.ts +9 -0
- package/api/resources/scripts/client/requests/CustomCodeInlineRequest.d.ts +8 -0
- package/api/resources/sites/client/Client.d.ts +3 -3
- package/api/resources/sites/client/Client.js +3 -3
- package/api/resources/sites/resources/scripts/client/Client.d.ts +13 -4
- package/api/resources/sites/resources/scripts/client/Client.js +13 -4
- package/api/resources/users/client/Client.d.ts +9 -6
- package/api/resources/users/client/Client.js +9 -6
- package/api/resources/webhooks/client/Client.d.ts +4 -4
- package/api/resources/webhooks/client/Client.js +4 -4
- package/core/fetcher/Fetcher.js +19 -18
- package/dist/api/resources/accessGroups/client/Client.d.ts +1 -1
- package/dist/api/resources/accessGroups/client/Client.js +1 -1
- package/dist/api/resources/assets/client/Client.d.ts +7 -7
- package/dist/api/resources/assets/client/Client.js +7 -7
- package/dist/api/resources/collections/client/Client.d.ts +11 -4
- package/dist/api/resources/collections/client/Client.js +11 -4
- package/dist/api/resources/collections/client/requests/CollectionsCreateRequest.d.ts +8 -0
- package/dist/api/resources/collections/resources/fields/client/Client.d.ts +11 -0
- package/dist/api/resources/collections/resources/fields/client/Client.js +11 -0
- package/dist/api/resources/collections/resources/fields/client/requests/FieldUpdate.d.ts +4 -0
- package/dist/api/resources/collections/resources/items/client/Client.d.ts +10 -8
- package/dist/api/resources/collections/resources/items/client/Client.js +10 -8
- package/dist/api/resources/ecommerce/client/Client.d.ts +1 -1
- package/dist/api/resources/ecommerce/client/Client.js +1 -1
- package/dist/api/resources/forms/client/Client.d.ts +5 -5
- package/dist/api/resources/forms/client/Client.js +5 -5
- package/dist/api/resources/inventory/client/Client.d.ts +2 -2
- package/dist/api/resources/inventory/client/Client.js +2 -2
- package/dist/api/resources/orders/client/Client.d.ts +6 -6
- package/dist/api/resources/orders/client/Client.js +6 -6
- package/dist/api/resources/pages/client/Client.d.ts +2 -2
- package/dist/api/resources/pages/client/Client.js +2 -2
- package/dist/api/resources/pages/resources/scripts/client/Client.d.ts +12 -3
- package/dist/api/resources/pages/resources/scripts/client/Client.js +12 -3
- package/dist/api/resources/products/client/Client.d.ts +6 -6
- package/dist/api/resources/products/client/Client.js +6 -6
- package/dist/api/resources/scripts/client/Client.d.ts +16 -1
- package/dist/api/resources/scripts/client/Client.js +16 -1
- package/dist/api/resources/scripts/client/requests/CustomCodeHostedRequest.d.ts +9 -0
- package/dist/api/resources/scripts/client/requests/CustomCodeInlineRequest.d.ts +8 -0
- package/dist/api/resources/sites/client/Client.d.ts +3 -3
- package/dist/api/resources/sites/client/Client.js +3 -3
- package/dist/api/resources/sites/resources/scripts/client/Client.d.ts +13 -4
- package/dist/api/resources/sites/resources/scripts/client/Client.js +13 -4
- package/dist/api/resources/users/client/Client.d.ts +9 -6
- package/dist/api/resources/users/client/Client.js +9 -6
- package/dist/api/resources/webhooks/client/Client.d.ts +4 -4
- package/dist/api/resources/webhooks/client/Client.js +4 -4
- package/dist/core/fetcher/Fetcher.js +19 -18
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/environments.d.ts +1 -1
- package/environments.js +1 -1
- package/package.json +2 -4
- package/dist/oauth.d.ts +0 -27
- package/dist/oauth.js +0 -113
- package/oauth.d.ts +0 -27
- package/oauth.js +0 -113
|
@@ -58,7 +58,7 @@ class Scripts {
|
|
|
58
58
|
* @throws {@link Webflow.InternalServerError}
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
|
-
* await webflow.sites.scripts.getCustomCode("
|
|
61
|
+
* await webflow.sites.scripts.getCustomCode("string")
|
|
62
62
|
*/
|
|
63
63
|
getCustomCode(siteId, requestOptions) {
|
|
64
64
|
var _a;
|
|
@@ -128,7 +128,16 @@ class Scripts {
|
|
|
128
128
|
* @throws {@link Webflow.InternalServerError}
|
|
129
129
|
*
|
|
130
130
|
* @example
|
|
131
|
-
* await webflow.sites.scripts.upsertCustomCode("
|
|
131
|
+
* await webflow.sites.scripts.upsertCustomCode("string", {
|
|
132
|
+
* scripts: [{
|
|
133
|
+
* id: "cms_slider",
|
|
134
|
+
* location: Webflow.ScriptApplyLocation.Header,
|
|
135
|
+
* version: "1.0.0",
|
|
136
|
+
* attributes: {
|
|
137
|
+
* "my-attribute": "some-value"
|
|
138
|
+
* }
|
|
139
|
+
* }]
|
|
140
|
+
* })
|
|
132
141
|
*/
|
|
133
142
|
upsertCustomCode(siteId, request, requestOptions) {
|
|
134
143
|
var _a;
|
|
@@ -199,7 +208,7 @@ class Scripts {
|
|
|
199
208
|
* @throws {@link Webflow.InternalServerError}
|
|
200
209
|
*
|
|
201
210
|
* @example
|
|
202
|
-
* await webflow.sites.scripts.deleteCustomCode("
|
|
211
|
+
* await webflow.sites.scripts.deleteCustomCode("string")
|
|
203
212
|
*/
|
|
204
213
|
deleteCustomCode(siteId, requestOptions) {
|
|
205
214
|
var _a;
|
|
@@ -263,7 +272,7 @@ class Scripts {
|
|
|
263
272
|
* @throws {@link Webflow.InternalServerError}
|
|
264
273
|
*
|
|
265
274
|
* @example
|
|
266
|
-
* await webflow.sites.scripts.listCustomCodeBlocks("
|
|
275
|
+
* await webflow.sites.scripts.listCustomCodeBlocks("string", {})
|
|
267
276
|
*/
|
|
268
277
|
listCustomCodeBlocks(siteId, request = {}, requestOptions) {
|
|
269
278
|
var _a;
|
|
@@ -27,7 +27,7 @@ export declare class Users {
|
|
|
27
27
|
* @throws {@link Webflow.InternalServerError}
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
* await webflow.users.list("
|
|
30
|
+
* await webflow.users.list("string", {
|
|
31
31
|
* sort: Webflow.UsersListRequestSort.CreatedOnAscending
|
|
32
32
|
* })
|
|
33
33
|
*/
|
|
@@ -42,7 +42,7 @@ export declare class Users {
|
|
|
42
42
|
* @throws {@link Webflow.InternalServerError}
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
|
-
* await webflow.users.get("
|
|
45
|
+
* await webflow.users.get("string", "string")
|
|
46
46
|
*/
|
|
47
47
|
get(siteId: string, userId: string, requestOptions?: Users.RequestOptions): Promise<Webflow.User>;
|
|
48
48
|
/**
|
|
@@ -55,7 +55,7 @@ export declare class Users {
|
|
|
55
55
|
* @throws {@link Webflow.InternalServerError}
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
|
-
* await webflow.users.delete("
|
|
58
|
+
* await webflow.users.delete("string", "string")
|
|
59
59
|
*/
|
|
60
60
|
delete(siteId: string, userId: string, requestOptions?: Users.RequestOptions): Promise<void>;
|
|
61
61
|
/**
|
|
@@ -70,7 +70,7 @@ export declare class Users {
|
|
|
70
70
|
* @throws {@link Webflow.InternalServerError}
|
|
71
71
|
*
|
|
72
72
|
* @example
|
|
73
|
-
* await webflow.users.update("
|
|
73
|
+
* await webflow.users.update("string", "string", {
|
|
74
74
|
* id: "6287ec36a841b25637c663df",
|
|
75
75
|
* lastUpdated: new Date("2016-10-24T19:41:29.156Z"),
|
|
76
76
|
* invitedOn: new Date("2016-10-24T19:41:29.156Z"),
|
|
@@ -79,7 +79,10 @@ export declare class Users {
|
|
|
79
79
|
* status: Webflow.UserStatus.Invited,
|
|
80
80
|
* accessGroups: [{
|
|
81
81
|
* type: Webflow.UserAccessGroupsItemType.Admin
|
|
82
|
-
* }]
|
|
82
|
+
* }],
|
|
83
|
+
* data: {
|
|
84
|
+
* data: {}
|
|
85
|
+
* }
|
|
83
86
|
* })
|
|
84
87
|
*/
|
|
85
88
|
update(siteId: string, userId: string, request: Webflow.User, requestOptions?: Users.RequestOptions): Promise<Webflow.User>;
|
|
@@ -94,7 +97,7 @@ export declare class Users {
|
|
|
94
97
|
* @throws {@link Webflow.InternalServerError}
|
|
95
98
|
*
|
|
96
99
|
* @example
|
|
97
|
-
* await webflow.users.invite("
|
|
100
|
+
* await webflow.users.invite("string", {
|
|
98
101
|
* email: "some.one@home.com"
|
|
99
102
|
* })
|
|
100
103
|
*/
|
|
@@ -59,7 +59,7 @@ class Users {
|
|
|
59
59
|
* @throws {@link Webflow.InternalServerError}
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
|
-
* await webflow.users.list("
|
|
62
|
+
* await webflow.users.list("string", {
|
|
63
63
|
* sort: Webflow.UsersListRequestSort.CreatedOnAscending
|
|
64
64
|
* })
|
|
65
65
|
*/
|
|
@@ -146,7 +146,7 @@ class Users {
|
|
|
146
146
|
* @throws {@link Webflow.InternalServerError}
|
|
147
147
|
*
|
|
148
148
|
* @example
|
|
149
|
-
* await webflow.users.get("
|
|
149
|
+
* await webflow.users.get("string", "string")
|
|
150
150
|
*/
|
|
151
151
|
get(siteId, userId, requestOptions) {
|
|
152
152
|
var _a;
|
|
@@ -219,7 +219,7 @@ class Users {
|
|
|
219
219
|
* @throws {@link Webflow.InternalServerError}
|
|
220
220
|
*
|
|
221
221
|
* @example
|
|
222
|
-
* await webflow.users.delete("
|
|
222
|
+
* await webflow.users.delete("string", "string")
|
|
223
223
|
*/
|
|
224
224
|
delete(siteId, userId, requestOptions) {
|
|
225
225
|
var _a;
|
|
@@ -288,7 +288,7 @@ class Users {
|
|
|
288
288
|
* @throws {@link Webflow.InternalServerError}
|
|
289
289
|
*
|
|
290
290
|
* @example
|
|
291
|
-
* await webflow.users.update("
|
|
291
|
+
* await webflow.users.update("string", "string", {
|
|
292
292
|
* id: "6287ec36a841b25637c663df",
|
|
293
293
|
* lastUpdated: new Date("2016-10-24T19:41:29.156Z"),
|
|
294
294
|
* invitedOn: new Date("2016-10-24T19:41:29.156Z"),
|
|
@@ -297,7 +297,10 @@ class Users {
|
|
|
297
297
|
* status: Webflow.UserStatus.Invited,
|
|
298
298
|
* accessGroups: [{
|
|
299
299
|
* type: Webflow.UserAccessGroupsItemType.Admin
|
|
300
|
-
* }]
|
|
300
|
+
* }],
|
|
301
|
+
* data: {
|
|
302
|
+
* data: {}
|
|
303
|
+
* }
|
|
301
304
|
* })
|
|
302
305
|
*/
|
|
303
306
|
update(siteId, userId, request, requestOptions) {
|
|
@@ -373,7 +376,7 @@ class Users {
|
|
|
373
376
|
* @throws {@link Webflow.InternalServerError}
|
|
374
377
|
*
|
|
375
378
|
* @example
|
|
376
|
-
* await webflow.users.invite("
|
|
379
|
+
* await webflow.users.invite("string", {
|
|
377
380
|
* email: "some.one@home.com"
|
|
378
381
|
* })
|
|
379
382
|
*/
|
|
@@ -26,7 +26,7 @@ export declare class Webhooks {
|
|
|
26
26
|
* @throws {@link Webflow.InternalServerError}
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
|
-
* await webflow.webhooks.list("
|
|
29
|
+
* await webflow.webhooks.list("string")
|
|
30
30
|
*/
|
|
31
31
|
list(siteId: string, requestOptions?: Webhooks.RequestOptions): Promise<Webflow.Webhook[]>;
|
|
32
32
|
/**
|
|
@@ -38,7 +38,7 @@ export declare class Webhooks {
|
|
|
38
38
|
* @throws {@link Webflow.InternalServerError}
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* await webflow.webhooks.create("
|
|
41
|
+
* await webflow.webhooks.create("string", {
|
|
42
42
|
* triggerType: Webflow.TriggerType.FormSubmission,
|
|
43
43
|
* url: "https://api.mydomain.com/webhook"
|
|
44
44
|
* })
|
|
@@ -53,7 +53,7 @@ export declare class Webhooks {
|
|
|
53
53
|
* @throws {@link Webflow.InternalServerError}
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
|
-
* await webflow.webhooks.get("
|
|
56
|
+
* await webflow.webhooks.get("string")
|
|
57
57
|
*/
|
|
58
58
|
get(webhookId: string, requestOptions?: Webhooks.RequestOptions): Promise<Webflow.Webhook>;
|
|
59
59
|
/**
|
|
@@ -65,7 +65,7 @@ export declare class Webhooks {
|
|
|
65
65
|
* @throws {@link Webflow.InternalServerError}
|
|
66
66
|
*
|
|
67
67
|
* @example
|
|
68
|
-
* await webflow.webhooks.delete("
|
|
68
|
+
* await webflow.webhooks.delete("string")
|
|
69
69
|
*/
|
|
70
70
|
delete(webhookId: string, requestOptions?: Webhooks.RequestOptions): Promise<void>;
|
|
71
71
|
protected _getAuthorizationHeader(): Promise<string>;
|
|
@@ -58,7 +58,7 @@ class Webhooks {
|
|
|
58
58
|
* @throws {@link Webflow.InternalServerError}
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
|
-
* await webflow.webhooks.list("
|
|
61
|
+
* await webflow.webhooks.list("string")
|
|
62
62
|
*/
|
|
63
63
|
list(siteId, requestOptions) {
|
|
64
64
|
var _a;
|
|
@@ -128,7 +128,7 @@ class Webhooks {
|
|
|
128
128
|
* @throws {@link Webflow.InternalServerError}
|
|
129
129
|
*
|
|
130
130
|
* @example
|
|
131
|
-
* await webflow.webhooks.create("
|
|
131
|
+
* await webflow.webhooks.create("string", {
|
|
132
132
|
* triggerType: Webflow.TriggerType.FormSubmission,
|
|
133
133
|
* url: "https://api.mydomain.com/webhook"
|
|
134
134
|
* })
|
|
@@ -202,7 +202,7 @@ class Webhooks {
|
|
|
202
202
|
* @throws {@link Webflow.InternalServerError}
|
|
203
203
|
*
|
|
204
204
|
* @example
|
|
205
|
-
* await webflow.webhooks.get("
|
|
205
|
+
* await webflow.webhooks.get("string")
|
|
206
206
|
*/
|
|
207
207
|
get(webhookId, requestOptions) {
|
|
208
208
|
var _a;
|
|
@@ -272,7 +272,7 @@ class Webhooks {
|
|
|
272
272
|
* @throws {@link Webflow.InternalServerError}
|
|
273
273
|
*
|
|
274
274
|
* @example
|
|
275
|
-
* await webflow.webhooks.delete("
|
|
275
|
+
* await webflow.webhooks.delete("string")
|
|
276
276
|
*/
|
|
277
277
|
delete(webhookId, requestOptions) {
|
|
278
278
|
var _a;
|
|
@@ -15,9 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.fetcher = void 0;
|
|
16
16
|
const form_data_1 = __importDefault(require("form-data"));
|
|
17
17
|
const qs_1 = __importDefault(require("qs"));
|
|
18
|
-
if (typeof window === "undefined") {
|
|
19
|
-
global.fetch = require("node-fetch");
|
|
20
|
-
}
|
|
21
18
|
const INITIAL_RETRY_DELAY = 1;
|
|
22
19
|
const MAX_RETRY_DELAY = 60;
|
|
23
20
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -46,18 +43,19 @@ function fetcherImpl(args) {
|
|
|
46
43
|
else {
|
|
47
44
|
body = JSON.stringify(args.body);
|
|
48
45
|
}
|
|
46
|
+
const fetchFn = typeof fetch == "function" ? fetch : require("node-fetch");
|
|
49
47
|
const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
50
48
|
const controller = new AbortController();
|
|
51
49
|
let abortId = undefined;
|
|
52
50
|
if (args.timeoutMs != null) {
|
|
53
51
|
abortId = setTimeout(() => controller.abort(), args.timeoutMs);
|
|
54
52
|
}
|
|
55
|
-
const response = yield
|
|
53
|
+
const response = yield fetchFn(url, {
|
|
56
54
|
method: args.method,
|
|
57
55
|
headers,
|
|
58
56
|
body,
|
|
59
57
|
signal: controller.signal,
|
|
60
|
-
credentials: args.withCredentials ? "
|
|
58
|
+
credentials: args.withCredentials ? "include" : undefined,
|
|
61
59
|
});
|
|
62
60
|
if (abortId != null) {
|
|
63
61
|
clearTimeout(abortId);
|
|
@@ -86,19 +84,22 @@ function fetcherImpl(args) {
|
|
|
86
84
|
else if (response.body != null && args.responseType === "streaming") {
|
|
87
85
|
body = response.body;
|
|
88
86
|
}
|
|
89
|
-
else
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
else {
|
|
88
|
+
const text = yield response.text();
|
|
89
|
+
if (text.length > 0) {
|
|
90
|
+
try {
|
|
91
|
+
body = JSON.parse(text);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
error: {
|
|
97
|
+
reason: "non-json",
|
|
98
|
+
statusCode: response.status,
|
|
99
|
+
rawBody: text,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
if (response.status >= 200 && response.status < 400) {
|
package/dist/environments.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
export declare const WebflowEnvironment: {
|
|
5
|
-
readonly Default: "https://api.webflow.com
|
|
5
|
+
readonly Default: "https://api.webflow.com";
|
|
6
6
|
};
|
|
7
7
|
export declare type WebflowEnvironment = typeof WebflowEnvironment.Default;
|
package/dist/environments.js
CHANGED
package/environments.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
export declare const WebflowEnvironment: {
|
|
5
|
-
readonly Default: "https://api.webflow.com
|
|
5
|
+
readonly Default: "https://api.webflow.com";
|
|
6
6
|
};
|
|
7
7
|
export declare type WebflowEnvironment = typeof WebflowEnvironment.Default;
|
package/environments.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webflow-api",
|
|
3
|
-
"
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"version": "2.0.0-beta",
|
|
3
|
+
"version": "2.0.0",
|
|
6
4
|
"private": false,
|
|
7
5
|
"repository": "https://github.com/webflow/js-webflow-api",
|
|
8
6
|
"main": "./index.js",
|
|
@@ -27,4 +25,4 @@
|
|
|
27
25
|
"prettier": "2.7.1",
|
|
28
26
|
"typescript": "4.6.4"
|
|
29
27
|
}
|
|
30
|
-
}
|
|
28
|
+
}
|
package/dist/oauth.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { OauthScope } from "./api/types";
|
|
2
|
-
/**
|
|
3
|
-
* @param clientId The OAuth client ID
|
|
4
|
-
* @param state The state
|
|
5
|
-
* @param redirectUri The redirect URI
|
|
6
|
-
* @param scope The OAuth scopes
|
|
7
|
-
* @returns the URL to authorize a user
|
|
8
|
-
*/
|
|
9
|
-
export declare function authorizeURL({ clientId, state, redirectUri, scope, }: {
|
|
10
|
-
clientId: string;
|
|
11
|
-
state?: string;
|
|
12
|
-
redirectUri?: string;
|
|
13
|
-
scope: OauthScope | OauthScope[];
|
|
14
|
-
}): string;
|
|
15
|
-
/**
|
|
16
|
-
* @param clientId The OAuth client ID
|
|
17
|
-
* @param clientSecret The OAuth client secret
|
|
18
|
-
* @param code The OAuth code
|
|
19
|
-
* @param redirect_uri The redirect uri
|
|
20
|
-
* @returns access token that can be used to hit our API
|
|
21
|
-
*/
|
|
22
|
-
export declare function getAccessToken({ clientId, clientSecret, code, redirectUri, }: {
|
|
23
|
-
clientId: string;
|
|
24
|
-
clientSecret: string;
|
|
25
|
-
code: string;
|
|
26
|
-
redirectUri?: string;
|
|
27
|
-
}): Promise<string>;
|
package/dist/oauth.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.getAccessToken = exports.authorizeURL = void 0;
|
|
39
|
-
const core = __importStar(require("./core"));
|
|
40
|
-
const errors = __importStar(require("./errors"));
|
|
41
|
-
const qs_1 = __importDefault(require("qs"));
|
|
42
|
-
/**
|
|
43
|
-
* @param clientId The OAuth client ID
|
|
44
|
-
* @param state The state
|
|
45
|
-
* @param redirectUri The redirect URI
|
|
46
|
-
* @param scope The OAuth scopes
|
|
47
|
-
* @returns the URL to authorize a user
|
|
48
|
-
*/
|
|
49
|
-
function authorizeURL({ clientId, state, redirectUri, scope, }) {
|
|
50
|
-
const params = { response_type: "code", client_id: clientId };
|
|
51
|
-
if (redirectUri != null) {
|
|
52
|
-
params["redirect_uri"] = redirectUri;
|
|
53
|
-
}
|
|
54
|
-
if (state != null) {
|
|
55
|
-
params["state"] = state;
|
|
56
|
-
}
|
|
57
|
-
if (typeof scope === "string") {
|
|
58
|
-
params["scope"] = scope;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
params["scope"] = scope.join("+");
|
|
62
|
-
}
|
|
63
|
-
return `https://webflow.com/oauth/authorize?${qs_1.default.stringify(params)}`;
|
|
64
|
-
}
|
|
65
|
-
exports.authorizeURL = authorizeURL;
|
|
66
|
-
/**
|
|
67
|
-
* @param clientId The OAuth client ID
|
|
68
|
-
* @param clientSecret The OAuth client secret
|
|
69
|
-
* @param code The OAuth code
|
|
70
|
-
* @param redirect_uri The redirect uri
|
|
71
|
-
* @returns access token that can be used to hit our API
|
|
72
|
-
*/
|
|
73
|
-
function getAccessToken({ clientId, clientSecret, code, redirectUri, }) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const body = {
|
|
76
|
-
client_id: clientId,
|
|
77
|
-
client_secret: clientSecret,
|
|
78
|
-
code,
|
|
79
|
-
grant_type: "authorization_code",
|
|
80
|
-
};
|
|
81
|
-
if (redirectUri != null) {
|
|
82
|
-
body["redirect_uri"] = redirectUri;
|
|
83
|
-
}
|
|
84
|
-
const response = yield core.fetcher({
|
|
85
|
-
url: "https://api.webflow.com/oauth/access_token",
|
|
86
|
-
method: "POST",
|
|
87
|
-
contentType: "application/json",
|
|
88
|
-
body,
|
|
89
|
-
});
|
|
90
|
-
if (response.ok) {
|
|
91
|
-
return response["access_token"];
|
|
92
|
-
}
|
|
93
|
-
switch (response.error.reason) {
|
|
94
|
-
case "status-code":
|
|
95
|
-
throw new errors.WebflowError({
|
|
96
|
-
statusCode: response.error.statusCode,
|
|
97
|
-
body: response.error.body,
|
|
98
|
-
});
|
|
99
|
-
case "non-json":
|
|
100
|
-
throw new errors.WebflowError({
|
|
101
|
-
statusCode: response.error.statusCode,
|
|
102
|
-
body: response.error.rawBody,
|
|
103
|
-
});
|
|
104
|
-
case "timeout":
|
|
105
|
-
throw new errors.WebflowTimeoutError();
|
|
106
|
-
case "unknown":
|
|
107
|
-
throw new errors.WebflowError({
|
|
108
|
-
message: response.error.errorMessage,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
exports.getAccessToken = getAccessToken;
|
package/oauth.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { OauthScope } from "./api/types";
|
|
2
|
-
/**
|
|
3
|
-
* @param clientId The OAuth client ID
|
|
4
|
-
* @param state The state
|
|
5
|
-
* @param redirectUri The redirect URI
|
|
6
|
-
* @param scope The OAuth scopes
|
|
7
|
-
* @returns the URL to authorize a user
|
|
8
|
-
*/
|
|
9
|
-
export declare function authorizeURL({ clientId, state, redirectUri, scope, }: {
|
|
10
|
-
clientId: string;
|
|
11
|
-
state?: string;
|
|
12
|
-
redirectUri?: string;
|
|
13
|
-
scope: OauthScope | OauthScope[];
|
|
14
|
-
}): string;
|
|
15
|
-
/**
|
|
16
|
-
* @param clientId The OAuth client ID
|
|
17
|
-
* @param clientSecret The OAuth client secret
|
|
18
|
-
* @param code The OAuth code
|
|
19
|
-
* @param redirect_uri The redirect uri
|
|
20
|
-
* @returns access token that can be used to hit our API
|
|
21
|
-
*/
|
|
22
|
-
export declare function getAccessToken({ clientId, clientSecret, code, redirectUri, }: {
|
|
23
|
-
clientId: string;
|
|
24
|
-
clientSecret: string;
|
|
25
|
-
code: string;
|
|
26
|
-
redirectUri?: string;
|
|
27
|
-
}): Promise<string>;
|
package/oauth.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.getAccessToken = exports.authorizeURL = void 0;
|
|
39
|
-
const core = __importStar(require("./core"));
|
|
40
|
-
const errors = __importStar(require("./errors"));
|
|
41
|
-
const qs_1 = __importDefault(require("qs"));
|
|
42
|
-
/**
|
|
43
|
-
* @param clientId The OAuth client ID
|
|
44
|
-
* @param state The state
|
|
45
|
-
* @param redirectUri The redirect URI
|
|
46
|
-
* @param scope The OAuth scopes
|
|
47
|
-
* @returns the URL to authorize a user
|
|
48
|
-
*/
|
|
49
|
-
function authorizeURL({ clientId, state, redirectUri, scope, }) {
|
|
50
|
-
const params = { response_type: "code", client_id: clientId };
|
|
51
|
-
if (redirectUri != null) {
|
|
52
|
-
params["redirect_uri"] = redirectUri;
|
|
53
|
-
}
|
|
54
|
-
if (state != null) {
|
|
55
|
-
params["state"] = state;
|
|
56
|
-
}
|
|
57
|
-
if (typeof scope === "string") {
|
|
58
|
-
params["scope"] = scope;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
params["scope"] = scope.join("+");
|
|
62
|
-
}
|
|
63
|
-
return `https://webflow.com/oauth/authorize?${qs_1.default.stringify(params)}`;
|
|
64
|
-
}
|
|
65
|
-
exports.authorizeURL = authorizeURL;
|
|
66
|
-
/**
|
|
67
|
-
* @param clientId The OAuth client ID
|
|
68
|
-
* @param clientSecret The OAuth client secret
|
|
69
|
-
* @param code The OAuth code
|
|
70
|
-
* @param redirect_uri The redirect uri
|
|
71
|
-
* @returns access token that can be used to hit our API
|
|
72
|
-
*/
|
|
73
|
-
function getAccessToken({ clientId, clientSecret, code, redirectUri, }) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const body = {
|
|
76
|
-
client_id: clientId,
|
|
77
|
-
client_secret: clientSecret,
|
|
78
|
-
code,
|
|
79
|
-
grant_type: "authorization_code",
|
|
80
|
-
};
|
|
81
|
-
if (redirectUri != null) {
|
|
82
|
-
body["redirect_uri"] = redirectUri;
|
|
83
|
-
}
|
|
84
|
-
const response = yield core.fetcher({
|
|
85
|
-
url: "https://api.webflow.com/oauth/access_token",
|
|
86
|
-
method: "POST",
|
|
87
|
-
contentType: "application/json",
|
|
88
|
-
body,
|
|
89
|
-
});
|
|
90
|
-
if (response.ok) {
|
|
91
|
-
return response["access_token"];
|
|
92
|
-
}
|
|
93
|
-
switch (response.error.reason) {
|
|
94
|
-
case "status-code":
|
|
95
|
-
throw new errors.WebflowError({
|
|
96
|
-
statusCode: response.error.statusCode,
|
|
97
|
-
body: response.error.body,
|
|
98
|
-
});
|
|
99
|
-
case "non-json":
|
|
100
|
-
throw new errors.WebflowError({
|
|
101
|
-
statusCode: response.error.statusCode,
|
|
102
|
-
body: response.error.rawBody,
|
|
103
|
-
});
|
|
104
|
-
case "timeout":
|
|
105
|
-
throw new errors.WebflowTimeoutError();
|
|
106
|
-
case "unknown":
|
|
107
|
-
throw new errors.WebflowError({
|
|
108
|
-
message: response.error.errorMessage,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
exports.getAccessToken = getAccessToken;
|