zmp-sdk 2.22.2 → 2.23.0-0

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.
@@ -3743,7 +3743,7 @@
3743
3743
  }
3744
3744
  }
3745
3745
 
3746
- var version = "2.22.2";
3746
+ var version = "2.23.0-0";
3747
3747
 
3748
3748
  class Basics {
3749
3749
  /**
@@ -4924,14 +4924,26 @@
4924
4924
  this._userAgent = getUserAgent();
4925
4925
  this._device = checkPlatform();
4926
4926
  this.isJumped = false;
4927
- _ZaloJSBridge_cookies.set(this, null);
4927
+ _ZaloJSBridge_cookies.set(this, []);
4928
4928
  _ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
4929
+ this.getCookie = (name) => __awaiter(this, void 0, void 0, function* () {
4930
+ var _a;
4931
+ yield this.jump();
4932
+ const cookie = (_a = __classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) === null || _a === void 0 ? void 0 : _a.find((cookie) => cookie.name === name);
4933
+ return cookie;
4934
+ });
4935
+ this.getCookieSync = (name) => {
4936
+ var _a;
4937
+ const cookie = (_a = __classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) === null || _a === void 0 ? void 0 : _a.find((cookie) => cookie.name === name);
4938
+ return cookie;
4939
+ };
4929
4940
  this.jump = () => {
4930
4941
  return new Promise((resolve, reject) => {
4931
- if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
4942
+ if (this.isJumped) {
4932
4943
  resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
4933
4944
  }
4934
4945
  else {
4946
+ this.debug('******** call jump ********');
4935
4947
  this.callNative(ACTION.JUMP_LOGIN, {})
4936
4948
  .then((data) => {
4937
4949
  const cookies = (data && data.cookiesOAuthLogins) || [];
@@ -5115,7 +5127,7 @@
5115
5127
  }
5116
5128
  callNative(action, data, option) {
5117
5129
  this.debug(action.name, data);
5118
- return new Promise((resolve, reject) => {
5130
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
5119
5131
  const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
5120
5132
  var _a, _b, _c, _d, _e, _f, _g, _h;
5121
5133
  try {
@@ -5139,7 +5151,8 @@
5139
5151
  error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
5140
5152
  }
5141
5153
  else if ((_b = (_a = action.error_list) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b[String(cb.error_code)]) {
5142
- let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
5154
+ let error_message = action.error_list[platform][String(cb.error_code)].map_to
5155
+ .message;
5143
5156
  if ((_e = (_d = (_c = action.error_list) === null || _c === void 0 ? void 0 : _c[platform]) === null || _d === void 0 ? void 0 : _d[String(cb.error_code)]) === null || _e === void 0 ? void 0 : _e.need_more_detail) {
5144
5157
  error_message = `${(_h = (_g = (_f = action.error_list) === null || _f === void 0 ? void 0 : _f[platform]) === null || _g === void 0 ? void 0 : _g[String(cb.error_code)]) === null || _h === void 0 ? void 0 : _h.map_to.message}: ${cb.error_message}`;
5145
5158
  }
@@ -5159,6 +5172,12 @@
5159
5172
  return reject(error);
5160
5173
  }
5161
5174
  });
5175
+ /**
5176
+ * Check jump status and auto call jump
5177
+ */
5178
+ if (!action.skip_jump) {
5179
+ yield this.jump();
5180
+ }
5162
5181
  const isIOS = checkPlatform().isIOS;
5163
5182
  const isSupportAction = checkIOSSupportAction(action);
5164
5183
  if (isIOS && !isSupportAction) {
@@ -5173,7 +5192,7 @@
5173
5192
  else {
5174
5193
  __classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, data, handleNativeCallback, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
5175
5194
  }
5176
- });
5195
+ }));
5177
5196
  }
5178
5197
  }
5179
5198
  _ZaloJSBridge_cookies = new WeakMap(), _ZaloJSBridge_actionRuntimeInfo = new WeakMap(), _ZaloJSBridge_instances = new WeakSet(), _ZaloJSBridge_jsCall = function _ZaloJSBridge_jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
