@descope/node-sdk 1.0.4-alpha.9 → 1.0.5

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/dist/index.d.ts CHANGED
@@ -3,22 +3,59 @@ import _descope_core_js_sdk__default, { SdkResponse, ExchangeAccessKeyResponse }
3
3
  export { DeliveryMethod, OAuthProvider } from '@descope/core-js-sdk';
4
4
  import { JWTHeaderParameters, KeyLike } from 'jose';
5
5
 
6
- /** Represents a tenant association for a User. The tenantId is required to denote
7
- * which tenant the user belongs to. The roleNames array is an optional list of
8
- * roles for the user in this specific tenant.
6
+ /** Represents a tenant association for a User or Access Key. The tenantId is required to denote
7
+ * which tenant the user or access key belongs to. The roleNames array is an optional list of
8
+ * roles for the user or access key in this specific tenant.
9
9
  */
10
- declare type UserTenant = {
10
+ declare type AssociatedTenant = {
11
11
  tenantId: string;
12
12
  roleNames: string[];
13
13
  };
14
14
  /** The tenantId of a newly created tenant */
15
15
  declare type CreateTenantResponse = {
16
- tenantId: string;
16
+ id: string;
17
+ };
18
+ /** An access key that can be used to access descope */
19
+ declare type AccessKey = {
20
+ id: string;
21
+ name: string;
22
+ expiredTime: number;
23
+ roleNames: string[];
24
+ keyTenants?: AssociatedTenant[];
25
+ status: string;
26
+ createdTime: number;
27
+ expiresTime: number;
28
+ createdBy: string;
29
+ };
30
+ /** Access Key extended details including created key cleartext */
31
+ declare type CreatedAccessKeyResponse = {
32
+ key: AccessKey;
33
+ cleartext: string;
34
+ };
35
+ /** Represents a mapping between a set of groups of users and a role that will be assigned to them */
36
+ declare type RoleMapping = {
37
+ groups: string[];
38
+ role: string;
39
+ };
40
+ /** Represents a mapping between Descope and IDP user attributes */
41
+ declare type AttributeMapping = {
42
+ name?: string;
43
+ email?: string;
44
+ phoneNumber?: string;
45
+ group?: string;
17
46
  };
18
47
  /** UpdateJWT response with a new JWT value with the added custom claims */
19
48
  declare type UpdateJWTResponse = {
20
49
  jwt: string;
21
50
  };
51
+ /** Represents a tenant in a project. It has an id, a name and an array of
52
+ * self provisioning domains used to associate users with that tenant.
53
+ */
54
+ declare type Tenant = {
55
+ id: string;
56
+ name: string;
57
+ selfProvisioningDomains: string[];
58
+ };
22
59
  /** Represents a permission in a project. It has a name and optionally a description.
23
60
  * It also has a flag indicating whether it is system default or not.
24
61
  */
@@ -35,6 +72,18 @@ declare type Role = {
35
72
  description?: string;
36
73
  permissionNames: string[];
37
74
  };
75
+ /** Represents a group in a project. It has an id and display name and a list of group members. */
76
+ declare type Group = {
77
+ id: string;
78
+ display: string;
79
+ members?: GroupMember[];
80
+ };
81
+ /** Represents a group member. It has loginId, userId and display. */
82
+ declare type GroupMember = {
83
+ loginId: string;
84
+ userId: string;
85
+ display: string;
86
+ };
38
87
 
39
88
  /** Parsed JWT token */
40
89
  interface Token {
@@ -50,376 +99,403 @@ interface AuthenticationInfo {
50
99
  cookies?: string[];
51
100
  }
52
101
 
53
- /** Refresh JWT cookie name */
54
- declare const refreshTokenCookieName = "DSR";
55
- /** Session JWT cookie name */
56
- declare const sessionTokenCookieName = "DS";
57
-
58
102
  /** Configuration arguments which include the Descope core SDK args and an optional management key */
59
103
  declare type NodeSdkArgs = Parameters<typeof _descope_core_js_sdk__default>[0] & {
60
104
  managementKey?: string;
61
105
  };
62
- /** Descope SDK client with delivery methods enum.
63
- *
64
- * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}
65
- * @example Usage
66
- *
67
- * ```js
68
- * import descopeSdk from '@descope/node-sdk';
69
- *
70
- * const myProjectId = 'xxx';
71
- * const sdk = descopeSdk({ projectId: myProjectId });
72
- *
73
- * const userIdentifier = 'identifier';
74
- * sdk.otp.signIn.email(userIdentifier);
75
- * const jwtResponse = sdk.otp.verify.email(userIdentifier, codeFromEmail);
76
- * ```
77
- */
78
- declare const sdkWithAttributes: ((args: NodeSdkArgs) => {
79
- /**
80
- * Provides various APIs for managing a Descope project programmatically. A management key must
81
- * be provided as an argument when initializing the SDK to use these APIs. Management keys can be
82
- * generated in the Descope console.
83
- */
84
- management: {
85
- user: {
86
- create: (identifier: string, email?: string, phone?: string, displayName?: string, roleNames?: string[], userTenants?: UserTenant[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
87
- update: (identifier: string, email?: string, phone?: string, displayName?: string, roleNames?: string[], userTenants?: UserTenant[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
88
- delete: (identifier: string) => Promise<SdkResponse<never>>;
89
- load: (identifier: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
90
- searchAll: (tenantIds?: string[], roleNames?: string[], limit?: number) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse[]>>;
91
- };
92
- tenant: {
93
- create: (name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<CreateTenantResponse>>;
94
- createWithId: (tenantId: string, name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<never>>;
95
- update: (tenantId: string, name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<never>>;
96
- delete: (tenantId: string) => Promise<SdkResponse<never>>;
97
- };
98
- jwt: {
99
- update: (jwt: string, customClaims?: Record<string, any>) => Promise<SdkResponse<UpdateJWTResponse>>;
100
- };
101
- permission: {
102
- create: (name: string, description?: string) => Promise<SdkResponse<never>>;
103
- update: (name: string, newName: string, description?: string) => Promise<SdkResponse<never>>;
104
- delete: (name: string) => Promise<SdkResponse<never>>;
105
- loadAll: () => Promise<SdkResponse<Permission[]>>;
106
- };
107
- role: {
108
- create: (name: string, description?: string, permissionNames?: string[]) => Promise<SdkResponse<never>>;
109
- update: (name: string, newName: string, description?: string, permissionNames?: string[]) => Promise<SdkResponse<never>>;
110
- delete: (name: string) => Promise<SdkResponse<never>>;
111
- loadAll: () => Promise<SdkResponse<Role[]>>;
112
- };
113
- };
114
- /** Get the key that can validate the given JWT KID in the header. Can retrieve the public key from local cache or from Descope. */
115
- getKey(header: JWTHeaderParameters): Promise<KeyLike | Uint8Array>;
116
- /**
117
- * Validate the given JWT with the right key and make sure the issuer is correct
118
- * @param jwt the JWT string to parse and validate
119
- * @returns AuthenticationInfo with the parsed token and JWT. Will throw an error if validation fails.
120
- */
121
- validateJwt(jwt: string): Promise<AuthenticationInfo>;
122
- /**
123
- * Validate session based on at least one of session and refresh JWTs. You must provide at least one of them.
124
- *
125
- * @param sessionToken session JWT
126
- * @param refreshToken refresh JWT
127
- * @returns AuthenticationInfo promise or throws Error if there is an issue with JWTs
128
- */
129
- validateSession(sessionToken?: string, refreshToken?: string): Promise<AuthenticationInfo>;
130
- /**
131
- * Exchange API key (access key) for a session key
132
- * @param accessKey access key to exchange for a session JWT
133
- * @returns AuthneticationInfo with session JWT data
134
- */
135
- exchangeAccessKey(accessKey: string): Promise<AuthenticationInfo>;
136
- /**
137
- * Make sure that all given permissions exist on the parsed JWT top level claims
138
- * @param authInfo JWT parsed info
139
- * @param permissions list of permissions to make sure they exist on te JWT claims
140
- * @returns true if all permissions exist, false otherwise
141
- */
142
- validatePermissions(authInfo: AuthenticationInfo, permissions: string[]): boolean;
143
- /**
144
- * Make sure that all given permissions exist on the parsed JWT tenant claims
145
- * @param authInfo JWT parsed info
146
- * @param permissions list of permissions to make sure they exist on te JWT claims
147
- * @returns true if all permissions exist, false otherwise
148
- */
149
- validateTenantPermissions(authInfo: AuthenticationInfo, tenant: string, permissions: string[]): boolean;
150
- /**
151
- * Make sure that all given roles exist on the parsed JWT top level claims
152
- * @param authInfo JWT parsed info
153
- * @param roles list of roles to make sure they exist on te JWT claims
154
- * @returns true if all roles exist, false otherwise
155
- */
156
- validateRoles(authInfo: AuthenticationInfo, roles: string[]): boolean;
157
- /**
158
- * Make sure that all given roles exist on the parsed JWT tenant claims
159
- * @param authInfo JWT parsed info
160
- * @param roles list of roles to make sure they exist on te JWT claims
161
- * @returns true if all roles exist, false otherwise
162
- */
163
- validateTenantRoles(authInfo: AuthenticationInfo, tenant: string, roles: string[]): boolean;
164
- accessKey: {
165
- exchange: (accessKey: string) => Promise<SdkResponse<ExchangeAccessKeyResponse>>;
166
- };
167
- otp: {
168
- verify: {
169
- email: (identifier: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
170
- sms: (identifier: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
171
- whatsapp: (identifier: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
172
- };
173
- signIn: {
174
- email: (identifier: string) => Promise<SdkResponse<never>>;
175
- sms: (identifier: string) => Promise<SdkResponse<never>>;
176
- whatsapp: (identifier: string) => Promise<SdkResponse<never>>;
177
- };
178
- signUp: {
179
- email: (identifier: string, user?: {
180
- email?: string;
181
- name?: string;
182
- phone?: string;
183
- }) => Promise<SdkResponse<never>>;
184
- sms: (identifier: string, user?: {
185
- email?: string;
186
- name?: string;
187
- phone?: string;
188
- }) => Promise<SdkResponse<never>>;
189
- whatsapp: (identifier: string, user?: {
190
- email?: string;
191
- name?: string;
192
- phone?: string;
193
- }) => Promise<SdkResponse<never>>;
106
+ declare const nodeSdk: {
107
+ ({ managementKey, ...config }: NodeSdkArgs): {
108
+ management: {
109
+ user: {
110
+ create: (loginId: string, email?: string, phone?: string, displayName?: string, roles?: string[], userTenants?: AssociatedTenant[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
111
+ update: (loginId: string, email?: string, phone?: string, displayName?: string, roles?: string[], userTenants?: AssociatedTenant[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
112
+ delete: (loginId: string) => Promise<SdkResponse<never>>;
113
+ load: (loginId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
114
+ loadByUserId: (userId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
115
+ searchAll: (tenantIds?: string[], roles?: string[], limit?: number) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse[]>>;
116
+ activate: (loginId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
117
+ deactivate: (loginId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
118
+ updateEmail: (loginId: string, email: string, isVerified: boolean) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
119
+ updatePhone: (loginId: string, phone: string, isVerified: boolean) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
120
+ updateDisplayName: (loginId: string, displayName: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
121
+ addRoles: (loginId: string, roles: string[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
122
+ removeRoles: (loginId: string, roles: string[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
123
+ addTenant: (loginId: string, tenantId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
124
+ removeTenant: (loginId: string, tenantId: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
125
+ addTenantRoles: (loginId: string, tenantId: string, roles: string[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
126
+ removeTenantRoles: (loginId: string, tenantId: string, roles: string[]) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
127
+ };
128
+ accessKey: {
129
+ create: (name: string, expireTime: number, roles?: string[], keyTenants?: AssociatedTenant[]) => Promise<SdkResponse<CreatedAccessKeyResponse>>;
130
+ load: (id: string) => Promise<SdkResponse<AccessKey>>;
131
+ searchAll: (tenantIds?: string[]) => Promise<SdkResponse<AccessKey[]>>;
132
+ update: (id: string, name: string) => Promise<SdkResponse<AccessKey>>;
133
+ deactivate: (id: string) => Promise<SdkResponse<never>>;
134
+ activate: (id: string) => Promise<SdkResponse<never>>;
135
+ delete: (id: string) => Promise<SdkResponse<never>>;
136
+ };
137
+ tenant: {
138
+ create: (name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<CreateTenantResponse>>;
139
+ createWithId: (id: string, name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<never>>;
140
+ update: (id: string, name: string, selfProvisioningDomains?: string[]) => Promise<SdkResponse<never>>;
141
+ delete: (id: string) => Promise<SdkResponse<never>>;
142
+ loadAll: () => Promise<SdkResponse<Tenant[]>>;
143
+ };
144
+ sso: {
145
+ configureSettings: (tenantId: string, idpURL: string, idpCert: string, entityId: string, redirectURL?: string, domain?: string) => Promise<SdkResponse<never>>;
146
+ configureMetadata: (tenantId: string, idpMetadataURL: string) => Promise<SdkResponse<never>>;
147
+ configureMapping: (tenantId: string, roleMapping?: RoleMapping, attributeMapping?: AttributeMapping) => Promise<SdkResponse<never>>;
148
+ };
149
+ jwt: {
150
+ update: (jwt: string, customClaims?: Record<string, any>) => Promise<SdkResponse<UpdateJWTResponse>>;
151
+ };
152
+ permission: {
153
+ create: (name: string, description?: string) => Promise<SdkResponse<never>>;
154
+ update: (name: string, newName: string, description?: string) => Promise<SdkResponse<never>>;
155
+ delete: (name: string) => Promise<SdkResponse<never>>;
156
+ loadAll: () => Promise<SdkResponse<Permission[]>>;
157
+ };
158
+ role: {
159
+ create: (name: string, description?: string, permissionNames?: string[]) => Promise<SdkResponse<never>>;
160
+ update: (name: string, newName: string, description?: string, permissionNames?: string[]) => Promise<SdkResponse<never>>;
161
+ delete: (name: string) => Promise<SdkResponse<never>>;
162
+ loadAll: () => Promise<SdkResponse<Role[]>>;
163
+ };
164
+ group: {
165
+ loadAllGroups: (tenantId: string) => Promise<SdkResponse<Group[]>>;
166
+ loadAllGroupsForMember: (tenantId: string, userIds: string[], loginIds: string[]) => Promise<SdkResponse<Group[]>>;
167
+ loadAllGroupMembers: (tenantId: string, groupId: string) => Promise<SdkResponse<Group[]>>;
168
+ };
194
169
  };
195
- signUpOrIn: {
196
- email: (identifier: string) => Promise<SdkResponse<never>>;
197
- sms: (identifier: string) => Promise<SdkResponse<never>>;
198
- whatsapp: (identifier: string) => Promise<SdkResponse<never>>;
170
+ getKey: (header: JWTHeaderParameters) => Promise<KeyLike | Uint8Array>;
171
+ validateJwt: (jwt: string) => Promise<AuthenticationInfo>;
172
+ validateSession: (sessionToken: string) => Promise<AuthenticationInfo>;
173
+ refreshSession: (refreshToken: string) => Promise<AuthenticationInfo>;
174
+ validateAndRefreshSession: (sessionToken?: string, refreshToken?: string) => Promise<AuthenticationInfo>;
175
+ exchangeAccessKey: (accessKey: string) => Promise<AuthenticationInfo>;
176
+ validatePermissions: (authInfo: AuthenticationInfo, permissions: string[]) => boolean;
177
+ validateTenantPermissions: (authInfo: AuthenticationInfo, tenant: string, permissions: string[]) => boolean;
178
+ validateRoles: (authInfo: AuthenticationInfo, roles: string[]) => boolean;
179
+ validateTenantRoles: (authInfo: AuthenticationInfo, tenant: string, roles: string[]) => boolean;
180
+ accessKey: {
181
+ exchange: (accessKey: string) => Promise<SdkResponse<ExchangeAccessKeyResponse>>;
199
182
  };
200
- update: {
201
- email: (identifier: string, email: string, token?: string) => Promise<SdkResponse<never>>;
202
- phone: {
203
- email: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
204
- sms: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
205
- whatsapp: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
206
- }; /**
207
- * Make sure that all given roles exist on the parsed JWT top level claims
208
- * @param authInfo JWT parsed info
209
- * @param roles list of roles to make sure they exist on te JWT claims
210
- * @returns true if all roles exist, false otherwise
211
- */
183
+ otp: {
184
+ verify: {
185
+ email: (loginId: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
186
+ refreshJwt?: string;
187
+ cookies?: string[];
188
+ }>>;
189
+ sms: (loginId: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
190
+ refreshJwt?: string;
191
+ cookies?: string[];
192
+ }>>;
193
+ whatsapp: (loginId: string, code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
194
+ refreshJwt?: string;
195
+ cookies?: string[];
196
+ }>>;
197
+ };
198
+ signIn: {
199
+ email: (loginId: string) => Promise<SdkResponse<never>>;
200
+ sms: (loginId: string) => Promise<SdkResponse<never>>;
201
+ whatsapp: (loginId: string) => Promise<SdkResponse<never>>;
202
+ };
203
+ signUp: {
204
+ email: (loginId: string, user?: {
205
+ email?: string;
206
+ name?: string;
207
+ phone?: string;
208
+ }) => Promise<SdkResponse<never>>;
209
+ sms: (loginId: string, user?: {
210
+ email?: string;
211
+ name?: string;
212
+ phone?: string;
213
+ }) => Promise<SdkResponse<never>>;
214
+ whatsapp: (loginId: string, user?: {
215
+ email?: string;
216
+ name?: string;
217
+ phone?: string;
218
+ }) => Promise<SdkResponse<never>>;
219
+ };
220
+ signUpOrIn: {
221
+ email: (loginId: string) => Promise<SdkResponse<never>>;
222
+ sms: (loginId: string) => Promise<SdkResponse<never>>;
223
+ whatsapp: (loginId: string) => Promise<SdkResponse<never>>;
224
+ };
225
+ update: {
226
+ email: (loginId: string, email: string, token?: string) => Promise<SdkResponse<never>>;
227
+ phone: {
228
+ email: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
229
+ sms: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
230
+ whatsapp: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
231
+ };
232
+ };
212
233
  };
213
- };
214
- magicLink: {
215
- verify: (token: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
216
- signIn: {
217
- email: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
218
- sms: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
219
- whatsapp: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
234
+ magicLink: {
235
+ verify: (token: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
236
+ refreshJwt?: string;
237
+ cookies?: string[];
238
+ }>>;
239
+ signIn: {
240
+ email: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
241
+ sms: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
242
+ whatsapp: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
243
+ };
244
+ signUp: {
245
+ email: (loginId: string, uri: string, user?: {
246
+ email?: string;
247
+ name?: string;
248
+ phone?: string;
249
+ }) => Promise<SdkResponse<never>>;
250
+ sms: (loginId: string, uri: string, user?: {
251
+ email?: string;
252
+ name?: string;
253
+ phone?: string;
254
+ }) => Promise<SdkResponse<never>>;
255
+ whatsapp: (loginId: string, uri: string, user?: {
256
+ email?: string;
257
+ name?: string;
258
+ phone?: string;
259
+ }) => Promise<SdkResponse<never>>;
260
+ };
261
+ signUpOrIn: {
262
+ email: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
263
+ sms: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
264
+ whatsapp: (loginId: string, uri: string) => Promise<SdkResponse<never>>;
265
+ };
266
+ update: {
267
+ email: (loginId: string, email: string, URI?: string, token?: string) => Promise<SdkResponse<never>>;
268
+ phone: {
269
+ email: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
270
+ sms: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
271
+ whatsapp: (loginId: string, phone: string) => Promise<SdkResponse<never>>;
272
+ };
273
+ };
220
274
  };
221
- signUp: {
222
- email: (identifier: string, uri: string, user?: {
223
- email?: string;
224
- name?: string;
225
- phone?: string;
226
- }) => Promise<SdkResponse<never>>;
227
- sms: (identifier: string, uri: string, user?: {
228
- email?: string;
229
- name?: string;
230
- phone?: string;
231
- }) => Promise<SdkResponse<never>>;
232
- whatsapp: (identifier: string, uri: string, user?: {
275
+ enchantedLink: {
276
+ verify: (token: string) => Promise<SdkResponse<never>>;
277
+ signIn: (loginId: string, uri: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse & {
278
+ refreshJwt?: string;
279
+ cookies?: string[];
280
+ }>>;
281
+ signUpOrIn: (loginId: string, uri: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
282
+ signUp: (loginId: string, uri: string, user?: {
233
283
  email?: string;
234
284
  name?: string;
235
285
  phone?: string;
236
- }) => Promise<SdkResponse<never>>;
237
- };
238
- signUpOrIn: {
239
- email: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
240
- sms: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
241
- whatsapp: (identifier: string, uri: string) => Promise<SdkResponse<never>>;
286
+ }) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse & {
287
+ refreshJwt?: string;
288
+ cookies?: string[];
289
+ }>>;
290
+ waitForSession: (pendingRef: string, config?: {
291
+ pollingIntervalMs: number;
292
+ timeoutMs: number;
293
+ }) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
294
+ update: {
295
+ email: (loginId: string, email: string, URI?: string, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
296
+ };
242
297
  };
243
- update: {
244
- email: (identifier: string, email: string, uri: string, token?: string) => Promise<SdkResponse<never>>;
245
- phone: {
246
- email: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
247
- sms: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
248
- whatsapp: (identifier: string, phone: string) => Promise<SdkResponse<never>>;
298
+ oauth: {
299
+ start: {
300
+ facebook: <B extends {
301
+ redirect: boolean;
302
+ }>(redirectURL?: string, config?: B) => Promise<B extends {
303
+ redirect: true;
304
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
305
+ github: <B_1 extends {
306
+ redirect: boolean;
307
+ }>(redirectURL?: string, config?: B_1) => Promise<B_1 extends {
308
+ redirect: true;
309
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
310
+ google: <B_2 extends {
311
+ redirect: boolean;
312
+ }>(redirectURL?: string, config?: B_2) => Promise<B_2 extends {
313
+ redirect: true;
314
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
315
+ microsoft: <B_3 extends {
316
+ redirect: boolean;
317
+ }>(redirectURL?: string, config?: B_3) => Promise<B_3 extends {
318
+ redirect: true;
319
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
320
+ gitlab: <B_4 extends {
321
+ redirect: boolean;
322
+ }>(redirectURL?: string, config?: B_4) => Promise<B_4 extends {
323
+ redirect: true;
324
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
325
+ apple: <B_5 extends {
326
+ redirect: boolean;
327
+ }>(redirectURL?: string, config?: B_5) => Promise<B_5 extends {
328
+ redirect: true;
329
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
330
+ discord: <B_6 extends {
331
+ redirect: boolean;
332
+ }>(redirectURL?: string, config?: B_6) => Promise<B_6 extends {
333
+ redirect: true;
334
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
335
+ linkedin: <B_7 extends {
336
+ redirect: boolean;
337
+ }>(redirectURL?: string, config?: B_7) => Promise<B_7 extends {
338
+ redirect: true;
339
+ } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
249
340
  };
250
- }; /**
251
- * Make sure that all given roles exist on the parsed JWT tenant claims
252
- * @param authInfo JWT parsed info
253
- * @param roles list of roles to make sure they exist on te JWT claims
254
- * @returns true if all roles exist, false otherwise
255
- */
256
- };
257
- enchantedLink: {
258
- verify: (token: string) => Promise<SdkResponse<never>>;
259
- signIn: (identifier: string, uri: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
260
- signUpOrIn: (identifier: string, uri: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
261
- signUp: (identifier: string, uri: string, user?: {
262
- email?: string;
263
- name?: string;
264
- phone?: string;
265
- }) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
266
- waitForSession: (pendingRef: string, config?: {
267
- pollingIntervalMs: number;
268
- timeoutMs: number;
269
- }) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
270
- update: {
271
- email: (identifier: string, email: string, uri: string, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
341
+ exchange: (code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
342
+ refreshJwt?: string;
343
+ cookies?: string[];
344
+ }>>;
272
345
  };
273
- };
274
- oauth: {
275
- start: {
276
- facebook: <B extends {
277
- redirect: boolean;
278
- }>(redirectURL?: string, config?: B) => Promise<B extends {
279
- redirect: true;
280
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
281
- github: <B_1 extends {
346
+ saml: {
347
+ start: <B_1 extends {
282
348
  redirect: boolean;
283
- }>(redirectURL?: string, config?: B_1) => Promise<B_1 extends {
349
+ }>(tenantNameOrEmail: string, config?: B_1) => Promise<B_1 extends {
284
350
  redirect: true;
285
351
  } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
286
- google: <B_2 extends {
287
- redirect: boolean;
288
- }>(redirectURL?: string, config?: B_2) => Promise<B_2 extends {
289
- redirect: true;
290
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
291
- microsoft: <B_3 extends {
292
- redirect: boolean;
293
- }>(redirectURL?: string, config?: B_3) => Promise<B_3 extends {
294
- redirect: true;
295
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
296
- gitlab: <B_4 extends {
297
- redirect: boolean;
298
- }>(redirectURL?: string, config?: B_4) => Promise<B_4 extends {
299
- redirect: true;
300
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
301
- apple: <B_5 extends {
302
- redirect: boolean;
303
- }>(redirectURL?: string, config?: B_5) => Promise<B_5 extends {
304
- redirect: true;
305
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
306
- };
307
- exchange: (code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
308
- };
309
- saml: {
310
- start: <B_1 extends {
311
- redirect: boolean;
312
- }>(tenantNameOrEmail: string, config?: B_1) => Promise<B_1 extends {
313
- redirect: true;
314
- } ? undefined : SdkResponse<_descope_core_js_sdk.URLResponse>>;
315
- exchange: (code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
316
- };
317
- totp: {
318
- signUp: (identifier: string, user?: {
319
- email?: string;
320
- name?: string;
321
- phone?: string;
322
- }) => Promise<SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
323
- verify: (identifier: string, code: string, loginOptions?: {
324
- stepup?: boolean;
325
- mfa?: boolean;
326
- customClaims?: Record<string, any>;
327
- }, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
328
- update: (identifier: string, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
329
- };
330
- webauthn: {
331
- signUp: {
332
- start: (identifier: string, origin: string, name: string) => Promise<SdkResponse<{
333
- transactionId: string;
334
- options: string;
335
- create: boolean;
352
+ exchange: (code: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
353
+ refreshJwt?: string;
354
+ cookies?: string[];
336
355
  }>>;
337
- finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
338
356
  };
339
- signIn: {
340
- start: (identifier: string, origin: string, loginOptions?: {
357
+ totp: {
358
+ signUp: (loginId: string, user?: {
359
+ email?: string;
360
+ name?: string;
361
+ phone?: string;
362
+ }) => Promise<SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
363
+ verify: (loginId: string, code: string, loginOptions?: {
341
364
  stepup?: boolean;
342
365
  mfa?: boolean;
343
366
  customClaims?: Record<string, any>;
344
- }, token?: string) => Promise<SdkResponse<{
345
- transactionId: string;
346
- options: string;
347
- create: boolean;
348
- }>>;
349
- finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
350
- };
351
- signUpOrIn: {
352
- start: (identifier: string, origin: string) => Promise<SdkResponse<{
353
- transactionId: string;
354
- options: string;
355
- create: boolean;
367
+ }, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
368
+ refreshJwt?: string;
369
+ cookies?: string[];
356
370
  }>>;
371
+ update: (loginId: string, token?: string) => Promise<SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
357
372
  };
358
- update: {
359
- start: (identifier: string, origin: string, token: string) => Promise<SdkResponse<{
360
- transactionId: string;
361
- options: string;
362
- create: boolean;
363
- }>>;
364
- finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.ResponseData>>;
365
- };
366
- };
367
- flow: {
368
- start: (flowId: string, interactionId?: string, input?: Record<string, FormDataEntryValue>, options?: {
369
- redirectUrl?: string;
370
- tenant?: string;
371
- deviceInfo?: {
372
- webAuthnSupport?: boolean;
373
+ webauthn: {
374
+ signUp: {
375
+ start: (loginId: string, origin: string, name: string) => Promise<SdkResponse<{
376
+ transactionId: string;
377
+ options: string;
378
+ create: boolean;
379
+ }>>;
380
+ finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
381
+ refreshJwt?: string;
382
+ cookies?: string[];
383
+ }>>;
373
384
  };
374
- lastUser?: {
375
- authMethod?: "otp" | "totp" | "webauthn" | "magiclink" | "social" | "sso";
376
- oauthProvider?: string;
377
- externalId?: string;
385
+ signIn: {
386
+ start: (loginId: string, origin: string, loginOptions?: {
387
+ stepup?: boolean;
388
+ mfa?: boolean;
389
+ customClaims?: Record<string, any>;
390
+ }, token?: string) => Promise<SdkResponse<{
391
+ transactionId: string;
392
+ options: string;
393
+ create: boolean;
394
+ }>>;
395
+ finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
396
+ refreshJwt?: string;
397
+ cookies?: string[];
398
+ }>>;
378
399
  };
379
- }) => Promise<SdkResponse<_descope_core_js_sdk.FlowResponse>>;
380
- next: (executionId: string, stepId: string, interactionId: string, input?: Record<string, FormDataEntryValue>) => Promise<SdkResponse<_descope_core_js_sdk.FlowResponse>>;
381
- };
382
- refresh: (token?: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse>>;
383
- logout: (token?: string) => Promise<SdkResponse<never>>;
384
- logoutAll: (token?: string) => Promise<SdkResponse<never>>;
385
- me: (token?: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
386
- isJwtExpired: (token: string) => boolean;
387
- getJwtPermissions: (token: string, tenant?: string) => string[];
388
- getJwtRoles: (token: string, tenant?: string) => string[];
389
- httpClient: {
390
- get: (path: string, config?: {
391
- headers?: HeadersInit;
392
- queryParams?: {
393
- [key: string]: string;
400
+ signUpOrIn: {
401
+ start: (loginId: string, origin: string) => Promise<SdkResponse<{
402
+ transactionId: string;
403
+ options: string;
404
+ create: boolean;
405
+ }>>;
394
406
  };
395
- token?: string;
396
- }) => Promise<globalThis.Response>;
397
- post: (path: string, body?: any, config?: {
398
- headers?: HeadersInit;
399
- queryParams?: {
400
- [key: string]: string;
407
+ update: {
408
+ start: (loginId: string, origin: string, token: string) => Promise<SdkResponse<{
409
+ transactionId: string;
410
+ options: string;
411
+ create: boolean;
412
+ }>>;
413
+ finish: (transactionId: string, response: string) => Promise<SdkResponse<_descope_core_js_sdk.ResponseData>>;
401
414
  };
402
- token?: string;
403
- }) => Promise<globalThis.Response>;
404
- put: (path: string, body?: any, config?: {
405
- headers?: HeadersInit;
406
- queryParams?: {
407
- [key: string]: string;
408
- };
409
- token?: string;
410
- }) => Promise<globalThis.Response>;
411
- delete: (path: string, body?: any, config?: {
412
- headers?: HeadersInit;
413
- queryParams?: {
414
- [key: string]: string;
415
+ };
416
+ flow: {
417
+ start: (flowId: string, options?: {
418
+ redirectUrl?: string;
419
+ tenant?: string;
420
+ deviceInfo?: {
421
+ webAuthnSupport?: boolean;
422
+ };
423
+ lastAuth?: {
424
+ authMethod?: "otp" | "oauth" | "saml" | "totp" | "webauthn" | "magiclink" | "enchantedlink";
425
+ oauthProvider?: string;
426
+ name?: string;
427
+ loginId?: string;
428
+ };
429
+ }, conditionInteractionId?: string, interactionId?: string, input?: {
430
+ [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
431
+ }) => Promise<SdkResponse<_descope_core_js_sdk.FlowResponse>>;
432
+ next: (executionId: string, stepId: string, interactionId: string, input?: {
433
+ [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
434
+ }) => Promise<SdkResponse<_descope_core_js_sdk.FlowResponse>>;
435
+ };
436
+ refresh: (token?: string) => Promise<SdkResponse<_descope_core_js_sdk.JWTResponse & {
437
+ refreshJwt?: string;
438
+ cookies?: string[];
439
+ }>>;
440
+ logout: (token?: string) => Promise<SdkResponse<never>>;
441
+ logoutAll: (token?: string) => Promise<SdkResponse<never>>;
442
+ me: (token?: string) => Promise<SdkResponse<_descope_core_js_sdk.UserResponse>>;
443
+ isJwtExpired: (token: string) => boolean;
444
+ getJwtPermissions: (token: string, tenant?: string) => string[];
445
+ getJwtRoles: (token: string, tenant?: string) => string[];
446
+ httpClient: {
447
+ get: (path: string, config?: {
448
+ headers?: HeadersInit;
449
+ queryParams?: {
450
+ [key: string]: string;
451
+ };
452
+ token?: string;
453
+ }) => Promise<Response>;
454
+ post: (path: string, body?: any, config?: {
455
+ headers?: HeadersInit;
456
+ queryParams?: {
457
+ [key: string]: string;
458
+ };
459
+ token?: string;
460
+ }) => Promise<Response>;
461
+ put: (path: string, body?: any, config?: {
462
+ headers?: HeadersInit;
463
+ queryParams?: {
464
+ [key: string]: string;
465
+ };
466
+ token?: string;
467
+ }) => Promise<Response>;
468
+ delete: (path: string, body?: any, config?: {
469
+ headers?: HeadersInit;
470
+ queryParams?: {
471
+ [key: string]: string;
472
+ };
473
+ token?: string;
474
+ }) => Promise<Response>;
475
+ hooks?: {
476
+ beforeRequest?: (config: _descope_core_js_sdk.RequestConfig) => _descope_core_js_sdk.RequestConfig;
477
+ afterRequest?: (req: _descope_core_js_sdk.RequestConfig, res: Response) => void | Promise<void>;
415
478
  };
416
- token?: string;
417
- }) => Promise<globalThis.Response>;
479
+ };
418
480
  };
419
- }) & {
420
- DeliveryMethods: typeof _descope_core_js_sdk__default.DeliveryMethods;
421
- RefreshTokenCookieName: typeof refreshTokenCookieName;
422
- SessionTokenCookieName: typeof sessionTokenCookieName;
481
+ /** Descope SDK client with delivery methods enum.
482
+ *
483
+ * Please see full documentation at {@link https://docs.descope.com/guides Descope Docs}
484
+ * @example Usage
485
+ *
486
+ * ```js
487
+ * import descopeSdk from '@descope/node-sdk';
488
+ *
489
+ * const myProjectId = 'xxx';
490
+ * const sdk = descopeSdk({ projectId: myProjectId });
491
+ *
492
+ * const userLoginId = 'loginId';
493
+ * sdk.otp.signIn.email(userLoginId);
494
+ * const jwtResponse = sdk.otp.verify.email(userLoginId, codeFromEmail);
495
+ * ```
496
+ */
497
+ RefreshTokenCookieName: string;
498
+ SessionTokenCookieName: string;
423
499
  };
424
500
 
425
- export { NodeSdkArgs, sdkWithAttributes as default };
501
+ export { nodeSdk as default };