@hostlink/light 0.0.14 → 0.0.16
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 +51 -51
- package/dist/light.umd.cjs +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/toQuery.d.ts +1 -1
- package/package.json +2 -2
package/dist/light.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsonToGraphQLQuery as w, VariableType as C } from "json-to-graphql-query";
|
|
2
2
|
import h from "axios";
|
|
3
|
-
const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : localStorage.getItem("light-api-url"),
|
|
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({
|
|
5
5
|
withCredentials: !0
|
|
6
6
|
}), i = {
|
|
@@ -9,41 +9,41 @@ const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : local
|
|
|
9
9
|
i.mutation[t] = !0, e && (i.mutation[t] = {}, i.mutation[t].__args = e), r.length > 0 && (i.mutation[t] = {}), r.forEach((l) => {
|
|
10
10
|
i.mutation[t][l] = !0;
|
|
11
11
|
});
|
|
12
|
-
const
|
|
12
|
+
const u = await n.post(m(), {
|
|
13
13
|
query: w(i)
|
|
14
14
|
});
|
|
15
|
-
if (
|
|
16
|
-
throw new Error(
|
|
17
|
-
return
|
|
18
|
-
}, V = async (t, e, r = "") => await
|
|
15
|
+
if (u.data.errors)
|
|
16
|
+
throw new Error(u.data.errors[0].message);
|
|
17
|
+
return u.data.data;
|
|
18
|
+
}, V = async (t, e, r = "") => await d("login", {
|
|
19
19
|
username: t,
|
|
20
20
|
password: e,
|
|
21
21
|
code: r
|
|
22
|
-
}),
|
|
22
|
+
}), F = async () => await d("logout"), f = (t) => {
|
|
23
23
|
let e = {};
|
|
24
|
-
return
|
|
24
|
+
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
25
|
+
Object.entries(f(r)).forEach(([n, i]) => {
|
|
26
|
+
e[n] = i;
|
|
27
|
+
});
|
|
28
|
+
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
25
29
|
if (r == "__args") {
|
|
26
30
|
e[r] = n;
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
n
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}) : e[r][i] = !0;
|
|
33
|
-
})) : n instanceof Object ? e[r] = d(n) : e[r] = n;
|
|
34
|
-
}), e;
|
|
35
|
-
}, q = (t) => d(t), y = async (t) => {
|
|
33
|
+
n === !0 ? e[r] = !0 : e[r] = f(n);
|
|
34
|
+
}), e);
|
|
35
|
+
}, E = (t) => f(t), y = async (t) => {
|
|
36
36
|
const e = h.create({
|
|
37
37
|
withCredentials: !0
|
|
38
38
|
});
|
|
39
|
-
let r = w(
|
|
39
|
+
let r = w(E(t));
|
|
40
40
|
const n = await e.post(m(), {
|
|
41
41
|
query: `{ ${r} }`
|
|
42
42
|
});
|
|
43
43
|
if (n.data.errors)
|
|
44
44
|
throw new Error(n.data.errors[0].message);
|
|
45
45
|
return n.data.data;
|
|
46
|
-
},
|
|
46
|
+
}, B = (t) => {
|
|
47
47
|
localStorage.setItem("light-api-url", t);
|
|
48
48
|
};
|
|
49
49
|
async function M(t) {
|
|
@@ -71,40 +71,40 @@ async function M(t) {
|
|
|
71
71
|
throw new Error(i.data.errors[0].message);
|
|
72
72
|
return i.data.data.fsUploadTempFile;
|
|
73
73
|
}
|
|
74
|
-
const P = (t, e, r) =>
|
|
74
|
+
const P = (t, e, r) => d("sendMail", { email: t, subject: e, message: r });
|
|
75
75
|
function b(t) {
|
|
76
|
-
const e = "==".slice(0, (4 - t.length % 4) % 4), r = t.replace(/-/g, "+").replace(/_/g, "/") + e, n = atob(r), i = new ArrayBuffer(n.length),
|
|
76
|
+
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
77
|
for (let l = 0; l < n.length; l++)
|
|
78
|
-
|
|
78
|
+
u[l] = n.charCodeAt(l);
|
|
79
79
|
return i;
|
|
80
80
|
}
|
|
81
81
|
function O(t) {
|
|
82
82
|
const e = new Uint8Array(t);
|
|
83
83
|
let r = "";
|
|
84
|
-
for (const
|
|
85
|
-
r += String.fromCharCode(
|
|
84
|
+
for (const u of e)
|
|
85
|
+
r += String.fromCharCode(u);
|
|
86
86
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
87
87
|
/\//g,
|
|
88
88
|
"_"
|
|
89
89
|
).replace(/=/g, "");
|
|
90
90
|
}
|
|
91
|
-
var a = "copy",
|
|
91
|
+
var a = "copy", c = "convert";
|
|
92
92
|
function p(t, e, r) {
|
|
93
93
|
if (e === a)
|
|
94
94
|
return r;
|
|
95
|
-
if (e ===
|
|
95
|
+
if (e === c)
|
|
96
96
|
return t(r);
|
|
97
97
|
if (e instanceof Array)
|
|
98
98
|
return r.map((n) => p(t, e[0], n));
|
|
99
99
|
if (e instanceof Object) {
|
|
100
100
|
const n = {};
|
|
101
|
-
for (const [i,
|
|
102
|
-
if (
|
|
103
|
-
const l =
|
|
101
|
+
for (const [i, u] of Object.entries(e)) {
|
|
102
|
+
if (u.derive) {
|
|
103
|
+
const l = u.derive(r);
|
|
104
104
|
l !== void 0 && (r[i] = l);
|
|
105
105
|
}
|
|
106
106
|
if (!(i in r)) {
|
|
107
|
-
if (
|
|
107
|
+
if (u.required)
|
|
108
108
|
throw new Error(`Missing key: ${i}`);
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
@@ -114,7 +114,7 @@ function p(t, e, r) {
|
|
|
114
114
|
}
|
|
115
115
|
n[i] = p(
|
|
116
116
|
t,
|
|
117
|
-
|
|
117
|
+
u.schema,
|
|
118
118
|
r[i]
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -142,7 +142,7 @@ function s(t) {
|
|
|
142
142
|
}
|
|
143
143
|
var S = {
|
|
144
144
|
type: o(a),
|
|
145
|
-
id: o(
|
|
145
|
+
id: o(c),
|
|
146
146
|
transports: s(a)
|
|
147
147
|
}, v = {
|
|
148
148
|
appid: s(a),
|
|
@@ -152,15 +152,15 @@ var S = {
|
|
|
152
152
|
appid: s(a),
|
|
153
153
|
appidExclude: s(a),
|
|
154
154
|
credProps: s(a)
|
|
155
|
-
},
|
|
155
|
+
}, R = {
|
|
156
156
|
publicKey: o({
|
|
157
157
|
rp: o(a),
|
|
158
158
|
user: o({
|
|
159
|
-
id: o(
|
|
159
|
+
id: o(c),
|
|
160
160
|
name: o(a),
|
|
161
161
|
displayName: o(a)
|
|
162
162
|
}),
|
|
163
|
-
challenge: o(
|
|
163
|
+
challenge: o(c),
|
|
164
164
|
pubKeyCredParams: o(a),
|
|
165
165
|
timeout: s(a),
|
|
166
166
|
excludeCredentials: s([S]),
|
|
@@ -169,14 +169,14 @@ var S = {
|
|
|
169
169
|
extensions: s(v)
|
|
170
170
|
}),
|
|
171
171
|
signal: s(a)
|
|
172
|
-
},
|
|
172
|
+
}, q = {
|
|
173
173
|
type: o(a),
|
|
174
174
|
id: o(a),
|
|
175
|
-
rawId: o(
|
|
175
|
+
rawId: o(c),
|
|
176
176
|
authenticatorAttachment: s(a),
|
|
177
177
|
response: o({
|
|
178
|
-
clientDataJSON: o(
|
|
179
|
-
attestationObject: o(
|
|
178
|
+
clientDataJSON: o(c),
|
|
179
|
+
attestationObject: o(c),
|
|
180
180
|
transports: g(
|
|
181
181
|
a,
|
|
182
182
|
(t) => {
|
|
@@ -192,7 +192,7 @@ var S = {
|
|
|
192
192
|
}, x = {
|
|
193
193
|
mediation: s(a),
|
|
194
194
|
publicKey: o({
|
|
195
|
-
challenge: o(
|
|
195
|
+
challenge: o(c),
|
|
196
196
|
timeout: s(a),
|
|
197
197
|
rpId: s(a),
|
|
198
198
|
allowCredentials: s([S]),
|
|
@@ -203,13 +203,13 @@ var S = {
|
|
|
203
203
|
}, J = {
|
|
204
204
|
type: o(a),
|
|
205
205
|
id: o(a),
|
|
206
|
-
rawId: o(
|
|
206
|
+
rawId: o(c),
|
|
207
207
|
authenticatorAttachment: s(a),
|
|
208
208
|
response: o({
|
|
209
|
-
clientDataJSON: o(
|
|
210
|
-
authenticatorData: o(
|
|
211
|
-
signature: o(
|
|
212
|
-
userHandle: o(
|
|
209
|
+
clientDataJSON: o(c),
|
|
210
|
+
authenticatorData: o(c),
|
|
211
|
+
signature: o(c),
|
|
212
|
+
userHandle: o(c)
|
|
213
213
|
}),
|
|
214
214
|
clientExtensionResults: g(
|
|
215
215
|
A,
|
|
@@ -217,12 +217,12 @@ var S = {
|
|
|
217
217
|
)
|
|
218
218
|
};
|
|
219
219
|
function N(t) {
|
|
220
|
-
return p(b,
|
|
220
|
+
return p(b, R, t);
|
|
221
221
|
}
|
|
222
222
|
function _(t) {
|
|
223
223
|
return p(
|
|
224
224
|
O,
|
|
225
|
-
|
|
225
|
+
q,
|
|
226
226
|
t
|
|
227
227
|
);
|
|
228
228
|
}
|
|
@@ -258,7 +258,7 @@ async function Q(t) {
|
|
|
258
258
|
})).webAuthnRequestOptions, n = j({
|
|
259
259
|
publicKey: r
|
|
260
260
|
}), i = await U(n);
|
|
261
|
-
await
|
|
261
|
+
await d("webAuthnAssertion", {
|
|
262
262
|
username: t,
|
|
263
263
|
assertion: i.toJSON()
|
|
264
264
|
});
|
|
@@ -267,19 +267,19 @@ async function L() {
|
|
|
267
267
|
const t = await y({ webAuthnCreationOptions: !0 }), e = N({
|
|
268
268
|
publicKey: t.webAuthnCreationOptions
|
|
269
269
|
}), r = await K(e);
|
|
270
|
-
await
|
|
270
|
+
await d("webAuthnRegister", {
|
|
271
271
|
registration: r.toJSON()
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
export {
|
|
275
275
|
m as getApiUrl,
|
|
276
276
|
V as login,
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
F as logout,
|
|
278
|
+
d as mutation,
|
|
279
279
|
y as query,
|
|
280
280
|
P as sendMail,
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
B as setApiUrl,
|
|
282
|
+
E as toQuery,
|
|
283
283
|
M as uploadFile,
|
|
284
284
|
Q as webauthnLogin,
|
|
285
285
|
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 i=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 i.post(h(),{query:f.jsonToGraphQLQuery(o)});if(l.data.errors)throw new Error(l.data.errors[0].message);return l.data.data},E=async(e,t,n="")=>await p("login",{username:e,password:t,code:n}),R=async()=>await p("logout"),y=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(n=>{Object.entries(y(n)).forEach(([i,o])=>{t[i]=o})}),t):(Object.entries(e).forEach(([n,i])=>{if(n=="__args"){t[n]=i;return}i===!0?t[n]=!0:t[n]=y(i)}),t)},S=e=>y(e),m=async e=>{const t=w.create({withCredentials:!0});let n=f.jsonToGraphQLQuery(S(e));const i=await t.post(h(),{query:`{ ${n} }`});if(i.data.errors)throw new Error(i.data.errors[0].message);return i.data.data},j=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}},i=new FormData;i.append("operations",JSON.stringify({query:f.jsonToGraphQLQuery({mutation:n})})),i.append("map",JSON.stringify({0:["variables.file"]})),i.append("0",e);const o=await t.post(h(),i);if(o.data.errors)throw new Error(o.data.errors[0].message);return o.data.data.fsUploadTempFile}const N=(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,i=atob(n),o=new ArrayBuffer(i.length),l=new Uint8Array(o);for(let d=0;d<i.length;d++)l[d]=i.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 r="copy",c="convert";function g(e,t,n){if(t===r)return n;if(t===c)return e(n);if(t instanceof Array)return n.map(i=>g(e,t[0],i));if(t instanceof Object){const i={};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){i[o]=null;continue}i[o]=g(e,l.schema,n[o])}return i}}function b(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 A={type:a(r),id:a(c),transports:s(r)},C={appid:s(r),appidExclude:s(r),credProps:s(r)},q={appid:s(r),appidExclude:s(r),credProps:s(r)},_={publicKey:a({rp:a(r),user:a({id:a(c),name:a(r),displayName:a(r)}),challenge:a(c),pubKeyCredParams:a(r),timeout:s(r),excludeCredentials:s([A]),authenticatorSelection:s(r),attestation:s(r),extensions:s(C)}),signal:s(r)},T={type:a(r),id:a(r),rawId:a(c),authenticatorAttachment:s(r),response:a({clientDataJSON:a(c),attestationObject:a(c),transports:b(r,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:b(q,e=>e.getClientExtensionResults())},U={mediation:s(r),publicKey:a({challenge:a(c),timeout:s(r),rpId:s(r),allowCredentials:s([A]),userVerification:s(r),extensions:s(C)}),signal:s(r)},K={type:a(r),id:a(r),rawId:a(c),authenticatorAttachment:s(r),response:a({clientDataJSON:a(c),authenticatorData:a(c),signature:a(c),userHandle:a(c)}),clientExtensionResults:b(q,e=>e.getClientExtensionResults())};function D(e){return g(O,_,e)}function F(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=()=>F(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 m({webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,i=I({publicKey:n}),o=await L(i);await p("webAuthnAssertion",{username:e,assertion:o.toJSON()})}async function x(){const e=await m({webAuthnCreationOptions:!0}),t=D({publicKey:e.webAuthnCreationOptions}),n=await V(t);await p("webAuthnRegister",{registration:n.toJSON()})}u.getApiUrl=h,u.login=E,u.logout=R,u.mutation=p,u.query=m,u.sendMail=N,u.setApiUrl=j,u.toQuery=S,u.uploadFile=J,u.webauthnLogin=M,u.webauthnRegister=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/dist/query.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (q: Object) => Promise<any>;
|
|
1
|
+
declare const _default: (q: Object | Array<string | Object | string>) => Promise<any>;
|
|
2
2
|
export default _default;
|
package/dist/toQuery.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (query:
|
|
1
|
+
declare const _default: (query: Object | Array<string | Object> | string) => any;
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hostlink/light",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dev": "vite --host",
|
|
18
18
|
"build": "tsc && vite build",
|
|
19
19
|
"preview": "vite preview",
|
|
20
|
-
"release": "npm version patch && npm publish --access public && git push --follow-tags"
|
|
20
|
+
"release": "npm run build && npm version patch && npm publish --access public && git push --follow-tags"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^5.0.2",
|