@whop/sdk 0.0.37 → 0.0.38
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 +19 -0
- package/client.d.mts +16 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +16 -3
- package/client.d.ts.map +1 -1
- package/client.js +7 -1
- package/client.js.map +1 -1
- package/client.mjs +7 -1
- package/client.mjs.map +1 -1
- package/lib/verify-user-token.d.mts +1 -0
- package/lib/verify-user-token.d.mts.map +1 -1
- package/lib/verify-user-token.d.ts +1 -0
- package/lib/verify-user-token.d.ts.map +1 -1
- package/lib/verify-user-token.js +39 -13
- package/lib/verify-user-token.js.map +1 -1
- package/lib/verify-user-token.mjs +40 -14
- package/lib/verify-user-token.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/checkout-configurations.d.mts +20 -0
- package/resources/checkout-configurations.d.mts.map +1 -1
- package/resources/checkout-configurations.d.ts +20 -0
- package/resources/checkout-configurations.d.ts.map +1 -1
- package/resources/forums.d.mts +5 -0
- package/resources/forums.d.mts.map +1 -1
- package/resources/forums.d.ts +5 -0
- package/resources/forums.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/invoices.d.mts +23 -7
- package/resources/invoices.d.mts.map +1 -1
- package/resources/invoices.d.ts +23 -7
- package/resources/invoices.d.ts.map +1 -1
- package/resources/payments.d.mts +5 -1
- package/resources/payments.d.mts.map +1 -1
- package/resources/payments.d.ts +5 -1
- package/resources/payments.d.ts.map +1 -1
- package/resources/plans.d.mts +1 -1
- package/resources/plans.d.ts +1 -1
- package/resources/shared.d.mts +10 -1
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +10 -1
- package/resources/shared.d.ts.map +1 -1
- package/resources/users.d.mts +77 -34
- package/resources/users.d.mts.map +1 -1
- package/resources/users.d.ts +77 -34
- package/resources/users.d.ts.map +1 -1
- package/resources/users.js +42 -12
- package/resources/users.js.map +1 -1
- package/resources/users.mjs +42 -12
- package/resources/users.mjs.map +1 -1
- package/resources/verifications.d.mts +1 -1
- package/resources/verifications.d.mts.map +1 -1
- package/resources/verifications.d.ts +1 -1
- package/resources/verifications.d.ts.map +1 -1
- package/src/client.ts +27 -2
- package/src/lib/verify-user-token.ts +49 -16
- package/src/resources/checkout-configurations.ts +24 -0
- package/src/resources/forums.ts +6 -0
- package/src/resources/index.ts +2 -1
- package/src/resources/invoices.ts +26 -7
- package/src/resources/payments.ts +9 -0
- package/src/resources/plans.ts +1 -1
- package/src/resources/shared.ts +12 -1
- package/src/resources/users.ts +95 -44
- package/src/resources/verifications.ts +2 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/users.d.ts
CHANGED
|
@@ -9,26 +9,56 @@ import { RequestOptions } from "../internal/request-options.js";
|
|
|
9
9
|
export declare class Users extends APIResource {
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the details of an existing user.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const user = await client.users.retrieve(
|
|
16
|
+
* 'user_xxxxxxxxxxxxx',
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
retrieve(id: string, query?: UserRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<User>;
|
|
21
|
+
/**
|
|
22
|
+
* Update a user's profile by their ID.
|
|
23
|
+
*
|
|
24
|
+
* Required permissions:
|
|
25
|
+
*
|
|
26
|
+
* - `user:profile:update`
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const user = await client.users.update(
|
|
31
|
+
* 'user_xxxxxxxxxxxxx',
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
12
34
|
*/
|
|
13
|
-
|
|
35
|
+
update(id: string, body?: UserUpdateParams | null | undefined, options?: RequestOptions): APIPromise<User>;
|
|
14
36
|
/**
|
|
15
37
|
* Search for users by name or username, ranked by social proximity to the
|
|
16
38
|
* authenticated user.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // Automatically fetches more pages as needed.
|
|
43
|
+
* for await (const userListResponse of client.users.list()) {
|
|
44
|
+
* // ...
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
17
47
|
*/
|
|
18
48
|
list(query?: UserListParams | null | undefined, options?: RequestOptions): PagePromise<UserListResponsesCursorPage, UserListResponse>;
|
|
19
49
|
/**
|
|
20
50
|
* Check whether a user has access to a specific resource, and return their access
|
|
21
51
|
* level.
|
|
22
|
-
*/
|
|
23
|
-
checkAccess(resourceID: string, params: UserCheckAccessParams, options?: RequestOptions): APIPromise<UserCheckAccessResponse>;
|
|
24
|
-
/**
|
|
25
|
-
* Update the currently authenticated user's profile.
|
|
26
52
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const response = await client.users.checkAccess(
|
|
56
|
+
* 'resource_id',
|
|
57
|
+
* { id: 'user_xxxxxxxxxxxxx' },
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
30
60
|
*/
|
|
31
|
-
|
|
61
|
+
checkAccess(resourceID: string, params: UserCheckAccessParams, options?: RequestOptions): APIPromise<UserCheckAccessResponse>;
|
|
32
62
|
}
|
|
33
63
|
export type UserListResponsesCursorPage = CursorPage<UserListResponse>;
|
|
34
64
|
/**
|
|
@@ -132,35 +162,24 @@ export interface UserCheckAccessResponse {
|
|
|
132
162
|
*/
|
|
133
163
|
has_access: boolean;
|
|
134
164
|
}
|
|
135
|
-
export interface
|
|
136
|
-
/**
|
|
137
|
-
* Returns the elements in the list that come before the specified cursor.
|
|
138
|
-
*/
|
|
139
|
-
before?: string | null;
|
|
140
|
-
/**
|
|
141
|
-
* Returns the first _n_ elements from the list.
|
|
142
|
-
*/
|
|
143
|
-
first?: number | null;
|
|
144
|
-
/**
|
|
145
|
-
* Returns the last _n_ elements from the list.
|
|
146
|
-
*/
|
|
147
|
-
last?: number | null;
|
|
165
|
+
export interface UserRetrieveParams {
|
|
148
166
|
/**
|
|
149
|
-
*
|
|
167
|
+
* When provided, returns the user's company-specific profile overrides (name,
|
|
168
|
+
* profile picture) instead of their global profile.
|
|
150
169
|
*/
|
|
151
|
-
|
|
170
|
+
company_id?: string | null;
|
|
152
171
|
}
|
|
153
|
-
export interface
|
|
154
|
-
/**
|
|
155
|
-
* The unique identifier or username of the user.
|
|
156
|
-
*/
|
|
157
|
-
id: string;
|
|
158
|
-
}
|
|
159
|
-
export interface UserUpdateProfileParams {
|
|
172
|
+
export interface UserUpdateParams {
|
|
160
173
|
/**
|
|
161
174
|
* A short biography displayed on the user's public profile.
|
|
162
175
|
*/
|
|
163
176
|
bio?: string | null;
|
|
177
|
+
/**
|
|
178
|
+
* When provided, updates the user's profile overrides for this company instead of
|
|
179
|
+
* the global profile. Pass name and profile_picture to set overrides, or null to
|
|
180
|
+
* clear them.
|
|
181
|
+
*/
|
|
182
|
+
company_id?: string | null;
|
|
164
183
|
/**
|
|
165
184
|
* The user's display name shown on their public profile. Maximum 100 characters.
|
|
166
185
|
*/
|
|
@@ -168,14 +187,14 @@ export interface UserUpdateProfileParams {
|
|
|
168
187
|
/**
|
|
169
188
|
* The user's profile picture image attachment.
|
|
170
189
|
*/
|
|
171
|
-
profile_picture?:
|
|
190
|
+
profile_picture?: UserUpdateParams.ProfilePicture | null;
|
|
172
191
|
/**
|
|
173
192
|
* The user's unique username. Alphanumeric characters and hyphens only. Maximum 42
|
|
174
193
|
* characters.
|
|
175
194
|
*/
|
|
176
195
|
username?: string | null;
|
|
177
196
|
}
|
|
178
|
-
export declare namespace
|
|
197
|
+
export declare namespace UserUpdateParams {
|
|
179
198
|
/**
|
|
180
199
|
* The user's profile picture image attachment.
|
|
181
200
|
*/
|
|
@@ -186,7 +205,31 @@ export declare namespace UserUpdateProfileParams {
|
|
|
186
205
|
id: string;
|
|
187
206
|
}
|
|
188
207
|
}
|
|
208
|
+
export interface UserListParams extends CursorPageParams {
|
|
209
|
+
/**
|
|
210
|
+
* Returns the elements in the list that come before the specified cursor.
|
|
211
|
+
*/
|
|
212
|
+
before?: string | null;
|
|
213
|
+
/**
|
|
214
|
+
* Returns the first _n_ elements from the list.
|
|
215
|
+
*/
|
|
216
|
+
first?: number | null;
|
|
217
|
+
/**
|
|
218
|
+
* Returns the last _n_ elements from the list.
|
|
219
|
+
*/
|
|
220
|
+
last?: number | null;
|
|
221
|
+
/**
|
|
222
|
+
* Search term to filter by name or username.
|
|
223
|
+
*/
|
|
224
|
+
query?: string | null;
|
|
225
|
+
}
|
|
226
|
+
export interface UserCheckAccessParams {
|
|
227
|
+
/**
|
|
228
|
+
* The unique identifier or username of the user.
|
|
229
|
+
*/
|
|
230
|
+
id: string;
|
|
231
|
+
}
|
|
189
232
|
export declare namespace Users {
|
|
190
|
-
export { type User as User, type UserListResponse as UserListResponse, type UserCheckAccessResponse as UserCheckAccessResponse, type UserListResponsesCursorPage as UserListResponsesCursorPage, type
|
|
233
|
+
export { type User as User, type UserListResponse as UserListResponse, type UserCheckAccessResponse as UserCheckAccessResponse, type UserListResponsesCursorPage as UserListResponsesCursorPage, type UserRetrieveParams as UserRetrieveParams, type UserUpdateParams as UserUpdateParams, type UserListParams as UserListParams, type UserCheckAccessParams as UserCheckAccessParams, };
|
|
191
234
|
}
|
|
192
235
|
//# sourceMappingURL=users.d.ts.map
|
package/resources/users.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/resources/users.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,MAAM;OACX,EAAE,UAAU,EAAE;O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;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC;IAEzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,yBAAiB,gBAAgB,CAAC;IAChC;;OAEG;IACH,UAAiB,cAAc;QAC7B;;WAEG;QACH,EAAE,EAAE,MAAM,CAAC;KACZ;CACF;AAED,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,OAAO,EACL,KAAK,IAAI,IAAI,IAAI,EACjB,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
|
package/resources/users.js
CHANGED
|
@@ -11,13 +11,45 @@ const path_1 = require("../internal/utils/path.js");
|
|
|
11
11
|
class Users extends resource_1.APIResource {
|
|
12
12
|
/**
|
|
13
13
|
* Retrieves the details of an existing user.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const user = await client.users.retrieve(
|
|
18
|
+
* 'user_xxxxxxxxxxxxx',
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
retrieve(id, query = {}, options) {
|
|
23
|
+
return this._client.get((0, path_1.path) `/users/${id}`, { query, ...options });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Update a user's profile by their ID.
|
|
27
|
+
*
|
|
28
|
+
* Required permissions:
|
|
29
|
+
*
|
|
30
|
+
* - `user:profile:update`
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const user = await client.users.update(
|
|
35
|
+
* 'user_xxxxxxxxxxxxx',
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
14
38
|
*/
|
|
15
|
-
|
|
16
|
-
return this._client.
|
|
39
|
+
update(id, body = {}, options) {
|
|
40
|
+
return this._client.patch((0, path_1.path) `/users/${id}`, { body, ...options });
|
|
17
41
|
}
|
|
18
42
|
/**
|
|
19
43
|
* Search for users by name or username, ranked by social proximity to the
|
|
20
44
|
* authenticated user.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Automatically fetches more pages as needed.
|
|
49
|
+
* for await (const userListResponse of client.users.list()) {
|
|
50
|
+
* // ...
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
21
53
|
*/
|
|
22
54
|
list(query = {}, options) {
|
|
23
55
|
return this._client.getAPIList('/users', (pagination_1.CursorPage), { query, ...options });
|
|
@@ -25,21 +57,19 @@ class Users extends resource_1.APIResource {
|
|
|
25
57
|
/**
|
|
26
58
|
* Check whether a user has access to a specific resource, and return their access
|
|
27
59
|
* level.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const response = await client.users.checkAccess(
|
|
64
|
+
* 'resource_id',
|
|
65
|
+
* { id: 'user_xxxxxxxxxxxxx' },
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
28
68
|
*/
|
|
29
69
|
checkAccess(resourceID, params, options) {
|
|
30
70
|
const { id } = params;
|
|
31
71
|
return this._client.get((0, path_1.path) `/users/${id}/access/${resourceID}`, options);
|
|
32
72
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Update the currently authenticated user's profile.
|
|
35
|
-
*
|
|
36
|
-
* Required permissions:
|
|
37
|
-
*
|
|
38
|
-
* - `user:profile:update`
|
|
39
|
-
*/
|
|
40
|
-
updateProfile(body = {}, options) {
|
|
41
|
-
return this._client.patch('/users/me', { body, ...options });
|
|
42
|
-
}
|
|
43
73
|
}
|
|
44
74
|
exports.Users = Users;
|
|
45
75
|
//# sourceMappingURL=users.js.map
|
package/resources/users.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.js","sourceRoot":"","sources":["../src/resources/users.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,sDAAoF;AAEpF,oDAA8C;AAE9C;;GAEG;AACH,MAAa,KAAM,SAAQ,sBAAW;IACpC
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../src/resources/users.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,sDAAoF;AAEpF,oDAA8C;AAE9C;;GAEG;AACH,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CACN,EAAU,EACV,QAA+C,EAAE,EACjD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CACJ,EAAU,EACV,OAA4C,EAAE,EAC9C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAI,EAAA,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,CACF,QAA2C,EAAE,EAC7C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAA,uBAA4B,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,CACT,UAAkB,EAClB,MAA6B,EAC7B,OAAwB;QAExB,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,UAAU,EAAE,WAAW,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF;AAhFD,sBAgFC"}
|
package/resources/users.mjs
CHANGED
|
@@ -8,13 +8,45 @@ import { path } from "../internal/utils/path.mjs";
|
|
|
8
8
|
export class Users extends APIResource {
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves the details of an existing user.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const user = await client.users.retrieve(
|
|
15
|
+
* 'user_xxxxxxxxxxxxx',
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
retrieve(id, query = {}, options) {
|
|
20
|
+
return this._client.get(path `/users/${id}`, { query, ...options });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Update a user's profile by their ID.
|
|
24
|
+
*
|
|
25
|
+
* Required permissions:
|
|
26
|
+
*
|
|
27
|
+
* - `user:profile:update`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const user = await client.users.update(
|
|
32
|
+
* 'user_xxxxxxxxxxxxx',
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
11
35
|
*/
|
|
12
|
-
|
|
13
|
-
return this._client.
|
|
36
|
+
update(id, body = {}, options) {
|
|
37
|
+
return this._client.patch(path `/users/${id}`, { body, ...options });
|
|
14
38
|
}
|
|
15
39
|
/**
|
|
16
40
|
* Search for users by name or username, ranked by social proximity to the
|
|
17
41
|
* authenticated user.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Automatically fetches more pages as needed.
|
|
46
|
+
* for await (const userListResponse of client.users.list()) {
|
|
47
|
+
* // ...
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
18
50
|
*/
|
|
19
51
|
list(query = {}, options) {
|
|
20
52
|
return this._client.getAPIList('/users', (CursorPage), { query, ...options });
|
|
@@ -22,20 +54,18 @@ export class Users extends APIResource {
|
|
|
22
54
|
/**
|
|
23
55
|
* Check whether a user has access to a specific resource, and return their access
|
|
24
56
|
* level.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const response = await client.users.checkAccess(
|
|
61
|
+
* 'resource_id',
|
|
62
|
+
* { id: 'user_xxxxxxxxxxxxx' },
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
25
65
|
*/
|
|
26
66
|
checkAccess(resourceID, params, options) {
|
|
27
67
|
const { id } = params;
|
|
28
68
|
return this._client.get(path `/users/${id}/access/${resourceID}`, options);
|
|
29
69
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Update the currently authenticated user's profile.
|
|
32
|
-
*
|
|
33
|
-
* Required permissions:
|
|
34
|
-
*
|
|
35
|
-
* - `user:profile:update`
|
|
36
|
-
*/
|
|
37
|
-
updateProfile(body = {}, options) {
|
|
38
|
-
return this._client.patch('/users/me', { body, ...options });
|
|
39
|
-
}
|
|
40
70
|
}
|
|
41
71
|
//# sourceMappingURL=users.mjs.map
|
package/resources/users.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.mjs","sourceRoot":"","sources":["../src/resources/users.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,UAAU,EAAsC;OAElD,EAAE,IAAI,EAAE;AAEf;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC
|
|
1
|
+
{"version":3,"file":"users.mjs","sourceRoot":"","sources":["../src/resources/users.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,UAAU,EAAsC;OAElD,EAAE,IAAI,EAAE;AAEf;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CACN,EAAU,EACV,QAA+C,EAAE,EACjD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CACJ,EAAU,EACV,OAA4C,EAAE,EAC9C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,CACF,QAA2C,EAAE,EAC7C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAA,UAA4B,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,CACT,UAAkB,EAClB,MAA6B,EAC7B,OAAwB;QAExB,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,UAAU,EAAE,WAAW,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF"}
|
|
@@ -32,7 +32,7 @@ export type VerificationErrorCode = 'abandoned' | 'consent_declined' | 'country_
|
|
|
32
32
|
/**
|
|
33
33
|
* A status for a verification.
|
|
34
34
|
*/
|
|
35
|
-
export type VerificationStatus = 'requires_input' | 'processing' | 'verified' | 'canceled' | 'created' | 'started' | 'submitted' | 'approved' | 'declined' | 'resubmission_requested' | 'expired' | 'abandoned' | 'review';
|
|
35
|
+
export type VerificationStatus = 'requires_input' | 'processing' | 'verified' | 'canceled' | 'created' | 'started' | 'submitted' | 'approved' | 'declined' | 'resubmission_requested' | 'expired' | 'abandoned' | 'review' | 'action_required';
|
|
36
36
|
/**
|
|
37
37
|
* An identity verification session used to confirm a person or entity's identity
|
|
38
38
|
* for payout account eligibility.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifications.d.mts","sourceRoot":"","sources":["../src/resources/verifications.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE;OAClD,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC;IAIxF;;;;;;;OAOG;IACH,IAAI,CACF,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,mCAAmC,EAAE,wBAAwB,CAAC;CAM9E;AAED,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,6BAA6B,GAC7B,2BAA2B,GAC3B,wBAAwB,GACxB,6BAA6B,GAC7B,sCAAsC,GACtC,oBAAoB,GACpB,4BAA4B,GAC5B,wBAAwB,GACxB,6BAA6B,GAC7B,+BAA+B,GAC/B,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,YAAY,GACZ,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,WAAW,GACX,UAAU,GACV,UAAU,GACV,wBAAwB,GACxB,SAAS,GACT,WAAW,GACX,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"verifications.d.mts","sourceRoot":"","sources":["../src/resources/verifications.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE;OAClD,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC;IAIxF;;;;;;;OAOG;IACH,IAAI,CACF,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,mCAAmC,EAAE,wBAAwB,CAAC;CAM9E;AAED,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,6BAA6B,GAC7B,2BAA2B,GAC3B,wBAAwB,GACxB,6BAA6B,GAC7B,sCAAsC,GACtC,oBAAoB,GACpB,4BAA4B,GAC5B,wBAAwB,GACxB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AA4B,EACjE,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,mCAAmC,IAAI,mCAAmC,EAC/E,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
|
@@ -32,7 +32,7 @@ export type VerificationErrorCode = 'abandoned' | 'consent_declined' | 'country_
|
|
|
32
32
|
/**
|
|
33
33
|
* A status for a verification.
|
|
34
34
|
*/
|
|
35
|
-
export type VerificationStatus = 'requires_input' | 'processing' | 'verified' | 'canceled' | 'created' | 'started' | 'submitted' | 'approved' | 'declined' | 'resubmission_requested' | 'expired' | 'abandoned' | 'review';
|
|
35
|
+
export type VerificationStatus = 'requires_input' | 'processing' | 'verified' | 'canceled' | 'created' | 'started' | 'submitted' | 'approved' | 'declined' | 'resubmission_requested' | 'expired' | 'abandoned' | 'review' | 'action_required';
|
|
36
36
|
/**
|
|
37
37
|
* An identity verification session used to confirm a person or entity's identity
|
|
38
38
|
* for payout account eligibility.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifications.d.ts","sourceRoot":"","sources":["../src/resources/verifications.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE;OAClD,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC;IAIxF;;;;;;;OAOG;IACH,IAAI,CACF,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,mCAAmC,EAAE,wBAAwB,CAAC;CAM9E;AAED,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,6BAA6B,GAC7B,2BAA2B,GAC3B,wBAAwB,GACxB,6BAA6B,GAC7B,sCAAsC,GACtC,oBAAoB,GACpB,4BAA4B,GAC5B,wBAAwB,GACxB,6BAA6B,GAC7B,+BAA+B,GAC/B,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,YAAY,GACZ,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,WAAW,GACX,UAAU,GACV,UAAU,GACV,wBAAwB,GACxB,SAAS,GACT,WAAW,GACX,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"verifications.d.ts","sourceRoot":"","sources":["../src/resources/verifications.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE;OAClD,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC;IAIxF;;;;;;;OAOG;IACH,IAAI,CACF,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,mCAAmC,EAAE,wBAAwB,CAAC;CAM9E;AAED,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,GAClB,6BAA6B,GAC7B,2BAA2B,GAC3B,wBAAwB,GACxB,6BAA6B,G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ACnD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,mCAAmC,IAAI,mCAAmC,EAC/E,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
package/src/client.ts
CHANGED
|
@@ -428,7 +428,8 @@ import {
|
|
|
428
428
|
UserListParams,
|
|
429
429
|
UserListResponse,
|
|
430
430
|
UserListResponsesCursorPage,
|
|
431
|
-
|
|
431
|
+
UserRetrieveParams,
|
|
432
|
+
UserUpdateParams,
|
|
432
433
|
Users,
|
|
433
434
|
} from './resources/users';
|
|
434
435
|
import {
|
|
@@ -539,6 +540,19 @@ export interface ClientOptions {
|
|
|
539
540
|
*/
|
|
540
541
|
appID?: string | null | undefined;
|
|
541
542
|
|
|
543
|
+
/**
|
|
544
|
+
* Static JWK (JSON string) used by `verifyUserToken` to verify user tokens.
|
|
545
|
+
* When set, the SDK skips remote JWKS fetching. Prefer `userTokenJwksUrl`
|
|
546
|
+
* (or the default) so key rotation is handled automatically.
|
|
547
|
+
*/
|
|
548
|
+
userTokenPublicKey?: string | null | undefined;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* URL of the JWKS endpoint used by `verifyUserToken`. Defaults to the
|
|
552
|
+
* canonical Whop JWKS. Override when pointing at a non-production backend.
|
|
553
|
+
*/
|
|
554
|
+
userTokenJwksUrl?: string | null | undefined;
|
|
555
|
+
|
|
542
556
|
/**
|
|
543
557
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
544
558
|
*
|
|
@@ -615,6 +629,8 @@ export class Whop {
|
|
|
615
629
|
apiKey: string;
|
|
616
630
|
webhookKey: string | null;
|
|
617
631
|
appID: string | null;
|
|
632
|
+
userTokenPublicKey: string | null;
|
|
633
|
+
userTokenJwksUrl: string | null;
|
|
618
634
|
baseURL: string;
|
|
619
635
|
maxRetries: number;
|
|
620
636
|
timeout: number;
|
|
@@ -646,6 +662,8 @@ export class Whop {
|
|
|
646
662
|
apiKey = readEnv('WHOP_API_KEY'),
|
|
647
663
|
webhookKey = readEnv('WHOP_WEBHOOK_SECRET') ?? null,
|
|
648
664
|
appID = readEnv('WHOP_APP_ID') ?? null,
|
|
665
|
+
userTokenPublicKey = readEnv('WHOP_USER_TOKEN_PUBLIC_KEY') ?? null,
|
|
666
|
+
userTokenJwksUrl = readEnv('WHOP_USER_TOKEN_JWKS_URL') ?? null,
|
|
649
667
|
...opts
|
|
650
668
|
}: ClientOptions = {}) {
|
|
651
669
|
if (apiKey === undefined) {
|
|
@@ -658,6 +676,8 @@ export class Whop {
|
|
|
658
676
|
apiKey,
|
|
659
677
|
webhookKey,
|
|
660
678
|
appID,
|
|
679
|
+
userTokenPublicKey,
|
|
680
|
+
userTokenJwksUrl,
|
|
661
681
|
...opts,
|
|
662
682
|
baseURL: baseURL || `https://api.whop.com/api/v1`,
|
|
663
683
|
};
|
|
@@ -682,6 +702,8 @@ export class Whop {
|
|
|
682
702
|
this.apiKey = apiKey;
|
|
683
703
|
this.webhookKey = webhookKey;
|
|
684
704
|
this.appID = appID;
|
|
705
|
+
this.userTokenPublicKey = userTokenPublicKey;
|
|
706
|
+
this.userTokenJwksUrl = userTokenJwksUrl;
|
|
685
707
|
}
|
|
686
708
|
|
|
687
709
|
/**
|
|
@@ -700,6 +722,8 @@ export class Whop {
|
|
|
700
722
|
apiKey: this.apiKey,
|
|
701
723
|
webhookKey: this.webhookKey,
|
|
702
724
|
appID: this.appID,
|
|
725
|
+
userTokenPublicKey: this.userTokenPublicKey,
|
|
726
|
+
userTokenJwksUrl: this.userTokenJwksUrl,
|
|
703
727
|
...options,
|
|
704
728
|
});
|
|
705
729
|
return client;
|
|
@@ -1737,9 +1761,10 @@ export declare namespace Whop {
|
|
|
1737
1761
|
type UserListResponse as UserListResponse,
|
|
1738
1762
|
type UserCheckAccessResponse as UserCheckAccessResponse,
|
|
1739
1763
|
type UserListResponsesCursorPage as UserListResponsesCursorPage,
|
|
1764
|
+
type UserRetrieveParams as UserRetrieveParams,
|
|
1765
|
+
type UserUpdateParams as UserUpdateParams,
|
|
1740
1766
|
type UserListParams as UserListParams,
|
|
1741
1767
|
type UserCheckAccessParams as UserCheckAccessParams,
|
|
1742
|
-
type UserUpdateProfileParams as UserUpdateProfileParams,
|
|
1743
1768
|
};
|
|
1744
1769
|
|
|
1745
1770
|
export {
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import { importJWK, jwtVerify } from 'jose';
|
|
1
|
+
import { createRemoteJWKSet, importJWK, jwtVerify } from 'jose';
|
|
2
2
|
import type { Whop } from '../client';
|
|
3
3
|
|
|
4
4
|
const USER_TOKEN_HEADER_NAME = 'x-whop-user-token';
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const DEFAULT_JWKS_URL = 'https://api.whop.com/.well-known/jwks.json';
|
|
6
|
+
|
|
7
|
+
// Module-level cache: one RemoteJWKSet per URL. jose's remote set handles
|
|
8
|
+
// HTTP caching (respecting the endpoint's Cache-Control), a cooldown to
|
|
9
|
+
// prevent tight-loop refetches on unknown kids, and thread-safe in-flight
|
|
10
|
+
// deduplication. Reusing the same instance across calls is what makes the
|
|
11
|
+
// verify path effectively free after the first lookup.
|
|
12
|
+
const jwksCache = new Map<string, ReturnType<typeof createRemoteJWKSet>>();
|
|
13
|
+
|
|
14
|
+
function getRemoteJwks(url: string): ReturnType<typeof createRemoteJWKSet> {
|
|
15
|
+
let existing = jwksCache.get(url);
|
|
16
|
+
if (existing) return existing;
|
|
17
|
+
existing = createRemoteJWKSet(new URL(url), {
|
|
18
|
+
cacheMaxAge: 12 * 60 * 60 * 1000,
|
|
19
|
+
cooldownDuration: 30_000,
|
|
20
|
+
});
|
|
21
|
+
jwksCache.set(url, existing);
|
|
22
|
+
return existing;
|
|
23
|
+
}
|
|
7
24
|
|
|
8
25
|
export interface GetUserTokenOptions {
|
|
9
26
|
headerName?: string | null | undefined;
|
|
@@ -43,9 +60,17 @@ export interface VerifyUserTokenOptions<DontThrow extends boolean = false> {
|
|
|
43
60
|
/// This is the app id of your app. You can find it in the app settings dashboard.
|
|
44
61
|
appId: string;
|
|
45
62
|
|
|
46
|
-
///
|
|
63
|
+
/// Static JWK (JSON string) used to verify the user token. When set, the
|
|
64
|
+
/// SDK skips the remote JWKS fetch entirely — useful for self-hosted or
|
|
65
|
+
/// test setups where you know the signing key. Prefer leaving this unset
|
|
66
|
+
/// and using `jwksUrl` instead so key rotation is handled automatically.
|
|
47
67
|
publicKey?: string;
|
|
48
68
|
|
|
69
|
+
/// URL of a JWKS endpoint to verify the user token against. Defaults to
|
|
70
|
+
/// Whop's canonical JWKS. Override this when pointing at a local Whop
|
|
71
|
+
/// backend (for example during local development).
|
|
72
|
+
jwksUrl?: string;
|
|
73
|
+
|
|
49
74
|
/// If true, the function will instead return null if the user token is invalid.
|
|
50
75
|
/// Otherwise, it will throw an error. Defaults to `false`, meaning on validation failure, an error will be thrown.
|
|
51
76
|
dontThrow?: DontThrow;
|
|
@@ -62,9 +87,9 @@ export function makeUserTokenVerifierFromSdk(client: Whop) {
|
|
|
62
87
|
if (!client.appID) {
|
|
63
88
|
throw Error('You must set appID in the Whop client constructor if you want to verify user tokens.');
|
|
64
89
|
}
|
|
65
|
-
const baseOptions: VerifyUserTokenOptions<false> = {
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
const baseOptions: VerifyUserTokenOptions<false> = { appId: client.appID };
|
|
91
|
+
if (client.userTokenPublicKey) baseOptions.publicKey = client.userTokenPublicKey;
|
|
92
|
+
if (client.userTokenJwksUrl) baseOptions.jwksUrl = client.userTokenJwksUrl;
|
|
68
93
|
return await internalVerifyUserToken<DT>(tokenOrHeadersOrRequest, {
|
|
69
94
|
...baseOptions,
|
|
70
95
|
...options,
|
|
@@ -96,15 +121,23 @@ async function internalVerifyUserToken<DontThrow extends boolean = false>(
|
|
|
96
121
|
);
|
|
97
122
|
}
|
|
98
123
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
const verifyOptions = { issuer: 'urn:whopcom:exp-proxy', algorithms: ['ES256'] };
|
|
125
|
+
|
|
126
|
+
let token;
|
|
127
|
+
if (options.publicKey) {
|
|
128
|
+
const key = await importJWK(JSON.parse(options.publicKey), 'ES256').catch(() => {
|
|
129
|
+
throw new Error('Invalid public key provided to verifyUserToken');
|
|
130
|
+
});
|
|
131
|
+
token = await jwtVerify(tokenString, key, verifyOptions).catch(() => {
|
|
132
|
+
throw new Error('Invalid user token provided to verifyUserToken');
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
const jwks = getRemoteJwks(options.jwksUrl ?? DEFAULT_JWKS_URL);
|
|
136
|
+
token = await jwtVerify(tokenString, jwks, verifyOptions).catch(() => {
|
|
137
|
+
throw new Error('Invalid user token provided to verifyUserToken');
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
108
141
|
if (!(token.payload.sub && token.payload.aud) || Array.isArray(token.payload.aud)) {
|
|
109
142
|
throw new Error('Invalid user token provided to verifyUserToken');
|
|
110
143
|
}
|
|
@@ -93,6 +93,12 @@ export interface CheckoutConfigurationListResponse {
|
|
|
93
93
|
*/
|
|
94
94
|
affiliate_code: string | null;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Whether the checkout configuration allows promo codes. When false, the promo
|
|
98
|
+
* code input is hidden and promo codes are rejected.
|
|
99
|
+
*/
|
|
100
|
+
allow_promo_codes: boolean;
|
|
101
|
+
|
|
96
102
|
/**
|
|
97
103
|
* The ID of the company to use for the checkout configuration
|
|
98
104
|
*/
|
|
@@ -250,6 +256,12 @@ export declare namespace CheckoutConfigurationCreateParams {
|
|
|
250
256
|
*/
|
|
251
257
|
affiliate_code?: string | null;
|
|
252
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Whether the checkout should show the promo code input field and accept promo
|
|
261
|
+
* codes. Defaults to true.
|
|
262
|
+
*/
|
|
263
|
+
allow_promo_codes?: boolean | null;
|
|
264
|
+
|
|
253
265
|
/**
|
|
254
266
|
* Checkout styling overrides for this session. Overrides plan and company
|
|
255
267
|
* defaults.
|
|
@@ -619,6 +631,12 @@ export declare namespace CheckoutConfigurationCreateParams {
|
|
|
619
631
|
*/
|
|
620
632
|
affiliate_code?: string | null;
|
|
621
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Whether the checkout should show the promo code input field and accept promo
|
|
636
|
+
* codes. Defaults to true.
|
|
637
|
+
*/
|
|
638
|
+
allow_promo_codes?: boolean | null;
|
|
639
|
+
|
|
622
640
|
/**
|
|
623
641
|
* Checkout styling overrides for this session. Overrides plan and company
|
|
624
642
|
* defaults.
|
|
@@ -713,6 +731,12 @@ export declare namespace CheckoutConfigurationCreateParams {
|
|
|
713
731
|
|
|
714
732
|
mode: 'setup';
|
|
715
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Whether the checkout should show the promo code input field and accept promo
|
|
736
|
+
* codes. Defaults to true.
|
|
737
|
+
*/
|
|
738
|
+
allow_promo_codes?: boolean | null;
|
|
739
|
+
|
|
716
740
|
/**
|
|
717
741
|
* Checkout styling overrides for this session. Overrides plan and company
|
|
718
742
|
* defaults.
|
package/src/resources/forums.ts
CHANGED
|
@@ -109,6 +109,12 @@ export namespace ForumListResponse {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export interface ForumUpdateParams {
|
|
112
|
+
/**
|
|
113
|
+
* A list of words that are automatically blocked from posts in this forum. For
|
|
114
|
+
* example, ['spam', 'scam'].
|
|
115
|
+
*/
|
|
116
|
+
banned_words?: Array<string> | null;
|
|
117
|
+
|
|
112
118
|
/**
|
|
113
119
|
* The banner image displayed at the top of the forum page. Pass null to remove the
|
|
114
120
|
* existing banner.
|
package/src/resources/index.ts
CHANGED
|
@@ -419,9 +419,10 @@ export {
|
|
|
419
419
|
type User,
|
|
420
420
|
type UserListResponse,
|
|
421
421
|
type UserCheckAccessResponse,
|
|
422
|
+
type UserRetrieveParams,
|
|
423
|
+
type UserUpdateParams,
|
|
422
424
|
type UserListParams,
|
|
423
425
|
type UserCheckAccessParams,
|
|
424
|
-
type UserUpdateProfileParams,
|
|
425
426
|
type UserListResponsesCursorPage,
|
|
426
427
|
} from './users';
|
|
427
428
|
export {
|