@@ -6273,6 +6292,21 @@
6273
6292
  this.setActionBarConfig = (setState) => {
6274
6293
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
6275
6294
  };
6295
+ this.getAuthCode = () => __awaiter(this, void 0, void 0, function* () {
6296
+ var _t, _u;
6297
+ const authCode = (_t = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZOAUTH))) === null || _t === void 0 ? void 0 : _t.value;
6298
+ const authCodeVerify = (_u = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZOAUTH_VRF))) === null || _u === void 0 ? void 0 : _u.value;
6299
+ return {
6300
+ authCode,
6301
+ authCodeVerify
6302
+ };
6303
+ });
6304
+ this.setAccessToken = (accessToken) => {
6305
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, accessToken, "f");
6306
+ __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = accessToken;
6307
+ window.ZJSBridge.setZAccSession &&
6308
+ window.ZJSBridge.setZAccSession(accessToken);
6309
+ };
6276
6310
  this.getVersion = Basics.getVersion;
6277
6311
  this.getSystemInfo = Basics.getSystemInfo;
6278
6312
  this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
@@ -6389,10 +6423,34 @@
6389
6423
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f");
6390
6424
  }
6391
6425
  getDeviceId() {
6392
- return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
6426
+ var _a;
6427
+ return __awaiter(this, void 0, void 0, function* () {
6428
+ return (_a = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.DEVICE_ID))) === null || _a === void 0 ? void 0 : _a.value;
6429
+ });
6430
+ }
6431
+ getDeviceIdSync() {
6432
+ var _a;
6433
+ return (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.DEVICE_ID)) === null || _a === void 0 ? void 0 : _a.value;
6393
6434
  }
6394
6435
  getContext() {
6395
- return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_context, "f");
6436
+ var _a, _b;
6437
+ return __awaiter(this, void 0, void 0, function* () {
6438
+ const contextID = (_a = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.CONTEXT_ID))) === null || _a === void 0 ? void 0 : _a.value;
6439
+ const contextType = (_b = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.CONTEXT_TYPE))) === null || _b === void 0 ? void 0 : _b.value;
6440
+ return {
6441
+ type: contextType,
6442
+ id: contextID
6443
+ };
6444
+ });
6445
+ }
6446
+ getContextSync() {
6447
+ var _a, _b;
6448
+ const contextID = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.CONTEXT_ID)) === null || _a === void 0 ? void 0 : _a.value;
6449
+ const contextType = (_b = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.CONTEXT_TYPE)) === null || _b === void 0 ? void 0 : _b.value;
6450
+ return {
6451
+ type: contextType,
6452
+ id: contextID
6453
+ };
6396
6454
  }
6397
6455
  getJSBridge() {
6398
6456
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
@@ -6403,29 +6461,12 @@
6403
6461
  if (__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") && deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f")) {
6404
6462
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6405
6463
  }
6406
- const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
6407
- const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
6408
- const contextID = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_ID);
6409
- const contextType = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_TYPE);
6410
- if (deviceId) {
6411
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
6412
- }
6413
- if (contextID && contextType) {
6414
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_context, {
6415
- id: contextID.value,
6416
- type: contextType.value
6417
- }, "f");
6418
- }
6419
- const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
6420
- const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
6421
- if (!_.isUndefined(zOAuthCookie) &&
6422
- !_.isNull(zOAuthCookie) &&
6423
- _.isString(zOAuthCookie.value)) {
6424
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuthCookie.value, "f");
6425
- if (!_.isUndefined(zOAuthVrfCookie) &&
6426
- !_.isNull(zOAuthVrfCookie) &&
6427
- _.isString(zOAuthVrfCookie.value)) {
6428
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuthVrf, zOAuthVrfCookie.value, "f");
6464
+ const zOAuth = yield (yield this.getAuthCode()).authCode;
6465
+ const zOAuthVrf = yield (yield this.getAuthCode()).authCodeVerify;
6466
+ if (zOAuth) {
6467
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuth, "f");
6468
+ if (zOAuthVrf) {
6469
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuthVrf, zOAuthVrf, "f");
6429
6470
  yield this.loginZaloV4();
