zmp-sdk 2.22.0 → 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.
@@ -1,6 +1,6 @@
1
1
  module.exports = function (Handlebars) {
2
- Handlebars.registerHelper('validTag', function (tag, options) {
3
- if (!tag) return false;
2
+ Handlebars.registerHelper('validTag', function (tag, commits, options) {
3
+ if (!tag || tag.indexOf('-') >=0 || commits.length <= 0) return false;
4
4
  var version = tag.split('v')[1];
5
5
  return version.localeCompare('2.21.2', undefined, { numeric: true, sensitivity: 'base' }) > 0;
6
6
  });
@@ -3,7 +3,7 @@
3
3
  [1]: https://www.npmjs.com/package/zmp-sdk?activeTab=versions
4
4
 
5
5
  {{#each releases}}
6
- {{#if (validTag tag)}}
6
+ {{#if (validTag tag commits)}}
7
7
  ## {{title}} ({{date}})
8
8
 
9
9
  {{! List commits with `Breaking change: ` somewhere in the message }}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  module.exports = function (Handlebars) {
4
- Handlebars.registerHelper('validTag', function (tag, options) {
5
- if (!tag) return false;
4
+ Handlebars.registerHelper('validTag', function (tag, commits, options) {
5
+ if (!tag || tag.indexOf('-') >= 0 || commits.length <= 0) return false;
6
6
  var version = tag.split('v')[1];
7
7
  return version.localeCompare('2.21.2', undefined, {
8
8
  numeric: true,
@@ -2783,7 +2783,7 @@
2783
2783
  unknown: 0
2784
2784
  };
2785
2785
  const ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION = {
2786
- android: 12100641,
2786
+ android: 12100615,
2787
2787
  iOS: 460,
2788
2788
  wp: 0,
2789
2789
  unknown: 0
@@ -3743,7 +3743,7 @@
3743
3743
  }
3744
3744
  }
3745
3745
 
3746
- var version = "2.22.0";
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,39 +6423,50 @@
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");
6399
6457
  }
6400
6458
  login(object) {
6401
6459
  return __awaiter(this, void 0, void 0, function* () {
6402
- const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
6403
- const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
6404
- const contextID = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_ID);
6405
- const contextType = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_TYPE);
6406
- if (deviceId) {
6407
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
6408
- }
6409
- if (contextID && contextType) {
6410
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_context, {
6411
- id: contextID.value,
6412
- type: contextType.value
6413
- }, "f");
6460
+ const deltaTime = new Date().getTime() - __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f");
6461
+ if (__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") && deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f")) {
6462
+ return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6414
6463
  }
6415
- const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
6416
- const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
6417
- if (!_.isUndefined(zOAuthCookie) &&
6418
- !_.isNull(zOAuthCookie) &&
6419
- _.isString(zOAuthCookie.value)) {
6420
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuthCookie.value, "f");
6421
- if (!_.isUndefined(zOAuthVrfCookie) &&
6422
- !_.isNull(zOAuthVrfCookie) &&
6423
- _.isString(zOAuthVrfCookie.value)) {
6424
- __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");
6425
6470
  yield this.loginZaloV4();
6426
6471
  }
6427
6472
  else {
@@ -6496,7 +6541,7 @@
6496
6541
  if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
6497
6542
  throw apiResponse.error.loginRequired();
6498
6543
  }
6499
- if (deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6544
+ if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f") || deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6500
6545
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6501
6546
  return yield this.login();
6502
6547
  });
@@ -6523,7 +6568,10 @@
6523
6568
  this.getAppId = () => {
6524
6569
  return __classPrivateFieldGet(this, _MockSDKService_appId, "f");
6525
6570
  };
6526
- this.getDeviceId = () => {
6571
+ this.getDeviceId = () => __awaiter(this, void 0, void 0, function* () {
6572
+ return Promise.resolve('');
6573
+ });
6574
+ this.getDeviceIdSync = () => {
6527
6575
  return '';
6528
6576
  };
6529
6577
  this.login = () => {
@@ -6826,8 +6874,19 @@
6826
6874
  this.openAppStore = (data) => {
6827
6875
  return Promise.resolve();
6828
6876
  };
6877
+ this.getAuthCode = () => {
6878
+ return Promise.resolve({
6879
+ authCode: '',
6880
+ authCodeVerify: ''
6881
+ });
6882
+ };
6829
6883
  }
6830
6884
  getContext() {
6885
+ return __awaiter(this, void 0, void 0, function* () {
6886
+ return Promise.resolve(null);
6887
+ });
6888
+ }
6889
+ getContextSync() {
6831
6890
  return null;
6832
6891
  }
6833
6892
  on(event, fn, context) {
@@ -6848,6 +6907,7 @@
6848
6907
  data: ''
6849
6908
  });
6850
6909
  }
6910
+ setAccessToken(accessToken) { }
6851
6911
  }
6852
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();
6853
6913
 
@@ -7379,7 +7439,6 @@
7379
7439
  }
7380
7440
  vibrate(object) {
7381
7441
  return __awaiter(this, void 0, void 0, function* () {
7382
- console.log(object);
7383
7442
  yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
7384
7443
  });
7385
7444
  }
@@ -7533,10 +7592,28 @@
7533
7592
  __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 0);
7534
7593
  }
7535
7594
  getDeviceId() {
7536
- 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
+ });
7537
7601
  }
7538
7602
  getContext() {
7539
- 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);
7540
7617
  }
7541
7618
  };
7542
7619
  _SDKCreator_sdkService = new WeakMap();
package/dist/index.es.js CHANGED
@@ -2780,7 +2780,7 @@ const ZALO_SUPPORT_STORAGE_VERSION = {
2780
2780
  unknown: 0
2781
2781
  };
2782
2782
  const ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION = {
2783
- android: 12100641,
2783
+ android: 12100615,
2784
2784
  iOS: 460,
2785
2785
  wp: 0,
2786
2786
  unknown: 0
@@ -3740,7 +3740,7 @@ class ZMPEEmitter extends eventemitter3 {
3740
3740
  }
3741
3741
  }
3742
3742
 
3743
- var version$1 = "2.22.0";
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,39 +6420,50 @@ 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");
6396
6454
  }
6397
6455
  login(object) {
6398
6456
  return __awaiter(this, void 0, void 0, function* () {
6399
- const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
6400
- const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
6401
- const contextID = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_ID);
6402
- const contextType = cookies.find((cookie) => cookie.name === COOKIE_NAME.CONTEXT_TYPE);
6403
- if (deviceId) {
6404
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
6405
- }
6406
- if (contextID && contextType) {
6407
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_context, {
6408
- id: contextID.value,
6409
- type: contextType.value
6410
- }, "f");
6457
+ const deltaTime = new Date().getTime() - __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f");
6458
+ if (__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") && deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f")) {
6459
+ return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6411
6460
  }
6412
- const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
6413
- const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
6414
- if (!_.isUndefined(zOAuthCookie) &&
6415
- !_.isNull(zOAuthCookie) &&
6416
- _.isString(zOAuthCookie.value)) {
6417
- __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_zOAuth, zOAuthCookie.value, "f");
6418
- if (!_.isUndefined(zOAuthVrfCookie) &&
6419
- !_.isNull(zOAuthVrfCookie) &&
6420
- _.isString(zOAuthVrfCookie.value)) {
6421
- __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");
6422
6467
  yield this.loginZaloV4();
6423
6468
  }
6424
6469
  else {
@@ -6493,7 +6538,7 @@ class ZaloMiniProgramSDKService {
6493
6538
  if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
6494
6539
  throw apiResponse.error.loginRequired();
6495
6540
  }
6496
- if (deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6541
+ if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, "f") || deltaTime < __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, "f"))
6497
6542
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
6498
6543
  return yield this.login();
6499
6544
  });
