zmp-sdk 2.20.0 → 2.21.1
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 +1340 -1299
- package/dist/index.es.js +1341 -1300
- 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 +95 -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 +2 -7
- 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) {
|
|
@@ -2139,6 +2143,7 @@
|
|
|
2139
2143
|
ShareSheetType[ShareSheetType["link"] = 4] = "link";
|
|
2140
2144
|
ShareSheetType[ShareSheetType["oa"] = 5] = "oa";
|
|
2141
2145
|
ShareSheetType[ShareSheetType["zmp"] = 20] = "zmp";
|
|
2146
|
+
ShareSheetType[ShareSheetType["multi_image"] = 21] = "multi_image";
|
|
2142
2147
|
})(ShareSheetType || (ShareSheetType = {}));
|
|
2143
2148
|
var OrientationType;
|
|
2144
2149
|
(function (OrientationType) {
|
|
@@ -2150,13 +2155,6 @@
|
|
|
2150
2155
|
(function (VibrateType) {
|
|
2151
2156
|
VibrateType[VibrateType["oneShot"] = 0] = "oneShot";
|
|
2152
2157
|
})(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
2158
|
var Events;
|
|
2161
2159
|
(function (Events) {
|
|
2162
2160
|
Events["AppPaused"] = "h5.event.paused";
|
|
@@ -2245,7 +2243,7 @@
|
|
|
2245
2243
|
ZACC_SESSiON: `h5.zdn.vn_zacc_session`,
|
|
2246
2244
|
JS_TOKEN: `h5.zdn.vn_zlink3rd`,
|
|
2247
2245
|
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf`,
|
|
2248
|
-
DEVICE_ID: `h5.zdn.vn_deviceID
|
|
2246
|
+
DEVICE_ID: `h5.zdn.vn_deviceID`
|
|
2249
2247
|
};
|
|
2250
2248
|
const APIS = {
|
|
2251
2249
|
GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
|
|
@@ -2253,6 +2251,8 @@
|
|
|
2253
2251
|
GET_ACCESS_TOKEN_V3: 'https://oauth.zaloapp.com/v3/access_token',
|
|
2254
2252
|
GET_LIST_USER_INFO: 'https://graph.zalo.me/v2.0/me/friends/list',
|
|
2255
2253
|
CREATE_ORDER: 'https://payment-mini.zalo.me/api/order/create',
|
|
2254
|
+
GET_APP_INFO: 'https://h5.zalo.me/apps/get-info',
|
|
2255
|
+
SEND_ACTION_LOG: 'https://h5.zalo.me/log/async'
|
|
2256
2256
|
};
|
|
2257
2257
|
const STORAGE_LIMIT = 5 * MB;
|
|
2258
2258
|
const NETWORK_TYPE = (isAndroid) => ({
|
|
@@ -2263,6 +2263,78 @@
|
|
|
2263
2263
|
'4G': isAndroid ? 13 : 2
|
|
2264
2264
|
});
|
|
2265
2265
|
const MEDIA_PICKER_LIMIT = 1 * MB;
|
|
2266
|
+
const RESPONSE_CODE = {
|
|
2267
|
+
SUCCESS: 0,
|
|
2268
|
+
UNKNOWN_ERROR: -2000,
|
|
2269
|
+
BAD_REQUEST: -1400,
|
|
2270
|
+
INTERNAL_SERVER_ERROR: -1500,
|
|
2271
|
+
UNAUTHORIZED: -1401,
|
|
2272
|
+
FORBIDDEN: -1403,
|
|
2273
|
+
CLIENT_NOT_SUPPORT: -1404,
|
|
2274
|
+
TIME_OUT: -1408,
|
|
2275
|
+
DECODE_FAILED: -2001,
|
|
2276
|
+
USER_DENIED: -2002,
|
|
2277
|
+
USER_CANCEL: -2003,
|
|
2278
|
+
// Media picker
|
|
2279
|
+
MEDIA_PICKER_FAIL: -2004,
|
|
2280
|
+
// Save image to gallery
|
|
2281
|
+
SAVE_IMAGE_FAIL: -2005
|
|
2282
|
+
};
|
|
2283
|
+
const MESSAGES = {
|
|
2284
|
+
SUCCESS: 'Success',
|
|
2285
|
+
UNKNOWN_ERROR: 'Unknown error. Please try again later.',
|
|
2286
|
+
TIME_OUT: 'Request timeout. Please try again later.',
|
|
2287
|
+
LOGIN_REQUIRED: 'Please login (https://miniapp.zalo.me/docs/api/login) before to call this api',
|
|
2288
|
+
LOGIN_FAILED: 'Login failed',
|
|
2289
|
+
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2290
|
+
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2291
|
+
DECODE_FAILED: 'Can not decode id. Please check your params again.',
|
|
2292
|
+
INVALID_PARAM: 'Invalid parameter',
|
|
2293
|
+
USER_DENIED: 'User denied',
|
|
2294
|
+
USER_CANCEL: 'User cancel',
|
|
2295
|
+
// Media picker
|
|
2296
|
+
MEDIA_PICKER_FAIL: 'Unable to pick media',
|
|
2297
|
+
// Save image to gallery
|
|
2298
|
+
SAVE_IMAGE_FAIL: 'Unable to save image'
|
|
2299
|
+
};
|
|
2300
|
+
const RESPONSE = {
|
|
2301
|
+
SUCCESS: {
|
|
2302
|
+
code: RESPONSE_CODE.SUCCESS,
|
|
2303
|
+
message: MESSAGES.SUCCESS
|
|
2304
|
+
},
|
|
2305
|
+
UNKNOWN_ERROR: {
|
|
2306
|
+
code: RESPONSE_CODE.UNKNOWN_ERROR,
|
|
2307
|
+
message: MESSAGES.UNKNOWN_ERROR
|
|
2308
|
+
},
|
|
2309
|
+
UNAUTHORIZED: {
|
|
2310
|
+
code: RESPONSE_CODE.UNAUTHORIZED,
|
|
2311
|
+
message: MESSAGES.LOGIN_REQUIRED
|
|
2312
|
+
},
|
|
2313
|
+
FORBIDDEN: {
|
|
2314
|
+
code: RESPONSE_CODE.FORBIDDEN,
|
|
2315
|
+
message: MESSAGES.NOT_PERMISSION
|
|
2316
|
+
},
|
|
2317
|
+
CLIENT_NOT_SUPPORT: {
|
|
2318
|
+
code: RESPONSE_CODE.CLIENT_NOT_SUPPORT,
|
|
2319
|
+
message: MESSAGES.CLIENT_NOT_SUPPORT
|
|
2320
|
+
},
|
|
2321
|
+
DECODE_FAILED: {
|
|
2322
|
+
code: RESPONSE_CODE.DECODE_FAILED,
|
|
2323
|
+
message: MESSAGES.DECODE_FAILED
|
|
2324
|
+
},
|
|
2325
|
+
TIME_OUT: {
|
|
2326
|
+
code: RESPONSE_CODE.TIME_OUT,
|
|
2327
|
+
message: MESSAGES.TIME_OUT
|
|
2328
|
+
},
|
|
2329
|
+
USER_DENIED: {
|
|
2330
|
+
code: RESPONSE_CODE.USER_DENIED,
|
|
2331
|
+
message: MESSAGES.USER_DENIED
|
|
2332
|
+
},
|
|
2333
|
+
USER_CANCEL: {
|
|
2334
|
+
code: RESPONSE_CODE.USER_CANCEL,
|
|
2335
|
+
message: MESSAGES.USER_CANCEL
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2266
2338
|
const ACTION = {
|
|
2267
2339
|
GET_DOWNLOADED_STICKER: {
|
|
2268
2340
|
name: 'action.get.downloaded.sticker',
|
|
@@ -2375,7 +2447,19 @@
|
|
|
2375
2447
|
have_callback: true
|
|
2376
2448
|
},
|
|
2377
2449
|
REQUEST_PERMISSION_CAMERA: {
|
|
2378
|
-
name: 'action.request.permission.camera'
|
|
2450
|
+
name: 'action.request.permission.camera',
|
|
2451
|
+
error_list: {
|
|
2452
|
+
android: {
|
|
2453
|
+
'-2': {
|
|
2454
|
+
map_to: RESPONSE.USER_DENIED
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
iOS: {
|
|
2458
|
+
'-2': {
|
|
2459
|
+
map_to: RESPONSE.USER_DENIED
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2379
2463
|
},
|
|
2380
2464
|
CHANGE_TITLE_HEADER: {
|
|
2381
2465
|
name: 'action.change.title.header',
|
|
@@ -2444,7 +2528,19 @@
|
|
|
2444
2528
|
},
|
|
2445
2529
|
GET_LOCATION: {
|
|
2446
2530
|
name: 'action.get.location',
|
|
2447
|
-
have_callback: true
|
|
2531
|
+
have_callback: true,
|
|
2532
|
+
error_list: {
|
|
2533
|
+
android: {
|
|
2534
|
+
'-1': {
|
|
2535
|
+
map_to: RESPONSE.USER_DENIED
|
|
2536
|
+
}
|
|
2537
|
+
},
|
|
2538
|
+
iOS: {
|
|
2539
|
+
'-1': {
|
|
2540
|
+
map_to: RESPONSE.USER_DENIED
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2448
2544
|
},
|
|
2449
2545
|
QUERY_LOCATION_HIDE: {
|
|
2450
2546
|
name: 'action.query.location.hide',
|
|
@@ -2542,7 +2638,34 @@
|
|
|
2542
2638
|
},
|
|
2543
2639
|
SAVE_IMAGE_GALLERY: {
|
|
2544
2640
|
name: 'action.save.image.gallery',
|
|
2545
|
-
version_live: { iOS: 408 }
|
|
2641
|
+
version_live: { iOS: 408 },
|
|
2642
|
+
error_list: {
|
|
2643
|
+
android: {
|
|
2644
|
+
'-101': {
|
|
2645
|
+
map_to: {
|
|
2646
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2647
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2648
|
+
},
|
|
2649
|
+
need_more_detail: true
|
|
2650
|
+
},
|
|
2651
|
+
'-102': {
|
|
2652
|
+
map_to: {
|
|
2653
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2654
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2655
|
+
},
|
|
2656
|
+
need_more_detail: true
|
|
2657
|
+
}
|
|
2658
|
+
},
|
|
2659
|
+
iOS: {
|
|
2660
|
+
'-10': {
|
|
2661
|
+
map_to: {
|
|
2662
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2663
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2664
|
+
},
|
|
2665
|
+
need_more_detail: true
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2546
2669
|
},
|
|
2547
2670
|
OPEN_MP: {
|
|
2548
2671
|
name: 'action.open.mp',
|
|
@@ -2563,11 +2686,41 @@
|
|
|
2563
2686
|
},
|
|
2564
2687
|
MP_GET_NUMBER: {
|
|
2565
2688
|
name: 'action.mp.get.number',
|
|
2566
|
-
version_live: { iOS: 416 }
|
|
2689
|
+
version_live: { iOS: 416 },
|
|
2690
|
+
error_list: {
|
|
2691
|
+
android: {
|
|
2692
|
+
'-1': {
|
|
2693
|
+
map_to: RESPONSE.USER_DENIED
|
|
2694
|
+
},
|
|
2695
|
+
'-101': {
|
|
2696
|
+
map_to: RESPONSE.USER_DENIED
|
|
2697
|
+
}
|
|
2698
|
+
},
|
|
2699
|
+
iOS: {
|
|
2700
|
+
'-1': {
|
|
2701
|
+
map_to: RESPONSE.USER_DENIED
|
|
2702
|
+
},
|
|
2703
|
+
'-10': {
|
|
2704
|
+
map_to: RESPONSE.USER_DENIED
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2567
2708
|
},
|
|
2568
2709
|
MP_OPEN_PROFILE_PICKER: {
|
|
2569
2710
|
name: 'action.mp.open.profile.picker',
|
|
2570
|
-
version_live: { iOS: 432 }
|
|
2711
|
+
version_live: { iOS: 432 },
|
|
2712
|
+
error_list: {
|
|
2713
|
+
android: {
|
|
2714
|
+
'-101': {
|
|
2715
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2716
|
+
}
|
|
2717
|
+
},
|
|
2718
|
+
iOS: {
|
|
2719
|
+
'-101': {
|
|
2720
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2571
2724
|
},
|
|
2572
2725
|
GET_SUPPORTED_ACTIONS: {
|
|
2573
2726
|
name: 'action.get.supported.actions',
|
|
@@ -2581,32 +2734,45 @@
|
|
|
2581
2734
|
},
|
|
2582
2735
|
PICK_MEDIA: {
|
|
2583
2736
|
name: 'action.pick.media',
|
|
2584
|
-
version_live: { iOS: 440 }
|
|
2737
|
+
version_live: { iOS: 440 },
|
|
2738
|
+
error_list: {
|
|
2739
|
+
android: {
|
|
2740
|
+
'-101': {
|
|
2741
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2742
|
+
},
|
|
2743
|
+
'999': {
|
|
2744
|
+
map_to: {
|
|
2745
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2746
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2747
|
+
},
|
|
2748
|
+
need_more_detail: true
|
|
2749
|
+
}
|
|
2750
|
+
},
|
|
2751
|
+
iOS: {
|
|
2752
|
+
'-10': {
|
|
2753
|
+
map_to: {
|
|
2754
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2755
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2585
2760
|
},
|
|
2586
2761
|
MP_CLOSE_LOADINGVIEW: {
|
|
2587
2762
|
name: 'action.mp.close.loadingview'
|
|
2588
2763
|
}
|
|
2589
2764
|
};
|
|
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'
|
|
2765
|
+
const COMMON_NATIVE_ERROR_CODE = {
|
|
2766
|
+
android: {
|
|
2767
|
+
'-4': RESPONSE.DECODE_FAILED,
|
|
2768
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2769
|
+
'-14': RESPONSE.TIME_OUT
|
|
2770
|
+
},
|
|
2771
|
+
iOS: {
|
|
2772
|
+
'-9': RESPONSE.DECODE_FAILED,
|
|
2773
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2774
|
+
'-14': RESPONSE.TIME_OUT
|
|
2775
|
+
}
|
|
2610
2776
|
};
|
|
2611
2777
|
const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
2612
2778
|
android: 12100571,
|
|
@@ -2614,6 +2780,12 @@
|
|
|
2614
2780
|
wp: 0,
|
|
2615
2781
|
unknown: 0
|
|
2616
2782
|
};
|
|
2783
|
+
const ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION = {
|
|
2784
|
+
android: 12220401,
|
|
2785
|
+
iOS: 460,
|
|
2786
|
+
wp: 0,
|
|
2787
|
+
unknown: 0
|
|
2788
|
+
};
|
|
2617
2789
|
// List actions supported before support action action.get.supported.actions
|
|
2618
2790
|
const ZALO_IOS_ACTIONS_SUPPORTED_BEFORE_VER_402 = [
|
|
2619
2791
|
ACTION.GET_DOWNLOADED_STICKER.name,
|
|
@@ -2718,124 +2890,36 @@
|
|
|
2718
2890
|
};
|
|
2719
2891
|
const PAYMENT_H5_URL = 'https://payment-mini.zalo.me';
|
|
2720
2892
|
|
|
2721
|
-
class
|
|
2893
|
+
class AppError {
|
|
2722
2894
|
constructor(code, msg, api) {
|
|
2723
2895
|
this.code = code;
|
|
2724
2896
|
this.message = msg;
|
|
2725
2897
|
this.api = api;
|
|
2726
2898
|
}
|
|
2727
2899
|
toString() {
|
|
2728
|
-
return `api: ${this.api}; code: ${this.code}; message: ${this.message}`;
|
|
2900
|
+
return `api: ${String(this.api)}; code: ${this.code}; message: ${this.message}`;
|
|
2729
2901
|
}
|
|
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
|
-
}
|
|
2902
|
+
toJSON() {
|
|
2903
|
+
return {
|
|
2904
|
+
code: this.code,
|
|
2905
|
+
message: this.message,
|
|
2906
|
+
api: this.api
|
|
2907
|
+
};
|
|
2755
2908
|
}
|
|
2756
2909
|
}
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
this.handler = handler;
|
|
2761
|
-
}
|
|
2910
|
+
const handleKnownExceptions = (error, api) => {
|
|
2911
|
+
error.api = api;
|
|
2912
|
+
return error.toJSON();
|
|
2762
2913
|
};
|
|
2763
|
-
const
|
|
2764
|
-
if (error instanceof
|
|
2765
|
-
error.
|
|
2766
|
-
return error;
|
|
2914
|
+
const handleUnknownExceptions = (error, api) => {
|
|
2915
|
+
if (error instanceof Error) {
|
|
2916
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, error.message, api).toJSON();
|
|
2767
2917
|
}
|
|
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;
|
|
2918
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, MESSAGES.UNKNOWN_ERROR, api).toJSON();
|
|
2812
2919
|
};
|
|
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
|
-
};
|
|
2920
|
+
const errorHandler = (error, api) => error instanceof AppError
|
|
2921
|
+
? handleKnownExceptions(error, api)
|
|
2922
|
+
: handleUnknownExceptions(error, api);
|
|
2839
2923
|
|
|
2840
2924
|
const apiResponse = {
|
|
2841
2925
|
success: (data, message) => ({
|
|
@@ -2844,13 +2928,13 @@
|
|
|
2844
2928
|
data: data || {}
|
|
2845
2929
|
}),
|
|
2846
2930
|
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
|
|
2931
|
+
badRequest: (message) => new AppError(RESPONSE_CODE.BAD_REQUEST, message),
|
|
2932
|
+
loginFailed: (message) => new AppError(RESPONSE_CODE.UNAUTHORIZED, `${MESSAGES.LOGIN_FAILED}: ${message}`),
|
|
2933
|
+
loginRequired: () => new AppError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED),
|
|
2934
|
+
missingParam: (params) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
|
|
2935
|
+
wrongTypeParam: (arg, expected, got) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
|
|
2936
|
+
cannotGetShareInfo: () => new AppError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
|
|
2937
|
+
lengthInvalid: (arg) => new AppError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
|
|
2854
2938
|
}
|
|
2855
2939
|
};
|
|
2856
2940
|
|
|
@@ -3265,7 +3349,7 @@
|
|
|
3265
3349
|
if (!_.isUndefined(currentVersion)) {
|
|
3266
3350
|
inputData.currentVersion = currentVersion;
|
|
3267
3351
|
}
|
|
3268
|
-
const api = QueryString.appendToUrl(
|
|
3352
|
+
const api = QueryString.appendToUrl(APIS.GET_APP_INFO, inputData);
|
|
3269
3353
|
const msgApi = yield fetch(api, {
|
|
3270
3354
|
credentials: 'include'
|
|
3271
3355
|
});
|
|
@@ -3657,504 +3741,97 @@
|
|
|
3657
3741
|
}
|
|
3658
3742
|
}
|
|
3659
3743
|
|
|
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;
|
|
3744
|
+
var version = "2.21.1";
|
|
3745
|
+
|
|
3746
|
+
class Basics {
|
|
3747
|
+
/**
|
|
3748
|
+
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
3749
|
+
*
|
|
3750
|
+
* @category Basics
|
|
3751
|
+
*
|
|
3752
|
+
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
3753
|
+
*/
|
|
3754
|
+
static getVersion() {
|
|
3755
|
+
return version;
|
|
3688
3756
|
}
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3757
|
+
/**
|
|
3758
|
+
* Gets system information.
|
|
3759
|
+
*
|
|
3760
|
+
* @function getSystemInfo
|
|
3761
|
+
* @category Basics
|
|
3762
|
+
*
|
|
3763
|
+
*
|
|
3764
|
+
*
|
|
3765
|
+
*/
|
|
3766
|
+
static getSystemInfo() {
|
|
3767
|
+
const system = {
|
|
3768
|
+
version: getMetaValue('version-id') || '',
|
|
3769
|
+
apiVersion: version,
|
|
3770
|
+
zaloVersion: getZaloVersion(),
|
|
3771
|
+
platform: getPlatform(),
|
|
3772
|
+
language: navigator.language,
|
|
3773
|
+
zaloLanguage: window.zLanguage || 'vi',
|
|
3774
|
+
zaloTheme: window.zTheme || 'light'
|
|
3775
|
+
};
|
|
3776
|
+
return system;
|
|
3693
3777
|
}
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3778
|
+
/**
|
|
3779
|
+
* Lấy thông tin mini app
|
|
3780
|
+
*
|
|
3781
|
+
* @async
|
|
3782
|
+
* @function getAppInfo
|
|
3783
|
+
* @category Device
|
|
3784
|
+
*
|
|
3785
|
+
*/
|
|
3786
|
+
static getAppInfo() {
|
|
3787
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3788
|
+
const appId = this.getAppId();
|
|
3789
|
+
const systemInfo = this.getSystemInfo();
|
|
3790
|
+
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
3791
|
+
});
|
|
3699
3792
|
}
|
|
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
|
-
});
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3795
|
+
class NavigationBar {
|
|
3796
|
+
/**
|
|
3797
|
+
* A promise for the user's favorite color.
|
|
3798
|
+
*
|
|
3799
|
+
* @promise FavoriteColorPromise
|
|
3800
|
+
* @fulfill {string} The user's favorite color.
|
|
3801
|
+
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
3802
|
+
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
3803
|
+
*/
|
|
3804
|
+
/**
|
|
3805
|
+
* Dynamically sets the title of the current page.
|
|
3806
|
+
*
|
|
3807
|
+
* @async
|
|
3808
|
+
* @function setNavigationBarTitle
|
|
3809
|
+
* @category Navigation Bar
|
|
3810
|
+
*
|
|
3811
|
+
* @example
|
|
3812
|
+
*
|
|
3813
|
+
* zmpApis.setNavigationBarTitle({
|
|
3814
|
+
* title: "Current Page"
|
|
3815
|
+
* }).then((res) => {
|
|
3816
|
+
* console.log("Success");
|
|
3817
|
+
* }).catch((error) => {
|
|
3818
|
+
* console.log("Fail");
|
|
3819
|
+
* });
|
|
3820
|
+
*
|
|
3821
|
+
* @param {Object} object
|
|
3822
|
+
* @param {string} object.title - The title of the page
|
|
3823
|
+
*
|
|
3824
|
+
* @return {Promise}
|
|
3825
|
+
*
|
|
3826
|
+
*/
|
|
3827
|
+
static setNavigationBarTitle(object) {
|
|
3828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3829
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
3830
|
+
title: object.title
|
|
3831
|
+
}, {
|
|
3832
|
+
haveTimeout: false
|
|
3833
|
+
});
|
|
3834
|
+
});
|
|
4158
3835
|
}
|
|
4159
3836
|
/**
|
|
4160
3837
|
* Sets the color of the navigation bar in the page.
|
|
@@ -4197,7 +3874,7 @@
|
|
|
4197
3874
|
actionBarType = HIDE_ACTION_BAR;
|
|
4198
3875
|
}
|
|
4199
3876
|
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()), {
|
|
3877
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
4201
3878
|
haveTimeout: false
|
|
4202
3879
|
});
|
|
4203
3880
|
});
|
|
@@ -4247,14 +3924,14 @@
|
|
|
4247
3924
|
: ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
|
|
4248
3925
|
}
|
|
4249
3926
|
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()), {
|
|
3927
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
4251
3928
|
haveTimeout: false
|
|
4252
3929
|
});
|
|
4253
3930
|
});
|
|
4254
3931
|
}
|
|
4255
3932
|
static setNavigationBar(data) {
|
|
4256
3933
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4257
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3934
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4258
3935
|
data
|
|
4259
3936
|
}, {
|
|
4260
3937
|
haveTimeout: false
|
|
@@ -4289,7 +3966,7 @@
|
|
|
4289
3966
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4290
3967
|
if (_.isString(object.backgroundColor) &&
|
|
4291
3968
|
object.backgroundColor.length > 0) {
|
|
4292
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3969
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4293
3970
|
actionbarType: this.isShowNavBar ? 5 : 6,
|
|
4294
3971
|
dataConfig: {
|
|
4295
3972
|
backgroundColor: object.backgroundColor,
|
|
@@ -4401,7 +4078,7 @@
|
|
|
4401
4078
|
*/
|
|
4402
4079
|
static setDeviceOrientation(object) {
|
|
4403
4080
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4404
|
-
yield this.callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4081
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4405
4082
|
autoRotate: OrientationType[object.rotate]
|
|
4406
4083
|
});
|
|
4407
4084
|
});
|
|
@@ -4425,7 +4102,7 @@
|
|
|
4425
4102
|
*/
|
|
4426
4103
|
static getNetworkType(object) {
|
|
4427
4104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4428
|
-
const resData = yield this.callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4105
|
+
const resData = yield this.getJSBridge().callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4429
4106
|
url: window.location.href,
|
|
4430
4107
|
featureId: ''
|
|
4431
4108
|
}).then((data) => {
|
|
@@ -4539,7 +4216,7 @@
|
|
|
4539
4216
|
items: Array.isArray(object === null || object === void 0 ? void 0 : object.items) ? object === null || object === void 0 ? void 0 : object.items : []
|
|
4540
4217
|
}
|
|
4541
4218
|
};
|
|
4542
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4219
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4543
4220
|
return true;
|
|
4544
4221
|
});
|
|
4545
4222
|
}
|
|
@@ -4558,7 +4235,7 @@
|
|
|
4558
4235
|
const data = {
|
|
4559
4236
|
subaction: 2
|
|
4560
4237
|
};
|
|
4561
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4238
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4562
4239
|
return true;
|
|
4563
4240
|
});
|
|
4564
4241
|
}
|
|
@@ -4579,7 +4256,7 @@
|
|
|
4579
4256
|
const data = {
|
|
4580
4257
|
subaction: 1
|
|
4581
4258
|
};
|
|
4582
|
-
const resData = yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4259
|
+
const resData = yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4583
4260
|
isMultiCallback: true
|
|
4584
4261
|
}).then((resData) => {
|
|
4585
4262
|
const res = {
|
|
@@ -4621,7 +4298,7 @@
|
|
|
4621
4298
|
*/
|
|
4622
4299
|
static stopBluetoothDevicesDiscovery() {
|
|
4623
4300
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4624
|
-
return this.callNative({
|
|
4301
|
+
return this.getJSBridge().callNative({
|
|
4625
4302
|
name: ''
|
|
4626
4303
|
}, {});
|
|
4627
4304
|
});
|
|
@@ -4648,7 +4325,7 @@
|
|
|
4648
4325
|
*/
|
|
4649
4326
|
static startBluetoothDevicesDiscovery(object) {
|
|
4650
4327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4651
|
-
return this.callNative({
|
|
4328
|
+
return this.getJSBridge().callNative({
|
|
4652
4329
|
name: ''
|
|
4653
4330
|
}, Object.assign({}, object));
|
|
4654
4331
|
});
|
|
@@ -4672,7 +4349,7 @@
|
|
|
4672
4349
|
*/
|
|
4673
4350
|
static openBluetoothAdapter() {
|
|
4674
4351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4675
|
-
return this.callNative({
|
|
4352
|
+
return this.getJSBridge().callNative({
|
|
4676
4353
|
name: ''
|
|
4677
4354
|
}, {});
|
|
4678
4355
|
});
|
|
@@ -4692,7 +4369,7 @@
|
|
|
4692
4369
|
*/
|
|
4693
4370
|
static onBluetoothDeviceFound() {
|
|
4694
4371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4695
|
-
return this.callNative({
|
|
4372
|
+
return this.getJSBridge().callNative({
|
|
4696
4373
|
name: ''
|
|
4697
4374
|
}, {});
|
|
4698
4375
|
});
|
|
@@ -4740,7 +4417,7 @@
|
|
|
4740
4417
|
const data = {
|
|
4741
4418
|
services: object.services || []
|
|
4742
4419
|
};
|
|
4743
|
-
return this.callNative({
|
|
4420
|
+
return this.getJSBridge().callNative({
|
|
4744
4421
|
name: ''
|
|
4745
4422
|
}, data);
|
|
4746
4423
|
});
|
|
@@ -4761,7 +4438,7 @@
|
|
|
4761
4438
|
*/
|
|
4762
4439
|
static getBluetoothDevices() {
|
|
4763
4440
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4764
|
-
return this.callNative({
|
|
4441
|
+
return this.getJSBridge().callNative({
|
|
4765
4442
|
name: ''
|
|
4766
4443
|
}, {});
|
|
4767
4444
|
});
|
|
@@ -4782,7 +4459,7 @@
|
|
|
4782
4459
|
*/
|
|
4783
4460
|
static getBluetoothAdapterState() {
|
|
4784
4461
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4785
|
-
return this.callNative({
|
|
4462
|
+
return this.getJSBridge().callNative({
|
|
4786
4463
|
name: ''
|
|
4787
4464
|
}, {});
|
|
4788
4465
|
});
|
|
@@ -4803,7 +4480,7 @@
|
|
|
4803
4480
|
*/
|
|
4804
4481
|
static closeBluetoothAdapter() {
|
|
4805
4482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4806
|
-
return this.callNative({
|
|
4483
|
+
return this.getJSBridge().callNative({
|
|
4807
4484
|
name: ''
|
|
4808
4485
|
}, {});
|
|
4809
4486
|
});
|
|
@@ -4817,7 +4494,7 @@
|
|
|
4817
4494
|
*/
|
|
4818
4495
|
static scanQRCode(object) {
|
|
4819
4496
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4820
|
-
return yield this.callNative(ACTION.OPEN_QR, {
|
|
4497
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_QR, {
|
|
4821
4498
|
skipOpenLink: true
|
|
4822
4499
|
});
|
|
4823
4500
|
});
|
|
@@ -4831,308 +4508,770 @@
|
|
|
4831
4508
|
*/
|
|
4832
4509
|
static showToast(object) {
|
|
4833
4510
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4834
|
-
yield this.callNative(ACTION.SHOW_TOAST, {
|
|
4835
|
-
toast: object.message
|
|
4511
|
+
yield this.getJSBridge().callNative(ACTION.SHOW_TOAST, {
|
|
4512
|
+
toast: object.message
|
|
4513
|
+
});
|
|
4514
|
+
});
|
|
4515
|
+
}
|
|
4516
|
+
/**
|
|
4517
|
+
* Ẩn keyboard
|
|
4518
|
+
* @async
|
|
4519
|
+
* @function hideKeyboard
|
|
4520
|
+
* @category Device
|
|
4521
|
+
*
|
|
4522
|
+
*/
|
|
4523
|
+
static hideKeyboard(object) {
|
|
4524
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4525
|
+
yield this.getJSBridge().callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4526
|
+
});
|
|
4527
|
+
}
|
|
4528
|
+
/**
|
|
4529
|
+
* Open phone
|
|
4530
|
+
* @async
|
|
4531
|
+
* @function openPhone
|
|
4532
|
+
* @category Device
|
|
4533
|
+
*
|
|
4534
|
+
*/
|
|
4535
|
+
static openPhone(object) {
|
|
4536
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4537
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_PHONE, {
|
|
4538
|
+
phoneNum: object.phoneNumber,
|
|
4539
|
+
phoneCode: object.phoneNumber
|
|
4540
|
+
});
|
|
4541
|
+
});
|
|
4542
|
+
}
|
|
4543
|
+
/**
|
|
4544
|
+
* Open SMS
|
|
4545
|
+
* @async
|
|
4546
|
+
* @function openSMS
|
|
4547
|
+
* @category Device
|
|
4548
|
+
*
|
|
4549
|
+
*/
|
|
4550
|
+
static openSMS(object) {
|
|
4551
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4552
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_SMS, {
|
|
4553
|
+
content: object.content,
|
|
4554
|
+
phoneCode: object.phoneNumber
|
|
4555
|
+
});
|
|
4556
|
+
});
|
|
4557
|
+
}
|
|
4558
|
+
/**
|
|
4559
|
+
* Keep screen.
|
|
4560
|
+
* @async
|
|
4561
|
+
* @function keepScreen
|
|
4562
|
+
* @category Device
|
|
4563
|
+
*
|
|
4564
|
+
*/
|
|
4565
|
+
static keepScreen(object) {
|
|
4566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4567
|
+
return yield this.getJSBridge().callNative(ACTION.KEEP_SCREEN, {
|
|
4568
|
+
data: {
|
|
4569
|
+
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4570
|
+
}
|
|
4571
|
+
});
|
|
4572
|
+
});
|
|
4573
|
+
}
|
|
4574
|
+
/**
|
|
4575
|
+
* Xác thực bằng sinh trắc học
|
|
4576
|
+
* @async
|
|
4577
|
+
* @function openBioAuthentication
|
|
4578
|
+
* @category Authentication
|
|
4579
|
+
*
|
|
4580
|
+
*/
|
|
4581
|
+
static openBioAuthentication(object) {
|
|
4582
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4583
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION, {
|
|
4584
|
+
secret_data: object.secretData,
|
|
4585
|
+
app_id: this.getZAppId(),
|
|
4586
|
+
ui: {
|
|
4587
|
+
title: object.ui.title,
|
|
4588
|
+
sub_title: object.ui.subTitle,
|
|
4589
|
+
negative_text: object.ui.negativeButtonText
|
|
4590
|
+
},
|
|
4591
|
+
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4592
|
+
}).then((data) => {
|
|
4593
|
+
var _a, _b, _c, _d;
|
|
4594
|
+
return {
|
|
4595
|
+
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4596
|
+
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4597
|
+
data: {
|
|
4598
|
+
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4599
|
+
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4600
|
+
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4601
|
+
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4602
|
+
}
|
|
4603
|
+
};
|
|
4604
|
+
});
|
|
4605
|
+
});
|
|
4606
|
+
}
|
|
4607
|
+
/**
|
|
4608
|
+
* 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...)
|
|
4609
|
+
* @async
|
|
4610
|
+
* @function checkStateBioAuthentication
|
|
4611
|
+
* @category Authentication
|
|
4612
|
+
*
|
|
4613
|
+
* @example
|
|
4614
|
+
* api.checkStateAuthen({
|
|
4615
|
+
* success: (res) => {},
|
|
4616
|
+
* fail: (err) => {}
|
|
4617
|
+
* })
|
|
4618
|
+
* @param {InputDataType.CallbackType} object
|
|
4619
|
+
*/
|
|
4620
|
+
static checkStateBioAuthentication(object) {
|
|
4621
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4622
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4623
|
+
return {
|
|
4624
|
+
bioState: data === null || data === void 0 ? void 0 : data.bio_state
|
|
4625
|
+
};
|
|
4626
|
+
});
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4629
|
+
/**
|
|
4630
|
+
* Vibrate.
|
|
4631
|
+
* @async
|
|
4632
|
+
* @function vibrate
|
|
4633
|
+
* @category Device
|
|
4634
|
+
*
|
|
4635
|
+
*/
|
|
4636
|
+
static vibrate(object) {
|
|
4637
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4638
|
+
return yield this.getJSBridge().callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4639
|
+
type: VibrateType[object.type],
|
|
4640
|
+
vibrate_time: object.milliseconds
|
|
4641
|
+
});
|
|
4642
|
+
});
|
|
4643
|
+
}
|
|
4644
|
+
/**
|
|
4645
|
+
* Connect Wifi.
|
|
4646
|
+
* @async
|
|
4647
|
+
* @function connectWifi
|
|
4648
|
+
* @category Device
|
|
4649
|
+
*
|
|
4650
|
+
*/
|
|
4651
|
+
static connectWifi(object) {
|
|
4652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4653
|
+
let securityType = 'open';
|
|
4654
|
+
if (_.isString(object.password) && object.password.length > 0) {
|
|
4655
|
+
securityType = 'wpa_wpa2';
|
|
4656
|
+
}
|
|
4657
|
+
return yield this.getJSBridge().callNative(ACTION.MP_JOIN_WIFI, {
|
|
4658
|
+
ssid: object.SSID,
|
|
4659
|
+
securityType: securityType,
|
|
4660
|
+
password: object.password,
|
|
4661
|
+
hiddenSsid: object.hiddenSSID
|
|
4662
|
+
});
|
|
4663
|
+
});
|
|
4664
|
+
}
|
|
4665
|
+
/**
|
|
4666
|
+
* Open App Store.
|
|
4667
|
+
* @async
|
|
4668
|
+
* @function openAppStore
|
|
4669
|
+
* @category Device
|
|
4670
|
+
*
|
|
4671
|
+
*/
|
|
4672
|
+
static openAppStore(object) {
|
|
4673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4674
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_APPSTORE, object);
|
|
4675
|
+
});
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4679
|
+
var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
|
|
4680
|
+
class LocalResourceStorage {
|
|
4681
|
+
constructor(prefix) {
|
|
4682
|
+
_LocalResourceStorage_storage.set(this, localStorage);
|
|
4683
|
+
_LocalResourceStorage_prefix.set(this, void 0);
|
|
4684
|
+
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
4685
|
+
checkPlatform();
|
|
4686
|
+
// if (platform.isMobile && platform.isZalo) {
|
|
4687
|
+
// Object.defineProperty(window, 'localStorage', {
|
|
4688
|
+
// value: null,
|
|
4689
|
+
// configurable: true,
|
|
4690
|
+
// enumerable: true,
|
|
4691
|
+
// writable: false
|
|
4692
|
+
// });
|
|
4693
|
+
// }
|
|
4694
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
4695
|
+
keys: new Set(),
|
|
4696
|
+
currentSize: 0,
|
|
4697
|
+
limitSize: STORAGE_LIMIT
|
|
4698
|
+
}, "f");
|
|
4699
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
4700
|
+
this.findAllCurrentDataByApp(prefix);
|
|
4701
|
+
}
|
|
4702
|
+
findAllCurrentDataByApp(prefix) {
|
|
4703
|
+
try {
|
|
4704
|
+
let _x;
|
|
4705
|
+
for (_x in __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f")) {
|
|
4706
|
+
if (prefix) {
|
|
4707
|
+
const _prefix = _x.split('_')[0];
|
|
4708
|
+
if (_prefix !== prefix) {
|
|
4709
|
+
continue;
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
catch (error) {
|
|
4716
|
+
logger.error(error, 'LocalResourceStorage > findAllCurrentDataByApp');
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
get(keys) {
|
|
4720
|
+
let res = new Map();
|
|
4721
|
+
keys.forEach((key) => {
|
|
4722
|
+
res.set(key, this.getSync(key));
|
|
4723
|
+
});
|
|
4724
|
+
return Promise.resolve(res);
|
|
4725
|
+
}
|
|
4726
|
+
getSync(key) {
|
|
4727
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4728
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4729
|
+
}
|
|
4730
|
+
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
4731
|
+
return null;
|
|
4732
|
+
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
4733
|
+
}
|
|
4734
|
+
set(data) {
|
|
4735
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4736
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
4737
|
+
this.setSync(key, value.replace(/\\"/g, '"'));
|
|
4836
4738
|
});
|
|
4739
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4837
4740
|
});
|
|
4838
4741
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4742
|
+
setSync(key, value) {
|
|
4743
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4744
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4745
|
+
}
|
|
4746
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").setItem(key, value);
|
|
4747
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(key);
|
|
4748
|
+
}
|
|
4749
|
+
getInfo() {
|
|
4847
4750
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4848
|
-
|
|
4751
|
+
return Promise.resolve(this.getInfoSync());
|
|
4849
4752
|
});
|
|
4850
4753
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4754
|
+
getInfoSync() {
|
|
4755
|
+
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
4756
|
+
return {
|
|
4757
|
+
currentSize: _.isNumber(currentSize)
|
|
4758
|
+
? Number((currentSize / 1024).toFixed(2))
|
|
4759
|
+
: 0,
|
|
4760
|
+
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
4761
|
+
};
|
|
4762
|
+
}
|
|
4763
|
+
remove(keys) {
|
|
4859
4764
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
phoneCode: object.phoneNumber
|
|
4765
|
+
keys.forEach((key) => {
|
|
4766
|
+
this.removeSync(key);
|
|
4863
4767
|
});
|
|
4768
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4864
4769
|
});
|
|
4865
4770
|
}
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4771
|
+
removeSync(key) {
|
|
4772
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4773
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4774
|
+
}
|
|
4775
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key)) {
|
|
4776
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4777
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
clear() {
|
|
4874
4781
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4875
|
-
|
|
4876
|
-
content: object.content,
|
|
4877
|
-
phoneCode: object.phoneNumber
|
|
4878
|
-
});
|
|
4782
|
+
return Promise.resolve(this.clearSync());
|
|
4879
4783
|
});
|
|
4880
4784
|
}
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
static keepScreen(object) {
|
|
4889
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4890
|
-
return yield this.callNative(ACTION.KEEP_SCREEN, {
|
|
4891
|
-
data: {
|
|
4892
|
-
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4893
|
-
}
|
|
4894
|
-
});
|
|
4785
|
+
clearSync() {
|
|
4786
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
4787
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
4788
|
+
return;
|
|
4789
|
+
}
|
|
4790
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4791
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4895
4792
|
});
|
|
4896
4793
|
}
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
return
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4794
|
+
}
|
|
4795
|
+
_LocalResourceStorage_storage = new WeakMap(), _LocalResourceStorage_prefix = new WeakMap(), _LocalResourceStorage_resourceInfo = new WeakMap();
|
|
4796
|
+
|
|
4797
|
+
var wrappers = {};
|
|
4798
|
+
var WrapperFn = function wrapFunction(fn, type, source) {
|
|
4799
|
+
var t = type || 'default';
|
|
4800
|
+
return function () {
|
|
4801
|
+
var callee = t in wrappers ? wrappers[t](fn, source) : fn;
|
|
4802
|
+
return callee.apply(this, arguments);
|
|
4803
|
+
};
|
|
4804
|
+
};
|
|
4805
|
+
WrapperFn.setWrapper = function (fn) {
|
|
4806
|
+
var type = arguments.length <= 1 || arguments[1] === undefined
|
|
4807
|
+
? 'default'
|
|
4808
|
+
: arguments[1];
|
|
4809
|
+
wrappers[type] = fn;
|
|
4810
|
+
};
|
|
4811
|
+
var ERROR = {
|
|
4812
|
+
error: {
|
|
4813
|
+
code: 1,
|
|
4814
|
+
error_subcode: 1357046,
|
|
4815
|
+
message: 'Received Invalid JSON reply.',
|
|
4816
|
+
type: 'http'
|
|
4817
|
+
}
|
|
4818
|
+
};
|
|
4819
|
+
function safelyParseResponse(rawResponse) {
|
|
4820
|
+
try {
|
|
4821
|
+
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
4822
|
+
}
|
|
4823
|
+
catch (ex) {
|
|
4824
|
+
return ERROR;
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
function createCORSRequest(method, url) {
|
|
4828
|
+
if (!self.XMLHttpRequest) {
|
|
4829
|
+
return null;
|
|
4830
|
+
}
|
|
4831
|
+
var xhr = new XMLHttpRequest();
|
|
4832
|
+
var noop = function noop() { };
|
|
4833
|
+
if ('withCredentials' in xhr) {
|
|
4834
|
+
xhr.open(method, url, true);
|
|
4835
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
4836
|
+
}
|
|
4837
|
+
else {
|
|
4838
|
+
return null;
|
|
4839
|
+
}
|
|
4840
|
+
var wrapper = {
|
|
4841
|
+
send: function send(data) {
|
|
4842
|
+
xhr.send(data);
|
|
4843
|
+
}
|
|
4844
|
+
};
|
|
4845
|
+
var onload = WrapperFn(function () {
|
|
4846
|
+
onload = noop;
|
|
4847
|
+
if ('onload' in wrapper) {
|
|
4848
|
+
wrapper.onload(xhr);
|
|
4849
|
+
}
|
|
4850
|
+
}, 'entry', 'XMLHttpRequest:load');
|
|
4851
|
+
var onerror = WrapperFn(function () {
|
|
4852
|
+
onerror = noop;
|
|
4853
|
+
if ('onerror' in wrapper) {
|
|
4854
|
+
wrapper.onerror(xhr);
|
|
4855
|
+
}
|
|
4856
|
+
}, 'entry', 'XMLHttpRequest:error');
|
|
4857
|
+
xhr.onload = function () {
|
|
4858
|
+
onload();
|
|
4859
|
+
};
|
|
4860
|
+
xhr.onerror = function () {
|
|
4861
|
+
onerror();
|
|
4862
|
+
};
|
|
4863
|
+
xhr.onreadystatechange = function () {
|
|
4864
|
+
if (xhr.readyState == 4) {
|
|
4865
|
+
if (xhr.status == 200) {
|
|
4866
|
+
onload();
|
|
4867
|
+
}
|
|
4868
|
+
else {
|
|
4869
|
+
onerror();
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
};
|
|
4873
|
+
return wrapper;
|
|
4874
|
+
}
|
|
4875
|
+
function execute(url, method, params, cb) {
|
|
4876
|
+
params.suppress_http_code = 1;
|
|
4877
|
+
var data = QueryString.encode(params);
|
|
4878
|
+
if (method != 'post') {
|
|
4879
|
+
url = QueryString.appendToUrl(url, data);
|
|
4880
|
+
data = '';
|
|
4881
|
+
}
|
|
4882
|
+
var request = createCORSRequest(method, url);
|
|
4883
|
+
if (!request) {
|
|
4884
|
+
return false;
|
|
4885
|
+
}
|
|
4886
|
+
request.onload = function (xhr) {
|
|
4887
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4888
|
+
};
|
|
4889
|
+
request.onerror = function (xhr) {
|
|
4890
|
+
if (xhr.responseText) {
|
|
4891
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4892
|
+
}
|
|
4893
|
+
else {
|
|
4894
|
+
cb({
|
|
4895
|
+
error: {
|
|
4896
|
+
code: 1,
|
|
4897
|
+
error_subcode: 1357045,
|
|
4898
|
+
message: 'unknown error (empty response)',
|
|
4899
|
+
status: xhr.status,
|
|
4900
|
+
type: 'http'
|
|
4901
|
+
}
|
|
4902
|
+
});
|
|
4903
|
+
}
|
|
4904
|
+
};
|
|
4905
|
+
request.send(data);
|
|
4906
|
+
return true;
|
|
4907
|
+
}
|
|
4908
|
+
var CORSRequest = {
|
|
4909
|
+
execute: execute
|
|
4910
|
+
};
|
|
4911
|
+
|
|
4912
|
+
var _ZaloJSBridge_instances, _ZaloJSBridge_cookies, _ZaloJSBridge_actionRuntimeInfo, _ZaloJSBridge_jsCall;
|
|
4913
|
+
class ZaloJSBridge extends eventemitter3 {
|
|
4914
|
+
constructor() {
|
|
4915
|
+
super();
|
|
4916
|
+
_ZaloJSBridge_instances.add(this);
|
|
4917
|
+
this.debug = Debug('zmp:ZaloJSBridge');
|
|
4918
|
+
this.events = ZMPEEmitter.getInstance();
|
|
4919
|
+
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
4920
|
+
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
4921
|
+
this.results = [];
|
|
4922
|
+
this._userAgent = getUserAgent();
|
|
4923
|
+
this._device = checkPlatform();
|
|
4924
|
+
this.isJumped = false;
|
|
4925
|
+
_ZaloJSBridge_cookies.set(this, null);
|
|
4926
|
+
_ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
|
|
4927
|
+
this.jump = () => {
|
|
4928
|
+
return new Promise((resolve, reject) => {
|
|
4929
|
+
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
|
|
4930
|
+
resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
|
|
4931
|
+
}
|
|
4932
|
+
else {
|
|
4933
|
+
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
4934
|
+
.then((data) => {
|
|
4935
|
+
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
4936
|
+
const actionPermission = (data && data.actionPermission) || [];
|
|
4937
|
+
Object.entries(actionPermission).forEach((item) => {
|
|
4938
|
+
const key = item[0];
|
|
4939
|
+
const value = item[1] || { perm: 0, decode: 0 };
|
|
4940
|
+
if (!__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key]) {
|
|
4941
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key] = {
|
|
4942
|
+
permission: false,
|
|
4943
|
+
support: false
|
|
4944
|
+
};
|
|
4945
|
+
}
|
|
4946
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key].permission = value.perm === 1;
|
|
4947
|
+
});
|
|
4948
|
+
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
4949
|
+
if (jsToken) {
|
|
4950
|
+
this.jsAccessTk = jsToken.value;
|
|
4951
|
+
window.ZJSBridge.setJSToken &&
|
|
4952
|
+
window.ZJSBridge.setJSToken(jsToken.value);
|
|
4953
|
+
}
|
|
4954
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_cookies, cookies, "f");
|
|
4955
|
+
this.isJumped = true;
|
|
4956
|
+
resolve(cookies);
|
|
4957
|
+
})
|
|
4958
|
+
.catch((error) => {
|
|
4959
|
+
this.isJumped = false;
|
|
4960
|
+
reject(error);
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4927
4963
|
});
|
|
4964
|
+
};
|
|
4965
|
+
this._jsCallFuncCallbacks = {};
|
|
4966
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_actionRuntimeInfo, {}, "f");
|
|
4967
|
+
this.events.on(Events.AppPaused, () => {
|
|
4968
|
+
if (this.results.length > 0) {
|
|
4969
|
+
let array = this.results;
|
|
4970
|
+
this.results = [];
|
|
4971
|
+
try {
|
|
4972
|
+
this.sendLogData(array);
|
|
4973
|
+
}
|
|
4974
|
+
catch (error) { }
|
|
4975
|
+
}
|
|
4928
4976
|
});
|
|
4977
|
+
if (this.sendLogTimer) {
|
|
4978
|
+
clearInterval(this.sendLogTimer);
|
|
4979
|
+
}
|
|
4980
|
+
else {
|
|
4981
|
+
this.sendLogTimer = setInterval(() => {
|
|
4982
|
+
if (this.results.length > 0) {
|
|
4983
|
+
let array = this.results;
|
|
4984
|
+
this.results = [];
|
|
4985
|
+
try {
|
|
4986
|
+
this.sendLogData(array);
|
|
4987
|
+
}
|
|
4988
|
+
catch (error) { }
|
|
4989
|
+
}
|
|
4990
|
+
}, 5000);
|
|
4991
|
+
}
|
|
4929
4992
|
}
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
return yield this.callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4993
|
+
static getInstance() {
|
|
4994
|
+
if (!ZaloJSBridge.instance) {
|
|
4995
|
+
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
4996
|
+
}
|
|
4997
|
+
return ZaloJSBridge.instance;
|
|
4998
|
+
}
|
|
4999
|
+
set accessTk(value) {
|
|
5000
|
+
this._accessTk = value;
|
|
5001
|
+
}
|
|
5002
|
+
set jsAccessTk(value) {
|
|
5003
|
+
this._jsAccessTk = value;
|
|
5004
|
+
}
|
|
5005
|
+
sendLogData(data) {
|
|
5006
|
+
try {
|
|
5007
|
+
const logData = data.map((item) => {
|
|
4946
5008
|
return {
|
|
4947
|
-
|
|
5009
|
+
action: item.action,
|
|
5010
|
+
error: item.error
|
|
4948
5011
|
};
|
|
4949
5012
|
});
|
|
4950
|
-
|
|
5013
|
+
CORSRequest.execute(APIS.SEND_ACTION_LOG, 'post', {
|
|
5014
|
+
appId: window.APP_ID,
|
|
5015
|
+
data: JSON.stringify(logData)
|
|
5016
|
+
}, (response) => { });
|
|
5017
|
+
window.zmpSentry &&
|
|
5018
|
+
window.zmpSentry.captureMessage('Result from native', {
|
|
5019
|
+
extra: {
|
|
5020
|
+
data: data
|
|
5021
|
+
}
|
|
5022
|
+
});
|
|
5023
|
+
}
|
|
5024
|
+
catch (error) { }
|
|
4951
5025
|
}
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
5026
|
+
onJSCall(key, data) {
|
|
5027
|
+
try {
|
|
5028
|
+
this.debug('onJSCall', key, data);
|
|
5029
|
+
const parsedData = parseJSON(data);
|
|
5030
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5031
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5032
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5033
|
+
if (!!callback) {
|
|
5034
|
+
try {
|
|
5035
|
+
callback.call(this, parsedData);
|
|
5036
|
+
}
|
|
5037
|
+
catch (error) {
|
|
5038
|
+
console.error('Call callback error', error);
|
|
5039
|
+
}
|
|
5040
|
+
!!timeout && clearTimeout(timeout);
|
|
5041
|
+
this._jsCallFuncCallbacks[key] = null;
|
|
5042
|
+
delete this._jsCallFuncCallbacks[key];
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
this.results.push({
|
|
5046
|
+
action: parsedData.action,
|
|
5047
|
+
error: parsedData.error_code,
|
|
5048
|
+
message: parsedData.error_message
|
|
4964
5049
|
});
|
|
4965
|
-
}
|
|
5050
|
+
}
|
|
5051
|
+
catch (e) {
|
|
5052
|
+
console.log('onJSCall', 'error', e);
|
|
5053
|
+
}
|
|
4966
5054
|
}
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
5055
|
+
onMultiJSCall(key, data) {
|
|
5056
|
+
try {
|
|
5057
|
+
this.debug('onMultiJSCall', key, data);
|
|
5058
|
+
const parsedData = parseJSON(data);
|
|
5059
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5060
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5061
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5062
|
+
if (!!callback) {
|
|
5063
|
+
try {
|
|
5064
|
+
callback.call(this, parsedData);
|
|
5065
|
+
}
|
|
5066
|
+
catch (error) {
|
|
5067
|
+
console.error('Call callback error', error);
|
|
5068
|
+
}
|
|
5069
|
+
!!timeout && clearTimeout(timeout);
|
|
5070
|
+
}
|
|
4979
5071
|
}
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
hiddenSsid: object.hiddenSSID
|
|
5072
|
+
this.results.push({
|
|
5073
|
+
action: parsedData.action,
|
|
5074
|
+
error: parsedData.error_code,
|
|
5075
|
+
message: parsedData.error_message
|
|
4985
5076
|
});
|
|
4986
|
-
}
|
|
4987
|
-
|
|
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
|
-
});
|
|
5077
|
+
}
|
|
5078
|
+
catch (e) {
|
|
5079
|
+
console.log('onMultiJSCall', 'error', e);
|
|
5080
|
+
}
|
|
4999
5081
|
}
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
_LocalResourceStorage_prefix.set(this, void 0);
|
|
5007
|
-
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
5008
|
-
checkPlatform();
|
|
5009
|
-
// if (platform.isMobile && platform.isZalo) {
|
|
5010
|
-
// Object.defineProperty(window, 'localStorage', {
|
|
5011
|
-
// value: null,
|
|
5012
|
-
// configurable: true,
|
|
5013
|
-
// enumerable: true,
|
|
5014
|
-
// writable: false
|
|
5015
|
-
// });
|
|
5016
|
-
// }
|
|
5017
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
5018
|
-
keys: new Set(),
|
|
5019
|
-
currentSize: 0,
|
|
5020
|
-
limitSize: STORAGE_LIMIT
|
|
5021
|
-
}, "f");
|
|
5022
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
5023
|
-
this.findAllCurrentDataByApp(prefix);
|
|
5082
|
+
nativeEventHandler(eventId, eventName, eventData) {
|
|
5083
|
+
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
5084
|
+
const data = stringToData(eventData);
|
|
5085
|
+
this.debug(data);
|
|
5086
|
+
const convertedData = this.handleEventData(eventName, data);
|
|
5087
|
+
this.events.emit(eventName, eventId, convertedData);
|
|
5024
5088
|
}
|
|
5025
|
-
|
|
5089
|
+
handleEventData(eventName, data) {
|
|
5026
5090
|
try {
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
const
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5091
|
+
switch (eventName) {
|
|
5092
|
+
case Events.OpenApp:
|
|
5093
|
+
const { url } = data;
|
|
5094
|
+
const validUrl = new URL(url);
|
|
5095
|
+
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
5096
|
+
return {
|
|
5097
|
+
path: `${path ? path : '/'}${validUrl.search}`
|
|
5098
|
+
};
|
|
5099
|
+
break;
|
|
5100
|
+
default:
|
|
5101
|
+
return data;
|
|
5102
|
+
break;
|
|
5036
5103
|
}
|
|
5037
5104
|
}
|
|
5038
5105
|
catch (error) {
|
|
5039
|
-
|
|
5106
|
+
return data;
|
|
5040
5107
|
}
|
|
5041
5108
|
}
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
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}`;
|
|
5109
|
+
defaultCallback(data) {
|
|
5110
|
+
if (data !== null && data !== undefined) {
|
|
5111
|
+
data = parseJSON(data);
|
|
5052
5112
|
}
|
|
5053
|
-
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
5054
|
-
return null;
|
|
5055
|
-
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
5056
5113
|
}
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5114
|
+
callNative(action, data, option) {
|
|
5115
|
+
this.debug(action.name, data);
|
|
5116
|
+
return new Promise((resolve, reject) => {
|
|
5117
|
+
const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
5118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5119
|
+
try {
|
|
5120
|
+
if (_.isUndefined(cb) || _.isNull(cb)) {
|
|
5121
|
+
return reject(new Error('Native callback is null'));
|
|
5122
|
+
}
|
|
5123
|
+
if (cb.error_code !== 0) {
|
|
5124
|
+
let error = new AppError(cb.error_code, cb.error_message);
|
|
5125
|
+
const platform = getPlatform();
|
|
5126
|
+
if (action === ACTION.JUMP_LOGIN) {
|
|
5127
|
+
error = new AppError(RESPONSE_CODE.UNKNOWN_ERROR, `Can not get auth code: ${cb.error_message}`);
|
|
5128
|
+
}
|
|
5129
|
+
else if (!this.isJumped && !action.skip_jump) {
|
|
5130
|
+
error = new AppError(RESPONSE.UNAUTHORIZED.code, RESPONSE.UNAUTHORIZED.message);
|
|
5131
|
+
}
|
|
5132
|
+
else if (String(error.message).toLowerCase() === 'permission required!' ||
|
|
5133
|
+
String(error.message).toLowerCase() === 'no permission!') {
|
|
5134
|
+
error = new AppError(RESPONSE.FORBIDDEN.code, RESPONSE.FORBIDDEN.message);
|
|
5135
|
+
}
|
|
5136
|
+
else if (COMMON_NATIVE_ERROR_CODE[platform][cb.error_code]) {
|
|
5137
|
+
error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
|
|
5138
|
+
}
|
|
5139
|
+
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)]) {
|
|
5140
|
+
let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
|
|
5141
|
+
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) {
|
|
5142
|
+
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}`;
|
|
5143
|
+
}
|
|
5144
|
+
error = new AppError(action.error_list[platform][String(cb.error_code)].map_to.code, error_message);
|
|
5145
|
+
}
|
|
5146
|
+
return reject(error);
|
|
5147
|
+
}
|
|
5148
|
+
if (option === null || option === void 0 ? void 0 : option.successCallback) {
|
|
5149
|
+
const res = yield option.successCallback(cb.data);
|
|
5150
|
+
return resolve(res);
|
|
5151
|
+
}
|
|
5152
|
+
else {
|
|
5153
|
+
resolve(cb.data || {});
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
catch (error) {
|
|
5157
|
+
return reject(error);
|
|
5158
|
+
}
|
|
5061
5159
|
});
|
|
5062
|
-
|
|
5160
|
+
const isIOS = checkPlatform().isIOS;
|
|
5161
|
+
const isSupportAction = checkIOSSupportAction(action);
|
|
5162
|
+
if (isIOS && !isSupportAction) {
|
|
5163
|
+
const error = new AppError(-5, `Client isn't support this action`);
|
|
5164
|
+
return reject(error);
|
|
5165
|
+
}
|
|
5166
|
+
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
5167
|
+
setTimeout(() => {
|
|
5168
|
+
__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);
|
|
5169
|
+
}, option.delay);
|
|
5170
|
+
}
|
|
5171
|
+
else {
|
|
5172
|
+
__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);
|
|
5173
|
+
}
|
|
5063
5174
|
});
|
|
5064
5175
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5176
|
+
}
|
|
5177
|
+
_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) {
|
|
5178
|
+
try {
|
|
5179
|
+
const actionName = action.name;
|
|
5180
|
+
const key = generateUniqueString(actionName);
|
|
5181
|
+
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
5182
|
+
this.onJSCall(key, {
|
|
5183
|
+
error_code: -13,
|
|
5184
|
+
error_message: 'params invalid!',
|
|
5185
|
+
data: {
|
|
5186
|
+
device: this._device.isMobile,
|
|
5187
|
+
jsToken: this._jsAccessTk,
|
|
5188
|
+
access_token: this._accessTk
|
|
5189
|
+
},
|
|
5190
|
+
action: actionName
|
|
5191
|
+
});
|
|
5192
|
+
return false;
|
|
5068
5193
|
}
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
currentSize: _.isNumber(currentSize)
|
|
5081
|
-
? Number((currentSize / 1024).toFixed(2))
|
|
5082
|
-
: 0,
|
|
5083
|
-
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
5194
|
+
if (options === undefined || options === null) {
|
|
5195
|
+
options = {};
|
|
5196
|
+
}
|
|
5197
|
+
if (!callback) {
|
|
5198
|
+
callback = this.defaultCallback;
|
|
5199
|
+
}
|
|
5200
|
+
const timeoutCallback = {
|
|
5201
|
+
error_code: -14,
|
|
5202
|
+
error_message: 'Request Timeout!',
|
|
5203
|
+
data: {},
|
|
5204
|
+
action: actionName
|
|
5084
5205
|
};
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
}
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5206
|
+
this._jsCallFuncCallbacks[key] = {
|
|
5207
|
+
timeout: haveTimeout &&
|
|
5208
|
+
action.have_callback &&
|
|
5209
|
+
setTimeout(() => {
|
|
5210
|
+
this.onJSCall(key, timeoutCallback);
|
|
5211
|
+
}, 8000),
|
|
5212
|
+
callback: callback
|
|
5213
|
+
};
|
|
5214
|
+
try {
|
|
5215
|
+
options = serialize(options);
|
|
5216
|
+
if (isMultiCallback) {
|
|
5217
|
+
if (this._device.isIOS) {
|
|
5218
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
5219
|
+
}
|
|
5220
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
5221
|
+
}
|
|
5222
|
+
if (this._device.isIOS) {
|
|
5223
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
5224
|
+
}
|
|
5225
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
5097
5226
|
}
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5227
|
+
catch (error) {
|
|
5228
|
+
if (nRetry-- > 0) {
|
|
5229
|
+
setTimeout(() => {
|
|
5230
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, options, callback, isMultiCallback, nRetry);
|
|
5231
|
+
}, 500);
|
|
5232
|
+
}
|
|
5233
|
+
else {
|
|
5234
|
+
const errorCallback = {
|
|
5235
|
+
error_code: -5,
|
|
5236
|
+
error_message: 'Not ready!',
|
|
5237
|
+
data: {
|
|
5238
|
+
userAgent: this._userAgent,
|
|
5239
|
+
options: options,
|
|
5240
|
+
jsToken: this._jsAccessTk,
|
|
5241
|
+
access_token: this._accessTk
|
|
5242
|
+
},
|
|
5243
|
+
action: actionName,
|
|
5244
|
+
js_error: error
|
|
5245
|
+
};
|
|
5246
|
+
this.onJSCall(key, errorCallback);
|
|
5247
|
+
return false;
|
|
5248
|
+
}
|
|
5101
5249
|
}
|
|
5102
5250
|
}
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
return Promise.resolve(this.clearSync());
|
|
5106
|
-
});
|
|
5107
|
-
}
|
|
5108
|
-
clearSync() {
|
|
5109
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
5110
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
5111
|
-
return;
|
|
5112
|
-
}
|
|
5113
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
5114
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5115
|
-
});
|
|
5251
|
+
catch (error) {
|
|
5252
|
+
console.log('jsCall', 'error', error);
|
|
5116
5253
|
}
|
|
5117
|
-
|
|
5118
|
-
|
|
5254
|
+
return false;
|
|
5255
|
+
};
|
|
5119
5256
|
|
|
5120
|
-
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo;
|
|
5121
|
-
class NativeResourceStorage
|
|
5257
|
+
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo, _NativeResourceStorage_bridge;
|
|
5258
|
+
class NativeResourceStorage {
|
|
5122
5259
|
constructor(appId) {
|
|
5123
|
-
super();
|
|
5124
5260
|
_NativeResourceStorage_appId.set(this, void 0);
|
|
5125
5261
|
_NativeResourceStorage_resourceInfo.set(this, void 0);
|
|
5262
|
+
_NativeResourceStorage_bridge.set(this, void 0);
|
|
5126
5263
|
__classPrivateFieldSet(this, _NativeResourceStorage_resourceInfo, {
|
|
5127
5264
|
keys: new Set(),
|
|
5128
5265
|
currentSize: 0,
|
|
5129
5266
|
limitSize: STORAGE_LIMIT
|
|
5130
5267
|
}, "f");
|
|
5131
5268
|
__classPrivateFieldSet(this, _NativeResourceStorage_appId, appId, "f");
|
|
5269
|
+
__classPrivateFieldSet(this, _NativeResourceStorage_bridge, ZaloJSBridge.getInstance(), "f");
|
|
5132
5270
|
}
|
|
5133
5271
|
get(keys) {
|
|
5134
5272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5135
|
-
return yield this
|
|
5273
|
+
return yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5274
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5136
5275
|
mpds_action: 'mpds.get',
|
|
5137
5276
|
mpds_data: {
|
|
5138
5277
|
keys
|
|
@@ -5140,7 +5279,8 @@
|
|
|
5140
5279
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5141
5280
|
}, {
|
|
5142
5281
|
isMultiCallback: false
|
|
5143
|
-
})
|
|
5282
|
+
})
|
|
5283
|
+
.then((data) => {
|
|
5144
5284
|
let res = new Map();
|
|
5145
5285
|
if (data && data.mpds_data && data.mpds_data.map) {
|
|
5146
5286
|
res = new Map(Object.entries(data.mpds_data.map));
|
|
@@ -5151,7 +5291,8 @@
|
|
|
5151
5291
|
}
|
|
5152
5292
|
set(data) {
|
|
5153
5293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5154
|
-
const errorKeys = yield this
|
|
5294
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5295
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5155
5296
|
mpds_action: 'mpds.set',
|
|
5156
5297
|
mpds_data: {
|
|
5157
5298
|
map: data
|
|
@@ -5159,7 +5300,8 @@
|
|
|
5159
5300
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5160
5301
|
}, {
|
|
5161
5302
|
isMultiCallback: false
|
|
5162
|
-
})
|
|
5303
|
+
})
|
|
5304
|
+
.then((data) => {
|
|
5163
5305
|
let res = [];
|
|
5164
5306
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5165
5307
|
res = data.mpds_data.error_keys;
|
|
@@ -5171,13 +5313,15 @@
|
|
|
5171
5313
|
}
|
|
5172
5314
|
getInfo() {
|
|
5173
5315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5174
|
-
const currentSize = yield this
|
|
5316
|
+
const currentSize = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5317
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5175
5318
|
mpds_action: 'mpds.get.size',
|
|
5176
5319
|
mpds_data: {},
|
|
5177
5320
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5178
5321
|
}, {
|
|
5179
5322
|
isMultiCallback: false
|
|
5180
|
-
})
|
|
5323
|
+
})
|
|
5324
|
+
.then((data) => {
|
|
5181
5325
|
let res = 0;
|
|
5182
5326
|
if (data && data.mpds_data && data.mpds_data.size) {
|
|
5183
5327
|
res = data.mpds_data.size;
|
|
@@ -5192,7 +5336,8 @@
|
|
|
5192
5336
|
}
|
|
5193
5337
|
remove(keys) {
|
|
5194
5338
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5195
|
-
const errorKeys = yield this
|
|
5339
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5340
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5196
5341
|
mpds_action: 'mpds.remove.key',
|
|
5197
5342
|
mpds_data: {
|
|
5198
5343
|
keys: keys
|
|
@@ -5200,7 +5345,8 @@
|
|
|
5200
5345
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5201
5346
|
}, {
|
|
5202
5347
|
isMultiCallback: false
|
|
5203
|
-
})
|
|
5348
|
+
})
|
|
5349
|
+
.then((data) => {
|
|
5204
5350
|
let res = [];
|
|
5205
5351
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5206
5352
|
res = data.mpds_data.error_keys;
|
|
@@ -5212,7 +5358,7 @@
|
|
|
5212
5358
|
}
|
|
5213
5359
|
clear() {
|
|
5214
5360
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5215
|
-
yield this.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5361
|
+
yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f").callNative(ACTION.ZBROWSER_MPDS, {
|
|
5216
5362
|
mpds_action: 'mpds.clear.appData',
|
|
5217
5363
|
mpds_data: {},
|
|
5218
5364
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
@@ -5220,7 +5366,7 @@
|
|
|
5220
5366
|
});
|
|
5221
5367
|
}
|
|
5222
5368
|
}
|
|
5223
|
-
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap();
|
|
5369
|
+
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap(), _NativeResourceStorage_bridge = new WeakMap();
|
|
5224
5370
|
|
|
5225
5371
|
var _LocalStorageCreator_appId, _NativeStorageCreator_appId;
|
|
5226
5372
|
class StorageCreator {
|
|
@@ -5472,18 +5618,13 @@
|
|
|
5472
5618
|
*/
|
|
5473
5619
|
static getPhoneNumber(object) {
|
|
5474
5620
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5475
|
-
return yield this.callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5621
|
+
return yield this.getJSBridge().callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5476
5622
|
isMultiCallback: true,
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
return Promise.resolve(res);
|
|
5483
|
-
}
|
|
5484
|
-
else {
|
|
5485
|
-
return Promise.reject(error);
|
|
5486
|
-
}
|
|
5623
|
+
successCallback: (data) => {
|
|
5624
|
+
const res = {
|
|
5625
|
+
number: data
|
|
5626
|
+
};
|
|
5627
|
+
return Promise.resolve(res);
|
|
5487
5628
|
},
|
|
5488
5629
|
delay: this.isIOS ? 400 : 0
|
|
5489
5630
|
});
|
|
@@ -5502,7 +5643,7 @@
|
|
|
5502
5643
|
*/
|
|
5503
5644
|
static closeApp(object) {
|
|
5504
5645
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5505
|
-
yield this.callNative(ACTION.WINDOW_CLOSE, {});
|
|
5646
|
+
yield this.getJSBridge().callNative(ACTION.WINDOW_CLOSE, {});
|
|
5506
5647
|
});
|
|
5507
5648
|
}
|
|
5508
5649
|
/**
|
|
@@ -5534,7 +5675,7 @@
|
|
|
5534
5675
|
mpInfo.appName = appInfo.name;
|
|
5535
5676
|
mpInfo.appAvtUrl = appInfo.logoUrl;
|
|
5536
5677
|
}
|
|
5537
|
-
yield this.callNative(ACTION.OPEN_MP, {
|
|
5678
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_MP, {
|
|
5538
5679
|
mpUrl: `${MINI_APP_INTERNAL_LINK}/${appId}/${queryParamString.length > 0 ? '?' + queryParamString : ''}`,
|
|
5539
5680
|
mpInfo: mpInfo
|
|
5540
5681
|
});
|
|
@@ -5550,7 +5691,7 @@
|
|
|
5550
5691
|
*/
|
|
5551
5692
|
static openWebview(url) {
|
|
5552
5693
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5553
|
-
yield this.callNative(ACTION.OPEN_INAPP, {
|
|
5694
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_INAPP, {
|
|
5554
5695
|
url: url
|
|
5555
5696
|
});
|
|
5556
5697
|
});
|
|
@@ -5565,7 +5706,7 @@
|
|
|
5565
5706
|
*/
|
|
5566
5707
|
static closeLoading(when) {
|
|
5567
5708
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5568
|
-
yield this.callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5709
|
+
yield this.getJSBridge().callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5569
5710
|
at: new Date().getTime(),
|
|
5570
5711
|
when: when,
|
|
5571
5712
|
url: location.href
|
|
@@ -5592,30 +5733,24 @@
|
|
|
5592
5733
|
*/
|
|
5593
5734
|
static getLocation(object) {
|
|
5594
5735
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5595
|
-
return yield this.callNative(ACTION.GET_LOCATION, {
|
|
5736
|
+
return yield this.getJSBridge().callNative(ACTION.GET_LOCATION, {
|
|
5596
5737
|
silent_request: false,
|
|
5597
5738
|
permission_description: 'Cho phép Zalo truy cập vào vị trí của thiết bị này?'
|
|
5598
5739
|
}, {
|
|
5599
5740
|
isMultiCallback: true,
|
|
5600
5741
|
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
|
-
}
|
|
5742
|
+
successCallback: (data) => {
|
|
5743
|
+
const res = {
|
|
5744
|
+
/** latitude */
|
|
5745
|
+
latitude: data.latitude,
|
|
5746
|
+
/** longitude */
|
|
5747
|
+
longitude: data.longitude,
|
|
5748
|
+
/** timestamp */
|
|
5749
|
+
timestamp: data.timestamp,
|
|
5750
|
+
/** provider */
|
|
5751
|
+
provider: data.provider
|
|
5752
|
+
};
|
|
5753
|
+
return Promise.resolve(res);
|
|
5619
5754
|
},
|
|
5620
5755
|
delay: this.isIOS ? 400 : 0
|
|
5621
5756
|
});
|
|
@@ -5631,7 +5766,7 @@
|
|
|
5631
5766
|
*/
|
|
5632
5767
|
static sendLocation(object) {
|
|
5633
5768
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5634
|
-
yield this.callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5769
|
+
yield this.getJSBridge().callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5635
5770
|
title: object.title,
|
|
5636
5771
|
touserid: object.toUserId,
|
|
5637
5772
|
zapp: this.getZAppId()
|
|
@@ -5651,17 +5786,12 @@
|
|
|
5651
5786
|
*/
|
|
5652
5787
|
static requestCameraPermission(object) {
|
|
5653
5788
|
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
|
-
}
|
|
5789
|
+
return yield this.getJSBridge().callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5790
|
+
successCallback: () => {
|
|
5791
|
+
return Promise.resolve({
|
|
5792
|
+
userAllow: true,
|
|
5793
|
+
message: 'User Allow'
|
|
5794
|
+
});
|
|
5665
5795
|
}
|
|
5666
5796
|
});
|
|
5667
5797
|
});
|
|
@@ -5687,7 +5817,7 @@
|
|
|
5687
5817
|
imageUrl: object.imageUrl
|
|
5688
5818
|
};
|
|
5689
5819
|
}
|
|
5690
|
-
return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5820
|
+
return yield this.getJSBridge().callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5691
5821
|
});
|
|
5692
5822
|
}
|
|
5693
5823
|
}
|
|
@@ -5702,7 +5832,7 @@
|
|
|
5702
5832
|
*/
|
|
5703
5833
|
static viewOAQr(object) {
|
|
5704
5834
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5705
|
-
yield this.callNative(ACTION.VIEW_MYQR, {
|
|
5835
|
+
yield this.getJSBridge().callNative(ACTION.VIEW_MYQR, {
|
|
5706
5836
|
dpn: object.displayName,
|
|
5707
5837
|
uid: object.id,
|
|
5708
5838
|
zapp: this.getZAppId()
|
|
@@ -5721,7 +5851,7 @@
|
|
|
5721
5851
|
*/
|
|
5722
5852
|
static openProfile(object) {
|
|
5723
5853
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5724
|
-
return yield this.callNative(ACTION.OPEN_PROFILE, {
|
|
5854
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_PROFILE, {
|
|
5725
5855
|
uId: object.id,
|
|
5726
5856
|
type: ProfileType[object.type],
|
|
5727
5857
|
zapp: this.getZAppId(),
|
|
@@ -5739,7 +5869,7 @@
|
|
|
5739
5869
|
*/
|
|
5740
5870
|
static openChat(object) {
|
|
5741
5871
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5742
|
-
return yield this.callNative(ACTION.OPEN_CHAT, {
|
|
5872
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_CHAT, {
|
|
5743
5873
|
uId: object.id,
|
|
5744
5874
|
type: ChatType[object.type],
|
|
5745
5875
|
msg: object.message || '',
|
|
@@ -5781,7 +5911,9 @@
|
|
|
5781
5911
|
};
|
|
5782
5912
|
break;
|
|
5783
5913
|
}
|
|
5784
|
-
return yield this.
|
|
5914
|
+
return yield this.getJSBridge()
|
|
5915
|
+
.callNative(ACTION.OPEN_POSTFEED, Object.assign(Object.assign({ type: PostFeedType[object.type] }, reqData), { zapp: this.getZAppId() }))
|
|
5916
|
+
.then((res) => {
|
|
5785
5917
|
return {
|
|
5786
5918
|
status: res.status,
|
|
5787
5919
|
shareType: res.share_type,
|
|
@@ -5800,7 +5932,7 @@
|
|
|
5800
5932
|
*/
|
|
5801
5933
|
static followOA(object) {
|
|
5802
5934
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5803
|
-
yield this.callNative(ACTION.FOLLOW_OA, {
|
|
5935
|
+
yield this.getJSBridge().callNative(ACTION.FOLLOW_OA, {
|
|
5804
5936
|
uid: object.id,
|
|
5805
5937
|
showDialogConfirm: true,
|
|
5806
5938
|
zapp: this.getZAppId()
|
|
@@ -5819,7 +5951,7 @@
|
|
|
5819
5951
|
*/
|
|
5820
5952
|
static unfollowOA(object) {
|
|
5821
5953
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5822
|
-
yield this.callNative(ACTION.UNFOLLOW_OA, {
|
|
5954
|
+
yield this.getJSBridge().callNative(ACTION.UNFOLLOW_OA, {
|
|
5823
5955
|
uid: object.id,
|
|
5824
5956
|
zapp: this.getZAppId()
|
|
5825
5957
|
}, {
|
|
@@ -5838,10 +5970,17 @@
|
|
|
5838
5970
|
static openShareSheet(object) {
|
|
5839
5971
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5840
5972
|
let reqData = {};
|
|
5973
|
+
let type = object.type;
|
|
5841
5974
|
switch (object.type) {
|
|
5842
5975
|
case 'image':
|
|
5843
5976
|
let photoUrls = [];
|
|
5844
|
-
|
|
5977
|
+
const zaloVersion = getZaloVersion();
|
|
5978
|
+
const platform = getPlatform();
|
|
5979
|
+
if (zaloVersion >= ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION[platform]) {
|
|
5980
|
+
type = 'multi_image';
|
|
5981
|
+
}
|
|
5982
|
+
if (Array.isArray(object.data.imageUrls) &&
|
|
5983
|
+
object.data.imageUrls.length > 0) {
|
|
5845
5984
|
photoUrls = object.data.imageUrls;
|
|
5846
5985
|
}
|
|
5847
5986
|
else {
|
|
@@ -5908,9 +6047,11 @@
|
|
|
5908
6047
|
object.type = 'link';
|
|
5909
6048
|
}
|
|
5910
6049
|
}
|
|
5911
|
-
return yield this.
|
|
6050
|
+
return yield this.getJSBridge()
|
|
6051
|
+
.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[type] }, reqData), { zapp: this.getZAppId() }), {
|
|
5912
6052
|
haveTimeout: false
|
|
5913
|
-
})
|
|
6053
|
+
})
|
|
6054
|
+
.then((res) => {
|
|
5914
6055
|
return {
|
|
5915
6056
|
status: res.status,
|
|
5916
6057
|
shareType: res.share_type,
|
|
@@ -5929,7 +6070,7 @@
|
|
|
5929
6070
|
*/
|
|
5930
6071
|
static createShortcut(url, title, icon) {
|
|
5931
6072
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5932
|
-
return yield this.callNative(ACTION.CREATE_SHORTCUT, {
|
|
6073
|
+
return yield this.getJSBridge().callNative(ACTION.CREATE_SHORTCUT, {
|
|
5933
6074
|
url: url,
|
|
5934
6075
|
title: title,
|
|
5935
6076
|
iconUrl: icon
|
|
@@ -5946,15 +6087,14 @@
|
|
|
5946
6087
|
*/
|
|
5947
6088
|
static openProfilePicker(maxProfile) {
|
|
5948
6089
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5949
|
-
return yield this.callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
6090
|
+
return yield this.getJSBridge().callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
5950
6091
|
maxProfile: maxProfile
|
|
5951
6092
|
}, {
|
|
5952
6093
|
isMultiCallback: true,
|
|
5953
|
-
|
|
5954
|
-
if (
|
|
5955
|
-
return Promise.resolve(
|
|
6094
|
+
successCallback: (data) => {
|
|
6095
|
+
if (Array.isArray(data)) {
|
|
6096
|
+
return Promise.resolve(data.map((item) => item.id));
|
|
5956
6097
|
}
|
|
5957
|
-
return Promise.reject(error);
|
|
5958
6098
|
}
|
|
5959
6099
|
});
|
|
5960
6100
|
});
|
|
@@ -5969,15 +6109,15 @@
|
|
|
5969
6109
|
*/
|
|
5970
6110
|
static getActionsSupported(object) {
|
|
5971
6111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5972
|
-
return yield this.callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
6112
|
+
return yield this.getJSBridge().callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
5973
6113
|
isMultiCallback: false,
|
|
5974
|
-
|
|
6114
|
+
successCallback: (data) => {
|
|
5975
6115
|
const platform = getPlatform();
|
|
5976
|
-
if (Array.isArray(
|
|
5977
|
-
|
|
6116
|
+
if (Array.isArray(data.actions) &&
|
|
6117
|
+
data.actions.length > 0) {
|
|
5978
6118
|
const skipJumpActions = Object.keys(ACTION).filter((item) => ACTION[item].skip_jump);
|
|
5979
6119
|
const res = {
|
|
5980
|
-
actions: [...
|
|
6120
|
+
actions: [...data.actions, ...skipJumpActions]
|
|
5981
6121
|
};
|
|
5982
6122
|
return Promise.resolve(res);
|
|
5983
6123
|
}
|
|
@@ -5987,7 +6127,6 @@
|
|
|
5987
6127
|
};
|
|
5988
6128
|
return Promise.resolve(res);
|
|
5989
6129
|
}
|
|
5990
|
-
return Promise.reject(error);
|
|
5991
6130
|
}
|
|
5992
6131
|
});
|
|
5993
6132
|
});
|
|
@@ -6011,7 +6150,7 @@
|
|
|
6011
6150
|
enable: 1,
|
|
6012
6151
|
aspect_ratio: '1:1'
|
|
6013
6152
|
};
|
|
6014
|
-
return yield this.callNative(ACTION.PICK_MEDIA, {
|
|
6153
|
+
return yield this.getJSBridge().callNative(ACTION.PICK_MEDIA, {
|
|
6015
6154
|
media_type: MediaPickerType[type],
|
|
6016
6155
|
edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
|
|
6017
6156
|
silent_request: silentRequest,
|
|
@@ -6019,15 +6158,11 @@
|
|
|
6019
6158
|
max_select_items: maxSelectItem
|
|
6020
6159
|
}, {
|
|
6021
6160
|
isMultiCallback: true,
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
};
|
|
6028
|
-
return Promise.resolve(res);
|
|
6029
|
-
}
|
|
6030
|
-
return Promise.reject(error);
|
|
6161
|
+
successCallback: (data) => {
|
|
6162
|
+
const res = {
|
|
6163
|
+
data: data === null || data === void 0 ? void 0 : data.result_content
|
|
6164
|
+
};
|
|
6165
|
+
return Promise.resolve(res);
|
|
6031
6166
|
}
|
|
6032
6167
|
});
|
|
6033
6168
|
});
|
|
@@ -6042,7 +6177,7 @@
|
|
|
6042
6177
|
*/
|
|
6043
6178
|
static openOutApp(url) {
|
|
6044
6179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6045
|
-
return yield this.callNative(ACTION.OPEN_OUTAPP, {
|
|
6180
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_OUTAPP, {
|
|
6046
6181
|
url: url
|
|
6047
6182
|
});
|
|
6048
6183
|
});
|
|
@@ -6081,7 +6216,7 @@
|
|
|
6081
6216
|
*/
|
|
6082
6217
|
static sendDataToPreviousMiniApp(object) {
|
|
6083
6218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6084
|
-
return yield this.callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6219
|
+
return yield this.getJSBridge().callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6085
6220
|
result: stringifyData(object.data)
|
|
6086
6221
|
});
|
|
6087
6222
|
});
|
|
@@ -6106,11 +6241,10 @@
|
|
|
6106
6241
|
}
|
|
6107
6242
|
}
|
|
6108
6243
|
|
|
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
|
|
6244
|
+
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;
|
|
6245
|
+
class ZaloMiniProgramSDKService {
|
|
6111
6246
|
constructor() {
|
|
6112
6247
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6113
|
-
super();
|
|
6114
6248
|
_ZaloMiniProgramSDKService_zAppId.set(this, ZAPP_ID);
|
|
6115
6249
|
_ZaloMiniProgramSDKService_appId.set(this, APP_ID);
|
|
6116
6250
|
_ZaloMiniProgramSDKService_appConfig.set(this, APP_CONFIG);
|
|
@@ -6123,9 +6257,9 @@
|
|
|
6123
6257
|
getToken: 0
|
|
6124
6258
|
}
|
|
6125
6259
|
});
|
|
6260
|
+
_ZaloMiniProgramSDKService_bridge.set(this, void 0);
|
|
6126
6261
|
_ZaloMiniProgramSDKService_prevGetTokenTimestamp.set(this, void 0);
|
|
6127
6262
|
_ZaloMiniProgramSDKService_tokenExpiresIn.set(this, void 0);
|
|
6128
|
-
_ZaloMiniProgramSDKService_cookies.set(this, null);
|
|
6129
6263
|
_ZaloMiniProgramSDKService_deviceId.set(this, void 0);
|
|
6130
6264
|
this.events = ZMPEEmitter.getInstance();
|
|
6131
6265
|
this.isIOS = checkPlatform().isIOS;
|
|
@@ -6136,34 +6270,6 @@
|
|
|
6136
6270
|
this.setActionBarConfig = (setState) => {
|
|
6137
6271
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
|
|
6138
6272
|
};
|
|
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
6273
|
this.getVersion = Basics.getVersion;
|
|
6168
6274
|
this.getSystemInfo = Basics.getSystemInfo;
|
|
6169
6275
|
this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
|
|
@@ -6234,6 +6340,7 @@
|
|
|
6234
6340
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, 0, "f");
|
|
6235
6341
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, 0, "f");
|
|
6236
6342
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, '', "f");
|
|
6343
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_bridge, ZaloJSBridge.getInstance(), "f");
|
|
6237
6344
|
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
6345
|
((_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
6346
|
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
@@ -6280,9 +6387,16 @@
|
|
|
6280
6387
|
getDeviceId() {
|
|
6281
6388
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
|
|
6282
6389
|
}
|
|
6390
|
+
getJSBridge() {
|
|
6391
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
|
|
6392
|
+
}
|
|
6283
6393
|
login(object) {
|
|
6284
6394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6285
|
-
const cookies = yield __classPrivateFieldGet(this,
|
|
6395
|
+
const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
|
|
6396
|
+
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6397
|
+
if (deviceId) {
|
|
6398
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6399
|
+
}
|
|
6286
6400
|
const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
|
|
6287
6401
|
const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
|
|
6288
6402
|
if (!_.isUndefined(zOAuthCookie) &&
|
|
@@ -6299,23 +6413,23 @@
|
|
|
6299
6413
|
yield this.loginZaloV3();
|
|
6300
6414
|
}
|
|
6301
6415
|
if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
|
|
6302
|
-
throw apiResponse.error.loginFailed();
|
|
6416
|
+
throw apiResponse.error.loginFailed('Invalid authorization code');
|
|
6303
6417
|
}
|
|
6304
6418
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
6305
6419
|
}
|
|
6306
|
-
throw apiResponse.error.loginFailed();
|
|
6420
|
+
throw apiResponse.error.loginFailed('Zalo app has not been activated');
|
|
6307
6421
|
});
|
|
6308
6422
|
}
|
|
6309
6423
|
loginZaloV3() {
|
|
6310
6424
|
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=
|
|
6425
|
+
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
6426
|
let resData = yield response.json();
|
|
6313
6427
|
if (resData.access_token) {
|
|
6314
6428
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, resData.access_token, "f");
|
|
6315
6429
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6316
6430
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6317
6431
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6318
|
-
this.
|
|
6432
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6319
6433
|
window.ZJSBridge.setZAccSession &&
|
|
6320
6434
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6321
6435
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6352,7 +6466,7 @@
|
|
|
6352
6466
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6353
6467
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6354
6468
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6355
|
-
this.
|
|
6469
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6356
6470
|
window.ZJSBridge.setZAccSession &&
|
|
6357
6471
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6358
6472
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6373,7 +6487,7 @@
|
|
|
6373
6487
|
});
|
|
6374
6488
|
}
|
|
6375
6489
|
}
|
|
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(),
|
|
6490
|
+
_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
6491
|
|
|
6378
6492
|
var _MockSDKService_appId, _MockSDKService_appConfig, _MockSDKService_zOAuth, _MockSDKService_accessToken, _MockSDKService_cache, _MockSDKService_loggedId;
|
|
6379
6493
|
class MockSDKService {
|
|
@@ -6749,90 +6863,175 @@
|
|
|
6749
6863
|
.replace(/\s/gi, '')
|
|
6750
6864
|
.split(',');
|
|
6751
6865
|
}
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6866
|
+
/**
|
|
6867
|
+
* Copies all metadata from one object to another.
|
|
6868
|
+
* Useful for overwriting function definition in
|
|
6869
|
+
* decorators while keeping all previously
|
|
6870
|
+
* attached metadata
|
|
6871
|
+
*
|
|
6872
|
+
* @param from object to copy metadata from
|
|
6873
|
+
* @param to object to copy metadata to
|
|
6874
|
+
*/
|
|
6875
|
+
function copyMetadata(from, to) {
|
|
6876
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
6877
|
+
metadataKeys.map((key) => {
|
|
6878
|
+
const value = Reflect.getMetadata(key, from);
|
|
6879
|
+
Reflect.defineMetadata(key, value, to);
|
|
6880
|
+
});
|
|
6881
|
+
}
|
|
6882
|
+
/**
|
|
6883
|
+
* Apply the given decorator to all class methods
|
|
6884
|
+
*
|
|
6885
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
6886
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
6887
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
6888
|
+
*/
|
|
6889
|
+
const DecorateAll = (decorator, options = {}) => {
|
|
6890
|
+
return (target) => {
|
|
6891
|
+
var _a;
|
|
6892
|
+
let descriptors = Object.getOwnPropertyDescriptors(target.prototype);
|
|
6893
|
+
if (options.deep) {
|
|
6894
|
+
let base = Object.getPrototypeOf(target);
|
|
6895
|
+
while (base.prototype) {
|
|
6896
|
+
const baseDescriptors = Object.getOwnPropertyDescriptors(base.prototype);
|
|
6897
|
+
descriptors = Object.assign(Object.assign({}, baseDescriptors), descriptors);
|
|
6898
|
+
base = Object.getPrototypeOf(base);
|
|
6899
|
+
}
|
|
6900
|
+
}
|
|
6901
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
6902
|
+
const isMethod = typeof descriptor.value == 'function' && propName != 'constructor';
|
|
6903
|
+
if ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(propName))
|
|
6904
|
+
continue;
|
|
6905
|
+
if (options.excludePrefix && propName.startsWith(options.excludePrefix))
|
|
6906
|
+
continue;
|
|
6907
|
+
if (!isMethod)
|
|
6908
|
+
continue;
|
|
6909
|
+
const originalMethod = descriptor.value;
|
|
6910
|
+
decorator(target, propName, descriptor);
|
|
6911
|
+
if (originalMethod != descriptor.value) {
|
|
6912
|
+
copyMetadata(originalMethod, descriptor.value);
|
|
6913
|
+
}
|
|
6914
|
+
Object.defineProperty(target.prototype, propName, descriptor);
|
|
6915
|
+
}
|
|
6916
|
+
};
|
|
6917
|
+
};
|
|
6918
|
+
const centralizedFunctionHandler = (target, propertyName, descriptor) => {
|
|
6919
|
+
const fn = descriptor.value;
|
|
6920
|
+
const argsName = getFnParamNames(fn);
|
|
6921
|
+
descriptor.value = function (...args) {
|
|
6922
|
+
try {
|
|
6923
|
+
// begin validation
|
|
6924
|
+
const requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target.prototype, propertyName);
|
|
6925
|
+
const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target.prototype, propertyName);
|
|
6926
|
+
if (checkTypeParameters) {
|
|
6927
|
+
checkTypeParameters.forEach((parameter) => {
|
|
6928
|
+
const { parameterIndex, type, properties, defaultValue } = parameter;
|
|
6929
|
+
let argument = args[parameterIndex];
|
|
6930
|
+
let argumentName = argsName[parameterIndex];
|
|
6931
|
+
const parameterType = typeof argument;
|
|
6932
|
+
if (!_.isUndefined(argument)) {
|
|
6933
|
+
if (!isType(argument, type)) {
|
|
6934
|
+
throw apiResponse.error.wrongTypeParam(argumentName, type, Array.isArray(argument)
|
|
6935
|
+
? 'array'
|
|
6936
|
+
: argument === null
|
|
6937
|
+
? 'null'
|
|
6938
|
+
: parameterType);
|
|
6939
|
+
}
|
|
6940
|
+
if (type === 'object') {
|
|
6941
|
+
Object.entries(properties).forEach(([propKey, propType]) => {
|
|
6942
|
+
const key = propKey.split('?')[0];
|
|
6943
|
+
const propValue = _.get(argument, key);
|
|
6944
|
+
if (!_.isUndefined(propValue) && !_.isNull(propValue)) {
|
|
6945
|
+
if (_.isFunction(propType)) {
|
|
6946
|
+
const res = propType(propValue);
|
|
6947
|
+
if (res && res.error) {
|
|
6948
|
+
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
else if (!propKey.includes('?')) {
|
|
6953
|
+
throw apiResponse.error.missingParam(propKey);
|
|
6954
|
+
}
|
|
6955
|
+
else if (!_.get(argument, key.split('.')[0]) &&
|
|
6956
|
+
defaultValue &&
|
|
6957
|
+
!_.isUndefined(_.get(defaultValue, key))) {
|
|
6958
|
+
_.set(args[parameterIndex], key, _.get(defaultValue, key));
|
|
6959
|
+
}
|
|
6960
|
+
});
|
|
6961
|
+
}
|
|
6962
|
+
}
|
|
6963
|
+
});
|
|
6964
|
+
}
|
|
6965
|
+
if (requiredParameters) {
|
|
6966
|
+
requiredParameters.forEach((parameter) => {
|
|
6967
|
+
const { parameterIndex, option, fields } = parameter;
|
|
6968
|
+
const argument = args[parameterIndex];
|
|
6969
|
+
const condition = option === null || option === void 0 ? void 0 : option.if;
|
|
6970
|
+
const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
|
|
6971
|
+
let isMeetCondition = true;
|
|
6972
|
+
if (condition) {
|
|
6973
|
+
isMeetCondition = Object.keys(condition).every((key) => _.get(argument, key) === condition[key]);
|
|
6771
6974
|
}
|
|
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);
|
|
6975
|
+
if (isMeetCondition) {
|
|
6976
|
+
fields.forEach((item) => {
|
|
6977
|
+
const isInValidField = (field) => {
|
|
6978
|
+
let isInValid = false;
|
|
6979
|
+
if (_.isEmpty(_.get(argument, field))) {
|
|
6980
|
+
if (!_.isUndefined(_.get(defaultValue, field))) {
|
|
6981
|
+
_.set(args[parameterIndex], field, _.get(defaultValue, field));
|
|
6781
6982
|
}
|
|
6983
|
+
isInValid = true;
|
|
6782
6984
|
}
|
|
6985
|
+
return isInValid;
|
|
6986
|
+
};
|
|
6987
|
+
if (Array.isArray(item) &&
|
|
6988
|
+
item.length > 0 &&
|
|
6989
|
+
item.every(isInValidField)) {
|
|
6990
|
+
throw apiResponse.error.missingParam(item.join(' or '));
|
|
6783
6991
|
}
|
|
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));
|
|
6992
|
+
else if (_.isString(item) && isInValidField(item)) {
|
|
6993
|
+
throw apiResponse.error.missingParam(item);
|
|
6791
6994
|
}
|
|
6792
6995
|
});
|
|
6793
6996
|
}
|
|
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 '));
|
|
6997
|
+
});
|
|
6998
|
+
}
|
|
6999
|
+
// end validation
|
|
7000
|
+
const res = fn.call(this, ...args);
|
|
7001
|
+
if (_.isPromise(res)) {
|
|
7002
|
+
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
7003
|
+
return new Promise((resolve, reject) => {
|
|
7004
|
+
res
|
|
7005
|
+
.then((data) => {
|
|
7006
|
+
if (!_.isNull(success) && _.isFunction(success)) {
|
|
7007
|
+
success.call(null, data, this);
|
|
7008
|
+
}
|
|
7009
|
+
else {
|
|
7010
|
+
resolve(res);
|
|
7011
|
+
}
|
|
7012
|
+
})
|
|
7013
|
+
.catch((error) => {
|
|
7014
|
+
const errorParsed = errorHandler(error, propertyName);
|
|
7015
|
+
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
7016
|
+
fail.call(null, errorParsed, this);
|
|
6821
7017
|
}
|
|
6822
|
-
else
|
|
6823
|
-
|
|
7018
|
+
else {
|
|
7019
|
+
reject(errorParsed);
|
|
6824
7020
|
}
|
|
6825
7021
|
});
|
|
6826
|
-
}
|
|
6827
|
-
}
|
|
7022
|
+
});
|
|
7023
|
+
}
|
|
7024
|
+
return res;
|
|
7025
|
+
}
|
|
7026
|
+
catch (error) {
|
|
7027
|
+
throw errorHandler(error, propertyName);
|
|
6828
7028
|
}
|
|
6829
|
-
return method.apply(this, arguments);
|
|
6830
7029
|
};
|
|
6831
7030
|
return descriptor;
|
|
6832
7031
|
};
|
|
6833
7032
|
|
|
6834
7033
|
var _SDKCreator_sdkService;
|
|
6835
|
-
class SDKCreator {
|
|
7034
|
+
let SDKCreator = class SDKCreator {
|
|
6836
7035
|
constructor() {
|
|
6837
7036
|
this.events = ZMPEEmitter.getInstance();
|
|
6838
7037
|
_SDKCreator_sdkService.set(this, void 0);
|
|
@@ -6893,7 +7092,7 @@
|
|
|
6893
7092
|
}
|
|
6894
7093
|
setNavigationBarTitle(object) {
|
|
6895
7094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6896
|
-
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
7095
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
6897
7096
|
});
|
|
6898
7097
|
}
|
|
6899
7098
|
setNavigationBarColor(object) {
|
|
@@ -7163,6 +7362,7 @@
|
|
|
7163
7362
|
}
|
|
7164
7363
|
vibrate(object) {
|
|
7165
7364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7365
|
+
console.log(object);
|
|
7166
7366
|
yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
|
|
7167
7367
|
});
|
|
7168
7368
|
}
|
|
@@ -7318,33 +7518,14 @@
|
|
|
7318
7518
|
getDeviceId() {
|
|
7319
7519
|
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
|
|
7320
7520
|
}
|
|
7321
|
-
}
|
|
7521
|
+
};
|
|
7322
7522
|
_SDKCreator_sdkService = new WeakMap();
|
|
7323
7523
|
__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
7524
|
__param(0, checkType('object', {
|
|
7342
7525
|
title: checkData('string')
|
|
7343
7526
|
}))
|
|
7344
7527
|
], SDKCreator.prototype, "setNavigationBarTitle", null);
|
|
7345
7528
|
__decorate([
|
|
7346
|
-
handleError,
|
|
7347
|
-
validate,
|
|
7348
7529
|
__param(0, checkType('object', {
|
|
7349
7530
|
color: checkData('string'),
|
|
7350
7531
|
'textColor?': checkData('string', { values: ['white', 'black'] }),
|
|
@@ -7352,57 +7533,37 @@
|
|
|
7352
7533
|
}))
|
|
7353
7534
|
], SDKCreator.prototype, "setNavigationBarColor", null);
|
|
7354
7535
|
__decorate([
|
|
7355
|
-
handleError,
|
|
7356
|
-
validate,
|
|
7357
7536
|
__param(0, checkType('object', {
|
|
7358
7537
|
backgroundColor: checkData('string'),
|
|
7359
7538
|
'textColor?': checkData('string', { values: ['white', 'black'] })
|
|
7360
7539
|
}))
|
|
7361
7540
|
], SDKCreator.prototype, "setBackgroundColor", null);
|
|
7362
7541
|
__decorate([
|
|
7363
|
-
handleError,
|
|
7364
|
-
validate,
|
|
7365
7542
|
__param(0, checkType('object', {
|
|
7366
7543
|
type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
|
|
7367
7544
|
}))
|
|
7368
7545
|
], SDKCreator.prototype, "setNavigationBarLeftButton", null);
|
|
7369
7546
|
__decorate([
|
|
7370
|
-
handleError,
|
|
7371
|
-
validate,
|
|
7372
7547
|
__param(0, checkType('object', {
|
|
7373
7548
|
rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
|
|
7374
7549
|
}))
|
|
7375
7550
|
], SDKCreator.prototype, "setDeviceOrientation", null);
|
|
7376
7551
|
__decorate([
|
|
7377
|
-
handleError,
|
|
7378
|
-
validate,
|
|
7379
7552
|
__param(0, checkType('object', {
|
|
7380
7553
|
data: checkData('object')
|
|
7381
7554
|
}))
|
|
7382
7555
|
], SDKCreator.prototype, "setStorage", null);
|
|
7383
7556
|
__decorate([
|
|
7384
|
-
handleError,
|
|
7385
|
-
validate,
|
|
7386
7557
|
__param(0, checkType('object', {
|
|
7387
7558
|
keys: checkData('array<string>')
|
|
7388
7559
|
}))
|
|
7389
7560
|
], SDKCreator.prototype, "getStorage", null);
|
|
7390
7561
|
__decorate([
|
|
7391
|
-
handleError
|
|
7392
|
-
], SDKCreator.prototype, "getStorageInfo", null);
|
|
7393
|
-
__decorate([
|
|
7394
|
-
handleError,
|
|
7395
|
-
validate,
|
|
7396
7562
|
__param(0, checkType('object', {
|
|
7397
7563
|
keys: checkData('array<string>')
|
|
7398
7564
|
}))
|
|
7399
7565
|
], SDKCreator.prototype, "removeStorage", null);
|
|
7400
7566
|
__decorate([
|
|
7401
|
-
handleError
|
|
7402
|
-
], SDKCreator.prototype, "clearStorage", null);
|
|
7403
|
-
__decorate([
|
|
7404
|
-
handleError,
|
|
7405
|
-
validate,
|
|
7406
7567
|
__param(0, checkType('object', {
|
|
7407
7568
|
'avatarType?': checkData('string', {
|
|
7408
7569
|
values: ['small', 'normal', 'large']
|
|
@@ -7410,67 +7571,12 @@
|
|
|
7410
7571
|
}))
|
|
7411
7572
|
], SDKCreator.prototype, "getUserInfo", null);
|
|
7412
7573
|
__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
7574
|
__param(0, checkType('object', {
|
|
7467
7575
|
type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
|
|
7468
7576
|
id: checkData('string')
|
|
7469
7577
|
}))
|
|
7470
7578
|
], SDKCreator.prototype, "openProfile", null);
|
|
7471
7579
|
__decorate([
|
|
7472
|
-
handleError,
|
|
7473
|
-
validate,
|
|
7474
7580
|
__param(0, checkType('object', {
|
|
7475
7581
|
type: checkData('string', { values: ['user', 'oa'] }),
|
|
7476
7582
|
id: checkData('string'),
|
|
@@ -7478,8 +7584,6 @@
|
|
|
7478
7584
|
}))
|
|
7479
7585
|
], SDKCreator.prototype, "openChat", null);
|
|
7480
7586
|
__decorate([
|
|
7481
|
-
handleError,
|
|
7482
|
-
validate,
|
|
7483
7587
|
__param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
|
|
7484
7588
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
7485
7589
|
__param(0, required(['data.id'], { if: { type: 'profile' } })),
|
|
@@ -7497,23 +7601,17 @@
|
|
|
7497
7601
|
}))
|
|
7498
7602
|
], SDKCreator.prototype, "openPostFeed", null);
|
|
7499
7603
|
__decorate([
|
|
7500
|
-
handleError,
|
|
7501
|
-
validate,
|
|
7502
7604
|
__param(0, checkType('object', {
|
|
7503
7605
|
id: checkData('string'),
|
|
7504
7606
|
'showDialogConfirm?': checkData('boolean')
|
|
7505
7607
|
}))
|
|
7506
7608
|
], SDKCreator.prototype, "followOA", null);
|
|
7507
7609
|
__decorate([
|
|
7508
|
-
handleError,
|
|
7509
|
-
validate,
|
|
7510
7610
|
__param(0, checkType('object', {
|
|
7511
7611
|
id: checkData('string')
|
|
7512
7612
|
}))
|
|
7513
7613
|
], SDKCreator.prototype, "unfollowOA", null);
|
|
7514
7614
|
__decorate([
|
|
7515
|
-
handleError,
|
|
7516
|
-
validate,
|
|
7517
7615
|
__param(0, required([['data.imageUrl', 'data.imageUrls']], { if: { type: 'image' } })),
|
|
7518
7616
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
7519
7617
|
__param(0, required(['data.id'], { if: { type: 'oa' } })),
|
|
@@ -7552,14 +7650,6 @@
|
|
|
7552
7650
|
}))
|
|
7553
7651
|
], SDKCreator.prototype, "openShareSheet", null);
|
|
7554
7652
|
__decorate([
|
|
7555
|
-
handleError
|
|
7556
|
-
], SDKCreator.prototype, "requestCameraPermission", null);
|
|
7557
|
-
__decorate([
|
|
7558
|
-
handleError
|
|
7559
|
-
], SDKCreator.prototype, "createShortcut", null);
|
|
7560
|
-
__decorate([
|
|
7561
|
-
handleError,
|
|
7562
|
-
validate,
|
|
7563
7653
|
__param(0, checkType('object', {
|
|
7564
7654
|
secretData: checkData('string'),
|
|
7565
7655
|
'ui?': checkData('object'),
|
|
@@ -7577,44 +7667,28 @@
|
|
|
7577
7667
|
}))
|
|
7578
7668
|
], SDKCreator.prototype, "openBioAuthentication", null);
|
|
7579
7669
|
__decorate([
|
|
7580
|
-
handleError
|
|
7581
|
-
], SDKCreator.prototype, "checkStateBioAuthentication", null);
|
|
7582
|
-
__decorate([
|
|
7583
|
-
handleError,
|
|
7584
|
-
validate,
|
|
7585
7670
|
__param(0, checkType('object', {
|
|
7586
7671
|
toUserId: checkData('string'),
|
|
7587
7672
|
'title?': checkData('string')
|
|
7588
7673
|
}))
|
|
7589
7674
|
], SDKCreator.prototype, "sendLocation", null);
|
|
7590
7675
|
__decorate([
|
|
7591
|
-
handleError,
|
|
7592
|
-
validate,
|
|
7593
7676
|
__param(0, checkType('object', {
|
|
7594
7677
|
message: checkData('string')
|
|
7595
7678
|
}))
|
|
7596
7679
|
], SDKCreator.prototype, "showToast", null);
|
|
7597
7680
|
__decorate([
|
|
7598
|
-
handleError
|
|
7599
|
-
], SDKCreator.prototype, "hideKeyboard", null);
|
|
7600
|
-
__decorate([
|
|
7601
|
-
handleError,
|
|
7602
|
-
validate,
|
|
7603
7681
|
__param(0, checkType('object', {
|
|
7604
7682
|
phoneNumber: checkData('string')
|
|
7605
7683
|
}))
|
|
7606
7684
|
], SDKCreator.prototype, "openPhone", null);
|
|
7607
7685
|
__decorate([
|
|
7608
|
-
handleError,
|
|
7609
|
-
validate,
|
|
7610
7686
|
__param(0, checkType('object', {
|
|
7611
7687
|
content: checkData('string'),
|
|
7612
7688
|
phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
|
|
7613
7689
|
}))
|
|
7614
7690
|
], SDKCreator.prototype, "openSMS", null);
|
|
7615
7691
|
__decorate([
|
|
7616
|
-
handleError,
|
|
7617
|
-
validate,
|
|
7618
7692
|
__param(0, checkType('object', {
|
|
7619
7693
|
id: checkData('string'),
|
|
7620
7694
|
'displayName?': checkData('string')
|
|
@@ -7623,35 +7697,24 @@
|
|
|
7623
7697
|
}))
|
|
7624
7698
|
], SDKCreator.prototype, "viewOAQr", null);
|
|
7625
7699
|
__decorate([
|
|
7626
|
-
handleError
|
|
7627
|
-
], SDKCreator.prototype, "keepScreen", null);
|
|
7628
|
-
__decorate([
|
|
7629
|
-
handleError,
|
|
7630
|
-
validate,
|
|
7631
7700
|
__param(0, checkType('object', {
|
|
7632
7701
|
'imageBase64Data?': checkData('string'),
|
|
7633
7702
|
'imageUrl?': checkData('url')
|
|
7634
7703
|
}))
|
|
7635
7704
|
], SDKCreator.prototype, "saveImageToGallery", null);
|
|
7636
7705
|
__decorate([
|
|
7637
|
-
handleError,
|
|
7638
|
-
validate,
|
|
7639
7706
|
__param(0, checkType('object', {
|
|
7640
7707
|
'imageBase64Data?': checkData('string'),
|
|
7641
7708
|
'imageUrl?': checkData('url')
|
|
7642
7709
|
}))
|
|
7643
7710
|
], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
|
|
7644
7711
|
__decorate([
|
|
7645
|
-
handleError,
|
|
7646
|
-
validate,
|
|
7647
7712
|
__param(0, checkType('object', {
|
|
7648
7713
|
appId: checkData('string'),
|
|
7649
7714
|
'params?': checkData('object')
|
|
7650
7715
|
}))
|
|
7651
7716
|
], SDKCreator.prototype, "openMiniApp", null);
|
|
7652
7717
|
__decorate([
|
|
7653
|
-
handleError,
|
|
7654
|
-
validate,
|
|
7655
7718
|
__param(0, checkType('object', {
|
|
7656
7719
|
'type?': checkData('string', { values: ['oneShot'] }),
|
|
7657
7720
|
'milliseconds?': checkData('number')
|
|
@@ -7661,30 +7724,11 @@
|
|
|
7661
7724
|
}))
|
|
7662
7725
|
], SDKCreator.prototype, "vibrate", null);
|
|
7663
7726
|
__decorate([
|
|
7664
|
-
handleError,
|
|
7665
|
-
validate,
|
|
7666
7727
|
__param(0, checkType('object', {
|
|
7667
7728
|
url: checkData('url')
|
|
7668
7729
|
}))
|
|
7669
7730
|
], SDKCreator.prototype, "openWebview", null);
|
|
7670
7731
|
__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
7732
|
__param(0, checkType('object', {
|
|
7689
7733
|
'maxProfile?': checkData('number', { min: 1, max: 10 })
|
|
7690
7734
|
}, {
|
|
@@ -7692,8 +7736,6 @@
|
|
|
7692
7736
|
}))
|
|
7693
7737
|
], SDKCreator.prototype, "openProfilePicker", null);
|
|
7694
7738
|
__decorate([
|
|
7695
|
-
handleError,
|
|
7696
|
-
validate,
|
|
7697
7739
|
__param(0, required(['SSID'])),
|
|
7698
7740
|
__param(0, checkType('object', {
|
|
7699
7741
|
SSID: checkData('string'),
|
|
@@ -7702,8 +7744,6 @@
|
|
|
7702
7744
|
}))
|
|
7703
7745
|
], SDKCreator.prototype, "connectWifi", null);
|
|
7704
7746
|
__decorate([
|
|
7705
|
-
handleError,
|
|
7706
|
-
validate,
|
|
7707
7747
|
__param(0, checkType('object', {
|
|
7708
7748
|
type: checkData('string', {
|
|
7709
7749
|
values: ['photo', 'video', 'file']
|
|
@@ -7718,8 +7758,6 @@
|
|
|
7718
7758
|
}))
|
|
7719
7759
|
], SDKCreator.prototype, "openMediaPicker", null);
|
|
7720
7760
|
__decorate([
|
|
7721
|
-
handleError,
|
|
7722
|
-
validate,
|
|
7723
7761
|
__param(0, checkType('object', {
|
|
7724
7762
|
title: checkData('string', { maxLength: 100 }),
|
|
7725
7763
|
'thumbnail?': checkData('url'),
|
|
@@ -7729,14 +7767,9 @@
|
|
|
7729
7767
|
description: ''
|
|
7730
7768
|
}))
|
|
7731
7769
|
], SDKCreator.prototype, "getShareableLink", null);
|
|
7732
|
-
__decorate([
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
], SDKCreator.prototype, "closeLoading", null);
|
|
7736
|
-
__decorate([
|
|
7737
|
-
handleError,
|
|
7738
|
-
validate
|
|
7739
|
-
], SDKCreator.prototype, "requestUpdateZalo", null);
|
|
7770
|
+
SDKCreator = __decorate([
|
|
7771
|
+
DecorateAll(centralizedFunctionHandler)
|
|
7772
|
+
], SDKCreator);
|
|
7740
7773
|
class ZaloMiniAppSDKCreator extends SDKCreator {
|
|
7741
7774
|
getServiceInstance() {
|
|
7742
7775
|
return ZaloMiniProgramSDKService.getInstance();
|
|
@@ -7932,7 +7965,7 @@
|
|
|
7932
7965
|
_MockPaymentService_appId = new WeakMap();
|
|
7933
7966
|
|
|
7934
7967
|
var _PaymentCreator_instance, _PaymentCreator_sdk;
|
|
7935
|
-
class PaymentCreator {
|
|
7968
|
+
let PaymentCreator = class PaymentCreator {
|
|
7936
7969
|
constructor(sdk) {
|
|
7937
7970
|
_PaymentCreator_instance.set(this, void 0);
|
|
7938
7971
|
_PaymentCreator_sdk.set(this, void 0);
|
|
@@ -7940,42 +7973,50 @@
|
|
|
7940
7973
|
__classPrivateFieldSet(this, _PaymentCreator_sdk, sdk, "f");
|
|
7941
7974
|
}
|
|
7942
7975
|
/**
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7976
|
+
* Tạo đơn hàng
|
|
7977
|
+
*
|
|
7978
|
+
* @async
|
|
7979
|
+
* @function createOrder
|
|
7980
|
+
* @category Payment
|
|
7981
|
+
* @returns {Promise<CallbackDataType.CreateOrderCallBack>}
|
|
7982
|
+
*/
|
|
7950
7983
|
createOrder(object) {
|
|
7951
7984
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").createOrder(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
7952
7985
|
}
|
|
7953
7986
|
/**
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7987
|
+
* Lấy thông tin transaction
|
|
7988
|
+
*
|
|
7989
|
+
* @async
|
|
7990
|
+
* @function checkTransaction
|
|
7991
|
+
* @category Payment
|
|
7992
|
+
* @returns {Promise<CallbackDataType.CheckTransactionSuccessCallBack>}
|
|
7993
|
+
*/
|
|
7961
7994
|
checkTransaction(object) {
|
|
7962
7995
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").checkTransaction(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
7963
7996
|
}
|
|
7964
|
-
}
|
|
7997
|
+
};
|
|
7965
7998
|
_PaymentCreator_instance = new WeakMap(), _PaymentCreator_sdk = new WeakMap();
|
|
7966
7999
|
__decorate([
|
|
7967
|
-
handleError,
|
|
7968
|
-
validate,
|
|
7969
8000
|
__param(0, checkType('object', {
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
'method?': checkData('string', {
|
|
8001
|
+
amount: checkData(['string', 'number']),
|
|
8002
|
+
desc: checkData('string'),
|
|
8003
|
+
'method?': checkData('string', {
|
|
8004
|
+
values: [
|
|
8005
|
+
'MOMO',
|
|
8006
|
+
'ZALOPAY',
|
|
8007
|
+
'MOMO_SANDBOX',
|
|
8008
|
+
'ZALOPAY_SANDBOX',
|
|
8009
|
+
'CC',
|
|
8010
|
+
'CC_SANDBOX',
|
|
8011
|
+
'ATM',
|
|
8012
|
+
'ATM_SANDBOX'
|
|
8013
|
+
]
|
|
8014
|
+
})
|
|
7973
8015
|
}))
|
|
7974
8016
|
], PaymentCreator.prototype, "createOrder", null);
|
|
7975
|
-
__decorate([
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
], PaymentCreator.prototype, "checkTransaction", null);
|
|
8017
|
+
PaymentCreator = __decorate([
|
|
8018
|
+
DecorateAll(centralizedFunctionHandler)
|
|
8019
|
+
], PaymentCreator);
|
|
7979
8020
|
class ZaloMiniAppPaymentCreator extends PaymentCreator {
|
|
7980
8021
|
getInstance() {
|
|
7981
8022
|
return PaymentService.getInstance();
|