6430
6471
  }
6431
6472
  else {
@@ -6500,7 +6541,7 @@
6500
6541
  if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
6501
6542
  throw apiResponse.error.loginRequired();
6502
6543
  }
6503
- if (deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6544
+ if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f") || deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6504
6545
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6505
6546
  return yield this.login();
6506
6547
  });
@@ -6527,7 +6568,10 @@
6527
6568
  this.getAppId = () => {
6528
6569
  return __classPrivateFieldGet(this, _MockSDKService_appId, "f");
6529
6570
  };
6530
- this.getDeviceId = () => {
6571
+ this.getDeviceId = () => __awaiter(this, void 0, void 0, function* () {
6572
+ return Promise.resolve('');
6573
+ });
6574
+ this.getDeviceIdSync = () => {
6531
6575
  return '';
6532
6576
  };
6533
6577
  this.login = () => {
@@ -6830,8 +6874,19 @@
6830
6874
  this.openAppStore = (data) => {
6831
6875
  return Promise.resolve();
6832
6876
  };
6877
+ this.getAuthCode = () => {
6878
+ return Promise.resolve({
6879
+ authCode: '',
6880
+ authCodeVerify: ''
6881
+ });
6882
+ };
6833
6883
  }
6834
6884
  getContext() {
6885
+ return __awaiter(this, void 0, void 0, function* () {
6886
+ return Promise.resolve(null);
6887
+ });
6888
+ }
6889
+ getContextSync() {
6835
6890
  return null;
6836
6891
  }
6837
6892
  on(event, fn, context) {
@@ -6852,6 +6907,7 @@
6852
6907
  data: ''
6853
6908
  });
6854
6909
  }
6910
+ setAccessToken(accessToken) { }
6855
6911
  }
6856
6912
  _MockSDKService_appId = new WeakMap(), _MockSDKService_appConfig = new WeakMap(), _MockSDKService_zOAuth = new WeakMap(), _MockSDKService_accessToken = new WeakMap(), _MockSDKService_cache = new WeakMap(), _MockSDKService_loggedId = new WeakMap();
6857
6913
 
@@ -7383,7 +7439,6 @@
7383
7439
  }
7384
7440
  vibrate(object) {
7385
7441
  return __awaiter(this, void 0, void 0, function* () {
7386
- console.log(object);
7387
7442
  yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
7388
7443
  });
7389
7444
  }
@@ -7537,10 +7592,28 @@
7537
7592
  __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 0);
7538
7593
  }
7539
7594
  getDeviceId() {
7540
- return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
7595
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceIdSync();
7596
+ }
7597
+ getDeviceIdAsync(object) {
7598
+ return __awaiter(this, void 0, void 0, function* () {
7599
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
7600
+ });
7541
7601
  }
7542
7602
  getContext() {
7543
- return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContext();
7603
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContextSync();
7604
+ }
7605
+ getContextAsync(object) {
7606
+ return __awaiter(this, void 0, void 0, function* () {
7607
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContext();
7608
+ });
7609
+ }
7610
+ getAuthCode(object) {
7611
+ return __awaiter(this, void 0, void 0, function* () {
7612
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getAuthCode();
7613
+ });
7614
+ }
7615
+ setAccessToken(accessToken) {
7616
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setAccessToken(accessToken);
7544
7617
  }
7545
7618
  };
7546
7619
  _SDKCreator_sdkService = new WeakMap();
package/dist/index.es.js CHANGED
@@ -3740,7 +3740,7 @@ class ZMPEEmitter extends eventemitter3 {
3740
3740
  }
3741
3741
  }
3742
3742
 
3743
- var version$1 = "2.22.2";
3743
+ var version$1 = "2.23.0-0";
3744
3744
 
