@hostlink/light 0.0.21 → 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/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>;
package/dist/light.js CHANGED
@@ -1,17 +1,18 @@
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 { 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", {
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
17
  }), w = (e) => {
17
18
  let t = {};
@@ -30,12 +31,12 @@ const V = (e, t, r = "") => u("login", {
30
31
  }
31
32
  t[r] = w(n);
32
33
  }), t);
33
- }, _ = (e) => w(e);
34
+ }, F = (e) => w(e);
34
35
  let g;
35
- const h = () => (g || (g = E.create({
36
+ const h = () => (g || (g = x.create({
36
37
  withCredentials: !0
37
- })), g), p = async (e) => {
38
- let t = b(_(e));
38
+ })), g), d = async (e) => {
39
+ let t = b(F(e));
39
40
  const r = await h().post(y(), {
40
41
  query: `{ ${t} }`
41
42
  });
@@ -46,7 +47,7 @@ const h = () => (g || (g = E.create({
46
47
  const n = {
47
48
  mutation: {}
48
49
  };
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] = !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
51
  n.mutation[e][l] = f;
51
52
  });
52
53
  const i = await h().post(y(), {
@@ -56,18 +57,18 @@ const h = () => (g || (g = E.create({
56
57
  throw new Error(i.data.errors[0].message);
57
58
  return i.data.data[e];
58
59
  };
59
- let F = "/api/";
60
- const z = (e) => {
61
- F = e;
62
- }, y = () => F;
63
- async function $(e) {
60
+ let O = "/api/";
61
+ const G = (e) => {
62
+ O = e;
63
+ }, y = () => O;
64
+ async function H(e) {
64
65
  const t = {
65
66
  __variables: {
66
67
  file: "Upload!"
67
68
  },
68
69
  fsUploadTempFile: {
69
70
  __args: {
70
- file: new R("file")
71
+ file: new E("file")
71
72
  },
72
73
  name: !0,
73
74
  path: !0,
@@ -83,18 +84,18 @@ async function $(e) {
83
84
  throw new Error(n.data.errors[0].message);
84
85
  return n.data.data.fsUploadTempFile;
85
86
  }
86
- const G = (e, t, r) => u("sendMail", {
87
+ const X = (e, t, r) => u("sendMail", {
87
88
  email: e,
88
89
  subject: t,
89
90
  message: r
90
- }), H = async (e) => (await p({
91
+ }), Y = async (e) => (await d({
91
92
  config: {
92
93
  __args: {
93
94
  name: e
94
95
  }
95
96
  }
96
97
  })).config;
97
- function O(e) {
98
+ function v(e) {
98
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);
99
100
  for (let f = 0; f < n.length; f++)
100
101
  l[f] = n.charCodeAt(f);
@@ -111,13 +112,13 @@ function S(e) {
111
112
  ).replace(/=/g, "");
112
113
  }
113
114
  var s = "copy", c = "convert";
114
- function d(e, t, r) {
115
+ function p(e, t, r) {
115
116
  if (t === s)
116
117
  return r;
117
118
  if (t === c)
118
119
  return e(r);
119
120
  if (t instanceof Array)
120
- return r.map((n) => d(e, t[0], n));
121
+ return r.map((n) => p(e, t[0], n));
121
122
  if (t instanceof Object) {
122
123
  const n = {};
123
124
  for (const [i, l] of Object.entries(t)) {
@@ -134,7 +135,7 @@ function d(e, t, r) {
134
135
  n[i] = null;
135
136
  continue;
136
137
  }
137
- n[i] = d(
138
+ n[i] = p(
138
139
  e,
139
140
  l.schema,
140
141
  r[i]
@@ -166,15 +167,15 @@ var A = {
166
167
  type: a(s),
167
168
  id: a(c),
168
169
  transports: o(s)
169
- }, v = {
170
+ }, C = {
170
171
  appid: o(s),
171
172
  appidExclude: o(s),
172
173
  credProps: o(s)
173
- }, C = {
174
+ }, R = {
174
175
  appid: o(s),
175
176
  appidExclude: o(s),
176
177
  credProps: o(s)
177
- }, x = {
178
+ }, q = {
178
179
  publicKey: a({
179
180
  rp: a(s),
180
181
  user: a({
@@ -188,10 +189,10 @@ var A = {
188
189
  excludeCredentials: o([A]),
189
190
  authenticatorSelection: o(s),
190
191
  attestation: o(s),
191
- extensions: o(v)
192
+ extensions: o(C)
192
193
  }),
193
194
  signal: o(s)
194
- }, q = {
195
+ }, J = {
195
196
  type: a(s),
196
197
  id: a(s),
197
198
  rawId: a(c),
@@ -208,10 +209,10 @@ var A = {
208
209
  )
209
210
  }),
210
211
  clientExtensionResults: m(
211
- C,
212
+ R,
212
213
  (e) => e.getClientExtensionResults()
213
214
  )
214
- }, J = {
215
+ }, N = {
215
216
  mediation: o(s),
216
217
  publicKey: a({
217
218
  challenge: a(c),
@@ -219,10 +220,10 @@ var A = {
219
220
  rpId: o(s),
220
221
  allowCredentials: o([A]),
221
222
  userVerification: o(s),
222
- extensions: o(v)
223
+ extensions: o(C)
223
224
  }),
224
225
  signal: o(s)
225
- }, N = {
226
+ }, P = {
226
227
  type: a(s),
227
228
  id: a(s),
228
229
  rawId: a(c),
@@ -234,66 +235,66 @@ var A = {
234
235
  userHandle: a(c)
235
236
  }),
236
237
  clientExtensionResults: m(
237
- C,
238
+ R,
238
239
  (e) => e.getClientExtensionResults()
239
240
  )
240
241
  };
241
- function P(e) {
242
- return d(O, x, e);
243
- }
244
242
  function j(e) {
245
- return d(
243
+ return p(v, q, e);
244
+ }
245
+ function D(e) {
246
+ return p(
246
247
  S,
247
- q,
248
+ J,
248
249
  e
249
250
  );
250
251
  }
251
- function D(e) {
252
- return d(O, J, e);
253
- }
254
252
  function T(e) {
255
- return d(
253
+ return p(v, N, e);
254
+ }
255
+ function K(e) {
256
+ return p(
256
257
  S,
257
- N,
258
+ P,
258
259
  e
259
260
  );
260
261
  }
261
- async function K(e) {
262
+ async function L(e) {
262
263
  const t = await navigator.credentials.create(
263
264
  e
264
265
  );
265
- return t.toJSON = () => j(t), t;
266
+ return t.toJSON = () => D(t), t;
266
267
  }
267
- async function L(e) {
268
+ async function U(e) {
268
269
  const t = await navigator.credentials.get(
269
270
  e
270
271
  );
271
- return t.toJSON = () => T(t), t;
272
+ return t.toJSON = () => K(t), t;
272
273
  }
273
- async function X(e) {
274
- const r = (await p({
274
+ async function Z(e) {
275
+ const r = (await d({
275
276
  webAuthnRequestOptions: {
276
277
  __args: {
277
278
  username: e
278
279
  }
279
280
  }
280
- })).webAuthnRequestOptions, n = D({
281
+ })).webAuthnRequestOptions, n = T({
281
282
  publicKey: r
282
- }), i = await L(n);
283
+ }), i = await U(n);
283
284
  await u("webAuthnAssertion", {
284
285
  username: e,
285
286
  assertion: i.toJSON()
286
287
  });
287
288
  }
288
- async function Y() {
289
- const e = await p({ webAuthnCreationOptions: !0 }), t = P({
289
+ async function k() {
290
+ const e = await d({ webAuthnCreationOptions: !0 }), t = j({
290
291
  publicKey: e.webAuthnCreationOptions
291
- }), r = await K(t);
292
+ }), r = await L(t);
292
293
  await u("webAuthnRegister", {
293
294
  registration: r.toJSON()
294
295
  });
295
296
  }
296
- const Z = async (e) => (await p({
297
+ const ee = async (e) => (await d({
297
298
  fsListFiles: {
298
299
  __args: {
299
300
  path: e
@@ -305,7 +306,7 @@ const Z = async (e) => (await p({
305
306
  canPreview: !0,
306
307
  imagePath: !0
307
308
  }
308
- })).fsListFiles, k = async (e) => (await p({
309
+ })).fsListFiles, te = async (e) => (await d({
309
310
  fsListFolders: {
310
311
  __args: {
311
312
  path: e
@@ -313,8 +314,8 @@ const Z = async (e) => (await p({
313
314
  name: !0,
314
315
  path: !0
315
316
  }
316
- })).fsListFolders, ee = async (e) => {
317
- let t = await p({
317
+ })).fsListFolders, re = async (e) => {
318
+ let t = await d({
318
319
  fsFile: {
319
320
  __args: {
320
321
  path: e
@@ -322,46 +323,50 @@ const Z = async (e) => (await p({
322
323
  content: !0
323
324
  }
324
325
  });
325
- return Buffer.from(t.fsFile.content, "base64").toString("utf-8");
326
- }, te = (e, t) => (t = Buffer.from(t).toString("base64"), u("fsWriteFileBase64", {
326
+ return _.from(t.fsFile.content, "base64").toString("utf-8");
327
+ }, ne = (e, t) => (t = _.from(t).toString("base64"), u("fsWriteFileBase64", {
327
328
  path: e,
328
329
  content: t
329
- })), re = (e) => u("fsDeleteFile", {
330
+ })), se = (e) => u("fsDeleteFile", {
330
331
  path: e
331
- }), ne = (e) => u("fsCreateFolder", {
332
+ }), ae = (e) => u("fsCreateFolder", {
332
333
  path: e
333
- }), se = (e) => u("fsDeleteFolder", {
334
+ }), oe = (e) => u("fsDeleteFolder", {
334
335
  path: e
335
- }), ae = (e, t) => u("fsRenameFile", {
336
+ }), ie = (e, t) => u("fsRenameFile", {
336
337
  path: e,
337
338
  name: t
338
- }), oe = (e, t) => u("fsRenameFolder", {
339
+ }), ue = (e, t) => u("fsRenameFolder", {
339
340
  path: e,
340
341
  name: t
342
+ }), ce = (e, t) => u("fsMoveFile", {
343
+ source: e,
344
+ target: t
341
345
  });
342
346
  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,
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,
353
358
  y as getApiUrl,
354
- H as getConfig,
355
- V as login,
356
- W as logout,
359
+ Y as getConfig,
360
+ W as login,
361
+ I as logout,
357
362
  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
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
367
372
  };
@@ -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,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.21",
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
  }