@@ -6520,7 +6565,10 @@ class MockSDKService {
6520
6565
  this.getAppId = () => {
6521
6566
  return __classPrivateFieldGet(this, _MockSDKService_appId, "f");
6522
6567
  };
6523
- this.getDeviceId = () => {
6568
+ this.getDeviceId = () => __awaiter(this, void 0, void 0, function* () {
6569
+ return Promise.resolve('');
6570
+ });
6571
+ this.getDeviceIdSync = () => {
6524
6572
  return '';
6525
6573
  };
6526
6574
  this.login = () => {
@@ -6823,8 +6871,19 @@ class MockSDKService {
6823
6871
  this.openAppStore = (data) => {
6824
6872
  return Promise.resolve();
6825
6873
  };
6874
+ this.getAuthCode = () => {
6875
+ return Promise.resolve({
6876
+ authCode: '',
6877
+ authCodeVerify: ''
6878
+ });
6879
+ };
6826
6880
  }
6827
6881
  getContext() {
6882
+ return __awaiter(this, void 0, void 0, function* () {
6883
+ return Promise.resolve(null);
6884
+ });
6885
+ }
6886
+ getContextSync() {
6828
6887
  return null;
6829
6888
  }
6830
6889
  on(event, fn, context) {
@@ -6845,6 +6904,7 @@ class MockSDKService {
6845
6904
  data: ''
6846
6905
  });
6847
6906
  }
6907
+ setAccessToken(accessToken) { }
6848
6908
  }
6849
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();
6850
6910
 
@@ -8734,7 +8794,6 @@ let SDKCreator = class SDKCreator {
8734
8794
  }
8735
8795
  vibrate(object) {
8736
8796
  return __awaiter(this, void 0, void 0, function* () {
8737
- console.log(object);
8738
8797
  yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
8739
8798
  });
8740
8799
  }
@@ -8888,10 +8947,28 @@ let SDKCreator = class SDKCreator {
8888
8947
  __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 0);
8889
8948
  }
8890
8949
  getDeviceId() {
8891
- 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
+ });
8892
8956
  }
8893
8957
  getContext() {
8894
- 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);
8895
8972
  }
8896
8973
  };
8897
8974
  _SDKCreator_sdkService = new WeakMap();