3745
3745
  class Basics {
3746
3746
  /**
@@ -4921,14 +4921,26 @@ class ZaloJSBridge extends eventemitter3 {
4921
4921
  this._userAgent = getUserAgent();
4922
4922
  this._device = checkPlatform();
4923
4923
  this.isJumped = false;
4924
- _ZaloJSBridge_cookies.set(this, null);
4924
+ _ZaloJSBridge_cookies.set(this, []);
4925
4925
  _ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
4926
+ this.getCookie = (name) => __awaiter(this, void 0, void 0, function* () {
4927
+ var _a;
4928
+ yield this.jump();
4929
+ const cookie = (_a = __classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) === null || _a === void 0 ? void 0 : _a.find((cookie) => cookie.name === name);
4930
+ return cookie;
4931
+ });
4932
+ this.getCookieSync = (name) => {
4933
+ var _a;
4934
+ const cookie = (_a = __classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) === null || _a === void 0 ? void 0 : _a.find((cookie) => cookie.name === name);
4935
+ return cookie;
4936
+ };
4926
4937
  this.jump = () => {
4927
4938
  return new Promise((resolve, reject) => {
4928
- if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
4939
+ if (this.isJumped) {
4929
4940
  resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
4930
4941
  }
4931
4942
  else {
4943
+ this.debug('******** call jump ********');
4932
4944
  this.callNative(ACTION.JUMP_LOGIN, {})
4933
4945
  .then((data) => {
4934
4946
  const cookies = (data && data.cookiesOAuthLogins) || [];
@@ -5112,7 +5124,7 @@ class ZaloJSBridge extends eventemitter3 {
5112
5124
  }
5113
5125
  callNative(action, data, option) {
5114
5126
  this.debug(action.name, data);
5115
- return new Promise((resolve, reject) => {
5127
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
5116
5128
  const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
5117
5129
  var _a, _b, _c, _d, _e, _f, _g, _h;
5118
5130
  try {
@@ -5136,7 +5148,8 @@ class ZaloJSBridge extends eventemitter3 {
5136
5148
  error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
5137
5149
  }
5138
5150
  else if ((_b = (_a = action.error_list) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b[String(cb.error_code)]) {
5139
- let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
5151
+ let error_message = action.error_list[platform][String(cb.error_code)].map_to
5152
+ .message;
5140
5153
  if ((_e = (_d = (_c = action.error_list) === null || _c === void 0 ? void 0 : _c[platform]) === null || _d === void 0 ? void 0 : _d[String(cb.error_code)]) === null || _e === void 0 ? void 0 : _e.need_more_detail) {
5141
5154
  error_message = `${(_h = (_g = (_f = action.error_list) === null || _f === void 0 ? void 0 : _f[platform]) === null || _g === void 0 ? void 0 : _g[String(cb.error_code)]) === null || _h === void 0 ? void 0 : _h.map_to.message}: ${cb.error_message}`;
5142
5155
  }
@@ -5156,6 +5169,12 @@ class ZaloJSBridge extends eventemitter3 {
5156
5169
  return reject(error);
5157
5170
  }
5158
5171
  });
5172
+ /**
5173
+ * Check jump status and auto call jump
5174
+ */
5175
+ if (!action.skip_jump) {
5176
+ yield this.jump();
5177
+ }
5159
5178
  const isIOS = checkPlatform().isIOS;
5160
5179
  const isSupportAction = checkIOSSupportAction(action);
5161
5180
  if (isIOS && !isSupportAction) {
@@ -5170,7 +5189,7 @@ class ZaloJSBridge extends eventemitter3 {
5170
5189
  else {
5171
5190
  __classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, data, handleNativeCallback, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
5172
5191
  }
5173
- });
5192
+ }));
5174
5193
  }
5175
5194
  }
5176
5195
  _ZaloJSBridge_cookies = new WeakMap(), _ZaloJSBridge_actionRuntimeInfo = new WeakMap(), _ZaloJSBridge_instances = new WeakSet(), _ZaloJSBridge_jsCall = function _ZaloJSBridge_jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
