webflow-api 1.1.1 → 1.2.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 +12 -1
- package/dist/api/collection.d.ts +85 -24
- package/dist/api/collection.js +88 -29
- package/dist/api/index.d.ts +7 -7
- package/dist/api/index.js +9 -19
- package/dist/api/item.d.ts +141 -107
- package/dist/api/item.js +145 -125
- package/dist/api/meta.d.ts +16 -14
- package/dist/api/meta.js +20 -19
- package/dist/api/oauth.d.ts +38 -36
- package/dist/api/oauth.js +59 -59
- package/dist/api/site.d.ts +118 -43
- package/dist/api/site.js +131 -53
- package/dist/{wrapper/membership.d.ts → api/user.d.ts} +59 -33
- package/dist/api/user.js +103 -0
- package/dist/api/webhook.d.ts +77 -55
- package/dist/api/webhook.js +74 -61
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +8 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/response.d.ts +32 -0
- package/dist/core/response.js +26 -0
- package/dist/{webflow.d.ts → core/webflow.d.ts} +57 -52
- package/dist/{webflow.js → core/webflow.js} +102 -61
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/src/api/collection.ts +102 -35
- package/src/api/index.ts +7 -7
- package/src/api/item.ts +207 -176
- package/src/api/meta.ts +19 -18
- package/src/api/oauth.ts +62 -74
- package/src/api/site.ts +158 -55
- package/src/api/user.ts +152 -0
- package/src/api/webhook.ts +97 -80
- package/src/core/error.ts +8 -0
- package/src/core/index.ts +2 -2
- package/src/core/response.ts +50 -0
- package/src/{webflow.ts → core/webflow.ts} +132 -137
- package/src/index.ts +1 -1
- package/yarn.lock +0 -5
- package/dist/api/membership.d.ts +0 -91
- package/dist/api/membership.js +0 -80
- package/dist/core/client.d.ts +0 -40
- package/dist/core/client.js +0 -49
- package/dist/core/options.d.ts +0 -8
- package/dist/core/options.js +0 -5
- package/dist/wrapper/collection.d.ts +0 -85
- package/dist/wrapper/collection.js +0 -94
- package/dist/wrapper/index.d.ts +0 -6
- package/dist/wrapper/index.js +0 -22
- package/dist/wrapper/item.d.ts +0 -140
- package/dist/wrapper/item.js +0 -153
- package/dist/wrapper/membership.js +0 -106
- package/dist/wrapper/response.d.ts +0 -16
- package/dist/wrapper/response.js +0 -17
- package/dist/wrapper/site.d.ts +0 -119
- package/dist/wrapper/site.js +0 -136
- package/dist/wrapper/webhook.d.ts +0 -78
- package/dist/wrapper/webhook.js +0 -82
- package/src/api/membership.ts +0 -125
- package/src/core/client.ts +0 -76
- package/src/core/options.ts +0 -9
- package/src/wrapper/collection.ts +0 -115
- package/src/wrapper/index.ts +0 -6
- package/src/wrapper/item.ts +0 -218
- package/src/wrapper/membership.ts +0 -138
- package/src/wrapper/response.ts +0 -25
- package/src/wrapper/site.ts +0 -164
- package/src/wrapper/webhook.ts +0 -116
package/dist/api/item.js
CHANGED
|
@@ -1,131 +1,151 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Item = void 0;
|
|
4
4
|
const core_1 = require("../core");
|
|
5
5
|
/**************************************************************
|
|
6
|
-
*
|
|
6
|
+
* Class
|
|
7
7
|
**************************************************************/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
class Item extends core_1.WebflowRecord {
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* Static Methods
|
|
11
|
+
**************************************************************/
|
|
12
|
+
/**
|
|
13
|
+
* Get a single Item
|
|
14
|
+
* @param params The params for the request
|
|
15
|
+
* @param params.collectionId The Collection ID
|
|
16
|
+
* @param params.itemId The Item ID
|
|
17
|
+
* @param client The Axios client instance
|
|
18
|
+
* @returns A single Item
|
|
19
|
+
*/
|
|
20
|
+
static getOne({ collectionId, itemId }, client) {
|
|
21
|
+
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
22
|
+
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
23
|
+
// The API returns a paginated list with one record :(
|
|
24
|
+
return client.get(path);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get a list of Items
|
|
28
|
+
* @param params The params for the request
|
|
29
|
+
* @param params.collectionId The Collection ID
|
|
30
|
+
* @param params.limit The number of items to return (optional)
|
|
31
|
+
* @param params.offset The number of items to skip (optional)
|
|
32
|
+
* @param client The Axios client instance
|
|
33
|
+
* @returns A list of Items
|
|
34
|
+
*/
|
|
35
|
+
static list({ collectionId, limit, offset }, client) {
|
|
36
|
+
(0, core_1.requireArgs)({ collectionId });
|
|
37
|
+
const params = { limit, offset };
|
|
38
|
+
const path = `/collections/${collectionId}/items`;
|
|
39
|
+
return client.get(path, { params });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a new Item
|
|
43
|
+
* @param params The params for the request
|
|
44
|
+
* @param params.collectionId The Collection ID
|
|
45
|
+
* @param params.fields The Item fields to create
|
|
46
|
+
* @param client The Axios client instance
|
|
47
|
+
* @returns The created Item
|
|
48
|
+
*/
|
|
49
|
+
static create({ collectionId, fields }, client) {
|
|
50
|
+
(0, core_1.requireArgs)({ collectionId });
|
|
51
|
+
const path = `/collections/${collectionId}/items`;
|
|
52
|
+
return client.post(path, { fields });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update a single Item
|
|
56
|
+
* @param params The params for the request
|
|
57
|
+
* @param params.collectionId The Collection ID
|
|
58
|
+
* @param params.itemId The Item ID
|
|
59
|
+
* @param params.fields The fields to update
|
|
60
|
+
* @param client The Axios client instance
|
|
61
|
+
* @returns The updated Item
|
|
62
|
+
*/
|
|
63
|
+
static update({ collectionId, itemId, fields, }, client) {
|
|
64
|
+
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
65
|
+
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
66
|
+
return client.put(path, { fields });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Patch a single Item
|
|
70
|
+
* @param params The params for the request
|
|
71
|
+
* @param params.collectionId The Collection ID
|
|
72
|
+
* @param params.itemId The Item ID
|
|
73
|
+
* @param params.fields The fields to patch
|
|
74
|
+
* @param client The Axios client instance
|
|
75
|
+
* @returns The patched Item
|
|
76
|
+
*/
|
|
77
|
+
static patch({ collectionId, itemId, fields, }, client) {
|
|
78
|
+
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
79
|
+
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
80
|
+
return client.patch(path, { fields });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove a single Item
|
|
84
|
+
* @param params The params for the request
|
|
85
|
+
* @param params.collectionId The Collection ID
|
|
86
|
+
* @param params.itemId The Item ID
|
|
87
|
+
* @param client The Axios client instance
|
|
88
|
+
* @returns The result from the removal
|
|
89
|
+
*/
|
|
90
|
+
static remove({ collectionId, itemId, }, client) {
|
|
91
|
+
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
92
|
+
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
93
|
+
return client.delete(path);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Unpublishes a list of Items
|
|
97
|
+
* @param params The params for the request
|
|
98
|
+
* @param params.collectionId The Collection ID
|
|
99
|
+
* @param params.live Unpublish from the live site
|
|
100
|
+
* @param client The Axios client instance
|
|
101
|
+
* @returns The result of the unpublish
|
|
102
|
+
*/
|
|
103
|
+
static unpublish({ collectionId, itemIds, live = false, }, client) {
|
|
104
|
+
(0, core_1.requireArgs)({ collectionId, itemIds });
|
|
105
|
+
const params = { live };
|
|
106
|
+
const data = { itemIds };
|
|
107
|
+
const url = `/collections/${collectionId}/items`;
|
|
108
|
+
const _params = { method: "DELETE", url, data, params };
|
|
109
|
+
// DELETE spec doesn't support body in delete
|
|
110
|
+
// RFC-9110 https://tools.ietf.org/html/rfc9110
|
|
111
|
+
return client.request(_params);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Publishes a list of Items
|
|
115
|
+
* @param params The request parameters
|
|
116
|
+
* @param params.collectionId The Collection ID
|
|
117
|
+
* @param params.itemIds The list of Item IDs to publish
|
|
118
|
+
* @param params.live Publish to live site
|
|
119
|
+
* @param client The Axios client instance
|
|
120
|
+
* @returns The result of the publish
|
|
121
|
+
*/
|
|
122
|
+
static publish({ itemIds, live = false, collectionId }, client) {
|
|
123
|
+
(0, core_1.requireArgs)({ collectionId, itemIds });
|
|
124
|
+
const params = { live };
|
|
125
|
+
const path = `/collections/${collectionId}/items/publish`;
|
|
126
|
+
return client.put(path, { itemIds }, { params });
|
|
127
|
+
}
|
|
128
|
+
/**************************************************************
|
|
129
|
+
* Instance Methods
|
|
130
|
+
**************************************************************/
|
|
131
|
+
/**
|
|
132
|
+
* Update a single Item
|
|
133
|
+
* @param fields The fields to update
|
|
134
|
+
* @returns The updated Item
|
|
135
|
+
*/
|
|
136
|
+
async update({ ...fields }) {
|
|
137
|
+
const params = { collectionId: this._cid, itemId: this._id, fields };
|
|
138
|
+
const res = await Item.update(params, this.client);
|
|
139
|
+
return new Item(this.client, res);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Remove a single Item
|
|
143
|
+
* @returns The result from the removal
|
|
144
|
+
*/
|
|
145
|
+
async remove() {
|
|
146
|
+
const params = { collectionId: this._cid, itemId: this._id };
|
|
147
|
+
const res = await Item.remove(params, this.client);
|
|
148
|
+
return res.data;
|
|
149
|
+
}
|
|
21
150
|
}
|
|
22
|
-
exports.
|
|
23
|
-
/**
|
|
24
|
-
* Get a list of Items
|
|
25
|
-
* @param client The Webflow client
|
|
26
|
-
* @param params The params for the request
|
|
27
|
-
* @param params.collectionId The Collection ID
|
|
28
|
-
* @param params.limit The number of items to return (optional)
|
|
29
|
-
* @param params.offset The number of items to skip (optional)
|
|
30
|
-
* @returns A list of Items
|
|
31
|
-
*/
|
|
32
|
-
function list(client, { collectionId, limit, offset, }) {
|
|
33
|
-
(0, core_1.requireArgs)({ collectionId });
|
|
34
|
-
const params = { limit, offset };
|
|
35
|
-
const path = `/collections/${collectionId}/items`;
|
|
36
|
-
return client.get(path, { params });
|
|
37
|
-
}
|
|
38
|
-
exports.list = list;
|
|
39
|
-
/**
|
|
40
|
-
* Create a new Item
|
|
41
|
-
* @param client The Webflow client
|
|
42
|
-
* @param params The params for the request
|
|
43
|
-
* @param params.collectionId The Collection ID
|
|
44
|
-
* @param params.fields The Item fields to create
|
|
45
|
-
* @returns The created Item
|
|
46
|
-
*/
|
|
47
|
-
function create(client, { collectionId, fields }) {
|
|
48
|
-
(0, core_1.requireArgs)({ collectionId });
|
|
49
|
-
const path = `/collections/${collectionId}/items`;
|
|
50
|
-
return client.post(path, { fields });
|
|
51
|
-
}
|
|
52
|
-
exports.create = create;
|
|
53
|
-
/**
|
|
54
|
-
* Update a single Item
|
|
55
|
-
* @param client The Webflow client
|
|
56
|
-
* @param params The params for the request
|
|
57
|
-
* @param params.collectionId The Collection ID
|
|
58
|
-
* @param params.itemId The Item ID
|
|
59
|
-
* @param params.fields The fields to update
|
|
60
|
-
* @returns The updated Item
|
|
61
|
-
*/
|
|
62
|
-
function update(client, { collectionId, itemId, fields, }) {
|
|
63
|
-
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
64
|
-
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
65
|
-
return client.put(path, { fields });
|
|
66
|
-
}
|
|
67
|
-
exports.update = update;
|
|
68
|
-
/**
|
|
69
|
-
* Patch a single Item
|
|
70
|
-
* @param client The Webflow client
|
|
71
|
-
* @param params The params for the request
|
|
72
|
-
* @param params.collectionId The Collection ID
|
|
73
|
-
* @param params.itemId The Item ID
|
|
74
|
-
* @param params.fields The fields to patch
|
|
75
|
-
* @returns The patched Item
|
|
76
|
-
*/
|
|
77
|
-
function patch(client, { collectionId, itemId, fields, }) {
|
|
78
|
-
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
79
|
-
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
80
|
-
return client.patch(path, { fields });
|
|
81
|
-
}
|
|
82
|
-
exports.patch = patch;
|
|
83
|
-
/**
|
|
84
|
-
* Remove a single Item
|
|
85
|
-
* @param client The Webflow client
|
|
86
|
-
* @param params The params for the request
|
|
87
|
-
* @param params.collectionId The Collection ID
|
|
88
|
-
* @param params.itemId The Item ID
|
|
89
|
-
* @returns The result from the removal
|
|
90
|
-
*/
|
|
91
|
-
function remove(client, { collectionId, itemId, }) {
|
|
92
|
-
(0, core_1.requireArgs)({ collectionId, itemId });
|
|
93
|
-
const path = `/collections/${collectionId}/items/${itemId}`;
|
|
94
|
-
return client.delete(path);
|
|
95
|
-
}
|
|
96
|
-
exports.remove = remove;
|
|
97
|
-
/**
|
|
98
|
-
* Unpublishes a list of Items
|
|
99
|
-
* @param client The Webflow client
|
|
100
|
-
* @param params The params for the request
|
|
101
|
-
* @param params.collectionId The Collection ID
|
|
102
|
-
* @param params.live Unpublish from the live site
|
|
103
|
-
* @returns The result of the unpublish
|
|
104
|
-
*/
|
|
105
|
-
function unpublish(client, { collectionId, itemIds, live = false, }) {
|
|
106
|
-
(0, core_1.requireArgs)({ collectionId, itemIds });
|
|
107
|
-
const params = { live };
|
|
108
|
-
const data = { itemIds };
|
|
109
|
-
const url = `/collections/${collectionId}/items`;
|
|
110
|
-
const _params = { method: "DELETE", url, data, params };
|
|
111
|
-
// DELETE spec doesn't support body in delete
|
|
112
|
-
// RFC-9110 https://tools.ietf.org/html/rfc9110
|
|
113
|
-
return client.request(_params);
|
|
114
|
-
}
|
|
115
|
-
exports.unpublish = unpublish;
|
|
116
|
-
/**
|
|
117
|
-
* Publishes a list of Items
|
|
118
|
-
* @param client The Webflow client
|
|
119
|
-
* @param params The request parameters
|
|
120
|
-
* @param params.collectionId The Collection ID
|
|
121
|
-
* @param params.itemIds The list of Item IDs to publish
|
|
122
|
-
* @param params.live Publish to live site
|
|
123
|
-
* @returns The result of the publish
|
|
124
|
-
*/
|
|
125
|
-
function publish(client, { itemIds, live = false, collectionId, }) {
|
|
126
|
-
(0, core_1.requireArgs)({ collectionId, itemIds });
|
|
127
|
-
const params = { live };
|
|
128
|
-
const path = `/collections/${collectionId}/items/publish`;
|
|
129
|
-
return client.put(path, { itemIds }, { params });
|
|
130
|
-
}
|
|
131
|
-
exports.publish = publish;
|
|
151
|
+
exports.Item = Item;
|
package/dist/api/meta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
2
|
/**************************************************************
|
|
3
3
|
* Types
|
|
4
4
|
**************************************************************/
|
|
@@ -35,17 +35,19 @@ export interface IAuthentiationInfo {
|
|
|
35
35
|
_id: string;
|
|
36
36
|
}
|
|
37
37
|
/**************************************************************
|
|
38
|
-
*
|
|
38
|
+
* Class
|
|
39
39
|
**************************************************************/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
export declare class Meta {
|
|
41
|
+
/**
|
|
42
|
+
* Get the authentication info for the current token
|
|
43
|
+
* @param client The Axios client instance
|
|
44
|
+
* @returns The authentication info
|
|
45
|
+
*/
|
|
46
|
+
static info(client: AxiosInstance): Promise<import("axios").AxiosResponse<IAuthentiationInfo, any>>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the authenticated user
|
|
49
|
+
* @param client The Axios client instance
|
|
50
|
+
* @returns The authenticated user
|
|
51
|
+
*/
|
|
52
|
+
static user(client: AxiosInstance): Promise<import("axios").AxiosResponse<IAuthenticatedUser, any>>;
|
|
53
|
+
}
|
package/dist/api/meta.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Meta = void 0;
|
|
4
4
|
/**************************************************************
|
|
5
|
-
*
|
|
5
|
+
* Class
|
|
6
6
|
**************************************************************/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
class Meta {
|
|
8
|
+
/**
|
|
9
|
+
* Get the authentication info for the current token
|
|
10
|
+
* @param client The Axios client instance
|
|
11
|
+
* @returns The authentication info
|
|
12
|
+
*/
|
|
13
|
+
static info(client) {
|
|
14
|
+
return client.get("/info");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the authenticated user
|
|
18
|
+
* @param client The Axios client instance
|
|
19
|
+
* @returns The authenticated user
|
|
20
|
+
*/
|
|
21
|
+
static user(client) {
|
|
22
|
+
return client.get("/user");
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
|
-
exports.
|
|
16
|
-
/**
|
|
17
|
-
* Get the authenticated user
|
|
18
|
-
* @param client The Webflow client
|
|
19
|
-
* @returns The authenticated user
|
|
20
|
-
*/
|
|
21
|
-
function user(client) {
|
|
22
|
-
return client.get("/user");
|
|
23
|
-
}
|
|
24
|
-
exports.user = user;
|
|
25
|
+
exports.Meta = Meta;
|
package/dist/api/oauth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
2
|
/**************************************************************
|
|
3
3
|
* Interfaces
|
|
4
4
|
**************************************************************/
|
|
@@ -29,39 +29,41 @@ export interface IRevokeToken {
|
|
|
29
29
|
didRevoke: boolean;
|
|
30
30
|
}
|
|
31
31
|
/**************************************************************
|
|
32
|
-
*
|
|
32
|
+
* Class
|
|
33
33
|
**************************************************************/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
export declare class OAuth {
|
|
35
|
+
/**
|
|
36
|
+
* Get the URL to authorize a user
|
|
37
|
+
* @param params The params for the request
|
|
38
|
+
* @param params.client_id The OAuth client ID
|
|
39
|
+
* @param params.scope The scope (optional)
|
|
40
|
+
* @param params.state The state (optional)
|
|
41
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
42
|
+
* @param params.response_type The response type (default: code)
|
|
43
|
+
* @param client The Axios client instance
|
|
44
|
+
* @returns The URL to authorize a user
|
|
45
|
+
*/
|
|
46
|
+
static authorizeUrl({ response_type, redirect_uri, client_id, state, scope }: IAuthorizeUrlParams, client: AxiosInstance): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get an access token
|
|
49
|
+
* @param params The params for the request
|
|
50
|
+
* @param params.code The OAuth code
|
|
51
|
+
* @param params.client_id The OAuth client ID
|
|
52
|
+
* @param params.client_secret The OAuth client secret
|
|
53
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
54
|
+
* @param params.grant_type The grant type (default: "authorization_code")
|
|
55
|
+
* @param client The Axios client instance
|
|
56
|
+
* @returns An access token
|
|
57
|
+
*/
|
|
58
|
+
static accessToken({ grant_type, client_secret, redirect_uri, client_id, code }: IAccessTokenParams, client: AxiosInstance): Promise<import("axios").AxiosResponse<IAccessToken, any>>;
|
|
59
|
+
/**
|
|
60
|
+
* Revoke an access token
|
|
61
|
+
* @param params The params for the request
|
|
62
|
+
* @param params.client_id The OAuth client ID
|
|
63
|
+
* @param params.client_secret The OAuth client secret
|
|
64
|
+
* @param params.access_token The OAuth access token
|
|
65
|
+
* @param client The Axios client instance
|
|
66
|
+
* @returns The result of the revoke
|
|
67
|
+
*/
|
|
68
|
+
static revokeToken({ client_secret, access_token, client_id }: IRevokeTokenParams, client: AxiosInstance): Promise<import("axios").AxiosResponse<IRevokeToken, any>>;
|
|
69
|
+
}
|
package/dist/api/oauth.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OAuth = void 0;
|
|
4
4
|
const core_1 = require("../core");
|
|
5
5
|
/**************************************************************
|
|
6
|
-
*
|
|
6
|
+
* Class
|
|
7
7
|
**************************************************************/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
class OAuth {
|
|
9
|
+
/**
|
|
10
|
+
* Get the URL to authorize a user
|
|
11
|
+
* @param params The params for the request
|
|
12
|
+
* @param params.client_id The OAuth client ID
|
|
13
|
+
* @param params.scope The scope (optional)
|
|
14
|
+
* @param params.state The state (optional)
|
|
15
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
16
|
+
* @param params.response_type The response type (default: code)
|
|
17
|
+
* @param client The Axios client instance
|
|
18
|
+
* @returns The URL to authorize a user
|
|
19
|
+
*/
|
|
20
|
+
static authorizeUrl({ response_type = "code", redirect_uri, client_id, state, scope }, client) {
|
|
21
|
+
(0, core_1.requireArgs)({ client_id });
|
|
22
|
+
const params = { response_type, client_id };
|
|
23
|
+
if (redirect_uri)
|
|
24
|
+
params["redirect_uri"] = redirect_uri;
|
|
25
|
+
if (state)
|
|
26
|
+
params["state"] = state;
|
|
27
|
+
if (scope)
|
|
28
|
+
params["scope"] = scope;
|
|
29
|
+
const url = "/oauth/authorize";
|
|
30
|
+
return client.getUri({ url, method: "GET", params });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get an access token
|
|
34
|
+
* @param params The params for the request
|
|
35
|
+
* @param params.code The OAuth code
|
|
36
|
+
* @param params.client_id The OAuth client ID
|
|
37
|
+
* @param params.client_secret The OAuth client secret
|
|
38
|
+
* @param params.redirect_uri The redirect URI (optional)
|
|
39
|
+
* @param params.grant_type The grant type (default: "authorization_code")
|
|
40
|
+
* @param client The Axios client instance
|
|
41
|
+
* @returns An access token
|
|
42
|
+
*/
|
|
43
|
+
static accessToken({ grant_type = "authorization_code", client_secret, redirect_uri, client_id, code }, client) {
|
|
44
|
+
(0, core_1.requireArgs)({ client_id, client_secret, code });
|
|
45
|
+
const path = "/oauth/access_token";
|
|
46
|
+
const data = { client_secret, redirect_uri, grant_type, client_id, code };
|
|
47
|
+
return client.post(path, data);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Revoke an access token
|
|
51
|
+
* @param params The params for the request
|
|
52
|
+
* @param params.client_id The OAuth client ID
|
|
53
|
+
* @param params.client_secret The OAuth client secret
|
|
54
|
+
* @param params.access_token The OAuth access token
|
|
55
|
+
* @param client The Axios client instance
|
|
56
|
+
* @returns The result of the revoke
|
|
57
|
+
*/
|
|
58
|
+
static revokeToken({ client_secret, access_token, client_id }, client) {
|
|
59
|
+
(0, core_1.requireArgs)({ client_id, client_secret, access_token });
|
|
60
|
+
const path = "/oauth/revoke_authorization";
|
|
61
|
+
const data = { client_secret, access_token, client_id };
|
|
62
|
+
return client.post(path, data);
|
|
63
|
+
}
|
|
30
64
|
}
|
|
31
|
-
exports.
|
|
32
|
-
/**
|
|
33
|
-
* Get an access token
|
|
34
|
-
* @param client The Webflow client
|
|
35
|
-
* @param params The params for the request
|
|
36
|
-
* @param params.code The OAuth code
|
|
37
|
-
* @param params.client_id The OAuth client ID
|
|
38
|
-
* @param params.client_secret The OAuth client secret
|
|
39
|
-
* @param params.redirect_uri The redirect URI (optional)
|
|
40
|
-
* @param params.grant_type The grant type (default: "authorization_code")
|
|
41
|
-
* @returns An access token
|
|
42
|
-
*/
|
|
43
|
-
function accessToken(client, { grant_type = "authorization_code", client_secret, redirect_uri, client_id, code, }) {
|
|
44
|
-
(0, core_1.requireArgs)({ client_id, client_secret, code });
|
|
45
|
-
const path = "/oauth/access_token";
|
|
46
|
-
const data = { client_secret, redirect_uri, grant_type, client_id, code };
|
|
47
|
-
return client.post(path, data);
|
|
48
|
-
}
|
|
49
|
-
exports.accessToken = accessToken;
|
|
50
|
-
/**
|
|
51
|
-
* Revoke an access token
|
|
52
|
-
* @param client The Webflow client
|
|
53
|
-
* @param params The params for the request
|
|
54
|
-
* @param params.client_id The OAuth client ID
|
|
55
|
-
* @param params.client_secret The OAuth client secret
|
|
56
|
-
* @param params.access_token The OAuth access token
|
|
57
|
-
* @returns The result of the revoke
|
|
58
|
-
*/
|
|
59
|
-
function revokeToken(client, { client_secret, access_token, client_id }) {
|
|
60
|
-
(0, core_1.requireArgs)({ client_id, client_secret, access_token });
|
|
61
|
-
const path = "/oauth/revoke_authorization";
|
|
62
|
-
const data = { client_secret, access_token, client_id };
|
|
63
|
-
return client.post(path, data);
|
|
64
|
-
}
|
|
65
|
-
exports.revokeToken = revokeToken;
|
|
65
|
+
exports.OAuth = OAuth;
|