zmp-sdk 2.23.3 → 2.23.4

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.
@@ -2250,6 +2250,9 @@
2250
2250
  DEVICE_ID: `h5.zdn.vn_deviceID`,
2251
2251
  CONTEXT_ID: `h5.zdn.vn_contextID`,
2252
2252
  CONTEXT_TYPE: `h5.zdn.vn_contextType`,
2253
+ UTOKEN_ZPI: 'h5.zdn.vn_utoken_zpi',
2254
+ GTOKEN_ZPI: 'h5.zdn.vn_gtoken_zpi',
2255
+ ZPP_ZPI: 'h5.zdn.vn_zpp_zpi',
2253
2256
  };
2254
2257
  const APIS = {
2255
2258
  GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
@@ -3307,6 +3310,12 @@
3307
3310
  }
3308
3311
  if (option) {
3309
3312
  if (Array.isArray(option === null || option === void 0 ? void 0 : option.values)) {
3313
+ if (Array.isArray(data)) {
3314
+ return {
3315
+ error: data.some((item) => { var _a; return !((_a = option === null || option === void 0 ? void 0 : option.values) === null || _a === void 0 ? void 0 : _a.includes(item)); }),
3316
+ errorMessage: option === null || option === void 0 ? void 0 : option.values.toString()
3317
+ };
3318
+ }
3310
3319
  return {
3311
3320
  error: !(option === null || option === void 0 ? void 0 : option.values.includes(data)),
3312
3321
  errorMessage: option === null || option === void 0 ? void 0 : option.values.toString()
@@ -3747,7 +3756,7 @@
3747
3756
  }
3748
3757
  }
3749
3758
 
3750
- var version = "2.23.3";
3759
+ var version = "2.23.4";
3751
3760
 
3752
3761
  class Basics {
3753
3762
  /**
@@ -6355,6 +6364,17 @@
6355
6364
  authCodeVerify
6356
6365
  };
6357
6366
  });
6367
+ this.getZPIToken = () => __awaiter(this, void 0, void 0, function* () {
6368
+ var _v, _w, _x;
6369
+ const utoken = (_v = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.UTOKEN_ZPI))) === null || _v === void 0 ? void 0 : _v.value;
6370
+ const gtoken = (_w = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.GTOKEN_ZPI))) === null || _w === void 0 ? void 0 : _w.value;
6371
+ const zpp = (_x = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZPP_ZPI))) === null || _x === void 0 ? void 0 : _x.value;
6372
+ return {
6373
+ utoken,
6374
+ gtoken,
6375
+ zpp
6376
+ };
6377
+ });
6358
6378
  this.setAccessToken = (accessToken) => {
6359
6379
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_autoLogin, false, "f");
6360
6380
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, accessToken, "f");
@@ -6963,6 +6983,13 @@
6963
6983
  authCodeVerify: ''
6964
6984
  });
6965
6985
  };
6986
+ this.getZPIToken = () => {
6987
+ return Promise.resolve({
6988
+ utoken: '',
6989
+ gtoken: '',
6990
+ zpp: ''
6991
+ });
6992
+ };
6966
6993
  }
6967
6994
  getContext() {
6968
6995
  return __awaiter(this, void 0, void 0, function* () {
@@ -7528,7 +7555,7 @@
7528
7555
  openWebview(object) {
7529
7556
  return __awaiter(this, void 0, void 0, function* () {
7530
7557
  const url = new URL(object.url);
7531
- const isVNPayLink = url.href.includes("vnpay");
7558
+ const isVNPayLink = url.href.includes('vnpay');
7532
7559
  const typeInapp = url.searchParams.get('typeInapp');
7533
7560
  if (!isVNPayLink && _.isEmpty(typeInapp)) {
7534
7561
  url.searchParams.set('typeInapp', '1');
@@ -7696,6 +7723,11 @@
7696
7723
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getAuthCode();
7697
7724
  });
7698
7725
  }
7726
+ getZPIToken(object) {
7727
+ return __awaiter(this, void 0, void 0, function* () {
7728
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getZPIToken();
7729
+ });
7730
+ }
7699
7731
  setAccessToken(accessToken) {
7700
7732
  return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setAccessToken(accessToken);
7701
7733
  }
@@ -7704,6 +7736,51 @@
7704
7736
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").openOutApp(encodeURI(object.url));
7705
7737
  });
7706
7738
  }
7739
+ chooseImage(object) {
7740
+ return __awaiter(this, void 0, void 0, function* () {
7741
+ const sourceType = object.sourceType || ['album', 'camera'];
7742
+ const cameraType = object.cameraType || 'front';
7743
+ const count = object.count || 1;
7744
+ const inputEl = document.createElement('input');
7745
+ inputEl.type = 'file';
7746
+ inputEl.multiple = count > 1;
7747
+ inputEl.accept = 'image/*';
7748
+ inputEl.style.display = 'none';
7749
+ if (sourceType.length === 1 && sourceType.includes('camera')) {
7750
+ inputEl.accept =
7751
+ cameraType === 'front'
7752
+ ? 'zcamera/photo-frontfacing'
7753
+ : 'zcamera/photo-backfacing';
7754
+ inputEl.capture =
7755
+ cameraType === 'front' ? 'user' : 'environment';
7756
+ }
7757
+ return new Promise((resolve, reject) => {
7758
+ inputEl.addEventListener('change', (event) => {
7759
+ var _a;
7760
+ const fileList = ((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.files) || [];
7761
+ if (fileList.length > count) {
7762
+ reject(new Error(`You are only allowed to choose a maximum of ${count} images at a time`));
7763
+ }
7764
+ else {
7765
+ const result = {
7766
+ filePaths: [],
7767
+ tempFiles: []
7768
+ };
7769
+ Array.from(fileList).forEach((file) => {
7770
+ result.filePaths.push(URL.createObjectURL(file));
7771
+ result.tempFiles.push({
7772
+ path: URL.createObjectURL(file),
7773
+ size: file.size
7774
+ });
7775
+ });
7776
+ resolve(result);
7777
+ }
7778
+ });
7779
+ document.body.appendChild(inputEl);
7780
+ inputEl.click();
7781
+ });
7782
+ });
7783
+ }
7707
7784
  };
7708
7785
  _SDKCreator_sdkService = new WeakMap();
7709
7786
  __decorate([
@@ -7959,6 +8036,19 @@
7959
8036
  url: checkData('url'),
7960
8037
  }))
7961
8038
  ], SDKCreator.prototype, "openOutApp", null);
8039
+ __decorate([
8040
+ __param(0, checkType('object', {
8041
+ 'count?': checkData('number', { min: 1, default: 1 }),
8042
+ 'sourceType?': checkData('array<string>', {
8043
+ values: ['album', 'camera'],
8044
+ default: ['album', 'camera']
8045
+ }),
8046
+ 'cameraType?': checkData('string', {
8047
+ values: ['back', 'front'],
8048
+ default: ['front']
8049
+ })
8050
+ }))
8051
+ ], SDKCreator.prototype, "chooseImage", null);
7962
8052
  SDKCreator = __decorate([
7963
8053
  DecorateAll(centralizedFunctionHandler)
7964
8054
  ], SDKCreator);
package/dist/index.es.js CHANGED
@@ -2247,6 +2247,9 @@ const COOKIE_NAME = {
2247
2247
  DEVICE_ID: `h5.zdn.vn_deviceID`,
2248
2248
  CONTEXT_ID: `h5.zdn.vn_contextID`,
2249
2249
  CONTEXT_TYPE: `h5.zdn.vn_contextType`,
2250
+ UTOKEN_ZPI: 'h5.zdn.vn_utoken_zpi',
2251
+ GTOKEN_ZPI: 'h5.zdn.vn_gtoken_zpi',
2252
+ ZPP_ZPI: 'h5.zdn.vn_zpp_zpi',
2250
2253
  };
2251
2254
  const APIS = {
2252
2255
  GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
@@ -3304,6 +3307,12 @@ const checkData = (types, option) => (data) => {
3304
3307
  }
3305
3308
  if (option) {
3306
3309
  if (Array.isArray(option === null || option === void 0 ? void 0 : option.values)) {
3310
+ if (Array.isArray(data)) {
3311
+ return {
3312
+ error: data.some((item) => { var _a; return !((_a = option === null || option === void 0 ? void 0 : option.values) === null || _a === void 0 ? void 0 : _a.includes(item)); }),
3313
+ errorMessage: option === null || option === void 0 ? void 0 : option.values.toString()
3314
+ };
3315
+ }
3307
3316
  return {
3308
3317
  error: !(option === null || option === void 0 ? void 0 : option.values.includes(data)),
3309
3318
  errorMessage: option === null || option === void 0 ? void 0 : option.values.toString()
@@ -3744,7 +3753,7 @@ class ZMPEEmitter extends eventemitter3 {
3744
3753
  }
3745
3754
  }
3746
3755
 
3747
- var version$1 = "2.23.3";
3756
+ var version$1 = "2.23.4";
3748
3757
 
3749
3758
  class Basics {
3750
3759
  /**
@@ -6352,6 +6361,17 @@ class ZaloMiniProgramSDKService {
6352
6361
  authCodeVerify
6353
6362
  };
6354
6363
  });
6364
+ this.getZPIToken = () => __awaiter(this, void 0, void 0, function* () {
6365
+ var _v, _w, _x;
6366
+ const utoken = (_v = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.UTOKEN_ZPI))) === null || _v === void 0 ? void 0 : _v.value;
6367
+ const gtoken = (_w = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.GTOKEN_ZPI))) === null || _w === void 0 ? void 0 : _w.value;
6368
+ const zpp = (_x = (yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").getCookie(COOKIE_NAME.ZPP_ZPI))) === null || _x === void 0 ? void 0 : _x.value;
6369
+ return {
6370
+ utoken,
6371
+ gtoken,
6372
+ zpp
6373
+ };
6374
+ });
6355
6375
  this.setAccessToken = (accessToken) => {
6356
6376
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_autoLogin, false, "f");
6357
6377
  __classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, accessToken, "f");
@@ -6960,6 +6980,13 @@ class MockSDKService {
6960
6980
  authCodeVerify: ''
6961
6981
  });
6962
6982
  };
6983
+ this.getZPIToken = () => {
6984
+ return Promise.resolve({
6985
+ utoken: '',
6986
+ gtoken: '',
6987
+ zpp: ''
6988
+ });
6989
+ };
6963
6990
  }
6964
6991
  getContext() {
6965
6992
  return __awaiter(this, void 0, void 0, function* () {
@@ -8883,7 +8910,7 @@ let SDKCreator = class SDKCreator {
8883
8910
  openWebview(object) {
8884
8911
  return __awaiter(this, void 0, void 0, function* () {
8885
8912
  const url = new URL(object.url);
8886
- const isVNPayLink = url.href.includes("vnpay");
8913
+ const isVNPayLink = url.href.includes('vnpay');
8887
8914
  const typeInapp = url.searchParams.get('typeInapp');
8888
8915
  if (!isVNPayLink && _.isEmpty(typeInapp)) {
8889
8916
  url.searchParams.set('typeInapp', '1');
@@ -9051,6 +9078,11 @@ let SDKCreator = class SDKCreator {
9051
9078
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getAuthCode();
9052
9079
  });
9053
9080
  }
9081
+ getZPIToken(object) {
9082
+ return __awaiter(this, void 0, void 0, function* () {
9083
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getZPIToken();
9084
+ });
9085
+ }
9054
9086
  setAccessToken(accessToken) {
9055
9087
  return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setAccessToken(accessToken);
9056
9088
  }
@@ -9059,6 +9091,51 @@ let SDKCreator = class SDKCreator {
9059
9091
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").openOutApp(encodeURI(object.url));
9060
9092
  });
9061
9093
  }
9094
+ chooseImage(object) {
9095
+ return __awaiter(this, void 0, void 0, function* () {
9096
+ const sourceType = object.sourceType || ['album', 'camera'];
9097
+ const cameraType = object.cameraType || 'front';
9098
+ const count = object.count || 1;
9099
+ const inputEl = document.createElement('input');
9100
+ inputEl.type = 'file';
9101
+ inputEl.multiple = count > 1;
9102
+ inputEl.accept = 'image/*';
9103
+ inputEl.style.display = 'none';
9104
+ if (sourceType.length === 1 && sourceType.includes('camera')) {
9105
+ inputEl.accept =
9106
+ cameraType === 'front'
9107
+ ? 'zcamera/photo-frontfacing'
9108
+ : 'zcamera/photo-backfacing';
9109
+ inputEl.capture =
9110
+ cameraType === 'front' ? 'user' : 'environment';
9111
+ }
9112
+ return new Promise((resolve, reject) => {
9113
+ inputEl.addEventListener('change', (event) => {
9114
+ var _a;
9115
+ const fileList = ((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.files) || [];
9116
+ if (fileList.length > count) {
9117
+ reject(new Error(`You are only allowed to choose a maximum of ${count} images at a time`));
9118
+ }
9119
+ else {
9120
+ const result = {
9121
+ filePaths: [],
9122
+ tempFiles: []
9123
+ };
9124
+ Array.from(fileList).forEach((file) => {
9125
+ result.filePaths.push(URL.createObjectURL(file));
9126
+ result.tempFiles.push({
9127
+ path: URL.createObjectURL(file),
9128
+ size: file.size
9129
+ });
9130
+ });
9131
+ resolve(result);
9132
+ }
9133
+ });
9134
+ document.body.appendChild(inputEl);
9135
+ inputEl.click();
9136
+ });
9137
+ });
9138
+ }
9062
9139
  };
9063
9140
  _SDKCreator_sdkService = new WeakMap();
9064
9141
  __decorate([
@@ -9314,6 +9391,19 @@ __decorate([
9314
9391
  url: checkData('url'),
9315
9392
  }))
9316
9393
  ], SDKCreator.prototype, "openOutApp", null);
9394
+ __decorate([
9395
+ __param(0, checkType('object', {
9396
+ 'count?': checkData('number', { min: 1, default: 1 }),
9397
+ 'sourceType?': checkData('array<string>', {
9398
+ values: ['album', 'camera'],
9399
+ default: ['album', 'camera']
9400
+ }),
9401
+ 'cameraType?': checkData('string', {
9402
+ values: ['back', 'front'],
9403
+ default: ['front']
9404
+ })
9405
+ }))
9406
+ ], SDKCreator.prototype, "chooseImage", null);
9317
9407
  SDKCreator = __decorate([
9318
9408
  DecorateAll(centralizedFunctionHandler)
9319
9409
  ], SDKCreator);