jk-vue-comps 0.1.5 → 0.1.7
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/README.md +3 -3
- package/dist/chunks/index-BP9Q78TM.js +13 -0
- package/dist/chunks/index-C_baUQWz.js +129 -0
- package/dist/components/GoogleAuth.d.ts +95 -0
- package/dist/components/GoogleAuth.js +70 -0
- package/dist/components/TelegramAuth.d.ts +96 -0
- package/dist/components/TelegramAuth.js +91 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +9 -0
- package/dist/index.d.ts +229 -0
- package/dist/index.js +65 -0
- package/dist/utils/index.d.ts +46 -0
- package/dist/utils/index.js +50 -0
- package/dist/utils/is.d.ts +59 -0
- package/dist/utils/is.js +120 -0
- package/dist/utils/timeZone.d.ts +9 -0
- package/dist/utils/timeZone.js +839 -0
- package/dist/utils/vuePropTypes.d.ts +65 -0
- package/dist/utils/vuePropTypes.js +29 -0
- package/dist/utils/withInstall.d.ts +3 -0
- package/dist/utils/withInstall.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# jk-vue-comps
|
|
2
|
-
|
|
3
|
-
npm install jk-vue-comps
|
|
1
|
+
# jk-vue-comps
|
|
2
|
+
|
|
3
|
+
npm install jk-vue-comps
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GoogleAuth as e, toGoogleAuth as o } from "../components/GoogleAuth.js";
|
|
2
|
+
import { TelegramAuth as t, getTelegramAuthUrlParams as r, toTelegramAuth as l } from "../components/TelegramAuth.js";
|
|
3
|
+
const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
|
+
__proto__: null,
|
|
5
|
+
GoogleAuth: e,
|
|
6
|
+
TelegramAuth: t,
|
|
7
|
+
getTelegramAuthUrlParams: r,
|
|
8
|
+
toGoogleAuth: o,
|
|
9
|
+
toTelegramAuth: l
|
|
10
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
11
|
+
export {
|
|
12
|
+
g as c
|
|
13
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { nextTick as m, createVNode as w } from "vue";
|
|
2
|
+
import { isString as u, isHtmlStr as f, isObject as a, isNumber as c, is as h, isArray as S, isBoolean as x, isClient as $, isDate as b, isDef as O, isEdgeBrowser as P, isElement as N, isEmail as v, isEmpty as y, isFunction as U, isInMobileBrowser as E, isIp as I, isMap as M, isNull as k, isNullAndUnDef as D, isNullOrUnDef as F, isPromise as L, isPromiseLink as T, isRegExp as _, isServer as j, isUnDef as z, isUrl as B, isValidPhoneNumber as H, isWindow as R, isZhLang as W } from "../utils/is.js";
|
|
3
|
+
import { propTypes as q } from "../utils/vuePropTypes.js";
|
|
4
|
+
import { timeZoneOptions as A } from "../utils/timeZone.js";
|
|
5
|
+
import { withInstall as V } from "../utils/withInstall.js";
|
|
6
|
+
function l(i) {
|
|
7
|
+
try {
|
|
8
|
+
return new Function(`'use strict'; return (${i});`)();
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function d(i, t = "float", n = 6) {
|
|
14
|
+
let e = String(i);
|
|
15
|
+
if (e = e.replace(/(^\s*)|(\s*$)/g, ""), e !== "") {
|
|
16
|
+
const s = e.indexOf("0") === 0 && e.length > 1 && e.indexOf(".") !== 1, r = t === "int" ? /[^\d]/g : /[^\d.]/g;
|
|
17
|
+
if (e = e.replace(r, ""), s)
|
|
18
|
+
return "0";
|
|
19
|
+
if (t === "int")
|
|
20
|
+
e = e.indexOf("0") === 0 && e.length > 1 ? e.substring(0, e.length - 1) : e;
|
|
21
|
+
else {
|
|
22
|
+
const o = l(`/\\.{${n},}/g`), p = l(`/^(\\d?)+(\\.\\d{0,${n}})?$/`);
|
|
23
|
+
e.indexOf(".") === 0 ? (e = "", e = e.replace(/[^$#$]/g, "0."), e = e.replace(o, ".")) : p.test(e) || (e = e.substring(0, e.length - 1));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return e;
|
|
27
|
+
}
|
|
28
|
+
function Z(i, t, n, e = "int", s = 6) {
|
|
29
|
+
return (r) => {
|
|
30
|
+
m().then(() => {
|
|
31
|
+
var o;
|
|
32
|
+
i[t] = d((o = r == null ? void 0 : r.target) == null ? void 0 : o.value, e, s), n == null || n();
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function C(i) {
|
|
37
|
+
return !u(i) || !f(i) ? i : w("div", { innerHTML: i });
|
|
38
|
+
}
|
|
39
|
+
function G() {
|
|
40
|
+
return window ? `${window.location.protocol}//${window.location.hostname}` : "";
|
|
41
|
+
}
|
|
42
|
+
function J() {
|
|
43
|
+
const i = new URLSearchParams(window.location.search);
|
|
44
|
+
if (!i.size)
|
|
45
|
+
return;
|
|
46
|
+
const t = {};
|
|
47
|
+
for (const [n, e] of i.entries())
|
|
48
|
+
t[n] = e;
|
|
49
|
+
return t;
|
|
50
|
+
}
|
|
51
|
+
function K(i) {
|
|
52
|
+
return u(i) ? i.replace(/\s+/g, "") : "";
|
|
53
|
+
}
|
|
54
|
+
function g(i = {}, t = {}) {
|
|
55
|
+
let n;
|
|
56
|
+
for (n in t)
|
|
57
|
+
i[n] = a(i[n]) ? g(i[n], t[n]) : i[n] = t[n];
|
|
58
|
+
return i;
|
|
59
|
+
}
|
|
60
|
+
function Q(i, t = 6, n = {
|
|
61
|
+
showPrefix: !0,
|
|
62
|
+
showSuffix: !0,
|
|
63
|
+
middleStr: "****"
|
|
64
|
+
}) {
|
|
65
|
+
if (!u(i) || !c(i))
|
|
66
|
+
return i;
|
|
67
|
+
const e = String(i), s = (e == null ? void 0 : e.length) ?? 0;
|
|
68
|
+
if (!e || !s || t <= 0)
|
|
69
|
+
return e;
|
|
70
|
+
const r = n.showPrefix ? e.substring(0, t) : "", o = n.showSuffix ? e.substring(s - t) : "";
|
|
71
|
+
return `${r}${n.middleStr}${o}`;
|
|
72
|
+
}
|
|
73
|
+
const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
74
|
+
__proto__: null,
|
|
75
|
+
deepMerge: g,
|
|
76
|
+
desensitization: Q,
|
|
77
|
+
evalPro: l,
|
|
78
|
+
filterInputNum: d,
|
|
79
|
+
generateFilterInputNumFn: Z,
|
|
80
|
+
getRouterParams: J,
|
|
81
|
+
getWebsiteUrl: G,
|
|
82
|
+
is: h,
|
|
83
|
+
isArray: S,
|
|
84
|
+
isBoolean: x,
|
|
85
|
+
isClient: $,
|
|
86
|
+
isDate: b,
|
|
87
|
+
isDef: O,
|
|
88
|
+
isEdgeBrowser: P,
|
|
89
|
+
isElement: N,
|
|
90
|
+
isEmail: v,
|
|
91
|
+
isEmpty: y,
|
|
92
|
+
isFunction: U,
|
|
93
|
+
isHtmlStr: f,
|
|
94
|
+
isInMobileBrowser: E,
|
|
95
|
+
isIp: I,
|
|
96
|
+
isMap: M,
|
|
97
|
+
isNull: k,
|
|
98
|
+
isNullAndUnDef: D,
|
|
99
|
+
isNullOrUnDef: F,
|
|
100
|
+
isNumber: c,
|
|
101
|
+
isObject: a,
|
|
102
|
+
isPromise: L,
|
|
103
|
+
isPromiseLink: T,
|
|
104
|
+
isRegExp: _,
|
|
105
|
+
isServer: j,
|
|
106
|
+
isString: u,
|
|
107
|
+
isUnDef: z,
|
|
108
|
+
isUrl: B,
|
|
109
|
+
isValidPhoneNumber: H,
|
|
110
|
+
isWindow: R,
|
|
111
|
+
isZhLang: W,
|
|
112
|
+
propTypes: q,
|
|
113
|
+
removeWhitespace: K,
|
|
114
|
+
renderHtmlStr: C,
|
|
115
|
+
timeZoneOptions: A,
|
|
116
|
+
withInstall: V
|
|
117
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
118
|
+
export {
|
|
119
|
+
G as a,
|
|
120
|
+
J as b,
|
|
121
|
+
K as c,
|
|
122
|
+
g as d,
|
|
123
|
+
l as e,
|
|
124
|
+
d as f,
|
|
125
|
+
Z as g,
|
|
126
|
+
Q as h,
|
|
127
|
+
C as r,
|
|
128
|
+
te as u
|
|
129
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type SlotsType } from 'vue';
|
|
2
|
+
/** 跳转谷歌身份检查 */
|
|
3
|
+
export declare function toGoogleAuth(clientId: string, redirectUri: string): void;
|
|
4
|
+
/** 谷歌身份检查 */
|
|
5
|
+
export declare const GoogleAuth: {
|
|
6
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
10
|
+
redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
}>> & {
|
|
14
|
+
onCallback?: ((_data: {
|
|
15
|
+
code: string;
|
|
16
|
+
}) => any) | undefined;
|
|
17
|
+
onRejectCallback?: ((_data: any) => any) | undefined;
|
|
18
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
|
+
callback: (_data: {
|
|
20
|
+
code: string;
|
|
21
|
+
}) => true;
|
|
22
|
+
rejectCallback: (_data: any) => true;
|
|
23
|
+
}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
+
clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
}>> & {
|
|
31
|
+
onCallback?: ((_data: {
|
|
32
|
+
code: string;
|
|
33
|
+
}) => any) | undefined;
|
|
34
|
+
onRejectCallback?: ((_data: any) => any) | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
clientId: string;
|
|
37
|
+
redirectUri: string;
|
|
38
|
+
}, true, {}, SlotsType<{
|
|
39
|
+
default: {
|
|
40
|
+
startCheck: () => void;
|
|
41
|
+
};
|
|
42
|
+
}>, {
|
|
43
|
+
P: {};
|
|
44
|
+
B: {};
|
|
45
|
+
D: {};
|
|
46
|
+
C: {};
|
|
47
|
+
M: {};
|
|
48
|
+
Defaults: {};
|
|
49
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
50
|
+
clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
}>> & {
|
|
57
|
+
onCallback?: ((_data: {
|
|
58
|
+
code: string;
|
|
59
|
+
}) => any) | undefined;
|
|
60
|
+
onRejectCallback?: ((_data: any) => any) | undefined;
|
|
61
|
+
}, () => JSX.Element, {}, {}, {}, {
|
|
62
|
+
clientId: string;
|
|
63
|
+
redirectUri: string;
|
|
64
|
+
}>;
|
|
65
|
+
__isFragment?: undefined;
|
|
66
|
+
__isTeleport?: undefined;
|
|
67
|
+
__isSuspense?: undefined;
|
|
68
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
69
|
+
clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
}>> & {
|
|
76
|
+
onCallback?: ((_data: {
|
|
77
|
+
code: string;
|
|
78
|
+
}) => any) | undefined;
|
|
79
|
+
onRejectCallback?: ((_data: any) => any) | undefined;
|
|
80
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
81
|
+
callback: (_data: {
|
|
82
|
+
code: string;
|
|
83
|
+
}) => true;
|
|
84
|
+
rejectCallback: (_data: any) => true;
|
|
85
|
+
}, string, {
|
|
86
|
+
clientId: string;
|
|
87
|
+
redirectUri: string;
|
|
88
|
+
}, {}, string, SlotsType<{
|
|
89
|
+
default: {
|
|
90
|
+
startCheck: () => void;
|
|
91
|
+
};
|
|
92
|
+
}>> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & ({
|
|
93
|
+
readonly toGoogleAuth: typeof toGoogleAuth;
|
|
94
|
+
} & import("vue").Plugin)));
|
|
95
|
+
export default GoogleAuth;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defineComponent as g, ref as p, onMounted as h, createVNode as C } from "vue";
|
|
2
|
+
import { propTypes as f } from "../utils/vuePropTypes.js";
|
|
3
|
+
import { isEdgeBrowser as w, isInMobileBrowser as _ } from "../utils/is.js";
|
|
4
|
+
import { withInstall as b } from "../utils/withInstall.js";
|
|
5
|
+
function v(o, r) {
|
|
6
|
+
if (!o || !r)
|
|
7
|
+
return;
|
|
8
|
+
const c = encodeURIComponent(r), s = encodeURIComponent("email profile"), i = encodeURIComponent(o), n = `https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=${c}&scope=${s}&client_id=${i}`;
|
|
9
|
+
w() ? window.open(n, "_self") : window.location.href = n;
|
|
10
|
+
}
|
|
11
|
+
const I = /* @__PURE__ */ g({
|
|
12
|
+
name: "GoogleAuth",
|
|
13
|
+
toGoogleAuth: v,
|
|
14
|
+
props: {
|
|
15
|
+
clientId: f.string,
|
|
16
|
+
redirectUri: f.string
|
|
17
|
+
},
|
|
18
|
+
emits: {
|
|
19
|
+
callback: (o) => !0,
|
|
20
|
+
rejectCallback: (o) => !0
|
|
21
|
+
},
|
|
22
|
+
slots: Object,
|
|
23
|
+
setup(o, {
|
|
24
|
+
emit: r,
|
|
25
|
+
slots: c,
|
|
26
|
+
expose: s
|
|
27
|
+
}) {
|
|
28
|
+
const i = p(null), n = p(!0), u = () => {
|
|
29
|
+
var e, t, l;
|
|
30
|
+
return (l = (t = (e = window == null ? void 0 : window.google) == null ? void 0 : e.accounts) == null ? void 0 : t.oauth2) == null ? void 0 : l.initCodeClient;
|
|
31
|
+
};
|
|
32
|
+
function d() {
|
|
33
|
+
var e, t, l;
|
|
34
|
+
(l = (t = (e = u()) == null ? void 0 : e({
|
|
35
|
+
client_id: o.clientId,
|
|
36
|
+
scope: "email profile",
|
|
37
|
+
redirect_uri: o.redirectUri,
|
|
38
|
+
ux_mode: _() ? "redirect" : "popup",
|
|
39
|
+
callback(a) {
|
|
40
|
+
a.error ? r("rejectCallback", a) : r("callback", a);
|
|
41
|
+
}
|
|
42
|
+
})) == null ? void 0 : t.requestCode) == null || l.call(t);
|
|
43
|
+
}
|
|
44
|
+
function m() {
|
|
45
|
+
if (!(window != null && window.document) || u() || !i.value) {
|
|
46
|
+
u() && (n.value = !1);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const e = document.createElement("script");
|
|
50
|
+
e.async = !0, e.defer = !0, e.src = "https://accounts.google.com/gsi/client", i.value.appendChild(e), e.onload = () => {
|
|
51
|
+
u() && (n.value = !1);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return h(m), s({
|
|
55
|
+
startCheck: d
|
|
56
|
+
}), () => {
|
|
57
|
+
var e;
|
|
58
|
+
return C("div", {
|
|
59
|
+
ref: i
|
|
60
|
+
}, [!n.value && ((e = c.default) == null ? void 0 : e.call(c, {
|
|
61
|
+
startCheck: d
|
|
62
|
+
}))]);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}), R = b(I);
|
|
66
|
+
export {
|
|
67
|
+
R as GoogleAuth,
|
|
68
|
+
R as default,
|
|
69
|
+
v as toGoogleAuth
|
|
70
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type SlotsType } from 'vue';
|
|
2
|
+
/** tg用户信息 */
|
|
3
|
+
export type TgUserData = {
|
|
4
|
+
auth_date: number;
|
|
5
|
+
first_name: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
id: number;
|
|
8
|
+
last_name: string;
|
|
9
|
+
photo_url: string;
|
|
10
|
+
username: string;
|
|
11
|
+
};
|
|
12
|
+
/** 跳转Telegram身份检查 */
|
|
13
|
+
export declare function toTelegramAuth(botId: number, toPath: string): void;
|
|
14
|
+
/** 获取路由中的Telegram身份检查回调参数 */
|
|
15
|
+
export declare function getTelegramAuthUrlParams(): TgUserData | null;
|
|
16
|
+
/** Telegram身份检查 */
|
|
17
|
+
export declare const TelegramAuth: {
|
|
18
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
}>> & {
|
|
26
|
+
onCallback?: ((_user: TgUserData) => any) | undefined;
|
|
27
|
+
onRejectCallback?: (() => any) | undefined;
|
|
28
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
29
|
+
callback: (_user: TgUserData) => true;
|
|
30
|
+
rejectCallback: () => true;
|
|
31
|
+
}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
|
|
32
|
+
botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
|
|
33
|
+
default: number;
|
|
34
|
+
};
|
|
35
|
+
toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}>> & {
|
|
39
|
+
onCallback?: ((_user: TgUserData) => any) | undefined;
|
|
40
|
+
onRejectCallback?: (() => any) | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
botId: number;
|
|
43
|
+
toPath: string;
|
|
44
|
+
}, true, {}, SlotsType<{
|
|
45
|
+
default: {
|
|
46
|
+
startCheck: () => void;
|
|
47
|
+
};
|
|
48
|
+
}>, {
|
|
49
|
+
P: {};
|
|
50
|
+
B: {};
|
|
51
|
+
D: {};
|
|
52
|
+
C: {};
|
|
53
|
+
M: {};
|
|
54
|
+
Defaults: {};
|
|
55
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
56
|
+
botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
|
|
57
|
+
default: number;
|
|
58
|
+
};
|
|
59
|
+
toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
}>> & {
|
|
63
|
+
onCallback?: ((_user: TgUserData) => any) | undefined;
|
|
64
|
+
onRejectCallback?: (() => any) | undefined;
|
|
65
|
+
}, () => JSX.Element, {}, {}, {}, {
|
|
66
|
+
botId: number;
|
|
67
|
+
toPath: string;
|
|
68
|
+
}>;
|
|
69
|
+
__isFragment?: undefined;
|
|
70
|
+
__isTeleport?: undefined;
|
|
71
|
+
__isSuspense?: undefined;
|
|
72
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
73
|
+
botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
|
|
74
|
+
default: number;
|
|
75
|
+
};
|
|
76
|
+
toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
79
|
+
}>> & {
|
|
80
|
+
onCallback?: ((_user: TgUserData) => any) | undefined;
|
|
81
|
+
onRejectCallback?: (() => any) | undefined;
|
|
82
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
83
|
+
callback: (_user: TgUserData) => true;
|
|
84
|
+
rejectCallback: () => true;
|
|
85
|
+
}, string, {
|
|
86
|
+
botId: number;
|
|
87
|
+
toPath: string;
|
|
88
|
+
}, {}, string, SlotsType<{
|
|
89
|
+
default: {
|
|
90
|
+
startCheck: () => void;
|
|
91
|
+
};
|
|
92
|
+
}>> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & ({
|
|
93
|
+
readonly toTelegramAuth: typeof toTelegramAuth;
|
|
94
|
+
readonly getTelegramAuthUrlParams: typeof getTelegramAuthUrlParams;
|
|
95
|
+
} & import("vue").Plugin)));
|
|
96
|
+
export default TelegramAuth;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { defineComponent as h, ref as g, onMounted as w, createVNode as b } from "vue";
|
|
2
|
+
import { propTypes as m } from "../utils/vuePropTypes.js";
|
|
3
|
+
import { a as _ } from "../chunks/index-C_baUQWz.js";
|
|
4
|
+
import { withInstall as A } from "../utils/withInstall.js";
|
|
5
|
+
import { isEdgeBrowser as C, isInMobileBrowser as p } from "../utils/is.js";
|
|
6
|
+
function d(r, o) {
|
|
7
|
+
if (!r || !o)
|
|
8
|
+
return;
|
|
9
|
+
const t = encodeURIComponent(_()), n = encodeURIComponent(o), a = `https://oauth.telegram.org/auth?bot_id=${r}&origin=${t}&embed=1&request_access=write&return_to=${t}${n}`;
|
|
10
|
+
C() ? window.open(a, "_self") : window.location.href = a;
|
|
11
|
+
}
|
|
12
|
+
function T() {
|
|
13
|
+
const r = /[#\?\&]tgAuthResult=([A-Za-z0-9\-_=]*)$/;
|
|
14
|
+
try {
|
|
15
|
+
const o = window.location.hash.toString(), t = o.match(r);
|
|
16
|
+
if (!t)
|
|
17
|
+
return null;
|
|
18
|
+
window.location.hash = o.replace(r, "");
|
|
19
|
+
let n = t[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
20
|
+
const a = n.length % 4;
|
|
21
|
+
return a > 1 && (n += new Array(5 - a).join("=")), n ? JSON.parse(window.atob(n)) : null;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const j = /* @__PURE__ */ h({
|
|
27
|
+
name: "TelegramAuth",
|
|
28
|
+
toTelegramAuth: d,
|
|
29
|
+
getTelegramAuthUrlParams: T,
|
|
30
|
+
props: {
|
|
31
|
+
botId: m.number,
|
|
32
|
+
toPath: m.string
|
|
33
|
+
},
|
|
34
|
+
emits: {
|
|
35
|
+
callback: (r) => !0,
|
|
36
|
+
rejectCallback: () => !0
|
|
37
|
+
},
|
|
38
|
+
slots: Object,
|
|
39
|
+
setup(r, {
|
|
40
|
+
emit: o,
|
|
41
|
+
slots: t,
|
|
42
|
+
expose: n
|
|
43
|
+
}) {
|
|
44
|
+
const a = g(null), l = () => {
|
|
45
|
+
var e, c;
|
|
46
|
+
return (c = (e = window == null ? void 0 : window.Telegram) == null ? void 0 : e.Login) == null ? void 0 : c.auth;
|
|
47
|
+
};
|
|
48
|
+
function s() {
|
|
49
|
+
const {
|
|
50
|
+
botId: e,
|
|
51
|
+
toPath: c
|
|
52
|
+
} = r;
|
|
53
|
+
if (!e)
|
|
54
|
+
return;
|
|
55
|
+
const i = l();
|
|
56
|
+
if (p() || !i) {
|
|
57
|
+
d(e, c);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
i == null || i({
|
|
61
|
+
bot_id: e,
|
|
62
|
+
request_access: !0
|
|
63
|
+
}, (u) => {
|
|
64
|
+
u ? o("callback", u) : o("rejectCallback");
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function f() {
|
|
68
|
+
var c;
|
|
69
|
+
if (!(window != null && window.document) || l() || p())
|
|
70
|
+
return;
|
|
71
|
+
const e = document.createElement("script");
|
|
72
|
+
e.async = !0, e.defer = !0, e.src = "https://telegram.org/js/telegram-widget.js", (c = a.value) == null || c.appendChild(e);
|
|
73
|
+
}
|
|
74
|
+
return w(f), n({
|
|
75
|
+
startCheck: s
|
|
76
|
+
}), () => {
|
|
77
|
+
var e;
|
|
78
|
+
return b("div", {
|
|
79
|
+
ref: a
|
|
80
|
+
}, [(e = t.default) == null ? void 0 : e.call(t, {
|
|
81
|
+
startCheck: s
|
|
82
|
+
})]);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}), R = A(j);
|
|
86
|
+
export {
|
|
87
|
+
R as TelegramAuth,
|
|
88
|
+
R as default,
|
|
89
|
+
T as getTelegramAuthUrlParams,
|
|
90
|
+
d as toTelegramAuth
|
|
91
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GoogleAuth as t, toGoogleAuth as r } from "./GoogleAuth.js";
|
|
2
|
+
import { TelegramAuth as l, getTelegramAuthUrlParams as m, toTelegramAuth as a } from "./TelegramAuth.js";
|
|
3
|
+
export {
|
|
4
|
+
t as GoogleAuth,
|
|
5
|
+
l as TelegramAuth,
|
|
6
|
+
m as getTelegramAuthUrlParams,
|
|
7
|
+
r as toGoogleAuth,
|
|
8
|
+
a as toTelegramAuth
|
|
9
|
+
};
|