@hostlink/light 0.0.16 → 0.0.17
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/light.js +36 -32
- package/dist/light.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/light.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as w, VariableType as
|
|
1
|
+
import { jsonToGraphQLQuery as w, VariableType as A } from "json-to-graphql-query";
|
|
2
2
|
import h from "axios";
|
|
3
3
|
const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : localStorage.getItem("light-api-url"), d = async (t, e = null, r = []) => {
|
|
4
4
|
const n = h.create({
|
|
@@ -15,28 +15,32 @@ const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : local
|
|
|
15
15
|
if (u.data.errors)
|
|
16
16
|
throw new Error(u.data.errors[0].message);
|
|
17
17
|
return u.data.data;
|
|
18
|
-
},
|
|
18
|
+
}, I = async (t, e, r = "") => await d("login", {
|
|
19
19
|
username: t,
|
|
20
20
|
password: e,
|
|
21
21
|
code: r
|
|
22
|
-
}),
|
|
22
|
+
}), V = async () => await d("logout"), f = (t) => {
|
|
23
23
|
let e = {};
|
|
24
24
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
25
25
|
Object.entries(f(r)).forEach(([n, i]) => {
|
|
26
26
|
e[n] = i;
|
|
27
27
|
});
|
|
28
28
|
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
29
|
-
if (r == "__args") {
|
|
29
|
+
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
30
30
|
e[r] = n;
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
if (typeof n == "boolean") {
|
|
34
|
+
e[r] = n;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
e[r] = f(n);
|
|
34
38
|
}), e);
|
|
35
|
-
},
|
|
39
|
+
}, C = (t) => f(t), b = async (t) => {
|
|
36
40
|
const e = h.create({
|
|
37
41
|
withCredentials: !0
|
|
38
42
|
});
|
|
39
|
-
let r = w(
|
|
43
|
+
let r = w(C(t));
|
|
40
44
|
const n = await e.post(m(), {
|
|
41
45
|
query: `{ ${r} }`
|
|
42
46
|
});
|
|
@@ -55,7 +59,7 @@ async function M(t) {
|
|
|
55
59
|
},
|
|
56
60
|
fsUploadTempFile: {
|
|
57
61
|
__args: {
|
|
58
|
-
file: new
|
|
62
|
+
file: new A("file")
|
|
59
63
|
},
|
|
60
64
|
name: !0,
|
|
61
65
|
path: !0,
|
|
@@ -72,7 +76,7 @@ async function M(t) {
|
|
|
72
76
|
return i.data.data.fsUploadTempFile;
|
|
73
77
|
}
|
|
74
78
|
const P = (t, e, r) => d("sendMail", { email: t, subject: e, message: r });
|
|
75
|
-
function
|
|
79
|
+
function y(t) {
|
|
76
80
|
const e = "==".slice(0, (4 - t.length % 4) % 4), r = t.replace(/-/g, "+").replace(/_/g, "/") + e, n = atob(r), i = new ArrayBuffer(n.length), u = new Uint8Array(i);
|
|
77
81
|
for (let l = 0; l < n.length; l++)
|
|
78
82
|
u[l] = n.charCodeAt(l);
|
|
@@ -144,15 +148,15 @@ var S = {
|
|
|
144
148
|
type: o(a),
|
|
145
149
|
id: o(c),
|
|
146
150
|
transports: s(a)
|
|
147
|
-
},
|
|
151
|
+
}, _ = {
|
|
148
152
|
appid: s(a),
|
|
149
153
|
appidExclude: s(a),
|
|
150
154
|
credProps: s(a)
|
|
151
|
-
},
|
|
155
|
+
}, v = {
|
|
152
156
|
appid: s(a),
|
|
153
157
|
appidExclude: s(a),
|
|
154
158
|
credProps: s(a)
|
|
155
|
-
},
|
|
159
|
+
}, E = {
|
|
156
160
|
publicKey: o({
|
|
157
161
|
rp: o(a),
|
|
158
162
|
user: o({
|
|
@@ -166,10 +170,10 @@ var S = {
|
|
|
166
170
|
excludeCredentials: s([S]),
|
|
167
171
|
authenticatorSelection: s(a),
|
|
168
172
|
attestation: s(a),
|
|
169
|
-
extensions: s(
|
|
173
|
+
extensions: s(_)
|
|
170
174
|
}),
|
|
171
175
|
signal: s(a)
|
|
172
|
-
},
|
|
176
|
+
}, R = {
|
|
173
177
|
type: o(a),
|
|
174
178
|
id: o(a),
|
|
175
179
|
rawId: o(c),
|
|
@@ -186,10 +190,10 @@ var S = {
|
|
|
186
190
|
)
|
|
187
191
|
}),
|
|
188
192
|
clientExtensionResults: g(
|
|
189
|
-
|
|
193
|
+
v,
|
|
190
194
|
(t) => t.getClientExtensionResults()
|
|
191
195
|
)
|
|
192
|
-
},
|
|
196
|
+
}, q = {
|
|
193
197
|
mediation: s(a),
|
|
194
198
|
publicKey: o({
|
|
195
199
|
challenge: o(c),
|
|
@@ -197,10 +201,10 @@ var S = {
|
|
|
197
201
|
rpId: s(a),
|
|
198
202
|
allowCredentials: s([S]),
|
|
199
203
|
userVerification: s(a),
|
|
200
|
-
extensions: s(
|
|
204
|
+
extensions: s(_)
|
|
201
205
|
}),
|
|
202
206
|
signal: s(a)
|
|
203
|
-
},
|
|
207
|
+
}, x = {
|
|
204
208
|
type: o(a),
|
|
205
209
|
id: o(a),
|
|
206
210
|
rawId: o(c),
|
|
@@ -212,27 +216,27 @@ var S = {
|
|
|
212
216
|
userHandle: o(c)
|
|
213
217
|
}),
|
|
214
218
|
clientExtensionResults: g(
|
|
215
|
-
|
|
219
|
+
v,
|
|
216
220
|
(t) => t.getClientExtensionResults()
|
|
217
221
|
)
|
|
218
222
|
};
|
|
219
|
-
function
|
|
220
|
-
return p(
|
|
223
|
+
function J(t) {
|
|
224
|
+
return p(y, E, t);
|
|
221
225
|
}
|
|
222
|
-
function
|
|
226
|
+
function N(t) {
|
|
223
227
|
return p(
|
|
224
228
|
O,
|
|
225
|
-
|
|
229
|
+
R,
|
|
226
230
|
t
|
|
227
231
|
);
|
|
228
232
|
}
|
|
229
233
|
function j(t) {
|
|
230
|
-
return p(
|
|
234
|
+
return p(y, q, t);
|
|
231
235
|
}
|
|
232
236
|
function T(t) {
|
|
233
237
|
return p(
|
|
234
238
|
O,
|
|
235
|
-
|
|
239
|
+
x,
|
|
236
240
|
t
|
|
237
241
|
);
|
|
238
242
|
}
|
|
@@ -240,7 +244,7 @@ async function K(t) {
|
|
|
240
244
|
const e = await navigator.credentials.create(
|
|
241
245
|
t
|
|
242
246
|
);
|
|
243
|
-
return e.toJSON = () =>
|
|
247
|
+
return e.toJSON = () => N(e), e;
|
|
244
248
|
}
|
|
245
249
|
async function U(t) {
|
|
246
250
|
const e = await navigator.credentials.get(
|
|
@@ -249,7 +253,7 @@ async function U(t) {
|
|
|
249
253
|
return e.toJSON = () => T(e), e;
|
|
250
254
|
}
|
|
251
255
|
async function Q(t) {
|
|
252
|
-
const r = (await
|
|
256
|
+
const r = (await b({
|
|
253
257
|
webAuthnRequestOptions: {
|
|
254
258
|
__args: {
|
|
255
259
|
username: t
|
|
@@ -264,7 +268,7 @@ async function Q(t) {
|
|
|
264
268
|
});
|
|
265
269
|
}
|
|
266
270
|
async function L() {
|
|
267
|
-
const t = await
|
|
271
|
+
const t = await b({ webAuthnCreationOptions: !0 }), e = J({
|
|
268
272
|
publicKey: t.webAuthnCreationOptions
|
|
269
273
|
}), r = await K(e);
|
|
270
274
|
await d("webAuthnRegister", {
|
|
@@ -273,13 +277,13 @@ async function L() {
|
|
|
273
277
|
}
|
|
274
278
|
export {
|
|
275
279
|
m as getApiUrl,
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
I as login,
|
|
281
|
+
V as logout,
|
|
278
282
|
d as mutation,
|
|
279
|
-
|
|
283
|
+
b as query,
|
|
280
284
|
P as sendMail,
|
|
281
285
|
B as setApiUrl,
|
|
282
|
-
|
|
286
|
+
C as toQuery,
|
|
283
287
|
M as uploadFile,
|
|
284
288
|
Q as webauthnLogin,
|
|
285
289
|
L as webauthnRegister
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],f):(u=typeof globalThis<"u"?globalThis:u||self,f(u.light={},u.jsonToGraphqlQuery,u.axios))})(this,function(u,f,w){"use strict";const h=()=>localStorage.getItem("light-api-url")===null?"/api/":localStorage.getItem("light-api-url"),p=async(e,t=null,n=[])=>{const
|
|
1
|
+
(function(u,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],f):(u=typeof globalThis<"u"?globalThis:u||self,f(u.light={},u.jsonToGraphqlQuery,u.axios))})(this,function(u,f,w){"use strict";const h=()=>localStorage.getItem("light-api-url")===null?"/api/":localStorage.getItem("light-api-url"),p=async(e,t=null,n=[])=>{const r=w.create({withCredentials:!0}),o={mutation:{}};o.mutation[e]=!0,t&&(o.mutation[e]={},o.mutation[e].__args=t),n.length>0&&(o.mutation[e]={}),n.forEach(d=>{o.mutation[e][d]=!0});const l=await r.post(h(),{query:f.jsonToGraphQLQuery(o)});if(l.data.errors)throw new Error(l.data.errors[0].message);return l.data.data},q=async(e,t,n="")=>await p("login",{username:e,password:t,code:n}),E=async()=>await p("logout"),m=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(n=>{Object.entries(m(n)).forEach(([r,o])=>{t[r]=o})}),t):(Object.entries(e).forEach(([n,r])=>{if(n=="__args"||n=="__aliasFor"||n=="__variables"||n=="__directives"||n=="__all_on"||n=="__name"){t[n]=r;return}if(typeof r=="boolean"){t[n]=r;return}t[n]=m(r)}),t)},S=e=>m(e),b=async e=>{const t=w.create({withCredentials:!0});let n=f.jsonToGraphQLQuery(S(e));const r=await t.post(h(),{query:`{ ${n} }`});if(r.data.errors)throw new Error(r.data.errors[0].message);return r.data.data},R=e=>{localStorage.setItem("light-api-url",e)};async function j(e){const t=w.create({withCredentials:!0}),n={__variables:{file:"Upload!"},fsUploadTempFile:{__args:{file:new f.VariableType("file")},name:!0,path:!0,size:!0,mime:!0}},r=new FormData;r.append("operations",JSON.stringify({query:f.jsonToGraphQLQuery({mutation:n})})),r.append("map",JSON.stringify({0:["variables.file"]})),r.append("0",e);const o=await t.post(h(),r);if(o.data.errors)throw new Error(o.data.errors[0].message);return o.data.data.fsUploadTempFile}const J=(e,t,n)=>p("sendMail",{email:e,subject:t,message:n});function O(e){const t="==".slice(0,(4-e.length%4)%4),n=e.replace(/-/g,"+").replace(/_/g,"/")+t,r=atob(n),o=new ArrayBuffer(r.length),l=new Uint8Array(o);for(let d=0;d<r.length;d++)l[d]=r.charCodeAt(d);return o}function v(e){const t=new Uint8Array(e);let n="";for(const l of t)n+=String.fromCharCode(l);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var i="copy",c="convert";function g(e,t,n){if(t===i)return n;if(t===c)return e(n);if(t instanceof Array)return n.map(r=>g(e,t[0],r));if(t instanceof Object){const r={};for(const[o,l]of Object.entries(t)){if(l.derive){const d=l.derive(n);d!==void 0&&(n[o]=d)}if(!(o in n)){if(l.required)throw new Error(`Missing key: ${o}`);continue}if(n[o]==null){r[o]=null;continue}r[o]=g(e,l.schema,n[o])}return r}}function y(e,t){return{required:!0,schema:e,derive:t}}function a(e){return{required:!0,schema:e}}function s(e){return{required:!1,schema:e}}var _={type:a(i),id:a(c),transports:s(i)},A={appid:s(i),appidExclude:s(i),credProps:s(i)},C={appid:s(i),appidExclude:s(i),credProps:s(i)},N={publicKey:a({rp:a(i),user:a({id:a(c),name:a(i),displayName:a(i)}),challenge:a(c),pubKeyCredParams:a(i),timeout:s(i),excludeCredentials:s([_]),authenticatorSelection:s(i),attestation:s(i),extensions:s(A)}),signal:s(i)},T={type:a(i),id:a(i),rawId:a(c),authenticatorAttachment:s(i),response:a({clientDataJSON:a(c),attestationObject:a(c),transports:y(i,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:y(C,e=>e.getClientExtensionResults())},U={mediation:s(i),publicKey:a({challenge:a(c),timeout:s(i),rpId:s(i),allowCredentials:s([_]),userVerification:s(i),extensions:s(A)}),signal:s(i)},K={type:a(i),id:a(i),rawId:a(c),authenticatorAttachment:s(i),response:a({clientDataJSON:a(c),authenticatorData:a(c),signature:a(c),userHandle:a(c)}),clientExtensionResults:y(C,e=>e.getClientExtensionResults())};function F(e){return g(O,N,e)}function D(e){return g(v,T,e)}function I(e){return g(O,U,e)}function Q(e){return g(v,K,e)}async function V(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>D(t),t}async function L(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>Q(t),t}async function M(e){const n=(await b({webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,r=I({publicKey:n}),o=await L(r);await p("webAuthnAssertion",{username:e,assertion:o.toJSON()})}async function x(){const e=await b({webAuthnCreationOptions:!0}),t=F({publicKey:e.webAuthnCreationOptions}),n=await V(t);await p("webAuthnRegister",{registration:n.toJSON()})}u.getApiUrl=h,u.login=q,u.logout=E,u.mutation=p,u.query=b,u.sendMail=J,u.setApiUrl=R,u.toQuery=S,u.uploadFile=j,u.webauthnLogin=M,u.webauthnRegister=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|