@hostlink/light 0.0.19 → 0.0.21
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/apiUrl.d.ts +2 -0
- package/dist/auth.d.ts +11 -0
- package/dist/fs.d.ts +21 -0
- package/dist/fs.test.d.ts +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/light.js +268 -196
- package/dist/light.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/getApiUrl.d.ts +0 -2
- package/dist/login.d.ts +0 -2
- package/dist/logout.d.ts +0 -2
package/dist/apiUrl.d.ts
ADDED
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const login: (username: string, password: string, code?: string) => Promise<boolean>;
|
|
2
|
+
export declare const logout: () => Promise<boolean>;
|
|
3
|
+
/**
|
|
4
|
+
* Updates the user's password.
|
|
5
|
+
* @param oldPassword The user's current password.
|
|
6
|
+
* @param newPassword The user's new password.
|
|
7
|
+
* @returns A Promise that resolves to a boolean indicating whether the password was successfully updated.
|
|
8
|
+
*/
|
|
9
|
+
export declare const updatePassword: (oldPassword: string, newPassword: string) => Promise<boolean>;
|
|
10
|
+
export declare const resetPassword: (email: string, password: string, code: string) => Promise<boolean>;
|
|
11
|
+
export declare const forgetPassword: (email: string) => Promise<boolean>;
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type File = {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
size: number;
|
|
5
|
+
mime: string;
|
|
6
|
+
canPreview: boolean;
|
|
7
|
+
imagePath: string;
|
|
8
|
+
};
|
|
9
|
+
export type Folder = {
|
|
10
|
+
name: String;
|
|
11
|
+
path: String;
|
|
12
|
+
};
|
|
13
|
+
export declare const fsListFiles: (path: string) => Promise<Array<File>>;
|
|
14
|
+
export declare const fsListFolders: (path: string) => Promise<Array<Folder>>;
|
|
15
|
+
export declare const fsReadFile: (path: string) => Promise<string>;
|
|
16
|
+
export declare const fsWriteFile: (path: string, content: string) => Promise<boolean>;
|
|
17
|
+
export declare const fsDeleteFile: (path: string) => Promise<boolean>;
|
|
18
|
+
export declare const fsCreateFolder: (path: string) => Promise<boolean>;
|
|
19
|
+
export declare const fsDeleteFolder: (path: string) => Promise<boolean>;
|
|
20
|
+
export declare const fsRenameFile: (path: string, name: string) => Promise<boolean>;
|
|
21
|
+
export declare const fsRenameFolder: (path: string, name: string) => Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import logout from './logout';
|
|
1
|
+
export * from './auth';
|
|
3
2
|
import query from './query';
|
|
4
3
|
import mutation from './mutation';
|
|
5
4
|
import toQuery from './toQuery';
|
|
6
|
-
|
|
7
|
-
import setApiUrl from './setApiUrl';
|
|
5
|
+
export * from './apiUrl';
|
|
8
6
|
import uploadFile from './uploadFile';
|
|
9
7
|
import sendMail from './sendMail';
|
|
10
8
|
import getConfig from './getConfig';
|
|
11
9
|
import webauthnLogin from './webauthnLogin';
|
|
12
10
|
import webauthnRegister from './webauthnRegister';
|
|
13
11
|
export type Fields = Object | Array<string | Object> | string;
|
|
14
|
-
export
|
|
12
|
+
export * from './fs';
|
|
13
|
+
export { toQuery, query, mutation, uploadFile, sendMail, webauthnLogin, webauthnRegister, getConfig, };
|
package/dist/light.js
CHANGED
|
@@ -1,295 +1,367 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})), d), m = () => typeof localStorage > "u" ? "http://127.0.0.1:8888/api/" : localStorage.getItem("light-api-url") === null ? "/api/" : localStorage.getItem("light-api-url"), f = async (t, e = null, r = []) => {
|
|
7
|
-
const n = {
|
|
8
|
-
mutation: {}
|
|
9
|
-
};
|
|
10
|
-
n.mutation[t] = !0, r instanceof Array && r.length != 0 && (n.mutation[t] = {}), e && (n.mutation[t] = {}, n.mutation[t].__args = e), Object.entries(O(r)).forEach(([u, l]) => {
|
|
11
|
-
n.mutation[t][u] = l;
|
|
12
|
-
});
|
|
13
|
-
const o = await _().post(m(), {
|
|
14
|
-
query: h(n)
|
|
15
|
-
});
|
|
16
|
-
if (o.data.errors)
|
|
17
|
-
throw new Error(o.data.errors[0].message);
|
|
18
|
-
return o.data.data[t];
|
|
19
|
-
}, B = async (t, e, r = "") => await f("login", {
|
|
20
|
-
username: t,
|
|
21
|
-
password: e,
|
|
1
|
+
import { jsonToGraphQLQuery as b, VariableType as R } from "json-to-graphql-query";
|
|
2
|
+
import E from "axios";
|
|
3
|
+
const V = (e, t, r = "") => u("login", {
|
|
4
|
+
username: e,
|
|
5
|
+
password: t,
|
|
22
6
|
code: r
|
|
23
|
-
}),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
}), W = () => u("logout"), I = (e, t) => u("updatePassword", {
|
|
8
|
+
old_password: e,
|
|
9
|
+
new_password: t
|
|
10
|
+
}), M = (e, t, r) => u("resetPassword", {
|
|
11
|
+
email: e,
|
|
12
|
+
password: t,
|
|
13
|
+
code: r
|
|
14
|
+
}), Q = (e) => u("forgetPassword", {
|
|
15
|
+
email: e
|
|
16
|
+
}), w = (e) => {
|
|
17
|
+
let t = {};
|
|
18
|
+
return typeof e == "string" ? (t[e] = !0, t) : e instanceof Array ? (e.forEach((r) => {
|
|
19
|
+
Object.entries(w(r)).forEach(([n, i]) => {
|
|
20
|
+
t[n] = i;
|
|
28
21
|
});
|
|
29
|
-
}),
|
|
22
|
+
}), t) : (Object.entries(e).forEach(([r, n]) => {
|
|
30
23
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
31
|
-
|
|
24
|
+
t[r] = n;
|
|
32
25
|
return;
|
|
33
26
|
}
|
|
34
27
|
if (typeof n == "boolean") {
|
|
35
|
-
|
|
28
|
+
t[r] = n;
|
|
36
29
|
return;
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
t[r] = w(n);
|
|
32
|
+
}), t);
|
|
33
|
+
}, _ = (e) => w(e);
|
|
34
|
+
let g;
|
|
35
|
+
const h = () => (g || (g = E.create({
|
|
36
|
+
withCredentials: !0
|
|
37
|
+
})), g), p = async (e) => {
|
|
38
|
+
let t = b(_(e));
|
|
39
|
+
const r = await h().post(y(), {
|
|
40
|
+
query: `{ ${t} }`
|
|
44
41
|
});
|
|
45
42
|
if (r.data.errors)
|
|
46
43
|
throw new Error(r.data.errors[0].message);
|
|
47
44
|
return r.data.data;
|
|
48
|
-
},
|
|
49
|
-
|
|
45
|
+
}, u = async (e, t = null, r = []) => {
|
|
46
|
+
const n = {
|
|
47
|
+
mutation: {}
|
|
48
|
+
};
|
|
49
|
+
n.mutation[e] = !0, r instanceof Array && r.length != 0 && (n.mutation[e] = {}), t && (n.mutation[e] = {}, n.mutation[e].__args = t), Object.entries(_(r)).forEach(([l, f]) => {
|
|
50
|
+
n.mutation[e][l] = f;
|
|
51
|
+
});
|
|
52
|
+
const i = await h().post(y(), {
|
|
53
|
+
query: b(n)
|
|
54
|
+
});
|
|
55
|
+
if (i.data.errors)
|
|
56
|
+
throw new Error(i.data.errors[0].message);
|
|
57
|
+
return i.data.data[e];
|
|
50
58
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
let F = "/api/";
|
|
60
|
+
const z = (e) => {
|
|
61
|
+
F = e;
|
|
62
|
+
}, y = () => F;
|
|
63
|
+
async function $(e) {
|
|
64
|
+
const t = {
|
|
55
65
|
__variables: {
|
|
56
66
|
file: "Upload!"
|
|
57
67
|
},
|
|
58
68
|
fsUploadTempFile: {
|
|
59
69
|
__args: {
|
|
60
|
-
file: new
|
|
70
|
+
file: new R("file")
|
|
61
71
|
},
|
|
62
72
|
name: !0,
|
|
63
73
|
path: !0,
|
|
64
74
|
size: !0,
|
|
65
75
|
mime: !0
|
|
66
76
|
}
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
query:
|
|
70
|
-
})),
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
throw new Error(
|
|
74
|
-
return
|
|
77
|
+
}, r = new FormData();
|
|
78
|
+
r.append("operations", JSON.stringify({
|
|
79
|
+
query: b({ mutation: t })
|
|
80
|
+
})), r.append("map", JSON.stringify({ 0: ["variables.file"] })), r.append("0", e);
|
|
81
|
+
const n = await h().post(y(), r);
|
|
82
|
+
if (n.data.errors)
|
|
83
|
+
throw new Error(n.data.errors[0].message);
|
|
84
|
+
return n.data.data.fsUploadTempFile;
|
|
75
85
|
}
|
|
76
|
-
const
|
|
86
|
+
const G = (e, t, r) => u("sendMail", {
|
|
87
|
+
email: e,
|
|
88
|
+
subject: t,
|
|
89
|
+
message: r
|
|
90
|
+
}), H = async (e) => (await p({
|
|
77
91
|
config: {
|
|
78
92
|
__args: {
|
|
79
|
-
name:
|
|
93
|
+
name: e
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
})).config;
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
for (let
|
|
86
|
-
|
|
87
|
-
return
|
|
97
|
+
function O(e) {
|
|
98
|
+
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, n = atob(r), i = new ArrayBuffer(n.length), l = new Uint8Array(i);
|
|
99
|
+
for (let f = 0; f < n.length; f++)
|
|
100
|
+
l[f] = n.charCodeAt(f);
|
|
101
|
+
return i;
|
|
88
102
|
}
|
|
89
|
-
function
|
|
90
|
-
const
|
|
103
|
+
function S(e) {
|
|
104
|
+
const t = new Uint8Array(e);
|
|
91
105
|
let r = "";
|
|
92
|
-
for (const
|
|
93
|
-
r += String.fromCharCode(
|
|
106
|
+
for (const l of t)
|
|
107
|
+
r += String.fromCharCode(l);
|
|
94
108
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
95
109
|
/\//g,
|
|
96
110
|
"_"
|
|
97
111
|
).replace(/=/g, "");
|
|
98
112
|
}
|
|
99
|
-
var
|
|
100
|
-
function
|
|
101
|
-
if (
|
|
113
|
+
var s = "copy", c = "convert";
|
|
114
|
+
function d(e, t, r) {
|
|
115
|
+
if (t === s)
|
|
102
116
|
return r;
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
105
|
-
if (
|
|
106
|
-
return r.map((n) =>
|
|
107
|
-
if (
|
|
117
|
+
if (t === c)
|
|
118
|
+
return e(r);
|
|
119
|
+
if (t instanceof Array)
|
|
120
|
+
return r.map((n) => d(e, t[0], n));
|
|
121
|
+
if (t instanceof Object) {
|
|
108
122
|
const n = {};
|
|
109
|
-
for (const [
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
|
|
123
|
+
for (const [i, l] of Object.entries(t)) {
|
|
124
|
+
if (l.derive) {
|
|
125
|
+
const f = l.derive(r);
|
|
126
|
+
f !== void 0 && (r[i] = f);
|
|
113
127
|
}
|
|
114
|
-
if (!(
|
|
115
|
-
if (
|
|
116
|
-
throw new Error(`Missing key: ${
|
|
128
|
+
if (!(i in r)) {
|
|
129
|
+
if (l.required)
|
|
130
|
+
throw new Error(`Missing key: ${i}`);
|
|
117
131
|
continue;
|
|
118
132
|
}
|
|
119
|
-
if (r[
|
|
120
|
-
n[
|
|
133
|
+
if (r[i] == null) {
|
|
134
|
+
n[i] = null;
|
|
121
135
|
continue;
|
|
122
136
|
}
|
|
123
|
-
n[
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
r[
|
|
137
|
+
n[i] = d(
|
|
138
|
+
e,
|
|
139
|
+
l.schema,
|
|
140
|
+
r[i]
|
|
127
141
|
);
|
|
128
142
|
}
|
|
129
143
|
return n;
|
|
130
144
|
}
|
|
131
145
|
}
|
|
132
|
-
function
|
|
146
|
+
function m(e, t) {
|
|
133
147
|
return {
|
|
134
148
|
required: !0,
|
|
135
|
-
schema:
|
|
136
|
-
derive:
|
|
149
|
+
schema: e,
|
|
150
|
+
derive: t
|
|
137
151
|
};
|
|
138
152
|
}
|
|
139
|
-
function
|
|
153
|
+
function a(e) {
|
|
140
154
|
return {
|
|
141
155
|
required: !0,
|
|
142
|
-
schema:
|
|
156
|
+
schema: e
|
|
143
157
|
};
|
|
144
158
|
}
|
|
145
|
-
function
|
|
159
|
+
function o(e) {
|
|
146
160
|
return {
|
|
147
161
|
required: !1,
|
|
148
|
-
schema:
|
|
162
|
+
schema: e
|
|
149
163
|
};
|
|
150
164
|
}
|
|
151
|
-
var
|
|
152
|
-
type:
|
|
153
|
-
id:
|
|
154
|
-
transports: s
|
|
165
|
+
var A = {
|
|
166
|
+
type: a(s),
|
|
167
|
+
id: a(c),
|
|
168
|
+
transports: o(s)
|
|
169
|
+
}, v = {
|
|
170
|
+
appid: o(s),
|
|
171
|
+
appidExclude: o(s),
|
|
172
|
+
credProps: o(s)
|
|
155
173
|
}, C = {
|
|
156
|
-
appid: s
|
|
157
|
-
appidExclude: s
|
|
158
|
-
credProps: s
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
user: i({
|
|
167
|
-
id: i(c),
|
|
168
|
-
name: i(a),
|
|
169
|
-
displayName: i(a)
|
|
174
|
+
appid: o(s),
|
|
175
|
+
appidExclude: o(s),
|
|
176
|
+
credProps: o(s)
|
|
177
|
+
}, x = {
|
|
178
|
+
publicKey: a({
|
|
179
|
+
rp: a(s),
|
|
180
|
+
user: a({
|
|
181
|
+
id: a(c),
|
|
182
|
+
name: a(s),
|
|
183
|
+
displayName: a(s)
|
|
170
184
|
}),
|
|
171
|
-
challenge:
|
|
172
|
-
pubKeyCredParams:
|
|
173
|
-
timeout: s
|
|
174
|
-
excludeCredentials:
|
|
175
|
-
authenticatorSelection: s
|
|
176
|
-
attestation: s
|
|
177
|
-
extensions:
|
|
185
|
+
challenge: a(c),
|
|
186
|
+
pubKeyCredParams: a(s),
|
|
187
|
+
timeout: o(s),
|
|
188
|
+
excludeCredentials: o([A]),
|
|
189
|
+
authenticatorSelection: o(s),
|
|
190
|
+
attestation: o(s),
|
|
191
|
+
extensions: o(v)
|
|
178
192
|
}),
|
|
179
|
-
signal: s
|
|
193
|
+
signal: o(s)
|
|
180
194
|
}, q = {
|
|
181
|
-
type:
|
|
182
|
-
id:
|
|
183
|
-
rawId:
|
|
184
|
-
authenticatorAttachment: s
|
|
185
|
-
response:
|
|
186
|
-
clientDataJSON:
|
|
187
|
-
attestationObject:
|
|
188
|
-
transports:
|
|
189
|
-
|
|
190
|
-
(
|
|
191
|
-
var
|
|
192
|
-
return ((
|
|
195
|
+
type: a(s),
|
|
196
|
+
id: a(s),
|
|
197
|
+
rawId: a(c),
|
|
198
|
+
authenticatorAttachment: o(s),
|
|
199
|
+
response: a({
|
|
200
|
+
clientDataJSON: a(c),
|
|
201
|
+
attestationObject: a(c),
|
|
202
|
+
transports: m(
|
|
203
|
+
s,
|
|
204
|
+
(e) => {
|
|
205
|
+
var t;
|
|
206
|
+
return ((t = e.getTransports) == null ? void 0 : t.call(e)) || [];
|
|
193
207
|
}
|
|
194
208
|
)
|
|
195
209
|
}),
|
|
196
|
-
clientExtensionResults:
|
|
197
|
-
|
|
198
|
-
(
|
|
210
|
+
clientExtensionResults: m(
|
|
211
|
+
C,
|
|
212
|
+
(e) => e.getClientExtensionResults()
|
|
199
213
|
)
|
|
200
214
|
}, J = {
|
|
201
|
-
mediation: s
|
|
202
|
-
publicKey:
|
|
203
|
-
challenge:
|
|
204
|
-
timeout: s
|
|
205
|
-
rpId: s
|
|
206
|
-
allowCredentials:
|
|
207
|
-
userVerification: s
|
|
208
|
-
extensions:
|
|
215
|
+
mediation: o(s),
|
|
216
|
+
publicKey: a({
|
|
217
|
+
challenge: a(c),
|
|
218
|
+
timeout: o(s),
|
|
219
|
+
rpId: o(s),
|
|
220
|
+
allowCredentials: o([A]),
|
|
221
|
+
userVerification: o(s),
|
|
222
|
+
extensions: o(v)
|
|
209
223
|
}),
|
|
210
|
-
signal: s
|
|
224
|
+
signal: o(s)
|
|
211
225
|
}, N = {
|
|
212
|
-
type:
|
|
213
|
-
id:
|
|
214
|
-
rawId:
|
|
215
|
-
authenticatorAttachment: s
|
|
216
|
-
response:
|
|
217
|
-
clientDataJSON:
|
|
218
|
-
authenticatorData:
|
|
219
|
-
signature:
|
|
220
|
-
userHandle:
|
|
226
|
+
type: a(s),
|
|
227
|
+
id: a(s),
|
|
228
|
+
rawId: a(c),
|
|
229
|
+
authenticatorAttachment: o(s),
|
|
230
|
+
response: a({
|
|
231
|
+
clientDataJSON: a(c),
|
|
232
|
+
authenticatorData: a(c),
|
|
233
|
+
signature: a(c),
|
|
234
|
+
userHandle: a(c)
|
|
221
235
|
}),
|
|
222
|
-
clientExtensionResults:
|
|
223
|
-
|
|
224
|
-
(
|
|
236
|
+
clientExtensionResults: m(
|
|
237
|
+
C,
|
|
238
|
+
(e) => e.getClientExtensionResults()
|
|
225
239
|
)
|
|
226
240
|
};
|
|
227
|
-
function
|
|
228
|
-
return
|
|
241
|
+
function P(e) {
|
|
242
|
+
return d(O, x, e);
|
|
229
243
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
232
|
-
|
|
244
|
+
function j(e) {
|
|
245
|
+
return d(
|
|
246
|
+
S,
|
|
233
247
|
q,
|
|
234
|
-
|
|
248
|
+
e
|
|
235
249
|
);
|
|
236
250
|
}
|
|
237
|
-
function
|
|
238
|
-
return
|
|
251
|
+
function D(e) {
|
|
252
|
+
return d(O, J, e);
|
|
239
253
|
}
|
|
240
|
-
function
|
|
241
|
-
return
|
|
242
|
-
|
|
254
|
+
function T(e) {
|
|
255
|
+
return d(
|
|
256
|
+
S,
|
|
243
257
|
N,
|
|
244
|
-
|
|
258
|
+
e
|
|
245
259
|
);
|
|
246
260
|
}
|
|
247
|
-
async function
|
|
248
|
-
const
|
|
249
|
-
|
|
261
|
+
async function K(e) {
|
|
262
|
+
const t = await navigator.credentials.create(
|
|
263
|
+
e
|
|
250
264
|
);
|
|
251
|
-
return
|
|
265
|
+
return t.toJSON = () => j(t), t;
|
|
252
266
|
}
|
|
253
|
-
async function
|
|
254
|
-
const
|
|
255
|
-
|
|
267
|
+
async function L(e) {
|
|
268
|
+
const t = await navigator.credentials.get(
|
|
269
|
+
e
|
|
256
270
|
);
|
|
257
|
-
return
|
|
271
|
+
return t.toJSON = () => T(t), t;
|
|
258
272
|
}
|
|
259
|
-
async function
|
|
260
|
-
const r = (await
|
|
273
|
+
async function X(e) {
|
|
274
|
+
const r = (await p({
|
|
261
275
|
webAuthnRequestOptions: {
|
|
262
276
|
__args: {
|
|
263
|
-
username:
|
|
277
|
+
username: e
|
|
264
278
|
}
|
|
265
279
|
}
|
|
266
|
-
})).webAuthnRequestOptions, n =
|
|
280
|
+
})).webAuthnRequestOptions, n = D({
|
|
267
281
|
publicKey: r
|
|
268
|
-
}),
|
|
269
|
-
await
|
|
270
|
-
username:
|
|
271
|
-
assertion:
|
|
282
|
+
}), i = await L(n);
|
|
283
|
+
await u("webAuthnAssertion", {
|
|
284
|
+
username: e,
|
|
285
|
+
assertion: i.toJSON()
|
|
272
286
|
});
|
|
273
287
|
}
|
|
274
|
-
async function
|
|
275
|
-
const
|
|
276
|
-
publicKey:
|
|
277
|
-
}), r = await
|
|
278
|
-
await
|
|
288
|
+
async function Y() {
|
|
289
|
+
const e = await p({ webAuthnCreationOptions: !0 }), t = P({
|
|
290
|
+
publicKey: e.webAuthnCreationOptions
|
|
291
|
+
}), r = await K(t);
|
|
292
|
+
await u("webAuthnRegister", {
|
|
279
293
|
registration: r.toJSON()
|
|
280
294
|
});
|
|
281
295
|
}
|
|
296
|
+
const Z = async (e) => (await p({
|
|
297
|
+
fsListFiles: {
|
|
298
|
+
__args: {
|
|
299
|
+
path: e
|
|
300
|
+
},
|
|
301
|
+
name: !0,
|
|
302
|
+
path: !0,
|
|
303
|
+
size: !0,
|
|
304
|
+
mime: !0,
|
|
305
|
+
canPreview: !0,
|
|
306
|
+
imagePath: !0
|
|
307
|
+
}
|
|
308
|
+
})).fsListFiles, k = async (e) => (await p({
|
|
309
|
+
fsListFolders: {
|
|
310
|
+
__args: {
|
|
311
|
+
path: e
|
|
312
|
+
},
|
|
313
|
+
name: !0,
|
|
314
|
+
path: !0
|
|
315
|
+
}
|
|
316
|
+
})).fsListFolders, ee = async (e) => {
|
|
317
|
+
let t = await p({
|
|
318
|
+
fsFile: {
|
|
319
|
+
__args: {
|
|
320
|
+
path: e
|
|
321
|
+
},
|
|
322
|
+
content: !0
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return Buffer.from(t.fsFile.content, "base64").toString("utf-8");
|
|
326
|
+
}, te = (e, t) => (t = Buffer.from(t).toString("base64"), u("fsWriteFileBase64", {
|
|
327
|
+
path: e,
|
|
328
|
+
content: t
|
|
329
|
+
})), re = (e) => u("fsDeleteFile", {
|
|
330
|
+
path: e
|
|
331
|
+
}), ne = (e) => u("fsCreateFolder", {
|
|
332
|
+
path: e
|
|
333
|
+
}), se = (e) => u("fsDeleteFolder", {
|
|
334
|
+
path: e
|
|
335
|
+
}), ae = (e, t) => u("fsRenameFile", {
|
|
336
|
+
path: e,
|
|
337
|
+
name: t
|
|
338
|
+
}), oe = (e, t) => u("fsRenameFolder", {
|
|
339
|
+
path: e,
|
|
340
|
+
name: t
|
|
341
|
+
});
|
|
282
342
|
export {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
343
|
+
Q as forgetPassword,
|
|
344
|
+
ne as fsCreateFolder,
|
|
345
|
+
re as fsDeleteFile,
|
|
346
|
+
se as fsDeleteFolder,
|
|
347
|
+
Z as fsListFiles,
|
|
348
|
+
k as fsListFolders,
|
|
349
|
+
ee as fsReadFile,
|
|
350
|
+
ae as fsRenameFile,
|
|
351
|
+
oe as fsRenameFolder,
|
|
352
|
+
te as fsWriteFile,
|
|
353
|
+
y as getApiUrl,
|
|
354
|
+
H as getConfig,
|
|
355
|
+
V as login,
|
|
356
|
+
W as logout,
|
|
357
|
+
u as mutation,
|
|
358
|
+
p as query,
|
|
359
|
+
M as resetPassword,
|
|
360
|
+
G as sendMail,
|
|
361
|
+
z as setApiUrl,
|
|
362
|
+
_ as toQuery,
|
|
363
|
+
I as updatePassword,
|
|
364
|
+
$ as uploadFile,
|
|
365
|
+
X as webauthnLogin,
|
|
366
|
+
Y as webauthnRegister
|
|
295
367
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(n,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],p):(n=typeof globalThis<"u"?globalThis:n||self,p(n.light={},n.jsonToGraphqlQuery,n.axios))})(this,function(n,p,q){"use strict";const E=(e,t,r="")=>l("login",{username:e,password:t,code:r}),P=()=>l("logout"),j=(e,t)=>l("updatePassword",{old_password:e,new_password:t}),J=(e,t,r)=>l("resetPassword",{email:e,password:t,code:r}),L=e=>l("forgetPassword",{email:e}),h=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(h(r)).forEach(([s,u])=>{t[s]=u})}),t):(Object.entries(e).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=s;return}if(typeof s=="boolean"){t[r]=s;return}t[r]=h(s)}),t)},b=e=>h(e);let y;const F=()=>(y||(y=q.create({withCredentials:!0})),y),g=async e=>{let t=p.jsonToGraphQLQuery(b(e));const r=await F().post(m(),{query:`{ ${t} }`});if(r.data.errors)throw new Error(r.data.errors[0].message);return r.data.data},l=async(e,t=null,r=[])=>{const s={mutation:{}};s.mutation[e]=!0,r instanceof Array&&r.length!=0&&(s.mutation[e]={}),t&&(s.mutation[e]={},s.mutation[e].__args=t),Object.entries(b(r)).forEach(([f,d])=>{s.mutation[e][f]=d});const u=await F().post(m(),{query:p.jsonToGraphQLQuery(s)});if(u.data.errors)throw new Error(u.data.errors[0].message);return u.data.data[e]};let O="/api/";const N=e=>{O=e},m=()=>O;async function D(e){const t={__variables:{file:"Upload!"},fsUploadTempFile:{__args:{file:new p.VariableType("file")},name:!0,path:!0,size:!0,mime:!0}},r=new FormData;r.append("operations",JSON.stringify({query:p.jsonToGraphQLQuery({mutation:t})})),r.append("map",JSON.stringify({0:["variables.file"]})),r.append("0",e);const s=await F().post(m(),r);if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data.fsUploadTempFile}const T=(e,t,r)=>l("sendMail",{email:e,subject:t,message:r}),U=async e=>(await g({config:{__args:{name:e}}})).config;function S(e){const t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,s=atob(r),u=new ArrayBuffer(s.length),f=new Uint8Array(u);for(let d=0;d<s.length;d++)f[d]=s.charCodeAt(d);return u}function A(e){const t=new Uint8Array(e);let r="";for(const f of t)r+=String.fromCharCode(f);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var a="copy",c="convert";function w(e,t,r){if(t===a)return r;if(t===c)return e(r);if(t instanceof Array)return r.map(s=>w(e,t[0],s));if(t instanceof Object){const s={};for(const[u,f]of Object.entries(t)){if(f.derive){const d=f.derive(r);d!==void 0&&(r[u]=d)}if(!(u in r)){if(f.required)throw new Error(`Missing key: ${u}`);continue}if(r[u]==null){s[u]=null;continue}s[u]=w(e,f.schema,r[u])}return s}}function _(e,t){return{required:!0,schema:e,derive:t}}function i(e){return{required:!0,schema:e}}function o(e){return{required:!1,schema:e}}var R={type:i(a),id:i(c),transports:o(a)},v={appid:o(a),appidExclude:o(a),credProps:o(a)},C={appid:o(a),appidExclude:o(a),credProps:o(a)},K={publicKey:i({rp:i(a),user:i({id:i(c),name:i(a),displayName:i(a)}),challenge:i(c),pubKeyCredParams:i(a),timeout:o(a),excludeCredentials:o([R]),authenticatorSelection:o(a),attestation:o(a),extensions:o(v)}),signal:o(a)},B={type:i(a),id:i(a),rawId:i(c),authenticatorAttachment:o(a),response:i({clientDataJSON:i(c),attestationObject:i(c),transports:_(a,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:_(C,e=>e.getClientExtensionResults())},Q={mediation:o(a),publicKey:i({challenge:i(c),timeout:o(a),rpId:o(a),allowCredentials:o([R]),userVerification:o(a),extensions:o(v)}),signal:o(a)},V={type:i(a),id:i(a),rawId:i(c),authenticatorAttachment:o(a),response:i({clientDataJSON:i(c),authenticatorData:i(c),signature:i(c),userHandle:i(c)}),clientExtensionResults:_(C,e=>e.getClientExtensionResults())};function M(e){return w(S,K,e)}function W(e){return w(A,B,e)}function I(e){return w(S,Q,e)}function z(e){return w(A,V,e)}async function $(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>W(t),t}async function G(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>z(t),t}async function H(e){const r=(await g({webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,s=I({publicKey:r}),u=await G(s);await l("webAuthnAssertion",{username:e,assertion:u.toJSON()})}async function X(){const e=await g({webAuthnCreationOptions:!0}),t=M({publicKey:e.webAuthnCreationOptions}),r=await $(t);await l("webAuthnRegister",{registration:r.toJSON()})}const Y=async e=>(await g({fsListFiles:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,Z=async e=>(await g({fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,x=async e=>{let t=await g({fsFile:{__args:{path:e},content:!0}});return Buffer.from(t.fsFile.content,"base64").toString("utf-8")},k=(e,t)=>(t=Buffer.from(t).toString("base64"),l("fsWriteFileBase64",{path:e,content:t})),ee=e=>l("fsDeleteFile",{path:e}),te=e=>l("fsCreateFolder",{path:e}),re=e=>l("fsDeleteFolder",{path:e}),ne=(e,t)=>l("fsRenameFile",{path:e,name:t}),se=(e,t)=>l("fsRenameFolder",{path:e,name:t});n.forgetPassword=L,n.fsCreateFolder=te,n.fsDeleteFile=ee,n.fsDeleteFolder=re,n.fsListFiles=Y,n.fsListFolders=Z,n.fsReadFile=x,n.fsRenameFile=ne,n.fsRenameFolder=se,n.fsWriteFile=k,n.getApiUrl=m,n.getConfig=U,n.login=E,n.logout=P,n.mutation=l,n.query=g,n.resetPassword=J,n.sendMail=T,n.setApiUrl=N,n.toQuery=b,n.updatePassword=j,n.uploadFile=D,n.webauthnLogin=H,n.webauthnRegister=X,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/dist/getApiUrl.d.ts
DELETED
package/dist/login.d.ts
DELETED
package/dist/logout.d.ts
DELETED