zmp-sdk 2.14.2 → 2.15.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.
@@ -21366,6 +21366,7 @@
21366
21366
  ShareSheetType[ShareSheetType["video"] = 12] = "video";
21367
21367
  ShareSheetType[ShareSheetType["link"] = 4] = "link";
21368
21368
  ShareSheetType[ShareSheetType["oa"] = 5] = "oa";
21369
+ ShareSheetType["zmp"] = "zmp";
21369
21370
  })(ShareSheetType || (ShareSheetType = {}));
21370
21371
  var OrientationType;
21371
21372
  (function (OrientationType) {
@@ -21565,6 +21566,7 @@
21565
21566
  ];
21566
21567
  const RESPONSE_CODE = {
21567
21568
  BAD_REQUEST: -1400,
21569
+ INTERNAL_SERVER_ERROR: -1500,
21568
21570
  UNAUTHORIZED: -1401,
21569
21571
  FORBIDDEN: -1403
21570
21572
  };
@@ -21590,7 +21592,7 @@
21590
21592
  const REGEXP_SPECIAL_UNICODE = new RegExp('[\\u0300-\\u036f]', 'g');
21591
21593
  const REGEXP_ACCENT_D = new RegExp('[đ|Đ]', 'g');
21592
21594
  const REGEXP_SPACES = new RegExp('\\s', 'g');
21593
- const debug$2 = src("zmp:utils:common");
21595
+ const debug$2 = src('zmp:utils:common');
21594
21596
  /**
21595
21597
  * Checks if a url is valid
21596
21598
  * @param {string} string URL
@@ -21690,10 +21692,11 @@
21690
21692
  const isArrayType = lowerCaseType === 'array' ||
21691
21693
  lowerCaseType === 'array<number>' ||
21692
21694
  lowerCaseType === 'array<string>';
21693
- if ((isArrayType &&
21694
- ((lowerCaseType === 'array' && Array.isArray(argument)) ||
21695
- (lowerCaseType === 'array<number>' && isArrayNumber(argument)) ||
21696
- (lowerCaseType === 'array<string>' && isArrayString(argument)))) ||
21695
+ if ((lowerCaseType === 'url' && isValidUrl(argument)) ||
21696
+ (isArrayType &&
21697
+ ((lowerCaseType === 'array' && Array.isArray(argument)) ||
21698
+ (lowerCaseType === 'array<number>' && isArrayNumber(argument)) ||
21699
+ (lowerCaseType === 'array<string>' && isArrayString(argument)))) ||
21697
21700
  (!Array.isArray(argument) && typeof argument === type)) {
21698
21701
  return true;
21699
21702
  }
@@ -21813,6 +21816,23 @@
21813
21816
  console.log(error);
21814
21817
  return data;
21815
21818
  }
21819
+ };
21820
+ const showUserInfoPermissionModal = (acceptHandler, denyHandler) => {
21821
+ const userInfoPermissionModal = document.getElementById('zmp-permission-container');
21822
+ const buttonAccept = document.getElementById('button-accept');
21823
+ const buttonDeny = document.getElementById('button-deny');
21824
+ if (!userInfoPermissionModal || !buttonAccept || !buttonDeny)
21825
+ return;
21826
+ // show modal
21827
+ userInfoPermissionModal.style.display = 'block';
21828
+ buttonAccept.onclick = () => {
21829
+ acceptHandler && acceptHandler();
21830
+ userInfoPermissionModal.style.display = 'none';
21831
+ };
21832
+ buttonDeny.onclick = () => {
21833
+ denyHandler && denyHandler();
21834
+ userInfoPermissionModal.style.display = 'none';
21835
+ };
21816
21836
  };
21817
21837
 
21818
21838
  /*! *****************************************************************************
@@ -34674,38 +34694,51 @@
34674
34694
  'default': zlib$1
34675
34695
  });
34676
34696
 
34677
- var name = "axios";
34678
- var version$1 = "0.21.1";
34679
- var description = "Promise based HTTP client for the browser and node.js";
34680
- var main = "index.js";
34681
- var scripts = {
34682
- test: "grunt test && bundlesize",
34683
- start: "node ./sandbox/server.js",
34684
- build: "NODE_ENV=production grunt build",
34685
- preversion: "npm test",
34686
- version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
34687
- postversion: "git push && git push --tags",
34688
- examples: "node ./examples/server.js",
34689
- coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
34690
- fix: "eslint --fix lib/**/*.js"
34697
+ var _from = "axios@0.21.1";
34698
+ var _id = "axios@0.21.1";
34699
+ var _inBundle = false;
34700
+ var _integrity = "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==";
34701
+ var _location = "/zmp-sdk/axios";
34702
+ var _phantomChildren = {
34691
34703
  };
34692
- var repository = {
34693
- type: "git",
34694
- url: "https://github.com/axios/axios.git"
34704
+ var _requested = {
34705
+ type: "version",
34706
+ registry: true,
34707
+ raw: "axios@0.21.1",
34708
+ name: "axios",
34709
+ escapedName: "axios",
34710
+ rawSpec: "0.21.1",
34711
+ saveSpec: null,
34712
+ fetchSpec: "0.21.1"
34695
34713
  };
34696
- var keywords = [
34697
- "xhr",
34698
- "http",
34699
- "ajax",
34700
- "promise",
34701
- "node"
34714
+ var _requiredBy = [
34715
+ "/zmp-sdk"
34702
34716
  ];
34703
- var author = "Matt Zabriskie";
34704
- var license = "MIT";
34717
+ var _resolved = "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz";
34718
+ var _shasum = "22563481962f4d6bde9a76d516ef0e5d3c09b2b8";
34719
+ var _spec = "axios@0.21.1";
34720
+ var _where = "/Users/nguyentuankiet/Work/Zalo/Projects/ZaloMiniProgram/TestNewFunction";
34721
+ var author = {
34722
+ name: "Matt Zabriskie"
34723
+ };
34724
+ var browser = {
34725
+ "./lib/adapters/http.js": "./lib/adapters/xhr.js"
34726
+ };
34705
34727
  var bugs = {
34706
34728
  url: "https://github.com/axios/axios/issues"
34707
34729
  };
34708
- var homepage = "https://github.com/axios/axios";
34730
+ var bundleDependencies = false;
34731
+ var bundlesize = [
34732
+ {
34733
+ path: "./dist/axios.min.js",
34734
+ threshold: "5kB"
34735
+ }
34736
+ ];
34737
+ var dependencies = {
34738
+ "follow-redirects": "^1.10.0"
34739
+ };
34740
+ var deprecated = false;
34741
+ var description = "Promise based HTTP client for the browser and node.js";
34709
34742
  var devDependencies = {
34710
34743
  bundlesize: "^0.17.0",
34711
34744
  coveralls: "^3.0.0",
@@ -34743,62 +34776,105 @@
34743
34776
  webpack: "^1.13.1",
34744
34777
  "webpack-dev-server": "^1.14.1"
34745
34778
  };
34746
- var browser = {
34747
- "./lib/adapters/http.js": "./lib/adapters/xhr.js"
34748
- };
34779
+ var homepage = "https://github.com/axios/axios";
34749
34780
  var jsdelivr = "dist/axios.min.js";
34750
- var unpkg = "dist/axios.min.js";
34751
- var typings = "./index.d.ts";
34752
- var dependencies = {
34753
- "follow-redirects": "^1.10.0"
34754
- };
34755
- var bundlesize = [
34756
- {
34757
- path: "./dist/axios.min.js",
34758
- threshold: "5kB"
34759
- }
34781
+ var keywords = [
34782
+ "xhr",
34783
+ "http",
34784
+ "ajax",
34785
+ "promise",
34786
+ "node"
34760
34787
  ];
34788
+ var license = "MIT";
34789
+ var main = "index.js";
34790
+ var name = "axios";
34791
+ var repository = {
34792
+ type: "git",
34793
+ url: "git+https://github.com/axios/axios.git"
34794
+ };
34795
+ var scripts = {
34796
+ build: "NODE_ENV=production grunt build",
34797
+ coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
34798
+ examples: "node ./examples/server.js",
34799
+ fix: "eslint --fix lib/**/*.js",
34800
+ postversion: "git push && git push --tags",
34801
+ preversion: "npm test",
34802
+ start: "node ./sandbox/server.js",
34803
+ test: "grunt test && bundlesize",
34804
+ version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
34805
+ };
34806
+ var typings = "./index.d.ts";
34807
+ var unpkg = "dist/axios.min.js";
34808
+ var version$1 = "0.21.1";
34761
34809
  var _package = {
34762
- name: name,
34763
- version: version$1,
34764
- description: description,
34765
- main: main,
34766
- scripts: scripts,
34767
- repository: repository,
34768
- keywords: keywords,
34810
+ _from: _from,
34811
+ _id: _id,
34812
+ _inBundle: _inBundle,
34813
+ _integrity: _integrity,
34814
+ _location: _location,
34815
+ _phantomChildren: _phantomChildren,
34816
+ _requested: _requested,
34817
+ _requiredBy: _requiredBy,
34818
+ _resolved: _resolved,
34819
+ _shasum: _shasum,
34820
+ _spec: _spec,
34821
+ _where: _where,
34769
34822
  author: author,
34770
- license: license,
34823
+ browser: browser,
34771
34824
  bugs: bugs,
34772
- homepage: homepage,
34825
+ bundleDependencies: bundleDependencies,
34826
+ bundlesize: bundlesize,
34827
+ dependencies: dependencies,
34828
+ deprecated: deprecated,
34829
+ description: description,
34773
34830
  devDependencies: devDependencies,
34774
- browser: browser,
34831
+ homepage: homepage,
34775
34832
  jsdelivr: jsdelivr,
34776
- unpkg: unpkg,
34833
+ keywords: keywords,
34834
+ license: license,
34835
+ main: main,
34836
+ name: name,
34837
+ repository: repository,
34838
+ scripts: scripts,
34777
34839
  typings: typings,
34778
- dependencies: dependencies,
34779
- bundlesize: bundlesize
34840
+ unpkg: unpkg,
34841
+ version: version$1
34780
34842
  };
34781
34843
 
34782
34844
  var _package$1 = /*#__PURE__*/Object.freeze({
34783
34845
  __proto__: null,
34784
- name: name,
34785
- version: version$1,
34786
- description: description,
34787
- main: main,
34788
- scripts: scripts,
34789
- repository: repository,
34790
- keywords: keywords,
34846
+ _from: _from,
34847
+ _id: _id,
34848
+ _inBundle: _inBundle,
34849
+ _integrity: _integrity,
34850
+ _location: _location,
34851
+ _phantomChildren: _phantomChildren,
34852
+ _requested: _requested,
34853
+ _requiredBy: _requiredBy,
34854
+ _resolved: _resolved,
34855
+ _shasum: _shasum,
34856
+ _spec: _spec,
34857
+ _where: _where,
34791
34858
  author: author,
34792
- license: license,
34859
+ browser: browser,
34793
34860
  bugs: bugs,
34794
- homepage: homepage,
34861
+ bundleDependencies: bundleDependencies,
34862
+ bundlesize: bundlesize,
34863
+ dependencies: dependencies,
34864
+ deprecated: deprecated,
34865
+ description: description,
34795
34866
  devDependencies: devDependencies,
34796
- browser: browser,
34867
+ homepage: homepage,
34797
34868
  jsdelivr: jsdelivr,
34798
- unpkg: unpkg,
34869
+ keywords: keywords,
34870
+ license: license,
34871
+ main: main,
34872
+ name: name,
34873
+ repository: repository,
34874
+ scripts: scripts,
34799
34875
  typings: typings,
34800
- dependencies: dependencies,
34801
- bundlesize: bundlesize,
34876
+ unpkg: unpkg,
34877
+ version: version$1,
34802
34878
  'default': _package
34803
34879
  });
34804
34880
 
@@ -36184,11 +36260,13 @@
36184
36260
  loginFailed: () => new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_FAILED),
36185
36261
  loginRequired: () => new CommonError(RESPONSE_CODE.BAD_REQUEST, MESSAGES.LOGIN_REQUIRED),
36186
36262
  missingParam: (params) => new CommonError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
36187
- wrongTypeParam: (arg, expected, got) => new CommonError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`)
36263
+ wrongTypeParam: (arg, expected, got) => new CommonError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
36264
+ cannotGetShareInfo: () => new CommonError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
36265
+ lengthInvalid: (arg) => new CommonError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
36188
36266
  }
36189
36267
  };
36190
36268
 
36191
- var version = "2.14.2";
36269
+ var version = "2.15.0-0";
36192
36270
 
36193
36271
  class Basics {
36194
36272
  /**
@@ -38058,6 +38136,28 @@
38058
38136
  uid: object.data.id
38059
38137
  };
38060
38138
  break;
38139
+ case 'zmp':
38140
+ const currentUrl = new URL(location.href);
38141
+ const params = new URLSearchParams();
38142
+ params.append('title', object.data.title);
38143
+ params.append('description', object.data.description);
38144
+ params.append('thumbnail', object.data.thumbnail);
38145
+ params.append('url', `https://zalo.me/app/link${currentUrl.pathname}${currentUrl.search}`);
38146
+ const config = {
38147
+ headers: {
38148
+ 'Content-Type': 'application/x-www-form-urlencoded'
38149
+ }
38150
+ };
38151
+ const res = yield axios.post('https://h5.zalo.me/openapi/create-sharelink', params, config);
38152
+ const resData = res.data;
38153
+ if (!resData || resData.err !== 0) {
38154
+ throw apiResponse.error.cannotGetShareInfo();
38155
+ }
38156
+ object.type = 'link';
38157
+ reqData = {
38158
+ link: resData.data.shareUrl,
38159
+ chatOnly: object.data.chatOnly ? 1 : 0
38160
+ };
38061
38161
  }
38062
38162
  return yield this.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[object.type] }, reqData), { zapp: this.getZAppId() }), {
38063
38163
  haveTimeout: false
@@ -38204,19 +38304,23 @@
38204
38304
  });
