zmp-sdk 2.20.0 → 2.21.0-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.min.js +1317 -1289
- package/dist/index.es.js +1318 -1290
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/src/apis/payment.d.ts +14 -14
- package/dist/types/src/constants.d.ts +89 -20
- package/dist/types/src/decorator.d.ts +22 -0
- package/dist/types/src/errorHandler.d.ts +12 -0
- package/dist/types/src/services/zalo-mp-service.d.ts +3 -2
- package/dist/types/src/storage/nativeStorage.d.ts +1 -2
- package/dist/types/src/types/enum.d.ts +0 -6
- package/dist/types/src/utils/lodash.d.ts +1 -0
- package/dist/types/src/utils/response.d.ts +8 -8
- package/dist/types/src/zaloJsBridge.d.ts +16 -2
- package/package.json +1 -1
- package/dist/types/src/bridgeProvider.d.ts +0 -19
- package/dist/types/src/middleware/error.middleware.d.ts +0 -18
- package/dist/types/src/middleware/validate.middleware.d.ts +0 -9
package/dist/index.es.js
CHANGED
|
@@ -2064,6 +2064,9 @@ function set(object, path, value) {
|
|
|
2064
2064
|
|
|
2065
2065
|
var set_1 = set;
|
|
2066
2066
|
|
|
2067
|
+
const isPromise = (obj) => !!obj &&
|
|
2068
|
+
(typeof obj === 'object' || typeof obj === 'function') &&
|
|
2069
|
+
typeof obj.then === 'function';
|
|
2067
2070
|
var _ = {
|
|
2068
2071
|
isEmpty: isEmpty_1,
|
|
2069
2072
|
isNull: isNull_1,
|
|
@@ -2075,7 +2078,8 @@ var _ = {
|
|
|
2075
2078
|
isArray: isArray_1,
|
|
2076
2079
|
isRegExp: isRegExp_1,
|
|
2077
2080
|
get: get_1,
|
|
2078
|
-
set: set_1
|
|
2081
|
+
set: set_1,
|
|
2082
|
+
isPromise,
|
|
2079
2083
|
};
|
|
2080
2084
|
|
|
2081
2085
|
function Debug(name) {
|
|
@@ -2147,13 +2151,6 @@ var VibrateType;
|
|
|
2147
2151
|
(function (VibrateType) {
|
|
2148
2152
|
VibrateType[VibrateType["oneShot"] = 0] = "oneShot";
|
|
2149
2153
|
})(VibrateType || (VibrateType = {}));
|
|
2150
|
-
var NativeCode;
|
|
2151
|
-
(function (NativeCode) {
|
|
2152
|
-
NativeCode[NativeCode["token_invalid"] = -2] = "token_invalid";
|
|
2153
|
-
NativeCode[NativeCode["not_permission"] = -1] = "not_permission";
|
|
2154
|
-
NativeCode[NativeCode["client_not_support"] = -5] = "client_not_support";
|
|
2155
|
-
NativeCode[NativeCode["decode_failed"] = -4] = "decode_failed";
|
|
2156
|
-
})(NativeCode || (NativeCode = {}));
|
|
2157
2154
|
var Events;
|
|
2158
2155
|
(function (Events) {
|
|
2159
2156
|
Events["AppPaused"] = "h5.event.paused";
|
|
@@ -2242,7 +2239,7 @@ const COOKIE_NAME = {
|
|
|
2242
2239
|
ZACC_SESSiON: `h5.zdn.vn_zacc_session`,
|
|
2243
2240
|
JS_TOKEN: `h5.zdn.vn_zlink3rd`,
|
|
2244
2241
|
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf`,
|
|
2245
|
-
DEVICE_ID: `h5.zdn.vn_deviceID
|
|
2242
|
+
DEVICE_ID: `h5.zdn.vn_deviceID`
|
|
2246
2243
|
};
|
|
2247
2244
|
const APIS = {
|
|
2248
2245
|
GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
|
|
@@ -2250,6 +2247,8 @@ const APIS = {
|
|
|
2250
2247
|
GET_ACCESS_TOKEN_V3: 'https://oauth.zaloapp.com/v3/access_token',
|
|
2251
2248
|
GET_LIST_USER_INFO: 'https://graph.zalo.me/v2.0/me/friends/list',
|
|
2252
2249
|
CREATE_ORDER: 'https://payment-mini.zalo.me/api/order/create',
|
|
2250
|
+
GET_APP_INFO: 'https://h5.zalo.me/apps/get-info',
|
|
2251
|
+
SEND_ACTION_LOG: 'https://h5.zalo.me/log/async'
|
|
2253
2252
|
};
|
|
2254
2253
|
const STORAGE_LIMIT = 5 * MB;
|
|
2255
2254
|
const NETWORK_TYPE = (isAndroid) => ({
|
|
@@ -2260,6 +2259,78 @@ const NETWORK_TYPE = (isAndroid) => ({
|
|
|
2260
2259
|
'4G': isAndroid ? 13 : 2
|
|
2261
2260
|
});
|
|
2262
2261
|
const MEDIA_PICKER_LIMIT = 1 * MB;
|
|
2262
|
+
const RESPONSE_CODE = {
|
|
2263
|
+
SUCCESS: 0,
|
|
2264
|
+
UNKNOWN_ERROR: -2000,
|
|
2265
|
+
BAD_REQUEST: -1400,
|
|
2266
|
+
INTERNAL_SERVER_ERROR: -1500,
|
|
2267
|
+
UNAUTHORIZED: -1401,
|
|
2268
|
+
FORBIDDEN: -1403,
|
|
2269
|
+
CLIENT_NOT_SUPPORT: -1404,
|
|
2270
|
+
TIME_OUT: -1408,
|
|
2271
|
+
DECODE_FAILED: -2001,
|
|
2272
|
+
USER_DENIED: -2002,
|
|
2273
|
+
USER_CANCEL: -2003,
|
|
2274
|
+
// Media picker
|
|
2275
|
+
MEDIA_PICKER_FAIL: -2004,
|
|
2276
|
+
// Save image to gallery
|
|
2277
|
+
SAVE_IMAGE_FAIL: -2005
|
|
2278
|
+
};
|
|
2279
|
+
const MESSAGES = {
|
|
2280
|
+
SUCCESS: 'Success',
|
|
2281
|
+
UNKNOWN_ERROR: 'Unknown error. Please try again later.',
|
|
2282
|
+
TIME_OUT: 'Request timeout. Please try again later.',
|
|
2283
|
+
LOGIN_REQUIRED: 'Please login (https://miniapp.zalo.me/docs/api/login) before to call this api',
|
|
2284
|
+
LOGIN_FAILED: 'Login failed',
|
|
2285
|
+
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2286
|
+
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2287
|
+
DECODE_FAILED: 'Can not decode id. Please check your params again.',
|
|
2288
|
+
INVALID_PARAM: 'Invalid parameter',
|
|
2289
|
+
USER_DENIED: 'User denied',
|
|
2290
|
+
USER_CANCEL: 'User cancel',
|
|
2291
|
+
// Media picker
|
|
2292
|
+
MEDIA_PICKER_FAIL: 'Unable to pick media',
|
|
2293
|
+
// Save image to gallery
|
|
2294
|
+
SAVE_IMAGE_FAIL: 'Unable to save image'
|
|
2295
|
+
};
|
|
2296
|
+
const RESPONSE = {
|
|
2297
|
+
SUCCESS: {
|
|
2298
|
+
code: RESPONSE_CODE.SUCCESS,
|
|
2299
|
+
message: MESSAGES.SUCCESS
|
|
2300
|
+
},
|
|
2301
|
+
UNKNOWN_ERROR: {
|
|
2302
|
+
code: RESPONSE_CODE.UNKNOWN_ERROR,
|
|
2303
|
+
message: MESSAGES.UNKNOWN_ERROR
|
|
2304
|
+
},
|
|
2305
|
+
UNAUTHORIZED: {
|
|
2306
|
+
code: RESPONSE_CODE.UNAUTHORIZED,
|
|
2307
|
+
message: MESSAGES.LOGIN_REQUIRED
|
|
2308
|
+
},
|
|
2309
|
+
FORBIDDEN: {
|
|
2310
|
+
code: RESPONSE_CODE.FORBIDDEN,
|
|
2311
|
+
message: MESSAGES.NOT_PERMISSION
|
|
2312
|
+
},
|
|
2313
|
+
CLIENT_NOT_SUPPORT: {
|
|
2314
|
+
code: RESPONSE_CODE.CLIENT_NOT_SUPPORT,
|
|
2315
|
+
message: MESSAGES.CLIENT_NOT_SUPPORT
|
|
2316
|
+
},
|
|
2317
|
+
DECODE_FAILED: {
|
|
2318
|
+
code: RESPONSE_CODE.DECODE_FAILED,
|
|
2319
|
+
message: MESSAGES.DECODE_FAILED
|
|
2320
|
+
},
|
|
2321
|
+
TIME_OUT: {
|
|
2322
|
+
code: RESPONSE_CODE.TIME_OUT,
|
|
2323
|
+
message: MESSAGES.TIME_OUT
|
|
2324
|
+
},
|
|
2325
|
+
USER_DENIED: {
|
|
2326
|
+
code: RESPONSE_CODE.USER_DENIED,
|
|
2327
|
+
message: MESSAGES.USER_DENIED
|
|
2328
|
+
},
|
|
2329
|
+
USER_CANCEL: {
|
|
2330
|
+
code: RESPONSE_CODE.USER_CANCEL,
|
|
2331
|
+
message: MESSAGES.USER_CANCEL
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2263
2334
|
const ACTION = {
|
|
2264
2335
|
GET_DOWNLOADED_STICKER: {
|
|
2265
2336
|
name: 'action.get.downloaded.sticker',
|
|
@@ -2372,7 +2443,19 @@ const ACTION = {
|
|
|
2372
2443
|
have_callback: true
|
|
2373
2444
|
},
|
|
2374
2445
|
REQUEST_PERMISSION_CAMERA: {
|
|
2375
|
-
name: 'action.request.permission.camera'
|
|
2446
|
+
name: 'action.request.permission.camera',
|
|
2447
|
+
error_list: {
|
|
2448
|
+
android: {
|
|
2449
|
+
'-2': {
|
|
2450
|
+
map_to: RESPONSE.USER_DENIED
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
iOS: {
|
|
2454
|
+
'-2': {
|
|
2455
|
+
map_to: RESPONSE.USER_DENIED
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2376
2459
|
},
|
|
2377
2460
|
CHANGE_TITLE_HEADER: {
|
|
2378
2461
|
name: 'action.change.title.header',
|
|
@@ -2441,7 +2524,19 @@ const ACTION = {
|
|
|
2441
2524
|
},
|
|
2442
2525
|
GET_LOCATION: {
|
|
2443
2526
|
name: 'action.get.location',
|
|
2444
|
-
have_callback: true
|
|
2527
|
+
have_callback: true,
|
|
2528
|
+
error_list: {
|
|
2529
|
+
android: {
|
|
2530
|
+
'-1': {
|
|
2531
|
+
map_to: RESPONSE.USER_DENIED
|
|
2532
|
+
}
|
|
2533
|
+
},
|
|
2534
|
+
iOS: {
|
|
2535
|
+
'-1': {
|
|
2536
|
+
map_to: RESPONSE.USER_DENIED
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2445
2540
|
},
|
|
2446
2541
|
QUERY_LOCATION_HIDE: {
|
|
2447
2542
|
name: 'action.query.location.hide',
|
|
@@ -2539,7 +2634,34 @@ const ACTION = {
|
|
|
2539
2634
|
},
|
|
2540
2635
|
SAVE_IMAGE_GALLERY: {
|
|
2541
2636
|
name: 'action.save.image.gallery',
|
|
2542
|
-
version_live: { iOS: 408 }
|
|
2637
|
+
version_live: { iOS: 408 },
|
|
2638
|
+
error_list: {
|
|
2639
|
+
android: {
|
|
2640
|
+
'-101': {
|
|
2641
|
+
map_to: {
|
|
2642
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2643
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2644
|
+
},
|
|
2645
|
+
need_more_detail: true
|
|
2646
|
+
},
|
|
2647
|
+
'-102': {
|
|
2648
|
+
map_to: {
|
|
2649
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2650
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2651
|
+
},
|
|
2652
|
+
need_more_detail: true
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
iOS: {
|
|
2656
|
+
'-10': {
|
|
2657
|
+
map_to: {
|
|
2658
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2659
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2660
|
+
},
|
|
2661
|
+
need_more_detail: true
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2543
2665
|
},
|
|
2544
2666
|
OPEN_MP: {
|
|
2545
2667
|
name: 'action.open.mp',
|
|
@@ -2560,11 +2682,41 @@ const ACTION = {
|
|
|
2560
2682
|
},
|
|
2561
2683
|
MP_GET_NUMBER: {
|
|
2562
2684
|
name: 'action.mp.get.number',
|
|
2563
|
-
version_live: { iOS: 416 }
|
|
2685
|
+
version_live: { iOS: 416 },
|
|
2686
|
+
error_list: {
|
|
2687
|
+
android: {
|
|
2688
|
+
'-1': {
|
|
2689
|
+
map_to: RESPONSE.USER_DENIED
|
|
2690
|
+
},
|
|
2691
|
+
'-101': {
|
|
2692
|
+
map_to: RESPONSE.USER_DENIED
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2695
|
+
iOS: {
|
|
2696
|
+
'-1': {
|
|
2697
|
+
map_to: RESPONSE.USER_DENIED
|
|
2698
|
+
},
|
|
2699
|
+
'-10': {
|
|
2700
|
+
map_to: RESPONSE.USER_DENIED
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2564
2704
|
},
|
|
2565
2705
|
MP_OPEN_PROFILE_PICKER: {
|
|
2566
2706
|
name: 'action.mp.open.profile.picker',
|
|
2567
|
-
version_live: { iOS: 432 }
|
|
2707
|
+
version_live: { iOS: 432 },
|
|
2708
|
+
error_list: {
|
|
2709
|
+
android: {
|
|
2710
|
+
'-101': {
|
|
2711
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2712
|
+
}
|
|
2713
|
+
},
|
|
2714
|
+
iOS: {
|
|
2715
|
+
'-101': {
|
|
2716
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2568
2720
|
},
|
|
2569
2721
|
GET_SUPPORTED_ACTIONS: {
|
|
2570
2722
|
name: 'action.get.supported.actions',
|
|
@@ -2578,32 +2730,45 @@ const ACTION = {
|
|
|
2578
2730
|
},
|
|
2579
2731
|
PICK_MEDIA: {
|
|
2580
2732
|
name: 'action.pick.media',
|
|
2581
|
-
version_live: { iOS: 440 }
|
|
2733
|
+
version_live: { iOS: 440 },
|
|
2734
|
+
error_list: {
|
|
2735
|
+
android: {
|
|
2736
|
+
'-101': {
|
|
2737
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2738
|
+
},
|
|
2739
|
+
'999': {
|
|
2740
|
+
map_to: {
|
|
2741
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2742
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2743
|
+
},
|
|
2744
|
+
need_more_detail: true
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
iOS: {
|
|
2748
|
+
'-10': {
|
|
2749
|
+
map_to: {
|
|
2750
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2751
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2582
2756
|
},
|
|
2583
2757
|
MP_CLOSE_LOADINGVIEW: {
|
|
2584
2758
|
name: 'action.mp.close.loadingview'
|
|
2585
2759
|
}
|
|
2586
2760
|
};
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
LOGIN_REQUIRED: 'Please login before to call this api. Read more at: https://miniapp.zalo.me/docs/api/login',
|
|
2599
|
-
LOGIN_FAILED: 'Login failed.',
|
|
2600
|
-
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2601
|
-
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2602
|
-
DECODE_FAILED: 'Can not decode your data. Read more at: https://miniapp.zalo.me/docs/api/error'
|
|
2603
|
-
};
|
|
2604
|
-
const API_DOMAIN = 'https://h5.zalo.me/';
|
|
2605
|
-
const H5_API = {
|
|
2606
|
-
GET_APP_INFO: 'apps/get-info'
|
|
2761
|
+
const COMMON_NATIVE_ERROR_CODE = {
|
|
2762
|
+
android: {
|
|
2763
|
+
'-4': RESPONSE.DECODE_FAILED,
|
|
2764
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2765
|
+
'-14': RESPONSE.TIME_OUT
|
|
2766
|
+
},
|
|
2767
|
+
iOS: {
|
|
2768
|
+
'-9': RESPONSE.DECODE_FAILED,
|
|
2769
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2770
|
+
'-14': RESPONSE.TIME_OUT
|
|
2771
|
+
}
|
|
2607
2772
|
};
|
|
2608
2773
|
const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
2609
2774
|
android: 12100571,
|
|
@@ -2715,124 +2880,36 @@ const PAYMENT_APIS = {
|
|
|
2715
2880
|
};
|
|
2716
2881
|
const PAYMENT_H5_URL = 'https://payment-mini.zalo.me';
|
|
2717
2882
|
|
|
2718
|
-
class
|
|
2883
|
+
class AppError {
|
|
2719
2884
|
constructor(code, msg, api) {
|
|
2720
2885
|
this.code = code;
|
|
2721
2886
|
this.message = msg;
|
|
2722
2887
|
this.api = api;
|
|
2723
2888
|
}
|
|
2724
2889
|
toString() {
|
|
2725
|
-
return `api: ${this.api}; code: ${this.code}; message: ${this.message}`;
|
|
2890
|
+
return `api: ${String(this.api)}; code: ${this.code}; message: ${this.message}`;
|
|
2726
2891
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
}
|
|
2734
|
-
handler() {
|
|
2735
|
-
switch (this.code) {
|
|
2736
|
-
case NativeCode.token_invalid:
|
|
2737
|
-
this.code = RESPONSE_CODE.UNAUTHORIZED;
|
|
2738
|
-
this.message = MESSAGES.LOGIN_REQUIRED;
|
|
2739
|
-
break;
|
|
2740
|
-
case NativeCode.not_permission:
|
|
2741
|
-
this.code = RESPONSE_CODE.FORBIDDEN;
|
|
2742
|
-
this.message = MESSAGES.NOT_PERMISSION;
|
|
2743
|
-
break;
|
|
2744
|
-
case NativeCode.client_not_support:
|
|
2745
|
-
this.code = RESPONSE_CODE.CLIENT_NOT_SUPPORT;
|
|
2746
|
-
this.message = MESSAGES.CLIENT_NOT_SUPPORT;
|
|
2747
|
-
break;
|
|
2748
|
-
case NativeCode.decode_failed:
|
|
2749
|
-
this.message = MESSAGES.DECODE_FAILED;
|
|
2750
|
-
break;
|
|
2751
|
-
}
|
|
2892
|
+
toJSON() {
|
|
2893
|
+
return {
|
|
2894
|
+
code: this.code,
|
|
2895
|
+
message: this.message,
|
|
2896
|
+
api: this.api
|
|
2897
|
+
};
|
|
2752
2898
|
}
|
|
2753
2899
|
}
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
this.handler = handler;
|
|
2758
|
-
}
|
|
2900
|
+
const handleKnownExceptions = (error, api) => {
|
|
2901
|
+
error.api = api;
|
|
2902
|
+
return error.toJSON();
|
|
2759
2903
|
};
|
|
2760
|
-
const
|
|
2761
|
-
if (error instanceof
|
|
2762
|
-
error.
|
|
2763
|
-
return error;
|
|
2904
|
+
const handleUnknownExceptions = (error, api) => {
|
|
2905
|
+
if (error instanceof Error) {
|
|
2906
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, error.message, api).toJSON();
|
|
2764
2907
|
}
|
|
2765
|
-
return new
|
|
2766
|
-
};
|
|
2767
|
-
catchDecoratorStore.setHandler(errorHandler);
|
|
2768
|
-
const handleError = (target, propertyName, descriptor) => {
|
|
2769
|
-
const fn = descriptor.value;
|
|
2770
|
-
descriptor.value = function (...args) {
|
|
2771
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2772
|
-
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
2773
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
2774
|
-
try {
|
|
2775
|
-
const res = yield fn.apply(this, args);
|
|
2776
|
-
if (!_.isNull(success) && _.isFunction(success)) {
|
|
2777
|
-
success.call(null, res, this);
|
|
2778
|
-
}
|
|
2779
|
-
else {
|
|
2780
|
-
resolve(res);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
catch (error) {
|
|
2784
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2785
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2786
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2787
|
-
let loggedIn = false;
|
|
2788
|
-
if (this instanceof SDKCreator) {
|
|
2789
|
-
loggedIn = this.getLoginStatus();
|
|
2790
|
-
}
|
|
2791
|
-
if (!loggedIn) {
|
|
2792
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
const { handler } = catchDecoratorStore;
|
|
2796
|
-
const errorParsed = handler.call(null, propertyName, error, this);
|
|
2797
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2798
|
-
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
2799
|
-
fail.call(null, errorParsed, this);
|
|
2800
|
-
}
|
|
2801
|
-
else {
|
|
2802
|
-
reject(errorParsed);
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
}));
|
|
2806
|
-
});
|
|
2807
|
-
};
|
|
2808
|
-
return descriptor;
|
|
2908
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, MESSAGES.UNKNOWN_ERROR, api).toJSON();
|
|
2809
2909
|
};
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
try {
|
|
2814
|
-
return fn.apply(this, args);
|
|
2815
|
-
}
|
|
2816
|
-
catch (error) {
|
|
2817
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2818
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2819
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2820
|
-
let loggedIn = false;
|
|
2821
|
-
if (this instanceof SDKCreator) {
|
|
2822
|
-
loggedIn = this.getLoginStatus();
|
|
2823
|
-
}
|
|
2824
|
-
if (!loggedIn) {
|
|
2825
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
const { handler } = catchDecoratorStore;
|
|
2829
|
-
const errorParsed = handler.call(null, key, error, this);
|
|
2830
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2831
|
-
throw errorParsed;
|
|
2832
|
-
}
|
|
2833
|
-
};
|
|
2834
|
-
return descriptor;
|
|
2835
|
-
};
|
|
2910
|
+
const errorHandler = (error, api) => error instanceof AppError
|
|
2911
|
+
? handleKnownExceptions(error, api)
|
|
2912
|
+
: handleUnknownExceptions(error, api);
|
|
2836
2913
|
|
|
2837
2914
|
const apiResponse = {
|
|
2838
2915
|
success: (data, message) => ({
|
|
@@ -2841,13 +2918,13 @@ const apiResponse = {
|
|
|
2841
2918
|
data: data || {}
|
|
2842
2919
|
}),
|
|
2843
2920
|
error: {
|
|
2844
|
-
badRequest: (message) => new
|
|
2845
|
-
loginFailed: () => new
|
|
2846
|
-
loginRequired: () => new
|
|
2847
|
-
missingParam: (params) => new
|
|
2848
|
-
wrongTypeParam: (arg, expected, got) => new
|
|
2849
|
-
cannotGetShareInfo: () => new
|
|
2850
|
-
lengthInvalid: (arg) => new
|
|
2921
|
+
badRequest: (message) => new AppError(RESPONSE_CODE.BAD_REQUEST, message),
|
|
2922
|
+
loginFailed: (message) => new AppError(RESPONSE_CODE.UNAUTHORIZED, `${MESSAGES.LOGIN_FAILED}: ${message}`),
|
|
2923
|
+
loginRequired: () => new AppError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED),
|
|
2924
|
+
missingParam: (params) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
|
|
2925
|
+
wrongTypeParam: (arg, expected, got) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
|
|
2926
|
+
cannotGetShareInfo: () => new AppError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
|
|
2927
|
+
lengthInvalid: (arg) => new AppError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
|
|
2851
2928
|
}
|
|
2852
2929
|
};
|
|
2853
2930
|
|
|
@@ -3262,7 +3339,7 @@ const getAppInfo = (appId, versionStatus, currentVersion) => __awaiter(void 0, v
|
|
|
3262
3339
|
if (!_.isUndefined(currentVersion)) {
|
|
3263
3340
|
inputData.currentVersion = currentVersion;
|
|
3264
3341
|
}
|
|
3265
|
-
const api = QueryString.appendToUrl(
|
|
3342
|
+
const api = QueryString.appendToUrl(APIS.GET_APP_INFO, inputData);
|
|
3266
3343
|
const msgApi = yield fetch(api, {
|
|
3267
3344
|
credentials: 'include'
|
|
3268
3345
|
});
|
|
@@ -3654,504 +3731,97 @@ class ZMPEEmitter extends eventemitter3 {
|
|
|
3654
3731
|
}
|
|
3655
3732
|
}
|
|
3656
3733
|
|
|
3657
|
-
var
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
wrappers[type] = fn;
|
|
3670
|
-
};
|
|
3671
|
-
var ERROR = {
|
|
3672
|
-
error: {
|
|
3673
|
-
code: 1,
|
|
3674
|
-
error_subcode: 1357046,
|
|
3675
|
-
message: 'Received Invalid JSON reply.',
|
|
3676
|
-
type: 'http'
|
|
3677
|
-
}
|
|
3678
|
-
};
|
|
3679
|
-
function safelyParseResponse(rawResponse) {
|
|
3680
|
-
try {
|
|
3681
|
-
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
3682
|
-
}
|
|
3683
|
-
catch (ex) {
|
|
3684
|
-
return ERROR;
|
|
3734
|
+
var version$1 = "2.21.0-rc";
|
|
3735
|
+
|
|
3736
|
+
class Basics {
|
|
3737
|
+
/**
|
|
3738
|
+
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
3739
|
+
*
|
|
3740
|
+
* @category Basics
|
|
3741
|
+
*
|
|
3742
|
+
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
3743
|
+
*/
|
|
3744
|
+
static getVersion() {
|
|
3745
|
+
return version$1;
|
|
3685
3746
|
}
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3747
|
+
/**
|
|
3748
|
+
* Gets system information.
|
|
3749
|
+
*
|
|
3750
|
+
* @function getSystemInfo
|
|
3751
|
+
* @category Basics
|
|
3752
|
+
*
|
|
3753
|
+
*
|
|
3754
|
+
*
|
|
3755
|
+
*/
|
|
3756
|
+
static getSystemInfo() {
|
|
3757
|
+
const system = {
|
|
3758
|
+
version: getMetaValue('version-id') || '',
|
|
3759
|
+
apiVersion: version$1,
|
|
3760
|
+
zaloVersion: getZaloVersion(),
|
|
3761
|
+
platform: getPlatform(),
|
|
3762
|
+
language: navigator.language,
|
|
3763
|
+
zaloLanguage: window.zLanguage || 'vi',
|
|
3764
|
+
zaloTheme: window.zTheme || 'light'
|
|
3765
|
+
};
|
|
3766
|
+
return system;
|
|
3690
3767
|
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3768
|
+
/**
|
|
3769
|
+
* Lấy thông tin mini app
|
|
3770
|
+
*
|
|
3771
|
+
* @async
|
|
3772
|
+
* @function getAppInfo
|
|
3773
|
+
* @category Device
|
|
3774
|
+
*
|
|
3775
|
+
*/
|
|
3776
|
+
static getAppInfo() {
|
|
3777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3778
|
+
const appId = this.getAppId();
|
|
3779
|
+
const systemInfo = this.getSystemInfo();
|
|
3780
|
+
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
3781
|
+
});
|
|
3696
3782
|
}
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
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
|
-
url = QueryString.appendToUrl(url, data);
|
|
3740
|
-
data = '';
|
|
3741
|
-
}
|
|
3742
|
-
var request = createCORSRequest(method, url);
|
|
3743
|
-
if (!request) {
|
|
3744
|
-
return false;
|
|
3745
|
-
}
|
|
3746
|
-
request.onload = function (xhr) {
|
|
3747
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3748
|
-
};
|
|
3749
|
-
request.onerror = function (xhr) {
|
|
3750
|
-
if (xhr.responseText) {
|
|
3751
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3752
|
-
}
|
|
3753
|
-
else {
|
|
3754
|
-
cb({
|
|
3755
|
-
error: {
|
|
3756
|
-
code: 1,
|
|
3757
|
-
error_subcode: 1357045,
|
|
3758
|
-
message: 'unknown error (empty response)',
|
|
3759
|
-
status: xhr.status,
|
|
3760
|
-
type: 'http'
|
|
3761
|
-
}
|
|
3762
|
-
});
|
|
3763
|
-
}
|
|
3764
|
-
};
|
|
3765
|
-
request.send(data);
|
|
3766
|
-
return true;
|
|
3767
|
-
}
|
|
3768
|
-
var CORSRequest = {
|
|
3769
|
-
execute: execute
|
|
3770
|
-
};
|
|
3771
|
-
|
|
3772
|
-
class ZaloJSBridge extends eventemitter3 {
|
|
3773
|
-
constructor() {
|
|
3774
|
-
super();
|
|
3775
|
-
this.debug = Debug('zmp:ZaloJSBridge');
|
|
3776
|
-
this.events = ZMPEEmitter.getInstance();
|
|
3777
|
-
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
3778
|
-
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
3779
|
-
this.results = [];
|
|
3780
|
-
this._userAgent = getUserAgent();
|
|
3781
|
-
this._device = checkPlatform();
|
|
3782
|
-
this._jsCallFuncCallbacks = {};
|
|
3783
|
-
this.events.on(Events.AppPaused, () => {
|
|
3784
|
-
if (this.results.length > 0) {
|
|
3785
|
-
let array = this.results;
|
|
3786
|
-
this.results = [];
|
|
3787
|
-
try {
|
|
3788
|
-
this.sendLogData(array);
|
|
3789
|
-
}
|
|
3790
|
-
catch (error) { }
|
|
3791
|
-
}
|
|
3792
|
-
});
|
|
3793
|
-
if (this.sendLogTimer) {
|
|
3794
|
-
clearInterval(this.sendLogTimer);
|
|
3795
|
-
}
|
|
3796
|
-
else {
|
|
3797
|
-
this.sendLogTimer = setInterval(() => {
|
|
3798
|
-
if (this.results.length > 0) {
|
|
3799
|
-
let array = this.results;
|
|
3800
|
-
this.results = [];
|
|
3801
|
-
try {
|
|
3802
|
-
this.sendLogData(array);
|
|
3803
|
-
}
|
|
3804
|
-
catch (error) { }
|
|
3805
|
-
}
|
|
3806
|
-
}, 5000);
|
|
3807
|
-
}
|
|
3808
|
-
}
|
|
3809
|
-
static getInstance() {
|
|
3810
|
-
if (!ZaloJSBridge.instance) {
|
|
3811
|
-
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
3812
|
-
}
|
|
3813
|
-
return ZaloJSBridge.instance;
|
|
3814
|
-
}
|
|
3815
|
-
set accessTk(value) {
|
|
3816
|
-
this._accessTk = value;
|
|
3817
|
-
}
|
|
3818
|
-
set jsAccessTk(value) {
|
|
3819
|
-
this._jsAccessTk = value;
|
|
3820
|
-
}
|
|
3821
|
-
sendLogData(data) {
|
|
3822
|
-
try {
|
|
3823
|
-
CORSRequest.execute('https://h5.zalo.me/log/async', 'post', {
|
|
3824
|
-
appId: window.APP_ID,
|
|
3825
|
-
data: JSON.stringify(data)
|
|
3826
|
-
}, (response) => { });
|
|
3827
|
-
}
|
|
3828
|
-
catch (error) { }
|
|
3829
|
-
}
|
|
3830
|
-
onJSCall(key, data) {
|
|
3831
|
-
try {
|
|
3832
|
-
this.debug('onJSCall', key, data);
|
|
3833
|
-
const parsedData = parseJSON(data);
|
|
3834
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3835
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3836
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3837
|
-
if (!!callback) {
|
|
3838
|
-
try {
|
|
3839
|
-
callback.call(this, parsedData);
|
|
3840
|
-
}
|
|
3841
|
-
catch (error) {
|
|
3842
|
-
console.error('Call callback error', error);
|
|
3843
|
-
}
|
|
3844
|
-
!!timeout && clearTimeout(timeout);
|
|
3845
|
-
this._jsCallFuncCallbacks[key] = null;
|
|
3846
|
-
delete this._jsCallFuncCallbacks[key];
|
|
3847
|
-
}
|
|
3848
|
-
}
|
|
3849
|
-
this.results.push({
|
|
3850
|
-
action: parsedData.action,
|
|
3851
|
-
error: parsedData.error_code
|
|
3852
|
-
});
|
|
3853
|
-
}
|
|
3854
|
-
catch (e) {
|
|
3855
|
-
console.log('onJSCall', 'error', e);
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
onMultiJSCall(key, data) {
|
|
3859
|
-
try {
|
|
3860
|
-
this.debug('onMultiJSCall', key, data);
|
|
3861
|
-
const parsedData = parseJSON(data);
|
|
3862
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3863
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3864
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3865
|
-
if (!!callback) {
|
|
3866
|
-
try {
|
|
3867
|
-
callback.call(this, parsedData);
|
|
3868
|
-
}
|
|
3869
|
-
catch (error) {
|
|
3870
|
-
console.error('Call callback error', error);
|
|
3871
|
-
}
|
|
3872
|
-
!!timeout && clearTimeout(timeout);
|
|
3873
|
-
}
|
|
3874
|
-
}
|
|
3875
|
-
this.results.push({
|
|
3876
|
-
action: parsedData.action,
|
|
3877
|
-
error: parsedData.error_code
|
|
3878
|
-
});
|
|
3879
|
-
}
|
|
3880
|
-
catch (e) {
|
|
3881
|
-
console.log('onMultiJSCall', 'error', e);
|
|
3882
|
-
}
|
|
3883
|
-
}
|
|
3884
|
-
nativeEventHandler(eventId, eventName, eventData) {
|
|
3885
|
-
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
3886
|
-
const data = stringToData(eventData);
|
|
3887
|
-
this.debug(data);
|
|
3888
|
-
const convertedData = this.handleEventData(eventName, data);
|
|
3889
|
-
this.events.emit(eventName, eventId, convertedData);
|
|
3890
|
-
}
|
|
3891
|
-
handleEventData(eventName, data) {
|
|
3892
|
-
try {
|
|
3893
|
-
switch (eventName) {
|
|
3894
|
-
case Events.OpenApp:
|
|
3895
|
-
const { url } = data;
|
|
3896
|
-
const validUrl = new URL(url);
|
|
3897
|
-
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
3898
|
-
return {
|
|
3899
|
-
path: `${path ? path : '/'}${validUrl.search}`
|
|
3900
|
-
};
|
|
3901
|
-
break;
|
|
3902
|
-
default:
|
|
3903
|
-
return data;
|
|
3904
|
-
break;
|
|
3905
|
-
}
|
|
3906
|
-
}
|
|
3907
|
-
catch (error) {
|
|
3908
|
-
return data;
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
defaultCallback(data) {
|
|
3912
|
-
if (data !== null && data !== undefined) {
|
|
3913
|
-
data = parseJSON(data);
|
|
3914
|
-
}
|
|
3915
|
-
}
|
|
3916
|
-
jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
|
|
3917
|
-
try {
|
|
3918
|
-
const actionName = action.name;
|
|
3919
|
-
const key = generateUniqueString(actionName);
|
|
3920
|
-
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
3921
|
-
this.onJSCall(key, {
|
|
3922
|
-
error_code: -13,
|
|
3923
|
-
error_message: 'params invalid!',
|
|
3924
|
-
data: {
|
|
3925
|
-
device: this._device.isMobile,
|
|
3926
|
-
jsToken: this._jsAccessTk,
|
|
3927
|
-
access_token: this._accessTk
|
|
3928
|
-
},
|
|
3929
|
-
action: actionName
|
|
3930
|
-
});
|
|
3931
|
-
return false;
|
|
3932
|
-
}
|
|
3933
|
-
if (options === undefined || options === null) {
|
|
3934
|
-
options = {};
|
|
3935
|
-
}
|
|
3936
|
-
if (!callback) {
|
|
3937
|
-
callback = this.defaultCallback;
|
|
3938
|
-
}
|
|
3939
|
-
const timeoutCallback = {
|
|
3940
|
-
error_code: -14,
|
|
3941
|
-
error_message: 'Request Timeout!',
|
|
3942
|
-
data: {},
|
|
3943
|
-
action: actionName
|
|
3944
|
-
};
|
|
3945
|
-
this._jsCallFuncCallbacks[key] = {
|
|
3946
|
-
timeout: haveTimeout &&
|
|
3947
|
-
action.have_callback &&
|
|
3948
|
-
setTimeout(() => {
|
|
3949
|
-
this.onJSCall(key, timeoutCallback);
|
|
3950
|
-
}, 8000),
|
|
3951
|
-
callback: callback
|
|
3952
|
-
};
|
|
3953
|
-
try {
|
|
3954
|
-
options = serialize(options);
|
|
3955
|
-
if (isMultiCallback) {
|
|
3956
|
-
if (this._device.isIOS) {
|
|
3957
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
3958
|
-
}
|
|
3959
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
3960
|
-
}
|
|
3961
|
-
if (this._device.isIOS) {
|
|
3962
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
3963
|
-
}
|
|
3964
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
3965
|
-
}
|
|
3966
|
-
catch (error) {
|
|
3967
|
-
if (nRetry-- > 0) {
|
|
3968
|
-
setTimeout(() => {
|
|
3969
|
-
this.jsCall(action, options, callback, isMultiCallback, nRetry);
|
|
3970
|
-
}, 500);
|
|
3971
|
-
}
|
|
3972
|
-
else {
|
|
3973
|
-
const errorCallback = {
|
|
3974
|
-
error_code: -5,
|
|
3975
|
-
error_message: 'Not ready!',
|
|
3976
|
-
data: {
|
|
3977
|
-
userAgent: this._userAgent,
|
|
3978
|
-
options: options,
|
|
3979
|
-
jsToken: this._jsAccessTk,
|
|
3980
|
-
access_token: this._accessTk
|
|
3981
|
-
},
|
|
3982
|
-
action: actionName,
|
|
3983
|
-
js_error: error
|
|
3984
|
-
};
|
|
3985
|
-
this.onJSCall(key, errorCallback);
|
|
3986
|
-
return false;
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
}
|
|
3990
|
-
catch (error) {
|
|
3991
|
-
console.log('jsCall', 'error', error);
|
|
3992
|
-
}
|
|
3993
|
-
return false;
|
|
3994
|
-
}
|
|
3995
|
-
}
|
|
3996
|
-
|
|
3997
|
-
var _ZJSBridgeProvider_bridge;
|
|
3998
|
-
/** @ignore */
|
|
3999
|
-
class ZJSBridgeProvider {
|
|
4000
|
-
/** @ignore */
|
|
4001
|
-
constructor() {
|
|
4002
|
-
this.debug = Debug('zmp:ZJSBridgeProvider');
|
|
4003
|
-
_ZJSBridgeProvider_bridge.set(this, void 0);
|
|
4004
|
-
__classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance(), "f");
|
|
4005
|
-
}
|
|
4006
|
-
setZAccSession(value) {
|
|
4007
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").accessTk = value;
|
|
4008
|
-
}
|
|
4009
|
-
setJSToken(value) {
|
|
4010
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsAccessTk = value;
|
|
4011
|
-
}
|
|
4012
|
-
callNative(action, data, option) {
|
|
4013
|
-
this.debug(action.name, data);
|
|
4014
|
-
return new Promise((resolve, reject) => {
|
|
4015
|
-
const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
4016
|
-
try {
|
|
4017
|
-
const error = new NativeError(cb.error_code, `${cb.action}: ${cb.error_message}`);
|
|
4018
|
-
if (option === null || option === void 0 ? void 0 : option.callback) {
|
|
4019
|
-
const res = yield option.callback(cb, error);
|
|
4020
|
-
return resolve(res);
|
|
4021
|
-
}
|
|
4022
|
-
else {
|
|
4023
|
-
if (cb && cb.error_code >= 0) {
|
|
4024
|
-
resolve(cb.data || {});
|
|
4025
|
-
}
|
|
4026
|
-
else if (cb && cb.error_code < 0) {
|
|
4027
|
-
try {
|
|
4028
|
-
window.zmpSentry &&
|
|
4029
|
-
window.zmpSentry.captureMessage(`${action.name}: call native fail`, {
|
|
4030
|
-
extra: {
|
|
4031
|
-
data: data,
|
|
4032
|
-
rs: cb
|
|
4033
|
-
}
|
|
4034
|
-
});
|
|
4035
|
-
}
|
|
4036
|
-
catch (error) { }
|
|
4037
|
-
return reject(error);
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
catch (error) {
|
|
4042
|
-
return reject(error);
|
|
4043
|
-
}
|
|
4044
|
-
});
|
|
4045
|
-
const isIOS = checkPlatform().isIOS;
|
|
4046
|
-
const isSupportAction = checkIOSSupportAction(action);
|
|
4047
|
-
if (isIOS && !isSupportAction) {
|
|
4048
|
-
const error = new NativeError(-5, `${action}: Client isn't support this action`);
|
|
4049
|
-
return reject(error);
|
|
4050
|
-
}
|
|
4051
|
-
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
4052
|
-
setTimeout(() => {
|
|
4053
|
-
__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);
|
|
4054
|
-
}, option.delay);
|
|
4055
|
-
}
|
|
4056
|
-
else {
|
|
4057
|
-
__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);
|
|
4058
|
-
}
|
|
4059
|
-
});
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
_ZJSBridgeProvider_bridge = new WeakMap();
|
|
4063
|
-
|
|
4064
|
-
var version$1 = "2.20.0";
|
|
4065
|
-
|
|
4066
|
-
class Basics {
|
|
4067
|
-
/**
|
|
4068
|
-
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
4069
|
-
*
|
|
4070
|
-
* @category Basics
|
|
4071
|
-
*
|
|
4072
|
-
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
4073
|
-
*/
|
|
4074
|
-
static getVersion() {
|
|
4075
|
-
return version$1;
|
|
4076
|
-
}
|
|
4077
|
-
/**
|
|
4078
|
-
* Gets system information.
|
|
4079
|
-
*
|
|
4080
|
-
* @function getSystemInfo
|
|
4081
|
-
* @category Basics
|
|
4082
|
-
*
|
|
4083
|
-
*
|
|
4084
|
-
*
|
|
4085
|
-
*/
|
|
4086
|
-
static getSystemInfo() {
|
|
4087
|
-
const system = {
|
|
4088
|
-
version: getMetaValue('version-id') || '',
|
|
4089
|
-
apiVersion: version$1,
|
|
4090
|
-
zaloVersion: getZaloVersion(),
|
|
4091
|
-
platform: getPlatform(),
|
|
4092
|
-
language: navigator.language,
|
|
4093
|
-
zaloLanguage: window.zLanguage || 'vi',
|
|
4094
|
-
zaloTheme: window.zTheme || 'light'
|
|
4095
|
-
};
|
|
4096
|
-
return system;
|
|
4097
|
-
}
|
|
4098
|
-
/**
|
|
4099
|
-
* Lấy thông tin mini app
|
|
4100
|
-
*
|
|
4101
|
-
* @async
|
|
4102
|
-
* @function getAppInfo
|
|
4103
|
-
* @category Device
|
|
4104
|
-
*
|
|
4105
|
-
*/
|
|
4106
|
-
static getAppInfo() {
|
|
4107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4108
|
-
const appId = this.getAppId();
|
|
4109
|
-
const systemInfo = this.getSystemInfo();
|
|
4110
|
-
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
4111
|
-
});
|
|
4112
|
-
}
|
|
4113
|
-
}
|
|
4114
|
-
|
|
4115
|
-
class NavigationBar {
|
|
4116
|
-
/**
|
|
4117
|
-
* A promise for the user's favorite color.
|
|
4118
|
-
*
|
|
4119
|
-
* @promise FavoriteColorPromise
|
|
4120
|
-
* @fulfill {string} The user's favorite color.
|
|
4121
|
-
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
4122
|
-
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
4123
|
-
*/
|
|
4124
|
-
/**
|
|
4125
|
-
* Dynamically sets the title of the current page.
|
|
4126
|
-
*
|
|
4127
|
-
* @async
|
|
4128
|
-
* @function setNavigationBarTitle
|
|
4129
|
-
* @category Navigation Bar
|
|
4130
|
-
*
|
|
4131
|
-
* @example
|
|
4132
|
-
*
|
|
4133
|
-
* zmpApis.setNavigationBarTitle({
|
|
4134
|
-
* title: "Current Page"
|
|
4135
|
-
* }).then((res) => {
|
|
4136
|
-
* console.log("Success");
|
|
4137
|
-
* }).catch((error) => {
|
|
4138
|
-
* console.log("Fail");
|
|
4139
|
-
* });
|
|
4140
|
-
*
|
|
4141
|
-
* @param {Object} object
|
|
4142
|
-
* @param {string} object.title - The title of the page
|
|
4143
|
-
*
|
|
4144
|
-
* @return {Promise}
|
|
4145
|
-
*
|
|
4146
|
-
*/
|
|
4147
|
-
static setNavigationBarTitle(object) {
|
|
4148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4149
|
-
yield this.callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
4150
|
-
title: object.title
|
|
4151
|
-
}, {
|
|
4152
|
-
haveTimeout: false
|
|
4153
|
-
});
|
|
4154
|
-
});
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
class NavigationBar {
|
|
3786
|
+
/**
|
|
3787
|
+
* A promise for the user's favorite color.
|
|
3788
|
+
*
|
|
3789
|
+
* @promise FavoriteColorPromise
|
|
3790
|
+
* @fulfill {string} The user's favorite color.
|
|
3791
|
+
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
3792
|
+
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
3793
|
+
*/
|
|
3794
|
+
/**
|
|
3795
|
+
* Dynamically sets the title of the current page.
|
|
3796
|
+
*
|
|
3797
|
+
* @async
|
|
3798
|
+
* @function setNavigationBarTitle
|
|
3799
|
+
* @category Navigation Bar
|
|
3800
|
+
*
|
|
3801
|
+
* @example
|
|
3802
|
+
*
|
|
3803
|
+
* zmpApis.setNavigationBarTitle({
|
|
3804
|
+
* title: "Current Page"
|
|
3805
|
+
* }).then((res) => {
|
|
3806
|
+
* console.log("Success");
|
|
3807
|
+
* }).catch((error) => {
|
|
3808
|
+
* console.log("Fail");
|
|
3809
|
+
* });
|
|
3810
|
+
*
|
|
3811
|
+
* @param {Object} object
|
|
3812
|
+
* @param {string} object.title - The title of the page
|
|
3813
|
+
*
|
|
3814
|
+
* @return {Promise}
|
|
3815
|
+
*
|
|
3816
|
+
*/
|
|
3817
|
+
static setNavigationBarTitle(object) {
|
|
3818
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3819
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
3820
|
+
title: object.title
|
|
3821
|
+
}, {
|
|
3822
|
+
haveTimeout: false
|
|
3823
|
+
});
|
|
3824
|
+
});
|
|
4155
3825
|
}
|
|
4156
3826
|
/**
|
|
4157
3827
|
* Sets the color of the navigation bar in the page.
|
|
@@ -4194,7 +3864,7 @@ class NavigationBar {
|
|
|
4194
3864
|
actionBarType = HIDE_ACTION_BAR;
|
|
4195
3865
|
}
|
|
4196
3866
|
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
|
|
4197
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
3867
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
4198
3868
|
haveTimeout: false
|
|
4199
3869
|
});
|
|
4200
3870
|
});
|
|
@@ -4244,14 +3914,14 @@ class NavigationBar {
|
|
|
4244
3914
|
: ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
|
|
4245
3915
|
}
|
|
4246
3916
|
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 }) })));
|
|
4247
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
3917
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
4248
3918
|
haveTimeout: false
|
|
4249
3919
|
});
|
|
4250
3920
|
});
|
|
4251
3921
|
}
|
|
4252
3922
|
static setNavigationBar(data) {
|
|
4253
3923
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4254
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3924
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4255
3925
|
data
|
|
4256
3926
|
}, {
|
|
4257
3927
|
haveTimeout: false
|
|
@@ -4286,7 +3956,7 @@ class Background {
|
|
|
4286
3956
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4287
3957
|
if (_.isString(object.backgroundColor) &&
|
|
4288
3958
|
object.backgroundColor.length > 0) {
|
|
4289
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3959
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4290
3960
|
actionbarType: this.isShowNavBar ? 5 : 6,
|
|
4291
3961
|
dataConfig: {
|
|
4292
3962
|
backgroundColor: object.backgroundColor,
|
|
@@ -4398,7 +4068,7 @@ class Device {
|
|
|
4398
4068
|
*/
|
|
4399
4069
|
static setDeviceOrientation(object) {
|
|
4400
4070
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4401
|
-
yield this.callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4071
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4402
4072
|
autoRotate: OrientationType[object.rotate]
|
|
4403
4073
|
});
|
|
4404
4074
|
});
|
|
@@ -4422,7 +4092,7 @@ class Device {
|
|
|
4422
4092
|
*/
|
|
4423
4093
|
static getNetworkType(object) {
|
|
4424
4094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4425
|
-
const resData = yield this.callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4095
|
+
const resData = yield this.getJSBridge().callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4426
4096
|
url: window.location.href,
|
|
4427
4097
|
featureId: ''
|
|
4428
4098
|
}).then((data) => {
|
|
@@ -4536,7 +4206,7 @@ class Device {
|
|
|
4536
4206
|
items: Array.isArray(object === null || object === void 0 ? void 0 : object.items) ? object === null || object === void 0 ? void 0 : object.items : []
|
|
4537
4207
|
}
|
|
4538
4208
|
};
|
|
4539
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4209
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4540
4210
|
return true;
|
|
4541
4211
|
});
|
|
4542
4212
|
}
|
|
@@ -4555,7 +4225,7 @@ class Device {
|
|
|
4555
4225
|
const data = {
|
|
4556
4226
|
subaction: 2
|
|
4557
4227
|
};
|
|
4558
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4228
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4559
4229
|
return true;
|
|
4560
4230
|
});
|
|
4561
4231
|
}
|
|
@@ -4576,7 +4246,7 @@ class Device {
|
|
|
4576
4246
|
const data = {
|
|
4577
4247
|
subaction: 1
|
|
4578
4248
|
};
|
|
4579
|
-
const resData = yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4249
|
+
const resData = yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4580
4250
|
isMultiCallback: true
|
|
4581
4251
|
}).then((resData) => {
|
|
4582
4252
|
const res = {
|
|
@@ -4618,7 +4288,7 @@ class Device {
|
|
|
4618
4288
|
*/
|
|
4619
4289
|
static stopBluetoothDevicesDiscovery() {
|
|
4620
4290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4621
|
-
return this.callNative({
|
|
4291
|
+
return this.getJSBridge().callNative({
|
|
4622
4292
|
name: ''
|
|
4623
4293
|
}, {});
|
|
4624
4294
|
});
|
|
@@ -4645,7 +4315,7 @@ class Device {
|
|
|
4645
4315
|
*/
|
|
4646
4316
|
static startBluetoothDevicesDiscovery(object) {
|
|
4647
4317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4648
|
-
return this.callNative({
|
|
4318
|
+
return this.getJSBridge().callNative({
|
|
4649
4319
|
name: ''
|
|
4650
4320
|
}, Object.assign({}, object));
|
|
4651
4321
|
});
|
|
@@ -4669,7 +4339,7 @@ class Device {
|
|
|
4669
4339
|
*/
|
|
4670
4340
|
static openBluetoothAdapter() {
|
|
4671
4341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4672
|
-
return this.callNative({
|
|
4342
|
+
return this.getJSBridge().callNative({
|
|
4673
4343
|
name: ''
|
|
4674
4344
|
}, {});
|
|
4675
4345
|
});
|
|
@@ -4689,7 +4359,7 @@ class Device {
|
|
|
4689
4359
|
*/
|
|
4690
4360
|
static onBluetoothDeviceFound() {
|
|
4691
4361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4692
|
-
return this.callNative({
|
|
4362
|
+
return this.getJSBridge().callNative({
|
|
4693
4363
|
name: ''
|
|
4694
4364
|
}, {});
|
|
4695
4365
|
});
|
|
@@ -4737,7 +4407,7 @@ class Device {
|
|
|
4737
4407
|
const data = {
|
|
4738
4408
|
services: object.services || []
|
|
4739
4409
|
};
|
|
4740
|
-
return this.callNative({
|
|
4410
|
+
return this.getJSBridge().callNative({
|
|
4741
4411
|
name: ''
|
|
4742
4412
|
}, data);
|
|
4743
4413
|
});
|
|
@@ -4758,7 +4428,7 @@ class Device {
|
|
|
4758
4428
|
*/
|
|
4759
4429
|
static getBluetoothDevices() {
|
|
4760
4430
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4761
|
-
return this.callNative({
|
|
4431
|
+
return this.getJSBridge().callNative({
|
|
4762
4432
|
name: ''
|
|
4763
4433
|
}, {});
|
|
4764
4434
|
});
|
|
@@ -4779,7 +4449,7 @@ class Device {
|
|
|
4779
4449
|
*/
|
|
4780
4450
|
static getBluetoothAdapterState() {
|
|
4781
4451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4782
|
-
return this.callNative({
|
|
4452
|
+
return this.getJSBridge().callNative({
|
|
4783
4453
|
name: ''
|
|
4784
4454
|
}, {});
|
|
4785
4455
|
});
|
|
@@ -4800,7 +4470,7 @@ class Device {
|
|
|
4800
4470
|
*/
|
|
4801
4471
|
static closeBluetoothAdapter() {
|
|
4802
4472
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4803
|
-
return this.callNative({
|
|
4473
|
+
return this.getJSBridge().callNative({
|
|
4804
4474
|
name: ''
|
|
4805
4475
|
}, {});
|
|
4806
4476
|
});
|
|
@@ -4814,7 +4484,7 @@ class Device {
|
|
|
4814
4484
|
*/
|
|
4815
4485
|
static scanQRCode(object) {
|
|
4816
4486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4817
|
-
return yield this.callNative(ACTION.OPEN_QR, {
|
|
4487
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_QR, {
|
|
4818
4488
|
skipOpenLink: true
|
|
4819
4489
|
});
|
|
4820
4490
|
});
|
|
@@ -4828,7 +4498,7 @@ class Device {
|
|
|
4828
4498
|
*/
|
|
4829
4499
|
static showToast(object) {
|
|
4830
4500
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4831
|
-
yield this.callNative(ACTION.SHOW_TOAST, {
|
|
4501
|
+
yield this.getJSBridge().callNative(ACTION.SHOW_TOAST, {
|
|
4832
4502
|
toast: object.message
|
|
4833
4503
|
});
|
|
4834
4504
|
});
|
|
@@ -4842,294 +4512,756 @@ class Device {
|
|
|
4842
4512
|
*/
|
|
4843
4513
|
static hideKeyboard(object) {
|
|
4844
4514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4845
|
-
yield this.callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4515
|
+
yield this.getJSBridge().callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4516
|
+
});
|
|
4517
|
+
}
|
|
4518
|
+
/**
|
|
4519
|
+
* Open phone
|
|
4520
|
+
* @async
|
|
4521
|
+
* @function openPhone
|
|
4522
|
+
* @category Device
|
|
4523
|
+
*
|
|
4524
|
+
*/
|
|
4525
|
+
static openPhone(object) {
|
|
4526
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4527
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_PHONE, {
|
|
4528
|
+
phoneNum: object.phoneNumber,
|
|
4529
|
+
phoneCode: object.phoneNumber
|
|
4530
|
+
});
|
|
4531
|
+
});
|
|
4532
|
+
}
|
|
4533
|
+
/**
|
|
4534
|
+
* Open SMS
|
|
4535
|
+
* @async
|
|
4536
|
+
* @function openSMS
|
|
4537
|
+
* @category Device
|
|
4538
|
+
*
|
|
4539
|
+
*/
|
|
4540
|
+
static openSMS(object) {
|
|
4541
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4542
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_SMS, {
|
|
4543
|
+
content: object.content,
|
|
4544
|
+
phoneCode: object.phoneNumber
|
|
4545
|
+
});
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
/**
|
|
4549
|
+
* Keep screen.
|
|
4550
|
+
* @async
|
|
4551
|
+
* @function keepScreen
|
|
4552
|
+
* @category Device
|
|
4553
|
+
*
|
|
4554
|
+
*/
|
|
4555
|
+
static keepScreen(object) {
|
|
4556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4557
|
+
return yield this.getJSBridge().callNative(ACTION.KEEP_SCREEN, {
|
|
4558
|
+
data: {
|
|
4559
|
+
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4560
|
+
}
|
|
4561
|
+
});
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
/**
|
|
4565
|
+
* Xác thực bằng sinh trắc học
|
|
4566
|
+
* @async
|
|
4567
|
+
* @function openBioAuthentication
|
|
4568
|
+
* @category Authentication
|
|
4569
|
+
*
|
|
4570
|
+
*/
|
|
4571
|
+
static openBioAuthentication(object) {
|
|
4572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4573
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION, {
|
|
4574
|
+
secret_data: object.secretData,
|
|
4575
|
+
app_id: this.getZAppId(),
|
|
4576
|
+
ui: {
|
|
4577
|
+
title: object.ui.title,
|
|
4578
|
+
sub_title: object.ui.subTitle,
|
|
4579
|
+
negative_text: object.ui.negativeButtonText
|
|
4580
|
+
},
|
|
4581
|
+
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4582
|
+
}).then((data) => {
|
|
4583
|
+
var _a, _b, _c, _d;
|
|
4584
|
+
return {
|
|
4585
|
+
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4586
|
+
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4587
|
+
data: {
|
|
4588
|
+
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4589
|
+
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4590
|
+
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4591
|
+
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4592
|
+
}
|
|
4593
|
+
};
|
|
4594
|
+
});
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4597
|
+
/**
|
|
4598
|
+
* 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...)
|
|
4599
|
+
* @async
|
|
4600
|
+
* @function checkStateBioAuthentication
|
|
4601
|
+
* @category Authentication
|
|
4602
|
+
*
|
|
4603
|
+
* @example
|
|
4604
|
+
* api.checkStateAuthen({
|
|
4605
|
+
* success: (res) => {},
|
|
4606
|
+
* fail: (err) => {}
|
|
4607
|
+
* })
|
|
4608
|
+
* @param {InputDataType.CallbackType} object
|
|
4609
|
+
*/
|
|
4610
|
+
static checkStateBioAuthentication(object) {
|
|
4611
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4612
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4613
|
+
return {
|
|
4614
|
+
bioState: data === null || data === void 0 ? void 0 : data.bio_state
|
|
4615
|
+
};
|
|
4616
|
+
});
|
|
4617
|
+
});
|
|
4618
|
+
}
|
|
4619
|
+
/**
|
|
4620
|
+
* Vibrate.
|
|
4621
|
+
* @async
|
|
4622
|
+
* @function vibrate
|
|
4623
|
+
* @category Device
|
|
4624
|
+
*
|
|
4625
|
+
*/
|
|
4626
|
+
static vibrate(object) {
|
|
4627
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4628
|
+
return yield this.getJSBridge().callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4629
|
+
type: VibrateType[object.type],
|
|
4630
|
+
vibrate_time: object.milliseconds
|
|
4631
|
+
});
|
|
4632
|
+
});
|
|
4633
|
+
}
|
|
4634
|
+
/**
|
|
4635
|
+
* Connect Wifi.
|
|
4636
|
+
* @async
|
|
4637
|
+
* @function connectWifi
|
|
4638
|
+
* @category Device
|
|
4639
|
+
*
|
|
4640
|
+
*/
|
|
4641
|
+
static connectWifi(object) {
|
|
4642
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4643
|
+
let securityType = 'open';
|
|
4644
|
+
if (_.isString(object.password) && object.password.length > 0) {
|
|
4645
|
+
securityType = 'wpa_wpa2';
|
|
4646
|
+
}
|
|
4647
|
+
return yield this.getJSBridge().callNative(ACTION.MP_JOIN_WIFI, {
|
|
4648
|
+
ssid: object.SSID,
|
|
4649
|
+
securityType: securityType,
|
|
4650
|
+
password: object.password,
|
|
4651
|
+
hiddenSsid: object.hiddenSSID
|
|
4652
|
+
});
|
|
4653
|
+
});
|
|
4654
|
+
}
|
|
4655
|
+
/**
|
|
4656
|
+
* Open App Store.
|
|
4657
|
+
* @async
|
|
4658
|
+
* @function openAppStore
|
|
4659
|
+
* @category Device
|
|
4660
|
+
*
|
|
4661
|
+
*/
|
|
4662
|
+
static openAppStore(object) {
|
|
4663
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4664
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_APPSTORE, object);
|
|
4665
|
+
});
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
|
|
4669
|
+
var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
|
|
4670
|
+
class LocalResourceStorage {
|
|
4671
|
+
constructor(prefix) {
|
|
4672
|
+
_LocalResourceStorage_storage.set(this, localStorage);
|
|
4673
|
+
_LocalResourceStorage_prefix.set(this, void 0);
|
|
4674
|
+
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
4675
|
+
checkPlatform();
|
|
4676
|
+
// if (platform.isMobile && platform.isZalo) {
|
|
4677
|
+
// Object.defineProperty(window, 'localStorage', {
|
|
4678
|
+
// value: null,
|
|
4679
|
+
// configurable: true,
|
|
4680
|
+
// enumerable: true,
|
|
4681
|
+
// writable: false
|
|
4682
|
+
// });
|
|
4683
|
+
// }
|
|
4684
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
4685
|
+
keys: new Set(),
|
|
4686
|
+
currentSize: 0,
|
|
4687
|
+
limitSize: STORAGE_LIMIT
|
|
4688
|
+
}, "f");
|
|
4689
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
4690
|
+
this.findAllCurrentDataByApp(prefix);
|
|
4691
|
+
}
|
|
4692
|
+
findAllCurrentDataByApp(prefix) {
|
|
4693
|
+
try {
|
|
4694
|
+
let _x;
|
|
4695
|
+
for (_x in __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f")) {
|
|
4696
|
+
if (prefix) {
|
|
4697
|
+
const _prefix = _x.split('_')[0];
|
|
4698
|
+
if (_prefix !== prefix) {
|
|
4699
|
+
continue;
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
catch (error) {
|
|
4706
|
+
logger.error(error, 'LocalResourceStorage > findAllCurrentDataByApp');
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
get(keys) {
|
|
4710
|
+
let res = new Map();
|
|
4711
|
+
keys.forEach((key) => {
|
|
4712
|
+
res.set(key, this.getSync(key));
|
|
4846
4713
|
});
|
|
4714
|
+
return Promise.resolve(res);
|
|
4715
|
+
}
|
|
4716
|
+
getSync(key) {
|
|
4717
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4718
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4719
|
+
}
|
|
4720
|
+
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
4721
|
+
return null;
|
|
4722
|
+
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
4847
4723
|
}
|
|
4848
|
-
|
|
4849
|
-
* Open phone
|
|
4850
|
-
* @async
|
|
4851
|
-
* @function openPhone
|
|
4852
|
-
* @category Device
|
|
4853
|
-
*
|
|
4854
|
-
*/
|
|
4855
|
-
static openPhone(object) {
|
|
4724
|
+
set(data) {
|
|
4856
4725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
phoneCode: object.phoneNumber
|
|
4726
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
4727
|
+
this.setSync(key, value.replace(/\\"/g, '"'));
|
|
4860
4728
|
});
|
|
4729
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4861
4730
|
});
|
|
4862
4731
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4732
|
+
setSync(key, value) {
|
|
4733
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4734
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4735
|
+
}
|
|
4736
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").setItem(key, value);
|
|
4737
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(key);
|
|
4738
|
+
}
|
|
4739
|
+
getInfo() {
|
|
4871
4740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4872
|
-
|
|
4873
|
-
content: object.content,
|
|
4874
|
-
phoneCode: object.phoneNumber
|
|
4875
|
-
});
|
|
4741
|
+
return Promise.resolve(this.getInfoSync());
|
|
4876
4742
|
});
|
|
4877
4743
|
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4744
|
+
getInfoSync() {
|
|
4745
|
+
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
4746
|
+
return {
|
|
4747
|
+
currentSize: _.isNumber(currentSize)
|
|
4748
|
+
? Number((currentSize / 1024).toFixed(2))
|
|
4749
|
+
: 0,
|
|
4750
|
+
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
remove(keys) {
|
|
4886
4754
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4890
|
-
}
|
|
4755
|
+
keys.forEach((key) => {
|
|
4756
|
+
this.removeSync(key);
|
|
4891
4757
|
});
|
|
4758
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4892
4759
|
});
|
|
4893
4760
|
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4761
|
+
removeSync(key) {
|
|
4762
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4763
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4764
|
+
}
|
|
4765
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key)) {
|
|
4766
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4767
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
clear() {
|
|
4902
4771
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4903
|
-
return
|
|
4904
|
-
secret_data: object.secretData,
|
|
4905
|
-
app_id: this.getZAppId(),
|
|
4906
|
-
ui: {
|
|
4907
|
-
title: object.ui.title,
|
|
4908
|
-
sub_title: object.ui.subTitle,
|
|
4909
|
-
negative_text: object.ui.negativeButtonText
|
|
4910
|
-
},
|
|
4911
|
-
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4912
|
-
}).then((data) => {
|
|
4913
|
-
var _a, _b, _c, _d;
|
|
4914
|
-
return {
|
|
4915
|
-
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4916
|
-
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4917
|
-
data: {
|
|
4918
|
-
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4919
|
-
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4920
|
-
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4921
|
-
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4922
|
-
}
|
|
4923
|
-
};
|
|
4924
|
-
});
|
|
4772
|
+
return Promise.resolve(this.clearSync());
|
|
4925
4773
|
});
|
|
4926
4774
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4775
|
+
clearSync() {
|
|
4776
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
4777
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4781
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4782
|
+
});
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
_LocalResourceStorage_storage = new WeakMap(), _LocalResourceStorage_prefix = new WeakMap(), _LocalResourceStorage_resourceInfo = new WeakMap();
|
|
4786
|
+
|
|
4787
|
+
var wrappers = {};
|
|
4788
|
+
var WrapperFn = function wrapFunction(fn, type, source) {
|
|
4789
|
+
var t = type || 'default';
|
|
4790
|
+
return function () {
|
|
4791
|
+
var callee = t in wrappers ? wrappers[t](fn, source) : fn;
|
|
4792
|
+
return callee.apply(this, arguments);
|
|
4793
|
+
};
|
|
4794
|
+
};
|
|
4795
|
+
WrapperFn.setWrapper = function (fn) {
|
|
4796
|
+
var type = arguments.length <= 1 || arguments[1] === undefined
|
|
4797
|
+
? 'default'
|
|
4798
|
+
: arguments[1];
|
|
4799
|
+
wrappers[type] = fn;
|
|
4800
|
+
};
|
|
4801
|
+
var ERROR = {
|
|
4802
|
+
error: {
|
|
4803
|
+
code: 1,
|
|
4804
|
+
error_subcode: 1357046,
|
|
4805
|
+
message: 'Received Invalid JSON reply.',
|
|
4806
|
+
type: 'http'
|
|
4807
|
+
}
|
|
4808
|
+
};
|
|
4809
|
+
function safelyParseResponse(rawResponse) {
|
|
4810
|
+
try {
|
|
4811
|
+
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
4812
|
+
}
|
|
4813
|
+
catch (ex) {
|
|
4814
|
+
return ERROR;
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
function createCORSRequest(method, url) {
|
|
4818
|
+
if (!self.XMLHttpRequest) {
|
|
4819
|
+
return null;
|
|
4820
|
+
}
|
|
4821
|
+
var xhr = new XMLHttpRequest();
|
|
4822
|
+
var noop = function noop() { };
|
|
4823
|
+
if ('withCredentials' in xhr) {
|
|
4824
|
+
xhr.open(method, url, true);
|
|
4825
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
4826
|
+
}
|
|
4827
|
+
else {
|
|
4828
|
+
return null;
|
|
4829
|
+
}
|
|
4830
|
+
var wrapper = {
|
|
4831
|
+
send: function send(data) {
|
|
4832
|
+
xhr.send(data);
|
|
4833
|
+
}
|
|
4834
|
+
};
|
|
4835
|
+
var onload = WrapperFn(function () {
|
|
4836
|
+
onload = noop;
|
|
4837
|
+
if ('onload' in wrapper) {
|
|
4838
|
+
wrapper.onload(xhr);
|
|
4839
|
+
}
|
|
4840
|
+
}, 'entry', 'XMLHttpRequest:load');
|
|
4841
|
+
var onerror = WrapperFn(function () {
|
|
4842
|
+
onerror = noop;
|
|
4843
|
+
if ('onerror' in wrapper) {
|
|
4844
|
+
wrapper.onerror(xhr);
|
|
4845
|
+
}
|
|
4846
|
+
}, 'entry', 'XMLHttpRequest:error');
|
|
4847
|
+
xhr.onload = function () {
|
|
4848
|
+
onload();
|
|
4849
|
+
};
|
|
4850
|
+
xhr.onerror = function () {
|
|
4851
|
+
onerror();
|
|
4852
|
+
};
|
|
4853
|
+
xhr.onreadystatechange = function () {
|
|
4854
|
+
if (xhr.readyState == 4) {
|
|
4855
|
+
if (xhr.status == 200) {
|
|
4856
|
+
onload();
|
|
4857
|
+
}
|
|
4858
|
+
else {
|
|
4859
|
+
onerror();
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
return wrapper;
|
|
4864
|
+
}
|
|
4865
|
+
function execute(url, method, params, cb) {
|
|
4866
|
+
params.suppress_http_code = 1;
|
|
4867
|
+
var data = QueryString.encode(params);
|
|
4868
|
+
if (method != 'post') {
|
|
4869
|
+
url = QueryString.appendToUrl(url, data);
|
|
4870
|
+
data = '';
|
|
4871
|
+
}
|
|
4872
|
+
var request = createCORSRequest(method, url);
|
|
4873
|
+
if (!request) {
|
|
4874
|
+
return false;
|
|
4875
|
+
}
|
|
4876
|
+
request.onload = function (xhr) {
|
|
4877
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4878
|
+
};
|
|
4879
|
+
request.onerror = function (xhr) {
|
|
4880
|
+
if (xhr.responseText) {
|
|
4881
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4882
|
+
}
|
|
4883
|
+
else {
|
|
4884
|
+
cb({
|
|
4885
|
+
error: {
|
|
4886
|
+
code: 1,
|
|
4887
|
+
error_subcode: 1357045,
|
|
4888
|
+
message: 'unknown error (empty response)',
|
|
4889
|
+
status: xhr.status,
|
|
4890
|
+
type: 'http'
|
|
4891
|
+
}
|
|
4892
|
+
});
|
|
4893
|
+
}
|
|
4894
|
+
};
|
|
4895
|
+
request.send(data);
|
|
4896
|
+
return true;
|
|
4897
|
+
}
|
|
4898
|
+
var CORSRequest = {
|
|
4899
|
+
execute: execute
|
|
4900
|
+
};
|
|
4901
|
+
|
|
4902
|
+
var _ZaloJSBridge_instances, _ZaloJSBridge_cookies, _ZaloJSBridge_actionRuntimeInfo, _ZaloJSBridge_jsCall;
|
|
4903
|
+
class ZaloJSBridge extends eventemitter3 {
|
|
4904
|
+
constructor() {
|
|
4905
|
+
super();
|
|
4906
|
+
_ZaloJSBridge_instances.add(this);
|
|
4907
|
+
this.debug = Debug('zmp:ZaloJSBridge');
|
|
4908
|
+
this.events = ZMPEEmitter.getInstance();
|
|
4909
|
+
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
4910
|
+
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
4911
|
+
this.results = [];
|
|
4912
|
+
this._userAgent = getUserAgent();
|
|
4913
|
+
this._device = checkPlatform();
|
|
4914
|
+
this.isJumped = false;
|
|
4915
|
+
_ZaloJSBridge_cookies.set(this, null);
|
|
4916
|
+
_ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
|
|
4917
|
+
this.jump = () => {
|
|
4918
|
+
return new Promise((resolve, reject) => {
|
|
4919
|
+
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
|
|
4920
|
+
resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
|
|
4921
|
+
}
|
|
4922
|
+
else {
|
|
4923
|
+
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
4924
|
+
.then((data) => {
|
|
4925
|
+
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
4926
|
+
const actionPermission = (data && data.actionPermission) || [];
|
|
4927
|
+
Object.entries(actionPermission).forEach((item) => {
|
|
4928
|
+
const key = item[0];
|
|
4929
|
+
const value = item[1] || { perm: 0, decode: 0 };
|
|
4930
|
+
if (!__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key]) {
|
|
4931
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key] = {
|
|
4932
|
+
permission: false,
|
|
4933
|
+
support: false
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key].permission = value.perm === 1;
|
|
4937
|
+
});
|
|
4938
|
+
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
4939
|
+
if (jsToken) {
|
|
4940
|
+
this.jsAccessTk = jsToken.value;
|
|
4941
|
+
window.ZJSBridge.setJSToken &&
|
|
4942
|
+
window.ZJSBridge.setJSToken(jsToken.value);
|
|
4943
|
+
}
|
|
4944
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_cookies, cookies, "f");
|
|
4945
|
+
this.isJumped = true;
|
|
4946
|
+
resolve(cookies);
|
|
4947
|
+
})
|
|
4948
|
+
.catch((error) => {
|
|
4949
|
+
this.isJumped = false;
|
|
4950
|
+
reject(error);
|
|
4951
|
+
});
|
|
4952
|
+
}
|
|
4946
4953
|
});
|
|
4954
|
+
};
|
|
4955
|
+
this._jsCallFuncCallbacks = {};
|
|
4956
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_actionRuntimeInfo, {}, "f");
|
|
4957
|
+
this.events.on(Events.AppPaused, () => {
|
|
4958
|
+
if (this.results.length > 0) {
|
|
4959
|
+
let array = this.results;
|
|
4960
|
+
this.results = [];
|
|
4961
|
+
try {
|
|
4962
|
+
this.sendLogData(array);
|
|
4963
|
+
}
|
|
4964
|
+
catch (error) { }
|
|
4965
|
+
}
|
|
4947
4966
|
});
|
|
4967
|
+
if (this.sendLogTimer) {
|
|
4968
|
+
clearInterval(this.sendLogTimer);
|
|
4969
|
+
}
|
|
4970
|
+
else {
|
|
4971
|
+
this.sendLogTimer = setInterval(() => {
|
|
4972
|
+
if (this.results.length > 0) {
|
|
4973
|
+
let array = this.results;
|
|
4974
|
+
this.results = [];
|
|
4975
|
+
try {
|
|
4976
|
+
this.sendLogData(array);
|
|
4977
|
+
}
|
|
4978
|
+
catch (error) { }
|
|
4979
|
+
}
|
|
4980
|
+
}, 5000);
|
|
4981
|
+
}
|
|
4948
4982
|
}
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
*
|
|
4955
|
-
*/
|
|
4956
|
-
static vibrate(object) {
|
|
4957
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4958
|
-
return yield this.callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4959
|
-
type: VibrateType[object.type],
|
|
4960
|
-
vibrate_time: object.milliseconds
|
|
4961
|
-
});
|
|
4962
|
-
});
|
|
4983
|
+
static getInstance() {
|
|
4984
|
+
if (!ZaloJSBridge.instance) {
|
|
4985
|
+
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
4986
|
+
}
|
|
4987
|
+
return ZaloJSBridge.instance;
|
|
4963
4988
|
}
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
* @async
|
|
4967
|
-
* @function connectWifi
|
|
4968
|
-
* @category Device
|
|
4969
|
-
*
|
|
4970
|
-
*/
|
|
4971
|
-
static connectWifi(object) {
|
|
4972
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4973
|
-
let securityType = 'open';
|
|
4974
|
-
if (_.isString(object.password) && object.password.length > 0) {
|
|
4975
|
-
securityType = 'wpa_wpa2';
|
|
4976
|
-
}
|
|
4977
|
-
return yield this.callNative(ACTION.MP_JOIN_WIFI, {
|
|
4978
|
-
ssid: object.SSID,
|
|
4979
|
-
securityType: securityType,
|
|
4980
|
-
password: object.password,
|
|
4981
|
-
hiddenSsid: object.hiddenSSID
|
|
4982
|
-
});
|
|
4983
|
-
});
|
|
4989
|
+
set accessTk(value) {
|
|
4990
|
+
this._accessTk = value;
|
|
4984
4991
|
}
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
* @async
|
|
4988
|
-
* @function openAppStore
|
|
4989
|
-
* @category Device
|
|
4990
|
-
*
|
|
4991
|
-
*/
|
|
4992
|
-
static openAppStore(object) {
|
|
4993
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4994
|
-
return yield this.callNative(ACTION.OPEN_APPSTORE, object);
|
|
4995
|
-
});
|
|
4992
|
+
set jsAccessTk(value) {
|
|
4993
|
+
this._jsAccessTk = value;
|
|
4996
4994
|
}
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
limitSize: STORAGE_LIMIT
|
|
5018
|
-
}, "f");
|
|
5019
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
5020
|
-
this.findAllCurrentDataByApp(prefix);
|
|
4995
|
+
sendLogData(data) {
|
|
4996
|
+
try {
|
|
4997
|
+
const logData = data.map((item) => {
|
|
4998
|
+
return {
|
|
4999
|
+
action: item.action,
|
|
5000
|
+
error: item.error
|
|
5001
|
+
};
|
|
5002
|
+
});
|
|
5003
|
+
CORSRequest.execute(APIS.SEND_ACTION_LOG, 'post', {
|
|
5004
|
+
appId: window.APP_ID,
|
|
5005
|
+
data: JSON.stringify(logData)
|
|
5006
|
+
}, (response) => { });
|
|
5007
|
+
window.zmpSentry &&
|
|
5008
|
+
window.zmpSentry.captureMessage('Result from native', {
|
|
5009
|
+
extra: {
|
|
5010
|
+
data: data
|
|
5011
|
+
}
|
|
5012
|
+
});
|
|
5013
|
+
}
|
|
5014
|
+
catch (error) { }
|
|
5021
5015
|
}
|
|
5022
|
-
|
|
5016
|
+
onJSCall(key, data) {
|
|
5023
5017
|
try {
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5018
|
+
this.debug('onJSCall', key, data);
|
|
5019
|
+
const parsedData = parseJSON(data);
|
|
5020
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5021
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5022
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5023
|
+
if (!!callback) {
|
|
5024
|
+
try {
|
|
5025
|
+
callback.call(this, parsedData);
|
|
5026
|
+
}
|
|
5027
|
+
catch (error) {
|
|
5028
|
+
console.error('Call callback error', error);
|
|
5030
5029
|
}
|
|
5030
|
+
!!timeout && clearTimeout(timeout);
|
|
5031
|
+
this._jsCallFuncCallbacks[key] = null;
|
|
5032
|
+
delete this._jsCallFuncCallbacks[key];
|
|
5031
5033
|
}
|
|
5032
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
5033
5034
|
}
|
|
5035
|
+
this.results.push({
|
|
5036
|
+
action: parsedData.action,
|
|
5037
|
+
error: parsedData.error_code,
|
|
5038
|
+
message: parsedData.error_message
|
|
5039
|
+
});
|
|
5034
5040
|
}
|
|
5035
|
-
catch (
|
|
5036
|
-
|
|
5037
|
-
}
|
|
5038
|
-
}
|
|
5039
|
-
get(keys) {
|
|
5040
|
-
let res = new Map();
|
|
5041
|
-
keys.forEach((key) => {
|
|
5042
|
-
res.set(key, this.getSync(key));
|
|
5043
|
-
});
|
|
5044
|
-
return Promise.resolve(res);
|
|
5045
|
-
}
|
|
5046
|
-
getSync(key) {
|
|
5047
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5048
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5041
|
+
catch (e) {
|
|
5042
|
+
console.log('onJSCall', 'error', e);
|
|
5049
5043
|
}
|
|
5050
|
-
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
5051
|
-
return null;
|
|
5052
|
-
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
5053
5044
|
}
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5045
|
+
onMultiJSCall(key, data) {
|
|
5046
|
+
try {
|
|
5047
|
+
this.debug('onMultiJSCall', key, data);
|
|
5048
|
+
const parsedData = parseJSON(data);
|
|
5049
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5050
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5051
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5052
|
+
if (!!callback) {
|
|
5053
|
+
try {
|
|
5054
|
+
callback.call(this, parsedData);
|
|
5055
|
+
}
|
|
5056
|
+
catch (error) {
|
|
5057
|
+
console.error('Call callback error', error);
|
|
5058
|
+
}
|
|
5059
|
+
!!timeout && clearTimeout(timeout);
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
this.results.push({
|
|
5063
|
+
action: parsedData.action,
|
|
5064
|
+
error: parsedData.error_code,
|
|
5065
|
+
message: parsedData.error_message
|
|
5058
5066
|
});
|
|
5059
|
-
return Promise.resolve({ errorKeys: [] });
|
|
5060
|
-
});
|
|
5061
|
-
}
|
|
5062
|
-
setSync(key, value) {
|
|
5063
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5064
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5065
5067
|
}
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
getInfo() {
|
|
5070
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
5071
|
-
return Promise.resolve(this.getInfoSync());
|
|
5072
|
-
});
|
|
5073
|
-
}
|
|
5074
|
-
getInfoSync() {
|
|
5075
|
-
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
5076
|
-
return {
|
|
5077
|
-
currentSize: _.isNumber(currentSize)
|
|
5078
|
-
? Number((currentSize / 1024).toFixed(2))
|
|
5079
|
-
: 0,
|
|
5080
|
-
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
5081
|
-
};
|
|
5068
|
+
catch (e) {
|
|
5069
|
+
console.log('onMultiJSCall', 'error', e);
|
|
5070
|
+
}
|
|
5082
5071
|
}
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
});
|
|
5072
|
+
nativeEventHandler(eventId, eventName, eventData) {
|
|
5073
|
+
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
5074
|
+
const data = stringToData(eventData);
|
|
5075
|
+
this.debug(data);
|
|
5076
|
+
const convertedData = this.handleEventData(eventName, data);
|
|
5077
|
+
this.events.emit(eventName, eventId, convertedData);
|
|
5090
5078
|
}
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5079
|
+
handleEventData(eventName, data) {
|
|
5080
|
+
try {
|
|
5081
|
+
switch (eventName) {
|
|
5082
|
+
case Events.OpenApp:
|
|
5083
|
+
const { url } = data;
|
|
5084
|
+
const validUrl = new URL(url);
|
|
5085
|
+
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
5086
|
+
return {
|
|
5087
|
+
path: `${path ? path : '/'}${validUrl.search}`
|
|
5088
|
+
};
|
|
5089
|
+
break;
|
|
5090
|
+
default:
|
|
5091
|
+
return data;
|
|
5092
|
+
break;
|
|
5093
|
+
}
|
|
5094
5094
|
}
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5095
|
+
catch (error) {
|
|
5096
|
+
return data;
|
|
5098
5097
|
}
|
|
5099
5098
|
}
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
}
|
|
5099
|
+
defaultCallback(data) {
|
|
5100
|
+
if (data !== null && data !== undefined) {
|
|
5101
|
+
data = parseJSON(data);
|
|
5102
|
+
}
|
|
5104
5103
|
}
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5104
|
+
callNative(action, data, option) {
|
|
5105
|
+
this.debug(action.name, data);
|
|
5106
|
+
return new Promise((resolve, reject) => {
|
|
5107
|
+
const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
5108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5109
|
+
try {
|
|
5110
|
+
if (_.isUndefined(cb) || _.isNull(cb)) {
|
|
5111
|
+
return reject(new Error('Native callback is null'));
|
|
5112
|
+
}
|
|
5113
|
+
if (cb.error_code !== 0) {
|
|
5114
|
+
let error = new AppError(cb.error_code, cb.error_message);
|
|
5115
|
+
const platform = getPlatform();
|
|
5116
|
+
if (action === ACTION.JUMP_LOGIN) {
|
|
5117
|
+
error = new AppError(RESPONSE_CODE.UNKNOWN_ERROR, `Can not get auth code: ${cb.error_message}`);
|
|
5118
|
+
}
|
|
5119
|
+
else if (!this.isJumped && !action.skip_jump) {
|
|
5120
|
+
error = new AppError(RESPONSE.UNAUTHORIZED.code, RESPONSE.UNAUTHORIZED.message);
|
|
5121
|
+
}
|
|
5122
|
+
else if (String(error.message).toLowerCase() === 'permission required!' ||
|
|
5123
|
+
String(error.message).toLowerCase() === 'no permission!') {
|
|
5124
|
+
error = new AppError(RESPONSE.FORBIDDEN.code, RESPONSE.FORBIDDEN.message);
|
|
5125
|
+
}
|
|
5126
|
+
else if (COMMON_NATIVE_ERROR_CODE[platform][cb.error_code]) {
|
|
5127
|
+
error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
|
|
5128
|
+
}
|
|
5129
|
+
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)]) {
|
|
5130
|
+
let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
|
|
5131
|
+
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) {
|
|
5132
|
+
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}`;
|
|
5133
|
+
}
|
|
5134
|
+
error = new AppError(action.error_list[platform][String(cb.error_code)].map_to.code, error_message);
|
|
5135
|
+
}
|
|
5136
|
+
return reject(error);
|
|
5137
|
+
}
|
|
5138
|
+
if (option === null || option === void 0 ? void 0 : option.successCallback) {
|
|
5139
|
+
const res = yield option.successCallback(cb.data);
|
|
5140
|
+
return resolve(res);
|
|
5141
|
+
}
|
|
5142
|
+
else {
|
|
5143
|
+
resolve(cb.data || {});
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
catch (error) {
|
|
5147
|
+
return reject(error);
|
|
5148
|
+
}
|
|
5149
|
+
});
|
|
5150
|
+
const isIOS = checkPlatform().isIOS;
|
|
5151
|
+
const isSupportAction = checkIOSSupportAction(action);
|
|
5152
|
+
if (isIOS && !isSupportAction) {
|
|
5153
|
+
const error = new AppError(-5, `Client isn't support this action`);
|
|
5154
|
+
return reject(error);
|
|
5155
|
+
}
|
|
5156
|
+
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
5157
|
+
setTimeout(() => {
|
|
5158
|
+
__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);
|
|
5159
|
+
}, option.delay);
|
|
5160
|
+
}
|
|
5161
|
+
else {
|
|
5162
|
+
__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);
|
|
5109
5163
|
}
|
|
5110
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
5111
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5112
5164
|
});
|
|
5113
5165
|
}
|
|
5114
5166
|
}
|
|
5115
|
-
|
|
5167
|
+
_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) {
|
|
5168
|
+
try {
|
|
5169
|
+
const actionName = action.name;
|
|
5170
|
+
const key = generateUniqueString(actionName);
|
|
5171
|
+
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
5172
|
+
this.onJSCall(key, {
|
|
5173
|
+
error_code: -13,
|
|
5174
|
+
error_message: 'params invalid!',
|
|
5175
|
+
data: {
|
|
5176
|
+
device: this._device.isMobile,
|
|
5177
|
+
jsToken: this._jsAccessTk,
|
|
5178
|
+
access_token: this._accessTk
|
|
5179
|
+
},
|
|
5180
|
+
action: actionName
|
|
5181
|
+
});
|
|
5182
|
+
return false;
|
|
5183
|
+
}
|
|
5184
|
+
if (options === undefined || options === null) {
|
|
5185
|
+
options = {};
|
|
5186
|
+
}
|
|
5187
|
+
if (!callback) {
|
|
5188
|
+
callback = this.defaultCallback;
|
|
5189
|
+
}
|
|
5190
|
+
const timeoutCallback = {
|
|
5191
|
+
error_code: -14,
|
|
5192
|
+
error_message: 'Request Timeout!',
|
|
5193
|
+
data: {},
|
|
5194
|
+
action: actionName
|
|
5195
|
+
};
|
|
5196
|
+
this._jsCallFuncCallbacks[key] = {
|
|
5197
|
+
timeout: haveTimeout &&
|
|
5198
|
+
action.have_callback &&
|
|
5199
|
+
setTimeout(() => {
|
|
5200
|
+
this.onJSCall(key, timeoutCallback);
|
|
5201
|
+
}, 8000),
|
|
5202
|
+
callback: callback
|
|
5203
|
+
};
|
|
5204
|
+
try {
|
|
5205
|
+
options = serialize(options);
|
|
5206
|
+
if (isMultiCallback) {
|
|
5207
|
+
if (this._device.isIOS) {
|
|
5208
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
5209
|
+
}
|
|
5210
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
5211
|
+
}
|
|
5212
|
+
if (this._device.isIOS) {
|
|
5213
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
5214
|
+
}
|
|
5215
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
5216
|
+
}
|
|
5217
|
+
catch (error) {
|
|
5218
|
+
if (nRetry-- > 0) {
|
|
5219
|
+
setTimeout(() => {
|
|
5220
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, options, callback, isMultiCallback, nRetry);
|
|
5221
|
+
}, 500);
|
|
5222
|
+
}
|
|
5223
|
+
else {
|
|
5224
|
+
const errorCallback = {
|
|
5225
|
+
error_code: -5,
|
|
5226
|
+
error_message: 'Not ready!',
|
|
5227
|
+
data: {
|
|
5228
|
+
userAgent: this._userAgent,
|
|
5229
|
+
options: options,
|
|
5230
|
+
jsToken: this._jsAccessTk,
|
|
5231
|
+
access_token: this._accessTk
|
|
5232
|
+
},
|
|
5233
|
+
action: actionName,
|
|
5234
|
+
js_error: error
|
|
5235
|
+
};
|
|
5236
|
+
this.onJSCall(key, errorCallback);
|
|
5237
|
+
return false;
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
catch (error) {
|
|
5242
|
+
console.log('jsCall', 'error', error);
|
|
5243
|
+
}
|
|
5244
|
+
return false;
|
|
5245
|
+
};
|
|
5116
5246
|
|
|
5117
|
-
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo;
|
|
5118
|
-
class NativeResourceStorage
|
|
5247
|
+
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo, _NativeResourceStorage_bridge;
|
|
5248
|
+
class NativeResourceStorage {
|
|
5119
5249
|
constructor(appId) {
|
|
5120
|
-
super();
|
|
5121
5250
|
_NativeResourceStorage_appId.set(this, void 0);
|
|
5122
5251
|
_NativeResourceStorage_resourceInfo.set(this, void 0);
|
|
5252
|
+
_NativeResourceStorage_bridge.set(this, void 0);
|
|
5123
5253
|
__classPrivateFieldSet(this, _NativeResourceStorage_resourceInfo, {
|
|
5124
5254
|
keys: new Set(),
|
|
5125
5255
|
currentSize: 0,
|
|
5126
5256
|
limitSize: STORAGE_LIMIT
|
|
5127
5257
|
}, "f");
|
|
5128
5258
|
__classPrivateFieldSet(this, _NativeResourceStorage_appId, appId, "f");
|
|
5259
|
+
__classPrivateFieldSet(this, _NativeResourceStorage_bridge, ZaloJSBridge.getInstance(), "f");
|
|
5129
5260
|
}
|
|
5130
5261
|
get(keys) {
|
|
5131
5262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5132
|
-
return yield this
|
|
5263
|
+
return yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5264
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5133
5265
|
mpds_action: 'mpds.get',
|
|
5134
5266
|
mpds_data: {
|
|
5135
5267
|
keys
|
|
@@ -5137,7 +5269,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5137
5269
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5138
5270
|
}, {
|
|
5139
5271
|
isMultiCallback: false
|
|
5140
|
-
})
|
|
5272
|
+
})
|
|
5273
|
+
.then((data) => {
|
|
5141
5274
|
let res = new Map();
|
|
5142
5275
|
if (data && data.mpds_data && data.mpds_data.map) {
|
|
5143
5276
|
res = new Map(Object.entries(data.mpds_data.map));
|
|
@@ -5148,7 +5281,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5148
5281
|
}
|
|
5149
5282
|
set(data) {
|
|
5150
5283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5151
|
-
const errorKeys = yield this
|
|
5284
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5285
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5152
5286
|
mpds_action: 'mpds.set',
|
|
5153
5287
|
mpds_data: {
|
|
5154
5288
|
map: data
|
|
@@ -5156,7 +5290,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5156
5290
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5157
5291
|
}, {
|
|
5158
5292
|
isMultiCallback: false
|
|
5159
|
-
})
|
|
5293
|
+
})
|
|
5294
|
+
.then((data) => {
|
|
5160
5295
|
let res = [];
|
|
5161
5296
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5162
5297
|
res = data.mpds_data.error_keys;
|
|
@@ -5168,13 +5303,15 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5168
5303
|
}
|
|
5169
5304
|
getInfo() {
|
|
5170
5305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5171
|
-
const currentSize = yield this
|
|
5306
|
+
const currentSize = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5307
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5172
5308
|
mpds_action: 'mpds.get.size',
|
|
5173
5309
|
mpds_data: {},
|
|
5174
5310
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5175
5311
|
}, {
|
|
5176
5312
|
isMultiCallback: false
|
|
5177
|
-
})
|
|
5313
|
+
})
|
|
5314
|
+
.then((data) => {
|
|
5178
5315
|
let res = 0;
|
|
5179
5316
|
if (data && data.mpds_data && data.mpds_data.size) {
|
|
5180
5317
|
res = data.mpds_data.size;
|
|
@@ -5189,7 +5326,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5189
5326
|
}
|
|
5190
5327
|
remove(keys) {
|
|
5191
5328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5192
|
-
const errorKeys = yield this
|
|
5329
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5330
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5193
5331
|
mpds_action: 'mpds.remove.key',
|
|
5194
5332
|
mpds_data: {
|
|
5195
5333
|
keys: keys
|
|
@@ -5197,7 +5335,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5197
5335
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5198
5336
|
}, {
|
|
5199
5337
|
isMultiCallback: false
|
|
5200
|
-
})
|
|
5338
|
+
})
|
|
5339
|
+
.then((data) => {
|
|
5201
5340
|
let res = [];
|
|
5202
5341
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5203
5342
|
res = data.mpds_data.error_keys;
|
|
@@ -5209,7 +5348,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5209
5348
|
}
|
|
5210
5349
|
clear() {
|
|
5211
5350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5212
|
-
yield this.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5351
|
+
yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f").callNative(ACTION.ZBROWSER_MPDS, {
|
|
5213
5352
|
mpds_action: 'mpds.clear.appData',
|
|
5214
5353
|
mpds_data: {},
|
|
5215
5354
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
@@ -5217,7 +5356,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5217
5356
|
});
|
|
5218
5357
|
}
|
|
5219
5358
|
}
|
|
5220
|
-
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap();
|
|
5359
|
+
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap(), _NativeResourceStorage_bridge = new WeakMap();
|
|
5221
5360
|
|
|
5222
5361
|
var _LocalStorageCreator_appId, _NativeStorageCreator_appId;
|
|
5223
5362
|
class StorageCreator {
|
|
@@ -5469,18 +5608,13 @@ class OpenApi {
|
|
|
5469
5608
|
*/
|
|
5470
5609
|
static getPhoneNumber(object) {
|
|
5471
5610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5472
|
-
return yield this.callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5611
|
+
return yield this.getJSBridge().callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5473
5612
|
isMultiCallback: true,
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
return Promise.resolve(res);
|
|
5480
|
-
}
|
|
5481
|
-
else {
|
|
5482
|
-
return Promise.reject(error);
|
|
5483
|
-
}
|
|
5613
|
+
successCallback: (data) => {
|
|
5614
|
+
const res = {
|
|
5615
|
+
number: data
|
|
5616
|
+
};
|
|
5617
|
+
return Promise.resolve(res);
|
|
5484
5618
|
},
|
|
5485
5619
|
delay: this.isIOS ? 400 : 0
|
|
5486
5620
|
});
|
|
@@ -5499,7 +5633,7 @@ class Window {
|
|
|
5499
5633
|
*/
|
|
5500
5634
|
static closeApp(object) {
|
|
5501
5635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5502
|
-
yield this.callNative(ACTION.WINDOW_CLOSE, {});
|
|
5636
|
+
yield this.getJSBridge().callNative(ACTION.WINDOW_CLOSE, {});
|
|
5503
5637
|
});
|
|
5504
5638
|
}
|
|
5505
5639
|
/**
|
|
@@ -5531,7 +5665,7 @@ class Window {
|
|
|
5531
5665
|
mpInfo.appName = appInfo.name;
|
|
5532
5666
|
mpInfo.appAvtUrl = appInfo.logoUrl;
|
|
5533
5667
|
}
|
|
5534
|
-
yield this.callNative(ACTION.OPEN_MP, {
|
|
5668
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_MP, {
|
|
5535
5669
|
mpUrl: `${MINI_APP_INTERNAL_LINK}/${appId}/${queryParamString.length > 0 ? '?' + queryParamString : ''}`,
|
|
5536
5670
|
mpInfo: mpInfo
|
|
5537
5671
|
});
|
|
@@ -5547,7 +5681,7 @@ class Window {
|
|
|
5547
5681
|
*/
|
|
5548
5682
|
static openWebview(url) {
|
|
5549
5683
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5550
|
-
yield this.callNative(ACTION.OPEN_INAPP, {
|
|
5684
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_INAPP, {
|
|
5551
5685
|
url: url
|
|
5552
5686
|
});
|
|
5553
5687
|
});
|
|
@@ -5562,7 +5696,7 @@ class Window {
|
|
|
5562
5696
|
*/
|
|
5563
5697
|
static closeLoading(when) {
|
|
5564
5698
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5565
|
-
yield this.callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5699
|
+
yield this.getJSBridge().callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5566
5700
|
at: new Date().getTime(),
|
|
5567
5701
|
when: when,
|
|
5568
5702
|
url: location.href
|
|
@@ -5589,30 +5723,24 @@ class Location {
|
|
|
5589
5723
|
*/
|
|
5590
5724
|
static getLocation(object) {
|
|
5591
5725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5592
|
-
return yield this.callNative(ACTION.GET_LOCATION, {
|
|
5726
|
+
return yield this.getJSBridge().callNative(ACTION.GET_LOCATION, {
|
|
5593
5727
|
silent_request: false,
|
|
5594
5728
|
permission_description: 'Cho phép Zalo truy cập vào vị trí của thiết bị này?'
|
|
5595
5729
|
}, {
|
|
5596
5730
|
isMultiCallback: true,
|
|
5597
5731
|
haveTimeout: false,
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
};
|
|
5611
|
-
return Promise.resolve(res);
|
|
5612
|
-
}
|
|
5613
|
-
else {
|
|
5614
|
-
return Promise.reject(error);
|
|
5615
|
-
}
|
|
5732
|
+
successCallback: (data) => {
|
|
5733
|
+
const res = {
|
|
5734
|
+
/** latitude */
|
|
5735
|
+
latitude: data.latitude,
|
|
5736
|
+
/** longitude */
|
|
5737
|
+
longitude: data.longitude,
|
|
5738
|
+
/** timestamp */
|
|
5739
|
+
timestamp: data.timestamp,
|
|
5740
|
+
/** provider */
|
|
5741
|
+
provider: data.provider
|
|
5742
|
+
};
|
|
5743
|
+
return Promise.resolve(res);
|
|
5616
5744
|
},
|
|
5617
5745
|
delay: this.isIOS ? 400 : 0
|
|
5618
5746
|
});
|
|
@@ -5628,7 +5756,7 @@ class Location {
|
|
|
5628
5756
|
*/
|
|
5629
5757
|
static sendLocation(object) {
|
|
5630
5758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5631
|
-
yield this.callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5759
|
+
yield this.getJSBridge().callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5632
5760
|
title: object.title,
|
|
5633
5761
|
touserid: object.toUserId,
|
|
5634
5762
|
zapp: this.getZAppId()
|
|
@@ -5648,17 +5776,12 @@ class Media {
|
|
|
5648
5776
|
*/
|
|
5649
5777
|
static requestCameraPermission(object) {
|
|
5650
5778
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5651
|
-
return yield this.callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
});
|
|
5658
|
-
}
|
|
5659
|
-
else {
|
|
5660
|
-
return Promise.reject(error);
|
|
5661
|
-
}
|
|
5779
|
+
return yield this.getJSBridge().callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5780
|
+
successCallback: () => {
|
|
5781
|
+
return Promise.resolve({
|
|
5782
|
+
userAllow: true,
|
|
5783
|
+
message: 'User Allow'
|
|
5784
|
+
});
|
|
5662
5785
|
}
|
|
5663
5786
|
});
|
|
5664
5787
|
});
|
|
@@ -5684,7 +5807,7 @@ class Media {
|
|
|
5684
5807
|
imageUrl: object.imageUrl
|
|
5685
5808
|
};
|
|
5686
5809
|
}
|
|
5687
|
-
return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5810
|
+
return yield this.getJSBridge().callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5688
5811
|
});
|
|
5689
5812
|
}
|
|
5690
5813
|
}
|
|
@@ -5699,7 +5822,7 @@ class Zalo {
|
|
|
5699
5822
|
*/
|
|
5700
5823
|
static viewOAQr(object) {
|
|
5701
5824
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5702
|
-
yield this.callNative(ACTION.VIEW_MYQR, {
|
|
5825
|
+
yield this.getJSBridge().callNative(ACTION.VIEW_MYQR, {
|
|
5703
5826
|
dpn: object.displayName,
|
|
5704
5827
|
uid: object.id,
|
|
5705
5828
|
zapp: this.getZAppId()
|
|
@@ -5718,7 +5841,7 @@ class Zalo {
|
|
|
5718
5841
|
*/
|
|
5719
5842
|
static openProfile(object) {
|
|
5720
5843
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5721
|
-
return yield this.callNative(ACTION.OPEN_PROFILE, {
|
|
5844
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_PROFILE, {
|
|
5722
5845
|
uId: object.id,
|
|
5723
5846
|
type: ProfileType[object.type],
|
|
5724
5847
|
zapp: this.getZAppId(),
|
|
@@ -5736,7 +5859,7 @@ class Zalo {
|
|
|
5736
5859
|
*/
|
|
5737
5860
|
static openChat(object) {
|
|
5738
5861
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5739
|
-
return yield this.callNative(ACTION.OPEN_CHAT, {
|
|
5862
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_CHAT, {
|
|
5740
5863
|
uId: object.id,
|
|
5741
5864
|
type: ChatType[object.type],
|
|
5742
5865
|
msg: object.message || '',
|
|
@@ -5778,7 +5901,9 @@ class Zalo {
|
|
|
5778
5901
|
};
|
|
5779
5902
|
break;
|
|
5780
5903
|
}
|
|
5781
|
-
return yield this.
|
|
5904
|
+
return yield this.getJSBridge()
|
|
5905
|
+
.callNative(ACTION.OPEN_POSTFEED, Object.assign(Object.assign({ type: PostFeedType[object.type] }, reqData), { zapp: this.getZAppId() }))
|
|
5906
|
+
.then((res) => {
|
|
5782
5907
|
return {
|
|
5783
5908
|
status: res.status,
|
|
5784
5909
|
shareType: res.share_type,
|
|
@@ -5797,7 +5922,7 @@ class Zalo {
|
|
|
5797
5922
|
*/
|
|
5798
5923
|
static followOA(object) {
|
|
5799
5924
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5800
|
-
yield this.callNative(ACTION.FOLLOW_OA, {
|
|
5925
|
+
yield this.getJSBridge().callNative(ACTION.FOLLOW_OA, {
|
|
5801
5926
|
uid: object.id,
|
|
5802
5927
|
showDialogConfirm: true,
|
|
5803
5928
|
zapp: this.getZAppId()
|
|
@@ -5816,7 +5941,7 @@ class Zalo {
|
|
|
5816
5941
|
*/
|
|
5817
5942
|
static unfollowOA(object) {
|
|
5818
5943
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5819
|
-
yield this.callNative(ACTION.UNFOLLOW_OA, {
|
|
5944
|
+
yield this.getJSBridge().callNative(ACTION.UNFOLLOW_OA, {
|
|
5820
5945
|
uid: object.id,
|
|
5821
5946
|
zapp: this.getZAppId()
|
|
5822
5947
|
}, {
|
|
@@ -5838,7 +5963,8 @@ class Zalo {
|
|
|
5838
5963
|
switch (object.type) {
|
|
5839
5964
|
case 'image':
|
|
5840
5965
|
let photoUrls = [];
|
|
5841
|
-
if (Array.isArray(object.data.imageUrls) &&
|
|
5966
|
+
if (Array.isArray(object.data.imageUrls) &&
|
|
5967
|
+
object.data.imageUrls.length > 0) {
|
|
5842
5968
|
photoUrls = object.data.imageUrls;
|
|
5843
5969
|
}
|
|
5844
5970
|
else {
|
|
@@ -5905,9 +6031,11 @@ class Zalo {
|
|
|
5905
6031
|
object.type = 'link';
|
|
5906
6032
|
}
|
|
5907
6033
|
}
|
|
5908
|
-
return yield this.
|
|
6034
|
+
return yield this.getJSBridge()
|
|
6035
|
+
.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[object.type] }, reqData), { zapp: this.getZAppId() }), {
|
|
5909
6036
|
haveTimeout: false
|
|
5910
|
-
})
|
|
6037
|
+
})
|
|
6038
|
+
.then((res) => {
|
|
5911
6039
|
return {
|
|
5912
6040
|
status: res.status,
|
|
5913
6041
|
shareType: res.share_type,
|
|
@@ -5926,7 +6054,7 @@ class Zalo {
|
|
|
5926
6054
|
*/
|
|
5927
6055
|
static createShortcut(url, title, icon) {
|
|
5928
6056
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5929
|
-
return yield this.callNative(ACTION.CREATE_SHORTCUT, {
|
|
6057
|
+
return yield this.getJSBridge().callNative(ACTION.CREATE_SHORTCUT, {
|
|
5930
6058
|
url: url,
|
|
5931
6059
|
title: title,
|
|
5932
6060
|
iconUrl: icon
|
|
@@ -5943,15 +6071,14 @@ class Zalo {
|
|
|
5943
6071
|
*/
|
|
5944
6072
|
static openProfilePicker(maxProfile) {
|
|
5945
6073
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5946
|
-
return yield this.callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
6074
|
+
return yield this.getJSBridge().callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
5947
6075
|
maxProfile: maxProfile
|
|
5948
6076
|
}, {
|
|
5949
6077
|
isMultiCallback: true,
|
|
5950
|
-
|
|
5951
|
-
if (
|
|
5952
|
-
return Promise.resolve(
|
|
6078
|
+
successCallback: (data) => {
|
|
6079
|
+
if (Array.isArray(data)) {
|
|
6080
|
+
return Promise.resolve(data.map((item) => item.id));
|
|
5953
6081
|
}
|
|
5954
|
-
return Promise.reject(error);
|
|
5955
6082
|
}
|
|
5956
6083
|
});
|
|
5957
6084
|
});
|
|
@@ -5966,15 +6093,15 @@ class Zalo {
|
|
|
5966
6093
|
*/
|
|
5967
6094
|
static getActionsSupported(object) {
|
|
5968
6095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5969
|
-
return yield this.callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
6096
|
+
return yield this.getJSBridge().callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
5970
6097
|
isMultiCallback: false,
|
|
5971
|
-
|
|
6098
|
+
successCallback: (data) => {
|
|
5972
6099
|
const platform = getPlatform();
|
|
5973
|
-
if (Array.isArray(
|
|
5974
|
-
|
|
6100
|
+
if (Array.isArray(data.actions) &&
|
|
6101
|
+
data.actions.length > 0) {
|
|
5975
6102
|
const skipJumpActions = Object.keys(ACTION).filter((item) => ACTION[item].skip_jump);
|
|
5976
6103
|
const res = {
|
|
5977
|
-
actions: [...
|
|
6104
|
+
actions: [...data.actions, ...skipJumpActions]
|
|
5978
6105
|
};
|
|
5979
6106
|
return Promise.resolve(res);
|
|
5980
6107
|
}
|
|
@@ -5984,7 +6111,6 @@ class Zalo {
|
|
|
5984
6111
|
};
|
|
5985
6112
|
return Promise.resolve(res);
|
|
5986
6113
|
}
|
|
5987
|
-
return Promise.reject(error);
|
|
5988
6114
|
}
|
|
5989
6115
|
});
|
|
5990
6116
|
});
|
|
@@ -6008,7 +6134,7 @@ class Zalo {
|
|
|
6008
6134
|
enable: 1,
|
|
6009
6135
|
aspect_ratio: '1:1'
|
|
6010
6136
|
};
|
|
6011
|
-
return yield this.callNative(ACTION.PICK_MEDIA, {
|
|
6137
|
+
return yield this.getJSBridge().callNative(ACTION.PICK_MEDIA, {
|
|
6012
6138
|
media_type: MediaPickerType[type],
|
|
6013
6139
|
edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
|
|
6014
6140
|
silent_request: silentRequest,
|
|
@@ -6016,15 +6142,11 @@ class Zalo {
|
|
|
6016
6142
|
max_select_items: maxSelectItem
|
|
6017
6143
|
}, {
|
|
6018
6144
|
isMultiCallback: true,
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
};
|
|
6025
|
-
return Promise.resolve(res);
|
|
6026
|
-
}
|
|
6027
|
-
return Promise.reject(error);
|
|
6145
|
+
successCallback: (data) => {
|
|
6146
|
+
const res = {
|
|
6147
|
+
data: data === null || data === void 0 ? void 0 : data.result_content
|
|
6148
|
+
};
|
|
6149
|
+
return Promise.resolve(res);
|
|
6028
6150
|
}
|
|
6029
6151
|
});
|
|
6030
6152
|
});
|
|
@@ -6039,7 +6161,7 @@ class Zalo {
|
|
|
6039
6161
|
*/
|
|
6040
6162
|
static openOutApp(url) {
|
|
6041
6163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6042
|
-
return yield this.callNative(ACTION.OPEN_OUTAPP, {
|
|
6164
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_OUTAPP, {
|
|
6043
6165
|
url: url
|
|
6044
6166
|
});
|
|
6045
6167
|
});
|
|
@@ -6078,7 +6200,7 @@ class Routing {
|
|
|
6078
6200
|
*/
|
|
6079
6201
|
static sendDataToPreviousMiniApp(object) {
|
|
6080
6202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6081
|
-
return yield this.callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6203
|
+
return yield this.getJSBridge().callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6082
6204
|
result: stringifyData(object.data)
|
|
6083
6205
|
});
|
|
6084
6206
|
});
|
|
@@ -6103,11 +6225,10 @@ class Routing {
|
|
|
6103
6225
|
}
|
|
6104
6226
|
}
|
|
6105
6227
|
|
|
6106
|
-
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn,
|
|
6107
|
-
class ZaloMiniProgramSDKService
|
|
6228
|
+
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;
|
|
6229
|
+
class ZaloMiniProgramSDKService {
|
|
6108
6230
|
constructor() {
|
|
6109
6231
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6110
|
-
super();
|
|
6111
6232
|
_ZaloMiniProgramSDKService_zAppId.set(this, ZAPP_ID);
|
|
6112
6233
|
_ZaloMiniProgramSDKService_appId.set(this, APP_ID);
|
|
6113
6234
|
_ZaloMiniProgramSDKService_appConfig.set(this, APP_CONFIG);
|
|
@@ -6120,9 +6241,9 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6120
6241
|
getToken: 0
|
|
6121
6242
|
}
|
|
6122
6243
|
});
|
|
6244
|
+
_ZaloMiniProgramSDKService_bridge.set(this, void 0);
|
|
6123
6245
|
_ZaloMiniProgramSDKService_prevGetTokenTimestamp.set(this, void 0);
|
|
6124
6246
|
_ZaloMiniProgramSDKService_tokenExpiresIn.set(this, void 0);
|
|
6125
|
-
_ZaloMiniProgramSDKService_cookies.set(this, null);
|
|
6126
6247
|
_ZaloMiniProgramSDKService_deviceId.set(this, void 0);
|
|
6127
6248
|
this.events = ZMPEEmitter.getInstance();
|
|
6128
6249
|
this.isIOS = checkPlatform().isIOS;
|
|
@@ -6133,34 +6254,6 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6133
6254
|
this.setActionBarConfig = (setState) => {
|
|
6134
6255
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
|
|
6135
6256
|
};
|
|
6136
|
-
_ZaloMiniProgramSDKService_callJump.set(this, () => {
|
|
6137
|
-
return new Promise((resolve, reject) => {
|
|
6138
|
-
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"))) {
|
|
6139
|
-
resolve(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"));
|
|
6140
|
-
}
|
|
6141
|
-
else {
|
|
6142
|
-
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
6143
|
-
.then((data) => {
|
|
6144
|
-
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
6145
|
-
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
6146
|
-
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6147
|
-
if (jsToken) {
|
|
6148
|
-
this.setJSToken(jsToken.value);
|
|
6149
|
-
window.ZJSBridge.setJSToken &&
|
|
6150
|
-
window.ZJSBridge.setJSToken(jsToken.value);
|
|
6151
|
-
}
|
|
6152
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_cookies, cookies, "f");
|
|
6153
|
-
if (deviceId) {
|
|
6154
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6155
|
-
}
|
|
6156
|
-
resolve(cookies);
|
|
6157
|
-
})
|
|
6158
|
-
.catch((error) => {
|
|
6159
|
-
reject(error);
|
|
6160
|
-
});
|
|
6161
|
-
}
|
|
6162
|
-
});
|
|
6163
|
-
});
|
|
6164
6257
|
this.getVersion = Basics.getVersion;
|
|
6165
6258
|
this.getSystemInfo = Basics.getSystemInfo;
|
|
6166
6259
|
this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
|
|
@@ -6231,6 +6324,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6231
6324
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, 0, "f");
|
|
6232
6325
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, 0, "f");
|
|
6233
6326
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, '', "f");
|
|
6327
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_bridge, ZaloJSBridge.getInstance(), "f");
|
|
6234
6328
|
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' ||
|
|
6235
6329
|
((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
|
|
6236
6330
|
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
@@ -6277,9 +6371,16 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6277
6371
|
getDeviceId() {
|
|
6278
6372
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
|
|
6279
6373
|
}
|
|
6374
|
+
getJSBridge() {
|
|
6375
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
|
|
6376
|
+
}
|
|
6280
6377
|
login(object) {
|
|
6281
6378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6282
|
-
const cookies = yield __classPrivateFieldGet(this,
|
|
6379
|
+
const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
|
|
6380
|
+
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6381
|
+
if (deviceId) {
|
|
6382
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6383
|
+
}
|
|
6283
6384
|
const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
|
|
6284
6385
|
const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
|
|
6285
6386
|
if (!_.isUndefined(zOAuthCookie) &&
|
|
@@ -6296,23 +6397,23 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6296
6397
|
yield this.loginZaloV3();
|
|
6297
6398
|
}
|
|
6298
6399
|
if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
|
|
6299
|
-
throw apiResponse.error.loginFailed();
|
|
6400
|
+
throw apiResponse.error.loginFailed('Invalid authorization code');
|
|
6300
6401
|
}
|
|
6301
6402
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
6302
6403
|
}
|
|
6303
|
-
throw apiResponse.error.loginFailed();
|
|
6404
|
+
throw apiResponse.error.loginFailed('Zalo app has not been activated');
|
|
6304
6405
|
});
|
|
6305
6406
|
}
|
|
6306
6407
|
loginZaloV3() {
|
|
6307
6408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6308
|
-
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=
|
|
6409
|
+
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* () {
|
|
6309
6410
|
let resData = yield response.json();
|
|
6310
6411
|
if (resData.access_token) {
|
|
6311
6412
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, resData.access_token, "f");
|
|
6312
6413
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6313
6414
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6314
6415
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6315
|
-
this.
|
|
6416
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6316
6417
|
window.ZJSBridge.setZAccSession &&
|
|
6317
6418
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6318
6419
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6349,7 +6450,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6349
6450
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6350
6451
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6351
6452
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6352
|
-
this.
|
|
6453
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6353
6454
|
window.ZJSBridge.setZAccSession &&
|
|
6354
6455
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6355
6456
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6370,7 +6471,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6370
6471
|
});
|
|
6371
6472
|
}
|
|
6372
6473
|
}
|
|
6373
|
-
_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(),
|
|
6474
|
+
_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();
|
|
6374
6475
|
|
|
6375
6476
|
var _MockSDKService_appId, _MockSDKService_appConfig, _MockSDKService_zOAuth, _MockSDKService_accessToken, _MockSDKService_cache, _MockSDKService_loggedId;
|
|
6376
6477
|
class MockSDKService {
|
|
@@ -8104,90 +8205,175 @@ function getFnParamNames(fn) {
|
|
|
8104
8205
|
.replace(/\s/gi, '')
|
|
8105
8206
|
.split(',');
|
|
8106
8207
|
}
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8208
|
+
/**
|
|
8209
|
+
* Copies all metadata from one object to another.
|
|
8210
|
+
* Useful for overwriting function definition in
|
|
8211
|
+
* decorators while keeping all previously
|
|
8212
|
+
* attached metadata
|
|
8213
|
+
*
|
|
8214
|
+
* @param from object to copy metadata from
|
|
8215
|
+
* @param to object to copy metadata to
|
|
8216
|
+
*/
|
|
8217
|
+
function copyMetadata(from, to) {
|
|
8218
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
8219
|
+
metadataKeys.map((key) => {
|
|
8220
|
+
const value = Reflect.getMetadata(key, from);
|
|
8221
|
+
Reflect.defineMetadata(key, value, to);
|
|
8222
|
+
});
|
|
8223
|
+
}
|
|
8224
|
+
/**
|
|
8225
|
+
* Apply the given decorator to all class methods
|
|
8226
|
+
*
|
|
8227
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
8228
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
8229
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
8230
|
+
*/
|
|
8231
|
+
const DecorateAll = (decorator, options = {}) => {
|
|
8232
|
+
return (target) => {
|
|
8233
|
+
var _a;
|
|
8234
|
+
let descriptors = Object.getOwnPropertyDescriptors(target.prototype);
|
|
8235
|
+
if (options.deep) {
|
|
8236
|
+
let base = Object.getPrototypeOf(target);
|
|
8237
|
+
while (base.prototype) {
|
|
8238
|
+
const baseDescriptors = Object.getOwnPropertyDescriptors(base.prototype);
|
|
8239
|
+
descriptors = Object.assign(Object.assign({}, baseDescriptors), descriptors);
|
|
8240
|
+
base = Object.getPrototypeOf(base);
|
|
8241
|
+
}
|
|
8242
|
+
}
|
|
8243
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
8244
|
+
const isMethod = typeof descriptor.value == 'function' && propName != 'constructor';
|
|
8245
|
+
if ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(propName))
|
|
8246
|
+
continue;
|
|
8247
|
+
if (options.excludePrefix && propName.startsWith(options.excludePrefix))
|
|
8248
|
+
continue;
|
|
8249
|
+
if (!isMethod)
|
|
8250
|
+
continue;
|
|
8251
|
+
const originalMethod = descriptor.value;
|
|
8252
|
+
decorator(target, propName, descriptor);
|
|
8253
|
+
if (originalMethod != descriptor.value) {
|
|
8254
|
+
copyMetadata(originalMethod, descriptor.value);
|
|
8255
|
+
}
|
|
8256
|
+
Object.defineProperty(target.prototype, propName, descriptor);
|
|
8257
|
+
}
|
|
8258
|
+
};
|
|
8259
|
+
};
|
|
8260
|
+
const centralizedFunctionHandler = (target, propertyName, descriptor) => {
|
|
8261
|
+
const fn = descriptor.value;
|
|
8262
|
+
const argsName = getFnParamNames(fn);
|
|
8263
|
+
descriptor.value = function (...args) {
|
|
8264
|
+
try {
|
|
8265
|
+
// begin validation
|
|
8266
|
+
const requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target.prototype, propertyName);
|
|
8267
|
+
const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target.prototype, propertyName);
|
|
8268
|
+
if (checkTypeParameters) {
|
|
8269
|
+
checkTypeParameters.forEach((parameter) => {
|
|
8270
|
+
const { parameterIndex, type, properties, defaultValue } = parameter;
|
|
8271
|
+
let argument = args[parameterIndex];
|
|
8272
|
+
let argumentName = argsName[parameterIndex];
|
|
8273
|
+
const parameterType = typeof argument;
|
|
8274
|
+
if (!_.isUndefined(argument)) {
|
|
8275
|
+
if (!isType(argument, type)) {
|
|
8276
|
+
throw apiResponse.error.wrongTypeParam(argumentName, type, Array.isArray(argument)
|
|
8277
|
+
? 'array'
|
|
8278
|
+
: argument === null
|
|
8279
|
+
? 'null'
|
|
8280
|
+
: parameterType);
|
|
8281
|
+
}
|
|
8282
|
+
if (type === 'object') {
|
|
8283
|
+
Object.entries(properties).forEach(([propKey, propType]) => {
|
|
8284
|
+
const key = propKey.split('?')[0];
|
|
8285
|
+
const propValue = _.get(argument, key);
|
|
8286
|
+
if (!_.isUndefined(propValue) && !_.isNull(propValue)) {
|
|
8287
|
+
if (_.isFunction(propType)) {
|
|
8288
|
+
const res = propType(propValue);
|
|
8289
|
+
if (res && res.error) {
|
|
8290
|
+
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8291
|
+
}
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8294
|
+
else if (!propKey.includes('?')) {
|
|
8295
|
+
throw apiResponse.error.missingParam(propKey);
|
|
8296
|
+
}
|
|
8297
|
+
else if (!_.get(argument, key.split('.')[0]) &&
|
|
8298
|
+
defaultValue &&
|
|
8299
|
+
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8300
|
+
_.set(args[parameterIndex], key, _.get(defaultValue, key));
|
|
8301
|
+
}
|
|
8302
|
+
});
|
|
8303
|
+
}
|
|
8304
|
+
}
|
|
8305
|
+
});
|
|
8306
|
+
}
|
|
8307
|
+
if (requiredParameters) {
|
|
8308
|
+
requiredParameters.forEach((parameter) => {
|
|
8309
|
+
const { parameterIndex, option, fields } = parameter;
|
|
8310
|
+
const argument = args[parameterIndex];
|
|
8311
|
+
const condition = option === null || option === void 0 ? void 0 : option.if;
|
|
8312
|
+
const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
|
|
8313
|
+
let isMeetCondition = true;
|
|
8314
|
+
if (condition) {
|
|
8315
|
+
isMeetCondition = Object.keys(condition).every((key) => _.get(argument, key) === condition[key]);
|
|
8126
8316
|
}
|
|
8127
|
-
if (
|
|
8128
|
-
|
|
8129
|
-
const
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
if (res && res.error) {
|
|
8135
|
-
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8317
|
+
if (isMeetCondition) {
|
|
8318
|
+
fields.forEach((item) => {
|
|
8319
|
+
const isInValidField = (field) => {
|
|
8320
|
+
let isInValid = false;
|
|
8321
|
+
if (_.isEmpty(_.get(argument, field))) {
|
|
8322
|
+
if (!_.isUndefined(_.get(defaultValue, field))) {
|
|
8323
|
+
_.set(args[parameterIndex], field, _.get(defaultValue, field));
|
|
8136
8324
|
}
|
|
8325
|
+
isInValid = true;
|
|
8137
8326
|
}
|
|
8327
|
+
return isInValid;
|
|
8328
|
+
};
|
|
8329
|
+
if (Array.isArray(item) &&
|
|
8330
|
+
item.length > 0 &&
|
|
8331
|
+
item.every(isInValidField)) {
|
|
8332
|
+
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8138
8333
|
}
|
|
8139
|
-
else if (
|
|
8140
|
-
throw apiResponse.error.missingParam(
|
|
8141
|
-
}
|
|
8142
|
-
else if (_.isObject(_.get(argument, key.split('.')[0])) &&
|
|
8143
|
-
defaultValue &&
|
|
8144
|
-
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8145
|
-
_.set(arguments[parameterIndex], key, _.get(defaultValue, key));
|
|
8334
|
+
else if (_.isString(item) && isInValidField(item)) {
|
|
8335
|
+
throw apiResponse.error.missingParam(item);
|
|
8146
8336
|
}
|
|
8147
8337
|
});
|
|
8148
8338
|
}
|
|
8149
|
-
}
|
|
8150
|
-
}
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
const {
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
}
|
|
8170
|
-
isInValid = true;
|
|
8171
|
-
}
|
|
8172
|
-
return isInValid;
|
|
8173
|
-
};
|
|
8174
|
-
if (Array.isArray(item) && item.length > 0 && item.every(isInValidField)) {
|
|
8175
|
-
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8339
|
+
});
|
|
8340
|
+
}
|
|
8341
|
+
// end validation
|
|
8342
|
+
const res = fn.call(this, ...args);
|
|
8343
|
+
if (_.isPromise(res)) {
|
|
8344
|
+
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
8345
|
+
return new Promise((resolve, reject) => {
|
|
8346
|
+
res
|
|
8347
|
+
.then((data) => {
|
|
8348
|
+
if (!_.isNull(success) && _.isFunction(success)) {
|
|
8349
|
+
success.call(null, data, this);
|
|
8350
|
+
}
|
|
8351
|
+
else {
|
|
8352
|
+
resolve(res);
|
|
8353
|
+
}
|
|
8354
|
+
})
|
|
8355
|
+
.catch((error) => {
|
|
8356
|
+
const errorParsed = errorHandler(error, propertyName);
|
|
8357
|
+
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
8358
|
+
fail.call(null, errorParsed, this);
|
|
8176
8359
|
}
|
|
8177
|
-
else
|
|
8178
|
-
|
|
8360
|
+
else {
|
|
8361
|
+
reject(errorParsed);
|
|
8179
8362
|
}
|
|
8180
8363
|
});
|
|
8181
|
-
}
|
|
8182
|
-
}
|
|
8364
|
+
});
|
|
8365
|
+
}
|
|
8366
|
+
return res;
|
|
8367
|
+
}
|
|
8368
|
+
catch (error) {
|
|
8369
|
+
throw errorHandler(error, propertyName);
|
|
8183
8370
|
}
|
|
8184
|
-
return method.apply(this, arguments);
|
|
8185
8371
|
};
|
|
8186
8372
|
return descriptor;
|
|
8187
8373
|
};
|
|
8188
8374
|
|
|
8189
8375
|
var _SDKCreator_sdkService;
|
|
8190
|
-
class SDKCreator {
|
|
8376
|
+
let SDKCreator = class SDKCreator {
|
|
8191
8377
|
constructor() {
|
|
8192
8378
|
this.events = ZMPEEmitter.getInstance();
|
|
8193
8379
|
_SDKCreator_sdkService.set(this, void 0);
|
|
@@ -8248,7 +8434,7 @@ class SDKCreator {
|
|
|
8248
8434
|
}
|
|
8249
8435
|
setNavigationBarTitle(object) {
|
|
8250
8436
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8251
|
-
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8437
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8252
8438
|
});
|
|
8253
8439
|
}
|
|
8254
8440
|
setNavigationBarColor(object) {
|
|
@@ -8518,6 +8704,7 @@ class SDKCreator {
|
|
|
8518
8704
|
}
|
|
8519
8705
|
vibrate(object) {
|
|
8520
8706
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8707
|
+
console.log(object);
|
|
8521
8708
|
yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
|
|
8522
8709
|
});
|
|
8523
8710
|
}
|
|
@@ -8673,33 +8860,14 @@ class SDKCreator {
|
|
|
8673
8860
|
getDeviceId() {
|
|
8674
8861
|
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
|
|
8675
8862
|
}
|
|
8676
|
-
}
|
|
8863
|
+
};
|
|
8677
8864
|
_SDKCreator_sdkService = new WeakMap();
|
|
8678
8865
|
__decorate([
|
|
8679
|
-
handleError
|
|
8680
|
-
], SDKCreator.prototype, "login", null);
|
|
8681
|
-
__decorate([
|
|
8682
|
-
handleErrorSync
|
|
8683
|
-
], SDKCreator.prototype, "getLoginStatus", null);
|
|
8684
|
-
__decorate([
|
|
8685
|
-
handleError
|
|
8686
|
-
], SDKCreator.prototype, "getAccessToken", null);
|
|
8687
|
-
__decorate([
|
|
8688
|
-
handleErrorSync
|
|
8689
|
-
], SDKCreator.prototype, "getVersion", null);
|
|
8690
|
-
__decorate([
|
|
8691
|
-
handleErrorSync
|
|
8692
|
-
], SDKCreator.prototype, "getSystemInfo", null);
|
|
8693
|
-
__decorate([
|
|
8694
|
-
handleError,
|
|
8695
|
-
validate,
|
|
8696
8866
|
__param(0, checkType('object', {
|
|
8697
8867
|
title: checkData('string')
|
|
8698
8868
|
}))
|
|
8699
8869
|
], SDKCreator.prototype, "setNavigationBarTitle", null);
|
|
8700
8870
|
__decorate([
|
|
8701
|
-
handleError,
|
|
8702
|
-
validate,
|
|
8703
8871
|
__param(0, checkType('object', {
|
|
8704
8872
|
color: checkData('string'),
|
|
8705
8873
|
'textColor?': checkData('string', { values: ['white', 'black'] }),
|
|
@@ -8707,57 +8875,37 @@ __decorate([
|
|
|
8707
8875
|
}))
|
|
8708
8876
|
], SDKCreator.prototype, "setNavigationBarColor", null);
|
|
8709
8877
|
__decorate([
|
|
8710
|
-
handleError,
|
|
8711
|
-
validate,
|
|
8712
8878
|
__param(0, checkType('object', {
|
|
8713
8879
|
backgroundColor: checkData('string'),
|
|
8714
8880
|
'textColor?': checkData('string', { values: ['white', 'black'] })
|
|
8715
8881
|
}))
|
|
8716
8882
|
], SDKCreator.prototype, "setBackgroundColor", null);
|
|
8717
8883
|
__decorate([
|
|
8718
|
-
handleError,
|
|
8719
|
-
validate,
|
|
8720
8884
|
__param(0, checkType('object', {
|
|
8721
8885
|
type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
|
|
8722
8886
|
}))
|
|
8723
8887
|
], SDKCreator.prototype, "setNavigationBarLeftButton", null);
|
|
8724
8888
|
__decorate([
|
|
8725
|
-
handleError,
|
|
8726
|
-
validate,
|
|
8727
8889
|
__param(0, checkType('object', {
|
|
8728
8890
|
rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
|
|
8729
8891
|
}))
|
|
8730
8892
|
], SDKCreator.prototype, "setDeviceOrientation", null);
|
|
8731
8893
|
__decorate([
|
|
8732
|
-
handleError,
|
|
8733
|
-
validate,
|
|
8734
8894
|
__param(0, checkType('object', {
|
|
8735
8895
|
data: checkData('object')
|
|
8736
8896
|
}))
|
|
8737
8897
|
], SDKCreator.prototype, "setStorage", null);
|
|
8738
8898
|
__decorate([
|
|
8739
|
-
handleError,
|
|
8740
|
-
validate,
|
|
8741
8899
|
__param(0, checkType('object', {
|
|
8742
8900
|
keys: checkData('array<string>')
|
|
8743
8901
|
}))
|
|
8744
8902
|
], SDKCreator.prototype, "getStorage", null);
|
|
8745
8903
|
__decorate([
|
|
8746
|
-
handleError
|
|
8747
|
-
], SDKCreator.prototype, "getStorageInfo", null);
|
|
8748
|
-
__decorate([
|
|
8749
|
-
handleError,
|
|
8750
|
-
validate,
|
|
8751
8904
|
__param(0, checkType('object', {
|
|
8752
8905
|
keys: checkData('array<string>')
|
|
8753
8906
|
}))
|
|
8754
8907
|
], SDKCreator.prototype, "removeStorage", null);
|
|
8755
8908
|
__decorate([
|
|
8756
|
-
handleError
|
|
8757
|
-
], SDKCreator.prototype, "clearStorage", null);
|
|
8758
|
-
__decorate([
|
|
8759
|
-
handleError,
|
|
8760
|
-
validate,
|
|
8761
8909
|
__param(0, checkType('object', {
|
|
8762
8910
|
'avatarType?': checkData('string', {
|
|
8763
8911
|
values: ['small', 'normal', 'large']
|
|
@@ -8765,67 +8913,12 @@ __decorate([
|
|
|
8765
8913
|
}))
|
|
8766
8914
|
], SDKCreator.prototype, "getUserInfo", null);
|
|
8767
8915
|
__decorate([
|
|
8768
|
-
handleError
|
|
8769
|
-
], SDKCreator.prototype, "getNetworkType", null);
|
|
8770
|
-
__decorate([
|
|
8771
|
-
handleError
|
|
8772
|
-
], SDKCreator.prototype, "onNetworkStatusChange", null);
|
|
8773
|
-
__decorate([
|
|
8774
|
-
handleError
|
|
8775
|
-
], SDKCreator.prototype, "startBeaconDiscovery", null);
|
|
8776
|
-
__decorate([
|
|
8777
|
-
handleError
|
|
8778
|
-
], SDKCreator.prototype, "stopBeaconDiscovery", null);
|
|
8779
|
-
__decorate([
|
|
8780
|
-
handleError
|
|
8781
|
-
], SDKCreator.prototype, "getBeacons", null);
|
|
8782
|
-
__decorate([
|
|
8783
|
-
handleError
|
|
8784
|
-
], SDKCreator.prototype, "closeApp", null);
|
|
8785
|
-
__decorate([
|
|
8786
|
-
handleError
|
|
8787
|
-
], SDKCreator.prototype, "getLocation", null);
|
|
8788
|
-
__decorate([
|
|
8789
|
-
handleError
|
|
8790
|
-
], SDKCreator.prototype, "stopBluetoothDevicesDiscovery", null);
|
|
8791
|
-
__decorate([
|
|
8792
|
-
handleError
|
|
8793
|
-
], SDKCreator.prototype, "startBluetoothDevicesDiscovery", null);
|
|
8794
|
-
__decorate([
|
|
8795
|
-
handleError
|
|
8796
|
-
], SDKCreator.prototype, "openBluetoothAdapter", null);
|
|
8797
|
-
__decorate([
|
|
8798
|
-
handleError
|
|
8799
|
-
], SDKCreator.prototype, "onBluetoothDeviceFound", null);
|
|
8800
|
-
__decorate([
|
|
8801
|
-
handleError
|
|
8802
|
-
], SDKCreator.prototype, "onBluetoothAdapterStateChange", null);
|
|
8803
|
-
__decorate([
|
|
8804
|
-
handleError
|
|
8805
|
-
], SDKCreator.prototype, "getConnectedBluetoothDevices", null);
|
|
8806
|
-
__decorate([
|
|
8807
|
-
handleError
|
|
8808
|
-
], SDKCreator.prototype, "getBluetoothDevices", null);
|
|
8809
|
-
__decorate([
|
|
8810
|
-
handleError
|
|
8811
|
-
], SDKCreator.prototype, "getBluetoothAdapterState", null);
|
|
8812
|
-
__decorate([
|
|
8813
|
-
handleError
|
|
8814
|
-
], SDKCreator.prototype, "closeBluetoothAdapter", null);
|
|
8815
|
-
__decorate([
|
|
8816
|
-
handleError
|
|
8817
|
-
], SDKCreator.prototype, "scanQRCode", null);
|
|
8818
|
-
__decorate([
|
|
8819
|
-
handleError,
|
|
8820
|
-
validate,
|
|
8821
8916
|
__param(0, checkType('object', {
|
|
8822
8917
|
type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
|
|
8823
8918
|
id: checkData('string')
|
|
8824
8919
|
}))
|
|
8825
8920
|
], SDKCreator.prototype, "openProfile", null);
|
|
8826
8921
|
__decorate([
|
|
8827
|
-
handleError,
|
|
8828
|
-
validate,
|
|
8829
8922
|
__param(0, checkType('object', {
|
|
8830
8923
|
type: checkData('string', { values: ['user', 'oa'] }),
|
|
8831
8924
|
id: checkData('string'),
|
|
@@ -8833,8 +8926,6 @@ __decorate([
|
|
|
8833
8926
|
}))
|
|
8834
8927
|
], SDKCreator.prototype, "openChat", null);
|
|
8835
8928
|
__decorate([
|
|
8836
|
-
handleError,
|
|
8837
|
-
validate,
|
|
8838
8929
|
__param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
|
|
8839
8930
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8840
8931
|
__param(0, required(['data.id'], { if: { type: 'profile' } })),
|
|
@@ -8852,23 +8943,17 @@ __decorate([
|
|
|
8852
8943
|
}))
|
|
8853
8944
|
], SDKCreator.prototype, "openPostFeed", null);
|
|
8854
8945
|
__decorate([
|
|
8855
|
-
handleError,
|
|
8856
|
-
validate,
|
|
8857
8946
|
__param(0, checkType('object', {
|
|
8858
8947
|
id: checkData('string'),
|
|
8859
8948
|
'showDialogConfirm?': checkData('boolean')
|
|
8860
8949
|
}))
|
|
8861
8950
|
], SDKCreator.prototype, "followOA", null);
|
|
8862
8951
|
__decorate([
|
|
8863
|
-
handleError,
|
|
8864
|
-
validate,
|
|
8865
8952
|
__param(0, checkType('object', {
|
|
8866
8953
|
id: checkData('string')
|
|
8867
8954
|
}))
|
|
8868
8955
|
], SDKCreator.prototype, "unfollowOA", null);
|
|
8869
8956
|
__decorate([
|
|
8870
|
-
handleError,
|
|
8871
|
-
validate,
|
|
8872
8957
|
__param(0, required([['data.imageUrl', 'data.imageUrls']], { if: { type: 'image' } })),
|
|
8873
8958
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8874
8959
|
__param(0, required(['data.id'], { if: { type: 'oa' } })),
|
|
@@ -8907,14 +8992,6 @@ __decorate([
|
|
|
8907
8992
|
}))
|
|
8908
8993
|
], SDKCreator.prototype, "openShareSheet", null);
|
|
8909
8994
|
__decorate([
|
|
8910
|
-
handleError
|
|
8911
|
-
], SDKCreator.prototype, "requestCameraPermission", null);
|
|
8912
|
-
__decorate([
|
|
8913
|
-
handleError
|
|
8914
|
-
], SDKCreator.prototype, "createShortcut", null);
|
|
8915
|
-
__decorate([
|
|
8916
|
-
handleError,
|
|
8917
|
-
validate,
|
|
8918
8995
|
__param(0, checkType('object', {
|
|
8919
8996
|
secretData: checkData('string'),
|
|
8920
8997
|
'ui?': checkData('object'),
|
|
@@ -8932,44 +9009,28 @@ __decorate([
|
|
|
8932
9009
|
}))
|
|
8933
9010
|
], SDKCreator.prototype, "openBioAuthentication", null);
|
|
8934
9011
|
__decorate([
|
|
8935
|
-
handleError
|
|
8936
|
-
], SDKCreator.prototype, "checkStateBioAuthentication", null);
|
|
8937
|
-
__decorate([
|
|
8938
|
-
handleError,
|
|
8939
|
-
validate,
|
|
8940
9012
|
__param(0, checkType('object', {
|
|
8941
9013
|
toUserId: checkData('string'),
|
|
8942
9014
|
'title?': checkData('string')
|
|
8943
9015
|
}))
|
|
8944
9016
|
], SDKCreator.prototype, "sendLocation", null);
|
|
8945
9017
|
__decorate([
|
|
8946
|
-
handleError,
|
|
8947
|
-
validate,
|
|
8948
9018
|
__param(0, checkType('object', {
|
|
8949
9019
|
message: checkData('string')
|
|
8950
9020
|
}))
|
|
8951
9021
|
], SDKCreator.prototype, "showToast", null);
|
|
8952
9022
|
__decorate([
|
|
8953
|
-
handleError
|
|
8954
|
-
], SDKCreator.prototype, "hideKeyboard", null);
|
|
8955
|
-
__decorate([
|
|
8956
|
-
handleError,
|
|
8957
|
-
validate,
|
|
8958
9023
|
__param(0, checkType('object', {
|
|
8959
9024
|
phoneNumber: checkData('string')
|
|
8960
9025
|
}))
|
|
8961
9026
|
], SDKCreator.prototype, "openPhone", null);
|
|
8962
9027
|
__decorate([
|
|
8963
|
-
handleError,
|
|
8964
|
-
validate,
|
|
8965
9028
|
__param(0, checkType('object', {
|
|
8966
9029
|
content: checkData('string'),
|
|
8967
9030
|
phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
|
|
8968
9031
|
}))
|
|
8969
9032
|
], SDKCreator.prototype, "openSMS", null);
|
|
8970
9033
|
__decorate([
|
|
8971
|
-
handleError,
|
|
8972
|
-
validate,
|
|
8973
9034
|
__param(0, checkType('object', {
|
|
8974
9035
|
id: checkData('string'),
|
|
8975
9036
|
'displayName?': checkData('string')
|
|
@@ -8978,35 +9039,24 @@ __decorate([
|
|
|
8978
9039
|
}))
|
|
8979
9040
|
], SDKCreator.prototype, "viewOAQr", null);
|
|
8980
9041
|
__decorate([
|
|
8981
|
-
handleError
|
|
8982
|
-
], SDKCreator.prototype, "keepScreen", null);
|
|
8983
|
-
__decorate([
|
|
8984
|
-
handleError,
|
|
8985
|
-
validate,
|
|
8986
9042
|
__param(0, checkType('object', {
|
|
8987
9043
|
'imageBase64Data?': checkData('string'),
|
|
8988
9044
|
'imageUrl?': checkData('url')
|
|
8989
9045
|
}))
|
|
8990
9046
|
], SDKCreator.prototype, "saveImageToGallery", null);
|
|
8991
9047
|
__decorate([
|
|
8992
|
-
handleError,
|
|
8993
|
-
validate,
|
|
8994
9048
|
__param(0, checkType('object', {
|
|
8995
9049
|
'imageBase64Data?': checkData('string'),
|
|
8996
9050
|
'imageUrl?': checkData('url')
|
|
8997
9051
|
}))
|
|
8998
9052
|
], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
|
|
8999
9053
|
__decorate([
|
|
9000
|
-
handleError,
|
|
9001
|
-
validate,
|
|
9002
9054
|
__param(0, checkType('object', {
|
|
9003
9055
|
appId: checkData('string'),
|
|
9004
9056
|
'params?': checkData('object')
|
|
9005
9057
|
}))
|
|
9006
9058
|
], SDKCreator.prototype, "openMiniApp", null);
|
|
9007
9059
|
__decorate([
|
|
9008
|
-
handleError,
|
|
9009
|
-
validate,
|
|
9010
9060
|
__param(0, checkType('object', {
|
|
9011
9061
|
'type?': checkData('string', { values: ['oneShot'] }),
|
|
9012
9062
|
'milliseconds?': checkData('number')
|
|
@@ -9016,30 +9066,11 @@ __decorate([
|
|
|
9016
9066
|
}))
|
|
9017
9067
|
], SDKCreator.prototype, "vibrate", null);
|
|
9018
9068
|
__decorate([
|
|
9019
|
-
handleError,
|
|
9020
|
-
validate,
|
|
9021
9069
|
__param(0, checkType('object', {
|
|
9022
9070
|
url: checkData('url')
|
|
9023
9071
|
}))
|
|
9024
9072
|
], SDKCreator.prototype, "openWebview", null);
|
|
9025
9073
|
__decorate([
|
|
9026
|
-
handleErrorSync
|
|
9027
|
-
], SDKCreator.prototype, "getRouteParams", null);
|
|
9028
|
-
__decorate([
|
|
9029
|
-
handleError
|
|
9030
|
-
], SDKCreator.prototype, "getAppInfo", null);
|
|
9031
|
-
__decorate([
|
|
9032
|
-
handleError
|
|
9033
|
-
], SDKCreator.prototype, "sendDataToPreviousMiniApp", null);
|
|
9034
|
-
__decorate([
|
|
9035
|
-
handleError
|
|
9036
|
-
], SDKCreator.prototype, "onCallbackData", null);
|
|
9037
|
-
__decorate([
|
|
9038
|
-
handleError
|
|
9039
|
-
], SDKCreator.prototype, "getPhoneNumber", null);
|
|
9040
|
-
__decorate([
|
|
9041
|
-
handleError,
|
|
9042
|
-
validate,
|
|
9043
9074
|
__param(0, checkType('object', {
|
|
9044
9075
|
'maxProfile?': checkData('number', { min: 1, max: 10 })
|
|
9045
9076
|
}, {
|
|
@@ -9047,8 +9078,6 @@ __decorate([
|
|
|
9047
9078
|
}))
|
|
9048
9079
|
], SDKCreator.prototype, "openProfilePicker", null);
|
|
9049
9080
|
__decorate([
|
|
9050
|
-
handleError,
|
|
9051
|
-
validate,
|
|
9052
9081
|
__param(0, required(['SSID'])),
|
|
9053
9082
|
__param(0, checkType('object', {
|
|
9054
9083
|
SSID: checkData('string'),
|
|
@@ -9057,8 +9086,6 @@ __decorate([
|
|
|
9057
9086
|
}))
|
|
9058
9087
|
], SDKCreator.prototype, "connectWifi", null);
|
|
9059
9088
|
__decorate([
|
|
9060
|
-
handleError,
|
|
9061
|
-
validate,
|
|
9062
9089
|
__param(0, checkType('object', {
|
|
9063
9090
|
type: checkData('string', {
|
|
9064
9091
|
values: ['photo', 'video', 'file']
|
|
@@ -9073,8 +9100,6 @@ __decorate([
|
|
|
9073
9100
|
}))
|
|
9074
9101
|
], SDKCreator.prototype, "openMediaPicker", null);
|
|
9075
9102
|
__decorate([
|
|
9076
|
-
handleError,
|
|
9077
|
-
validate,
|
|
9078
9103
|
__param(0, checkType('object', {
|
|
9079
9104
|
title: checkData('string', { maxLength: 100 }),
|
|
9080
9105
|
'thumbnail?': checkData('url'),
|
|
@@ -9084,14 +9109,9 @@ __decorate([
|
|
|
9084
9109
|
description: ''
|
|
9085
9110
|
}))
|
|
9086
9111
|
], SDKCreator.prototype, "getShareableLink", null);
|
|
9087
|
-
__decorate([
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
], SDKCreator.prototype, "closeLoading", null);
|
|
9091
|
-
__decorate([
|
|
9092
|
-
handleError,
|
|
9093
|
-
validate
|
|
9094
|
-
], SDKCreator.prototype, "requestUpdateZalo", null);
|
|
9112
|
+
SDKCreator = __decorate([
|
|
9113
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9114
|
+
], SDKCreator);
|
|
9095
9115
|
class ZaloMiniAppSDKCreator extends SDKCreator {
|
|
9096
9116
|
getServiceInstance() {
|
|
9097
9117
|
return ZaloMiniProgramSDKService.getInstance();
|
|
@@ -9287,7 +9307,7 @@ class MockPaymentService {
|
|
|
9287
9307
|
_MockPaymentService_appId = new WeakMap();
|
|
9288
9308
|
|
|
9289
9309
|
var _PaymentCreator_instance, _PaymentCreator_sdk;
|
|
9290
|
-
class PaymentCreator {
|
|
9310
|
+
let PaymentCreator = class PaymentCreator {
|
|
9291
9311
|
constructor(sdk) {
|
|
9292
9312
|
_PaymentCreator_instance.set(this, void 0);
|
|
9293
9313
|
_PaymentCreator_sdk.set(this, void 0);
|
|
@@ -9295,42 +9315,50 @@ class PaymentCreator {
|
|
|
9295
9315
|
__classPrivateFieldSet(this, _PaymentCreator_sdk, sdk, "f");
|
|
9296
9316
|
}
|
|
9297
9317
|
/**
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9318
|
+
* Tạo đơn hàng
|
|
9319
|
+
*
|
|
9320
|
+
* @async
|
|
9321
|
+
* @function createOrder
|
|
9322
|
+
* @category Payment
|
|
9323
|
+
* @returns {Promise<CallbackDataType.CreateOrderCallBack>}
|
|
9324
|
+
*/
|
|
9305
9325
|
createOrder(object) {
|
|
9306
9326
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").createOrder(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9307
9327
|
}
|
|
9308
9328
|
/**
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9329
|
+
* Lấy thông tin transaction
|
|
9330
|
+
*
|
|
9331
|
+
* @async
|
|
9332
|
+
* @function checkTransaction
|
|
9333
|
+
* @category Payment
|
|
9334
|
+
* @returns {Promise<CallbackDataType.CheckTransactionSuccessCallBack>}
|
|
9335
|
+
*/
|
|
9316
9336
|
checkTransaction(object) {
|
|
9317
9337
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").checkTransaction(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9318
9338
|
}
|
|
9319
|
-
}
|
|
9339
|
+
};
|
|
9320
9340
|
_PaymentCreator_instance = new WeakMap(), _PaymentCreator_sdk = new WeakMap();
|
|
9321
9341
|
__decorate([
|
|
9322
|
-
handleError,
|
|
9323
|
-
validate,
|
|
9324
9342
|
__param(0, checkType('object', {
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
'method?': checkData('string', {
|
|
9343
|
+
amount: checkData(['string', 'number']),
|
|
9344
|
+
desc: checkData('string'),
|
|
9345
|
+
'method?': checkData('string', {
|
|
9346
|
+
values: [
|
|
9347
|
+
'MOMO',
|
|
9348
|
+
'ZALOPAY',
|
|
9349
|
+
'MOMO_SANDBOX',
|
|
9350
|
+
'ZALOPAY_SANDBOX',
|
|
9351
|
+
'CC',
|
|
9352
|
+
'CC_SANDBOX',
|
|
9353
|
+
'ATM',
|
|
9354
|
+
'ATM_SANDBOX'
|
|
9355
|
+
]
|
|
9356
|
+
})
|
|
9328
9357
|
}))
|
|
9329
9358
|
], PaymentCreator.prototype, "createOrder", null);
|
|
9330
|
-
__decorate([
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
], PaymentCreator.prototype, "checkTransaction", null);
|
|
9359
|
+
PaymentCreator = __decorate([
|
|
9360
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9361
|
+
], PaymentCreator);
|
|
9334
9362
|
class ZaloMiniAppPaymentCreator extends PaymentCreator {
|
|
9335
9363
|
getInstance() {
|
|
9336
9364
|
return PaymentService.getInstance();
|
|
@@ -9372,4 +9400,4 @@ else {
|
|
|
9372
9400
|
window.ZaloMiniAppSDK = app;
|
|
9373
9401
|
|
|
9374
9402
|
export default app;
|
|
9375
|
-
export { ChatType, Events, MediaPickerType,
|
|
9403
|
+
export { ChatType, Events, MediaPickerType, NetworkType, OrientationType, payment as Payment, PlatformType, PostFeedType, ProfileType, SDKCreator, ShareSheetType, VibrateType };
|