1.2.9 • Published 2 years ago

@smiilliin/auth-api v1.2.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

auth-api - auth API

Usage

AuthAPI

Initialize AuthAPI class

const authAPI = new AuthAPI("https://smiilliin.com/api");

Load

Load fetchstrings

await authAPI.load("en");

login

Login with id and password

const refreshToken: string = await authAPI.login(id, password);
console.log("[Refresh Token]", refreshToken);

signup

Signup with id, password, google recaptcha response

const refreshToken: string = await authAPI.signup(id, password, g_response);
console.log("[Refresh Token]", refreshToken);

get access token

Get access token with refresh token

const accessToken: string = await authAPI.getAccessToken(refreshToken);
console.log("[Access Token]", accessToken);

renew refresh token

Renew refresh token

const renewedRefreshToken: string = await authAPI.renewRefreshToken(refreshToken);
console.log("[Refresh Token]", renewedRefreshToken);

TokenKeeper

const tokenKeeper = new TokenKeeper(authAPI, refreshToken, accessToken);

setTokenInterval

Set the interval between refresh callbacks

tokenKeeper.setTokenInterval(60 * 60 * 1000, 10 * 60 * 1000, 30 * 60 * 1000, 5 * 60 * 1000);

watchRefreshToken

Watch if the refresh token changed

tokenKeeper.watchRefreshToken = (refreshToken: string) => {
  console.log(refreshToken);
};

watchAccessToken

Watch if the access token changed

tokenKeeper.watchAccessToken = (accessToken: string) => {
  console.log(accessToken);
};
1.2.0

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.9

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago