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.
- package/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/main/skapi.d.ts +5 -0
- package/js/main/skapi.js +5 -2
- package/js/methods/request.js +1 -0
- package/js/methods/user.d.ts +5 -0
- package/js/methods/user.js +5 -1
- package/package.json +1 -1
package/js/main/skapi.d.ts
CHANGED
|
@@ -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.
|
|
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
|
}
|
package/js/methods/request.js
CHANGED
package/js/methods/user.d.ts
CHANGED
|
@@ -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;
|
package/js/methods/user.js
CHANGED
|
@@ -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, {
|