@hostlink/light 0.0.21 → 0.0.23

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