@hostlink/light 2.0.2 → 2.2.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/auth.d.ts +3 -0
- package/dist/light.js +158 -147
- package/dist/light.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/auth.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ declare const _default: (axios: AxiosInstance) => {
|
|
|
4
4
|
login: (username: string) => Promise<void>;
|
|
5
5
|
register: () => Promise<void>;
|
|
6
6
|
};
|
|
7
|
+
facebookLogin: (accessToken: string) => Promise<boolean>;
|
|
8
|
+
microsoftLogin: (accessToken: string) => Promise<boolean>;
|
|
7
9
|
googleLogin: (credential: string) => Promise<boolean>;
|
|
8
10
|
login: (username: string, password: string, code?: string) => Promise<boolean>;
|
|
9
11
|
logout: () => Promise<boolean>;
|
|
12
|
+
changeExpiredPassword: (username: string, oldPassword: string, newPassword: string) => Promise<boolean>;
|
|
10
13
|
updatePassword: (oldPassword: string, newPassword: string) => Promise<boolean>;
|
|
11
14
|
resetPassword: (username: string, password: string, code: string) => Promise<boolean>;
|
|
12
15
|
forgetPassword: (username: string, email: string) => Promise<boolean>;
|
package/dist/light.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as
|
|
1
|
+
import { jsonToGraphQLQuery as R, VariableType as S } from "json-to-graphql-query";
|
|
2
2
|
import U from "axios";
|
|
3
3
|
function j(t) {
|
|
4
4
|
const e = "==".slice(0, (4 - t.length % 4) % 4), r = t.replace(/-/g, "+").replace(/_/g, "/") + e, n = atob(r), s = new ArrayBuffer(n.length), a = new Uint8Array(s);
|
|
5
|
-
for (let
|
|
6
|
-
a[
|
|
5
|
+
for (let i = 0; i < n.length; i++)
|
|
6
|
+
a[i] = n.charCodeAt(i);
|
|
7
7
|
return s;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function L(t) {
|
|
10
10
|
const e = new Uint8Array(t);
|
|
11
11
|
let r = "";
|
|
12
12
|
for (const a of e)
|
|
@@ -16,11 +16,11 @@ function N(t) {
|
|
|
16
16
|
"_"
|
|
17
17
|
).replace(/=/g, "");
|
|
18
18
|
}
|
|
19
|
-
var
|
|
19
|
+
var u = "copy", w = "convert";
|
|
20
20
|
function F(t, e, r) {
|
|
21
|
-
if (e ===
|
|
21
|
+
if (e === u)
|
|
22
22
|
return r;
|
|
23
|
-
if (e ===
|
|
23
|
+
if (e === w)
|
|
24
24
|
return t(r);
|
|
25
25
|
if (e instanceof Array)
|
|
26
26
|
return r.map((n) => F(t, e[0], n));
|
|
@@ -28,8 +28,8 @@ function F(t, e, r) {
|
|
|
28
28
|
const n = {};
|
|
29
29
|
for (const [s, a] of Object.entries(e)) {
|
|
30
30
|
if (a.derive) {
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const i = a.derive(r);
|
|
32
|
+
i !== void 0 && (r[s] = i);
|
|
33
33
|
}
|
|
34
34
|
if (!(s in r)) {
|
|
35
35
|
if (a.required)
|
|
@@ -49,14 +49,14 @@ function F(t, e, r) {
|
|
|
49
49
|
return n;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function E(t, e) {
|
|
53
53
|
return {
|
|
54
54
|
required: !0,
|
|
55
55
|
schema: t,
|
|
56
56
|
derive: e
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function c(t) {
|
|
60
60
|
return {
|
|
61
61
|
required: !0,
|
|
62
62
|
schema: t
|
|
@@ -68,89 +68,89 @@ function d(t) {
|
|
|
68
68
|
schema: t
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
var
|
|
72
|
-
type: u
|
|
73
|
-
id:
|
|
74
|
-
transports: d(
|
|
75
|
-
}, L = {
|
|
76
|
-
appid: d(l),
|
|
77
|
-
appidExclude: d(l),
|
|
78
|
-
credProps: d(l)
|
|
71
|
+
var N = {
|
|
72
|
+
type: c(u),
|
|
73
|
+
id: c(w),
|
|
74
|
+
transports: d(u)
|
|
79
75
|
}, P = {
|
|
80
|
-
appid: d(
|
|
81
|
-
appidExclude: d(
|
|
82
|
-
credProps: d(
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
appid: d(u),
|
|
77
|
+
appidExclude: d(u),
|
|
78
|
+
credProps: d(u)
|
|
79
|
+
}, J = {
|
|
80
|
+
appid: d(u),
|
|
81
|
+
appidExclude: d(u),
|
|
82
|
+
credProps: d(u)
|
|
83
|
+
}, V = {
|
|
84
|
+
publicKey: c({
|
|
85
|
+
rp: c(u),
|
|
86
|
+
user: c({
|
|
87
|
+
id: c(w),
|
|
88
|
+
name: c(u),
|
|
89
|
+
displayName: c(u)
|
|
90
90
|
}),
|
|
91
|
-
challenge:
|
|
92
|
-
pubKeyCredParams: u
|
|
93
|
-
timeout: d(
|
|
94
|
-
excludeCredentials: d([
|
|
95
|
-
authenticatorSelection: d(
|
|
96
|
-
attestation: d(
|
|
97
|
-
extensions: d(
|
|
91
|
+
challenge: c(w),
|
|
92
|
+
pubKeyCredParams: c(u),
|
|
93
|
+
timeout: d(u),
|
|
94
|
+
excludeCredentials: d([N]),
|
|
95
|
+
authenticatorSelection: d(u),
|
|
96
|
+
attestation: d(u),
|
|
97
|
+
extensions: d(P)
|
|
98
98
|
}),
|
|
99
|
-
signal: d(
|
|
100
|
-
},
|
|
101
|
-
type: u
|
|
102
|
-
id: u
|
|
103
|
-
rawId:
|
|
104
|
-
authenticatorAttachment: d(
|
|
105
|
-
response:
|
|
106
|
-
clientDataJSON:
|
|
107
|
-
attestationObject:
|
|
108
|
-
transports:
|
|
109
|
-
|
|
99
|
+
signal: d(u)
|
|
100
|
+
}, T = {
|
|
101
|
+
type: c(u),
|
|
102
|
+
id: c(u),
|
|
103
|
+
rawId: c(w),
|
|
104
|
+
authenticatorAttachment: d(u),
|
|
105
|
+
response: c({
|
|
106
|
+
clientDataJSON: c(w),
|
|
107
|
+
attestationObject: c(w),
|
|
108
|
+
transports: E(
|
|
109
|
+
u,
|
|
110
110
|
(t) => {
|
|
111
111
|
var e;
|
|
112
112
|
return ((e = t.getTransports) == null ? void 0 : e.call(t)) || [];
|
|
113
113
|
}
|
|
114
114
|
)
|
|
115
115
|
}),
|
|
116
|
-
clientExtensionResults:
|
|
117
|
-
|
|
116
|
+
clientExtensionResults: E(
|
|
117
|
+
J,
|
|
118
118
|
(t) => t.getClientExtensionResults()
|
|
119
119
|
)
|
|
120
120
|
}, K = {
|
|
121
|
-
mediation: d(
|
|
122
|
-
publicKey:
|
|
123
|
-
challenge:
|
|
124
|
-
timeout: d(
|
|
125
|
-
rpId: d(
|
|
126
|
-
allowCredentials: d([
|
|
127
|
-
userVerification: d(
|
|
128
|
-
extensions: d(
|
|
121
|
+
mediation: d(u),
|
|
122
|
+
publicKey: c({
|
|
123
|
+
challenge: c(w),
|
|
124
|
+
timeout: d(u),
|
|
125
|
+
rpId: d(u),
|
|
126
|
+
allowCredentials: d([N]),
|
|
127
|
+
userVerification: d(u),
|
|
128
|
+
extensions: d(P)
|
|
129
129
|
}),
|
|
130
|
-
signal: d(
|
|
130
|
+
signal: d(u)
|
|
131
131
|
}, D = {
|
|
132
|
-
type: u
|
|
133
|
-
id: u
|
|
134
|
-
rawId:
|
|
135
|
-
authenticatorAttachment: d(
|
|
136
|
-
response:
|
|
137
|
-
clientDataJSON:
|
|
138
|
-
authenticatorData:
|
|
139
|
-
signature:
|
|
140
|
-
userHandle:
|
|
132
|
+
type: c(u),
|
|
133
|
+
id: c(u),
|
|
134
|
+
rawId: c(w),
|
|
135
|
+
authenticatorAttachment: d(u),
|
|
136
|
+
response: c({
|
|
137
|
+
clientDataJSON: c(w),
|
|
138
|
+
authenticatorData: c(w),
|
|
139
|
+
signature: c(w),
|
|
140
|
+
userHandle: c(w)
|
|
141
141
|
}),
|
|
142
|
-
clientExtensionResults:
|
|
143
|
-
|
|
142
|
+
clientExtensionResults: E(
|
|
143
|
+
J,
|
|
144
144
|
(t) => t.getClientExtensionResults()
|
|
145
145
|
)
|
|
146
146
|
};
|
|
147
147
|
function B(t) {
|
|
148
|
-
return F(j,
|
|
148
|
+
return F(j, V, t);
|
|
149
149
|
}
|
|
150
150
|
function Q(t) {
|
|
151
151
|
return F(
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
L,
|
|
153
|
+
T,
|
|
154
154
|
t
|
|
155
155
|
);
|
|
156
156
|
}
|
|
@@ -159,7 +159,7 @@ function W(t) {
|
|
|
159
159
|
}
|
|
160
160
|
function $(t) {
|
|
161
161
|
return F(
|
|
162
|
-
|
|
162
|
+
L,
|
|
163
163
|
D,
|
|
164
164
|
t
|
|
165
165
|
);
|
|
@@ -187,7 +187,7 @@ const H = (t) => ({
|
|
|
187
187
|
})).webAuthnRequestOptions, s = W({
|
|
188
188
|
publicKey: n
|
|
189
189
|
}), a = await G(s);
|
|
190
|
-
await
|
|
190
|
+
await l(t, "webAuthnAssertion", {
|
|
191
191
|
username: e,
|
|
192
192
|
assertion: a.toJSON()
|
|
193
193
|
});
|
|
@@ -196,36 +196,47 @@ const H = (t) => ({
|
|
|
196
196
|
const e = await h(t, { webAuthnCreationOptions: !0 }), r = B({
|
|
197
197
|
publicKey: e.webAuthnCreationOptions
|
|
198
198
|
}), n = await z(r);
|
|
199
|
-
await
|
|
199
|
+
await l(t, "webAuthnRegister", {
|
|
200
200
|
registration: n.toJSON()
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}), I = (t) => ({
|
|
204
204
|
WebAuthn: H(t),
|
|
205
|
-
|
|
205
|
+
facebookLogin: (e) => l(t, "facebookLogin", {
|
|
206
|
+
access_token: e
|
|
207
|
+
}),
|
|
208
|
+
microsoftLogin: (e) => l(t, "microsoftLogin", {
|
|
209
|
+
access_token: e
|
|
210
|
+
}),
|
|
211
|
+
googleLogin: (e) => l(t, "googleLogin", {
|
|
206
212
|
credential: e
|
|
207
213
|
}),
|
|
208
|
-
login: (e, r, n = "") =>
|
|
214
|
+
login: (e, r, n = "") => l(t, "login", {
|
|
209
215
|
username: e,
|
|
210
216
|
password: r,
|
|
211
217
|
code: n
|
|
212
218
|
}),
|
|
213
|
-
logout: () =>
|
|
214
|
-
|
|
219
|
+
logout: () => l(t, "logout"),
|
|
220
|
+
changeExpiredPassword: (e, r, n) => l(t, "changeExpiredPassword", {
|
|
221
|
+
username: e,
|
|
222
|
+
old_password: r,
|
|
223
|
+
new_password: n
|
|
224
|
+
}),
|
|
225
|
+
updatePassword: (e, r) => l(t, "updatePassword", {
|
|
215
226
|
old_password: e,
|
|
216
227
|
new_password: r
|
|
217
228
|
}),
|
|
218
|
-
resetPassword: (e, r, n) =>
|
|
229
|
+
resetPassword: (e, r, n) => l(t, "resetPassword", {
|
|
219
230
|
username: e,
|
|
220
231
|
password: r,
|
|
221
232
|
code: n
|
|
222
233
|
}),
|
|
223
|
-
forgetPassword: (e, r) =>
|
|
234
|
+
forgetPassword: (e, r) => l(t, "forgetPassword", {
|
|
224
235
|
username: e,
|
|
225
236
|
email: r
|
|
226
237
|
}),
|
|
227
238
|
verifyCode(e, r) {
|
|
228
|
-
return
|
|
239
|
+
return l(t, "forgetPasswordVerifyCode", {
|
|
229
240
|
username: e,
|
|
230
241
|
code: r
|
|
231
242
|
});
|
|
@@ -238,41 +249,41 @@ const H = (t) => ({
|
|
|
238
249
|
}
|
|
239
250
|
})).granted
|
|
240
251
|
}), M = (t, e, r) => {
|
|
241
|
-
const n = e, s = t, a = r,
|
|
252
|
+
const n = e, s = t, a = r, i = (o) => a[o] ? a[o]() : null;
|
|
242
253
|
return {
|
|
243
|
-
field:
|
|
254
|
+
field: i,
|
|
244
255
|
$fields: a,
|
|
245
|
-
gqlFields(
|
|
256
|
+
gqlFields(o) {
|
|
246
257
|
const p = [];
|
|
247
|
-
for (const f of
|
|
258
|
+
for (const f of o)
|
|
248
259
|
if (typeof f == "string") {
|
|
249
|
-
const g =
|
|
260
|
+
const g = i(f);
|
|
250
261
|
g && p.push(g.getGQLField());
|
|
251
262
|
} else typeof f == "object" && p.push(f);
|
|
252
263
|
return p;
|
|
253
264
|
},
|
|
254
|
-
async update(
|
|
255
|
-
return await
|
|
265
|
+
async update(o, p) {
|
|
266
|
+
return await l(s, "update" + n, { id: o, data: p });
|
|
256
267
|
},
|
|
257
|
-
async delete(
|
|
258
|
-
return await
|
|
268
|
+
async delete(o) {
|
|
269
|
+
return await l(s, "delete" + n, { id: o });
|
|
259
270
|
},
|
|
260
|
-
async add(
|
|
261
|
-
return await
|
|
271
|
+
async add(o) {
|
|
272
|
+
return await l(s, "add" + n, { data: o });
|
|
262
273
|
},
|
|
263
|
-
fields(
|
|
274
|
+
fields(o) {
|
|
264
275
|
let p = [];
|
|
265
|
-
for (let f of
|
|
266
|
-
const g =
|
|
276
|
+
for (let f of o) {
|
|
277
|
+
const g = i(f);
|
|
267
278
|
g && p.push(g);
|
|
268
279
|
}
|
|
269
280
|
return p;
|
|
270
281
|
},
|
|
271
|
-
async get(
|
|
282
|
+
async get(o, p) {
|
|
272
283
|
return (await h(s, {
|
|
273
284
|
["list" + n]: {
|
|
274
285
|
__args: {
|
|
275
|
-
filters:
|
|
286
|
+
filters: o
|
|
276
287
|
},
|
|
277
288
|
data: {
|
|
278
289
|
__args: {
|
|
@@ -283,11 +294,11 @@ const H = (t) => ({
|
|
|
283
294
|
}
|
|
284
295
|
}))["list" + n].data[0];
|
|
285
296
|
},
|
|
286
|
-
async list(
|
|
297
|
+
async list(o, p) {
|
|
287
298
|
return (await h(s, {
|
|
288
299
|
["list" + n]: {
|
|
289
300
|
__args: {
|
|
290
|
-
filters:
|
|
301
|
+
filters: o
|
|
291
302
|
},
|
|
292
303
|
data: {
|
|
293
304
|
...A(p)
|
|
@@ -299,17 +310,17 @@ const H = (t) => ({
|
|
|
299
310
|
};
|
|
300
311
|
function X(t) {
|
|
301
312
|
t = "<~" + t + "~>";
|
|
302
|
-
var e, r, n, s, a,
|
|
303
|
-
for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, n = [], s = 0, a = t.length; a > s; s += 5) r = 52200625 * (t.charCodeAt(s) - 33) + 614125 * (t.charCodeAt(s + 1) - 33) + 7225 * (t.charCodeAt(s + 2) - 33) + 85 * (t.charCodeAt(s + 3) - 33) + (t.charCodeAt(s + 4) - 33), n.push(
|
|
313
|
+
var e, r, n, s, a, i = String, o = 255;
|
|
314
|
+
for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, n = [], s = 0, a = t.length; a > s; s += 5) r = 52200625 * (t.charCodeAt(s) - 33) + 614125 * (t.charCodeAt(s + 1) - 33) + 7225 * (t.charCodeAt(s + 2) - 33) + 85 * (t.charCodeAt(s + 3) - 33) + (t.charCodeAt(s + 4) - 33), n.push(o & r >> 24, o & r >> 16, o & r >> 8, o & r);
|
|
304
315
|
return function(p, f) {
|
|
305
316
|
for (var g = f; g > 0; g--) p.pop();
|
|
306
|
-
}(n, e.length),
|
|
317
|
+
}(n, e.length), i.fromCharCode.apply(i, n);
|
|
307
318
|
}
|
|
308
319
|
const v = (t = "") => {
|
|
309
320
|
const e = t, r = (n = "application/octet-stream") => {
|
|
310
321
|
const s = new Uint8Array(e.length);
|
|
311
|
-
for (let
|
|
312
|
-
s[
|
|
322
|
+
for (let o = 0; o < e.length; o++)
|
|
323
|
+
s[o] = e.charCodeAt(o);
|
|
313
324
|
const a = new Blob([s], { type: n });
|
|
314
325
|
return URL.createObjectURL(a);
|
|
315
326
|
};
|
|
@@ -324,14 +335,14 @@ const v = (t = "") => {
|
|
|
324
335
|
window.open(r(n), "_blank");
|
|
325
336
|
}
|
|
326
337
|
};
|
|
327
|
-
},
|
|
338
|
+
}, oe = {
|
|
328
339
|
fromBase85: (t) => v(X(t)),
|
|
329
340
|
fromBase64: (t) => v(atob(t)),
|
|
330
341
|
fromString: (t) => v(t)
|
|
331
|
-
},
|
|
342
|
+
}, q = (t) => {
|
|
332
343
|
let e = {};
|
|
333
344
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
334
|
-
Object.entries(
|
|
345
|
+
Object.entries(q(r)).forEach(([n, s]) => {
|
|
335
346
|
e[n] = s;
|
|
336
347
|
});
|
|
337
348
|
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
@@ -343,10 +354,10 @@ const v = (t = "") => {
|
|
|
343
354
|
e[r] = n;
|
|
344
355
|
return;
|
|
345
356
|
}
|
|
346
|
-
e[r] =
|
|
357
|
+
e[r] = q(n);
|
|
347
358
|
}), e);
|
|
348
|
-
}, A = (t) =>
|
|
349
|
-
let r =
|
|
359
|
+
}, A = (t) => q(t), h = async (t, e) => {
|
|
360
|
+
let r = R(A(e));
|
|
350
361
|
const n = await t.post("", {
|
|
351
362
|
query: `{ ${r} }`
|
|
352
363
|
});
|
|
@@ -366,41 +377,41 @@ function Z(t) {
|
|
|
366
377
|
return !0;
|
|
367
378
|
return !1;
|
|
368
379
|
}
|
|
369
|
-
const
|
|
380
|
+
const l = async (t, e, r = null, n = []) => {
|
|
370
381
|
let s = {
|
|
371
382
|
[e]: {}
|
|
372
383
|
};
|
|
373
384
|
const a = new FormData();
|
|
374
|
-
let
|
|
385
|
+
let i = !1;
|
|
375
386
|
if (r) {
|
|
376
387
|
const f = {}, g = {}, O = {};
|
|
377
388
|
let b = 0;
|
|
378
|
-
Object.entries(r).forEach(([
|
|
389
|
+
Object.entries(r).forEach(([m, _]) => {
|
|
379
390
|
if (_ instanceof Array && Y(_)) {
|
|
380
|
-
|
|
391
|
+
i = !0;
|
|
381
392
|
let y = 0;
|
|
382
393
|
_.forEach((C) => {
|
|
383
|
-
C instanceof File && (f[
|
|
384
|
-
}), O[
|
|
385
|
-
} else _ instanceof File ? (
|
|
386
|
-
C instanceof File ? (f[
|
|
387
|
-
})) : _ !== void 0 && (f[
|
|
388
|
-
}), s[e].__args = f, s.__variables = O,
|
|
394
|
+
C instanceof File && (f[m] = new S(m), g[b] = ["variables." + m + "." + y], a.append(b.toString(), C), b++);
|
|
395
|
+
}), O[m] = "[Upload!]!";
|
|
396
|
+
} else _ instanceof File ? (i = !0, f[m] = new S(m), g[b] = ["variables." + m], a.append(b.toString(), _), O[m] = "Upload!", b++) : _ instanceof Object && Z(_) ? (i = !0, f[m] = {}, Object.entries(_).forEach(([y, C]) => {
|
|
397
|
+
C instanceof File ? (f[m][y] = new S(y), g[b] = ["variables." + y], a.append(b.toString(), C), O[y] = "Upload!", b++) : f[m][y] = C;
|
|
398
|
+
})) : _ !== void 0 && (f[m] = _);
|
|
399
|
+
}), s[e].__args = f, s.__variables = O, i && a.append("map", JSON.stringify(g));
|
|
389
400
|
}
|
|
390
401
|
Object.entries(A(n)).forEach(([f, g]) => {
|
|
391
402
|
s[e][f] = g;
|
|
392
403
|
}), Object.entries(s[e]).length === 0 && (s[e] = !0);
|
|
393
|
-
let
|
|
394
|
-
const p =
|
|
395
|
-
if (
|
|
404
|
+
let o = null;
|
|
405
|
+
const p = R({ mutation: s });
|
|
406
|
+
if (i ? (a.append("operations", JSON.stringify({
|
|
396
407
|
query: p
|
|
397
|
-
})),
|
|
408
|
+
})), o = await t.post("", a)) : o = await t.post("", {
|
|
398
409
|
query: p
|
|
399
|
-
}),
|
|
400
|
-
throw new Error(
|
|
401
|
-
return
|
|
410
|
+
}), o.data.errors)
|
|
411
|
+
throw new Error(o.data.errors[0].message);
|
|
412
|
+
return o.data.data[e];
|
|
402
413
|
}, x = (t) => ({
|
|
403
|
-
uploadTempFile: (e) =>
|
|
414
|
+
uploadTempFile: (e) => l(t, "fsUploadTempFile", {
|
|
404
415
|
file: e
|
|
405
416
|
}, {
|
|
406
417
|
name: !0,
|
|
@@ -418,9 +429,9 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
418
429
|
path: !0
|
|
419
430
|
}
|
|
420
431
|
})).fsListFolders,
|
|
421
|
-
create: (e) =>
|
|
422
|
-
delete: (e) =>
|
|
423
|
-
rename: (e, r) =>
|
|
432
|
+
create: (e) => l(t, "fsCreateFolder", { path: e }),
|
|
433
|
+
delete: (e) => l(t, "fsDeleteFolder", { path: e }),
|
|
434
|
+
rename: (e, r) => l(t, "fsRenameFolder", { path: e, name: r })
|
|
424
435
|
},
|
|
425
436
|
files: {
|
|
426
437
|
list: async (e) => (await h(t, {
|
|
@@ -447,13 +458,13 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
447
458
|
});
|
|
448
459
|
return window.atob(r.fsFile.base64Content);
|
|
449
460
|
},
|
|
450
|
-
write: (e, r) =>
|
|
461
|
+
write: (e, r) => l(t, "fsWriteFile", {
|
|
451
462
|
path: e,
|
|
452
463
|
content: r
|
|
453
464
|
}),
|
|
454
|
-
delete: (e) =>
|
|
455
|
-
rename: (e, r) =>
|
|
456
|
-
move: (e, r) =>
|
|
465
|
+
delete: (e) => l(t, "fsDeleteFile", { path: e }),
|
|
466
|
+
rename: (e, r) => l(t, "fsRenameFile", { path: e, name: r }),
|
|
467
|
+
move: (e, r) => l(t, "fsMoveFile", { source: e, target: r })
|
|
457
468
|
}
|
|
458
469
|
}), k = (t) => ({
|
|
459
470
|
get: async (e) => (await t({
|
|
@@ -464,7 +475,7 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
464
475
|
}
|
|
465
476
|
})).config
|
|
466
477
|
}), ee = (t) => ({
|
|
467
|
-
send: (e, r, n) =>
|
|
478
|
+
send: (e, r, n) => l(t, "sendMail", {
|
|
468
479
|
email: e,
|
|
469
480
|
subject: r,
|
|
470
481
|
message: n
|
|
@@ -496,12 +507,12 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
496
507
|
getRaw() {
|
|
497
508
|
return a;
|
|
498
509
|
},
|
|
499
|
-
getValue(
|
|
500
|
-
return a.field && typeof a.field == "function" ? a.field(
|
|
510
|
+
getValue(i) {
|
|
511
|
+
return a.field && typeof a.field == "function" ? a.field(i) : a.field && typeof a.field == "string" ? i[a.field] : i[this.getName()];
|
|
501
512
|
},
|
|
502
|
-
getFormattedValue(
|
|
503
|
-
const
|
|
504
|
-
return a.format ? a.format(
|
|
513
|
+
getFormattedValue(i) {
|
|
514
|
+
const o = this.getValue(i);
|
|
515
|
+
return a.format ? a.format(o) : o;
|
|
505
516
|
}
|
|
506
517
|
});
|
|
507
518
|
}
|
|
@@ -517,11 +528,11 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
517
528
|
name: !0
|
|
518
529
|
}
|
|
519
530
|
})).listRole
|
|
520
|
-
}),
|
|
531
|
+
}), ie = (t) => {
|
|
521
532
|
const e = U.create({
|
|
522
533
|
baseURL: t,
|
|
523
534
|
withCredentials: !0
|
|
524
|
-
}), r = (a,
|
|
535
|
+
}), r = (a, i = null, o = []) => l(e, a, i, o), n = (a) => h(e, a), s = re();
|
|
525
536
|
return {
|
|
526
537
|
baseURL: t,
|
|
527
538
|
axios: e,
|
|
@@ -540,10 +551,10 @@ const c = async (t, e, r = null, n = []) => {
|
|
|
540
551
|
};
|
|
541
552
|
};
|
|
542
553
|
export {
|
|
543
|
-
|
|
544
|
-
|
|
554
|
+
oe as File,
|
|
555
|
+
ie as createClient,
|
|
545
556
|
v as file,
|
|
546
|
-
|
|
557
|
+
l as mutation,
|
|
547
558
|
h as query,
|
|
548
559
|
A as toQuery
|
|
549
560
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(w,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],y):(w=typeof globalThis<"u"?globalThis:w||self,y(w.light={},w.jsonToGraphqlQuery,w.axios))})(this,function(w,y,T){"use strict";function R(t){const e="==".slice(0,(4-t.length%4)%4),r=t.replace(/-/g,"+").replace(/_/g,"/")+e,n=atob(r),s=new ArrayBuffer(n.length),a=new Uint8Array(s);for(let u=0;u<n.length;u++)a[u]=n.charCodeAt(u);return s}function L(t){const e=new Uint8Array(t);let r="";for(const a of e)r+=String.fromCharCode(a);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var o="copy",h="convert";function O(t,e,r){if(e===o)return r;if(e===h)return t(r);if(e instanceof Array)return r.map(n=>O(t,e[0],n));if(e instanceof Object){const n={};for(const[s,a]of Object.entries(e)){if(a.derive){const u=a.derive(r);u!==void 0&&(r[s]=u)}if(!(s in r)){if(a.required)throw new Error(`Missing key: ${s}`);continue}if(r[s]==null){n[s]=null;continue}n[s]=O(t,a.schema,r[s])}return n}}function E(t,e){return{required:!0,schema:t,derive:e}}function c(t){return{required:!0,schema:t}}function d(t){return{required:!1,schema:t}}var N={type:c(o),id:c(h),transports:d(o)},P={appid:d(o),appidExclude:d(o),credProps:d(o)},J={appid:d(o),appidExclude:d(o),credProps:d(o)},V={publicKey:c({rp:c(o),user:c({id:c(h),name:c(o),displayName:c(o)}),challenge:c(h),pubKeyCredParams:c(o),timeout:d(o),excludeCredentials:d([N]),authenticatorSelection:d(o),attestation:d(o),extensions:d(P)}),signal:d(o)},U={type:c(o),id:c(o),rawId:c(h),authenticatorAttachment:d(o),response:c({clientDataJSON:c(h),attestationObject:c(h),transports:E(o,t=>{var e;return((e=t.getTransports)==null?void 0:e.call(t))||[]})}),clientExtensionResults:E(J,t=>t.getClientExtensionResults())},K={mediation:d(o),publicKey:c({challenge:c(h),timeout:d(o),rpId:d(o),allowCredentials:d([N]),userVerification:d(o),extensions:d(P)}),signal:d(o)},D={type:c(o),id:c(o),rawId:c(h),authenticatorAttachment:d(o),response:c({clientDataJSON:c(h),authenticatorData:c(h),signature:c(h),userHandle:c(h)}),clientExtensionResults:E(J,t=>t.getClientExtensionResults())};function B(t){return O(R,V,t)}function Q(t){return O(L,U,t)}function W(t){return O(R,K,t)}function M(t){return O(L,D,t)}async function $(t){const e=await navigator.credentials.create(t);return e.toJSON=()=>Q(e),e}async function z(t){const e=await navigator.credentials.get(t);return e.toJSON=()=>M(e),e}const H=t=>({login:async e=>{const n=(await m(t,{webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,s=W({publicKey:n}),a=await z(s);await l(t,"webAuthnAssertion",{username:e,assertion:a.toJSON()})},register:async()=>{const e=await m(t,{webAuthnCreationOptions:!0}),r=B({publicKey:e.webAuthnCreationOptions}),n=await $(r);await l(t,"webAuthnRegister",{registration:n.toJSON()})}}),I=t=>({WebAuthn:H(t),facebookLogin:e=>l(t,"facebookLogin",{access_token:e}),microsoftLogin:e=>l(t,"microsoftLogin",{access_token:e}),googleLogin:e=>l(t,"googleLogin",{credential:e}),login:(e,r,n="")=>l(t,"login",{username:e,password:r,code:n}),logout:()=>l(t,"logout"),changeExpiredPassword:(e,r,n)=>l(t,"changeExpiredPassword",{username:e,old_password:r,new_password:n}),updatePassword:(e,r)=>l(t,"updatePassword",{old_password:e,new_password:r}),resetPassword:(e,r,n)=>l(t,"resetPassword",{username:e,password:r,code:n}),forgetPassword:(e,r)=>l(t,"forgetPassword",{username:e,email:r}),verifyCode(e,r){return l(t,"forgetPasswordVerifyCode",{username:e,code:r})},granted:async e=>(await m(t,{granted:{__args:{rights:e}}})).granted}),G=(t,e,r)=>{const n=e,s=t,a=r,u=i=>a[i]?a[i]():null;return{field:u,$fields:a,gqlFields(i){const p=[];for(const f of i)if(typeof f=="string"){const g=u(f);g&&p.push(g.getGQLField())}else typeof f=="object"&&p.push(f);return p},async update(i,p){return await l(s,"update"+n,{id:i,data:p})},async delete(i){return await l(s,"delete"+n,{id:i})},async add(i){return await l(s,"add"+n,{data:i})},fields(i){let p=[];for(let f of i){const g=u(f);g&&p.push(g)}return p},async get(i,p){return(await m(s,{["list"+n]:{__args:{filters:i},data:{__args:{limit:1},...S(p)}}}))["list"+n].data[0]},async list(i,p){return(await m(s,{["list"+n]:{__args:{filters:i},data:{...S(p)}}}))["list"+n].data}}};function X(t){t="<~"+t+"~>";var e,r,n,s,a,u=String,i=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,n=[],s=0,a=t.length;a>s;s+=5)r=52200625*(t.charCodeAt(s)-33)+614125*(t.charCodeAt(s+1)-33)+7225*(t.charCodeAt(s+2)-33)+85*(t.charCodeAt(s+3)-33)+(t.charCodeAt(s+4)-33),n.push(i&r>>24,i&r>>16,i&r>>8,i&r);return function(p,f){for(var g=f;g>0;g--)p.pop()}(n,e.length),u.fromCharCode.apply(u,n)}const q=(t="")=>{const e=t,r=(n="application/octet-stream")=>{const s=new Uint8Array(e.length);for(let i=0;i<e.length;i++)s[i]=e.charCodeAt(i);const a=new Blob([s],{type:n});return URL.createObjectURL(a)};return{getContent:()=>e,getURL:r,download:n=>{const s=document.createElement("a");s.download=n,s.href=r(),document.body.appendChild(s),s.click(),document.body.removeChild(s)},open:n=>{window.open(r(n),"_blank")}}},Y={fromBase85:t=>q(X(t)),fromBase64:t=>q(atob(t)),fromString:t=>q(t)},j=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(j(r)).forEach(([n,s])=>{e[n]=s})}),e):(Object.entries(t).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=n;return}if(typeof n=="boolean"){e[r]=n;return}e[r]=j(n)}),e)},S=t=>j(t),m=async(t,e)=>{let r=y.jsonToGraphQLQuery(S(e));const n=await t.post("",{query:`{ ${r} }`});if(n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function Z(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function x(t){for(let e in t)if(t[e]instanceof File)return!0;return!1}const l=async(t,e,r=null,n=[])=>{let s={[e]:{}};const a=new FormData;let u=!1;if(r){const f={},g={},v={};let C=0;Object.entries(r).forEach(([b,_])=>{if(_ instanceof Array&&Z(_)){u=!0;let F=0;_.forEach(A=>{A instanceof File&&(f[b]=new y.VariableType(b),g[C]=["variables."+b+"."+F],a.append(C.toString(),A),C++)}),v[b]="[Upload!]!"}else _ instanceof File?(u=!0,f[b]=new y.VariableType(b),g[C]=["variables."+b],a.append(C.toString(),_),v[b]="Upload!",C++):_ instanceof Object&&x(_)?(u=!0,f[b]={},Object.entries(_).forEach(([F,A])=>{A instanceof File?(f[b][F]=new y.VariableType(F),g[C]=["variables."+F],a.append(C.toString(),A),v[F]="Upload!",C++):f[b][F]=A})):_!==void 0&&(f[b]=_)}),s[e].__args=f,s.__variables=v,u&&a.append("map",JSON.stringify(g))}Object.entries(S(n)).forEach(([f,g])=>{s[e][f]=g}),Object.entries(s[e]).length===0&&(s[e]=!0);let i=null;const p=y.jsonToGraphQLQuery({mutation:s});if(u?(a.append("operations",JSON.stringify({query:p})),i=await t.post("",a)):i=await t.post("",{query:p}),i.data.errors)throw new Error(i.data.errors[0].message);return i.data.data[e]},k=t=>({uploadTempFile:e=>l(t,"fsUploadTempFile",{file:e},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async e=>(await m(t,{fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,create:e=>l(t,"fsCreateFolder",{path:e}),delete:e=>l(t,"fsDeleteFolder",{path:e}),rename:(e,r)=>l(t,"fsRenameFolder",{path:e,name:r})},files:{list:async e=>(await m(t,{fsListFiles:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,read:async e=>{let r=await m(t,{fsFile:{__args:{path:e},base64Content:!0}});return window.atob(r.fsFile.base64Content)},write:(e,r)=>l(t,"fsWriteFile",{path:e,content:r}),delete:e=>l(t,"fsDeleteFile",{path:e}),rename:(e,r)=>l(t,"fsRenameFile",{path:e,name:r}),move:(e,r)=>l(t,"fsMoveFile",{source:e,target:r})}}),ee=t=>({get:async e=>(await t({config:{__args:{name:e}}})).config}),te=t=>({send:(e,r,n)=>l(t,"sendMail",{email:e,subject:r,message:n})}),re=t=>({list:async()=>(await m(t,{listUser:{data:{user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0}}})).listUser.data}),ne=()=>{const t={};return{create(e,r){t[e]={};for(const n of Object.entries(r)){const[s,a]=n;t[e][s]=()=>({name:a.name?a.name:s,raw:a,getName:()=>a.name?a.name:s,getGQLField:()=>a.gqlField!==void 0?a.gqlField:a.name||s,getRaw(){return a},getValue(u){return a.field&&typeof a.field=="function"?a.field(u):a.field&&typeof a.field=="string"?u[a.field]:u[this.getName()]},getFormattedValue(u){const i=this.getValue(u);return a.format?a.format(i):i}})}return t[e]},get(e){return t[e]}}},se=t=>({list:async()=>(await m(t,{listRole:{name:!0}})).listRole}),ae=t=>{const e=T.create({baseURL:t,withCredentials:!0}),r=(a,u=null,i=[])=>l(e,a,u,i),n=a=>m(e,a),s=ne();return{baseURL:t,axios:e,auth:I(e),mutation:r,query:n,config:ee(n),mail:te(e),users:re(e),fs:k(e),models:s,model(a){return G(e,a,s.get(a))},roles:se(e)}};w.File=Y,w.createClient=ae,w.file=q,w.mutation=l,w.query=m,w.toQuery=S,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hostlink/light",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dev": "vite --host",
|
|
19
19
|
"build": "tsc && vite build",
|
|
20
20
|
"preview": "vite preview",
|
|
21
|
-
"release": "npm run build && npm
|
|
21
|
+
"release": "npm run build && npm publish --access public && git push --follow-tags",
|
|
22
22
|
"test": "vitest"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|