jk-vue-comps 0.1.11 → 0.1.12
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/chunks/index-BE5vnR2C.js +175 -0
- package/dist/chunks/index-DyiqKziC.js +13 -0
- package/dist/components/GoogleAuth.d.ts +95 -0
- package/dist/components/GoogleAuth.js +71 -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 +258 -0
- package/dist/index.js +95 -0
- package/dist/utils/index.d.ts +54 -0
- package/dist/utils/index.js +80 -0
- package/dist/utils/is.d.ts +59 -0
- package/dist/utils/is.js +120 -0
- package/dist/utils/math.d.ts +107 -0
- package/dist/utils/math.js +821 -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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { nextTick as S, createVNode as N } from "vue";
|
|
2
|
+
import { isString as u, isHtmlStr as m, isObject as l, isNumber as p, is as $, isArray as b, isBoolean as x, isClient as O, isDate as v, isDef as P, isEdgeBrowser as T, isElement as U, isEmail as y, isEmpty as E, isFunction as B, isInMobileBrowser as I, isIp as L, isMap as D, isNull as k, isNullAndUnDef as q, isNullOrUnDef as F, isPromise as M, isPromiseLink as R, isRegExp as _, isServer as W, isUnDef as j, isUrl as z, isValidPhoneNumber as H, isWindow as V, isZhLang as A } from "../utils/is.js";
|
|
3
|
+
import { isNanValue as d, toNum as g, BigNumber as C, DOWN as G, UP as Z, add as J, divide as K, formatRate as Q, helper as X, isBigNum as Y, isBool as ee, isEqualTo as ie, isGreaterThan as te, isGreaterThanOrEqualTo as ne, isInt as re, isLessThan as oe, isLessThanOrEqualTo as se, isNum as ue, multiply as ae, power as le, subtract as fe, toBigNum as ce, toDecimalPlaces as me, toInt as pe, toLocaleString as de, toString as ge, unFormatRate as he } from "../utils/math.js";
|
|
4
|
+
import { propTypes as we } from "../utils/vuePropTypes.js";
|
|
5
|
+
import { timeZoneOptions as Se } from "../utils/timeZone.js";
|
|
6
|
+
import { withInstall as Ne } from "../utils/withInstall.js";
|
|
7
|
+
function a(i) {
|
|
8
|
+
try {
|
|
9
|
+
return new Function(`'use strict'; return (${i});`)();
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function h(i, n = "float", t = 6) {
|
|
15
|
+
let e = String(i);
|
|
16
|
+
if (e = e.replace(/(^\s*)|(\s*$)/g, ""), e !== "") {
|
|
17
|
+
const r = e.indexOf("0") === 0 && e.length > 1 && e.indexOf(".") !== 1, o = n === "int" ? /[^\d]/g : /[^\d.]/g;
|
|
18
|
+
if (e = e.replace(o, ""), r)
|
|
19
|
+
return "0";
|
|
20
|
+
if (n === "int")
|
|
21
|
+
e = e.indexOf("0") === 0 && e.length > 1 ? e.substring(0, e.length - 1) : e;
|
|
22
|
+
else {
|
|
23
|
+
const s = a(`/\\.{${t},}/g`), f = a(`/^(\\d?)+(\\.\\d{0,${t}})?$/`);
|
|
24
|
+
e.indexOf(".") === 0 ? (e = "", e = e.replace(/[^$#$]/g, "0."), e = e.replace(s, ".")) : f.test(e) || (e = e.substring(0, e.length - 1));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
function $e(i, n, t, e = "int", r = 6) {
|
|
30
|
+
return (o) => {
|
|
31
|
+
S().then(() => {
|
|
32
|
+
var s;
|
|
33
|
+
i[n] = h((s = o == null ? void 0 : o.target) == null ? void 0 : s.value, e, r), t == null || t();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function be(i) {
|
|
38
|
+
return !u(i) || !m(i) ? i : N("div", { innerHTML: i });
|
|
39
|
+
}
|
|
40
|
+
function xe() {
|
|
41
|
+
return window ? `${window.location.protocol}//${window.location.hostname}` : "";
|
|
42
|
+
}
|
|
43
|
+
function Oe() {
|
|
44
|
+
const i = new URLSearchParams(window.location.search);
|
|
45
|
+
if (!i.size)
|
|
46
|
+
return;
|
|
47
|
+
const n = {};
|
|
48
|
+
for (const [t, e] of i.entries())
|
|
49
|
+
n[t] = e;
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
function ve(i) {
|
|
53
|
+
return u(i) ? i.replace(/\s+/g, "") : "";
|
|
54
|
+
}
|
|
55
|
+
function w(i = {}, n = {}) {
|
|
56
|
+
let t;
|
|
57
|
+
for (t in n)
|
|
58
|
+
i[t] = l(i[t]) ? w(i[t], n[t]) : i[t] = n[t];
|
|
59
|
+
return i;
|
|
60
|
+
}
|
|
61
|
+
function Pe(i, n = 6, t = {
|
|
62
|
+
showPrefix: !0,
|
|
63
|
+
showSuffix: !0,
|
|
64
|
+
middleStr: "****"
|
|
65
|
+
}) {
|
|
66
|
+
if (!u(i) && !p(i))
|
|
67
|
+
return i;
|
|
68
|
+
const e = String(i), r = (e == null ? void 0 : e.length) ?? 0;
|
|
69
|
+
if (!e || !r || n <= 0)
|
|
70
|
+
return e;
|
|
71
|
+
const o = t.showPrefix ? e.substring(0, n) : "", s = t.showSuffix ? e.substring(r - n) : "";
|
|
72
|
+
return `${o}${t.middleStr}${s}`;
|
|
73
|
+
}
|
|
74
|
+
function Te(i, n = "px") {
|
|
75
|
+
if (!(i === null || i === "" || i === void 0))
|
|
76
|
+
return d(i) ? String(i) : `${g(i)}${n}`;
|
|
77
|
+
}
|
|
78
|
+
function Ue(i) {
|
|
79
|
+
return i ? l(i) ? i : i.split(";").reduce((n, t) => {
|
|
80
|
+
const [e, r] = t.trim().split(":");
|
|
81
|
+
if (e) {
|
|
82
|
+
const s = e.trim().replace(/-(\w)/g, (f, c) => c ? c.toUpperCase() : "");
|
|
83
|
+
n[s] = r.trim();
|
|
84
|
+
}
|
|
85
|
+
return n;
|
|
86
|
+
}, {}) : {};
|
|
87
|
+
}
|
|
88
|
+
const ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
89
|
+
__proto__: null,
|
|
90
|
+
BigNumber: C,
|
|
91
|
+
DOWN: G,
|
|
92
|
+
UP: Z,
|
|
93
|
+
add: J,
|
|
94
|
+
deepMerge: w,
|
|
95
|
+
desensitization: Pe,
|
|
96
|
+
divide: K,
|
|
97
|
+
evalPro: a,
|
|
98
|
+
filterInputNum: h,
|
|
99
|
+
formatRate: Q,
|
|
100
|
+
generateFilterInputNumFn: $e,
|
|
101
|
+
getRouterParams: Oe,
|
|
102
|
+
getWebsiteUrl: xe,
|
|
103
|
+
helper: X,
|
|
104
|
+
is: $,
|
|
105
|
+
isArray: b,
|
|
106
|
+
isBigNum: Y,
|
|
107
|
+
isBool: ee,
|
|
108
|
+
isBoolean: x,
|
|
109
|
+
isClient: O,
|
|
110
|
+
isDate: v,
|
|
111
|
+
isDef: P,
|
|
112
|
+
isEdgeBrowser: T,
|
|
113
|
+
isElement: U,
|
|
114
|
+
isEmail: y,
|
|
115
|
+
isEmpty: E,
|
|
116
|
+
isEqualTo: ie,
|
|
117
|
+
isFunction: B,
|
|
118
|
+
isGreaterThan: te,
|
|
119
|
+
isGreaterThanOrEqualTo: ne,
|
|
120
|
+
isHtmlStr: m,
|
|
121
|
+
isInMobileBrowser: I,
|
|
122
|
+
isInt: re,
|
|
123
|
+
isIp: L,
|
|
124
|
+
isLessThan: oe,
|
|
125
|
+
isLessThanOrEqualTo: se,
|
|
126
|
+
isMap: D,
|
|
127
|
+
isNanValue: d,
|
|
128
|
+
isNull: k,
|
|
129
|
+
isNullAndUnDef: q,
|
|
130
|
+
isNullOrUnDef: F,
|
|
131
|
+
isNum: ue,
|
|
132
|
+
isNumber: p,
|
|
133
|
+
isObject: l,
|
|
134
|
+
isPromise: M,
|
|
135
|
+
isPromiseLink: R,
|
|
136
|
+
isRegExp: _,
|
|
137
|
+
isServer: W,
|
|
138
|
+
isString: u,
|
|
139
|
+
isUnDef: j,
|
|
140
|
+
isUrl: z,
|
|
141
|
+
isValidPhoneNumber: H,
|
|
142
|
+
isWindow: V,
|
|
143
|
+
isZhLang: A,
|
|
144
|
+
multiply: ae,
|
|
145
|
+
power: le,
|
|
146
|
+
propTypes: we,
|
|
147
|
+
removeWhitespace: ve,
|
|
148
|
+
renderHtmlStr: be,
|
|
149
|
+
subtract: fe,
|
|
150
|
+
timeZoneOptions: Se,
|
|
151
|
+
toBigNum: ce,
|
|
152
|
+
toDecimalPlaces: me,
|
|
153
|
+
toInt: pe,
|
|
154
|
+
toLocaleString: de,
|
|
155
|
+
toNum: g,
|
|
156
|
+
toString: ge,
|
|
157
|
+
toStyleObject: Ue,
|
|
158
|
+
toStyleUnit: Te,
|
|
159
|
+
unFormatRate: he,
|
|
160
|
+
withInstall: Ne
|
|
161
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
162
|
+
export {
|
|
163
|
+
ke as U,
|
|
164
|
+
xe as a,
|
|
165
|
+
Oe as b,
|
|
166
|
+
ve as c,
|
|
167
|
+
w as d,
|
|
168
|
+
a as e,
|
|
169
|
+
h as f,
|
|
170
|
+
$e as g,
|
|
171
|
+
Pe as h,
|
|
172
|
+
Ue as i,
|
|
173
|
+
be as r,
|
|
174
|
+
Te as t
|
|
175
|
+
};
|
|
@@ -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,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,71 @@
|
|
|
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 "../utils/math.js";
|
|
5
|
+
import { withInstall as b } from "../utils/withInstall.js";
|
|
6
|
+
function v(o, r) {
|
|
7
|
+
if (!o || !r)
|
|
8
|
+
return;
|
|
9
|
+
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}`;
|
|
10
|
+
w() ? window.open(n, "_self") : window.location.href = n;
|
|
11
|
+
}
|
|
12
|
+
const I = /* @__PURE__ */ g({
|
|
13
|
+
name: "GoogleAuth",
|
|
14
|
+
toGoogleAuth: v,
|
|
15
|
+
props: {
|
|
16
|
+
clientId: f.string,
|
|
17
|
+
redirectUri: f.string
|
|
18
|
+
},
|
|
19
|
+
emits: {
|
|
20
|
+
callback: (o) => !0,
|
|
21
|
+
rejectCallback: (o) => !0
|
|
22
|
+
},
|
|
23
|
+
slots: Object,
|
|
24
|
+
setup(o, {
|
|
25
|
+
emit: r,
|
|
26
|
+
slots: c,
|
|
27
|
+
expose: s
|
|
28
|
+
}) {
|
|
29
|
+
const i = p(null), n = p(!0), u = () => {
|
|
30
|
+
var e, t, l;
|
|
31
|
+
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;
|
|
32
|
+
};
|
|
33
|
+
function d() {
|
|
34
|
+
var e, t, l;
|
|
35
|
+
(l = (t = (e = u()) == null ? void 0 : e({
|
|
36
|
+
client_id: o.clientId,
|
|
37
|
+
scope: "email profile",
|
|
38
|
+
redirect_uri: o.redirectUri,
|
|
39
|
+
ux_mode: _() ? "redirect" : "popup",
|
|
40
|
+
callback(a) {
|
|
41
|
+
a.error ? r("rejectCallback", a) : r("callback", a);
|
|
42
|
+
}
|
|
43
|
+
})) == null ? void 0 : t.requestCode) == null || l.call(t);
|
|
44
|
+
}
|
|
45
|
+
function m() {
|
|
46
|
+
if (!(window != null && window.document) || u() || !i.value) {
|
|
47
|
+
u() && (n.value = !1);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const e = document.createElement("script");
|
|
51
|
+
e.async = !0, e.defer = !0, e.src = "https://accounts.google.com/gsi/client", i.value.appendChild(e), e.onload = () => {
|
|
52
|
+
u() && (n.value = !1);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return h(m), s({
|
|
56
|
+
startCheck: d
|
|
57
|
+
}), () => {
|
|
58
|
+
var e;
|
|
59
|
+
return C("div", {
|
|
60
|
+
ref: i
|
|
61
|
+
}, [!n.value && ((e = c.default) == null ? void 0 : e.call(c, {
|
|
62
|
+
startCheck: d
|
|
63
|
+
}))]);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}), j = b(I);
|
|
67
|
+
export {
|
|
68
|
+
j as GoogleAuth,
|
|
69
|
+
j as default,
|
|
70
|
+
v as toGoogleAuth
|
|
71
|
+
};
|
|
@@ -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-BE5vnR2C.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
|
+
};
|