@@ -6270,6 +6289,21 @@ class ZaloMiniProgramSDKService {
6270
6289
  this.setActionBarConfig = (setState) => {
6271
6290
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
6272
6291
  };
6292
+ this.getAuthCode = () => __awaiter(this, void 0, void 0, function* () {
6293
+ var _t, _u;
6294
+ const authCode = (_t = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZOAUTH))) === null || _t === void 0 ? void 0 : _t.value;
6295
+ const authCodeVerify = (_u = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZOAUTH_VRF))) === null || _u === void 0 ? void 0 : _u.value;
6296
+ return {
6297
+ authCode,
6298
+ authCodeVerify
6299
+ };
6300
+ });
6301
+ this.setAccessToken = (accessToken) => {
6302
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, accessToken, "f");
6303
+ __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = accessToken;
6304
+ window.ZJSBridge.setZAccSession &&
6305
+ window.ZJSBridge.setZAccSession(accessToken);
6306
+ };
6273
6307
  this.getVersion = Basics.getVersion;
6274
6308
  this.getSystemInfo = Basics.getSystemInfo;
6275
6309
  this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
@@ -6386,10 +6420,34 @@ class ZaloMiniProgramSDKService {
6386
6420
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f");
6387
6421
  }
6388
6422
  getDeviceId() {
6389
- return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
6423
+ var _a;
6424
+ return __awaiter(this, void 0, void 0, function* () {
6425
+ return (_a = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.DEVICE_ID))) === null || _a === void 0 ? void 0 : _a.value;
6426
+ });
6427
+ }
6428
+ getDeviceIdSync() {
6429
+ var _a;
6430
+ return (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.DEVICE_ID)) === null || _a === void 0 ? void 0 : _a.value;
6390
6431
  }
6391
6432
  getContext() {
6392
- return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_context, "f");
6433
+ var _a, _b;
6434
+ return __awaiter(this, void 0, void 0, function* () {
6435
+ const contextID = (_a = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.CONTEXT_ID))) === null || _a === void 0 ? void 0 : _a.value;
6436
+ const contextType = (_b = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.CONTEXT_TYPE))) === null || _b === void 0 ? void 0 : _b.value;
6437
+ return {
6438
+ type: contextType,
6439
+ id: contextID
6440
+ };
6441
+ });
6442
+ }
6443
+ getContextSync() {
6444
+ var _a, _b;
6445
+ const contextID = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.CONTEXT_ID)) === null || _a === void 0 ? void 0 : _a.value;
6446
+ const contextType = (_b = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookieSync(COOKIE_NAME.CONTEXT_TYPE)) === null || _b === void 0 ? void 0 : _b.value;
6447
+ return {
6448
+ type: contextType,
6449
+ id: contextID
6450
+ };
6393
6451
  }
6394
6452
  getJSBridge() {
6395
6453
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
@@ -6400,29 +6458,12 @@ class ZaloMiniProgramSDKService {
6400
6458
  if (__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") && deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f")) {
6401
6459
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6402
6460
  }
6403
- const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
6404
- const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
6405
- const contextID = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_ID);
6406
- const contextType = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_TYPE);
6407
- if (deviceId) {
6408
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
6409
- }
6410
- if (contextID && contextType) {
6411
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_context, {
6412
- id: contextID.value,
6413
- type: contextType.value
6414
- }, "f");
6415
- }
6416
- const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
6417
- const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
6418
- if (!_.isUndefined(zOAuthCookie) &&
6419
- !_.isNull(zOAuthCookie) &&
6420
- _.isString(zOAuthCookie.value)) {
6421
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuthCookie.value, "f");
6422
- if (!_.isUndefined(zOAuthVrfCookie) &&
6423
- !_.isNull(zOAuthVrfCookie) &&
6424
- _.isString(zOAuthVrfCookie.value)) {
6425
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuthVrf, zOAuthVrfCookie.value, "f");
6461
+ const zOAuth = yield (yield this.getAuthCode()).authCode;
6462
+ const zOAuthVrf = yield (yield this.getAuthCode()).authCodeVerify;
6463
+ if (zOAuth) {
6464
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuth, "f");
6465
+ if (zOAuthVrf) {
6466
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuthVrf, zOAuthVrf, "f");
6426
6467
  yield this.loginZaloV4();
