@hostlink/light 0.0.15 → 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 +55 -55
- package/dist/light.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/light.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsonToGraphQLQuery as w, VariableType as C } 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
|
-
const
|
|
4
|
+
const n = h.create({
|
|
5
5
|
withCredentials: !0
|
|
6
6
|
}), i = {
|
|
7
7
|
mutation: {}
|
|
@@ -9,7 +9,7 @@ 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 u = await
|
|
12
|
+
const u = await n.post(m(), {
|
|
13
13
|
query: w(i)
|
|
14
14
|
});
|
|
15
15
|
if (u.data.errors)
|
|
@@ -22,27 +22,27 @@ const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : local
|
|
|
22
22
|
}), F = 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
|
-
Object.entries(f(r)).forEach(([
|
|
26
|
-
e[
|
|
25
|
+
Object.entries(f(r)).forEach(([n, i]) => {
|
|
26
|
+
e[n] = i;
|
|
27
27
|
});
|
|
28
|
-
}), e) : (Object.entries(t).forEach(([r,
|
|
28
|
+
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
29
29
|
if (r == "__args") {
|
|
30
|
-
e[r] =
|
|
30
|
+
e[r] = n;
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
e[r] = f(
|
|
33
|
+
n === !0 ? e[r] = !0 : e[r] = f(n);
|
|
34
34
|
}), e);
|
|
35
35
|
}, E = (t) => f(t), y = async (t) => {
|
|
36
36
|
const e = h.create({
|
|
37
37
|
withCredentials: !0
|
|
38
38
|
});
|
|
39
39
|
let r = w(E(t));
|
|
40
|
-
const
|
|
40
|
+
const n = await e.post(m(), {
|
|
41
41
|
query: `{ ${r} }`
|
|
42
42
|
});
|
|
43
|
-
if (
|
|
44
|
-
throw new Error(
|
|
45
|
-
return
|
|
43
|
+
if (n.data.errors)
|
|
44
|
+
throw new Error(n.data.errors[0].message);
|
|
45
|
+
return n.data.data;
|
|
46
46
|
}, B = (t) => {
|
|
47
47
|
localStorage.setItem("light-api-url", t);
|
|
48
48
|
};
|
|
@@ -62,20 +62,20 @@ async function M(t) {
|
|
|
62
62
|
size: !0,
|
|
63
63
|
mime: !0
|
|
64
64
|
}
|
|
65
|
-
},
|
|
66
|
-
|
|
65
|
+
}, n = new FormData();
|
|
66
|
+
n.append("operations", JSON.stringify({
|
|
67
67
|
query: w({ mutation: r })
|
|
68
|
-
})),
|
|
69
|
-
const i = await e.post(m(),
|
|
68
|
+
})), n.append("map", JSON.stringify({ 0: ["variables.file"] })), n.append("0", t);
|
|
69
|
+
const i = await e.post(m(), n);
|
|
70
70
|
if (i.data.errors)
|
|
71
71
|
throw new Error(i.data.errors[0].message);
|
|
72
72
|
return i.data.data.fsUploadTempFile;
|
|
73
73
|
}
|
|
74
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,
|
|
77
|
-
for (let l = 0; l <
|
|
78
|
-
u[l] =
|
|
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
|
+
for (let l = 0; l < n.length; l++)
|
|
78
|
+
u[l] = n.charCodeAt(l);
|
|
79
79
|
return i;
|
|
80
80
|
}
|
|
81
81
|
function O(t) {
|
|
@@ -88,16 +88,16 @@ function O(t) {
|
|
|
88
88
|
"_"
|
|
89
89
|
).replace(/=/g, "");
|
|
90
90
|
}
|
|
91
|
-
var
|
|
91
|
+
var a = "copy", c = "convert";
|
|
92
92
|
function p(t, e, r) {
|
|
93
|
-
if (e ===
|
|
93
|
+
if (e === a)
|
|
94
94
|
return r;
|
|
95
95
|
if (e === c)
|
|
96
96
|
return t(r);
|
|
97
97
|
if (e instanceof Array)
|
|
98
|
-
return r.map((
|
|
98
|
+
return r.map((n) => p(t, e[0], n));
|
|
99
99
|
if (e instanceof Object) {
|
|
100
|
-
const
|
|
100
|
+
const n = {};
|
|
101
101
|
for (const [i, u] of Object.entries(e)) {
|
|
102
102
|
if (u.derive) {
|
|
103
103
|
const l = u.derive(r);
|
|
@@ -109,16 +109,16 @@ function p(t, e, r) {
|
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
111
111
|
if (r[i] == null) {
|
|
112
|
-
|
|
112
|
+
n[i] = null;
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
n[i] = p(
|
|
116
116
|
t,
|
|
117
117
|
u.schema,
|
|
118
118
|
r[i]
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return n;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
function g(t, e) {
|
|
@@ -141,44 +141,44 @@ function s(t) {
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
var S = {
|
|
144
|
-
type: o(
|
|
144
|
+
type: o(a),
|
|
145
145
|
id: o(c),
|
|
146
|
-
transports: s(
|
|
146
|
+
transports: s(a)
|
|
147
147
|
}, v = {
|
|
148
|
-
appid: s(
|
|
149
|
-
appidExclude: s(
|
|
150
|
-
credProps: s(
|
|
148
|
+
appid: s(a),
|
|
149
|
+
appidExclude: s(a),
|
|
150
|
+
credProps: s(a)
|
|
151
151
|
}, A = {
|
|
152
|
-
appid: s(
|
|
153
|
-
appidExclude: s(
|
|
154
|
-
credProps: s(
|
|
152
|
+
appid: s(a),
|
|
153
|
+
appidExclude: s(a),
|
|
154
|
+
credProps: s(a)
|
|
155
155
|
}, R = {
|
|
156
156
|
publicKey: o({
|
|
157
|
-
rp: o(
|
|
157
|
+
rp: o(a),
|
|
158
158
|
user: o({
|
|
159
159
|
id: o(c),
|
|
160
|
-
name: o(
|
|
161
|
-
displayName: o(
|
|
160
|
+
name: o(a),
|
|
161
|
+
displayName: o(a)
|
|
162
162
|
}),
|
|
163
163
|
challenge: o(c),
|
|
164
|
-
pubKeyCredParams: o(
|
|
165
|
-
timeout: s(
|
|
164
|
+
pubKeyCredParams: o(a),
|
|
165
|
+
timeout: s(a),
|
|
166
166
|
excludeCredentials: s([S]),
|
|
167
|
-
authenticatorSelection: s(
|
|
168
|
-
attestation: s(
|
|
167
|
+
authenticatorSelection: s(a),
|
|
168
|
+
attestation: s(a),
|
|
169
169
|
extensions: s(v)
|
|
170
170
|
}),
|
|
171
|
-
signal: s(
|
|
171
|
+
signal: s(a)
|
|
172
172
|
}, q = {
|
|
173
|
-
type: o(
|
|
174
|
-
id: o(
|
|
173
|
+
type: o(a),
|
|
174
|
+
id: o(a),
|
|
175
175
|
rawId: o(c),
|
|
176
|
-
authenticatorAttachment: s(
|
|
176
|
+
authenticatorAttachment: s(a),
|
|
177
177
|
response: o({
|
|
178
178
|
clientDataJSON: o(c),
|
|
179
179
|
attestationObject: o(c),
|
|
180
180
|
transports: g(
|
|
181
|
-
|
|
181
|
+
a,
|
|
182
182
|
(t) => {
|
|
183
183
|
var e;
|
|
184
184
|
return ((e = t.getTransports) == null ? void 0 : e.call(t)) || [];
|
|
@@ -190,21 +190,21 @@ var S = {
|
|
|
190
190
|
(t) => t.getClientExtensionResults()
|
|
191
191
|
)
|
|
192
192
|
}, x = {
|
|
193
|
-
mediation: s(
|
|
193
|
+
mediation: s(a),
|
|
194
194
|
publicKey: o({
|
|
195
195
|
challenge: o(c),
|
|
196
|
-
timeout: s(
|
|
197
|
-
rpId: s(
|
|
196
|
+
timeout: s(a),
|
|
197
|
+
rpId: s(a),
|
|
198
198
|
allowCredentials: s([S]),
|
|
199
|
-
userVerification: s(
|
|
199
|
+
userVerification: s(a),
|
|
200
200
|
extensions: s(v)
|
|
201
201
|
}),
|
|
202
|
-
signal: s(
|
|
202
|
+
signal: s(a)
|
|
203
203
|
}, J = {
|
|
204
|
-
type: o(
|
|
205
|
-
id: o(
|
|
204
|
+
type: o(a),
|
|
205
|
+
id: o(a),
|
|
206
206
|
rawId: o(c),
|
|
207
|
-
authenticatorAttachment: s(
|
|
207
|
+
authenticatorAttachment: s(a),
|
|
208
208
|
response: o({
|
|
209
209
|
clientDataJSON: o(c),
|
|
210
210
|
authenticatorData: o(c),
|
|
@@ -255,9 +255,9 @@ async function Q(t) {
|
|
|
255
255
|
username: t
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
})).webAuthnRequestOptions,
|
|
258
|
+
})).webAuthnRequestOptions, n = j({
|
|
259
259
|
publicKey: r
|
|
260
|
-
}), i = await U(
|
|
260
|
+
}), i = await U(n);
|
|
261
261
|
await d("webAuthnAssertion", {
|
|
262
262
|
username: t,
|
|
263
263
|
assertion: i.toJSON()
|
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,
|
|
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/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",
|