@rockyatoyan/nest-oauth 0.0.2 → 0.0.3
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.mts +75 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +334 -0
- package/dist/index.mjs +334 -0
- package/package.json +4 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { FactoryProvider, ModuleMetadata, DynamicModule } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
interface ProviderOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
scopes: string[];
|
|
8
|
+
authUrl: string;
|
|
9
|
+
tokensUrl: string;
|
|
10
|
+
userInfoUrl: string;
|
|
11
|
+
}
|
|
12
|
+
type ProviderInstanceOptions = Pick<ProviderOptions, 'clientId' | 'clientSecret'>;
|
|
13
|
+
interface TokensResponse {
|
|
14
|
+
access_token: string;
|
|
15
|
+
refresh_token?: string;
|
|
16
|
+
expires_in?: number;
|
|
17
|
+
refresh_token_expires_in?: number;
|
|
18
|
+
}
|
|
19
|
+
interface ExtractUserResponse {
|
|
20
|
+
id: string;
|
|
21
|
+
avatarUrl: string;
|
|
22
|
+
email: string;
|
|
23
|
+
provider: string;
|
|
24
|
+
}
|
|
25
|
+
interface UserInfo extends ExtractUserResponse {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
expiresIn?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'express-serve-static-core' {
|
|
32
|
+
interface Request {
|
|
33
|
+
providerInfo?: UserInfo;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class BaseProvider {
|
|
38
|
+
protected readonly options: ProviderOptions;
|
|
39
|
+
BASE_URL: string;
|
|
40
|
+
constructor(options: ProviderOptions);
|
|
41
|
+
getAuthUrl(): string;
|
|
42
|
+
getRedirectUrl(): string;
|
|
43
|
+
extractUserInfo(data: any): ExtractUserResponse;
|
|
44
|
+
getUserFromCode(code: string): Promise<{
|
|
45
|
+
accessToken: string;
|
|
46
|
+
refreshToken: string | undefined;
|
|
47
|
+
expiresIn: number | undefined;
|
|
48
|
+
id: string;
|
|
49
|
+
avatarUrl: string;
|
|
50
|
+
email: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
}>;
|
|
53
|
+
set BaseUrl(url: string);
|
|
54
|
+
get BaseUrl(): string;
|
|
55
|
+
get name(): string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ProviderModuleOptions {
|
|
59
|
+
baseUrl: string;
|
|
60
|
+
providers: BaseProvider[];
|
|
61
|
+
}
|
|
62
|
+
interface ProviderModuleAsyncOptions extends Omit<FactoryProvider<ProviderModuleOptions>, 'provide'> {
|
|
63
|
+
imports: ModuleMetadata['imports'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class ProviderModule {
|
|
67
|
+
static register(options: ProviderModuleOptions): DynamicModule;
|
|
68
|
+
static registerAsync(options: ProviderModuleAsyncOptions): DynamicModule;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare const OAuthUrl: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
72
|
+
|
|
73
|
+
declare const OAuthCallback: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
74
|
+
|
|
75
|
+
export { BaseProvider, type ExtractUserResponse, OAuthCallback, OAuthUrl, type ProviderInstanceOptions, ProviderModule, type ProviderOptions, type TokensResponse, type UserInfo };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { FactoryProvider, ModuleMetadata, DynamicModule } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
interface ProviderOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
scopes: string[];
|
|
8
|
+
authUrl: string;
|
|
9
|
+
tokensUrl: string;
|
|
10
|
+
userInfoUrl: string;
|
|
11
|
+
}
|
|
12
|
+
type ProviderInstanceOptions = Pick<ProviderOptions, 'clientId' | 'clientSecret'>;
|
|
13
|
+
interface TokensResponse {
|
|
14
|
+
access_token: string;
|
|
15
|
+
refresh_token?: string;
|
|
16
|
+
expires_in?: number;
|
|
17
|
+
refresh_token_expires_in?: number;
|
|
18
|
+
}
|
|
19
|
+
interface ExtractUserResponse {
|
|
20
|
+
id: string;
|
|
21
|
+
avatarUrl: string;
|
|
22
|
+
email: string;
|
|
23
|
+
provider: string;
|
|
24
|
+
}
|
|
25
|
+
interface UserInfo extends ExtractUserResponse {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
expiresIn?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'express-serve-static-core' {
|
|
32
|
+
interface Request {
|
|
33
|
+
providerInfo?: UserInfo;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class BaseProvider {
|
|
38
|
+
protected readonly options: ProviderOptions;
|
|
39
|
+
BASE_URL: string;
|
|
40
|
+
constructor(options: ProviderOptions);
|
|
41
|
+
getAuthUrl(): string;
|
|
42
|
+
getRedirectUrl(): string;
|
|
43
|
+
extractUserInfo(data: any): ExtractUserResponse;
|
|
44
|
+
getUserFromCode(code: string): Promise<{
|
|
45
|
+
accessToken: string;
|
|
46
|
+
refreshToken: string | undefined;
|
|
47
|
+
expiresIn: number | undefined;
|
|
48
|
+
id: string;
|
|
49
|
+
avatarUrl: string;
|
|
50
|
+
email: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
}>;
|
|
53
|
+
set BaseUrl(url: string);
|
|
54
|
+
get BaseUrl(): string;
|
|
55
|
+
get name(): string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ProviderModuleOptions {
|
|
59
|
+
baseUrl: string;
|
|
60
|
+
providers: BaseProvider[];
|
|
61
|
+
}
|
|
62
|
+
interface ProviderModuleAsyncOptions extends Omit<FactoryProvider<ProviderModuleOptions>, 'provide'> {
|
|
63
|
+
imports: ModuleMetadata['imports'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class ProviderModule {
|
|
67
|
+
static register(options: ProviderModuleOptions): DynamicModule;
|
|
68
|
+
static registerAsync(options: ProviderModuleAsyncOptions): DynamicModule;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare const OAuthUrl: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
72
|
+
|
|
73
|
+
declare const OAuthCallback: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
74
|
+
|
|
75
|
+
export { BaseProvider, type ExtractUserResponse, OAuthCallback, OAuthUrl, type ProviderInstanceOptions, ProviderModule, type ProviderOptions, type TokensResponse, type UserInfo };
|