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