@niledatabase/server 5.0.0-alpha.2 → 5.0.0-alpha.4

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
@@ -1,5 +1,13 @@
1
1
  import pg, { PoolConfig, PoolClient } from 'pg';
2
2
 
3
+ type ExtensionCtx = {
4
+ handleOnRequest: (config: Config, _init: RequestInit & {
5
+ request: Request;
6
+ }, params: RequestInit) => Promise<void>;
7
+ };
8
+ type ConfigConstructor = NileConfig & {
9
+ extensionCtx?: ExtensionCtx;
10
+ };
3
11
  declare class Config {
4
12
  routes: Routes;
5
13
  handlers: {
@@ -14,7 +22,9 @@ declare class Config {
14
22
  delete: string[];
15
23
  put: string[];
16
24
  };
17
- logger?: LoggerType;
25
+ extensionCtx: ExtensionCtx;
26
+ extensions?: Extension[];
27
+ logger: LoggerType;
18
28
  /**
19
29
  * Stores the set tenant id from Server for use in sub classes
20
30
  */
@@ -47,7 +57,7 @@ declare class Config {
47
57
  */
48
58
  routePrefix: string;
49
59
  db: NilePoolConfig;
50
- constructor(config?: NileConfig, logger?: string);
60
+ constructor(config?: ConfigConstructor);
51
61
  }
52
62
 
53
63
  type Routes = {
@@ -70,193 +80,10 @@ type Routes = {
70
80
  PASSWORD_RESET: string;
71
81
  LOG: string;
72
82
  VERIFY_EMAIL: string;
83
+ INVITES: string;
84
+ INVITE: string;
73
85
  };
74
86
 
75
- type Opts = {
76
- basePath?: string;
77
- fetch?: typeof fetch;
78
- };
79
- type NilePoolConfig = PoolConfig & {
80
- afterCreate?: AfterCreate;
81
- };
82
- type LoggerType = {
83
- info?: (args: unknown | unknown[]) => void;
84
- warn?: (args: unknown | unknown[]) => void;
85
- error?: (args: unknown | unknown[]) => void;
86
- debug?: (args: unknown | unknown[]) => void;
87
- };
88
- type NileConfig = {
89
- /**
90
- * The specific database id. Either passed in or figured out by NILEDB_API_URL
91
- * process.env.NILEDB_ID
92
- */
93
- databaseId?: string;
94
- /**
95
- * The user UUID to the database
96
- * process.env.NILEDB_USER
97
- */
98
- user?: string;
99
- /**
100
- * The password UUID to the database
101
- * process.env.NILEDB_PASSWORD
102
- */
103
- password?: string;
104
- /**
105
- * The name of the database. Automatically obtained from NILEDB_POSTGRES_URL
106
- * process.env.NILEDB_NAME
107
- */
108
- databaseName?: string;
109
- /**
110
- * A tenant id. Scopes requests to a specific tenant, both API and DB
111
- * process.env.NILEDB_TENANT
112
- */
113
- tenantId?: string | null | undefined;
114
- /**
115
- * A user id. Possibly not the logged in user, used for setting database context (nile.user_id)
116
- * Generally speaking, this wouldn't be used for authentication, and in some cases simply won't do anything on some endpoints
117
- */
118
- userId?: string | null | undefined;
119
- /**
120
- * Shows a bunch of logging on the server side to see what's being done between the sdk and nile-auth
121
- */
122
- debug?: boolean;
123
- /**
124
- * DB configuration overrides. Environment variables are the way to go, but maybe you need something more
125
- */
126
- db?: NilePoolConfig;
127
- /**
128
- * Some kind of logger if you want to send to an external service
129
- */
130
- logger?: LoggerType;
131
- /**
132
- * The configuration value that maps to `NILEDB_API_URL` - its going to be nile-auth (or similar service)
133
- */
134
- apiUrl?: string | undefined;
135
- /**
136
- * Ignore client callbackUrls by setting this.
137
- * You can force the callback URL server side to be sure nile-auth redirects to whatever location.
138
- */
139
- callbackUrl?: string | undefined;
140
- /**
141
- * Need to override some routes? Change it here
142
- */
143
- routes?: Partial<Routes>;
144
- /**
145
- * don't like the default `/api`? change it here
146
- */
147
- routePrefix?: string | undefined;
148
- /**
149
- * In some cases, you may want to force secure cookies.
150
- * The SDK handles this for you, but might be necessary in some firewall / internal cases
151
- * Defaults to true if you're in production
152
- */
153
- secureCookies?: boolean;
154
- /**
155
- * The origin for the requests.
156
- * Allows the setting of the callback origin to a random FE
157
- * eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
158
- * In full stack cases, will just be the `host` header of the incoming request, which is used by default
159
- * It is also important to set this when dealing with secure cookies. Calling via server side needs to know if TLS is being used so that nile-auth knows which cookies to be sent.
160
- */
161
- origin?: null | undefined | string;
162
- /**
163
- * Set the headers to use in API requests.
164
- * The `cookie` would be expected if you are setting this, else most calls will be unauthorized
165
- */
166
- headers?: null | Headers | Record<string, string>;
167
- };
168
- type NileDb = NilePoolConfig & {
169
- tenantId?: string;
170
- };
171
- type AfterCreate = (conn: PoolClient, done: (err: null | Error, conn: PoolClient) => void) => void;
172
- interface NileBody<R, B> {
173
- readonly body: ReadableStream<Uint8Array> | null | B;
174
- readonly bodyUsed: boolean;
175
- arrayBuffer(): Promise<ArrayBuffer>;
176
- blob(): Promise<Blob>;
177
- formData(): Promise<FormData>;
178
- json(): Promise<R>;
179
- text(): Promise<string>;
180
- }
181
- interface NResponse<T> extends NileBody<T, any> {
182
- readonly headers: Headers;
183
- readonly ok: boolean;
184
- readonly redirected: boolean;
185
- readonly status: number;
186
- readonly statusText: string;
187
- readonly type: ResponseType;
188
- readonly url: string;
189
- clone(): Response;
190
- }
191
- interface NRequest<T> extends NileBody<any, T> {
192
- /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
193
- readonly cache: RequestCache;
194
- /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
195
- readonly credentials: RequestCredentials;
196
- /** Returns the kind of resource requested by request, e.g., "document" or "script". */
197
- readonly destination: RequestDestination;
198
- /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
199
- readonly headers: Headers;
200
- /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
201
- readonly integrity: string;
202
- /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
203
- readonly keepalive: boolean;
204
- /** Returns request's HTTP method, which is "GET" by default. */
205
- readonly method: string;
206
- /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
207
- readonly mode: RequestMode;
208
- /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
209
- readonly redirect: RequestRedirect;
210
- /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
211
- readonly referrer: string;
212
- /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
213
- readonly referrerPolicy: ReferrerPolicy;
214
- /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
215
- readonly signal: AbortSignal;
216
- /** Returns the URL of request as a string. */
217
- readonly url: string;
218
- clone(): Request;
219
- }
220
- type NileRequest<T> = NRequest<T> | T;
221
- declare const APIErrorErrorCodeEnum: {
222
- readonly InternalError: "internal_error";
223
- readonly BadRequest: "bad_request";
224
- readonly EntityNotFound: "entity_not_found";
225
- readonly DuplicateEntity: "duplicate_entity";
226
- readonly InvalidCredentials: "invalid_credentials";
227
- readonly UnknownOidcProvider: "unknown_oidc_provider";
228
- readonly ProviderAlreadyExists: "provider_already_exists";
229
- readonly ProviderConfigError: "provider_config_error";
230
- readonly ProviderMismatch: "provider_mismatch";
231
- readonly ProviderUpdateError: "provider_update_error";
232
- readonly SessionStateMissing: "session_state_missing";
233
- readonly SessionStateMismatch: "session_state_mismatch";
234
- readonly OidcCodeMissing: "oidc_code_missing";
235
- };
236
- type APIErrorErrorCodeEnum = (typeof APIErrorErrorCodeEnum)[keyof typeof APIErrorErrorCodeEnum];
237
- interface APIError {
238
- [key: string]: any | any;
239
- /**
240
- *
241
- * @type {string}
242
- * @memberof APIError
243
- */
244
- errorCode: APIErrorErrorCodeEnum;
245
- /**
246
- *
247
- * @type {string}
248
- * @memberof APIError
249
- */
250
- message: string;
251
- /**
252
- *
253
- * @type {number}
254
- * @memberof APIError
255
- */
256
- statusCode: number;
257
- }
258
- type NileResponse<T> = Promise<T | NResponse<T & APIError>>;
259
-
260
87
  interface CreateBasicUserRequest {
261
88
  email: string;
262
89
  password: string;
@@ -304,43 +131,6 @@ interface User {
304
131
  tenants: string[];
305
132
  }
306
133
 
307
- type Tenant = {
308
- id: string;
309
- name: string;
310
- };
311
-
312
- type ProviderName = 'discord' | 'github' | 'google' | 'hubspot' | 'linkedin' | 'slack' | 'twitter' | 'email' | 'credentials' | 'azure';
313
- type Providers = {
314
- [providerName in ProviderName]: Provider;
315
- };
316
- type Provider = {
317
- id: string;
318
- name: string;
319
- type: string;
320
- signinUrl: string;
321
- callbackUrl: string;
322
- };
323
- type JWT = {
324
- email: string;
325
- sub: string;
326
- id: string;
327
- iat: number;
328
- exp: number;
329
- jti: string;
330
- };
331
- type ActiveSession = {
332
- id: string;
333
- email: string;
334
- expires: string;
335
- user?: {
336
- id: string;
337
- name: string;
338
- image: string;
339
- email: string;
340
- emailVerified: void | Date;
341
- };
342
- };
343
-
344
134
  declare class Users {
345
135
  #private;
346
136
  constructor(config: Config);
@@ -348,12 +138,30 @@ declare class Users {
348
138
  emailVerified: boolean;
349
139
  }>, rawResponse?: boolean): Promise<T>;
350
140
  removeSelf(): Promise<Response>;
351
- getSelf(rawResponse?: true): Promise<Response>;
352
141
  getSelf<T = User | Response>(): Promise<T>;
353
- verifySelf(rawResponse?: true): Promise<Response>;
354
- verifySelf<T = Response | void>(): Promise<T>;
142
+ getSelf(rawResponse?: true): Promise<Response>;
143
+ verifySelf<T = void>(): Promise<T>;
144
+ verifySelf(rawResponse: true): Promise<Response>;
145
+ verifySelf<T = Response | User>(options: {
146
+ bypassEmail?: boolean;
147
+ callbackUrl?: string;
148
+ }, rawResponse?: true): Promise<T>;
355
149
  }
356
150
 
151
+ type Tenant = {
152
+ id: string;
153
+ name: string;
154
+ };
155
+ type Invite = {
156
+ id: string;
157
+ tenant_id: string;
158
+ token: string;
159
+ identifier: string;
160
+ roles: null | string;
161
+ created_by: string;
162
+ expires: Date;
163
+ };
164
+
357
165
  type ReqContext = {
358
166
  userId?: string;
359
167
  tenantId?: string;
@@ -364,6 +172,7 @@ type JoinTenantRequest = string | ReqContext | {
364
172
  declare class Tenants {
365
173
  #private;
366
174
  constructor(config: Config);
175
+ create(name: string, rawResponse: true): Promise<Response>;
367
176
  create<T = Tenant | Response>(name: string, rawResponse?: boolean): Promise<T>;
368
177
  create<T = Tenant | Response>(payload: {
369
178
  name: string;
@@ -373,27 +182,79 @@ declare class Tenants {
373
182
  delete<T = Response>(payload: {
374
183
  id: string;
375
184
  }): Promise<T>;
376
- get(rawResponse: true): Promise<Response>;
185
+ get<T = Tenant | Response>(): Promise<T>;
377
186
  get<T = Tenant | Response>(id: string, rawResponse?: boolean): Promise<T>;
187
+ get(rawResponse: true): Promise<Response>;
378
188
  get<T = Tenant | Response>(payload: {
379
189
  id: string;
380
190
  }, rawResponse?: boolean): Promise<T>;
381
191
  update(req: Partial<Tenant>, rawResponse: true): Promise<Response>;
382
192
  update<T = Tenant | Response | undefined>(req: Partial<Tenant>, rawResponse?: boolean): Promise<T>;
383
- list(rawResponse: true): Promise<Response>;
384
193
  list<T = Tenant[] | Response>(): Promise<T>;
194
+ list(rawResponse: true): Promise<Response>;
385
195
  leaveTenant<T = Response>(req?: string | {
386
196
  tenantId: string;
387
197
  }): Promise<T>;
388
198
  addMember(req: JoinTenantRequest, rawResponse: true): Promise<Response>;
389
199
  addMember<T = User | Response>(req: JoinTenantRequest, rawResponse?: boolean): Promise<T>;
390
200
  removeMember(req: JoinTenantRequest, rawResponse?: boolean): Promise<Response>;
391
- users(req: boolean): Promise<Response>;
392
201
  users<T = User[] | Response>(req?: boolean | {
393
202
  tenantId?: string;
394
203
  }, rawResponse?: boolean): Promise<T>;
204
+ users(req: true): Promise<Response>;
205
+ invites<T = Invite[] | Response>(): Promise<T>;
206
+ invite<T = Response | Invite>(req: string | {
207
+ email: string;
208
+ callbackUrl?: string;
209
+ redirectUrl?: string;
210
+ }, rawResponse?: boolean): Promise<T>;
211
+ invite(req: string | {
212
+ email: string;
213
+ callbackUrl?: string;
214
+ redirectUrl?: string;
215
+ }, rawResponse: true): Promise<Response>;
216
+ acceptInvite<T = Response>(req?: {
217
+ identifier: string;
218
+ token: string;
219
+ redirectUrl?: string;
220
+ }, rawResponse?: boolean): Promise<T>;
221
+ deleteInvite<T = Response>(req: string | {
222
+ id: string;
223
+ }): Promise<T>;
395
224
  }
396
225
 
226
+ type ProviderName = 'discord' | 'github' | 'google' | 'hubspot' | 'linkedin' | 'slack' | 'twitter' | 'email' | 'credentials' | 'azure';
227
+ type Providers = {
228
+ [providerName in ProviderName]: Provider;
229
+ };
230
+ type Provider = {
231
+ id: string;
232
+ name: string;
233
+ type: string;
234
+ signinUrl: string;
235
+ callbackUrl: string;
236
+ };
237
+ type JWT = {
238
+ email: string;
239
+ sub: string;
240
+ id: string;
241
+ iat: number;
242
+ exp: number;
243
+ jti: string;
244
+ };
245
+ type ActiveSession = {
246
+ id: string;
247
+ email: string;
248
+ expires: string;
249
+ user?: {
250
+ id: string;
251
+ name: string;
252
+ image: string;
253
+ email: string;
254
+ emailVerified: void | Date;
255
+ };
256
+ };
257
+
397
258
  type SignUpPayload = {
398
259
  email: string;
399
260
  password: string;
@@ -403,10 +264,10 @@ type SignUpPayload = {
403
264
  declare class Auth {
404
265
  #private;
405
266
  constructor(config: Config);
406
- getSession(rawResponse: true): Promise<Response>;
407
267
  getSession<T = JWT | ActiveSession | undefined>(rawResponse?: false): Promise<T>;
408
- getCsrf(rawResponse: true): Promise<Response>;
268
+ getSession(rawResponse: true): Promise<Response>;
409
269
  getCsrf<T = Response | JSON>(rawResponse?: false): Promise<T>;
270
+ getCsrf(rawResponse: true): Promise<Response>;
410
271
  listProviders(rawResponse: true): Promise<Response>;
411
272
  listProviders<T = {
412
273
  [key: string]: Provider;
@@ -419,6 +280,11 @@ declare class Auth {
419
280
  */
420
281
  signUp(payload: SignUpPayload, rawResponse: true): Promise<Response>;
421
282
  signUp<T = User | Response>(payload: SignUpPayload): Promise<T>;
283
+ forgotPassword(req: {
284
+ email: string;
285
+ callbackUrl?: string;
286
+ redirectUrl?: string;
287
+ }): Promise<Response>;
422
288
  resetPassword(req: Request | {
423
289
  email: string;
424
290
  password: string;
@@ -505,4 +371,205 @@ declare class Server {
505
371
  }
506
372
  declare function create(config?: NileConfig): Server;
507
373
 
508
- export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CreateBasicUserRequest, type CreateTenantUserRequest, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, Server, type Tenant, type User, parseCSRF, parseCallback, parseToken };
374
+ type Opts = {
375
+ basePath?: string;
376
+ fetch?: typeof fetch;
377
+ };
378
+ interface ExtensionResult {
379
+ id?: string;
380
+ [key: string]: unknown;
381
+ onRequest?: (req: Request) => void | Promise<void | RequestInit>;
382
+ onResponse?: (res: Response) => void | Promise<void>;
383
+ }
384
+ type Extension = (instance: Server) => ExtensionResult | Promise<ExtensionResult>;
385
+ type NilePoolConfig = PoolConfig & {
386
+ afterCreate?: AfterCreate;
387
+ };
388
+ type LoggerType = {
389
+ info: (args: unknown | unknown[]) => void;
390
+ warn: (args: unknown | unknown[]) => void;
391
+ error: (args: unknown | unknown[]) => void;
392
+ debug: (args: unknown | unknown[]) => void;
393
+ };
394
+ type NileConfig = {
395
+ /**
396
+ * The specific database id. Either passed in or figured out by NILEDB_API_URL
397
+ * process.env.NILEDB_ID
398
+ */
399
+ databaseId?: string;
400
+ /**
401
+ * The user UUID to the database
402
+ * process.env.NILEDB_USER
403
+ */
404
+ user?: string;
405
+ /**
406
+ * The password UUID to the database
407
+ * process.env.NILEDB_PASSWORD
408
+ */
409
+ password?: string;
410
+ /**
411
+ * The name of the database. Automatically obtained from NILEDB_POSTGRES_URL
412
+ * process.env.NILEDB_NAME
413
+ */
414
+ databaseName?: string;
415
+ /**
416
+ * A tenant id. Scopes requests to a specific tenant, both API and DB
417
+ * process.env.NILEDB_TENANT
418
+ */
419
+ tenantId?: string | null | undefined;
420
+ /**
421
+ * A user id. Possibly not the logged in user, used for setting database context (nile.user_id)
422
+ * Generally speaking, this wouldn't be used for authentication, and in some cases simply won't do anything on some endpoints
423
+ */
424
+ userId?: string | null | undefined;
425
+ /**
426
+ * Shows a bunch of logging on the server side to see what's being done between the sdk and nile-auth
427
+ */
428
+ debug?: boolean;
429
+ /**
430
+ * DB configuration overrides. Environment variables are the way to go, but maybe you need something more
431
+ */
432
+ db?: NilePoolConfig;
433
+ /**
434
+ * Some kind of logger if you want to send to an external service
435
+ */
436
+ logger?: LoggerType;
437
+ /**
438
+ * The configuration value that maps to `NILEDB_API_URL` - its going to be nile-auth (or similar service)
439
+ */
440
+ apiUrl?: string | undefined;
441
+ /**
442
+ * Ignore client callbackUrls by setting this.
443
+ * You can force the callback URL server side to be sure nile-auth redirects to whatever location.
444
+ */
445
+ callbackUrl?: string | undefined;
446
+ /**
447
+ * Need to override some routes? Change it here
448
+ */
449
+ routes?: Partial<Routes>;
450
+ /**
451
+ * don't like the default `/api`? change it here
452
+ */
453
+ routePrefix?: string | undefined;
454
+ /**
455
+ * In some cases, you may want to force secure cookies.
456
+ * The SDK handles this for you, but might be necessary in some firewall / internal cases
457
+ * Defaults to true if you're in production
458
+ */
459
+ secureCookies?: boolean;
460
+ /**
461
+ * The origin for the requests.
462
+ * Allows the setting of the callback origin to a random FE
463
+ * eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
464
+ * In full stack cases, will just be the `host` header of the incoming request, which is used by default
465
+ * It is also important to set this when dealing with secure cookies. Calling via server side needs to know if TLS is being used so that nile-auth knows which cookies to be sent.
466
+ */
467
+ origin?: null | undefined | string;
468
+ /**
469
+ * Set the headers to use in API requests.
470
+ * The `cookie` would be expected if you are setting this, else most calls will be unauthorized
471
+ */
472
+ headers?: null | Headers | Record<string, string>;
473
+ /**
474
+ * Functions to run at various points to make life easier
475
+ */
476
+ extensions?: Extension[];
477
+ };
478
+ type NileDb = NilePoolConfig & {
479
+ tenantId?: string;
480
+ };
481
+ type AfterCreate = (conn: PoolClient, done: (err: null | Error, conn: PoolClient) => void) => void;
482
+ interface NileBody<R, B> {
483
+ readonly body: ReadableStream<Uint8Array> | null | B;
484
+ readonly bodyUsed: boolean;
485
+ arrayBuffer(): Promise<ArrayBuffer>;
486
+ blob(): Promise<Blob>;
487
+ formData(): Promise<FormData>;
488
+ json(): Promise<R>;
489
+ text(): Promise<string>;
490
+ }
491
+ interface NResponse<T> extends NileBody<T, any> {
492
+ readonly headers: Headers;
493
+ readonly ok: boolean;
494
+ readonly redirected: boolean;
495
+ readonly status: number;
496
+ readonly statusText: string;
497
+ readonly type: ResponseType;
498
+ readonly url: string;
499
+ clone(): Response;
500
+ }
501
+ interface NRequest<T> extends NileBody<any, T> {
502
+ /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
503
+ readonly cache: RequestCache;
504
+ /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
505
+ readonly credentials: RequestCredentials;
506
+ /** Returns the kind of resource requested by request, e.g., "document" or "script". */
507
+ readonly destination: RequestDestination;
508
+ /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
509
+ readonly headers: Headers;
510
+ /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
511
+ readonly integrity: string;
512
+ /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
513
+ readonly keepalive: boolean;
514
+ /** Returns request's HTTP method, which is "GET" by default. */
515
+ readonly method: string;
516
+ /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
517
+ readonly mode: RequestMode;
518
+ /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
519
+ readonly redirect: RequestRedirect;
520
+ /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
521
+ readonly referrer: string;
522
+ /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
523
+ readonly referrerPolicy: ReferrerPolicy;
524
+ /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
525
+ readonly signal: AbortSignal;
526
+ /** Returns the URL of request as a string. */
527
+ readonly url: string;
528
+ clone(): Request;
529
+ }
530
+ type NileRequest<T> = NRequest<T> | T;
531
+ declare const APIErrorErrorCodeEnum: {
532
+ readonly InternalError: "internal_error";
533
+ readonly BadRequest: "bad_request";
534
+ readonly EntityNotFound: "entity_not_found";
535
+ readonly DuplicateEntity: "duplicate_entity";
536
+ readonly InvalidCredentials: "invalid_credentials";
537
+ readonly UnknownOidcProvider: "unknown_oidc_provider";
538
+ readonly ProviderAlreadyExists: "provider_already_exists";
539
+ readonly ProviderConfigError: "provider_config_error";
540
+ readonly ProviderMismatch: "provider_mismatch";
541
+ readonly ProviderUpdateError: "provider_update_error";
542
+ readonly SessionStateMissing: "session_state_missing";
543
+ readonly SessionStateMismatch: "session_state_mismatch";
544
+ readonly OidcCodeMissing: "oidc_code_missing";
545
+ };
546
+ type APIErrorErrorCodeEnum = (typeof APIErrorErrorCodeEnum)[keyof typeof APIErrorErrorCodeEnum];
547
+ interface APIError {
548
+ [key: string]: any | any;
549
+ /**
550
+ *
551
+ * @type {string}
552
+ * @memberof APIError
553
+ */
554
+ errorCode: APIErrorErrorCodeEnum;
555
+ /**
556
+ *
557
+ * @type {string}
558
+ * @memberof APIError
559
+ */
560
+ message: string;
561
+ /**
562
+ *
563
+ * @type {number}
564
+ * @memberof APIError
565
+ */
566
+ statusCode: number;
567
+ }
568
+ type NileResponse<T> = Promise<T | NResponse<T & APIError>>;
569
+
570
+ declare const TENANT_COOKIE = "nile.tenant-id";
571
+ declare const USER_COOKIE = "nile.user-id";
572
+ declare const HEADER_ORIGIN = "nile-origin";
573
+ declare const HEADER_SECURE_COOKIES = "nile-secure-cookies";
574
+
575
+ export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CreateBasicUserRequest, type CreateTenantUserRequest, type Extension, type ExtensionResult, HEADER_ORIGIN, HEADER_SECURE_COOKIES, type Invite, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, Server, TENANT_COOKIE, type Tenant, USER_COOKIE, type User, parseCSRF, parseCallback, parseToken };