@authorizerdev/authorizer-js 1.2.0-beta.0 → 1.2.0
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/README.md +21 -21
- package/lib/authorizer.min.js +2 -0
- package/lib/authorizer.min.js.map +1 -0
- package/lib/cjs/constants.d.ts +3 -0
- package/lib/cjs/index.d.ts +29 -0
- package/lib/cjs/index.js +495 -0
- package/lib/cjs/index.js.map +1 -0
- package/{dist/index.d.ts → lib/cjs/types.d.ts} +28 -58
- package/lib/cjs/utils.d.ts +13 -0
- package/lib/constants.d.ts +3 -0
- package/lib/esm/constants.d.ts +3 -0
- package/lib/esm/index.d.ts +29 -0
- package/lib/esm/index.js +487 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types.d.ts +185 -0
- package/lib/esm/utils.d.ts +13 -0
- package/lib/index.d.ts +29 -0
- package/lib/types.d.ts +185 -0
- package/lib/utils.d.ts +13 -0
- package/package.json +10 -25
- package/src/constants.ts +3 -0
- package/src/index.ts +499 -0
- package/src/types.ts +203 -0
- package/src/utils.ts +155 -0
- package/dist/index.global.js +0 -19
- package/dist/index.global.js.map +0 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -14
- package/dist/index.mjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
interface ConfigType {
|
|
1
|
+
export interface ConfigType {
|
|
2
2
|
authorizerURL: string;
|
|
3
3
|
redirectURL: string;
|
|
4
4
|
clientID: string;
|
|
5
5
|
extraHeaders?: Record<string, string>;
|
|
6
6
|
}
|
|
7
|
-
interface User {
|
|
7
|
+
export interface User {
|
|
8
8
|
id: string;
|
|
9
9
|
email: string;
|
|
10
10
|
preferred_username: string;
|
|
@@ -24,7 +24,7 @@ interface User {
|
|
|
24
24
|
updated_at: number;
|
|
25
25
|
is_multi_factor_auth_enabled?: boolean;
|
|
26
26
|
}
|
|
27
|
-
interface AuthToken {
|
|
27
|
+
export interface AuthToken {
|
|
28
28
|
message?: string;
|
|
29
29
|
access_token: string;
|
|
30
30
|
expires_in: number;
|
|
@@ -33,18 +33,18 @@ interface AuthToken {
|
|
|
33
33
|
user?: User;
|
|
34
34
|
should_show_otp_screen?: boolean;
|
|
35
35
|
}
|
|
36
|
-
interface Response {
|
|
36
|
+
export interface Response {
|
|
37
37
|
message: string;
|
|
38
38
|
}
|
|
39
|
-
type Headers = Record<string, string>;
|
|
40
|
-
interface LoginInput {
|
|
39
|
+
export type Headers = Record<string, string>;
|
|
40
|
+
export interface LoginInput {
|
|
41
41
|
email: string;
|
|
42
42
|
password: string;
|
|
43
43
|
roles?: string[];
|
|
44
44
|
scope?: string[];
|
|
45
45
|
state?: string;
|
|
46
46
|
}
|
|
47
|
-
interface SignupInput {
|
|
47
|
+
export interface SignupInput {
|
|
48
48
|
email: string;
|
|
49
49
|
password: string;
|
|
50
50
|
confirm_password: string;
|
|
@@ -62,31 +62,31 @@ interface SignupInput {
|
|
|
62
62
|
is_multi_factor_auth_enabled?: boolean;
|
|
63
63
|
state?: string;
|
|
64
64
|
}
|
|
65
|
-
interface MagicLinkLoginInput {
|
|
65
|
+
export interface MagicLinkLoginInput {
|
|
66
66
|
email: string;
|
|
67
67
|
roles?: string[];
|
|
68
68
|
scopes?: string[];
|
|
69
69
|
state?: string;
|
|
70
70
|
redirect_uri?: string;
|
|
71
71
|
}
|
|
72
|
-
interface VerifyEmailInput {
|
|
72
|
+
export interface VerifyEmailInput {
|
|
73
73
|
token: string;
|
|
74
74
|
state?: string;
|
|
75
75
|
}
|
|
76
|
-
interface VerifyOtpInput {
|
|
76
|
+
export interface VerifyOtpInput {
|
|
77
77
|
email: string;
|
|
78
78
|
otp: string;
|
|
79
79
|
state?: string;
|
|
80
80
|
}
|
|
81
|
-
interface ResendOtpInput {
|
|
81
|
+
export interface ResendOtpInput {
|
|
82
82
|
email: string;
|
|
83
83
|
}
|
|
84
|
-
interface GraphqlQueryInput {
|
|
84
|
+
export interface GraphqlQueryInput {
|
|
85
85
|
query: string;
|
|
86
86
|
variables?: Record<string, any>;
|
|
87
87
|
headers?: Headers;
|
|
88
88
|
}
|
|
89
|
-
interface MetaData {
|
|
89
|
+
export interface MetaData {
|
|
90
90
|
version: string;
|
|
91
91
|
client_id: string;
|
|
92
92
|
is_google_login_enabled: boolean;
|
|
@@ -102,7 +102,7 @@ interface MetaData {
|
|
|
102
102
|
is_sign_up_enabled: boolean;
|
|
103
103
|
is_strong_password_enabled: boolean;
|
|
104
104
|
}
|
|
105
|
-
interface UpdateProfileInput {
|
|
105
|
+
export interface UpdateProfileInput {
|
|
106
106
|
old_password?: string;
|
|
107
107
|
new_password?: string;
|
|
108
108
|
confirm_new_password?: string;
|
|
@@ -117,99 +117,69 @@ interface UpdateProfileInput {
|
|
|
117
117
|
picture?: string;
|
|
118
118
|
is_multi_factor_auth_enabled?: boolean;
|
|
119
119
|
}
|
|
120
|
-
interface ForgotPasswordInput {
|
|
120
|
+
export interface ForgotPasswordInput {
|
|
121
121
|
email: string;
|
|
122
122
|
state?: string;
|
|
123
123
|
redirect_uri?: string;
|
|
124
124
|
}
|
|
125
|
-
interface ResetPasswordInput {
|
|
125
|
+
export interface ResetPasswordInput {
|
|
126
126
|
token: string;
|
|
127
127
|
password: string;
|
|
128
128
|
confirm_password: string;
|
|
129
129
|
}
|
|
130
|
-
interface SessionQueryInput {
|
|
130
|
+
export interface SessionQueryInput {
|
|
131
131
|
roles?: string[];
|
|
132
132
|
}
|
|
133
|
-
interface IsValidJWTQueryInput {
|
|
133
|
+
export interface IsValidJWTQueryInput {
|
|
134
134
|
jwt: string;
|
|
135
135
|
roles?: string[];
|
|
136
136
|
}
|
|
137
|
-
interface ValidJWTResponse {
|
|
137
|
+
export interface ValidJWTResponse {
|
|
138
138
|
valid: string;
|
|
139
139
|
message: string;
|
|
140
140
|
}
|
|
141
|
-
declare enum OAuthProviders {
|
|
141
|
+
export declare enum OAuthProviders {
|
|
142
142
|
Apple = "apple",
|
|
143
143
|
Github = "github",
|
|
144
144
|
Google = "google",
|
|
145
145
|
Facebook = "facebook",
|
|
146
146
|
LinkedIn = "linkedin"
|
|
147
147
|
}
|
|
148
|
-
declare enum ResponseTypes {
|
|
148
|
+
export declare enum ResponseTypes {
|
|
149
149
|
Code = "code",
|
|
150
150
|
Token = "token"
|
|
151
151
|
}
|
|
152
|
-
interface AuthorizeInput {
|
|
152
|
+
export interface AuthorizeInput {
|
|
153
153
|
response_type: ResponseTypes;
|
|
154
154
|
use_refresh_token?: boolean;
|
|
155
155
|
response_mode?: string;
|
|
156
156
|
}
|
|
157
|
-
interface AuthorizeResponse {
|
|
157
|
+
export interface AuthorizeResponse {
|
|
158
158
|
state: string;
|
|
159
159
|
code?: string;
|
|
160
160
|
error?: string;
|
|
161
161
|
error_description?: string;
|
|
162
162
|
}
|
|
163
|
-
interface RevokeTokenInput {
|
|
163
|
+
export interface RevokeTokenInput {
|
|
164
164
|
refresh_token: string;
|
|
165
165
|
}
|
|
166
|
-
interface GetTokenInput {
|
|
166
|
+
export interface GetTokenInput {
|
|
167
167
|
code?: string;
|
|
168
168
|
grant_type?: string;
|
|
169
169
|
refresh_token?: string;
|
|
170
170
|
}
|
|
171
|
-
interface GetTokenResponse {
|
|
171
|
+
export interface GetTokenResponse {
|
|
172
172
|
access_token: string;
|
|
173
173
|
expires_in: number;
|
|
174
174
|
id_token: string;
|
|
175
175
|
refresh_token?: string;
|
|
176
176
|
}
|
|
177
|
-
interface ValidateJWTTokenInput {
|
|
177
|
+
export interface ValidateJWTTokenInput {
|
|
178
178
|
token_type: 'access_token' | 'id_token' | 'refresh_token';
|
|
179
179
|
token: string;
|
|
180
180
|
roles?: string[];
|
|
181
181
|
}
|
|
182
|
-
interface ValidateJWTTokenResponse {
|
|
182
|
+
export interface ValidateJWTTokenResponse {
|
|
183
183
|
is_valid: boolean;
|
|
184
184
|
claims: Record<string, any>;
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
declare class Authorizer {
|
|
188
|
-
config: ConfigType;
|
|
189
|
-
codeVerifier: string;
|
|
190
|
-
constructor(config: ConfigType);
|
|
191
|
-
authorize: (data: AuthorizeInput) => Promise<GetTokenResponse | AuthorizeResponse | undefined>;
|
|
192
|
-
browserLogin: () => Promise<AuthToken | void>;
|
|
193
|
-
forgotPassword: (data: ForgotPasswordInput) => Promise<Response | void>;
|
|
194
|
-
getMetaData: () => Promise<MetaData | void>;
|
|
195
|
-
getProfile: (headers?: Headers) => Promise<User | void>;
|
|
196
|
-
getSession: (headers?: Headers, params?: SessionQueryInput) => Promise<AuthToken>;
|
|
197
|
-
getToken: (data: GetTokenInput) => Promise<GetTokenResponse>;
|
|
198
|
-
graphqlQuery: (data: GraphqlQueryInput) => Promise<any>;
|
|
199
|
-
login: (data: LoginInput) => Promise<AuthToken | void>;
|
|
200
|
-
logout: (headers?: Headers) => Promise<Response | void>;
|
|
201
|
-
magicLinkLogin: (data: MagicLinkLoginInput) => Promise<Response>;
|
|
202
|
-
oauthLogin: (oauthProvider: string, roles?: string[], redirect_uri?: string, state?: string) => Promise<void>;
|
|
203
|
-
resendOtp: (data: ResendOtpInput) => Promise<Response | void>;
|
|
204
|
-
resetPassword: (data: ResetPasswordInput) => Promise<Response | void>;
|
|
205
|
-
revokeToken: (data: {
|
|
206
|
-
refresh_token: string;
|
|
207
|
-
}) => Promise<any>;
|
|
208
|
-
signup: (data: SignupInput) => Promise<AuthToken | void>;
|
|
209
|
-
updateProfile: (data: UpdateProfileInput, headers?: Headers) => Promise<Response | void>;
|
|
210
|
-
validateJWTToken: (params?: ValidateJWTTokenInput) => Promise<ValidateJWTTokenResponse>;
|
|
211
|
-
verifyEmail: (data: VerifyEmailInput) => Promise<AuthToken | void>;
|
|
212
|
-
verifyOtp: (data: VerifyOtpInput) => Promise<AuthToken | void>;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export { AuthToken, AuthorizeInput, AuthorizeResponse, Authorizer, ConfigType, ForgotPasswordInput, GetTokenInput, GetTokenResponse, GraphqlQueryInput, Headers, IsValidJWTQueryInput, LoginInput, MagicLinkLoginInput, MetaData, OAuthProviders, ResendOtpInput, ResetPasswordInput, Response, ResponseTypes, RevokeTokenInput, SessionQueryInput, SignupInput, UpdateProfileInput, User, ValidJWTResponse, ValidateJWTTokenInput, ValidateJWTTokenResponse, VerifyEmailInput, VerifyOtpInput };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthorizeResponse } from './types';
|
|
2
|
+
export declare const hasWindow: () => boolean;
|
|
3
|
+
export declare const trimURL: (url: string) => string;
|
|
4
|
+
export declare const getCrypto: () => Crypto | null;
|
|
5
|
+
export declare const getCryptoSubtle: () => any;
|
|
6
|
+
export declare const createRandomString: () => string;
|
|
7
|
+
export declare const encode: (value: string) => string;
|
|
8
|
+
export declare const decode: (value: string) => string;
|
|
9
|
+
export declare const createQueryParams: (params: any) => string;
|
|
10
|
+
export declare const sha256: (s: string) => Promise<any>;
|
|
11
|
+
export declare const urlDecodeB64: (input: string) => string;
|
|
12
|
+
export declare const bufferToBase64UrlEncoded: (input: number[] | Uint8Array) => string;
|
|
13
|
+
export declare const executeIframe: (authorizeUrl: string, eventOrigin: string, timeoutInSeconds?: number) => Promise<AuthorizeResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Types from './types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export declare class Authorizer {
|
|
4
|
+
config: Types.ConfigType;
|
|
5
|
+
codeVerifier: string;
|
|
6
|
+
constructor(config: Types.ConfigType);
|
|
7
|
+
authorize: (data: Types.AuthorizeInput) => Promise<Types.AuthorizeResponse | Types.GetTokenResponse | undefined>;
|
|
8
|
+
browserLogin: () => Promise<Types.AuthToken | void>;
|
|
9
|
+
forgotPassword: (data: Types.ForgotPasswordInput) => Promise<Types.Response | void>;
|
|
10
|
+
getMetaData: () => Promise<Types.MetaData | void>;
|
|
11
|
+
getProfile: (headers?: Types.Headers) => Promise<Types.User | void>;
|
|
12
|
+
getSession: (headers?: Types.Headers, params?: Types.SessionQueryInput) => Promise<Types.AuthToken>;
|
|
13
|
+
getToken: (data: Types.GetTokenInput) => Promise<Types.GetTokenResponse>;
|
|
14
|
+
graphqlQuery: (data: Types.GraphqlQueryInput) => Promise<any>;
|
|
15
|
+
login: (data: Types.LoginInput) => Promise<Types.AuthToken | void>;
|
|
16
|
+
logout: (headers?: Types.Headers) => Promise<Types.Response | void>;
|
|
17
|
+
magicLinkLogin: (data: Types.MagicLinkLoginInput) => Promise<Types.Response>;
|
|
18
|
+
oauthLogin: (oauthProvider: string, roles?: string[], redirect_uri?: string, state?: string) => Promise<void>;
|
|
19
|
+
resendOtp: (data: Types.ResendOtpInput) => Promise<Types.Response | void>;
|
|
20
|
+
resetPassword: (data: Types.ResetPasswordInput) => Promise<Types.Response | void>;
|
|
21
|
+
revokeToken: (data: {
|
|
22
|
+
refresh_token: string;
|
|
23
|
+
}) => Promise<any>;
|
|
24
|
+
signup: (data: Types.SignupInput) => Promise<Types.AuthToken | void>;
|
|
25
|
+
updateProfile: (data: Types.UpdateProfileInput, headers?: Types.Headers) => Promise<Types.Response | void>;
|
|
26
|
+
validateJWTToken: (params?: Types.ValidateJWTTokenInput) => Promise<Types.ValidateJWTTokenResponse>;
|
|
27
|
+
verifyEmail: (data: Types.VerifyEmailInput) => Promise<Types.AuthToken | void>;
|
|
28
|
+
verifyOtp: (data: Types.VerifyOtpInput) => Promise<Types.AuthToken | void>;
|
|
29
|
+
}
|