skapi-js 1.0.38 → 1.0.40
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/error.js +2 -2
- package/js/main/skapi.d.ts +8 -0
- package/js/main/skapi.js +5 -2
- package/js/methods/request.js +1 -0
- package/js/methods/user.d.ts +8 -0
- package/js/methods/user.js +44 -0
- package/package.json +1 -1
package/js/main/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default class SkapiError extends Error {
|
|
2
2
|
constructor(error, options) {
|
|
3
3
|
if (Array.isArray(error) && error.length <= 2) {
|
|
4
|
-
super(error[1] || 'Something went wrong.');
|
|
4
|
+
super((error[1] || 'Something went wrong.').trim());
|
|
5
5
|
this.name = options && options.name || "SKAPI";
|
|
6
6
|
this.code = error[0] || "ERROR";
|
|
7
7
|
if (options) {
|
|
@@ -27,7 +27,7 @@ export default class SkapiError extends Error {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
else if (error instanceof Error) {
|
|
30
|
-
super(error.message || 'Something went wrong.');
|
|
30
|
+
super((error.message || 'Something went wrong.').trim());
|
|
31
31
|
this.cause = error;
|
|
32
32
|
this.name = error.name;
|
|
33
33
|
if (error.hasOwnProperty('code')) {
|
package/js/main/skapi.d.ts
CHANGED
|
@@ -49,6 +49,14 @@ export default class Skapi {
|
|
|
49
49
|
provider: string;
|
|
50
50
|
nonce?: string;
|
|
51
51
|
}): Promise<string>;
|
|
52
|
+
clientSecretRequest(params: {
|
|
53
|
+
url: string;
|
|
54
|
+
clientSecretName: string;
|
|
55
|
+
method: 'get' | 'post' | 'GET' | 'POST';
|
|
56
|
+
headers?: Record<string, string>;
|
|
57
|
+
data?: Record<string, string>;
|
|
58
|
+
params?: Record<string, string>;
|
|
59
|
+
}): Promise<string>;
|
|
52
60
|
consumeTicket(params: {
|
|
53
61
|
ticket_id: string;
|
|
54
62
|
}): 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, jwtLogin } 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, clientSecretRequest } 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.40';
|
|
27
27
|
this.session = null;
|
|
28
28
|
this.connection = null;
|
|
29
29
|
this.host = 'skapi';
|
|
@@ -202,6 +202,9 @@ export default class Skapi {
|
|
|
202
202
|
jwtLogin(params) {
|
|
203
203
|
return jwtLogin.bind(this)(params);
|
|
204
204
|
}
|
|
205
|
+
clientSecretRequest(params) {
|
|
206
|
+
return clientSecretRequest.bind(this)(params);
|
|
207
|
+
}
|
|
205
208
|
consumeTicket(params) {
|
|
206
209
|
return consumeTicket.bind(this)(params);
|
|
207
210
|
}
|
package/js/methods/request.js
CHANGED
package/js/methods/user.d.ts
CHANGED
|
@@ -32,6 +32,14 @@ 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 clientSecretRequest(params: {
|
|
36
|
+
url: string;
|
|
37
|
+
clientSecretName: string;
|
|
38
|
+
method: 'get' | 'post' | 'GET' | 'POST';
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
data?: Record<string, string>;
|
|
41
|
+
params?: Record<string, string>;
|
|
42
|
+
}): any;
|
|
35
43
|
export declare function jwtLogin(params: {
|
|
36
44
|
idToken: string;
|
|
37
45
|
keyUrl: string;
|
package/js/methods/user.js
CHANGED
|
@@ -341,6 +341,50 @@ 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 function clientSecretRequest(params) {
|
|
345
|
+
validator.Params(params, {
|
|
346
|
+
url: 'string',
|
|
347
|
+
clientSecretName: 'string',
|
|
348
|
+
method: ['get', 'post', 'GET', 'POST'],
|
|
349
|
+
headers: (v) => v,
|
|
350
|
+
data: (v) => {
|
|
351
|
+
if (v && typeof v !== 'object') {
|
|
352
|
+
throw new SkapiError('"data" should be type: <object>.', { code: 'INVALID_PARAMETER' });
|
|
353
|
+
}
|
|
354
|
+
return v;
|
|
355
|
+
},
|
|
356
|
+
params: (v) => {
|
|
357
|
+
if (v && typeof v !== 'object') {
|
|
358
|
+
throw new SkapiError('"params" should be type: <object>.', { code: 'INVALID_PARAMETER' });
|
|
359
|
+
}
|
|
360
|
+
return v;
|
|
361
|
+
}
|
|
362
|
+
}, ['clientSecretName', 'method', 'url']);
|
|
363
|
+
let hasSecret = false;
|
|
364
|
+
if (!params.data && !params.params) {
|
|
365
|
+
throw new SkapiError(`${params.method.toLowerCase() === 'post' ? '"data"' : '"params"'} is required.`, { code: 'INVALID_PARAMETER' });
|
|
366
|
+
}
|
|
367
|
+
if (params.data) {
|
|
368
|
+
for (let k in params.data) {
|
|
369
|
+
if (typeof params.data[k] === 'string' && params.data[k].includes('$CLIENT_SECRET')) {
|
|
370
|
+
hasSecret = true;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (params.params) {
|
|
376
|
+
for (let k in params.params) {
|
|
377
|
+
if (typeof params.params[k] === 'string' && params.params[k].includes('$CLIENT_SECRET')) {
|
|
378
|
+
hasSecret = true;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (!hasSecret) {
|
|
384
|
+
throw new SkapiError(`At least one parameter value should include "$CLIENT_SECRET" in ${params.method.toLowerCase() === 'post' ? '"data"' : '"params"'}.`, { code: 'INVALID_PARAMETER' });
|
|
385
|
+
}
|
|
386
|
+
return request.bind(this)("client-secret-request", params);
|
|
387
|
+
}
|
|
344
388
|
export async function jwtLogin(params) {
|
|
345
389
|
validator.Params(params, {
|
|
346
390
|
idToken: 'string',
|