6427
6468
  }
6428
6469
  else {
@@ -6497,7 +6538,7 @@ class ZaloMiniProgramSDKService {
6497
6538
  if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
6498
6539
  throw apiResponse.error.loginRequired();
6499
6540
  }
6500
- if (deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6541
+ if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f") || deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6501
6542
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6502
6543
  return yield this.login();
6503
6544
  });
@@ -6524,7 +6565,10 @@ class MockSDKService {
6524
6565
  this.getAppId = () => {
6525
6566
  return __classPrivateFieldGet(this, _MockSDKService_appId, "f");
6526
6567
  };
6527
- this.getDeviceId = () => {
6568
+ this.getDeviceId = () => __awaiter(this, void 0, void 0, function* () {
6569
+ return Promise.resolve('');
6570
+ });
6571
+ this.getDeviceIdSync = () => {
6528
6572
  return '';
6529
6573
  };
6530
6574
  this.login = () => {
@@ -6827,8 +6871,19 @@ class MockSDKService {
6827
6871
  this.openAppStore = (data) => {
6828
6872
  return Promise.resolve();
6829
6873
  };
6874
+ this.getAuthCode = () => {
6875
+ return Promise.resolve({
6876
+ authCode: '',
6877
+ authCodeVerify: ''
6878
+ });
6879
+ };
6830
6880
  }
6831
6881
  getContext() {
6882
+ return __awaiter(this, void 0, void 0, function* () {
6883
+ return Promise.resolve(null);
6884
+ });
6885
+ }
6886
+ getContextSync() {
6832
6887
  return null;
6833
6888
  }
6834
6889
  on(event, fn, context) {
@@ -6849,6 +6904,7 @@ class MockSDKService {
6849
6904
  data: ''
6850
6905
  });
6851
6906
  }
6907
+ setAccessToken(accessToken) { }
6852
6908
  }
6853
6909
  _MockSDKService_appId = new WeakMap(), _MockSDKService_appConfig = new WeakMap(), _MockSDKService_zOAuth = new WeakMap(), _MockSDKService_accessToken = new WeakMap(), _MockSDKService_cache = new WeakMap(), _MockSDKService_loggedId = new WeakMap();
6854
6910
 
@@ -8738,7 +8794,6 @@ let SDKCreator = class SDKCreator {
8738
8794
  }
8739
8795
  vibrate(object) {
8740
8796
  return __awaiter(this, void 0, void 0, function* () {
8741
- console.log(object);
8742
8797
  yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
8743
8798
  });
8744
8799
  }
@@ -8892,10 +8947,28 @@ let SDKCreator = class SDKCreator {
8892
8947
  __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 0);
8893
8948
  }
8894
8949
  getDeviceId() {
8895
- return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
8950
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceIdSync();
8951
+ }
8952
+ getDeviceIdAsync(object) {
8953
+ return __awaiter(this, void 0, void 0, function* () {
8954
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
8955
+ });
8896
8956
  }
8897
8957
  getContext() {
8898
- return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContext();
8958
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContextSync();
8959
+ }
8960
+ getContextAsync(object) {
8961
+ return __awaiter(this, void 0, void 0, function* () {
8962
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getContext();
8963
+ });
8964
+ }
8965
+ getAuthCode(object) {
8966
+ return __awaiter(this, void 0, void 0, function* () {
8967
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getAuthCode();
8968
+ });
8969
+ }
8970
+ setAccessToken(accessToken) {
8971
+ return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setAccessToken(accessToken);
8899
8972
  }
8900
8973
  };
8901
8974
  _SDKCreator_sdkService = new WeakMap();