skapi-js 1.0.21 → 1.0.23

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.
@@ -32,7 +32,7 @@ export default class Skapi {
32
32
  private __socket_group;
33
33
  constructor(service: string, owner: string, options?: {
34
34
  autoLogin: boolean;
35
- });
35
+ }, __etc?: any);
36
36
  updateConnection(): Promise<Connection>;
37
37
  private checkAdmin;
38
38
  private request;
@@ -42,6 +42,15 @@ export default class Skapi {
42
42
  message: any;
43
43
  sender?: string;
44
44
  }) => Promise<WebSocket>): any;
45
+ consumeTicket(params: {
46
+ ticket_id: string;
47
+ }): Promise<string>;
48
+ releaseTicket(params: {
49
+ ticket_id: string;
50
+ }): Promise<string>;
51
+ getTicketKey(params: {
52
+ ticket_id: string;
53
+ }): Promise<string>;
45
54
  closeRealtime(): Promise<void>;
46
55
  getRealtimeUsers(params: {
47
56
  group: 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 } 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 } from '../methods/user';
14
14
  export default class Skapi {
15
15
  get user() {
16
16
  if (this.__user && Object.keys(this.__user).length) {
@@ -22,8 +22,8 @@ export default class Skapi {
22
22
  }
23
23
  set user(value) {
24
24
  }
25
- constructor(service, owner, options) {
26
- this.version = '1.0.21';
25
+ constructor(service, owner, options, __etc) {
26
+ this.version = '1.0.23';
27
27
  this.session = null;
28
28
  this.connection = null;
29
29
  this.host = 'skapi';
@@ -98,6 +98,8 @@ export default class Skapi {
98
98
  this.service = service;
99
99
  this.owner = owner;
100
100
  let autoLogin = typeof options?.autoLogin === 'boolean' ? options.autoLogin : true;
101
+ this.target_cdn = __etc?.target_cdn || this.target_cdn;
102
+ this.hostDomain = __etc?.hostDomain || this.hostDomain;
101
103
  const cdn_domain = `https://${this.target_cdn}.cloudfront.net`;
102
104
  let sreg = service.substring(0, 4);
103
105
  this.admin_endpoint = fetch(`${cdn_domain}/${sreg}/admin.json`)
@@ -194,6 +196,15 @@ export default class Skapi {
194
196
  connectRealtime(cb) {
195
197
  return connectRealtime.bind(this)(cb);
196
198
  }
199
+ consumeTicket(params) {
200
+ return consumeTicket.bind(this)(params);
201
+ }
202
+ releaseTicket(params) {
203
+ return releaseTicket.bind(this)(params);
204
+ }
205
+ getTicketKey(params) {
206
+ return getTicketKey.bind(this)(params);
207
+ }
197
208
  closeRealtime() {
198
209
  return closeRealtime.bind(this)();
199
210
  }
@@ -63,6 +63,7 @@ export async function request(url, data = null, options) {
63
63
  case 'service':
64
64
  case 'grant-access':
65
65
  case 'last-verified-email':
66
+ case 'ticket':
66
67
  case 'get-newsletter-subscription':
67
68
  case 'request-username-change':
68
69
  return {
@@ -5,6 +5,15 @@ export declare function setUserPool(params: {
5
5
  UserPoolId: string;
6
6
  ClientId: string;
7
7
  }): void;
8
+ export declare function consumeTicket(params: {
9
+ ticket_id: string;
10
+ }): Promise<string>;
11
+ export declare function releaseTicket(params: {
12
+ ticket_id: string;
13
+ }): Promise<string>;
14
+ export declare function getTicketKey(params: {
15
+ ticket_id: string;
16
+ }): Promise<string>;
8
17
  export declare function authentication(): {
9
18
  getSession: (option?: {
10
19
  refreshToken?: boolean;
@@ -8,6 +8,24 @@ export let userPool = null;
8
8
  export function setUserPool(params) {
9
9
  userPool = new CognitoUserPool(params);
10
10
  }
11
+ export function consumeTicket(params) {
12
+ if (!params.ticket_id) {
13
+ throw new SkapiError('Ticket ID is required.', { code: 'INVALID_PARAMETER' });
14
+ }
15
+ return request.bind(this)('ticket', { ticket_id: params, exec: 'consume' }, { auth: true });
16
+ }
17
+ export function releaseTicket(params) {
18
+ if (!params.ticket_id) {
19
+ throw new SkapiError('Ticket ID is required.', { code: 'INVALID_PARAMETER' });
20
+ }
21
+ return request.bind(this)('ticket', { ticket_id: params, exec: 'release' }, { auth: true });
22
+ }
23
+ export function getTicketKey(params) {
24
+ if (!params.ticket_id) {
25
+ throw new SkapiError('Ticket ID is required.', { code: 'INVALID_PARAMETER' });
26
+ }
27
+ return request.bind(this)('ticket', { ticket_id: params, exec: 'request' }, { auth: true });
28
+ }
11
29
  export function authentication() {
12
30
  if (!userPool)
13
31
  throw new SkapiError('User pool is missing', { code: 'INVALID_REQUEST' });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.21",
4
- "description": "Javascript library for Skapi: Complete JAM Stack, front-end driven serverless backend API service.",
3
+ "version": "1.0.23",
4
+ "description": "Skapi: JS Backend API with no deployment required.",
5
5
  "main": "./dist/skapi.module.js",
6
6
  "types": "./js/Main.d.ts",
7
7
  "files": [
@@ -33,6 +33,6 @@
33
33
  "backend",
34
34
  "skapi",
35
35
  "api",
36
- "jamstack"
36
+ "serverless"
37
37
  ]
38
38
  }