@authorizerdev/authorizer-js 1.1.5 → 1.2.0-beta.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 +25 -21
- package/{lib/cjs/types.d.ts → dist/index.d.ts} +83 -53
- package/dist/index.global.js +19 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +31 -12
- package/lib/authorizer.min.js +0 -2
- package/lib/authorizer.min.js.map +0 -1
- package/lib/cjs/constants.d.ts +0 -3
- package/lib/cjs/index.d.ts +0 -29
- package/lib/cjs/index.js +0 -519
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/utils.d.ts +0 -13
- package/lib/constants.d.ts +0 -3
- package/lib/esm/constants.d.ts +0 -3
- package/lib/esm/index.d.ts +0 -29
- package/lib/esm/index.js +0 -511
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/types.d.ts +0 -185
- package/lib/esm/utils.d.ts +0 -13
- package/lib/index.d.ts +0 -29
- package/lib/types.d.ts +0 -185
- package/lib/utils.d.ts +0 -13
- package/src/constants.ts +0 -3
- package/src/index.ts +0 -493
- package/src/types.ts +0 -203
- package/src/utils.ts +0 -157
package/README.md
CHANGED
|
@@ -18,17 +18,17 @@ All the above versions require `Authorizer` instance to be instantiated and used
|
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
const authRef = new Authorizer({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
21
|
+
authorizerURL: 'https://app.herokuapp.com',
|
|
22
|
+
redirectURL: window.location.origin,
|
|
23
|
+
})
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## IIFE
|
|
27
27
|
|
|
28
28
|
- Step 1: Load Javascript using CDN
|
|
29
29
|
|
|
30
30
|
```html
|
|
31
|
-
<script src="https://unpkg.com/@authorizerdev/authorizer-js/
|
|
31
|
+
<script src="https://unpkg.com/@authorizerdev/authorizer-js/dist/index.global.js"></script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
- Step 2: Use the library to instantiate `Authorizer` instance and access [various methods](/authorizer-js/functions)
|
|
@@ -80,18 +80,18 @@ yarn add @authorizerdev/authoirzer-js
|
|
|
80
80
|
- Step 2: Import and initialize the authorizer instance
|
|
81
81
|
|
|
82
82
|
```js
|
|
83
|
-
const { Authorizer } = require('@authorizerdev/authoirzer-js')
|
|
83
|
+
const { Authorizer } = require('@authorizerdev/authoirzer-js')
|
|
84
84
|
|
|
85
85
|
const authRef = new Authorizer({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
})
|
|
86
|
+
authorizerURL: 'https://app.heroku.com',
|
|
87
|
+
redirectURL: 'http://app.heroku.com/app',
|
|
88
|
+
})
|
|
89
89
|
|
|
90
90
|
async function main() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
await authRef.login({
|
|
92
|
+
email: 'foo@bar.com',
|
|
93
|
+
password: 'test',
|
|
94
|
+
})
|
|
95
95
|
}
|
|
96
96
|
```
|
|
97
97
|
|
|
@@ -108,18 +108,18 @@ yarn add @authorizerdev/authorizer-js
|
|
|
108
108
|
- Step 2: Import and initialize the authorizer instance
|
|
109
109
|
|
|
110
110
|
```js
|
|
111
|
-
import { Authorizer } from '@authorizerdev/authorizer-js'
|
|
111
|
+
import { Authorizer } from '@authorizerdev/authorizer-js'
|
|
112
112
|
|
|
113
113
|
const authRef = new Authorizer({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
114
|
+
authorizerURL: 'https://app.heroku.com',
|
|
115
|
+
redirectURL: 'http://app.heroku.com/app',
|
|
116
|
+
})
|
|
117
117
|
|
|
118
118
|
async function main() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
await authRef.login({
|
|
120
|
+
email: 'foo@bar.com',
|
|
121
|
+
password: 'test',
|
|
122
|
+
})
|
|
123
123
|
}
|
|
124
124
|
```
|
|
125
125
|
|
|
@@ -135,3 +135,7 @@ async function main() {
|
|
|
135
135
|
- Install dependencies using `pnpm install`
|
|
136
136
|
- Run `pnpm build` to build the library
|
|
137
137
|
- Run `pnpm test` to run the tests
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
### Release
|
|
141
|
+
- Run `pnpm release` to release a new version of the library
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface ConfigType {
|
|
2
2
|
authorizerURL: string;
|
|
3
3
|
redirectURL: string;
|
|
4
4
|
clientID: string;
|
|
5
5
|
extraHeaders?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
}
|
|
7
|
+
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
|
-
|
|
26
|
+
}
|
|
27
|
+
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
|
-
|
|
35
|
+
}
|
|
36
|
+
interface Response {
|
|
37
37
|
message: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
}
|
|
39
|
+
type Headers = Record<string, string>;
|
|
40
|
+
interface LoginInput {
|
|
41
41
|
email: string;
|
|
42
42
|
password: string;
|
|
43
43
|
roles?: string[];
|
|
44
44
|
scope?: string[];
|
|
45
45
|
state?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
46
|
+
}
|
|
47
|
+
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
|
-
|
|
64
|
+
}
|
|
65
|
+
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
|
-
|
|
71
|
+
}
|
|
72
|
+
interface VerifyEmailInput {
|
|
73
73
|
token: string;
|
|
74
74
|
state?: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
75
|
+
}
|
|
76
|
+
interface VerifyOtpInput {
|
|
77
77
|
email: string;
|
|
78
78
|
otp: string;
|
|
79
79
|
state?: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
80
|
+
}
|
|
81
|
+
interface ResendOtpInput {
|
|
82
82
|
email: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
83
|
+
}
|
|
84
|
+
interface GraphqlQueryInput {
|
|
85
85
|
query: string;
|
|
86
86
|
variables?: Record<string, any>;
|
|
87
87
|
headers?: Headers;
|
|
88
|
-
}
|
|
89
|
-
|
|
88
|
+
}
|
|
89
|
+
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
|
-
|
|
104
|
+
}
|
|
105
|
+
interface UpdateProfileInput {
|
|
106
106
|
old_password?: string;
|
|
107
107
|
new_password?: string;
|
|
108
108
|
confirm_new_password?: string;
|
|
@@ -116,70 +116,100 @@ export type UpdateProfileInput = {
|
|
|
116
116
|
phone_number?: string;
|
|
117
117
|
picture?: string;
|
|
118
118
|
is_multi_factor_auth_enabled?: boolean;
|
|
119
|
-
}
|
|
120
|
-
|
|
119
|
+
}
|
|
120
|
+
interface ForgotPasswordInput {
|
|
121
121
|
email: string;
|
|
122
122
|
state?: string;
|
|
123
123
|
redirect_uri?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
124
|
+
}
|
|
125
|
+
interface ResetPasswordInput {
|
|
126
126
|
token: string;
|
|
127
127
|
password: string;
|
|
128
128
|
confirm_password: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
129
|
+
}
|
|
130
|
+
interface SessionQueryInput {
|
|
131
131
|
roles?: string[];
|
|
132
|
-
}
|
|
133
|
-
|
|
132
|
+
}
|
|
133
|
+
interface IsValidJWTQueryInput {
|
|
134
134
|
jwt: string;
|
|
135
135
|
roles?: string[];
|
|
136
|
-
}
|
|
137
|
-
|
|
136
|
+
}
|
|
137
|
+
interface ValidJWTResponse {
|
|
138
138
|
valid: string;
|
|
139
139
|
message: string;
|
|
140
|
-
}
|
|
141
|
-
|
|
140
|
+
}
|
|
141
|
+
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
|
-
|
|
148
|
+
declare enum ResponseTypes {
|
|
149
149
|
Code = "code",
|
|
150
150
|
Token = "token"
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
interface AuthorizeInput {
|
|
153
153
|
response_type: ResponseTypes;
|
|
154
154
|
use_refresh_token?: boolean;
|
|
155
155
|
response_mode?: string;
|
|
156
|
-
}
|
|
157
|
-
|
|
156
|
+
}
|
|
157
|
+
interface AuthorizeResponse {
|
|
158
158
|
state: string;
|
|
159
159
|
code?: string;
|
|
160
160
|
error?: string;
|
|
161
161
|
error_description?: string;
|
|
162
|
-
}
|
|
163
|
-
|
|
162
|
+
}
|
|
163
|
+
interface RevokeTokenInput {
|
|
164
164
|
refresh_token: string;
|
|
165
|
-
}
|
|
166
|
-
|
|
165
|
+
}
|
|
166
|
+
interface GetTokenInput {
|
|
167
167
|
code?: string;
|
|
168
168
|
grant_type?: string;
|
|
169
169
|
refresh_token?: string;
|
|
170
|
-
}
|
|
171
|
-
|
|
170
|
+
}
|
|
171
|
+
interface GetTokenResponse {
|
|
172
172
|
access_token: string;
|
|
173
173
|
expires_in: number;
|
|
174
174
|
id_token: string;
|
|
175
175
|
refresh_token?: string;
|
|
176
|
-
}
|
|
177
|
-
|
|
176
|
+
}
|
|
177
|
+
interface ValidateJWTTokenInput {
|
|
178
178
|
token_type: 'access_token' | 'id_token' | 'refresh_token';
|
|
179
179
|
token: string;
|
|
180
180
|
roles?: string[];
|
|
181
|
-
}
|
|
182
|
-
|
|
181
|
+
}
|
|
182
|
+
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 };
|