skapi-js 1.0.29 → 1.0.31

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.
@@ -42,6 +42,11 @@ export default class Skapi {
42
42
  message: any;
43
43
  sender?: string;
44
44
  }) => Promise<WebSocket>): any;
45
+ jwtLogin(params: {
46
+ jwt: string;
47
+ key_url: string;
48
+ client_id: string;
49
+ }): Promise<string>;
45
50
  consumeTicket(params: {
46
51
  ticket_id: string;
47
52
  }): Promise<string>;
package/js/main/skapi.js CHANGED
@@ -10,7 +10,7 @@ import { getRecords, postRecord, deleteRecords, getTables, getIndexes, getTags,
10
10
  import { connectRealtime, joinRealtime, postRealtime, closeRealtime, getRealtimeUsers, getRealtimeGroups } from '../methods/realtime';
11
11
  import { request, secureRequest, mock, getFormResponse, formHandler, getConnection } from '../methods/request';
12
12
  import { subscribe, unsubscribe, blockSubscriber, unblockSubscriber, getSubscriptions, subscribeNewsletter, getNewsletters, unsubscribeNewsletter, getNewsletterSubscription } from '../methods/subscription';
13
- import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange, consumeTicket, releaseTicket, getTicketKey } from '../methods/user';
13
+ import { checkAdmin, getProfile, logout, recoverAccount, resendSignupConfirmation, authentication, login, signup, disableAccount, resetPassword, verifyEmail, verifyPhoneNumber, forgotPassword, changePassword, updateProfile, getUsers, setUserPool, userPool, lastVerifiedEmail, requestUsernameChange, consumeTicket, releaseTicket, getTicketKey, jwtLogin } from '../methods/user';
14
14
  export default class Skapi {
15
15
  get user() {
16
16
  if (this.__user && Object.keys(this.__user).length) {
@@ -23,7 +23,7 @@ export default class Skapi {
23
23
  set user(value) {
24
24
  }
25
25
  constructor(service, owner, options, __etc) {
26
- this.version = '1.0.29';
26
+ this.version = '1.0.31';
27
27
  this.session = null;
28
28
  this.connection = null;
29
29
  this.host = 'skapi';
@@ -199,6 +199,9 @@ export default class Skapi {
199
199
  connectRealtime(cb) {
200
200
  return connectRealtime.bind(this)(cb);
201
201
  }
202
+ jwtLogin(params) {
203
+ return jwtLogin.bind(this)(params);
204
+ }
202
205
  consumeTicket(params) {
203
206
  return consumeTicket.bind(this)(params);
204
207
  }
@@ -66,6 +66,7 @@ export async function request(url, data = null, options) {
66
66
  case 'ticket':
67
67
  case 'get-newsletter-subscription':
68
68
  case 'request-username-change':
69
+ case 'jwt-login':
69
70
  return {
70
71
  public: admin.admin_public,
71
72
  private: admin.admin_private
@@ -32,6 +32,11 @@ export declare function checkAdmin(): Promise<boolean>;
32
32
  export declare function logout(): Promise<'SUCCESS: The user has been logged out.'>;
33
33
  export declare function resendSignupConfirmation(redirect: string): Promise<'SUCCESS: Signup confirmation E-Mail has been sent.'>;
34
34
  export declare function recoverAccount(redirect?: boolean | string): Promise<"SUCCESS: Recovery e-mail has been sent.">;
35
+ export declare function jwtLogin(params: {
36
+ jwt: string;
37
+ key_url: string;
38
+ client_id: string;
39
+ }): Promise<any>;
35
40
  export declare function login(form: Form<{
36
41
  username?: string;
37
42
  email: string;
@@ -197,7 +197,7 @@ export function authentication() {
197
197
  const createCognitoUser = async (email) => {
198
198
  if (!email)
199
199
  throw new SkapiError('E-Mail is required.', { code: 'INVALID_PARAMETER' });
200
- let username = this.service + '-' + MD5.hash(email);
200
+ let username = email.includes(this.service + '-') ? email : this.service + '-' + MD5.hash(email);
201
201
  return {
202
202
  cognitoUser: new CognitoUser({
203
203
  Username: username,
@@ -341,6 +341,10 @@ export async function recoverAccount(redirect = false) {
341
341
  this.__disabledAccount = null;
342
342
  return 'SUCCESS: Recovery e-mail has been sent.';
343
343
  }
344
+ export async function jwtLogin(params) {
345
+ let { hashedPassword } = request.bind(this)("jwt-login", params);
346
+ return login.bind(this)({ email: params.client_id, password: hashedPassword });
347
+ }
344
348
  export async function login(form) {
345
349
  await this.logout();
346
350
  let params = validator.Params(form, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Skapi: Backend API Library for HTML frontend.",
5
5
  "main": "./dist/skapi.module.js",
6
6
  "types": "./js/Main.d.ts",