@opexa/portal-sdk 0.59.80 → 0.59.81

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/index.d.cts CHANGED
@@ -136,7 +136,7 @@ declare class Sdk {
136
136
  * @deprecated use `sendVerificationCode__next`
137
137
  */
138
138
  sendVerificationCode(mobileNumber: string): Promise<SendVerificationCodeReturn>;
139
- sendVerificationCode__next(input: SendVerificationCodeInput__Next): Promise<SendVerificationCodeReturn__Next>;
139
+ sendVerificationCode__next(input: SendVerificationCodeInput__Next, version?: 1 | 3): Promise<SendVerificationCodeReturn__Next>;
140
140
  wallet(): Promise<WalletReturn>;
141
141
  memberWalletAccount(): Promise<MemberWalletAccountReturn>;
142
142
  memberLevelHistory(): Promise<MemberLevelHistoryReturn>;
package/dist/index.d.ts CHANGED
@@ -136,7 +136,7 @@ declare class Sdk {
136
136
  * @deprecated use `sendVerificationCode__next`
137
137
  */
138
138
  sendVerificationCode(mobileNumber: string): Promise<SendVerificationCodeReturn>;
139
- sendVerificationCode__next(input: SendVerificationCodeInput__Next): Promise<SendVerificationCodeReturn__Next>;
139
+ sendVerificationCode__next(input: SendVerificationCodeInput__Next, version?: 1 | 3): Promise<SendVerificationCodeReturn__Next>;
140
140
  wallet(): Promise<WalletReturn>;
141
141
  memberWalletAccount(): Promise<MemberWalletAccountReturn>;
142
142
  memberLevelHistory(): Promise<MemberLevelHistoryReturn>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService, getFingerPrint } from './chunk-CBF46HKK.js';
1
+ import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService, getFingerPrint } from './chunk-443LKA6K.js';
2
2
  import { GraphQLClient, isPlainObject } from './chunk-7APXFZ5G.js';
3
3
  import './chunk-WVFSGB7Y.js';
4
4
  import { ObjectId } from '@opexa/object-id';
@@ -717,6 +717,14 @@ var SessionManagerCookie = class {
717
717
  this.logger.warn("'client cookies' is not available on the server.");
718
718
  return true;
719
719
  }
720
+ const val = cookies.get(this.storageKey);
721
+ if (val) {
722
+ try {
723
+ const stored = JSON.parse(val);
724
+ if (stored.version === 4) return await this.verifyV4();
725
+ } catch {
726
+ }
727
+ }
720
728
  const s = await this.get();
721
729
  if (s.error?.name === "InvalidTokenError") return false;
722
730
  if (s.error?.name === "SessionExpiredError") return false;
@@ -728,6 +736,18 @@ var SessionManagerCookie = class {
728
736
  }
729
737
  return v;
730
738
  }
739
+ async verifyV4() {
740
+ if (!this.v4AccessToken || !this.v4AccessTokenExpiresAt || isAfter(/* @__PURE__ */ new Date(), new Date(this.v4AccessTokenExpiresAt))) {
741
+ return true;
742
+ }
743
+ const v = await this.authService.verifySession(this.v4AccessToken);
744
+ if (!v) {
745
+ cookies.remove(this.storageKey);
746
+ this.v4AccessToken = null;
747
+ this.v4AccessTokenExpiresAt = null;
748
+ }
749
+ return v;
750
+ }
731
751
  get onMaya() {
732
752
  if (this.isServer) {
733
753
  this.logger.warn("'client cookies' is not available on the server.");
@@ -1164,6 +1184,14 @@ var SessionManager = class {
1164
1184
  this.logger.warn("'localStorage' is not available on the server.");
1165
1185
  return true;
1166
1186
  }
1187
+ const val = localStorage.getItem(this.storageKey);
1188
+ if (val) {
1189
+ try {
1190
+ const stored = JSON.parse(val);
1191
+ if (stored.version === 4) return await this.verifyV4();
1192
+ } catch {
1193
+ }
1194
+ }
1167
1195
  const s = await this.get();
1168
1196
  if (s.error?.name === "InvalidTokenError") return false;
1169
1197
  if (s.error?.name === "SessionExpiredError") return false;
@@ -1175,6 +1203,18 @@ var SessionManager = class {
1175
1203
  }
1176
1204
  return v;
1177
1205
  }
1206
+ async verifyV4() {
1207
+ if (!this.v4AccessToken || !this.v4AccessTokenExpiresAt || isAfter(/* @__PURE__ */ new Date(), new Date(this.v4AccessTokenExpiresAt))) {
1208
+ return true;
1209
+ }
1210
+ const v = await this.authService.verifySession(this.v4AccessToken);
1211
+ if (!v) {
1212
+ localStorage.removeItem(this.storageKey);
1213
+ this.v4AccessToken = null;
1214
+ this.v4AccessTokenExpiresAt = null;
1215
+ }
1216
+ return v;
1217
+ }
1178
1218
  get onMaya() {
1179
1219
  if (this.isServer) {
1180
1220
  this.logger.warn("'localStorage' is not available on the server.");
@@ -3973,15 +4013,18 @@ var Sdk = class {
3973
4013
  }
3974
4014
  });
3975
4015
  }
3976
- async sendVerificationCode__next(input) {
4016
+ async sendVerificationCode__next(input, version = 1) {
3977
4017
  if (input.type === "SMS") {
3978
- return this.authService.sendVerificationCode({
3979
- channel: "SMS",
3980
- recipient: addAreaCode(input.mobileNumber, await this.locale),
3981
- ...input.strict && {
3982
- verificationType: "MEMBER"
3983
- }
3984
- });
4018
+ return this.authService.sendVerificationCode(
4019
+ {
4020
+ channel: "SMS",
4021
+ recipient: addAreaCode(input.mobileNumber, await this.locale),
4022
+ ...input.strict && {
4023
+ verificationType: "MEMBER"
4024
+ }
4025
+ },
4026
+ version
4027
+ );
3985
4028
  }
3986
4029
  throw new Error("'Email' verification code is not yet supported");
3987
4030
  }