@niledatabase/server 5.0.0-alpha.1 → 5.0.0-alpha.2
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/express.js +102 -48
- package/dist/express.js.map +1 -1
- package/dist/express.mjs +102 -48
- package/dist/express.mjs.map +1 -1
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +658 -390
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +658 -390
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,10 @@ declare class Config {
|
|
|
32
32
|
*/
|
|
33
33
|
apiUrl: string;
|
|
34
34
|
origin?: string | undefined | null;
|
|
35
|
+
/**
|
|
36
|
+
* important for separating the `origin` config value from a default in order to make requests
|
|
37
|
+
*/
|
|
38
|
+
serverOrigin: string;
|
|
35
39
|
debug?: boolean;
|
|
36
40
|
/**
|
|
37
41
|
* To use secure cookies or not in the fetch
|
|
@@ -65,6 +69,7 @@ type Routes = {
|
|
|
65
69
|
VERIFY_REQUEST: string;
|
|
66
70
|
PASSWORD_RESET: string;
|
|
67
71
|
LOG: string;
|
|
72
|
+
VERIFY_EMAIL: string;
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
type Opts = {
|
|
@@ -143,6 +148,7 @@ type NileConfig = {
|
|
|
143
148
|
/**
|
|
144
149
|
* In some cases, you may want to force secure cookies.
|
|
145
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
|
|
146
152
|
*/
|
|
147
153
|
secureCookies?: boolean;
|
|
148
154
|
/**
|
|
@@ -150,6 +156,7 @@ type NileConfig = {
|
|
|
150
156
|
* Allows the setting of the callback origin to a random FE
|
|
151
157
|
* eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
|
|
152
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.
|
|
153
160
|
*/
|
|
154
161
|
origin?: null | undefined | string;
|
|
155
162
|
/**
|
|
@@ -303,6 +310,9 @@ type Tenant = {
|
|
|
303
310
|
};
|
|
304
311
|
|
|
305
312
|
type ProviderName = 'discord' | 'github' | 'google' | 'hubspot' | 'linkedin' | 'slack' | 'twitter' | 'email' | 'credentials' | 'azure';
|
|
313
|
+
type Providers = {
|
|
314
|
+
[providerName in ProviderName]: Provider;
|
|
315
|
+
};
|
|
306
316
|
type Provider = {
|
|
307
317
|
id: string;
|
|
308
318
|
name: string;
|
|
@@ -334,10 +344,14 @@ type ActiveSession = {
|
|
|
334
344
|
declare class Users {
|
|
335
345
|
#private;
|
|
336
346
|
constructor(config: Config);
|
|
337
|
-
updateSelf<T = User[] | Response>(req: Partial<Omit<User, 'email' | 'tenants' | 'created' | 'updated'
|
|
347
|
+
updateSelf<T = User[] | Response>(req: Partial<Omit<User, 'email' | 'tenants' | 'created' | 'updated' | 'emailVerified'> & {
|
|
348
|
+
emailVerified: boolean;
|
|
349
|
+
}>, rawResponse?: boolean): Promise<T>;
|
|
338
350
|
removeSelf(): Promise<Response>;
|
|
339
351
|
getSelf(rawResponse?: true): Promise<Response>;
|
|
340
352
|
getSelf<T = User | Response>(): Promise<T>;
|
|
353
|
+
verifySelf(rawResponse?: true): Promise<Response>;
|
|
354
|
+
verifySelf<T = Response | void>(): Promise<T>;
|
|
341
355
|
}
|
|
342
356
|
|
|
343
357
|
type ReqContext = {
|
|
@@ -405,13 +419,20 @@ declare class Auth {
|
|
|
405
419
|
*/
|
|
406
420
|
signUp(payload: SignUpPayload, rawResponse: true): Promise<Response>;
|
|
407
421
|
signUp<T = User | Response>(payload: SignUpPayload): Promise<T>;
|
|
422
|
+
resetPassword(req: Request | {
|
|
423
|
+
email: string;
|
|
424
|
+
password: string;
|
|
425
|
+
callbackUrl?: string;
|
|
426
|
+
redirectUrl?: string;
|
|
427
|
+
}): Promise<Response>;
|
|
428
|
+
callback(provider: ProviderName, body?: string | Request): Promise<Response>;
|
|
408
429
|
/**
|
|
409
430
|
* The return value from this will be a redirect for the client
|
|
410
431
|
* In most cases, you should forward the response directly to the client
|
|
411
432
|
* @param payload
|
|
412
433
|
* @param rawResponse
|
|
413
434
|
*/
|
|
414
|
-
signIn<T = Response>(provider: ProviderName, payload?: {
|
|
435
|
+
signIn<T = Response>(provider: ProviderName, payload?: Request | {
|
|
415
436
|
email: string;
|
|
416
437
|
password: string;
|
|
417
438
|
}, rawResponse?: true): Promise<T>;
|
|
@@ -484,4 +505,4 @@ declare class Server {
|
|
|
484
505
|
}
|
|
485
506
|
declare function create(config?: NileConfig): Server;
|
|
486
507
|
|
|
487
|
-
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, Server, type Tenant, type User, parseCSRF, parseCallback, parseToken };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ declare class Config {
|
|
|
32
32
|
*/
|
|
33
33
|
apiUrl: string;
|
|
34
34
|
origin?: string | undefined | null;
|
|
35
|
+
/**
|
|
36
|
+
* important for separating the `origin` config value from a default in order to make requests
|
|
37
|
+
*/
|
|
38
|
+
serverOrigin: string;
|
|
35
39
|
debug?: boolean;
|
|
36
40
|
/**
|
|
37
41
|
* To use secure cookies or not in the fetch
|
|
@@ -65,6 +69,7 @@ type Routes = {
|
|
|
65
69
|
VERIFY_REQUEST: string;
|
|
66
70
|
PASSWORD_RESET: string;
|
|
67
71
|
LOG: string;
|
|
72
|
+
VERIFY_EMAIL: string;
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
type Opts = {
|
|
@@ -143,6 +148,7 @@ type NileConfig = {
|
|
|
143
148
|
/**
|
|
144
149
|
* In some cases, you may want to force secure cookies.
|
|
145
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
|
|
146
152
|
*/
|
|
147
153
|
secureCookies?: boolean;
|
|
148
154
|
/**
|
|
@@ -150,6 +156,7 @@ type NileConfig = {
|
|
|
150
156
|
* Allows the setting of the callback origin to a random FE
|
|
151
157
|
* eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
|
|
152
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.
|
|
153
160
|
*/
|
|
154
161
|
origin?: null | undefined | string;
|
|
155
162
|
/**
|
|
@@ -303,6 +310,9 @@ type Tenant = {
|
|
|
303
310
|
};
|
|
304
311
|
|
|
305
312
|
type ProviderName = 'discord' | 'github' | 'google' | 'hubspot' | 'linkedin' | 'slack' | 'twitter' | 'email' | 'credentials' | 'azure';
|
|
313
|
+
type Providers = {
|
|
314
|
+
[providerName in ProviderName]: Provider;
|
|
315
|
+
};
|
|
306
316
|
type Provider = {
|
|
307
317
|
id: string;
|
|
308
318
|
name: string;
|
|
@@ -334,10 +344,14 @@ type ActiveSession = {
|
|
|
334
344
|
declare class Users {
|
|
335
345
|
#private;
|
|
336
346
|
constructor(config: Config);
|
|
337
|
-
updateSelf<T = User[] | Response>(req: Partial<Omit<User, 'email' | 'tenants' | 'created' | 'updated'
|
|
347
|
+
updateSelf<T = User[] | Response>(req: Partial<Omit<User, 'email' | 'tenants' | 'created' | 'updated' | 'emailVerified'> & {
|
|
348
|
+
emailVerified: boolean;
|
|
349
|
+
}>, rawResponse?: boolean): Promise<T>;
|
|
338
350
|
removeSelf(): Promise<Response>;
|
|
339
351
|
getSelf(rawResponse?: true): Promise<Response>;
|
|
340
352
|
getSelf<T = User | Response>(): Promise<T>;
|
|
353
|
+
verifySelf(rawResponse?: true): Promise<Response>;
|
|
354
|
+
verifySelf<T = Response | void>(): Promise<T>;
|
|
341
355
|
}
|
|
342
356
|
|
|
343
357
|
type ReqContext = {
|
|
@@ -405,13 +419,20 @@ declare class Auth {
|
|
|
405
419
|
*/
|
|
406
420
|
signUp(payload: SignUpPayload, rawResponse: true): Promise<Response>;
|
|
407
421
|
signUp<T = User | Response>(payload: SignUpPayload): Promise<T>;
|
|
422
|
+
resetPassword(req: Request | {
|
|
423
|
+
email: string;
|
|
424
|
+
password: string;
|
|
425
|
+
callbackUrl?: string;
|
|
426
|
+
redirectUrl?: string;
|
|
427
|
+
}): Promise<Response>;
|
|
428
|
+
callback(provider: ProviderName, body?: string | Request): Promise<Response>;
|
|
408
429
|
/**
|
|
409
430
|
* The return value from this will be a redirect for the client
|
|
410
431
|
* In most cases, you should forward the response directly to the client
|
|
411
432
|
* @param payload
|
|
412
433
|
* @param rawResponse
|
|
413
434
|
*/
|
|
414
|
-
signIn<T = Response>(provider: ProviderName, payload?: {
|
|
435
|
+
signIn<T = Response>(provider: ProviderName, payload?: Request | {
|
|
415
436
|
email: string;
|
|
416
437
|
password: string;
|
|
417
438
|
}, rawResponse?: true): Promise<T>;
|
|
@@ -484,4 +505,4 @@ declare class Server {
|
|
|
484
505
|
}
|
|
485
506
|
declare function create(config?: NileConfig): Server;
|
|
486
507
|
|
|
487
|
-
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, Server, type Tenant, type User, parseCSRF, parseCallback, parseToken };
|
|
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 };
|