zmp-sdk 2.20.0 → 2.21.0-rc
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/browser.min.js +1317 -1289
- package/dist/index.es.js +1318 -1290
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/src/apis/payment.d.ts +14 -14
- package/dist/types/src/constants.d.ts +89 -20
- package/dist/types/src/decorator.d.ts +22 -0
- package/dist/types/src/errorHandler.d.ts +12 -0
- package/dist/types/src/services/zalo-mp-service.d.ts +3 -2
- package/dist/types/src/storage/nativeStorage.d.ts +1 -2
- package/dist/types/src/types/enum.d.ts +0 -6
- package/dist/types/src/utils/lodash.d.ts +1 -0
- package/dist/types/src/utils/response.d.ts +8 -8
- package/dist/types/src/zaloJsBridge.d.ts +16 -2
- package/package.json +1 -1
- package/dist/types/src/bridgeProvider.d.ts +0 -19
- package/dist/types/src/middleware/error.middleware.d.ts +0 -18
- package/dist/types/src/middleware/validate.middleware.d.ts +0 -9
package/dist/browser.min.js
CHANGED
|
@@ -2067,6 +2067,9 @@
|
|
|
2067
2067
|
|
|
2068
2068
|
var set_1 = set;
|
|
2069
2069
|
|
|
2070
|
+
const isPromise = (obj) => !!obj &&
|
|
2071
|
+
(typeof obj === 'object' || typeof obj === 'function') &&
|
|
2072
|
+
typeof obj.then === 'function';
|
|
2070
2073
|
var _ = {
|
|
2071
2074
|
isEmpty: isEmpty_1,
|
|
2072
2075
|
isNull: isNull_1,
|
|
@@ -2078,7 +2081,8 @@
|
|
|
2078
2081
|
isArray: isArray_1,
|
|
2079
2082
|
isRegExp: isRegExp_1,
|
|
2080
2083
|
get: get_1,
|
|
2081
|
-
set: set_1
|
|
2084
|
+
set: set_1,
|
|
2085
|
+
isPromise,
|
|
2082
2086
|
};
|
|
2083
2087
|
|
|
2084
2088
|
function Debug(name) {
|
|
@@ -2150,13 +2154,6 @@
|
|
|
2150
2154
|
(function (VibrateType) {
|
|
2151
2155
|
VibrateType[VibrateType["oneShot"] = 0] = "oneShot";
|
|
2152
2156
|
})(VibrateType || (VibrateType = {}));
|
|
2153
|
-
var NativeCode;
|
|
2154
|
-
(function (NativeCode) {
|
|
2155
|
-
NativeCode[NativeCode["token_invalid"] = -2] = "token_invalid";
|
|
2156
|
-
NativeCode[NativeCode["not_permission"] = -1] = "not_permission";
|
|
2157
|
-
NativeCode[NativeCode["client_not_support"] = -5] = "client_not_support";
|
|
2158
|
-
NativeCode[NativeCode["decode_failed"] = -4] = "decode_failed";
|
|
2159
|
-
})(NativeCode || (NativeCode = {}));
|
|
2160
2157
|
var Events;
|
|
2161
2158
|
(function (Events) {
|
|
2162
2159
|
Events["AppPaused"] = "h5.event.paused";
|
|
@@ -2245,7 +2242,7 @@
|
|
|
2245
2242
|
ZACC_SESSiON: `h5.zdn.vn_zacc_session`,
|
|
2246
2243
|
JS_TOKEN: `h5.zdn.vn_zlink3rd`,
|
|
2247
2244
|
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf`,
|
|
2248
|
-
DEVICE_ID: `h5.zdn.vn_deviceID
|
|
2245
|
+
DEVICE_ID: `h5.zdn.vn_deviceID`
|
|
2249
2246
|
};
|
|
2250
2247
|
const APIS = {
|
|
2251
2248
|
GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
|
|
@@ -2253,6 +2250,8 @@
|
|
|
2253
2250
|
GET_ACCESS_TOKEN_V3: 'https://oauth.zaloapp.com/v3/access_token',
|
|
2254
2251
|
GET_LIST_USER_INFO: 'https://graph.zalo.me/v2.0/me/friends/list',
|
|
2255
2252
|
CREATE_ORDER: 'https://payment-mini.zalo.me/api/order/create',
|
|
2253
|
+
GET_APP_INFO: 'https://h5.zalo.me/apps/get-info',
|
|
2254
|
+
SEND_ACTION_LOG: 'https://h5.zalo.me/log/async'
|
|
2256
2255
|
};
|
|
2257
2256
|
const STORAGE_LIMIT = 5 * MB;
|
|
2258
2257
|
const NETWORK_TYPE = (isAndroid) => ({
|
|
@@ -2263,6 +2262,78 @@
|
|
|
2263
2262
|
'4G': isAndroid ? 13 : 2
|
|
2264
2263
|
});
|
|
2265
2264
|
const MEDIA_PICKER_LIMIT = 1 * MB;
|
|
2265
|
+
const RESPONSE_CODE = {
|
|
2266
|
+
SUCCESS: 0,
|
|
2267
|
+
UNKNOWN_ERROR: -2000,
|
|
2268
|
+
BAD_REQUEST: -1400,
|
|
2269
|
+
INTERNAL_SERVER_ERROR: -1500,
|
|
2270
|
+
UNAUTHORIZED: -1401,
|
|
2271
|
+
FORBIDDEN: -1403,
|
|
2272
|
+
CLIENT_NOT_SUPPORT: -1404,
|
|
2273
|
+
TIME_OUT: -1408,
|
|
2274
|
+
DECODE_FAILED: -2001,
|
|
2275
|
+
USER_DENIED: -2002,
|
|
2276
|
+
USER_CANCEL: -2003,
|
|
2277
|
+
// Media picker
|
|
2278
|
+
MEDIA_PICKER_FAIL: -2004,
|
|
2279
|
+
// Save image to gallery
|
|
2280
|
+
SAVE_IMAGE_FAIL: -2005
|
|
2281
|
+
};
|
|
2282
|
+
const MESSAGES = {
|
|
2283
|
+
SUCCESS: 'Success',
|
|
2284
|
+
UNKNOWN_ERROR: 'Unknown error. Please try again later.',
|
|
2285
|
+
TIME_OUT: 'Request timeout. Please try again later.',
|
|
2286
|
+
LOGIN_REQUIRED: 'Please login (https://miniapp.zalo.me/docs/api/login) before to call this api',
|
|
2287
|
+
LOGIN_FAILED: 'Login failed',
|
|
2288
|
+
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2289
|
+
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2290
|
+
DECODE_FAILED: 'Can not decode id. Please check your params again.',
|
|
2291
|
+
INVALID_PARAM: 'Invalid parameter',
|
|
2292
|
+
USER_DENIED: 'User denied',
|
|
2293
|
+
USER_CANCEL: 'User cancel',
|
|
2294
|
+
// Media picker
|
|
2295
|
+
MEDIA_PICKER_FAIL: 'Unable to pick media',
|
|
2296
|
+
// Save image to gallery
|
|
2297
|
+
SAVE_IMAGE_FAIL: 'Unable to save image'
|
|
2298
|
+
};
|
|
2299
|
+
const RESPONSE = {
|
|
2300
|
+
SUCCESS: {
|
|
2301
|
+
code: RESPONSE_CODE.SUCCESS,
|
|
2302
|
+
message: MESSAGES.SUCCESS
|
|
2303
|
+
},
|
|
2304
|
+
UNKNOWN_ERROR: {
|
|
2305
|
+
code: RESPONSE_CODE.UNKNOWN_ERROR,
|
|
2306
|
+
message: MESSAGES.UNKNOWN_ERROR
|
|
2307
|
+
},
|
|
2308
|
+
UNAUTHORIZED: {
|
|
2309
|
+
code: RESPONSE_CODE.UNAUTHORIZED,
|
|
2310
|
+
message: MESSAGES.LOGIN_REQUIRED
|
|
2311
|
+
},
|
|
2312
|
+
FORBIDDEN: {
|
|
2313
|
+
code: RESPONSE_CODE.FORBIDDEN,
|
|
2314
|
+
message: MESSAGES.NOT_PERMISSION
|
|
2315
|
+
},
|
|
2316
|
+
CLIENT_NOT_SUPPORT: {
|
|
2317
|
+
code: RESPONSE_CODE.CLIENT_NOT_SUPPORT,
|
|
2318
|
+
message: MESSAGES.CLIENT_NOT_SUPPORT
|
|
2319
|
+
},
|
|
2320
|
+
DECODE_FAILED: {
|
|
2321
|
+
code: RESPONSE_CODE.DECODE_FAILED,
|
|
2322
|
+
message: MESSAGES.DECODE_FAILED
|
|
2323
|
+
},
|
|
2324
|
+
TIME_OUT: {
|
|
2325
|
+
code: RESPONSE_CODE.TIME_OUT,
|
|
2326
|
+
message: MESSAGES.TIME_OUT
|
|
2327
|
+
},
|
|
2328
|
+
USER_DENIED: {
|
|
2329
|
+
code: RESPONSE_CODE.USER_DENIED,
|
|
2330
|
+
message: MESSAGES.USER_DENIED
|
|
2331
|
+
},
|
|
2332
|
+
USER_CANCEL: {
|
|
2333
|
+
code: RESPONSE_CODE.USER_CANCEL,
|
|
2334
|
+
message: MESSAGES.USER_CANCEL
|
|
2335
|
+
}
|
|
2336
|
+
};
|
|
2266
2337
|
const ACTION = {
|
|
2267
2338
|
GET_DOWNLOADED_STICKER: {
|
|
2268
2339
|
name: 'action.get.downloaded.sticker',
|
|
@@ -2375,7 +2446,19 @@
|
|
|
2375
2446
|
have_callback: true
|
|
2376
2447
|
},
|
|
2377
2448
|
REQUEST_PERMISSION_CAMERA: {
|
|
2378
|
-
name: 'action.request.permission.camera'
|
|
2449
|
+
name: 'action.request.permission.camera',
|
|
2450
|
+
error_list: {
|
|
2451
|
+
android: {
|
|
2452
|
+
'-2': {
|
|
2453
|
+
map_to: RESPONSE.USER_DENIED
|
|
2454
|
+
}
|
|
2455
|
+
},
|
|
2456
|
+
iOS: {
|
|
2457
|
+
'-2': {
|
|
2458
|
+
map_to: RESPONSE.USER_DENIED
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2379
2462
|
},
|
|
2380
2463
|
CHANGE_TITLE_HEADER: {
|
|
2381
2464
|
name: 'action.change.title.header',
|
|
@@ -2444,7 +2527,19 @@
|
|
|
2444
2527
|
},
|
|
2445
2528
|
GET_LOCATION: {
|
|
2446
2529
|
name: 'action.get.location',
|
|
2447
|
-
have_callback: true
|
|
2530
|
+
have_callback: true,
|
|
2531
|
+
error_list: {
|
|
2532
|
+
android: {
|
|
2533
|
+
'-1': {
|
|
2534
|
+
map_to: RESPONSE.USER_DENIED
|
|
2535
|
+
}
|
|
2536
|
+
},
|
|
2537
|
+
iOS: {
|
|
2538
|
+
'-1': {
|
|
2539
|
+
map_to: RESPONSE.USER_DENIED
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2448
2543
|
},
|
|
2449
2544
|
QUERY_LOCATION_HIDE: {
|
|
2450
2545
|
name: 'action.query.location.hide',
|
|
@@ -2542,7 +2637,34 @@
|
|
|
2542
2637
|
},
|
|
2543
2638
|
SAVE_IMAGE_GALLERY: {
|
|
2544
2639
|
name: 'action.save.image.gallery',
|
|
2545
|
-
version_live: { iOS: 408 }
|
|
2640
|
+
version_live: { iOS: 408 },
|
|
2641
|
+
error_list: {
|
|
2642
|
+
android: {
|
|
2643
|
+
'-101': {
|
|
2644
|
+
map_to: {
|
|
2645
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2646
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2647
|
+
},
|
|
2648
|
+
need_more_detail: true
|
|
2649
|
+
},
|
|
2650
|
+
'-102': {
|
|
2651
|
+
map_to: {
|
|
2652
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2653
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2654
|
+
},
|
|
2655
|
+
need_more_detail: true
|
|
2656
|
+
}
|
|
2657
|
+
},
|
|
2658
|
+
iOS: {
|
|
2659
|
+
'-10': {
|
|
2660
|
+
map_to: {
|
|
2661
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2662
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2663
|
+
},
|
|
2664
|
+
need_more_detail: true
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2546
2668
|
},
|
|
2547
2669
|
OPEN_MP: {
|
|
2548
2670
|
name: 'action.open.mp',
|
|
@@ -2563,11 +2685,41 @@
|
|
|
2563
2685
|
},
|
|
2564
2686
|
MP_GET_NUMBER: {
|
|
2565
2687
|
name: 'action.mp.get.number',
|
|
2566
|
-
version_live: { iOS: 416 }
|
|
2688
|
+
version_live: { iOS: 416 },
|
|
2689
|
+
error_list: {
|
|
2690
|
+
android: {
|
|
2691
|
+
'-1': {
|
|
2692
|
+
map_to: RESPONSE.USER_DENIED
|
|
2693
|
+
},
|
|
2694
|
+
'-101': {
|
|
2695
|
+
map_to: RESPONSE.USER_DENIED
|
|
2696
|
+
}
|
|
2697
|
+
},
|
|
2698
|
+
iOS: {
|
|
2699
|
+
'-1': {
|
|
2700
|
+
map_to: RESPONSE.USER_DENIED
|
|
2701
|
+
},
|
|
2702
|
+
'-10': {
|
|
2703
|
+
map_to: RESPONSE.USER_DENIED
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2567
2707
|
},
|
|
2568
2708
|
MP_OPEN_PROFILE_PICKER: {
|
|
2569
2709
|
name: 'action.mp.open.profile.picker',
|
|
2570
|
-
version_live: { iOS: 432 }
|
|
2710
|
+
version_live: { iOS: 432 },
|
|
2711
|
+
error_list: {
|
|
2712
|
+
android: {
|
|
2713
|
+
'-101': {
|
|
2714
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2715
|
+
}
|
|
2716
|
+
},
|
|
2717
|
+
iOS: {
|
|
2718
|
+
'-101': {
|
|
2719
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2571
2723
|
},
|
|
2572
2724
|
GET_SUPPORTED_ACTIONS: {
|
|
2573
2725
|
name: 'action.get.supported.actions',
|
|
@@ -2581,32 +2733,45 @@
|
|
|
2581
2733
|
},
|
|
2582
2734
|
PICK_MEDIA: {
|
|
2583
2735
|
name: 'action.pick.media',
|
|
2584
|
-
version_live: { iOS: 440 }
|
|
2736
|
+
version_live: { iOS: 440 },
|
|
2737
|
+
error_list: {
|
|
2738
|
+
android: {
|
|
2739
|
+
'-101': {
|
|
2740
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2741
|
+
},
|
|
2742
|
+
'999': {
|
|
2743
|
+
map_to: {
|
|
2744
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2745
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2746
|
+
},
|
|
2747
|
+
need_more_detail: true
|
|
2748
|
+
}
|
|
2749
|
+
},
|
|
2750
|
+
iOS: {
|
|
2751
|
+
'-10': {
|
|
2752
|
+
map_to: {
|
|
2753
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2754
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2585
2759
|
},
|
|
2586
2760
|
MP_CLOSE_LOADINGVIEW: {
|
|
2587
2761
|
name: 'action.mp.close.loadingview'
|
|
2588
2762
|
}
|
|
2589
2763
|
};
|
|
2590
|
-
const
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
LOGIN_REQUIRED: 'Please login before to call this api. Read more at: https://miniapp.zalo.me/docs/api/login',
|
|
2602
|
-
LOGIN_FAILED: 'Login failed.',
|
|
2603
|
-
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2604
|
-
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2605
|
-
DECODE_FAILED: 'Can not decode your data. Read more at: https://miniapp.zalo.me/docs/api/error'
|
|
2606
|
-
};
|
|
2607
|
-
const API_DOMAIN = 'https://h5.zalo.me/';
|
|
2608
|
-
const H5_API = {
|
|
2609
|
-
GET_APP_INFO: 'apps/get-info'
|
|
2764
|
+
const COMMON_NATIVE_ERROR_CODE = {
|
|
2765
|
+
android: {
|
|
2766
|
+
'-4': RESPONSE.DECODE_FAILED,
|
|
2767
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2768
|
+
'-14': RESPONSE.TIME_OUT
|
|
2769
|
+
},
|
|
2770
|
+
iOS: {
|
|
2771
|
+
'-9': RESPONSE.DECODE_FAILED,
|
|
2772
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2773
|
+
'-14': RESPONSE.TIME_OUT
|
|
2774
|
+
}
|
|
2610
2775
|
};
|
|
2611
2776
|
const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
2612
2777
|
android: 12100571,
|
|
@@ -2718,124 +2883,36 @@
|
|
|
2718
2883
|
};
|
|
2719
2884
|
const PAYMENT_H5_URL = 'https://payment-mini.zalo.me';
|
|
2720
2885
|
|
|
2721
|
-
class
|
|
2886
|
+
class AppError {
|
|
2722
2887
|
constructor(code, msg, api) {
|
|
2723
2888
|
this.code = code;
|
|
2724
2889
|
this.message = msg;
|
|
2725
2890
|
this.api = api;
|
|
2726
2891
|
}
|
|
2727
2892
|
toString() {
|
|
2728
|
-
return `api: ${this.api}; code: ${this.code}; message: ${this.message}`;
|
|
2893
|
+
return `api: ${String(this.api)}; code: ${this.code}; message: ${this.message}`;
|
|
2729
2894
|
}
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
}
|
|
2737
|
-
handler() {
|
|
2738
|
-
switch (this.code) {
|
|
2739
|
-
case NativeCode.token_invalid:
|
|
2740
|
-
this.code = RESPONSE_CODE.UNAUTHORIZED;
|
|
2741
|
-
this.message = MESSAGES.LOGIN_REQUIRED;
|
|
2742
|
-
break;
|
|
2743
|
-
case NativeCode.not_permission:
|
|
2744
|
-
this.code = RESPONSE_CODE.FORBIDDEN;
|
|
2745
|
-
this.message = MESSAGES.NOT_PERMISSION;
|
|
2746
|
-
break;
|
|
2747
|
-
case NativeCode.client_not_support:
|
|
2748
|
-
this.code = RESPONSE_CODE.CLIENT_NOT_SUPPORT;
|
|
2749
|
-
this.message = MESSAGES.CLIENT_NOT_SUPPORT;
|
|
2750
|
-
break;
|
|
2751
|
-
case NativeCode.decode_failed:
|
|
2752
|
-
this.message = MESSAGES.DECODE_FAILED;
|
|
2753
|
-
break;
|
|
2754
|
-
}
|
|
2895
|
+
toJSON() {
|
|
2896
|
+
return {
|
|
2897
|
+
code: this.code,
|
|
2898
|
+
message: this.message,
|
|
2899
|
+
api: this.api
|
|
2900
|
+
};
|
|
2755
2901
|
}
|
|
2756
2902
|
}
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
this.handler = handler;
|
|
2761
|
-
}
|
|
2903
|
+
const handleKnownExceptions = (error, api) => {
|
|
2904
|
+
error.api = api;
|
|
2905
|
+
return error.toJSON();
|
|
2762
2906
|
};
|
|
2763
|
-
const
|
|
2764
|
-
if (error instanceof
|
|
2765
|
-
error.
|
|
2766
|
-
return error;
|
|
2907
|
+
const handleUnknownExceptions = (error, api) => {
|
|
2908
|
+
if (error instanceof Error) {
|
|
2909
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, error.message, api).toJSON();
|
|
2767
2910
|
}
|
|
2768
|
-
return new
|
|
2769
|
-
};
|
|
2770
|
-
catchDecoratorStore.setHandler(errorHandler);
|
|
2771
|
-
const handleError = (target, propertyName, descriptor) => {
|
|
2772
|
-
const fn = descriptor.value;
|
|
2773
|
-
descriptor.value = function (...args) {
|
|
2774
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2775
|
-
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
2776
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
2777
|
-
try {
|
|
2778
|
-
const res = yield fn.apply(this, args);
|
|
2779
|
-
if (!_.isNull(success) && _.isFunction(success)) {
|
|
2780
|
-
success.call(null, res, this);
|
|
2781
|
-
}
|
|
2782
|
-
else {
|
|
2783
|
-
resolve(res);
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
catch (error) {
|
|
2787
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2788
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2789
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2790
|
-
let loggedIn = false;
|
|
2791
|
-
if (this instanceof SDKCreator) {
|
|
2792
|
-
loggedIn = this.getLoginStatus();
|
|
2793
|
-
}
|
|
2794
|
-
if (!loggedIn) {
|
|
2795
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
const { handler } = catchDecoratorStore;
|
|
2799
|
-
const errorParsed = handler.call(null, propertyName, error, this);
|
|
2800
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2801
|
-
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
2802
|
-
fail.call(null, errorParsed, this);
|
|
2803
|
-
}
|
|
2804
|
-
else {
|
|
2805
|
-
reject(errorParsed);
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
|
-
}));
|
|
2809
|
-
});
|
|
2810
|
-
};
|
|
2811
|
-
return descriptor;
|
|
2911
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, MESSAGES.UNKNOWN_ERROR, api).toJSON();
|
|
2812
2912
|
};
|
|
2813
|
-
const
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
try {
|
|
2817
|
-
return fn.apply(this, args);
|
|
2818
|
-
}
|
|
2819
|
-
catch (error) {
|
|
2820
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2821
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2822
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2823
|
-
let loggedIn = false;
|
|
2824
|
-
if (this instanceof SDKCreator) {
|
|
2825
|
-
loggedIn = this.getLoginStatus();
|
|
2826
|
-
}
|
|
2827
|
-
if (!loggedIn) {
|
|
2828
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
const { handler } = catchDecoratorStore;
|
|
2832
|
-
const errorParsed = handler.call(null, key, error, this);
|
|
2833
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2834
|
-
throw errorParsed;
|
|
2835
|
-
}
|
|
2836
|
-
};
|
|
2837
|
-
return descriptor;
|
|
2838
|
-
};
|
|
2913
|
+
const errorHandler = (error, api) => error instanceof AppError
|
|
2914
|
+
? handleKnownExceptions(error, api)
|
|
2915
|
+
: handleUnknownExceptions(error, api);
|
|
2839
2916
|
|
|
2840
2917
|
const apiResponse = {
|
|
2841
2918
|
success: (data, message) => ({
|
|
@@ -2844,13 +2921,13 @@
|
|
|
2844
2921
|
data: data || {}
|
|
2845
2922
|
}),
|
|
2846
2923
|
error: {
|
|
2847
|
-
badRequest: (message) => new
|
|
2848
|
-
loginFailed: () => new
|
|
2849
|
-
loginRequired: () => new
|
|
2850
|
-
missingParam: (params) => new
|
|
2851
|
-
wrongTypeParam: (arg, expected, got) => new
|
|
2852
|
-
cannotGetShareInfo: () => new
|
|
2853
|
-
lengthInvalid: (arg) => new
|
|
2924
|
+
badRequest: (message) => new AppError(RESPONSE_CODE.BAD_REQUEST, message),
|
|
2925
|
+
loginFailed: (message) => new AppError(RESPONSE_CODE.UNAUTHORIZED, `${MESSAGES.LOGIN_FAILED}: ${message}`),
|
|
2926
|
+
loginRequired: () => new AppError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED),
|
|
2927
|
+
missingParam: (params) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
|
|
2928
|
+
wrongTypeParam: (arg, expected, got) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
|
|
2929
|
+
cannotGetShareInfo: () => new AppError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
|
|
2930
|
+
lengthInvalid: (arg) => new AppError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
|
|
2854
2931
|
}
|
|
2855
2932
|
};
|
|
2856
2933
|
|
|
@@ -3265,7 +3342,7 @@
|
|
|
3265
3342
|
if (!_.isUndefined(currentVersion)) {
|
|
3266
3343
|
inputData.currentVersion = currentVersion;
|
|
3267
3344
|
}
|
|
3268
|
-
const api = QueryString.appendToUrl(
|
|
3345
|
+
const api = QueryString.appendToUrl(APIS.GET_APP_INFO, inputData);
|
|
3269
3346
|
const msgApi = yield fetch(api, {
|
|
3270
3347
|
credentials: 'include'
|
|
3271
3348
|
});
|
|
@@ -3657,504 +3734,97 @@
|
|
|
3657
3734
|
}
|
|
3658
3735
|
}
|
|
3659
3736
|
|
|
3660
|
-
var
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
wrappers[type] = fn;
|
|
3673
|
-
};
|
|
3674
|
-
var ERROR = {
|
|
3675
|
-
error: {
|
|
3676
|
-
code: 1,
|
|
3677
|
-
error_subcode: 1357046,
|
|
3678
|
-
message: 'Received Invalid JSON reply.',
|
|
3679
|
-
type: 'http'
|
|
3680
|
-
}
|
|
3681
|
-
};
|
|
3682
|
-
function safelyParseResponse(rawResponse) {
|
|
3683
|
-
try {
|
|
3684
|
-
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
3685
|
-
}
|
|
3686
|
-
catch (ex) {
|
|
3687
|
-
return ERROR;
|
|
3737
|
+
var version = "2.21.0-rc";
|
|
3738
|
+
|
|
3739
|
+
class Basics {
|
|
3740
|
+
/**
|
|
3741
|
+
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
3742
|
+
*
|
|
3743
|
+
* @category Basics
|
|
3744
|
+
*
|
|
3745
|
+
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
3746
|
+
*/
|
|
3747
|
+
static getVersion() {
|
|
3748
|
+
return version;
|
|
3688
3749
|
}
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3750
|
+
/**
|
|
3751
|
+
* Gets system information.
|
|
3752
|
+
*
|
|
3753
|
+
* @function getSystemInfo
|
|
3754
|
+
* @category Basics
|
|
3755
|
+
*
|
|
3756
|
+
*
|
|
3757
|
+
*
|
|
3758
|
+
*/
|
|
3759
|
+
static getSystemInfo() {
|
|
3760
|
+
const system = {
|
|
3761
|
+
version: getMetaValue('version-id') || '',
|
|
3762
|
+
apiVersion: version,
|
|
3763
|
+
zaloVersion: getZaloVersion(),
|
|
3764
|
+
platform: getPlatform(),
|
|
3765
|
+
language: navigator.language,
|
|
3766
|
+
zaloLanguage: window.zLanguage || 'vi',
|
|
3767
|
+
zaloTheme: window.zTheme || 'light'
|
|
3768
|
+
};
|
|
3769
|
+
return system;
|
|
3693
3770
|
}
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3771
|
+
/**
|
|
3772
|
+
* Lấy thông tin mini app
|
|
3773
|
+
*
|
|
3774
|
+
* @async
|
|
3775
|
+
* @function getAppInfo
|
|
3776
|
+
* @category Device
|
|
3777
|
+
*
|
|
3778
|
+
*/
|
|
3779
|
+
static getAppInfo() {
|
|
3780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3781
|
+
const appId = this.getAppId();
|
|
3782
|
+
const systemInfo = this.getSystemInfo();
|
|
3783
|
+
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
3784
|
+
});
|
|
3699
3785
|
}
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
url = QueryString.appendToUrl(url, data);
|
|
3743
|
-
data = '';
|
|
3744
|
-
}
|
|
3745
|
-
var request = createCORSRequest(method, url);
|
|
3746
|
-
if (!request) {
|
|
3747
|
-
return false;
|
|
3748
|
-
}
|
|
3749
|
-
request.onload = function (xhr) {
|
|
3750
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3751
|
-
};
|
|
3752
|
-
request.onerror = function (xhr) {
|
|
3753
|
-
if (xhr.responseText) {
|
|
3754
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3755
|
-
}
|
|
3756
|
-
else {
|
|
3757
|
-
cb({
|
|
3758
|
-
error: {
|
|
3759
|
-
code: 1,
|
|
3760
|
-
error_subcode: 1357045,
|
|
3761
|
-
message: 'unknown error (empty response)',
|
|
3762
|
-
status: xhr.status,
|
|
3763
|
-
type: 'http'
|
|
3764
|
-
}
|
|
3765
|
-
});
|
|
3766
|
-
}
|
|
3767
|
-
};
|
|
3768
|
-
request.send(data);
|
|
3769
|
-
return true;
|
|
3770
|
-
}
|
|
3771
|
-
var CORSRequest = {
|
|
3772
|
-
execute: execute
|
|
3773
|
-
};
|
|
3774
|
-
|
|
3775
|
-
class ZaloJSBridge extends eventemitter3 {
|
|
3776
|
-
constructor() {
|
|
3777
|
-
super();
|
|
3778
|
-
this.debug = Debug('zmp:ZaloJSBridge');
|
|
3779
|
-
this.events = ZMPEEmitter.getInstance();
|
|
3780
|
-
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
3781
|
-
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
3782
|
-
this.results = [];
|
|
3783
|
-
this._userAgent = getUserAgent();
|
|
3784
|
-
this._device = checkPlatform();
|
|
3785
|
-
this._jsCallFuncCallbacks = {};
|
|
3786
|
-
this.events.on(Events.AppPaused, () => {
|
|
3787
|
-
if (this.results.length > 0) {
|
|
3788
|
-
let array = this.results;
|
|
3789
|
-
this.results = [];
|
|
3790
|
-
try {
|
|
3791
|
-
this.sendLogData(array);
|
|
3792
|
-
}
|
|
3793
|
-
catch (error) { }
|
|
3794
|
-
}
|
|
3795
|
-
});
|
|
3796
|
-
if (this.sendLogTimer) {
|
|
3797
|
-
clearInterval(this.sendLogTimer);
|
|
3798
|
-
}
|
|
3799
|
-
else {
|
|
3800
|
-
this.sendLogTimer = setInterval(() => {
|
|
3801
|
-
if (this.results.length > 0) {
|
|
3802
|
-
let array = this.results;
|
|
3803
|
-
this.results = [];
|
|
3804
|
-
try {
|
|
3805
|
-
this.sendLogData(array);
|
|
3806
|
-
}
|
|
3807
|
-
catch (error) { }
|
|
3808
|
-
}
|
|
3809
|
-
}, 5000);
|
|
3810
|
-
}
|
|
3811
|
-
}
|
|
3812
|
-
static getInstance() {
|
|
3813
|
-
if (!ZaloJSBridge.instance) {
|
|
3814
|
-
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
3815
|
-
}
|
|
3816
|
-
return ZaloJSBridge.instance;
|
|
3817
|
-
}
|
|
3818
|
-
set accessTk(value) {
|
|
3819
|
-
this._accessTk = value;
|
|
3820
|
-
}
|
|
3821
|
-
set jsAccessTk(value) {
|
|
3822
|
-
this._jsAccessTk = value;
|
|
3823
|
-
}
|
|
3824
|
-
sendLogData(data) {
|
|
3825
|
-
try {
|
|
3826
|
-
CORSRequest.execute('https://h5.zalo.me/log/async', 'post', {
|
|
3827
|
-
appId: window.APP_ID,
|
|
3828
|
-
data: JSON.stringify(data)
|
|
3829
|
-
}, (response) => { });
|
|
3830
|
-
}
|
|
3831
|
-
catch (error) { }
|
|
3832
|
-
}
|
|
3833
|
-
onJSCall(key, data) {
|
|
3834
|
-
try {
|
|
3835
|
-
this.debug('onJSCall', key, data);
|
|
3836
|
-
const parsedData = parseJSON(data);
|
|
3837
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3838
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3839
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3840
|
-
if (!!callback) {
|
|
3841
|
-
try {
|
|
3842
|
-
callback.call(this, parsedData);
|
|
3843
|
-
}
|
|
3844
|
-
catch (error) {
|
|
3845
|
-
console.error('Call callback error', error);
|
|
3846
|
-
}
|
|
3847
|
-
!!timeout && clearTimeout(timeout);
|
|
3848
|
-
this._jsCallFuncCallbacks[key] = null;
|
|
3849
|
-
delete this._jsCallFuncCallbacks[key];
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
|
-
this.results.push({
|
|
3853
|
-
action: parsedData.action,
|
|
3854
|
-
error: parsedData.error_code
|
|
3855
|
-
});
|
|
3856
|
-
}
|
|
3857
|
-
catch (e) {
|
|
3858
|
-
console.log('onJSCall', 'error', e);
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
onMultiJSCall(key, data) {
|
|
3862
|
-
try {
|
|
3863
|
-
this.debug('onMultiJSCall', key, data);
|
|
3864
|
-
const parsedData = parseJSON(data);
|
|
3865
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3866
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3867
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3868
|
-
if (!!callback) {
|
|
3869
|
-
try {
|
|
3870
|
-
callback.call(this, parsedData);
|
|
3871
|
-
}
|
|
3872
|
-
catch (error) {
|
|
3873
|
-
console.error('Call callback error', error);
|
|
3874
|
-
}
|
|
3875
|
-
!!timeout && clearTimeout(timeout);
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
this.results.push({
|
|
3879
|
-
action: parsedData.action,
|
|
3880
|
-
error: parsedData.error_code
|
|
3881
|
-
});
|
|
3882
|
-
}
|
|
3883
|
-
catch (e) {
|
|
3884
|
-
console.log('onMultiJSCall', 'error', e);
|
|
3885
|
-
}
|
|
3886
|
-
}
|
|
3887
|
-
nativeEventHandler(eventId, eventName, eventData) {
|
|
3888
|
-
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
3889
|
-
const data = stringToData(eventData);
|
|
3890
|
-
this.debug(data);
|
|
3891
|
-
const convertedData = this.handleEventData(eventName, data);
|
|
3892
|
-
this.events.emit(eventName, eventId, convertedData);
|
|
3893
|
-
}
|
|
3894
|
-
handleEventData(eventName, data) {
|
|
3895
|
-
try {
|
|
3896
|
-
switch (eventName) {
|
|
3897
|
-
case Events.OpenApp:
|
|
3898
|
-
const { url } = data;
|
|
3899
|
-
const validUrl = new URL(url);
|
|
3900
|
-
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
3901
|
-
return {
|
|
3902
|
-
path: `${path ? path : '/'}${validUrl.search}`
|
|
3903
|
-
};
|
|
3904
|
-
break;
|
|
3905
|
-
default:
|
|
3906
|
-
return data;
|
|
3907
|
-
break;
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
catch (error) {
|
|
3911
|
-
return data;
|
|
3912
|
-
}
|
|
3913
|
-
}
|
|
3914
|
-
defaultCallback(data) {
|
|
3915
|
-
if (data !== null && data !== undefined) {
|
|
3916
|
-
data = parseJSON(data);
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3919
|
-
jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
|
|
3920
|
-
try {
|
|
3921
|
-
const actionName = action.name;
|
|
3922
|
-
const key = generateUniqueString(actionName);
|
|
3923
|
-
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
3924
|
-
this.onJSCall(key, {
|
|
3925
|
-
error_code: -13,
|
|
3926
|
-
error_message: 'params invalid!',
|
|
3927
|
-
data: {
|
|
3928
|
-
device: this._device.isMobile,
|
|
3929
|
-
jsToken: this._jsAccessTk,
|
|
3930
|
-
access_token: this._accessTk
|
|
3931
|
-
},
|
|
3932
|
-
action: actionName
|
|
3933
|
-
});
|
|
3934
|
-
return false;
|
|
3935
|
-
}
|
|
3936
|
-
if (options === undefined || options === null) {
|
|
3937
|
-
options = {};
|
|
3938
|
-
}
|
|
3939
|
-
if (!callback) {
|
|
3940
|
-
callback = this.defaultCallback;
|
|
3941
|
-
}
|
|
3942
|
-
const timeoutCallback = {
|
|
3943
|
-
error_code: -14,
|
|
3944
|
-
error_message: 'Request Timeout!',
|
|
3945
|
-
data: {},
|
|
3946
|
-
action: actionName
|
|
3947
|
-
};
|
|
3948
|
-
this._jsCallFuncCallbacks[key] = {
|
|
3949
|
-
timeout: haveTimeout &&
|
|
3950
|
-
action.have_callback &&
|
|
3951
|
-
setTimeout(() => {
|
|
3952
|
-
this.onJSCall(key, timeoutCallback);
|
|
3953
|
-
}, 8000),
|
|
3954
|
-
callback: callback
|
|
3955
|
-
};
|
|
3956
|
-
try {
|
|
3957
|
-
options = serialize(options);
|
|
3958
|
-
if (isMultiCallback) {
|
|
3959
|
-
if (this._device.isIOS) {
|
|
3960
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
3961
|
-
}
|
|
3962
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
3963
|
-
}
|
|
3964
|
-
if (this._device.isIOS) {
|
|
3965
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
3966
|
-
}
|
|
3967
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
3968
|
-
}
|
|
3969
|
-
catch (error) {
|
|
3970
|
-
if (nRetry-- > 0) {
|
|
3971
|
-
setTimeout(() => {
|
|
3972
|
-
this.jsCall(action, options, callback, isMultiCallback, nRetry);
|
|
3973
|
-
}, 500);
|
|
3974
|
-
}
|
|
3975
|
-
else {
|
|
3976
|
-
const errorCallback = {
|
|
3977
|
-
error_code: -5,
|
|
3978
|
-
error_message: 'Not ready!',
|
|
3979
|
-
data: {
|
|
3980
|
-
userAgent: this._userAgent,
|
|
3981
|
-
options: options,
|
|
3982
|
-
jsToken: this._jsAccessTk,
|
|
3983
|
-
access_token: this._accessTk
|
|
3984
|
-
},
|
|
3985
|
-
action: actionName,
|
|
3986
|
-
js_error: error
|
|
3987
|
-
};
|
|
3988
|
-
this.onJSCall(key, errorCallback);
|
|
3989
|
-
return false;
|
|
3990
|
-
}
|
|
3991
|
-
}
|
|
3992
|
-
}
|
|
3993
|
-
catch (error) {
|
|
3994
|
-
console.log('jsCall', 'error', error);
|
|
3995
|
-
}
|
|
3996
|
-
return false;
|
|
3997
|
-
}
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
var _ZJSBridgeProvider_bridge;
|
|
4001
|
-
/** @ignore */
|
|
4002
|
-
class ZJSBridgeProvider {
|
|
4003
|
-
/** @ignore */
|
|
4004
|
-
constructor() {
|
|
4005
|
-
this.debug = Debug('zmp:ZJSBridgeProvider');
|
|
4006
|
-
_ZJSBridgeProvider_bridge.set(this, void 0);
|
|
4007
|
-
__classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance(), "f");
|
|
4008
|
-
}
|
|
4009
|
-
setZAccSession(value) {
|
|
4010
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").accessTk = value;
|
|
4011
|
-
}
|
|
4012
|
-
setJSToken(value) {
|
|
4013
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsAccessTk = value;
|
|
4014
|
-
}
|
|
4015
|
-
callNative(action, data, option) {
|
|
4016
|
-
this.debug(action.name, data);
|
|
4017
|
-
return new Promise((resolve, reject) => {
|
|
4018
|
-
const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
4019
|
-
try {
|
|
4020
|
-
const error = new NativeError(cb.error_code, `${cb.action}: ${cb.error_message}`);
|
|
4021
|
-
if (option === null || option === void 0 ? void 0 : option.callback) {
|
|
4022
|
-
const res = yield option.callback(cb, error);
|
|
4023
|
-
return resolve(res);
|
|
4024
|
-
}
|
|
4025
|
-
else {
|
|
4026
|
-
if (cb && cb.error_code >= 0) {
|
|
4027
|
-
resolve(cb.data || {});
|
|
4028
|
-
}
|
|
4029
|
-
else if (cb && cb.error_code < 0) {
|
|
4030
|
-
try {
|
|
4031
|
-
window.zmpSentry &&
|
|
4032
|
-
window.zmpSentry.captureMessage(`${action.name}: call native fail`, {
|
|
4033
|
-
extra: {
|
|
4034
|
-
data: data,
|
|
4035
|
-
rs: cb
|
|
4036
|
-
}
|
|
4037
|
-
});
|
|
4038
|
-
}
|
|
4039
|
-
catch (error) { }
|
|
4040
|
-
return reject(error);
|
|
4041
|
-
}
|
|
4042
|
-
}
|
|
4043
|
-
}
|
|
4044
|
-
catch (error) {
|
|
4045
|
-
return reject(error);
|
|
4046
|
-
}
|
|
4047
|
-
});
|
|
4048
|
-
const isIOS = checkPlatform().isIOS;
|
|
4049
|
-
const isSupportAction = checkIOSSupportAction(action);
|
|
4050
|
-
if (isIOS && !isSupportAction) {
|
|
4051
|
-
const error = new NativeError(-5, `${action}: Client isn't support this action`);
|
|
4052
|
-
return reject(error);
|
|
4053
|
-
}
|
|
4054
|
-
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
4055
|
-
setTimeout(() => {
|
|
4056
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsCall(action, data, fn, 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);
|
|
4057
|
-
}, option.delay);
|
|
4058
|
-
}
|
|
4059
|
-
else {
|
|
4060
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsCall(action, data, fn, 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);
|
|
4061
|
-
}
|
|
4062
|
-
});
|
|
4063
|
-
}
|
|
4064
|
-
}
|
|
4065
|
-
_ZJSBridgeProvider_bridge = new WeakMap();
|
|
4066
|
-
|
|
4067
|
-
var version = "2.20.0";
|
|
4068
|
-
|
|
4069
|
-
class Basics {
|
|
4070
|
-
/**
|
|
4071
|
-
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
4072
|
-
*
|
|
4073
|
-
* @category Basics
|
|
4074
|
-
*
|
|
4075
|
-
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
4076
|
-
*/
|
|
4077
|
-
static getVersion() {
|
|
4078
|
-
return version;
|
|
4079
|
-
}
|
|
4080
|
-
/**
|
|
4081
|
-
* Gets system information.
|
|
4082
|
-
*
|
|
4083
|
-
* @function getSystemInfo
|
|
4084
|
-
* @category Basics
|
|
4085
|
-
*
|
|
4086
|
-
*
|
|
4087
|
-
*
|
|
4088
|
-
*/
|
|
4089
|
-
static getSystemInfo() {
|
|
4090
|
-
const system = {
|
|
4091
|
-
version: getMetaValue('version-id') || '',
|
|
4092
|
-
apiVersion: version,
|
|
4093
|
-
zaloVersion: getZaloVersion(),
|
|
4094
|
-
platform: getPlatform(),
|
|
4095
|
-
language: navigator.language,
|
|
4096
|
-
zaloLanguage: window.zLanguage || 'vi',
|
|
4097
|
-
zaloTheme: window.zTheme || 'light'
|
|
4098
|
-
};
|
|
4099
|
-
return system;
|
|
4100
|
-
}
|
|
4101
|
-
/**
|
|
4102
|
-
* Lấy thông tin mini app
|
|
4103
|
-
*
|
|
4104
|
-
* @async
|
|
4105
|
-
* @function getAppInfo
|
|
4106
|
-
* @category Device
|
|
4107
|
-
*
|
|
4108
|
-
*/
|
|
4109
|
-
static getAppInfo() {
|
|
4110
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4111
|
-
const appId = this.getAppId();
|
|
4112
|
-
const systemInfo = this.getSystemInfo();
|
|
4113
|
-
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
4114
|
-
});
|
|
4115
|
-
}
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
|
-
class NavigationBar {
|
|
4119
|
-
/**
|
|
4120
|
-
* A promise for the user's favorite color.
|
|
4121
|
-
*
|
|
4122
|
-
* @promise FavoriteColorPromise
|
|
4123
|
-
* @fulfill {string} The user's favorite color.
|
|
4124
|
-
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
4125
|
-
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
4126
|
-
*/
|
|
4127
|
-
/**
|
|
4128
|
-
* Dynamically sets the title of the current page.
|
|
4129
|
-
*
|
|
4130
|
-
* @async
|
|
4131
|
-
* @function setNavigationBarTitle
|
|
4132
|
-
* @category Navigation Bar
|
|
4133
|
-
*
|
|
4134
|
-
* @example
|
|
4135
|
-
*
|
|
4136
|
-
* zmpApis.setNavigationBarTitle({
|
|
4137
|
-
* title: "Current Page"
|
|
4138
|
-
* }).then((res) => {
|
|
4139
|
-
* console.log("Success");
|
|
4140
|
-
* }).catch((error) => {
|
|
4141
|
-
* console.log("Fail");
|
|
4142
|
-
* });
|
|
4143
|
-
*
|
|
4144
|
-
* @param {Object} object
|
|
4145
|
-
* @param {string} object.title - The title of the page
|
|
4146
|
-
*
|
|
4147
|
-
* @return {Promise}
|
|
4148
|
-
*
|
|
4149
|
-
*/
|
|
4150
|
-
static setNavigationBarTitle(object) {
|
|
4151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4152
|
-
yield this.callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
4153
|
-
title: object.title
|
|
4154
|
-
}, {
|
|
4155
|
-
haveTimeout: false
|
|
4156
|
-
});
|
|
4157
|
-
});
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
class NavigationBar {
|
|
3789
|
+
/**
|
|
3790
|
+
* A promise for the user's favorite color.
|
|
3791
|
+
*
|
|
3792
|
+
* @promise FavoriteColorPromise
|
|
3793
|
+
* @fulfill {string} The user's favorite color.
|
|
3794
|
+
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
3795
|
+
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
3796
|
+
*/
|
|
3797
|
+
/**
|
|
3798
|
+
* Dynamically sets the title of the current page.
|
|
3799
|
+
*
|
|
3800
|
+
* @async
|
|
3801
|
+
* @function setNavigationBarTitle
|
|
3802
|
+
* @category Navigation Bar
|
|
3803
|
+
*
|
|
3804
|
+
* @example
|
|
3805
|
+
*
|
|
3806
|
+
* zmpApis.setNavigationBarTitle({
|
|
3807
|
+
* title: "Current Page"
|
|
3808
|
+
* }).then((res) => {
|
|
3809
|
+
* console.log("Success");
|
|
3810
|
+
* }).catch((error) => {
|
|
3811
|
+
* console.log("Fail");
|
|
3812
|
+
* });
|
|
3813
|
+
*
|
|
3814
|
+
* @param {Object} object
|
|
3815
|
+
* @param {string} object.title - The title of the page
|
|
3816
|
+
*
|
|
3817
|
+
* @return {Promise}
|
|
3818
|
+
*
|
|
3819
|
+
*/
|
|
3820
|
+
static setNavigationBarTitle(object) {
|
|
3821
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3822
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
3823
|
+
title: object.title
|
|
3824
|
+
}, {
|
|
3825
|
+
haveTimeout: false
|
|
3826
|
+
});
|
|
3827
|
+
});
|
|
4158
3828
|
}
|
|
4159
3829
|
/**
|
|
4160
3830
|
* Sets the color of the navigation bar in the page.
|
|
@@ -4197,7 +3867,7 @@
|
|
|
4197
3867
|
actionBarType = HIDE_ACTION_BAR;
|
|
4198
3868
|
}
|
|
4199
3869
|
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
|
|
4200
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
3870
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
4201
3871
|
haveTimeout: false
|
|
4202
3872
|
});
|
|
4203
3873
|
});
|
|
@@ -4247,14 +3917,14 @@
|
|
|
4247
3917
|
: ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
|
|
4248
3918
|
}
|
|
4249
3919
|
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { buttonType: _.isNumber(leftButtonType) ? leftButtonType : state.buttonType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), { confirmToExit: _.isNumber(confirmToExit) ? confirmToExit : state.dataConfig.confirmToExit, viewInLeftType: _.isNumber(leftButtonType) ? leftButtonType : state.dataConfig.viewInLeftType }), homeConfig: Object.assign(Object.assign({}, state.homeConfig), { enable: _.isNumber(showHomeButton) ? showHomeButton : state.homeConfig.enable }) })));
|
|
4250
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
3920
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
4251
3921
|
haveTimeout: false
|
|
4252
3922
|
});
|
|
4253
3923
|
});
|
|
4254
3924
|
}
|
|
4255
3925
|
static setNavigationBar(data) {
|
|
4256
3926
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4257
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3927
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4258
3928
|
data
|
|
4259
3929
|
}, {
|
|
4260
3930
|
haveTimeout: false
|
|
@@ -4289,7 +3959,7 @@
|
|
|
4289
3959
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4290
3960
|
if (_.isString(object.backgroundColor) &&
|
|
4291
3961
|
object.backgroundColor.length > 0) {
|
|
4292
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3962
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4293
3963
|
actionbarType: this.isShowNavBar ? 5 : 6,
|
|
4294
3964
|
dataConfig: {
|
|
4295
3965
|
backgroundColor: object.backgroundColor,
|
|
@@ -4401,7 +4071,7 @@
|
|
|
4401
4071
|
*/
|
|
4402
4072
|
static setDeviceOrientation(object) {
|
|
4403
4073
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4404
|
-
yield this.callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4074
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4405
4075
|
autoRotate: OrientationType[object.rotate]
|
|
4406
4076
|
});
|
|
4407
4077
|
});
|
|
@@ -4425,7 +4095,7 @@
|
|
|
4425
4095
|
*/
|
|
4426
4096
|
static getNetworkType(object) {
|
|
4427
4097
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4428
|
-
const resData = yield this.callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4098
|
+
const resData = yield this.getJSBridge().callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4429
4099
|
url: window.location.href,
|
|
4430
4100
|
featureId: ''
|
|
4431
4101
|
}).then((data) => {
|
|
@@ -4539,7 +4209,7 @@
|
|
|
4539
4209
|
items: Array.isArray(object === null || object === void 0 ? void 0 : object.items) ? object === null || object === void 0 ? void 0 : object.items : []
|
|
4540
4210
|
}
|
|
4541
4211
|
};
|
|
4542
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4212
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4543
4213
|
return true;
|
|
4544
4214
|
});
|
|
4545
4215
|
}
|
|
@@ -4558,7 +4228,7 @@
|
|
|
4558
4228
|
const data = {
|
|
4559
4229
|
subaction: 2
|
|
4560
4230
|
};
|
|
4561
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4231
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4562
4232
|
return true;
|
|
4563
4233
|
});
|
|
4564
4234
|
}
|
|
@@ -4579,7 +4249,7 @@
|
|
|
4579
4249
|
const data = {
|
|
4580
4250
|
subaction: 1
|
|
4581
4251
|
};
|
|
4582
|
-
const resData = yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4252
|
+
const resData = yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4583
4253
|
isMultiCallback: true
|
|
4584
4254
|
}).then((resData) => {
|
|
4585
4255
|
const res = {
|
|
@@ -4621,7 +4291,7 @@
|
|
|
4621
4291
|
*/
|
|
4622
4292
|
static stopBluetoothDevicesDiscovery() {
|
|
4623
4293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4624
|
-
return this.callNative({
|
|
4294
|
+
return this.getJSBridge().callNative({
|
|
4625
4295
|
name: ''
|
|
4626
4296
|
}, {});
|
|
4627
4297
|
});
|
|
@@ -4648,7 +4318,7 @@
|
|
|
4648
4318
|
*/
|
|
4649
4319
|
static startBluetoothDevicesDiscovery(object) {
|
|
4650
4320
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4651
|
-
return this.callNative({
|
|
4321
|
+
return this.getJSBridge().callNative({
|
|
4652
4322
|
name: ''
|
|
4653
4323
|
}, Object.assign({}, object));
|
|
4654
4324
|
});
|
|
@@ -4672,7 +4342,7 @@
|
|
|
4672
4342
|
*/
|
|
4673
4343
|
static openBluetoothAdapter() {
|
|
4674
4344
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4675
|
-
return this.callNative({
|
|
4345
|
+
return this.getJSBridge().callNative({
|
|
4676
4346
|
name: ''
|
|
4677
4347
|
}, {});
|
|
4678
4348
|
});
|
|
@@ -4692,7 +4362,7 @@
|
|
|
4692
4362
|
*/
|
|
4693
4363
|
static onBluetoothDeviceFound() {
|
|
4694
4364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4695
|
-
return this.callNative({
|
|
4365
|
+
return this.getJSBridge().callNative({
|
|
4696
4366
|
name: ''
|
|
4697
4367
|
}, {});
|
|
4698
4368
|
});
|
|
@@ -4740,7 +4410,7 @@
|
|
|
4740
4410
|
const data = {
|
|
4741
4411
|
services: object.services || []
|
|
4742
4412
|
};
|
|
4743
|
-
return this.callNative({
|
|
4413
|
+
return this.getJSBridge().callNative({
|
|
4744
4414
|
name: ''
|
|
4745
4415
|
}, data);
|
|
4746
4416
|
});
|
|
@@ -4761,7 +4431,7 @@
|
|
|
4761
4431
|
*/
|
|
4762
4432
|
static getBluetoothDevices() {
|
|
4763
4433
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4764
|
-
return this.callNative({
|
|
4434
|
+
return this.getJSBridge().callNative({
|
|
4765
4435
|
name: ''
|
|
4766
4436
|
}, {});
|
|
4767
4437
|
});
|
|
@@ -4782,7 +4452,7 @@
|
|
|
4782
4452
|
*/
|
|
4783
4453
|
static getBluetoothAdapterState() {
|
|
4784
4454
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4785
|
-
return this.callNative({
|
|
4455
|
+
return this.getJSBridge().callNative({
|
|
4786
4456
|
name: ''
|
|
4787
4457
|
}, {});
|
|
4788
4458
|
});
|
|
@@ -4803,7 +4473,7 @@
|
|
|
4803
4473
|
*/
|
|
4804
4474
|
static closeBluetoothAdapter() {
|
|
4805
4475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4806
|
-
return this.callNative({
|
|
4476
|
+
return this.getJSBridge().callNative({
|
|
4807
4477
|
name: ''
|
|
4808
4478
|
}, {});
|
|
4809
4479
|
});
|
|
@@ -4817,7 +4487,7 @@
|
|
|
4817
4487
|
*/
|
|
4818
4488
|
static scanQRCode(object) {
|
|
4819
4489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4820
|
-
return yield this.callNative(ACTION.OPEN_QR, {
|
|
4490
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_QR, {
|
|
4821
4491
|
skipOpenLink: true
|
|
4822
4492
|
});
|
|
4823
4493
|
});
|
|
@@ -4831,7 +4501,7 @@
|
|
|
4831
4501
|
*/
|
|
4832
4502
|
static showToast(object) {
|
|
4833
4503
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4834
|
-
yield this.callNative(ACTION.SHOW_TOAST, {
|
|
4504
|
+
yield this.getJSBridge().callNative(ACTION.SHOW_TOAST, {
|
|
4835
4505
|
toast: object.message
|
|
4836
4506
|
});
|
|
4837
4507
|
});
|
|
@@ -4845,294 +4515,756 @@
|
|
|
4845
4515
|
*/
|
|
4846
4516
|
static hideKeyboard(object) {
|
|
4847
4517
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4848
|
-
yield this.callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4518
|
+
yield this.getJSBridge().callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4519
|
+
});
|
|
4520
|
+
}
|
|
4521
|
+
/**
|
|
4522
|
+
* Open phone
|
|
4523
|
+
* @async
|
|
4524
|
+
* @function openPhone
|
|
4525
|
+
* @category Device
|
|
4526
|
+
*
|
|
4527
|
+
*/
|
|
4528
|
+
static openPhone(object) {
|
|
4529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4530
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_PHONE, {
|
|
4531
|
+
phoneNum: object.phoneNumber,
|
|
4532
|
+
phoneCode: object.phoneNumber
|
|
4533
|
+
});
|
|
4534
|
+
});
|
|
4535
|
+
}
|
|
4536
|
+
/**
|
|
4537
|
+
* Open SMS
|
|
4538
|
+
* @async
|
|
4539
|
+
* @function openSMS
|
|
4540
|
+
* @category Device
|
|
4541
|
+
*
|
|
4542
|
+
*/
|
|
4543
|
+
static openSMS(object) {
|
|
4544
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4545
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_SMS, {
|
|
4546
|
+
content: object.content,
|
|
4547
|
+
phoneCode: object.phoneNumber
|
|
4548
|
+
});
|
|
4549
|
+
});
|
|
4550
|
+
}
|
|
4551
|
+
/**
|
|
4552
|
+
* Keep screen.
|
|
4553
|
+
* @async
|
|
4554
|
+
* @function keepScreen
|
|
4555
|
+
* @category Device
|
|
4556
|
+
*
|
|
4557
|
+
*/
|
|
4558
|
+
static keepScreen(object) {
|
|
4559
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4560
|
+
return yield this.getJSBridge().callNative(ACTION.KEEP_SCREEN, {
|
|
4561
|
+
data: {
|
|
4562
|
+
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
});
|
|
4566
|
+
}
|
|
4567
|
+
/**
|
|
4568
|
+
* Xác thực bằng sinh trắc học
|
|
4569
|
+
* @async
|
|
4570
|
+
* @function openBioAuthentication
|
|
4571
|
+
* @category Authentication
|
|
4572
|
+
*
|
|
4573
|
+
*/
|
|
4574
|
+
static openBioAuthentication(object) {
|
|
4575
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4576
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION, {
|
|
4577
|
+
secret_data: object.secretData,
|
|
4578
|
+
app_id: this.getZAppId(),
|
|
4579
|
+
ui: {
|
|
4580
|
+
title: object.ui.title,
|
|
4581
|
+
sub_title: object.ui.subTitle,
|
|
4582
|
+
negative_text: object.ui.negativeButtonText
|
|
4583
|
+
},
|
|
4584
|
+
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4585
|
+
}).then((data) => {
|
|
4586
|
+
var _a, _b, _c, _d;
|
|
4587
|
+
return {
|
|
4588
|
+
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4589
|
+
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4590
|
+
data: {
|
|
4591
|
+
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4592
|
+
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4593
|
+
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4594
|
+
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4595
|
+
}
|
|
4596
|
+
};
|
|
4597
|
+
});
|
|
4598
|
+
});
|
|
4599
|
+
}
|
|
4600
|
+
/**
|
|
4601
|
+
* Một phần của flow H5-Bio-Authentication. Dùng cho H5 kiểm tra xem bio-factor có bị thay đổi gì so với trước đây ko (thêm vân tay, reset...)
|
|
4602
|
+
* @async
|
|
4603
|
+
* @function checkStateBioAuthentication
|
|
4604
|
+
* @category Authentication
|
|
4605
|
+
*
|
|
4606
|
+
* @example
|
|
4607
|
+
* api.checkStateAuthen({
|
|
4608
|
+
* success: (res) => {},
|
|
4609
|
+
* fail: (err) => {}
|
|
4610
|
+
* })
|
|
4611
|
+
* @param {InputDataType.CallbackType} object
|
|
4612
|
+
*/
|
|
4613
|
+
static checkStateBioAuthentication(object) {
|
|
4614
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4615
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4616
|
+
return {
|
|
4617
|
+
bioState: data === null || data === void 0 ? void 0 : data.bio_state
|
|
4618
|
+
};
|
|
4619
|
+
});
|
|
4620
|
+
});
|
|
4621
|
+
}
|
|
4622
|
+
/**
|
|
4623
|
+
* Vibrate.
|
|
4624
|
+
* @async
|
|
4625
|
+
* @function vibrate
|
|
4626
|
+
* @category Device
|
|
4627
|
+
*
|
|
4628
|
+
*/
|
|
4629
|
+
static vibrate(object) {
|
|
4630
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4631
|
+
return yield this.getJSBridge().callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4632
|
+
type: VibrateType[object.type],
|
|
4633
|
+
vibrate_time: object.milliseconds
|
|
4634
|
+
});
|
|
4635
|
+
});
|
|
4636
|
+
}
|
|
4637
|
+
/**
|
|
4638
|
+
* Connect Wifi.
|
|
4639
|
+
* @async
|
|
4640
|
+
* @function connectWifi
|
|
4641
|
+
* @category Device
|
|
4642
|
+
*
|
|
4643
|
+
*/
|
|
4644
|
+
static connectWifi(object) {
|
|
4645
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4646
|
+
let securityType = 'open';
|
|
4647
|
+
if (_.isString(object.password) && object.password.length > 0) {
|
|
4648
|
+
securityType = 'wpa_wpa2';
|
|
4649
|
+
}
|
|
4650
|
+
return yield this.getJSBridge().callNative(ACTION.MP_JOIN_WIFI, {
|
|
4651
|
+
ssid: object.SSID,
|
|
4652
|
+
securityType: securityType,
|
|
4653
|
+
password: object.password,
|
|
4654
|
+
hiddenSsid: object.hiddenSSID
|
|
4655
|
+
});
|
|
4656
|
+
});
|
|
4657
|
+
}
|
|
4658
|
+
/**
|
|
4659
|
+
* Open App Store.
|
|
4660
|
+
* @async
|
|
4661
|
+
* @function openAppStore
|
|
4662
|
+
* @category Device
|
|
4663
|
+
*
|
|
4664
|
+
*/
|
|
4665
|
+
static openAppStore(object) {
|
|
4666
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4667
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_APPSTORE, object);
|
|
4668
|
+
});
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
|
|
4673
|
+
class LocalResourceStorage {
|
|
4674
|
+
constructor(prefix) {
|
|
4675
|
+
_LocalResourceStorage_storage.set(this, localStorage);
|
|
4676
|
+
_LocalResourceStorage_prefix.set(this, void 0);
|
|
4677
|
+
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
4678
|
+
checkPlatform();
|
|
4679
|
+
// if (platform.isMobile && platform.isZalo) {
|
|
4680
|
+
// Object.defineProperty(window, 'localStorage', {
|
|
4681
|
+
// value: null,
|
|
4682
|
+
// configurable: true,
|
|
4683
|
+
// enumerable: true,
|
|
4684
|
+
// writable: false
|
|
4685
|
+
// });
|
|
4686
|
+
// }
|
|
4687
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
4688
|
+
keys: new Set(),
|
|
4689
|
+
currentSize: 0,
|
|
4690
|
+
limitSize: STORAGE_LIMIT
|
|
4691
|
+
}, "f");
|
|
4692
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
4693
|
+
this.findAllCurrentDataByApp(prefix);
|
|
4694
|
+
}
|
|
4695
|
+
findAllCurrentDataByApp(prefix) {
|
|
4696
|
+
try {
|
|
4697
|
+
let _x;
|
|
4698
|
+
for (_x in __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f")) {
|
|
4699
|
+
if (prefix) {
|
|
4700
|
+
const _prefix = _x.split('_')[0];
|
|
4701
|
+
if (_prefix !== prefix) {
|
|
4702
|
+
continue;
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
catch (error) {
|
|
4709
|
+
logger.error(error, 'LocalResourceStorage > findAllCurrentDataByApp');
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
get(keys) {
|
|
4713
|
+
let res = new Map();
|
|
4714
|
+
keys.forEach((key) => {
|
|
4715
|
+
res.set(key, this.getSync(key));
|
|
4849
4716
|
});
|
|
4717
|
+
return Promise.resolve(res);
|
|
4718
|
+
}
|
|
4719
|
+
getSync(key) {
|
|
4720
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4721
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4722
|
+
}
|
|
4723
|
+
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
4724
|
+
return null;
|
|
4725
|
+
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
4850
4726
|
}
|
|
4851
|
-
|
|
4852
|
-
* Open phone
|
|
4853
|
-
* @async
|
|
4854
|
-
* @function openPhone
|
|
4855
|
-
* @category Device
|
|
4856
|
-
*
|
|
4857
|
-
*/
|
|
4858
|
-
static openPhone(object) {
|
|
4727
|
+
set(data) {
|
|
4859
4728
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
phoneCode: object.phoneNumber
|
|
4729
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
4730
|
+
this.setSync(key, value.replace(/\\"/g, '"'));
|
|
4863
4731
|
});
|
|
4732
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4864
4733
|
});
|
|
4865
4734
|
}
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4735
|
+
setSync(key, value) {
|
|
4736
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4737
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4738
|
+
}
|
|
4739
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").setItem(key, value);
|
|
4740
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(key);
|
|
4741
|
+
}
|
|
4742
|
+
getInfo() {
|
|
4874
4743
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4875
|
-
|
|
4876
|
-
content: object.content,
|
|
4877
|
-
phoneCode: object.phoneNumber
|
|
4878
|
-
});
|
|
4744
|
+
return Promise.resolve(this.getInfoSync());
|
|
4879
4745
|
});
|
|
4880
4746
|
}
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4747
|
+
getInfoSync() {
|
|
4748
|
+
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
4749
|
+
return {
|
|
4750
|
+
currentSize: _.isNumber(currentSize)
|
|
4751
|
+
? Number((currentSize / 1024).toFixed(2))
|
|
4752
|
+
: 0,
|
|
4753
|
+
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
4754
|
+
};
|
|
4755
|
+
}
|
|
4756
|
+
remove(keys) {
|
|
4889
4757
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4893
|
-
}
|
|
4758
|
+
keys.forEach((key) => {
|
|
4759
|
+
this.removeSync(key);
|
|
4894
4760
|
});
|
|
4761
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4895
4762
|
});
|
|
4896
4763
|
}
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4764
|
+
removeSync(key) {
|
|
4765
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4766
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4767
|
+
}
|
|
4768
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key)) {
|
|
4769
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4770
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
clear() {
|
|
4905
4774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4906
|
-
return
|
|
4907
|
-
secret_data: object.secretData,
|
|
4908
|
-
app_id: this.getZAppId(),
|
|
4909
|
-
ui: {
|
|
4910
|
-
title: object.ui.title,
|
|
4911
|
-
sub_title: object.ui.subTitle,
|
|
4912
|
-
negative_text: object.ui.negativeButtonText
|
|
4913
|
-
},
|
|
4914
|
-
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4915
|
-
}).then((data) => {
|
|
4916
|
-
var _a, _b, _c, _d;
|
|
4917
|
-
return {
|
|
4918
|
-
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4919
|
-
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4920
|
-
data: {
|
|
4921
|
-
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4922
|
-
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4923
|
-
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4924
|
-
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4925
|
-
}
|
|
4926
|
-
};
|
|
4927
|
-
});
|
|
4775
|
+
return Promise.resolve(this.clearSync());
|
|
4928
4776
|
});
|
|
4929
4777
|
}
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4778
|
+
clearSync() {
|
|
4779
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
4780
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
4781
|
+
return;
|
|
4782
|
+
}
|
|
4783
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4784
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4785
|
+
});
|
|
4786
|
+
}
|
|
4787
|
+
}
|
|
4788
|
+
_LocalResourceStorage_storage = new WeakMap(), _LocalResourceStorage_prefix = new WeakMap(), _LocalResourceStorage_resourceInfo = new WeakMap();
|
|
4789
|
+
|
|
4790
|
+
var wrappers = {};
|
|
4791
|
+
var WrapperFn = function wrapFunction(fn, type, source) {
|
|
4792
|
+
var t = type || 'default';
|
|
4793
|
+
return function () {
|
|
4794
|
+
var callee = t in wrappers ? wrappers[t](fn, source) : fn;
|
|
4795
|
+
return callee.apply(this, arguments);
|
|
4796
|
+
};
|
|
4797
|
+
};
|
|
4798
|
+
WrapperFn.setWrapper = function (fn) {
|
|
4799
|
+
var type = arguments.length <= 1 || arguments[1] === undefined
|
|
4800
|
+
? 'default'
|
|
4801
|
+
: arguments[1];
|
|
4802
|
+
wrappers[type] = fn;
|
|
4803
|
+
};
|
|
4804
|
+
var ERROR = {
|
|
4805
|
+
error: {
|
|
4806
|
+
code: 1,
|
|
4807
|
+
error_subcode: 1357046,
|
|
4808
|
+
message: 'Received Invalid JSON reply.',
|
|
4809
|
+
type: 'http'
|
|
4810
|
+
}
|
|
4811
|
+
};
|
|
4812
|
+
function safelyParseResponse(rawResponse) {
|
|
4813
|
+
try {
|
|
4814
|
+
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
4815
|
+
}
|
|
4816
|
+
catch (ex) {
|
|
4817
|
+
return ERROR;
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
function createCORSRequest(method, url) {
|
|
4821
|
+
if (!self.XMLHttpRequest) {
|
|
4822
|
+
return null;
|
|
4823
|
+
}
|
|
4824
|
+
var xhr = new XMLHttpRequest();
|
|
4825
|
+
var noop = function noop() { };
|
|
4826
|
+
if ('withCredentials' in xhr) {
|
|
4827
|
+
xhr.open(method, url, true);
|
|
4828
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
4829
|
+
}
|
|
4830
|
+
else {
|
|
4831
|
+
return null;
|
|
4832
|
+
}
|
|
4833
|
+
var wrapper = {
|
|
4834
|
+
send: function send(data) {
|
|
4835
|
+
xhr.send(data);
|
|
4836
|
+
}
|
|
4837
|
+
};
|
|
4838
|
+
var onload = WrapperFn(function () {
|
|
4839
|
+
onload = noop;
|
|
4840
|
+
if ('onload' in wrapper) {
|
|
4841
|
+
wrapper.onload(xhr);
|
|
4842
|
+
}
|
|
4843
|
+
}, 'entry', 'XMLHttpRequest:load');
|
|
4844
|
+
var onerror = WrapperFn(function () {
|
|
4845
|
+
onerror = noop;
|
|
4846
|
+
if ('onerror' in wrapper) {
|
|
4847
|
+
wrapper.onerror(xhr);
|
|
4848
|
+
}
|
|
4849
|
+
}, 'entry', 'XMLHttpRequest:error');
|
|
4850
|
+
xhr.onload = function () {
|
|
4851
|
+
onload();
|
|
4852
|
+
};
|
|
4853
|
+
xhr.onerror = function () {
|
|
4854
|
+
onerror();
|
|
4855
|
+
};
|
|
4856
|
+
xhr.onreadystatechange = function () {
|
|
4857
|
+
if (xhr.readyState == 4) {
|
|
4858
|
+
if (xhr.status == 200) {
|
|
4859
|
+
onload();
|
|
4860
|
+
}
|
|
4861
|
+
else {
|
|
4862
|
+
onerror();
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
};
|
|
4866
|
+
return wrapper;
|
|
4867
|
+
}
|
|
4868
|
+
function execute(url, method, params, cb) {
|
|
4869
|
+
params.suppress_http_code = 1;
|
|
4870
|
+
var data = QueryString.encode(params);
|
|
4871
|
+
if (method != 'post') {
|
|
4872
|
+
url = QueryString.appendToUrl(url, data);
|
|
4873
|
+
data = '';
|
|
4874
|
+
}
|
|
4875
|
+
var request = createCORSRequest(method, url);
|
|
4876
|
+
if (!request) {
|
|
4877
|
+
return false;
|
|
4878
|
+
}
|
|
4879
|
+
request.onload = function (xhr) {
|
|
4880
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4881
|
+
};
|
|
4882
|
+
request.onerror = function (xhr) {
|
|
4883
|
+
if (xhr.responseText) {
|
|
4884
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4885
|
+
}
|
|
4886
|
+
else {
|
|
4887
|
+
cb({
|
|
4888
|
+
error: {
|
|
4889
|
+
code: 1,
|
|
4890
|
+
error_subcode: 1357045,
|
|
4891
|
+
message: 'unknown error (empty response)',
|
|
4892
|
+
status: xhr.status,
|
|
4893
|
+
type: 'http'
|
|
4894
|
+
}
|
|
4895
|
+
});
|
|
4896
|
+
}
|
|
4897
|
+
};
|
|
4898
|
+
request.send(data);
|
|
4899
|
+
return true;
|
|
4900
|
+
}
|
|
4901
|
+
var CORSRequest = {
|
|
4902
|
+
execute: execute
|
|
4903
|
+
};
|
|
4904
|
+
|
|
4905
|
+
var _ZaloJSBridge_instances, _ZaloJSBridge_cookies, _ZaloJSBridge_actionRuntimeInfo, _ZaloJSBridge_jsCall;
|
|
4906
|
+
class ZaloJSBridge extends eventemitter3 {
|
|
4907
|
+
constructor() {
|
|
4908
|
+
super();
|
|
4909
|
+
_ZaloJSBridge_instances.add(this);
|
|
4910
|
+
this.debug = Debug('zmp:ZaloJSBridge');
|
|
4911
|
+
this.events = ZMPEEmitter.getInstance();
|
|
4912
|
+
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
4913
|
+
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
4914
|
+
this.results = [];
|
|
4915
|
+
this._userAgent = getUserAgent();
|
|
4916
|
+
this._device = checkPlatform();
|
|
4917
|
+
this.isJumped = false;
|
|
4918
|
+
_ZaloJSBridge_cookies.set(this, null);
|
|
4919
|
+
_ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
|
|
4920
|
+
this.jump = () => {
|
|
4921
|
+
return new Promise((resolve, reject) => {
|
|
4922
|
+
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
|
|
4923
|
+
resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
|
|
4924
|
+
}
|
|
4925
|
+
else {
|
|
4926
|
+
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
4927
|
+
.then((data) => {
|
|
4928
|
+
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
4929
|
+
const actionPermission = (data && data.actionPermission) || [];
|
|
4930
|
+
Object.entries(actionPermission).forEach((item) => {
|
|
4931
|
+
const key = item[0];
|
|
4932
|
+
const value = item[1] || { perm: 0, decode: 0 };
|
|
4933
|
+
if (!__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key]) {
|
|
4934
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key] = {
|
|
4935
|
+
permission: false,
|
|
4936
|
+
support: false
|
|
4937
|
+
};
|
|
4938
|
+
}
|
|
4939
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key].permission = value.perm === 1;
|
|
4940
|
+
});
|
|
4941
|
+
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
4942
|
+
if (jsToken) {
|
|
4943
|
+
this.jsAccessTk = jsToken.value;
|
|
4944
|
+
window.ZJSBridge.setJSToken &&
|
|
4945
|
+
window.ZJSBridge.setJSToken(jsToken.value);
|
|
4946
|
+
}
|
|
4947
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_cookies, cookies, "f");
|
|
4948
|
+
this.isJumped = true;
|
|
4949
|
+
resolve(cookies);
|
|
4950
|
+
})
|
|
4951
|
+
.catch((error) => {
|
|
4952
|
+
this.isJumped = false;
|
|
4953
|
+
reject(error);
|
|
4954
|
+
});
|
|
4955
|
+
}
|
|
4949
4956
|
});
|
|
4957
|
+
};
|
|
4958
|
+
this._jsCallFuncCallbacks = {};
|
|
4959
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_actionRuntimeInfo, {}, "f");
|
|
4960
|
+
this.events.on(Events.AppPaused, () => {
|
|
4961
|
+
if (this.results.length > 0) {
|
|
4962
|
+
let array = this.results;
|
|
4963
|
+
this.results = [];
|
|
4964
|
+
try {
|
|
4965
|
+
this.sendLogData(array);
|
|
4966
|
+
}
|
|
4967
|
+
catch (error) { }
|
|
4968
|
+
}
|
|
4950
4969
|
});
|
|
4970
|
+
if (this.sendLogTimer) {
|
|
4971
|
+
clearInterval(this.sendLogTimer);
|
|
4972
|
+
}
|
|
4973
|
+
else {
|
|
4974
|
+
this.sendLogTimer = setInterval(() => {
|
|
4975
|
+
if (this.results.length > 0) {
|
|
4976
|
+
let array = this.results;
|
|
4977
|
+
this.results = [];
|
|
4978
|
+
try {
|
|
4979
|
+
this.sendLogData(array);
|
|
4980
|
+
}
|
|
4981
|
+
catch (error) { }
|
|
4982
|
+
}
|
|
4983
|
+
}, 5000);
|
|
4984
|
+
}
|
|
4951
4985
|
}
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
*
|
|
4958
|
-
*/
|
|
4959
|
-
static vibrate(object) {
|
|
4960
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4961
|
-
return yield this.callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4962
|
-
type: VibrateType[object.type],
|
|
4963
|
-
vibrate_time: object.milliseconds
|
|
4964
|
-
});
|
|
4965
|
-
});
|
|
4986
|
+
static getInstance() {
|
|
4987
|
+
if (!ZaloJSBridge.instance) {
|
|
4988
|
+
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
4989
|
+
}
|
|
4990
|
+
return ZaloJSBridge.instance;
|
|
4966
4991
|
}
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
* @async
|
|
4970
|
-
* @function connectWifi
|
|
4971
|
-
* @category Device
|
|
4972
|
-
*
|
|
4973
|
-
*/
|
|
4974
|
-
static connectWifi(object) {
|
|
4975
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4976
|
-
let securityType = 'open';
|
|
4977
|
-
if (_.isString(object.password) && object.password.length > 0) {
|
|
4978
|
-
securityType = 'wpa_wpa2';
|
|
4979
|
-
}
|
|
4980
|
-
return yield this.callNative(ACTION.MP_JOIN_WIFI, {
|
|
4981
|
-
ssid: object.SSID,
|
|
4982
|
-
securityType: securityType,
|
|
4983
|
-
password: object.password,
|
|
4984
|
-
hiddenSsid: object.hiddenSSID
|
|
4985
|
-
});
|
|
4986
|
-
});
|
|
4992
|
+
set accessTk(value) {
|
|
4993
|
+
this._accessTk = value;
|
|
4987
4994
|
}
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
* @async
|
|
4991
|
-
* @function openAppStore
|
|
4992
|
-
* @category Device
|
|
4993
|
-
*
|
|
4994
|
-
*/
|
|
4995
|
-
static openAppStore(object) {
|
|
4996
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4997
|
-
return yield this.callNative(ACTION.OPEN_APPSTORE, object);
|
|
4998
|
-
});
|
|
4995
|
+
set jsAccessTk(value) {
|
|
4996
|
+
this._jsAccessTk = value;
|
|
4999
4997
|
}
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
limitSize: STORAGE_LIMIT
|
|
5021
|
-
}, "f");
|
|
5022
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
5023
|
-
this.findAllCurrentDataByApp(prefix);
|
|
4998
|
+
sendLogData(data) {
|
|
4999
|
+
try {
|
|
5000
|
+
const logData = data.map((item) => {
|
|
5001
|
+
return {
|
|
5002
|
+
action: item.action,
|
|
5003
|
+
error: item.error
|
|
5004
|
+
};
|
|
5005
|
+
});
|
|
5006
|
+
CORSRequest.execute(APIS.SEND_ACTION_LOG, 'post', {
|
|
5007
|
+
appId: window.APP_ID,
|
|
5008
|
+
data: JSON.stringify(logData)
|
|
5009
|
+
}, (response) => { });
|
|
5010
|
+
window.zmpSentry &&
|
|
5011
|
+
window.zmpSentry.captureMessage('Result from native', {
|
|
5012
|
+
extra: {
|
|
5013
|
+
data: data
|
|
5014
|
+
}
|
|
5015
|
+
});
|
|
5016
|
+
}
|
|
5017
|
+
catch (error) { }
|
|
5024
5018
|
}
|
|
5025
|
-
|
|
5019
|
+
onJSCall(key, data) {
|
|
5026
5020
|
try {
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5021
|
+
this.debug('onJSCall', key, data);
|
|
5022
|
+
const parsedData = parseJSON(data);
|
|
5023
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5024
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5025
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5026
|
+
if (!!callback) {
|
|
5027
|
+
try {
|
|
5028
|
+
callback.call(this, parsedData);
|
|
5029
|
+
}
|
|
5030
|
+
catch (error) {
|
|
5031
|
+
console.error('Call callback error', error);
|
|
5033
5032
|
}
|
|
5033
|
+
!!timeout && clearTimeout(timeout);
|
|
5034
|
+
this._jsCallFuncCallbacks[key] = null;
|
|
5035
|
+
delete this._jsCallFuncCallbacks[key];
|
|
5034
5036
|
}
|
|
5035
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
5036
5037
|
}
|
|
5038
|
+
this.results.push({
|
|
5039
|
+
action: parsedData.action,
|
|
5040
|
+
error: parsedData.error_code,
|
|
5041
|
+
message: parsedData.error_message
|
|
5042
|
+
});
|
|
5037
5043
|
}
|
|
5038
|
-
catch (
|
|
5039
|
-
|
|
5040
|
-
}
|
|
5041
|
-
}
|
|
5042
|
-
get(keys) {
|
|
5043
|
-
let res = new Map();
|
|
5044
|
-
keys.forEach((key) => {
|
|
5045
|
-
res.set(key, this.getSync(key));
|
|
5046
|
-
});
|
|
5047
|
-
return Promise.resolve(res);
|
|
5048
|
-
}
|
|
5049
|
-
getSync(key) {
|
|
5050
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5051
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5044
|
+
catch (e) {
|
|
5045
|
+
console.log('onJSCall', 'error', e);
|
|
5052
5046
|
}
|
|
5053
|
-
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
5054
|
-
return null;
|
|
5055
|
-
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
5056
5047
|
}
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5048
|
+
onMultiJSCall(key, data) {
|
|
5049
|
+
try {
|
|
5050
|
+
this.debug('onMultiJSCall', key, data);
|
|
5051
|
+
const parsedData = parseJSON(data);
|
|
5052
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5053
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5054
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5055
|
+
if (!!callback) {
|
|
5056
|
+
try {
|
|
5057
|
+
callback.call(this, parsedData);
|
|
5058
|
+
}
|
|
5059
|
+
catch (error) {
|
|
5060
|
+
console.error('Call callback error', error);
|
|
5061
|
+
}
|
|
5062
|
+
!!timeout && clearTimeout(timeout);
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
this.results.push({
|
|
5066
|
+
action: parsedData.action,
|
|
5067
|
+
error: parsedData.error_code,
|
|
5068
|
+
message: parsedData.error_message
|
|
5061
5069
|
});
|
|
5062
|
-
return Promise.resolve({ errorKeys: [] });
|
|
5063
|
-
});
|
|
5064
|
-
}
|
|
5065
|
-
setSync(key, value) {
|
|
5066
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5067
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5068
5070
|
}
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
getInfo() {
|
|
5073
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
5074
|
-
return Promise.resolve(this.getInfoSync());
|
|
5075
|
-
});
|
|
5076
|
-
}
|
|
5077
|
-
getInfoSync() {
|
|
5078
|
-
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
5079
|
-
return {
|
|
5080
|
-
currentSize: _.isNumber(currentSize)
|
|
5081
|
-
? Number((currentSize / 1024).toFixed(2))
|
|
5082
|
-
: 0,
|
|
5083
|
-
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
5084
|
-
};
|
|
5071
|
+
catch (e) {
|
|
5072
|
+
console.log('onMultiJSCall', 'error', e);
|
|
5073
|
+
}
|
|
5085
5074
|
}
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
});
|
|
5075
|
+
nativeEventHandler(eventId, eventName, eventData) {
|
|
5076
|
+
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
5077
|
+
const data = stringToData(eventData);
|
|
5078
|
+
this.debug(data);
|
|
5079
|
+
const convertedData = this.handleEventData(eventName, data);
|
|
5080
|
+
this.events.emit(eventName, eventId, convertedData);
|
|
5093
5081
|
}
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5082
|
+
handleEventData(eventName, data) {
|
|
5083
|
+
try {
|
|
5084
|
+
switch (eventName) {
|
|
5085
|
+
case Events.OpenApp:
|
|
5086
|
+
const { url } = data;
|
|
5087
|
+
const validUrl = new URL(url);
|
|
5088
|
+
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
5089
|
+
return {
|
|
5090
|
+
path: `${path ? path : '/'}${validUrl.search}`
|
|
5091
|
+
};
|
|
5092
|
+
break;
|
|
5093
|
+
default:
|
|
5094
|
+
return data;
|
|
5095
|
+
break;
|
|
5096
|
+
}
|
|
5097
5097
|
}
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5098
|
+
catch (error) {
|
|
5099
|
+
return data;
|
|
5101
5100
|
}
|
|
5102
5101
|
}
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
}
|
|
5102
|
+
defaultCallback(data) {
|
|
5103
|
+
if (data !== null && data !== undefined) {
|
|
5104
|
+
data = parseJSON(data);
|
|
5105
|
+
}
|
|
5107
5106
|
}
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5107
|
+
callNative(action, data, option) {
|
|
5108
|
+
this.debug(action.name, data);
|
|
5109
|
+
return new Promise((resolve, reject) => {
|
|
5110
|
+
const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
5111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5112
|
+
try {
|
|
5113
|
+
if (_.isUndefined(cb) || _.isNull(cb)) {
|
|
5114
|
+
return reject(new Error('Native callback is null'));
|
|
5115
|
+
}
|
|
5116
|
+
if (cb.error_code !== 0) {
|
|
5117
|
+
let error = new AppError(cb.error_code, cb.error_message);
|
|
5118
|
+
const platform = getPlatform();
|
|
5119
|
+
if (action === ACTION.JUMP_LOGIN) {
|
|
5120
|
+
error = new AppError(RESPONSE_CODE.UNKNOWN_ERROR, `Can not get auth code: ${cb.error_message}`);
|
|
5121
|
+
}
|
|
5122
|
+
else if (!this.isJumped && !action.skip_jump) {
|
|
5123
|
+
error = new AppError(RESPONSE.UNAUTHORIZED.code, RESPONSE.UNAUTHORIZED.message);
|
|
5124
|
+
}
|
|
5125
|
+
else if (String(error.message).toLowerCase() === 'permission required!' ||
|
|
5126
|
+
String(error.message).toLowerCase() === 'no permission!') {
|
|
5127
|
+
error = new AppError(RESPONSE.FORBIDDEN.code, RESPONSE.FORBIDDEN.message);
|
|
5128
|
+
}
|
|
5129
|
+
else if (COMMON_NATIVE_ERROR_CODE[platform][cb.error_code]) {
|
|
5130
|
+
error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
|
|
5131
|
+
}
|
|
5132
|
+
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)]) {
|
|
5133
|
+
let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
|
|
5134
|
+
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) {
|
|
5135
|
+
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}`;
|
|
5136
|
+
}
|
|
5137
|
+
error = new AppError(action.error_list[platform][String(cb.error_code)].map_to.code, error_message);
|
|
5138
|
+
}
|
|
5139
|
+
return reject(error);
|
|
5140
|
+
}
|
|
5141
|
+
if (option === null || option === void 0 ? void 0 : option.successCallback) {
|
|
5142
|
+
const res = yield option.successCallback(cb.data);
|
|
5143
|
+
return resolve(res);
|
|
5144
|
+
}
|
|
5145
|
+
else {
|
|
5146
|
+
resolve(cb.data || {});
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
catch (error) {
|
|
5150
|
+
return reject(error);
|
|
5151
|
+
}
|
|
5152
|
+
});
|
|
5153
|
+
const isIOS = checkPlatform().isIOS;
|
|
5154
|
+
const isSupportAction = checkIOSSupportAction(action);
|
|
5155
|
+
if (isIOS && !isSupportAction) {
|
|
5156
|
+
const error = new AppError(-5, `Client isn't support this action`);
|
|
5157
|
+
return reject(error);
|
|
5158
|
+
}
|
|
5159
|
+
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
5160
|
+
setTimeout(() => {
|
|
5161
|
+
__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);
|
|
5162
|
+
}, option.delay);
|
|
5163
|
+
}
|
|
5164
|
+
else {
|
|
5165
|
+
__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);
|
|
5112
5166
|
}
|
|
5113
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
5114
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5115
5167
|
});
|
|
5116
5168
|
}
|
|
5117
5169
|
}
|
|
5118
|
-
|
|
5170
|
+
_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) {
|
|
5171
|
+
try {
|
|
5172
|
+
const actionName = action.name;
|
|
5173
|
+
const key = generateUniqueString(actionName);
|
|
5174
|
+
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
5175
|
+
this.onJSCall(key, {
|
|
5176
|
+
error_code: -13,
|
|
5177
|
+
error_message: 'params invalid!',
|
|
5178
|
+
data: {
|
|
5179
|
+
device: this._device.isMobile,
|
|
5180
|
+
jsToken: this._jsAccessTk,
|
|
5181
|
+
access_token: this._accessTk
|
|
5182
|
+
},
|
|
5183
|
+
action: actionName
|
|
5184
|
+
});
|
|
5185
|
+
return false;
|
|
5186
|
+
}
|
|
5187
|
+
if (options === undefined || options === null) {
|
|
5188
|
+
options = {};
|
|
5189
|
+
}
|
|
5190
|
+
if (!callback) {
|
|
5191
|
+
callback = this.defaultCallback;
|
|
5192
|
+
}
|
|
5193
|
+
const timeoutCallback = {
|
|
5194
|
+
error_code: -14,
|
|
5195
|
+
error_message: 'Request Timeout!',
|
|
5196
|
+
data: {},
|
|
5197
|
+
action: actionName
|
|
5198
|
+
};
|
|
5199
|
+
this._jsCallFuncCallbacks[key] = {
|
|
5200
|
+
timeout: haveTimeout &&
|
|
5201
|
+
action.have_callback &&
|
|
5202
|
+
setTimeout(() => {
|
|
5203
|
+
this.onJSCall(key, timeoutCallback);
|
|
5204
|
+
}, 8000),
|
|
5205
|
+
callback: callback
|
|
5206
|
+
};
|
|
5207
|
+
try {
|
|
5208
|
+
options = serialize(options);
|
|
5209
|
+
if (isMultiCallback) {
|
|
5210
|
+
if (this._device.isIOS) {
|
|
5211
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
5212
|
+
}
|
|
5213
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
5214
|
+
}
|
|
5215
|
+
if (this._device.isIOS) {
|
|
5216
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
5217
|
+
}
|
|
5218
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
5219
|
+
}
|
|
5220
|
+
catch (error) {
|
|
5221
|
+
if (nRetry-- > 0) {
|
|
5222
|
+
setTimeout(() => {
|
|
5223
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, options, callback, isMultiCallback, nRetry);
|
|
5224
|
+
}, 500);
|
|
5225
|
+
}
|
|
5226
|
+
else {
|
|
5227
|
+
const errorCallback = {
|
|
5228
|
+
error_code: -5,
|
|
5229
|
+
error_message: 'Not ready!',
|
|
5230
|
+
data: {
|
|
5231
|
+
userAgent: this._userAgent,
|
|
5232
|
+
options: options,
|
|
5233
|
+
jsToken: this._jsAccessTk,
|
|
5234
|
+
access_token: this._accessTk
|
|
5235
|
+
},
|
|
5236
|
+
action: actionName,
|
|
5237
|
+
js_error: error
|
|
5238
|
+
};
|
|
5239
|
+
this.onJSCall(key, errorCallback);
|
|
5240
|
+
return false;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
catch (error) {
|
|
5245
|
+
console.log('jsCall', 'error', error);
|
|
5246
|
+
}
|
|
5247
|
+
return false;
|
|
5248
|
+
};
|
|
5119
5249
|
|
|
5120
|
-
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo;
|
|
5121
|
-
class NativeResourceStorage
|
|
5250
|
+
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo, _NativeResourceStorage_bridge;
|
|
5251
|
+
class NativeResourceStorage {
|
|
5122
5252
|
constructor(appId) {
|
|
5123
|
-
super();
|
|
5124
5253
|
_NativeResourceStorage_appId.set(this, void 0);
|
|
5125
5254
|
_NativeResourceStorage_resourceInfo.set(this, void 0);
|
|
5255
|
+
_NativeResourceStorage_bridge.set(this, void 0);
|
|
5126
5256
|
__classPrivateFieldSet(this, _NativeResourceStorage_resourceInfo, {
|
|
5127
5257
|
keys: new Set(),
|
|
5128
5258
|
currentSize: 0,
|
|
5129
5259
|
limitSize: STORAGE_LIMIT
|
|
5130
5260
|
}, "f");
|
|
5131
5261
|
__classPrivateFieldSet(this, _NativeResourceStorage_appId, appId, "f");
|
|
5262
|
+
__classPrivateFieldSet(this, _NativeResourceStorage_bridge, ZaloJSBridge.getInstance(), "f");
|
|
5132
5263
|
}
|
|
5133
5264
|
get(keys) {
|
|
5134
5265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5135
|
-
return yield this
|
|
5266
|
+
return yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5267
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5136
5268
|
mpds_action: 'mpds.get',
|
|
5137
5269
|
mpds_data: {
|
|
5138
5270
|
keys
|
|
@@ -5140,7 +5272,8 @@
|
|
|
5140
5272
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5141
5273
|
}, {
|
|
5142
5274
|
isMultiCallback: false
|
|
5143
|
-
})
|
|
5275
|
+
})
|
|
5276
|
+
.then((data) => {
|
|
5144
5277
|
let res = new Map();
|
|
5145
5278
|
if (data && data.mpds_data && data.mpds_data.map) {
|
|
5146
5279
|
res = new Map(Object.entries(data.mpds_data.map));
|
|
@@ -5151,7 +5284,8 @@
|
|
|
5151
5284
|
}
|
|
5152
5285
|
set(data) {
|
|
5153
5286
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5154
|
-
const errorKeys = yield this
|
|
5287
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5288
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5155
5289
|
mpds_action: 'mpds.set',
|
|
5156
5290
|
mpds_data: {
|
|
5157
5291
|
map: data
|
|
@@ -5159,7 +5293,8 @@
|
|
|
5159
5293
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5160
5294
|
}, {
|
|
5161
5295
|
isMultiCallback: false
|
|
5162
|
-
})
|
|
5296
|
+
})
|
|
5297
|
+
.then((data) => {
|
|
5163
5298
|
let res = [];
|
|
5164
5299
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5165
5300
|
res = data.mpds_data.error_keys;
|
|
@@ -5171,13 +5306,15 @@
|
|
|
5171
5306
|
}
|
|
5172
5307
|
getInfo() {
|
|
5173
5308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5174
|
-
const currentSize = yield this
|
|
5309
|
+
const currentSize = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5310
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5175
5311
|
mpds_action: 'mpds.get.size',
|
|
5176
5312
|
mpds_data: {},
|
|
5177
5313
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5178
5314
|
}, {
|
|
5179
5315
|
isMultiCallback: false
|
|
5180
|
-
})
|
|
5316
|
+
})
|
|
5317
|
+
.then((data) => {
|
|
5181
5318
|
let res = 0;
|
|
5182
5319
|
if (data && data.mpds_data && data.mpds_data.size) {
|
|
5183
5320
|
res = data.mpds_data.size;
|
|
@@ -5192,7 +5329,8 @@
|
|
|
5192
5329
|
}
|
|
5193
5330
|
remove(keys) {
|
|
5194
5331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5195
|
-
const errorKeys = yield this
|
|
5332
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5333
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5196
5334
|
mpds_action: 'mpds.remove.key',
|
|
5197
5335
|
mpds_data: {
|
|
5198
5336
|
keys: keys
|
|
@@ -5200,7 +5338,8 @@
|
|
|
5200
5338
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5201
5339
|
}, {
|
|
5202
5340
|
isMultiCallback: false
|
|
5203
|
-
})
|
|
5341
|
+
})
|
|
5342
|
+
.then((data) => {
|
|
5204
5343
|
let res = [];
|
|
5205
5344
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5206
5345
|
res = data.mpds_data.error_keys;
|
|
@@ -5212,7 +5351,7 @@
|
|
|
5212
5351
|
}
|
|
5213
5352
|
clear() {
|
|
5214
5353
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5215
|
-
yield this.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5354
|
+
yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f").callNative(ACTION.ZBROWSER_MPDS, {
|
|
5216
5355
|
mpds_action: 'mpds.clear.appData',
|
|
5217
5356
|
mpds_data: {},
|
|
5218
5357
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
@@ -5220,7 +5359,7 @@
|
|
|
5220
5359
|
});
|
|
5221
5360
|
}
|
|
5222
5361
|
}
|
|
5223
|
-
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap();
|
|
5362
|
+
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap(), _NativeResourceStorage_bridge = new WeakMap();
|
|
5224
5363
|
|
|
5225
5364
|
var _LocalStorageCreator_appId, _NativeStorageCreator_appId;
|
|
5226
5365
|
class StorageCreator {
|
|
@@ -5472,18 +5611,13 @@
|
|
|
5472
5611
|
*/
|
|
5473
5612
|
static getPhoneNumber(object) {
|
|
5474
5613
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5475
|
-
return yield this.callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5614
|
+
return yield this.getJSBridge().callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5476
5615
|
isMultiCallback: true,
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
return Promise.resolve(res);
|
|
5483
|
-
}
|
|
5484
|
-
else {
|
|
5485
|
-
return Promise.reject(error);
|
|
5486
|
-
}
|
|
5616
|
+
successCallback: (data) => {
|
|
5617
|
+
const res = {
|
|
5618
|
+
number: data
|
|
5619
|
+
};
|
|
5620
|
+
return Promise.resolve(res);
|
|
5487
5621
|
},
|
|
5488
5622
|
delay: this.isIOS ? 400 : 0
|
|
5489
5623
|
});
|
|
@@ -5502,7 +5636,7 @@
|
|
|
5502
5636
|
*/
|
|
5503
5637
|
static closeApp(object) {
|
|
5504
5638
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5505
|
-
yield this.callNative(ACTION.WINDOW_CLOSE, {});
|
|
5639
|
+
yield this.getJSBridge().callNative(ACTION.WINDOW_CLOSE, {});
|
|
5506
5640
|
});
|
|
5507
5641
|
}
|
|
5508
5642
|
/**
|
|
@@ -5534,7 +5668,7 @@
|
|
|
5534
5668
|
mpInfo.appName = appInfo.name;
|
|
5535
5669
|
mpInfo.appAvtUrl = appInfo.logoUrl;
|
|
5536
5670
|
}
|
|
5537
|
-
yield this.callNative(ACTION.OPEN_MP, {
|
|
5671
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_MP, {
|
|
5538
5672
|
mpUrl: `${MINI_APP_INTERNAL_LINK}/${appId}/${queryParamString.length > 0 ? '?' + queryParamString : ''}`,
|
|
5539
5673
|
mpInfo: mpInfo
|
|
5540
5674
|
});
|
|
@@ -5550,7 +5684,7 @@
|
|
|
5550
5684
|
*/
|
|
5551
5685
|
static openWebview(url) {
|
|
5552
5686
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5553
|
-
yield this.callNative(ACTION.OPEN_INAPP, {
|
|
5687
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_INAPP, {
|
|
5554
5688
|
url: url
|
|
5555
5689
|
});
|
|
5556
5690
|
});
|
|
@@ -5565,7 +5699,7 @@
|
|
|
5565
5699
|
*/
|
|
5566
5700
|
static closeLoading(when) {
|
|
5567
5701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5568
|
-
yield this.callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5702
|
+
yield this.getJSBridge().callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5569
5703
|
at: new Date().getTime(),
|
|
5570
5704
|
when: when,
|
|
5571
5705
|
url: location.href
|
|
@@ -5592,30 +5726,24 @@
|
|
|
5592
5726
|
*/
|
|
5593
5727
|
static getLocation(object) {
|
|
5594
5728
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5595
|
-
return yield this.callNative(ACTION.GET_LOCATION, {
|
|
5729
|
+
return yield this.getJSBridge().callNative(ACTION.GET_LOCATION, {
|
|
5596
5730
|
silent_request: false,
|
|
5597
5731
|
permission_description: 'Cho phép Zalo truy cập vào vị trí của thiết bị này?'
|
|
5598
5732
|
}, {
|
|
5599
5733
|
isMultiCallback: true,
|
|
5600
5734
|
haveTimeout: false,
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
};
|
|
5614
|
-
return Promise.resolve(res);
|
|
5615
|
-
}
|
|
5616
|
-
else {
|
|
5617
|
-
return Promise.reject(error);
|
|
5618
|
-
}
|
|
5735
|
+
successCallback: (data) => {
|
|
5736
|
+
const res = {
|
|
5737
|
+
/** latitude */
|
|
5738
|
+
latitude: data.latitude,
|
|
5739
|
+
/** longitude */
|
|
5740
|
+
longitude: data.longitude,
|
|
5741
|
+
/** timestamp */
|
|
5742
|
+
timestamp: data.timestamp,
|
|
5743
|
+
/** provider */
|
|
5744
|
+
provider: data.provider
|
|
5745
|
+
};
|
|
5746
|
+
return Promise.resolve(res);
|
|
5619
5747
|
},
|
|
5620
5748
|
delay: this.isIOS ? 400 : 0
|
|
5621
5749
|
});
|
|
@@ -5631,7 +5759,7 @@
|
|
|
5631
5759
|
*/
|
|
5632
5760
|
static sendLocation(object) {
|
|
5633
5761
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5634
|
-
yield this.callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5762
|
+
yield this.getJSBridge().callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5635
5763
|
title: object.title,
|
|
5636
5764
|
touserid: object.toUserId,
|
|
5637
5765
|
zapp: this.getZAppId()
|
|
@@ -5651,17 +5779,12 @@
|
|
|
5651
5779
|
*/
|
|
5652
5780
|
static requestCameraPermission(object) {
|
|
5653
5781
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5654
|
-
return yield this.callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
});
|
|
5661
|
-
}
|
|
5662
|
-
else {
|
|
5663
|
-
return Promise.reject(error);
|
|
5664
|
-
}
|
|
5782
|
+
return yield this.getJSBridge().callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5783
|
+
successCallback: () => {
|
|
5784
|
+
return Promise.resolve({
|
|
5785
|
+
userAllow: true,
|
|
5786
|
+
message: 'User Allow'
|
|
5787
|
+
});
|
|
5665
5788
|
}
|
|
5666
5789
|
});
|
|
5667
5790
|
});
|
|
@@ -5687,7 +5810,7 @@
|
|
|
5687
5810
|
imageUrl: object.imageUrl
|
|
5688
5811
|
};
|
|
5689
5812
|
}
|
|
5690
|
-
return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5813
|
+
return yield this.getJSBridge().callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5691
5814
|
});
|
|
5692
5815
|
}
|
|
5693
5816
|
}
|
|
@@ -5702,7 +5825,7 @@
|
|
|
5702
5825
|
*/
|
|
5703
5826
|
static viewOAQr(object) {
|
|
5704
5827
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5705
|
-
yield this.callNative(ACTION.VIEW_MYQR, {
|
|
5828
|
+
yield this.getJSBridge().callNative(ACTION.VIEW_MYQR, {
|
|
5706
5829
|
dpn: object.displayName,
|
|
5707
5830
|
uid: object.id,
|
|
5708
5831
|
zapp: this.getZAppId()
|
|
@@ -5721,7 +5844,7 @@
|
|
|
5721
5844
|
*/
|
|
5722
5845
|
static openProfile(object) {
|
|
5723
5846
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5724
|
-
return yield this.callNative(ACTION.OPEN_PROFILE, {
|
|
5847
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_PROFILE, {
|
|
5725
5848
|
uId: object.id,
|
|
5726
5849
|
type: ProfileType[object.type],
|
|
5727
5850
|
zapp: this.getZAppId(),
|
|
@@ -5739,7 +5862,7 @@
|
|
|
5739
5862
|
*/
|
|
5740
5863
|
static openChat(object) {
|
|
5741
5864
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5742
|
-
return yield this.callNative(ACTION.OPEN_CHAT, {
|
|
5865
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_CHAT, {
|
|
5743
5866
|
uId: object.id,
|
|
5744
5867
|
type: ChatType[object.type],
|
|
5745
5868
|
msg: object.message || '',
|
|
@@ -5781,7 +5904,9 @@
|
|
|
5781
5904
|
};
|
|
5782
5905
|
break;
|
|
5783
5906
|
}
|
|
5784
|
-
return yield this.
|
|
5907
|
+
return yield this.getJSBridge()
|
|
5908
|
+
.callNative(ACTION.OPEN_POSTFEED, Object.assign(Object.assign({ type: PostFeedType[object.type] }, reqData), { zapp: this.getZAppId() }))
|
|
5909
|
+
.then((res) => {
|
|
5785
5910
|
return {
|
|
5786
5911
|
status: res.status,
|
|
5787
5912
|
shareType: res.share_type,
|
|
@@ -5800,7 +5925,7 @@
|
|
|
5800
5925
|
*/
|
|
5801
5926
|
static followOA(object) {
|
|
5802
5927
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5803
|
-
yield this.callNative(ACTION.FOLLOW_OA, {
|
|
5928
|
+
yield this.getJSBridge().callNative(ACTION.FOLLOW_OA, {
|
|
5804
5929
|
uid: object.id,
|
|
5805
5930
|
showDialogConfirm: true,
|
|
5806
5931
|
zapp: this.getZAppId()
|
|
@@ -5819,7 +5944,7 @@
|
|
|
5819
5944
|
*/
|
|
5820
5945
|
static unfollowOA(object) {
|
|
5821
5946
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5822
|
-
yield this.callNative(ACTION.UNFOLLOW_OA, {
|
|
5947
|
+
yield this.getJSBridge().callNative(ACTION.UNFOLLOW_OA, {
|
|
5823
5948
|
uid: object.id,
|
|
5824
5949
|
zapp: this.getZAppId()
|
|
5825
5950
|
}, {
|
|
@@ -5841,7 +5966,8 @@
|
|
|
5841
5966
|
switch (object.type) {
|
|
5842
5967
|
case 'image':
|
|
5843
5968
|
let photoUrls = [];
|
|
5844
|
-
if (Array.isArray(object.data.imageUrls) &&
|
|
5969
|
+
if (Array.isArray(object.data.imageUrls) &&
|
|
5970
|
+
object.data.imageUrls.length > 0) {
|
|
5845
5971
|
photoUrls = object.data.imageUrls;
|
|
5846
5972
|
}
|
|
5847
5973
|
else {
|
|
@@ -5908,9 +6034,11 @@
|
|
|
5908
6034
|
object.type = 'link';
|
|
5909
6035
|
}
|
|
5910
6036
|
}
|
|
5911
|
-
return yield this.
|
|
6037
|
+
return yield this.getJSBridge()
|
|
6038
|
+
.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[object.type] }, reqData), { zapp: this.getZAppId() }), {
|
|
5912
6039
|
haveTimeout: false
|
|
5913
|
-
})
|
|
6040
|
+
})
|
|
6041
|
+
.then((res) => {
|
|
5914
6042
|
return {
|
|
5915
6043
|
status: res.status,
|
|
5916
6044
|
shareType: res.share_type,
|
|
@@ -5929,7 +6057,7 @@
|
|
|
5929
6057
|
*/
|
|
5930
6058
|
static createShortcut(url, title, icon) {
|
|
5931
6059
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5932
|
-
return yield this.callNative(ACTION.CREATE_SHORTCUT, {
|
|
6060
|
+
return yield this.getJSBridge().callNative(ACTION.CREATE_SHORTCUT, {
|
|
5933
6061
|
url: url,
|
|
5934
6062
|
title: title,
|
|
5935
6063
|
iconUrl: icon
|
|
@@ -5946,15 +6074,14 @@
|
|
|
5946
6074
|
*/
|
|
5947
6075
|
static openProfilePicker(maxProfile) {
|
|
5948
6076
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5949
|
-
return yield this.callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
6077
|
+
return yield this.getJSBridge().callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
5950
6078
|
maxProfile: maxProfile
|
|
5951
6079
|
}, {
|
|
5952
6080
|
isMultiCallback: true,
|
|
5953
|
-
|
|
5954
|
-
if (
|
|
5955
|
-
return Promise.resolve(
|
|
6081
|
+
successCallback: (data) => {
|
|
6082
|
+
if (Array.isArray(data)) {
|
|
6083
|
+
return Promise.resolve(data.map((item) => item.id));
|
|
5956
6084
|
}
|
|
5957
|
-
return Promise.reject(error);
|
|
5958
6085
|
}
|
|
5959
6086
|
});
|
|
5960
6087
|
});
|
|
@@ -5969,15 +6096,15 @@
|
|
|
5969
6096
|
*/
|
|
5970
6097
|
static getActionsSupported(object) {
|
|
5971
6098
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5972
|
-
return yield this.callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
6099
|
+
return yield this.getJSBridge().callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
5973
6100
|
isMultiCallback: false,
|
|
5974
|
-
|
|
6101
|
+
successCallback: (data) => {
|
|
5975
6102
|
const platform = getPlatform();
|
|
5976
|
-
if (Array.isArray(
|
|
5977
|
-
|
|
6103
|
+
if (Array.isArray(data.actions) &&
|
|
6104
|
+
data.actions.length > 0) {
|
|
5978
6105
|
const skipJumpActions = Object.keys(ACTION).filter((item) => ACTION[item].skip_jump);
|
|
5979
6106
|
const res = {
|
|
5980
|
-
actions: [...
|
|
6107
|
+
actions: [...data.actions, ...skipJumpActions]
|
|
5981
6108
|
};
|
|
5982
6109
|
return Promise.resolve(res);
|
|
5983
6110
|
}
|
|
@@ -5987,7 +6114,6 @@
|
|
|
5987
6114
|
};
|
|
5988
6115
|
return Promise.resolve(res);
|
|
5989
6116
|
}
|
|
5990
|
-
return Promise.reject(error);
|
|
5991
6117
|
}
|
|
5992
6118
|
});
|
|
5993
6119
|
});
|
|
@@ -6011,7 +6137,7 @@
|
|
|
6011
6137
|
enable: 1,
|
|
6012
6138
|
aspect_ratio: '1:1'
|
|
6013
6139
|
};
|
|
6014
|
-
return yield this.callNative(ACTION.PICK_MEDIA, {
|
|
6140
|
+
return yield this.getJSBridge().callNative(ACTION.PICK_MEDIA, {
|
|
6015
6141
|
media_type: MediaPickerType[type],
|
|
6016
6142
|
edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
|
|
6017
6143
|
silent_request: silentRequest,
|
|
@@ -6019,15 +6145,11 @@
|
|
|
6019
6145
|
max_select_items: maxSelectItem
|
|
6020
6146
|
}, {
|
|
6021
6147
|
isMultiCallback: true,
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
};
|
|
6028
|
-
return Promise.resolve(res);
|
|
6029
|
-
}
|
|
6030
|
-
return Promise.reject(error);
|
|
6148
|
+
successCallback: (data) => {
|
|
6149
|
+
const res = {
|
|
6150
|
+
data: data === null || data === void 0 ? void 0 : data.result_content
|
|
6151
|
+
};
|
|
6152
|
+
return Promise.resolve(res);
|
|
6031
6153
|
}
|
|
6032
6154
|
});
|
|
6033
6155
|
});
|
|
@@ -6042,7 +6164,7 @@
|
|
|
6042
6164
|
*/
|
|
6043
6165
|
static openOutApp(url) {
|
|
6044
6166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6045
|
-
return yield this.callNative(ACTION.OPEN_OUTAPP, {
|
|
6167
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_OUTAPP, {
|
|
6046
6168
|
url: url
|
|
6047
6169
|
});
|
|
6048
6170
|
});
|
|
@@ -6081,7 +6203,7 @@
|
|
|
6081
6203
|
*/
|
|
6082
6204
|
static sendDataToPreviousMiniApp(object) {
|
|
6083
6205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6084
|
-
return yield this.callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6206
|
+
return yield this.getJSBridge().callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6085
6207
|
result: stringifyData(object.data)
|
|
6086
6208
|
});
|
|
6087
6209
|
});
|
|
@@ -6106,11 +6228,10 @@
|
|
|
6106
6228
|
}
|
|
6107
6229
|
}
|
|
6108
6230
|
|
|
6109
|
-
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn,
|
|
6110
|
-
class ZaloMiniProgramSDKService
|
|
6231
|
+
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_bridge, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn, _ZaloMiniProgramSDKService_deviceId, _ZaloMiniProgramSDKService_actionBarConfig, _ZaloMiniProgramSDKService_getActionsSupported;
|
|
6232
|
+
class ZaloMiniProgramSDKService {
|
|
6111
6233
|
constructor() {
|
|
6112
6234
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6113
|
-
super();
|
|
6114
6235
|
_ZaloMiniProgramSDKService_zAppId.set(this, ZAPP_ID);
|
|
6115
6236
|
_ZaloMiniProgramSDKService_appId.set(this, APP_ID);
|
|
6116
6237
|
_ZaloMiniProgramSDKService_appConfig.set(this, APP_CONFIG);
|
|
@@ -6123,9 +6244,9 @@
|
|
|
6123
6244
|
getToken: 0
|
|
6124
6245
|
}
|
|
6125
6246
|
});
|
|
6247
|
+
_ZaloMiniProgramSDKService_bridge.set(this, void 0);
|
|
6126
6248
|
_ZaloMiniProgramSDKService_prevGetTokenTimestamp.set(this, void 0);
|
|
6127
6249
|
_ZaloMiniProgramSDKService_tokenExpiresIn.set(this, void 0);
|
|
6128
|
-
_ZaloMiniProgramSDKService_cookies.set(this, null);
|
|
6129
6250
|
_ZaloMiniProgramSDKService_deviceId.set(this, void 0);
|
|
6130
6251
|
this.events = ZMPEEmitter.getInstance();
|
|
6131
6252
|
this.isIOS = checkPlatform().isIOS;
|
|
@@ -6136,34 +6257,6 @@
|
|
|
6136
6257
|
this.setActionBarConfig = (setState) => {
|
|
6137
6258
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
|
|
6138
6259
|
};
|
|
6139
|
-
_ZaloMiniProgramSDKService_callJump.set(this, () => {
|
|
6140
|
-
return new Promise((resolve, reject) => {
|
|
6141
|
-
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"))) {
|
|
6142
|
-
resolve(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"));
|
|
6143
|
-
}
|
|
6144
|
-
else {
|
|
6145
|
-
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
6146
|
-
.then((data) => {
|
|
6147
|
-
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
6148
|
-
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
6149
|
-
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6150
|
-
if (jsToken) {
|
|
6151
|
-
this.setJSToken(jsToken.value);
|
|
6152
|
-
window.ZJSBridge.setJSToken &&
|
|
6153
|
-
window.ZJSBridge.setJSToken(jsToken.value);
|
|
6154
|
-
}
|
|
6155
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_cookies, cookies, "f");
|
|
6156
|
-
if (deviceId) {
|
|
6157
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6158
|
-
}
|
|
6159
|
-
resolve(cookies);
|
|
6160
|
-
})
|
|
6161
|
-
.catch((error) => {
|
|
6162
|
-
reject(error);
|
|
6163
|
-
});
|
|
6164
|
-
}
|
|
6165
|
-
});
|
|
6166
|
-
});
|
|
6167
6260
|
this.getVersion = Basics.getVersion;
|
|
6168
6261
|
this.getSystemInfo = Basics.getSystemInfo;
|
|
6169
6262
|
this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
|
|
@@ -6234,6 +6327,7 @@
|
|
|
6234
6327
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, 0, "f");
|
|
6235
6328
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, 0, "f");
|
|
6236
6329
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, '', "f");
|
|
6330
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_bridge, ZaloJSBridge.getInstance(), "f");
|
|
6237
6331
|
const showHomeButton = ((_b = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _a === void 0 ? void 0 : _a.app) === null || _b === void 0 ? void 0 : _b.leftButton) === 'home' ||
|
|
6238
6332
|
((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
|
|
6239
6333
|
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
@@ -6280,9 +6374,16 @@
|
|
|
6280
6374
|
getDeviceId() {
|
|
6281
6375
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
|
|
6282
6376
|
}
|
|
6377
|
+
getJSBridge() {
|
|
6378
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
|
|
6379
|
+
}
|
|
6283
6380
|
login(object) {
|
|
6284
6381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6285
|
-
const cookies = yield __classPrivateFieldGet(this,
|
|
6382
|
+
const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
|
|
6383
|
+
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6384
|
+
if (deviceId) {
|
|
6385
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6386
|
+
}
|
|
6286
6387
|
const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
|
|
6287
6388
|
const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
|
|
6288
6389
|
if (!_.isUndefined(zOAuthCookie) &&
|
|
@@ -6299,23 +6400,23 @@
|
|
|
6299
6400
|
yield this.loginZaloV3();
|
|
6300
6401
|
}
|
|
6301
6402
|
if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
|
|
6302
|
-
throw apiResponse.error.loginFailed();
|
|
6403
|
+
throw apiResponse.error.loginFailed('Invalid authorization code');
|
|
6303
6404
|
}
|
|
6304
6405
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
6305
6406
|
}
|
|
6306
|
-
throw apiResponse.error.loginFailed();
|
|
6407
|
+
throw apiResponse.error.loginFailed('Zalo app has not been activated');
|
|
6307
6408
|
});
|
|
6308
6409
|
}
|
|
6309
6410
|
loginZaloV3() {
|
|
6310
6411
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6311
|
-
return yield fetch(`${APIS.GET_ACCESS_TOKEN_V3}?app_id=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f")}&redirect_uri=${MINI_APP_INTERNAL_LINK}/${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appId, "f")}/&code=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zOAuth, "f")}&isSDK=
|
|
6412
|
+
return yield fetch(`${APIS.GET_ACCESS_TOKEN_V3}?app_id=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f")}&redirect_uri=${MINI_APP_INTERNAL_LINK}/${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appId, "f")}/&code=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zOAuth, "f")}&isSDK=true`).then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
6312
6413
|
let resData = yield response.json();
|
|
6313
6414
|
if (resData.access_token) {
|
|
6314
6415
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, resData.access_token, "f");
|
|
6315
6416
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6316
6417
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6317
6418
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6318
|
-
this.
|
|
6419
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6319
6420
|
window.ZJSBridge.setZAccSession &&
|
|
6320
6421
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6321
6422
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6352,7 +6453,7 @@
|
|
|
6352
6453
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6353
6454
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6354
6455
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6355
|
-
this.
|
|
6456
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6356
6457
|
window.ZJSBridge.setZAccSession &&
|
|
6357
6458
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6358
6459
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6373,7 +6474,7 @@
|
|
|
6373
6474
|
});
|
|
6374
6475
|
}
|
|
6375
6476
|
}
|
|
6376
|
-
_ZaloMiniProgramSDKService_zAppId = new WeakMap(), _ZaloMiniProgramSDKService_appId = new WeakMap(), _ZaloMiniProgramSDKService_appConfig = new WeakMap(), _ZaloMiniProgramSDKService_zOAuth = new WeakMap(), _ZaloMiniProgramSDKService_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDKService_accessToken = new WeakMap(), _ZaloMiniProgramSDKService_refreshToken = new WeakMap(), _ZaloMiniProgramSDKService_cache = new WeakMap(),
|
|
6477
|
+
_ZaloMiniProgramSDKService_zAppId = new WeakMap(), _ZaloMiniProgramSDKService_appId = new WeakMap(), _ZaloMiniProgramSDKService_appConfig = new WeakMap(), _ZaloMiniProgramSDKService_zOAuth = new WeakMap(), _ZaloMiniProgramSDKService_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDKService_accessToken = new WeakMap(), _ZaloMiniProgramSDKService_refreshToken = new WeakMap(), _ZaloMiniProgramSDKService_cache = new WeakMap(), _ZaloMiniProgramSDKService_bridge = new WeakMap(), _ZaloMiniProgramSDKService_prevGetTokenTimestamp = new WeakMap(), _ZaloMiniProgramSDKService_tokenExpiresIn = new WeakMap(), _ZaloMiniProgramSDKService_deviceId = new WeakMap(), _ZaloMiniProgramSDKService_actionBarConfig = new WeakMap(), _ZaloMiniProgramSDKService_getActionsSupported = new WeakMap();
|
|
6377
6478
|
|
|
6378
6479
|
var _MockSDKService_appId, _MockSDKService_appConfig, _MockSDKService_zOAuth, _MockSDKService_accessToken, _MockSDKService_cache, _MockSDKService_loggedId;
|
|
6379
6480
|
class MockSDKService {
|
|
@@ -6749,90 +6850,175 @@
|
|
|
6749
6850
|
.replace(/\s/gi, '')
|
|
6750
6851
|
.split(',');
|
|
6751
6852
|
}
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6853
|
+
/**
|
|
6854
|
+
* Copies all metadata from one object to another.
|
|
6855
|
+
* Useful for overwriting function definition in
|
|
6856
|
+
* decorators while keeping all previously
|
|
6857
|
+
* attached metadata
|
|
6858
|
+
*
|
|
6859
|
+
* @param from object to copy metadata from
|
|
6860
|
+
* @param to object to copy metadata to
|
|
6861
|
+
*/
|
|
6862
|
+
function copyMetadata(from, to) {
|
|
6863
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
6864
|
+
metadataKeys.map((key) => {
|
|
6865
|
+
const value = Reflect.getMetadata(key, from);
|
|
6866
|
+
Reflect.defineMetadata(key, value, to);
|
|
6867
|
+
});
|
|
6868
|
+
}
|
|
6869
|
+
/**
|
|
6870
|
+
* Apply the given decorator to all class methods
|
|
6871
|
+
*
|
|
6872
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
6873
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
6874
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
6875
|
+
*/
|
|
6876
|
+
const DecorateAll = (decorator, options = {}) => {
|
|
6877
|
+
return (target) => {
|
|
6878
|
+
var _a;
|
|
6879
|
+
let descriptors = Object.getOwnPropertyDescriptors(target.prototype);
|
|
6880
|
+
if (options.deep) {
|
|
6881
|
+
let base = Object.getPrototypeOf(target);
|
|
6882
|
+
while (base.prototype) {
|
|
6883
|
+
const baseDescriptors = Object.getOwnPropertyDescriptors(base.prototype);
|
|
6884
|
+
descriptors = Object.assign(Object.assign({}, baseDescriptors), descriptors);
|
|
6885
|
+
base = Object.getPrototypeOf(base);
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6888
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
6889
|
+
const isMethod = typeof descriptor.value == 'function' && propName != 'constructor';
|
|
6890
|
+
if ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(propName))
|
|
6891
|
+
continue;
|
|
6892
|
+
if (options.excludePrefix && propName.startsWith(options.excludePrefix))
|
|
6893
|
+
continue;
|
|
6894
|
+
if (!isMethod)
|
|
6895
|
+
continue;
|
|
6896
|
+
const originalMethod = descriptor.value;
|
|
6897
|
+
decorator(target, propName, descriptor);
|
|
6898
|
+
if (originalMethod != descriptor.value) {
|
|
6899
|
+
copyMetadata(originalMethod, descriptor.value);
|
|
6900
|
+
}
|
|
6901
|
+
Object.defineProperty(target.prototype, propName, descriptor);
|
|
6902
|
+
}
|
|
6903
|
+
};
|
|
6904
|
+
};
|
|
6905
|
+
const centralizedFunctionHandler = (target, propertyName, descriptor) => {
|
|
6906
|
+
const fn = descriptor.value;
|
|
6907
|
+
const argsName = getFnParamNames(fn);
|
|
6908
|
+
descriptor.value = function (...args) {
|
|
6909
|
+
try {
|
|
6910
|
+
// begin validation
|
|
6911
|
+
const requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target.prototype, propertyName);
|
|
6912
|
+
const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target.prototype, propertyName);
|
|
6913
|
+
if (checkTypeParameters) {
|
|
6914
|
+
checkTypeParameters.forEach((parameter) => {
|
|
6915
|
+
const { parameterIndex, type, properties, defaultValue } = parameter;
|
|
6916
|
+
let argument = args[parameterIndex];
|
|
6917
|
+
let argumentName = argsName[parameterIndex];
|
|
6918
|
+
const parameterType = typeof argument;
|
|
6919
|
+
if (!_.isUndefined(argument)) {
|
|
6920
|
+
if (!isType(argument, type)) {
|
|
6921
|
+
throw apiResponse.error.wrongTypeParam(argumentName, type, Array.isArray(argument)
|
|
6922
|
+
? 'array'
|
|
6923
|
+
: argument === null
|
|
6924
|
+
? 'null'
|
|
6925
|
+
: parameterType);
|
|
6926
|
+
}
|
|
6927
|
+
if (type === 'object') {
|
|
6928
|
+
Object.entries(properties).forEach(([propKey, propType]) => {
|
|
6929
|
+
const key = propKey.split('?')[0];
|
|
6930
|
+
const propValue = _.get(argument, key);
|
|
6931
|
+
if (!_.isUndefined(propValue) && !_.isNull(propValue)) {
|
|
6932
|
+
if (_.isFunction(propType)) {
|
|
6933
|
+
const res = propType(propValue);
|
|
6934
|
+
if (res && res.error) {
|
|
6935
|
+
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
6936
|
+
}
|
|
6937
|
+
}
|
|
6938
|
+
}
|
|
6939
|
+
else if (!propKey.includes('?')) {
|
|
6940
|
+
throw apiResponse.error.missingParam(propKey);
|
|
6941
|
+
}
|
|
6942
|
+
else if (!_.get(argument, key.split('.')[0]) &&
|
|
6943
|
+
defaultValue &&
|
|
6944
|
+
!_.isUndefined(_.get(defaultValue, key))) {
|
|
6945
|
+
_.set(args[parameterIndex], key, _.get(defaultValue, key));
|
|
6946
|
+
}
|
|
6947
|
+
});
|
|
6948
|
+
}
|
|
6949
|
+
}
|
|
6950
|
+
});
|
|
6951
|
+
}
|
|
6952
|
+
if (requiredParameters) {
|
|
6953
|
+
requiredParameters.forEach((parameter) => {
|
|
6954
|
+
const { parameterIndex, option, fields } = parameter;
|
|
6955
|
+
const argument = args[parameterIndex];
|
|
6956
|
+
const condition = option === null || option === void 0 ? void 0 : option.if;
|
|
6957
|
+
const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
|
|
6958
|
+
let isMeetCondition = true;
|
|
6959
|
+
if (condition) {
|
|
6960
|
+
isMeetCondition = Object.keys(condition).every((key) => _.get(argument, key) === condition[key]);
|
|
6771
6961
|
}
|
|
6772
|
-
if (
|
|
6773
|
-
|
|
6774
|
-
const
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
if (res && res.error) {
|
|
6780
|
-
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
6962
|
+
if (isMeetCondition) {
|
|
6963
|
+
fields.forEach((item) => {
|
|
6964
|
+
const isInValidField = (field) => {
|
|
6965
|
+
let isInValid = false;
|
|
6966
|
+
if (_.isEmpty(_.get(argument, field))) {
|
|
6967
|
+
if (!_.isUndefined(_.get(defaultValue, field))) {
|
|
6968
|
+
_.set(args[parameterIndex], field, _.get(defaultValue, field));
|
|
6781
6969
|
}
|
|
6970
|
+
isInValid = true;
|
|
6782
6971
|
}
|
|
6972
|
+
return isInValid;
|
|
6973
|
+
};
|
|
6974
|
+
if (Array.isArray(item) &&
|
|
6975
|
+
item.length > 0 &&
|
|
6976
|
+
item.every(isInValidField)) {
|
|
6977
|
+
throw apiResponse.error.missingParam(item.join(' or '));
|
|
6783
6978
|
}
|
|
6784
|
-
else if (
|
|
6785
|
-
throw apiResponse.error.missingParam(
|
|
6786
|
-
}
|
|
6787
|
-
else if (_.isObject(_.get(argument, key.split('.')[0])) &&
|
|
6788
|
-
defaultValue &&
|
|
6789
|
-
!_.isUndefined(_.get(defaultValue, key))) {
|
|
6790
|
-
_.set(arguments[parameterIndex], key, _.get(defaultValue, key));
|
|
6979
|
+
else if (_.isString(item) && isInValidField(item)) {
|
|
6980
|
+
throw apiResponse.error.missingParam(item);
|
|
6791
6981
|
}
|
|
6792
6982
|
});
|
|
6793
6983
|
}
|
|
6794
|
-
}
|
|
6795
|
-
}
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
const {
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
}
|
|
6815
|
-
isInValid = true;
|
|
6816
|
-
}
|
|
6817
|
-
return isInValid;
|
|
6818
|
-
};
|
|
6819
|
-
if (Array.isArray(item) && item.length > 0 && item.every(isInValidField)) {
|
|
6820
|
-
throw apiResponse.error.missingParam(item.join(' or '));
|
|
6984
|
+
});
|
|
6985
|
+
}
|
|
6986
|
+
// end validation
|
|
6987
|
+
const res = fn.call(this, ...args);
|
|
6988
|
+
if (_.isPromise(res)) {
|
|
6989
|
+
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
6990
|
+
return new Promise((resolve, reject) => {
|
|
6991
|
+
res
|
|
6992
|
+
.then((data) => {
|
|
6993
|
+
if (!_.isNull(success) && _.isFunction(success)) {
|
|
6994
|
+
success.call(null, data, this);
|
|
6995
|
+
}
|
|
6996
|
+
else {
|
|
6997
|
+
resolve(res);
|
|
6998
|
+
}
|
|
6999
|
+
})
|
|
7000
|
+
.catch((error) => {
|
|
7001
|
+
const errorParsed = errorHandler(error, propertyName);
|
|
7002
|
+
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
7003
|
+
fail.call(null, errorParsed, this);
|
|
6821
7004
|
}
|
|
6822
|
-
else
|
|
6823
|
-
|
|
7005
|
+
else {
|
|
7006
|
+
reject(errorParsed);
|
|
6824
7007
|
}
|
|
6825
7008
|
});
|
|
6826
|
-
}
|
|
6827
|
-
}
|
|
7009
|
+
});
|
|
7010
|
+
}
|
|
7011
|
+
return res;
|
|
7012
|
+
}
|
|
7013
|
+
catch (error) {
|
|
7014
|
+
throw errorHandler(error, propertyName);
|
|
6828
7015
|
}
|
|
6829
|
-
return method.apply(this, arguments);
|
|
6830
7016
|
};
|
|
6831
7017
|
return descriptor;
|
|
6832
7018
|
};
|
|
6833
7019
|
|
|
6834
7020
|
var _SDKCreator_sdkService;
|
|
6835
|
-
class SDKCreator {
|
|
7021
|
+
let SDKCreator = class SDKCreator {
|
|
6836
7022
|
constructor() {
|
|
6837
7023
|
this.events = ZMPEEmitter.getInstance();
|
|
6838
7024
|
_SDKCreator_sdkService.set(this, void 0);
|
|
@@ -6893,7 +7079,7 @@
|
|
|
6893
7079
|
}
|
|
6894
7080
|
setNavigationBarTitle(object) {
|
|
6895
7081
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6896
|
-
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
7082
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
6897
7083
|
});
|
|
6898
7084
|
}
|
|
6899
7085
|
setNavigationBarColor(object) {
|
|
@@ -7163,6 +7349,7 @@
|
|
|
7163
7349
|
}
|
|
7164
7350
|
vibrate(object) {
|
|
7165
7351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7352
|
+
console.log(object);
|
|
7166
7353
|
yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
|
|
7167
7354
|
});
|
|
7168
7355
|
}
|
|
@@ -7318,33 +7505,14 @@
|
|
|
7318
7505
|
getDeviceId() {
|
|
7319
7506
|
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
|
|
7320
7507
|
}
|
|
7321
|
-
}
|
|
7508
|
+
};
|
|
7322
7509
|
_SDKCreator_sdkService = new WeakMap();
|
|
7323
7510
|
__decorate([
|
|
7324
|
-
handleError
|
|
7325
|
-
], SDKCreator.prototype, "login", null);
|
|
7326
|
-
__decorate([
|
|
7327
|
-
handleErrorSync
|
|
7328
|
-
], SDKCreator.prototype, "getLoginStatus", null);
|
|
7329
|
-
__decorate([
|
|
7330
|
-
handleError
|
|
7331
|
-
], SDKCreator.prototype, "getAccessToken", null);
|
|
7332
|
-
__decorate([
|
|
7333
|
-
handleErrorSync
|
|
7334
|
-
], SDKCreator.prototype, "getVersion", null);
|
|
7335
|
-
__decorate([
|
|
7336
|
-
handleErrorSync
|
|
7337
|
-
], SDKCreator.prototype, "getSystemInfo", null);
|
|
7338
|
-
__decorate([
|
|
7339
|
-
handleError,
|
|
7340
|
-
validate,
|
|
7341
7511
|
__param(0, checkType('object', {
|
|
7342
7512
|
title: checkData('string')
|
|
7343
7513
|
}))
|
|
7344
7514
|
], SDKCreator.prototype, "setNavigationBarTitle", null);
|
|
7345
7515
|
__decorate([
|
|
7346
|
-
handleError,
|
|
7347
|
-
validate,
|
|
7348
7516
|
__param(0, checkType('object', {
|
|
7349
7517
|
color: checkData('string'),
|
|
7350
7518
|
'textColor?': checkData('string', { values: ['white', 'black'] }),
|
|
@@ -7352,57 +7520,37 @@
|
|
|
7352
7520
|
}))
|
|
7353
7521
|
], SDKCreator.prototype, "setNavigationBarColor", null);
|
|
7354
7522
|
__decorate([
|
|
7355
|
-
handleError,
|
|
7356
|
-
validate,
|
|
7357
7523
|
__param(0, checkType('object', {
|
|
7358
7524
|
backgroundColor: checkData('string'),
|
|
7359
7525
|
'textColor?': checkData('string', { values: ['white', 'black'] })
|
|
7360
7526
|
}))
|
|
7361
7527
|
], SDKCreator.prototype, "setBackgroundColor", null);
|
|
7362
7528
|
__decorate([
|
|
7363
|
-
handleError,
|
|
7364
|
-
validate,
|
|
7365
7529
|
__param(0, checkType('object', {
|
|
7366
7530
|
type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
|
|
7367
7531
|
}))
|
|
7368
7532
|
], SDKCreator.prototype, "setNavigationBarLeftButton", null);
|
|
7369
7533
|
__decorate([
|
|
7370
|
-
handleError,
|
|
7371
|
-
validate,
|
|
7372
7534
|
__param(0, checkType('object', {
|
|
7373
7535
|
rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
|
|
7374
7536
|
}))
|
|
7375
7537
|
], SDKCreator.prototype, "setDeviceOrientation", null);
|
|
7376
7538
|
__decorate([
|
|
7377
|
-
handleError,
|
|
7378
|
-
validate,
|
|
7379
7539
|
__param(0, checkType('object', {
|
|
7380
7540
|
data: checkData('object')
|
|
7381
7541
|
}))
|
|
7382
7542
|
], SDKCreator.prototype, "setStorage", null);
|
|
7383
7543
|
__decorate([
|
|
7384
|
-
handleError,
|
|
7385
|
-
validate,
|
|
7386
7544
|
__param(0, checkType('object', {
|
|
7387
7545
|
keys: checkData('array<string>')
|
|
7388
7546
|
}))
|
|
7389
7547
|
], SDKCreator.prototype, "getStorage", null);
|
|
7390
7548
|
__decorate([
|
|
7391
|
-
handleError
|
|
7392
|
-
], SDKCreator.prototype, "getStorageInfo", null);
|
|
7393
|
-
__decorate([
|
|
7394
|
-
handleError,
|
|
7395
|
-
validate,
|
|
7396
7549
|
__param(0, checkType('object', {
|
|
7397
7550
|
keys: checkData('array<string>')
|
|
7398
7551
|
}))
|
|
7399
7552
|
], SDKCreator.prototype, "removeStorage", null);
|
|
7400
7553
|
__decorate([
|
|
7401
|
-
handleError
|
|
7402
|
-
], SDKCreator.prototype, "clearStorage", null);
|
|
7403
|
-
__decorate([
|
|
7404
|
-
handleError,
|
|
7405
|
-
validate,
|
|
7406
7554
|
__param(0, checkType('object', {
|
|
7407
7555
|
'avatarType?': checkData('string', {
|
|
7408
7556
|
values: ['small', 'normal', 'large']
|
|
@@ -7410,67 +7558,12 @@
|
|
|
7410
7558
|
}))
|
|
7411
7559
|
], SDKCreator.prototype, "getUserInfo", null);
|
|
7412
7560
|
__decorate([
|
|
7413
|
-
handleError
|
|
7414
|
-
], SDKCreator.prototype, "getNetworkType", null);
|
|
7415
|
-
__decorate([
|
|
7416
|
-
handleError
|
|
7417
|
-
], SDKCreator.prototype, "onNetworkStatusChange", null);
|
|
7418
|
-
__decorate([
|
|
7419
|
-
handleError
|
|
7420
|
-
], SDKCreator.prototype, "startBeaconDiscovery", null);
|
|
7421
|
-
__decorate([
|
|
7422
|
-
handleError
|
|
7423
|
-
], SDKCreator.prototype, "stopBeaconDiscovery", null);
|
|
7424
|
-
__decorate([
|
|
7425
|
-
handleError
|
|
7426
|
-
], SDKCreator.prototype, "getBeacons", null);
|
|
7427
|
-
__decorate([
|
|
7428
|
-
handleError
|
|
7429
|
-
], SDKCreator.prototype, "closeApp", null);
|
|
7430
|
-
__decorate([
|
|
7431
|
-
handleError
|
|
7432
|
-
], SDKCreator.prototype, "getLocation", null);
|
|
7433
|
-
__decorate([
|
|
7434
|
-
handleError
|
|
7435
|
-
], SDKCreator.prototype, "stopBluetoothDevicesDiscovery", null);
|
|
7436
|
-
__decorate([
|
|
7437
|
-
handleError
|
|
7438
|
-
], SDKCreator.prototype, "startBluetoothDevicesDiscovery", null);
|
|
7439
|
-
__decorate([
|
|
7440
|
-
handleError
|
|
7441
|
-
], SDKCreator.prototype, "openBluetoothAdapter", null);
|
|
7442
|
-
__decorate([
|
|
7443
|
-
handleError
|
|
7444
|
-
], SDKCreator.prototype, "onBluetoothDeviceFound", null);
|
|
7445
|
-
__decorate([
|
|
7446
|
-
handleError
|
|
7447
|
-
], SDKCreator.prototype, "onBluetoothAdapterStateChange", null);
|
|
7448
|
-
__decorate([
|
|
7449
|
-
handleError
|
|
7450
|
-
], SDKCreator.prototype, "getConnectedBluetoothDevices", null);
|
|
7451
|
-
__decorate([
|
|
7452
|
-
handleError
|
|
7453
|
-
], SDKCreator.prototype, "getBluetoothDevices", null);
|
|
7454
|
-
__decorate([
|
|
7455
|
-
handleError
|
|
7456
|
-
], SDKCreator.prototype, "getBluetoothAdapterState", null);
|
|
7457
|
-
__decorate([
|
|
7458
|
-
handleError
|
|
7459
|
-
], SDKCreator.prototype, "closeBluetoothAdapter", null);
|
|
7460
|
-
__decorate([
|
|
7461
|
-
handleError
|
|
7462
|
-
], SDKCreator.prototype, "scanQRCode", null);
|
|
7463
|
-
__decorate([
|
|
7464
|
-
handleError,
|
|
7465
|
-
validate,
|
|
7466
7561
|
__param(0, checkType('object', {
|
|
7467
7562
|
type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
|
|
7468
7563
|
id: checkData('string')
|
|
7469
7564
|
}))
|
|
7470
7565
|
], SDKCreator.prototype, "openProfile", null);
|
|
7471
7566
|
__decorate([
|
|
7472
|
-
handleError,
|
|
7473
|
-
validate,
|
|
7474
7567
|
__param(0, checkType('object', {
|
|
7475
7568
|
type: checkData('string', { values: ['user', 'oa'] }),
|
|
7476
7569
|
id: checkData('string'),
|
|
@@ -7478,8 +7571,6 @@
|
|
|
7478
7571
|
}))
|
|
7479
7572
|
], SDKCreator.prototype, "openChat", null);
|
|
7480
7573
|
__decorate([
|
|
7481
|
-
handleError,
|
|
7482
|
-
validate,
|
|
7483
7574
|
__param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
|
|
7484
7575
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
7485
7576
|
__param(0, required(['data.id'], { if: { type: 'profile' } })),
|
|
@@ -7497,23 +7588,17 @@
|
|
|
7497
7588
|
}))
|
|
7498
7589
|
], SDKCreator.prototype, "openPostFeed", null);
|
|
7499
7590
|
__decorate([
|
|
7500
|
-
handleError,
|
|
7501
|
-
validate,
|
|
7502
7591
|
__param(0, checkType('object', {
|
|
7503
7592
|
id: checkData('string'),
|
|
7504
7593
|
'showDialogConfirm?': checkData('boolean')
|
|
7505
7594
|
}))
|
|
7506
7595
|
], SDKCreator.prototype, "followOA", null);
|
|
7507
7596
|
__decorate([
|
|
7508
|
-
handleError,
|
|
7509
|
-
validate,
|
|
7510
7597
|
__param(0, checkType('object', {
|
|
7511
7598
|
id: checkData('string')
|
|
7512
7599
|
}))
|
|
7513
7600
|
], SDKCreator.prototype, "unfollowOA", null);
|
|
7514
7601
|
__decorate([
|
|
7515
|
-
handleError,
|
|
7516
|
-
validate,
|
|
7517
7602
|
__param(0, required([['data.imageUrl', 'data.imageUrls']], { if: { type: 'image' } })),
|
|
7518
7603
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
7519
7604
|
__param(0, required(['data.id'], { if: { type: 'oa' } })),
|
|
@@ -7552,14 +7637,6 @@
|
|
|
7552
7637
|
}))
|
|
7553
7638
|
], SDKCreator.prototype, "openShareSheet", null);
|
|
7554
7639
|
__decorate([
|
|
7555
|
-
handleError
|
|
7556
|
-
], SDKCreator.prototype, "requestCameraPermission", null);
|
|
7557
|
-
__decorate([
|
|
7558
|
-
handleError
|
|
7559
|
-
], SDKCreator.prototype, "createShortcut", null);
|
|
7560
|
-
__decorate([
|
|
7561
|
-
handleError,
|
|
7562
|
-
validate,
|
|
7563
7640
|
__param(0, checkType('object', {
|
|
7564
7641
|
secretData: checkData('string'),
|
|
7565
7642
|
'ui?': checkData('object'),
|
|
@@ -7577,44 +7654,28 @@
|
|
|
7577
7654
|
}))
|
|
7578
7655
|
], SDKCreator.prototype, "openBioAuthentication", null);
|
|
7579
7656
|
__decorate([
|
|
7580
|
-
handleError
|
|
7581
|
-
], SDKCreator.prototype, "checkStateBioAuthentication", null);
|
|
7582
|
-
__decorate([
|
|
7583
|
-
handleError,
|
|
7584
|
-
validate,
|
|
7585
7657
|
__param(0, checkType('object', {
|
|
7586
7658
|
toUserId: checkData('string'),
|
|
7587
7659
|
'title?': checkData('string')
|
|
7588
7660
|
}))
|
|
7589
7661
|
], SDKCreator.prototype, "sendLocation", null);
|
|
7590
7662
|
__decorate([
|
|
7591
|
-
handleError,
|
|
7592
|
-
validate,
|
|
7593
7663
|
__param(0, checkType('object', {
|
|
7594
7664
|
message: checkData('string')
|
|
7595
7665
|
}))
|
|
7596
7666
|
], SDKCreator.prototype, "showToast", null);
|
|
7597
7667
|
__decorate([
|
|
7598
|
-
handleError
|
|
7599
|
-
], SDKCreator.prototype, "hideKeyboard", null);
|
|
7600
|
-
__decorate([
|
|
7601
|
-
handleError,
|
|
7602
|
-
validate,
|
|
7603
7668
|
__param(0, checkType('object', {
|
|
7604
7669
|
phoneNumber: checkData('string')
|
|
7605
7670
|
}))
|
|
7606
7671
|
], SDKCreator.prototype, "openPhone", null);
|
|
7607
7672
|
__decorate([
|
|
7608
|
-
handleError,
|
|
7609
|
-
validate,
|
|
7610
7673
|
__param(0, checkType('object', {
|
|
7611
7674
|
content: checkData('string'),
|
|
7612
7675
|
phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
|
|
7613
7676
|
}))
|
|
7614
7677
|
], SDKCreator.prototype, "openSMS", null);
|
|
7615
7678
|
__decorate([
|
|
7616
|
-
handleError,
|
|
7617
|
-
validate,
|
|
7618
7679
|
__param(0, checkType('object', {
|
|
7619
7680
|
id: checkData('string'),
|
|
7620
7681
|
'displayName?': checkData('string')
|
|
@@ -7623,35 +7684,24 @@
|
|
|
7623
7684
|
}))
|
|
7624
7685
|
], SDKCreator.prototype, "viewOAQr", null);
|
|
7625
7686
|
__decorate([
|
|
7626
|
-
handleError
|
|
7627
|
-
], SDKCreator.prototype, "keepScreen", null);
|
|
7628
|
-
__decorate([
|
|
7629
|
-
handleError,
|
|
7630
|
-
validate,
|
|
7631
7687
|
__param(0, checkType('object', {
|
|
7632
7688
|
'imageBase64Data?': checkData('string'),
|
|
7633
7689
|
'imageUrl?': checkData('url')
|
|
7634
7690
|
}))
|
|
7635
7691
|
], SDKCreator.prototype, "saveImageToGallery", null);
|
|
7636
7692
|
__decorate([
|
|
7637
|
-
handleError,
|
|
7638
|
-
validate,
|
|
7639
7693
|
__param(0, checkType('object', {
|
|
7640
7694
|
'imageBase64Data?': checkData('string'),
|
|
7641
7695
|
'imageUrl?': checkData('url')
|
|
7642
7696
|
}))
|
|
7643
7697
|
], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
|
|
7644
7698
|
__decorate([
|
|
7645
|
-
handleError,
|
|
7646
|
-
validate,
|
|
7647
7699
|
__param(0, checkType('object', {
|
|
7648
7700
|
appId: checkData('string'),
|
|
7649
7701
|
'params?': checkData('object')
|
|
7650
7702
|
}))
|
|
7651
7703
|
], SDKCreator.prototype, "openMiniApp", null);
|
|
7652
7704
|
__decorate([
|
|
7653
|
-
handleError,
|
|
7654
|
-
validate,
|
|
7655
7705
|
__param(0, checkType('object', {
|
|
7656
7706
|
'type?': checkData('string', { values: ['oneShot'] }),
|
|
7657
7707
|
'milliseconds?': checkData('number')
|
|
@@ -7661,30 +7711,11 @@
|
|
|
7661
7711
|
}))
|
|
7662
7712
|
], SDKCreator.prototype, "vibrate", null);
|
|
7663
7713
|
__decorate([
|
|
7664
|
-
handleError,
|
|
7665
|
-
validate,
|
|
7666
7714
|
__param(0, checkType('object', {
|
|
7667
7715
|
url: checkData('url')
|
|
7668
7716
|
}))
|
|
7669
7717
|
], SDKCreator.prototype, "openWebview", null);
|
|
7670
7718
|
__decorate([
|
|
7671
|
-
handleErrorSync
|
|
7672
|
-
], SDKCreator.prototype, "getRouteParams", null);
|
|
7673
|
-
__decorate([
|
|
7674
|
-
handleError
|
|
7675
|
-
], SDKCreator.prototype, "getAppInfo", null);
|
|
7676
|
-
__decorate([
|
|
7677
|
-
handleError
|
|
7678
|
-
], SDKCreator.prototype, "sendDataToPreviousMiniApp", null);
|
|
7679
|
-
__decorate([
|
|
7680
|
-
handleError
|
|
7681
|
-
], SDKCreator.prototype, "onCallbackData", null);
|
|
7682
|
-
__decorate([
|
|
7683
|
-
handleError
|
|
7684
|
-
], SDKCreator.prototype, "getPhoneNumber", null);
|
|
7685
|
-
__decorate([
|
|
7686
|
-
handleError,
|
|
7687
|
-
validate,
|
|
7688
7719
|
__param(0, checkType('object', {
|
|
7689
7720
|
'maxProfile?': checkData('number', { min: 1, max: 10 })
|
|
7690
7721
|
}, {
|
|
@@ -7692,8 +7723,6 @@
|
|
|
7692
7723
|
}))
|
|
7693
7724
|
], SDKCreator.prototype, "openProfilePicker", null);
|
|
7694
7725
|
__decorate([
|
|
7695
|
-
handleError,
|
|
7696
|
-
validate,
|
|
7697
7726
|
__param(0, required(['SSID'])),
|
|
7698
7727
|
__param(0, checkType('object', {
|
|
7699
7728
|
SSID: checkData('string'),
|
|
@@ -7702,8 +7731,6 @@
|
|
|
7702
7731
|
}))
|
|
7703
7732
|
], SDKCreator.prototype, "connectWifi", null);
|
|
7704
7733
|
__decorate([
|
|
7705
|
-
handleError,
|
|
7706
|
-
validate,
|
|
7707
7734
|
__param(0, checkType('object', {
|
|
7708
7735
|
type: checkData('string', {
|
|
7709
7736
|
values: ['photo', 'video', 'file']
|
|
@@ -7718,8 +7745,6 @@
|
|
|
7718
7745
|
}))
|
|
7719
7746
|
], SDKCreator.prototype, "openMediaPicker", null);
|
|
7720
7747
|
__decorate([
|
|
7721
|
-
handleError,
|
|
7722
|
-
validate,
|
|
7723
7748
|
__param(0, checkType('object', {
|
|
7724
7749
|
title: checkData('string', { maxLength: 100 }),
|
|
7725
7750
|
'thumbnail?': checkData('url'),
|
|
@@ -7729,14 +7754,9 @@
|
|
|
7729
7754
|
description: ''
|
|
7730
7755
|
}))
|
|
7731
7756
|
], SDKCreator.prototype, "getShareableLink", null);
|
|
7732
|
-
__decorate([
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
], SDKCreator.prototype, "closeLoading", null);
|
|
7736
|
-
__decorate([
|
|
7737
|
-
handleError,
|
|
7738
|
-
validate
|
|
7739
|
-
], SDKCreator.prototype, "requestUpdateZalo", null);
|
|
7757
|
+
SDKCreator = __decorate([
|
|
7758
|
+
DecorateAll(centralizedFunctionHandler)
|
|
7759
|
+
], SDKCreator);
|
|
7740
7760
|
class ZaloMiniAppSDKCreator extends SDKCreator {
|
|
7741
7761
|
getServiceInstance() {
|
|
7742
7762
|
return ZaloMiniProgramSDKService.getInstance();
|
|
@@ -7932,7 +7952,7 @@
|
|
|
7932
7952
|
_MockPaymentService_appId = new WeakMap();
|
|
7933
7953
|
|
|
7934
7954
|
var _PaymentCreator_instance, _PaymentCreator_sdk;
|
|
7935
|
-
class PaymentCreator {
|
|
7955
|
+
let PaymentCreator = class PaymentCreator {
|
|
7936
7956
|
constructor(sdk) {
|
|
7937
7957
|
_PaymentCreator_instance.set(this, void 0);
|
|
7938
7958
|
_PaymentCreator_sdk.set(this, void 0);
|
|
@@ -7940,42 +7960,50 @@
|
|
|
7940
7960
|
__classPrivateFieldSet(this, _PaymentCreator_sdk, sdk, "f");
|
|
7941
7961
|
}
|
|
7942
7962
|
/**
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7963
|
+
* Tạo đơn hàng
|
|
7964
|
+
*
|
|
7965
|
+
* @async
|
|
7966
|
+
* @function createOrder
|
|
7967
|
+
* @category Payment
|
|
7968
|
+
* @returns {Promise<CallbackDataType.CreateOrderCallBack>}
|
|
7969
|
+
*/
|
|
7950
7970
|
createOrder(object) {
|
|
7951
7971
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").createOrder(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
7952
7972
|
}
|
|
7953
7973
|
/**
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7974
|
+
* Lấy thông tin transaction
|
|
7975
|
+
*
|
|
7976
|
+
* @async
|
|
7977
|
+
* @function checkTransaction
|
|
7978
|
+
* @category Payment
|
|
7979
|
+
* @returns {Promise<CallbackDataType.CheckTransactionSuccessCallBack>}
|
|
7980
|
+
*/
|
|
7961
7981
|
checkTransaction(object) {
|
|
7962
7982
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").checkTransaction(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
7963
7983
|
}
|
|
7964
|
-
}
|
|
7984
|
+
};
|
|
7965
7985
|
_PaymentCreator_instance = new WeakMap(), _PaymentCreator_sdk = new WeakMap();
|
|
7966
7986
|
__decorate([
|
|
7967
|
-
handleError,
|
|
7968
|
-
validate,
|
|
7969
7987
|
__param(0, checkType('object', {
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
'method?': checkData('string', {
|
|
7988
|
+
amount: checkData(['string', 'number']),
|
|
7989
|
+
desc: checkData('string'),
|
|
7990
|
+
'method?': checkData('string', {
|
|
7991
|
+
values: [
|
|
7992
|
+
'MOMO',
|
|
7993
|
+
'ZALOPAY',
|
|
7994
|
+
'MOMO_SANDBOX',
|
|
7995
|
+
'ZALOPAY_SANDBOX',
|
|
7996
|
+
'CC',
|
|
7997
|
+
'CC_SANDBOX',
|
|
7998
|
+
'ATM',
|
|
7999
|
+
'ATM_SANDBOX'
|
|
8000
|
+
]
|
|
8001
|
+
})
|
|
7973
8002
|
}))
|
|
7974
8003
|
], PaymentCreator.prototype, "createOrder", null);
|
|
7975
|
-
__decorate([
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
], PaymentCreator.prototype, "checkTransaction", null);
|
|
8004
|
+
PaymentCreator = __decorate([
|
|
8005
|
+
DecorateAll(centralizedFunctionHandler)
|
|
8006
|
+
], PaymentCreator);
|
|
7979
8007
|
class ZaloMiniAppPaymentCreator extends PaymentCreator {
|
|
7980
8008
|
getInstance() {
|
|
7981
8009
|
return PaymentService.getInstance();
|