@authorizerdev/authorizer-js 1.1.5 → 1.1.6
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 +4 -0
- package/lib/authorizer.min.js +1 -1
- package/lib/authorizer.min.js.map +1 -1
- package/lib/cjs/index.js +65 -89
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +50 -50
- package/lib/esm/index.js +65 -89
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +50 -50
- package/lib/types.d.ts +50 -50
- package/package.json +7 -3
- package/src/constants.ts +3 -3
- package/src/index.ts +464 -458
- package/src/types.ts +198 -198
- package/src/utils.ts +125 -127
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ConfigType {
|
|
2
2
|
authorizerURL: string;
|
|
3
3
|
redirectURL: string;
|
|
4
4
|
clientID: string;
|
|
5
5
|
extraHeaders?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export interface User {
|
|
8
8
|
id: string;
|
|
9
9
|
email: string;
|
|
10
10
|
preferred_username: string;
|
|
@@ -23,8 +23,8 @@ export type User = {
|
|
|
23
23
|
created_at: number;
|
|
24
24
|
updated_at: number;
|
|
25
25
|
is_multi_factor_auth_enabled?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export
|
|
26
|
+
}
|
|
27
|
+
export interface AuthToken {
|
|
28
28
|
message?: string;
|
|
29
29
|
access_token: string;
|
|
30
30
|
expires_in: number;
|
|
@@ -32,19 +32,19 @@ export type AuthToken = {
|
|
|
32
32
|
refresh_token?: string;
|
|
33
33
|
user?: User;
|
|
34
34
|
should_show_otp_screen?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface Response {
|
|
37
37
|
message: string;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
export type Headers = Record<string, string>;
|
|
40
|
-
export
|
|
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
|
-
}
|
|
47
|
-
export
|
|
46
|
+
}
|
|
47
|
+
export interface SignupInput {
|
|
48
48
|
email: string;
|
|
49
49
|
password: string;
|
|
50
50
|
confirm_password: string;
|
|
@@ -61,32 +61,32 @@ export type SignupInput = {
|
|
|
61
61
|
redirect_uri?: string;
|
|
62
62
|
is_multi_factor_auth_enabled?: boolean;
|
|
63
63
|
state?: string;
|
|
64
|
-
}
|
|
65
|
-
export
|
|
64
|
+
}
|
|
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
|
-
}
|
|
72
|
-
export
|
|
71
|
+
}
|
|
72
|
+
export interface VerifyEmailInput {
|
|
73
73
|
token: string;
|
|
74
74
|
state?: string;
|
|
75
|
-
}
|
|
76
|
-
export
|
|
75
|
+
}
|
|
76
|
+
export interface VerifyOtpInput {
|
|
77
77
|
email: string;
|
|
78
78
|
otp: string;
|
|
79
79
|
state?: string;
|
|
80
|
-
}
|
|
81
|
-
export
|
|
80
|
+
}
|
|
81
|
+
export interface ResendOtpInput {
|
|
82
82
|
email: string;
|
|
83
|
-
}
|
|
84
|
-
export
|
|
83
|
+
}
|
|
84
|
+
export interface GraphqlQueryInput {
|
|
85
85
|
query: string;
|
|
86
86
|
variables?: Record<string, any>;
|
|
87
87
|
headers?: Headers;
|
|
88
|
-
}
|
|
89
|
-
export
|
|
88
|
+
}
|
|
89
|
+
export interface MetaData {
|
|
90
90
|
version: string;
|
|
91
91
|
client_id: string;
|
|
92
92
|
is_google_login_enabled: boolean;
|
|
@@ -101,8 +101,8 @@ export type MetaData = {
|
|
|
101
101
|
is_magic_link_login_enabled: boolean;
|
|
102
102
|
is_sign_up_enabled: boolean;
|
|
103
103
|
is_strong_password_enabled: boolean;
|
|
104
|
-
}
|
|
105
|
-
export
|
|
104
|
+
}
|
|
105
|
+
export interface UpdateProfileInput {
|
|
106
106
|
old_password?: string;
|
|
107
107
|
new_password?: string;
|
|
108
108
|
confirm_new_password?: string;
|
|
@@ -116,28 +116,28 @@ export type UpdateProfileInput = {
|
|
|
116
116
|
phone_number?: string;
|
|
117
117
|
picture?: string;
|
|
118
118
|
is_multi_factor_auth_enabled?: boolean;
|
|
119
|
-
}
|
|
120
|
-
export
|
|
119
|
+
}
|
|
120
|
+
export interface ForgotPasswordInput {
|
|
121
121
|
email: string;
|
|
122
122
|
state?: string;
|
|
123
123
|
redirect_uri?: string;
|
|
124
|
-
}
|
|
125
|
-
export
|
|
124
|
+
}
|
|
125
|
+
export interface ResetPasswordInput {
|
|
126
126
|
token: string;
|
|
127
127
|
password: string;
|
|
128
128
|
confirm_password: string;
|
|
129
|
-
}
|
|
130
|
-
export
|
|
129
|
+
}
|
|
130
|
+
export interface SessionQueryInput {
|
|
131
131
|
roles?: string[];
|
|
132
|
-
}
|
|
133
|
-
export
|
|
132
|
+
}
|
|
133
|
+
export interface IsValidJWTQueryInput {
|
|
134
134
|
jwt: string;
|
|
135
135
|
roles?: string[];
|
|
136
|
-
}
|
|
137
|
-
export
|
|
136
|
+
}
|
|
137
|
+
export interface ValidJWTResponse {
|
|
138
138
|
valid: string;
|
|
139
139
|
message: string;
|
|
140
|
-
}
|
|
140
|
+
}
|
|
141
141
|
export declare enum OAuthProviders {
|
|
142
142
|
Apple = "apple",
|
|
143
143
|
Github = "github",
|
|
@@ -149,37 +149,37 @@ export declare enum ResponseTypes {
|
|
|
149
149
|
Code = "code",
|
|
150
150
|
Token = "token"
|
|
151
151
|
}
|
|
152
|
-
export
|
|
152
|
+
export interface AuthorizeInput {
|
|
153
153
|
response_type: ResponseTypes;
|
|
154
154
|
use_refresh_token?: boolean;
|
|
155
155
|
response_mode?: string;
|
|
156
|
-
}
|
|
157
|
-
export
|
|
156
|
+
}
|
|
157
|
+
export interface AuthorizeResponse {
|
|
158
158
|
state: string;
|
|
159
159
|
code?: string;
|
|
160
160
|
error?: string;
|
|
161
161
|
error_description?: string;
|
|
162
|
-
}
|
|
163
|
-
export
|
|
162
|
+
}
|
|
163
|
+
export interface RevokeTokenInput {
|
|
164
164
|
refresh_token: string;
|
|
165
|
-
}
|
|
166
|
-
export
|
|
165
|
+
}
|
|
166
|
+
export interface GetTokenInput {
|
|
167
167
|
code?: string;
|
|
168
168
|
grant_type?: string;
|
|
169
169
|
refresh_token?: string;
|
|
170
|
-
}
|
|
171
|
-
export
|
|
170
|
+
}
|
|
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
|
-
}
|
|
177
|
-
export
|
|
176
|
+
}
|
|
177
|
+
export interface ValidateJWTTokenInput {
|
|
178
178
|
token_type: 'access_token' | 'id_token' | 'refresh_token';
|
|
179
179
|
token: string;
|
|
180
180
|
roles?: string[];
|
|
181
|
-
}
|
|
182
|
-
export
|
|
181
|
+
}
|
|
182
|
+
export interface ValidateJWTTokenResponse {
|
|
183
183
|
is_valid: boolean;
|
|
184
184
|
claims: Record<string, any>;
|
|
185
|
-
}
|
|
185
|
+
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ConfigType {
|
|
2
2
|
authorizerURL: string;
|
|
3
3
|
redirectURL: string;
|
|
4
4
|
clientID: string;
|
|
5
5
|
extraHeaders?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export interface User {
|
|
8
8
|
id: string;
|
|
9
9
|
email: string;
|
|
10
10
|
preferred_username: string;
|
|
@@ -23,8 +23,8 @@ export type User = {
|
|
|
23
23
|
created_at: number;
|
|
24
24
|
updated_at: number;
|
|
25
25
|
is_multi_factor_auth_enabled?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export
|
|
26
|
+
}
|
|
27
|
+
export interface AuthToken {
|
|
28
28
|
message?: string;
|
|
29
29
|
access_token: string;
|
|
30
30
|
expires_in: number;
|
|
@@ -32,19 +32,19 @@ export type AuthToken = {
|
|
|
32
32
|
refresh_token?: string;
|
|
33
33
|
user?: User;
|
|
34
34
|
should_show_otp_screen?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface Response {
|
|
37
37
|
message: string;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
export type Headers = Record<string, string>;
|
|
40
|
-
export
|
|
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
|
-
}
|
|
47
|
-
export
|
|
46
|
+
}
|
|
47
|
+
export interface SignupInput {
|
|
48
48
|
email: string;
|
|
49
49
|
password: string;
|
|
50
50
|
confirm_password: string;
|
|
@@ -61,32 +61,32 @@ export type SignupInput = {
|
|
|
61
61
|
redirect_uri?: string;
|
|
62
62
|
is_multi_factor_auth_enabled?: boolean;
|
|
63
63
|
state?: string;
|
|
64
|
-
}
|
|
65
|
-
export
|
|
64
|
+
}
|
|
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
|
-
}
|
|
72
|
-
export
|
|
71
|
+
}
|
|
72
|
+
export interface VerifyEmailInput {
|
|
73
73
|
token: string;
|
|
74
74
|
state?: string;
|
|
75
|
-
}
|
|
76
|
-
export
|
|
75
|
+
}
|
|
76
|
+
export interface VerifyOtpInput {
|
|
77
77
|
email: string;
|
|
78
78
|
otp: string;
|
|
79
79
|
state?: string;
|
|
80
|
-
}
|
|
81
|
-
export
|
|
80
|
+
}
|
|
81
|
+
export interface ResendOtpInput {
|
|
82
82
|
email: string;
|
|
83
|
-
}
|
|
84
|
-
export
|
|
83
|
+
}
|
|
84
|
+
export interface GraphqlQueryInput {
|
|
85
85
|
query: string;
|
|
86
86
|
variables?: Record<string, any>;
|
|
87
87
|
headers?: Headers;
|
|
88
|
-
}
|
|
89
|
-
export
|
|
88
|
+
}
|
|
89
|
+
export interface MetaData {
|
|
90
90
|
version: string;
|
|
91
91
|
client_id: string;
|
|
92
92
|
is_google_login_enabled: boolean;
|
|
@@ -101,8 +101,8 @@ export type MetaData = {
|
|
|
101
101
|
is_magic_link_login_enabled: boolean;
|
|
102
102
|
is_sign_up_enabled: boolean;
|
|
103
103
|
is_strong_password_enabled: boolean;
|
|
104
|
-
}
|
|
105
|
-
export
|
|
104
|
+
}
|
|
105
|
+
export interface UpdateProfileInput {
|
|
106
106
|
old_password?: string;
|
|
107
107
|
new_password?: string;
|
|
108
108
|
confirm_new_password?: string;
|
|
@@ -116,28 +116,28 @@ export type UpdateProfileInput = {
|
|
|
116
116
|
phone_number?: string;
|
|
117
117
|
picture?: string;
|
|
118
118
|
is_multi_factor_auth_enabled?: boolean;
|
|
119
|
-
}
|
|
120
|
-
export
|
|
119
|
+
}
|
|
120
|
+
export interface ForgotPasswordInput {
|
|
121
121
|
email: string;
|
|
122
122
|
state?: string;
|
|
123
123
|
redirect_uri?: string;
|
|
124
|
-
}
|
|
125
|
-
export
|
|
124
|
+
}
|
|
125
|
+
export interface ResetPasswordInput {
|
|
126
126
|
token: string;
|
|
127
127
|
password: string;
|
|
128
128
|
confirm_password: string;
|
|
129
|
-
}
|
|
130
|
-
export
|
|
129
|
+
}
|
|
130
|
+
export interface SessionQueryInput {
|
|
131
131
|
roles?: string[];
|
|
132
|
-
}
|
|
133
|
-
export
|
|
132
|
+
}
|
|
133
|
+
export interface IsValidJWTQueryInput {
|
|
134
134
|
jwt: string;
|
|
135
135
|
roles?: string[];
|
|
136
|
-
}
|
|
137
|
-
export
|
|
136
|
+
}
|
|
137
|
+
export interface ValidJWTResponse {
|
|
138
138
|
valid: string;
|
|
139
139
|
message: string;
|
|
140
|
-
}
|
|
140
|
+
}
|
|
141
141
|
export declare enum OAuthProviders {
|
|
142
142
|
Apple = "apple",
|
|
143
143
|
Github = "github",
|
|
@@ -149,37 +149,37 @@ export declare enum ResponseTypes {
|
|
|
149
149
|
Code = "code",
|
|
150
150
|
Token = "token"
|
|
151
151
|
}
|
|
152
|
-
export
|
|
152
|
+
export interface AuthorizeInput {
|
|
153
153
|
response_type: ResponseTypes;
|
|
154
154
|
use_refresh_token?: boolean;
|
|
155
155
|
response_mode?: string;
|
|
156
|
-
}
|
|
157
|
-
export
|
|
156
|
+
}
|
|
157
|
+
export interface AuthorizeResponse {
|
|
158
158
|
state: string;
|
|
159
159
|
code?: string;
|
|
160
160
|
error?: string;
|
|
161
161
|
error_description?: string;
|
|
162
|
-
}
|
|
163
|
-
export
|
|
162
|
+
}
|
|
163
|
+
export interface RevokeTokenInput {
|
|
164
164
|
refresh_token: string;
|
|
165
|
-
}
|
|
166
|
-
export
|
|
165
|
+
}
|
|
166
|
+
export interface GetTokenInput {
|
|
167
167
|
code?: string;
|
|
168
168
|
grant_type?: string;
|
|
169
169
|
refresh_token?: string;
|
|
170
|
-
}
|
|
171
|
-
export
|
|
170
|
+
}
|
|
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
|
-
}
|
|
177
|
-
export
|
|
176
|
+
}
|
|
177
|
+
export interface ValidateJWTTokenInput {
|
|
178
178
|
token_type: 'access_token' | 'id_token' | 'refresh_token';
|
|
179
179
|
token: string;
|
|
180
180
|
roles?: string[];
|
|
181
|
-
}
|
|
182
|
-
export
|
|
181
|
+
}
|
|
182
|
+
export interface ValidateJWTTokenResponse {
|
|
183
183
|
is_valid: boolean;
|
|
184
184
|
claims: Record<string, any>;
|
|
185
|
-
}
|
|
185
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
2
|
+
"version": "1.1.6",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"typings": "lib/cjs/index.d.ts",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
"name": "@authorizerdev/authorizer-js",
|
|
20
20
|
"author": "Lakhan Samani",
|
|
21
21
|
"devDependencies": {
|
|
22
|
+
"@antfu/eslint-config": "^0.35.3",
|
|
22
23
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
23
24
|
"@rollup/plugin-typescript": "^8.2.5",
|
|
24
25
|
"@types/node-fetch": "^2.5.12",
|
|
26
|
+
"bumpp": "^9.0.0",
|
|
27
|
+
"eslint": "^8.35.0",
|
|
25
28
|
"husky": "^7.0.1",
|
|
26
29
|
"jest": "^27.0.6",
|
|
27
|
-
"prettier": "2.3.2",
|
|
28
30
|
"rimraf": "^2.7.1",
|
|
29
31
|
"rollup": "^2.56.0",
|
|
30
32
|
"rollup-plugin-filesize": "^9.1.1",
|
|
@@ -42,6 +44,8 @@
|
|
|
42
44
|
"ts-types": "tsc --emitDeclarationOnly --outDir lib",
|
|
43
45
|
"build": "npm run clean && rollup --config rollup.config.js --environment INCLUDE_DEPS,BUILD:production",
|
|
44
46
|
"test": "npm run build && jest --testTimeout=20000 --runInBand",
|
|
45
|
-
"
|
|
47
|
+
"release": "pnpm build && bumpp --commit --push --tag && pnpm publish",
|
|
48
|
+
"lint": "eslint --ext .ts,.tsx,.js,.jsx .",
|
|
49
|
+
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx . --fix"
|
|
46
50
|
}
|
|
47
51
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60
|
|
2
|
-
export const CLEANUP_IFRAME_TIMEOUT_IN_SECONDS = 2
|
|
3
|
-
export const AUTHORIZE_IFRAME_TIMEOUT = 5
|
|
1
|
+
export const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60
|
|
2
|
+
export const CLEANUP_IFRAME_TIMEOUT_IN_SECONDS = 2
|
|
3
|
+
export const AUTHORIZE_IFRAME_TIMEOUT = 5
|