38205
38305
  _ZaloMiniProgramSDK_callJump.set(this, () => {
38206
38306
  return new Promise((resolve, reject) => {
38207
- this.callNative('action.jump.login', {})
38208
- .then((data) => {
38209
- const cookies = (data && data.cookiesOAuthLogins) || [];
38210
- const jsToken = cookies.find((cookie) => cookie.name === CONT.COOKIE_NAME.JS_TOKEN);
38211
- if (jsToken) {
38212
- this.setJSToken(jsToken.value);
38213
- window.ZJSBridge.setJSToken &&
38214
- window.ZJSBridge.setJSToken(jsToken.value);
38215
- }
38216
- resolve(cookies);
38217
- })
38218
- .catch((error) => {
38219
- reject(error);
38307
+ showUserInfoPermissionModal(() => {
38308
+ this.callNative('action.jump.login', {})
38309
+ .then((data) => {
38310
+ const cookies = (data && data.cookiesOAuthLogins) || [];
38311
+ const jsToken = cookies.find((cookie) => cookie.name === CONT.COOKIE_NAME.JS_TOKEN);
38312
+ if (jsToken) {
38313
+ this.setJSToken(jsToken.value);
38314
+ window.ZJSBridge.setJSToken &&
38315
+ window.ZJSBridge.setJSToken(jsToken.value);
38316
+ }
38317
+ resolve(cookies);
38318
+ })
38319
+ .catch((error) => {
38320
+ reject(error);
38321
+ });
38322
+ }, () => {
38323
+ reject(new Error("User denied!"));
38220
38324
  });
38221
38325
  });
38222
38326
  });
@@ -40166,6 +40270,9 @@
40166
40270
  else if (type === 'oa' && isEmpty(object.data.id)) {
40167
40271
  throw apiResponse.error.wrongTypeParam('object.data.id', 'valid id', 'empty');
40168
40272
  }
40273
+ else if (type === 'zmp' && (object.data.title.length > 100 || object.data.description.length > 400)) {
40274
+ throw apiResponse.error.lengthInvalid(`'title' or 'description'`);
40275
+ }
40169
40276
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openShareSheet(object);
40170
40277
  });
40171
40278
  }
@@ -40505,7 +40612,7 @@
40505
40612
  handleError,
40506
40613
  validate,
40507
40614
  __param(0, checkType('object', {
40508
- type: ['image', 'gif', 'video', 'link', 'oa'],
40615
+ type: ['image', 'gif', 'video', 'link', 'oa', 'zmp'],
40509
40616
  data: 'object'
40510
40617
  })),
40511
40618
  __param(0, checkType('object', {
@@ -40517,7 +40624,10 @@
40517
40624
  videoUrl: 'string',
40518
40625
  link: 'string',
40519
40626
  chatOnly: 'boolean',
40520
- id: 'string'
40627
+ id: 'string',
40628
+ title: 'string',
40629
+ description: 'string',
40630
+ thumbnail: 'url'
40521
40631
  }, 'data')),
40522
40632
  __param(0, required('type', 'data'))
40523
40633
  ], SDKCreator.prototype, "openShareSheet", null);