@cloudbase/oauth 2.5.41-beta.0 → 2.5.43-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/auth/apis.d.ts +16 -0
- package/dist/cjs/auth/apis.js +27 -8
- package/dist/cjs/auth/consts.d.ts +3 -0
- package/dist/cjs/auth/consts.js +4 -1
- package/dist/cjs/captcha/captcha.js +52 -28
- package/dist/cjs/oauth2client/consts.js +1 -1
- package/dist/cjs/utils/mp.d.ts +2 -0
- package/dist/cjs/utils/mp.js +58 -0
- package/dist/esm/auth/apis.d.ts +16 -0
- package/dist/esm/auth/apis.js +27 -8
- package/dist/esm/auth/consts.d.ts +3 -0
- package/dist/esm/auth/consts.js +4 -1
- package/dist/esm/captcha/captcha.js +52 -28
- package/dist/esm/oauth2client/consts.js +1 -1
- package/dist/esm/utils/mp.d.ts +2 -0
- package/dist/esm/utils/mp.js +53 -0
- package/package.json +2 -2
- package/src/auth/apis.ts +100 -127
- package/src/auth/consts.ts +6 -2
- package/src/captcha/captcha.ts +86 -50
- package/src/oauth2client/consts.ts +3 -2
- package/src/utils/mp.ts +53 -0
package/src/utils/mp.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function isMp() {
|
|
2
|
+
const { wx } = globalThis as any
|
|
3
|
+
if (typeof wx === 'undefined') {
|
|
4
|
+
return false
|
|
5
|
+
}
|
|
6
|
+
if ((globalThis as any).Page === undefined) {
|
|
7
|
+
return false
|
|
8
|
+
}
|
|
9
|
+
if (!wx.getSystemInfoSync) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
if (!wx.getStorageSync) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
if (!wx.setStorageSync) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
if (!wx.connectSocket) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
if (!wx.request) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
if (!wx.getSystemInfoSync()) {
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (wx.getSystemInfoSync().AppPlatform === 'qq') {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let IS_IN_MP_WEBVIEW = !!navigator.userAgent.match(/miniprogram/i) || (window as any).__wxjs_environment === 'miniprogram'
|
|
41
|
+
function ready() {
|
|
42
|
+
IS_IN_MP_WEBVIEW = IS_IN_MP_WEBVIEW || (typeof window !== undefined && (window as any).__wxjs_environment === 'miniprogram')
|
|
43
|
+
}
|
|
44
|
+
if (!isMp()) {
|
|
45
|
+
if ((window as any)?.WeixinJSBridge?.invoke) {
|
|
46
|
+
ready()
|
|
47
|
+
} else if (typeof document !== 'undefined') {
|
|
48
|
+
document.addEventListener?.('WeixinJSBridgeReady', ready, false)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function isInMpWebView() {
|
|
52
|
+
return IS_IN_MP_WEBVIEW
|
|
53
|
+
}
|