kodzero-front-sdk-alfa 0.0.5 → 0.0.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 CHANGED
@@ -18,14 +18,14 @@ const kodzero = new Kodzero({
18
18
  host: 'https://api.your-backend.com'
19
19
  });
20
20
 
21
- // Sign up a new user
22
- const signupResult = await kodzero.auth.signup({
21
+ // New user registration
22
+ const registerResult = await kodzero.auth.register({
23
23
  email: 'user@example.com',
24
24
  password: 'secure_password'
25
25
  });
26
26
 
27
- // Sign in
28
- const signinResult = await kodzero.auth.signin({
27
+ // Login
28
+ const loginResult = await kodzero.auth.login({
29
29
  email: 'user@example.com',
30
30
  password: 'secure_password'
31
31
  });
@@ -36,8 +36,8 @@ const verified = await kodzero.auth.verify();
36
36
  // Refresh the token
37
37
  const refreshed = await kodzero.auth.refresh();
38
38
 
39
- // Sign out
40
- await kodzero.auth.signout();
39
+ // Logout
40
+ await kodzero.auth.logout();
41
41
 
42
42
  // Manually set tokens (useful for persisting sessions)
43
43
  kodzero.auth.setTokens('access_token', 'refresh_token');
@@ -7,10 +7,10 @@ declare class KodzeroAuthBase {
7
7
  tokensManager: TokensManagerClass;
8
8
  constructor(options: AuthOptions, api: typeof FluidFetch, tokensManager: TokensManagerClass);
9
9
  _handleApiError(response: Response): Promise<void>;
10
- signin: (...args: any[]) => Promise<any> | void;
11
- signup: (...args: any[]) => Promise<any> | void;
10
+ login: (...args: any[]) => Promise<any> | void;
11
+ register: (...args: any[]) => Promise<any> | void;
12
12
  refresh: (...args: any[]) => Promise<any> | void;
13
- signout: (...args: any[]) => Promise<any> | void;
13
+ logout: (...args: any[]) => Promise<any> | void;
14
14
  verify: (...args: any[]) => Promise<any> | void;
15
15
  }
16
16
  export default KodzeroAuthBase;
package/dist/auth/base.js CHANGED
@@ -13,10 +13,10 @@ class KodzeroAuthBase {
13
13
  _handleApiError(response) {
14
14
  return validateApiResponse(response);
15
15
  }
16
- signin = (...args) => { };
17
- signup = (...args) => { };
16
+ login = (...args) => { };
17
+ register = (...args) => { };
18
18
  refresh = (...args) => { };
19
- signout = (...args) => { };
19
+ logout = (...args) => { };
20
20
  verify = (...args) => { };
21
21
  }
22
22
  export default KodzeroAuthBase;
@@ -2,7 +2,7 @@ import FluidFetch from "fluid-fetch";
2
2
  import { AuthOptions } from "./index.js";
3
3
  import KodzeroAuthBase from "./base.js";
4
4
  import TokensManagerClass from "./tokens.js";
5
- interface KodzeroAuthEmailSignin {
5
+ interface KodzeroAuthEmailLogin {
6
6
  email: string;
7
7
  password: string;
8
8
  }
@@ -11,13 +11,13 @@ declare class KodzeroAuthEmail extends KodzeroAuthBase {
11
11
  collection: "auth/password";
12
12
  constructor(options: AuthOptions, api: typeof FluidFetch, tokensManager: TokensManagerClass);
13
13
  _setTokens: (access: string, refresh?: string) => void;
14
- signin: (input: KodzeroAuthEmailSignin) => Promise<{
14
+ login: (input: KodzeroAuthEmailLogin) => Promise<{
15
15
  access: string;
16
16
  refresh: string;
17
17
  }>;
18
- signup: (userData: Record<string, string>) => Promise<Record<string, any>>;
18
+ register: (userData: Record<string, string>) => Promise<Record<string, any>>;
19
19
  verify: () => Promise<any>;
20
20
  refresh: () => Promise<any>;
21
- signout: () => Promise<any>;
21
+ logout: () => Promise<any>;
22
22
  }
23
23
  export default KodzeroAuthEmail;
@@ -13,8 +13,8 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
13
13
  if (refresh)
14
14
  this.tokensManager.setRefresh(refresh);
15
15
  };
16
- signin = async (input) => {
17
- const url = buildURL(this.host, this.collection + '/signin');
16
+ login = async (input) => {
17
+ const url = buildURL(this.host, this.collection + '/login');
18
18
  const response = await this.api.post(url, input)
19
19
  .headers({ 'Content-Type': 'application/json' });
20
20
  await this._handleApiError(response);
@@ -24,8 +24,8 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
24
24
  }
25
25
  return json.tokens;
26
26
  };
27
- signup = async (userData) => {
28
- const url = buildURL(this.host, this.collection + '/signup');
27
+ register = async (userData) => {
28
+ const url = buildURL(this.host, this.collection + '/register');
29
29
  const response = await this.api.post(url, userData)
30
30
  .headers({ 'Content-Type': 'application/json' });
31
31
  await this._handleApiError(response);
@@ -58,8 +58,8 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
58
58
  }
59
59
  return json.ok ? true : false;
60
60
  };
61
- signout = async () => {
62
- const url = buildURL(this.host, this.collection + '/signout');
61
+ logout = async () => {
62
+ const url = buildURL(this.host, this.collection + '/logout');
63
63
  const response = await this.api.post(url, {})
64
64
  .headers({ 'Content-Type': 'application/json' });
65
65
  await this._handleApiError(response);
@@ -7,9 +7,9 @@ class KodzeroAuth extends KodzeroAuthBase {
7
7
  constructor(options, api, tokensManager) {
8
8
  super(options, api, tokensManager);
9
9
  this.email = new KodzeroAuthEmail(options, api, tokensManager);
10
- this.signin = this.email.signin;
11
- this.signup = this.email.signup;
12
- this.signout = this.email.signout;
10
+ this.login = this.email.login;
11
+ this.register = this.email.register;
12
+ this.logout = this.email.logout;
13
13
  this.verify = this.email.verify;
14
14
  this.refresh = this.email.refresh;
15
15
  this.setTokens = (access, refresh) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodzero-front-sdk-alfa",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "tsc": "tsc -b src/",
package/src/auth/base.ts CHANGED
@@ -29,10 +29,10 @@ class KodzeroAuthBase {
29
29
  * Base auth methods.
30
30
  * These will be overridden by specific strategies (e.g. email, social, etc.)
31
31
  */
32
- signin = (...args: any[]): Promise<any> | void => {}
33
- signup = (...args: any[]): Promise<any> | void => {}
32
+ login = (...args: any[]): Promise<any> | void => {}
33
+ register = (...args: any[]): Promise<any> | void => {}
34
34
  refresh = (...args: any[]): Promise<any> | void => {}
35
- signout = (...args: any[]): Promise<any> | void => {}
35
+ logout = (...args: any[]): Promise<any> | void => {}
36
36
  verify = (...args: any[]): Promise<any> | void => {}
37
37
  }
38
38
 
package/src/auth/email.ts CHANGED
@@ -4,7 +4,7 @@ import buildURL from "../utils/buildURL.js"
4
4
  import KodzeroAuthBase from "./base.js"
5
5
  import TokensManagerClass from "./tokens.js"
6
6
 
7
- interface KodzeroAuthEmailSignin {
7
+ interface KodzeroAuthEmailLogin {
8
8
  email: string
9
9
  password: string
10
10
  }
@@ -30,11 +30,11 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
30
30
  }
31
31
 
32
32
  /**
33
- * Sign in with email and password. On success, sets tokens in TokensManager automatically
33
+ * Login with email and password. On success, sets tokens in TokensManager automatically
34
34
  */
35
- signin = async (input: KodzeroAuthEmailSignin): Promise<{access: string, refresh: string}> => {
36
- const url = buildURL(this.host, this.collection + '/signin')
37
-
35
+ login = async (input: KodzeroAuthEmailLogin): Promise<{access: string, refresh: string}> => {
36
+ const url = buildURL(this.host, this.collection + '/login')
37
+
38
38
  const response = await this.api.post(url, input)
39
39
  .headers({ 'Content-Type': 'application/json' });
40
40
 
@@ -49,10 +49,10 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
49
49
  }
50
50
 
51
51
  /**
52
- * Sign up with email and password. On success, sets tokens in TokensManager automatically
52
+ * Register with email and password. On success, sets tokens in TokensManager automatically
53
53
  */
54
- signup = async (userData: Record<string, string>): Promise<Record<string, any>> => {
55
- const url = buildURL(this.host, this.collection + '/signup')
54
+ register = async (userData: Record<string, string>): Promise<Record<string, any>> => {
55
+ const url = buildURL(this.host, this.collection + '/register')
56
56
  const response = await this.api.post(url, userData)
57
57
  .headers({ 'Content-Type': 'application/json' });
58
58
 
@@ -102,11 +102,11 @@ class KodzeroAuthEmail extends KodzeroAuthBase {
102
102
  }
103
103
 
104
104
  /**
105
- * Sign out the user
105
+ * Logout the user
106
106
  * If success, clears tokens in TokensManager automatically
107
107
  */
108
- signout = async (): Promise<any> => {
109
- const url = buildURL(this.host, this.collection + '/signout')
108
+ logout = async (): Promise<any> => {
109
+ const url = buildURL(this.host, this.collection + '/logout')
110
110
  const response = await this.api.post(url, {})
111
111
  .headers({ 'Content-Type': 'application/json' });
112
112
 
package/src/auth/index.ts CHANGED
@@ -19,9 +19,9 @@ class KodzeroAuth extends KodzeroAuthBase {
19
19
  this.email = new KodzeroAuthEmail(options, api, tokensManager)
20
20
 
21
21
  // Default methods set to email strategy methods
22
- this.signin = this.email.signin
23
- this.signup = this.email.signup
24
- this.signout = this.email.signout
22
+ this.login = this.email.login
23
+ this.register = this.email.register
24
+ this.logout = this.email.logout
25
25
  this.verify = this.email.verify
26
26
  this.refresh = this.email.refresh
27
27