@hostlink/light 0.0.22 → 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/granted.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/light.js +64 -53
- package/dist/light.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const granted: (rights: string[]) => Promise<string[]>;
|
package/dist/index.d.ts
CHANGED
package/dist/light.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as b, VariableType as E } from "json-to-graphql-query";
|
|
2
1
|
import x from "axios";
|
|
3
|
-
import {
|
|
2
|
+
import { jsonToGraphQLQuery as b, VariableType as E } from "json-to-graphql-query";
|
|
3
|
+
import { Buffer as y } from "buffer";
|
|
4
4
|
const W = (e, t, r = "") => u("login", {
|
|
5
5
|
username: e,
|
|
6
6
|
password: t,
|
|
@@ -14,7 +14,19 @@ const W = (e, t, r = "") => u("login", {
|
|
|
14
14
|
code: r
|
|
15
15
|
}), $ = (e) => u("forgetPassword", {
|
|
16
16
|
email: e
|
|
17
|
-
})
|
|
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) => {
|
|
18
30
|
let t = {};
|
|
19
31
|
return typeof e == "string" ? (t[e] = !0, t) : e instanceof Array ? (e.forEach((r) => {
|
|
20
32
|
Object.entries(w(r)).forEach(([n, i]) => {
|
|
@@ -31,13 +43,9 @@ const W = (e, t, r = "") => u("login", {
|
|
|
31
43
|
}
|
|
32
44
|
t[r] = w(n);
|
|
33
45
|
}), t);
|
|
34
|
-
}, F = (e) => w(e)
|
|
35
|
-
let g;
|
|
36
|
-
const h = () => (g || (g = x.create({
|
|
37
|
-
withCredentials: !0
|
|
38
|
-
})), g), d = async (e) => {
|
|
46
|
+
}, F = (e) => w(e), d = async (e) => {
|
|
39
47
|
let t = b(F(e));
|
|
40
|
-
const r = await h().post(
|
|
48
|
+
const r = await h().post(_(), {
|
|
41
49
|
query: `{ ${t} }`
|
|
42
50
|
});
|
|
43
51
|
if (r.data.errors)
|
|
@@ -50,7 +58,7 @@ const h = () => (g || (g = x.create({
|
|
|
50
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]) => {
|
|
51
59
|
n.mutation[e][l] = f;
|
|
52
60
|
});
|
|
53
|
-
const i = await h().post(
|
|
61
|
+
const i = await h().post(_(), {
|
|
54
62
|
query: b(n)
|
|
55
63
|
});
|
|
56
64
|
if (i.data.errors)
|
|
@@ -58,10 +66,10 @@ const h = () => (g || (g = x.create({
|
|
|
58
66
|
return i.data.data[e];
|
|
59
67
|
};
|
|
60
68
|
let O = "/api/";
|
|
61
|
-
const
|
|
69
|
+
const X = (e) => {
|
|
62
70
|
O = e;
|
|
63
|
-
},
|
|
64
|
-
async function
|
|
71
|
+
}, _ = () => O;
|
|
72
|
+
async function Y(e) {
|
|
65
73
|
const t = {
|
|
66
74
|
__variables: {
|
|
67
75
|
file: "Upload!"
|
|
@@ -79,16 +87,16 @@ async function H(e) {
|
|
|
79
87
|
r.append("operations", JSON.stringify({
|
|
80
88
|
query: b({ mutation: t })
|
|
81
89
|
})), r.append("map", JSON.stringify({ 0: ["variables.file"] })), r.append("0", e);
|
|
82
|
-
const n = await h().post(
|
|
90
|
+
const n = await h().post(_(), r);
|
|
83
91
|
if (n.data.errors)
|
|
84
92
|
throw new Error(n.data.errors[0].message);
|
|
85
93
|
return n.data.data.fsUploadTempFile;
|
|
86
94
|
}
|
|
87
|
-
const
|
|
95
|
+
const Z = (e, t, r) => u("sendMail", {
|
|
88
96
|
email: e,
|
|
89
97
|
subject: t,
|
|
90
98
|
message: r
|
|
91
|
-
}),
|
|
99
|
+
}), k = async (e) => (await d({
|
|
92
100
|
config: {
|
|
93
101
|
__args: {
|
|
94
102
|
name: e
|
|
@@ -101,7 +109,7 @@ function v(e) {
|
|
|
101
109
|
l[f] = n.charCodeAt(f);
|
|
102
110
|
return i;
|
|
103
111
|
}
|
|
104
|
-
function
|
|
112
|
+
function A(e) {
|
|
105
113
|
const t = new Uint8Array(e);
|
|
106
114
|
let r = "";
|
|
107
115
|
for (const l of t)
|
|
@@ -163,7 +171,7 @@ function o(e) {
|
|
|
163
171
|
schema: e
|
|
164
172
|
};
|
|
165
173
|
}
|
|
166
|
-
var
|
|
174
|
+
var S = {
|
|
167
175
|
type: a(s),
|
|
168
176
|
id: a(c),
|
|
169
177
|
transports: o(s)
|
|
@@ -186,7 +194,7 @@ var A = {
|
|
|
186
194
|
challenge: a(c),
|
|
187
195
|
pubKeyCredParams: a(s),
|
|
188
196
|
timeout: o(s),
|
|
189
|
-
excludeCredentials: o([
|
|
197
|
+
excludeCredentials: o([S]),
|
|
190
198
|
authenticatorSelection: o(s),
|
|
191
199
|
attestation: o(s),
|
|
192
200
|
extensions: o(C)
|
|
@@ -218,7 +226,7 @@ var A = {
|
|
|
218
226
|
challenge: a(c),
|
|
219
227
|
timeout: o(s),
|
|
220
228
|
rpId: o(s),
|
|
221
|
-
allowCredentials: o([
|
|
229
|
+
allowCredentials: o([S]),
|
|
222
230
|
userVerification: o(s),
|
|
223
231
|
extensions: o(C)
|
|
224
232
|
}),
|
|
@@ -244,7 +252,7 @@ function j(e) {
|
|
|
244
252
|
}
|
|
245
253
|
function D(e) {
|
|
246
254
|
return p(
|
|
247
|
-
|
|
255
|
+
A,
|
|
248
256
|
J,
|
|
249
257
|
e
|
|
250
258
|
);
|
|
@@ -254,7 +262,7 @@ function T(e) {
|
|
|
254
262
|
}
|
|
255
263
|
function K(e) {
|
|
256
264
|
return p(
|
|
257
|
-
|
|
265
|
+
A,
|
|
258
266
|
P,
|
|
259
267
|
e
|
|
260
268
|
);
|
|
@@ -271,7 +279,7 @@ async function U(e) {
|
|
|
271
279
|
);
|
|
272
280
|
return t.toJSON = () => K(t), t;
|
|
273
281
|
}
|
|
274
|
-
async function
|
|
282
|
+
async function ee(e) {
|
|
275
283
|
const r = (await d({
|
|
276
284
|
webAuthnRequestOptions: {
|
|
277
285
|
__args: {
|
|
@@ -286,7 +294,7 @@ async function Z(e) {
|
|
|
286
294
|
assertion: i.toJSON()
|
|
287
295
|
});
|
|
288
296
|
}
|
|
289
|
-
async function
|
|
297
|
+
async function te() {
|
|
290
298
|
const e = await d({ webAuthnCreationOptions: !0 }), t = j({
|
|
291
299
|
publicKey: e.webAuthnCreationOptions
|
|
292
300
|
}), r = await L(t);
|
|
@@ -294,7 +302,7 @@ async function k() {
|
|
|
294
302
|
registration: r.toJSON()
|
|
295
303
|
});
|
|
296
304
|
}
|
|
297
|
-
const
|
|
305
|
+
const re = async (e) => (await d({
|
|
298
306
|
fsListFiles: {
|
|
299
307
|
__args: {
|
|
300
308
|
path: e
|
|
@@ -306,7 +314,7 @@ const ee = async (e) => (await d({
|
|
|
306
314
|
canPreview: !0,
|
|
307
315
|
imagePath: !0
|
|
308
316
|
}
|
|
309
|
-
})).fsListFiles,
|
|
317
|
+
})).fsListFiles, ne = async (e) => (await d({
|
|
310
318
|
fsListFolders: {
|
|
311
319
|
__args: {
|
|
312
320
|
path: e
|
|
@@ -314,59 +322,62 @@ const ee = async (e) => (await d({
|
|
|
314
322
|
name: !0,
|
|
315
323
|
path: !0
|
|
316
324
|
}
|
|
317
|
-
})).fsListFolders,
|
|
325
|
+
})).fsListFolders, se = async (e) => {
|
|
318
326
|
let t = await d({
|
|
319
327
|
fsFile: {
|
|
320
328
|
__args: {
|
|
321
329
|
path: e
|
|
322
330
|
},
|
|
323
|
-
|
|
331
|
+
base64Content: !0
|
|
324
332
|
}
|
|
325
333
|
});
|
|
326
|
-
return
|
|
327
|
-
},
|
|
334
|
+
return y.from(t.fsFile.base64Content, "base64").toString("utf-8");
|
|
335
|
+
}, ae = (e, t) => (t = y.from(t).toString("base64"), u("fsWriteFileBase64", {
|
|
328
336
|
path: e,
|
|
329
337
|
content: t
|
|
330
|
-
})),
|
|
338
|
+
})), oe = (e) => u("fsDeleteFile", {
|
|
331
339
|
path: e
|
|
332
|
-
}),
|
|
340
|
+
}), ie = (e) => u("fsCreateFolder", {
|
|
333
341
|
path: e
|
|
334
|
-
}),
|
|
342
|
+
}), ue = (e) => u("fsDeleteFolder", {
|
|
335
343
|
path: e
|
|
336
|
-
}),
|
|
344
|
+
}), ce = (e, t) => u("fsRenameFile", {
|
|
337
345
|
path: e,
|
|
338
346
|
name: t
|
|
339
|
-
}),
|
|
347
|
+
}), le = (e, t) => u("fsRenameFolder", {
|
|
340
348
|
path: e,
|
|
341
349
|
name: t
|
|
342
|
-
}),
|
|
350
|
+
}), fe = (e, t) => u("fsMoveFile", {
|
|
343
351
|
source: e,
|
|
344
352
|
target: t
|
|
345
353
|
});
|
|
346
354
|
export {
|
|
347
355
|
$ as forgetPassword,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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,
|
|
360
370
|
W as login,
|
|
361
371
|
I as logout,
|
|
362
372
|
u as mutation,
|
|
363
373
|
d as query,
|
|
364
374
|
z as resetPassword,
|
|
365
|
-
|
|
366
|
-
|
|
375
|
+
Z as sendMail,
|
|
376
|
+
X as setApiUrl,
|
|
377
|
+
G as setAxios,
|
|
367
378
|
F as toQuery,
|
|
368
379
|
Q as updatePassword,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
380
|
+
Y as uploadFile,
|
|
381
|
+
ee as webauthnLogin,
|
|
382
|
+
te as webauthnRegister
|
|
372
383
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,
|
|
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"})});
|