@hostlink/light 0.0.18 → 0.0.20

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.
@@ -0,0 +1,3 @@
1
+ declare const setApiUrl: (url: string) => void;
2
+ declare const getApiUrl: () => string;
3
+ export { setApiUrl, getApiUrl };
@@ -0,0 +1,4 @@
1
+ import { AxiosInstance } from "axios";
2
+ declare const setAxios: (a: AxiosInstance) => void;
3
+ declare const getAxios: () => AxiosInstance;
4
+ export { setAxios, getAxios };
package/dist/index.d.ts CHANGED
@@ -3,11 +3,11 @@ import logout from './logout';
3
3
  import query from './query';
4
4
  import mutation from './mutation';
5
5
  import toQuery from './toQuery';
6
- import getApiUrl from './getApiUrl';
7
- import setApiUrl from './setApiUrl';
6
+ import { getApiUrl, setApiUrl } from './apiUrl';
8
7
  import uploadFile from './uploadFile';
9
8
  import sendMail from './sendMail';
9
+ import getConfig from './getConfig';
10
10
  import webauthnLogin from './webauthnLogin';
11
11
  import webauthnRegister from './webauthnRegister';
12
12
  export type Fields = Object | Array<string | Object> | string;
13
- export { toQuery, login, logout, query, mutation, getApiUrl, setApiUrl, uploadFile, sendMail, webauthnLogin, webauthnRegister, };
13
+ export { toQuery, login, logout, query, mutation, getApiUrl, setApiUrl, uploadFile, sendMail, webauthnLogin, webauthnRegister, getConfig };
package/dist/light.js CHANGED
@@ -1,29 +1,30 @@
1
- import { jsonToGraphQLQuery as w, VariableType as E } from "json-to-graphql-query";
2
- import h from "axios";
3
- const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : localStorage.getItem("light-api-url"), d = async (t, e = null, r = []) => {
4
- const n = h.create({
5
- withCredentials: !0
6
- }), i = {
1
+ import { jsonToGraphQLQuery as b, VariableType as x } from "json-to-graphql-query";
2
+ import R from "axios";
3
+ let d;
4
+ const m = () => (d || (d = R.create({
5
+ withCredentials: !0
6
+ })), d), f = async (t, e = null, r = []) => {
7
+ const n = {
7
8
  mutation: {}
8
9
  };
9
- i.mutation[t] = !0, e && (i.mutation[t] = {}, i.mutation[t].__args = e), r instanceof Array && r.length == 0 && (i.mutation[t] = {}), Object.entries(b(r)).forEach(([l, C]) => {
10
- i.mutation[t][l] = C;
10
+ n.mutation[t] = !0, r instanceof Array && r.length != 0 && (n.mutation[t] = {}), e && (n.mutation[t] = {}, n.mutation[t].__args = e), Object.entries(_(r)).forEach(([u, l]) => {
11
+ n.mutation[t][u] = l;
11
12
  });
12
- const u = await n.post(m(), {
13
- query: w(i)
13
+ const s = await m().post(y(), {
14
+ query: b(n)
14
15
  });
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", {
16
+ if (s.data.errors)
17
+ throw new Error(s.data.errors[0].message);
18
+ return s.data.data[t];
19
+ }, M = async (t, e, r = "") => await f("login", {
19
20
  username: t,
20
21
  password: e,
21
22
  code: r
22
- }), B = async () => await d("logout"), f = (t) => {
23
+ }), P = async () => await f("logout"), g = (t) => {
23
24
  let e = {};
24
25
  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;
26
+ Object.entries(g(r)).forEach(([n, s]) => {
27
+ e[n] = s;
27
28
  });
28
29
  }), e) : (Object.entries(t).forEach(([r, n]) => {
29
30
  if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
@@ -34,53 +35,56 @@ const m = () => localStorage.getItem("light-api-url") === null ? "/api/" : local
34
35
  e[r] = n;
35
36
  return;
36
37
  }
37
- e[r] = f(n);
38
+ e[r] = g(n);
38
39
  }), e);
39
- }, b = (t) => f(t), y = async (t) => {
40
- const e = h.create({
41
- withCredentials: !0
40
+ }, _ = (t) => g(t), h = async (t) => {
41
+ let e = b(_(t));
42
+ const r = await m().post(y(), {
43
+ query: `{ ${e} }`
42
44
  });
43
- let r = w(b(t));
44
- const n = await e.post(m(), {
45
- query: `{ ${r} }`
46
- });
47
- if (n.data.errors)
48
- throw new Error(n.data.errors[0].message);
49
- return n.data.data;
50
- }, M = (t) => {
51
- localStorage.setItem("light-api-url", t);
45
+ if (r.data.errors)
46
+ throw new Error(r.data.errors[0].message);
47
+ return r.data.data;
52
48
  };
53
- async function P(t) {
54
- const e = h.create({
55
- withCredentials: !0
56
- }), r = {
49
+ let O = "/api/";
50
+ const Q = (t) => {
51
+ O = t;
52
+ }, y = () => O;
53
+ async function L(t) {
54
+ const e = {
57
55
  __variables: {
58
56
  file: "Upload!"
59
57
  },
60
58
  fsUploadTempFile: {
61
59
  __args: {
62
- file: new E("file")
60
+ file: new x("file")
63
61
  },
64
62
  name: !0,
65
63
  path: !0,
66
64
  size: !0,
67
65
  mime: !0
68
66
  }
69
- }, n = new FormData();
70
- n.append("operations", JSON.stringify({
71
- query: w({ mutation: r })
72
- })), n.append("map", JSON.stringify({ 0: ["variables.file"] })), n.append("0", t);
73
- const i = await e.post(m(), n);
74
- if (i.data.errors)
75
- throw new Error(i.data.errors[0].message);
76
- return i.data.data.fsUploadTempFile;
67
+ }, r = new FormData();
68
+ r.append("operations", JSON.stringify({
69
+ query: b({ mutation: e })
70
+ })), r.append("map", JSON.stringify({ 0: ["variables.file"] })), r.append("0", t);
71
+ const n = await m().post(y(), r);
72
+ if (n.data.errors)
73
+ throw new Error(n.data.errors[0].message);
74
+ return n.data.data.fsUploadTempFile;
77
75
  }
78
- const Q = (t, e, r) => d("sendMail", { email: t, subject: e, message: r });
79
- function O(t) {
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);
76
+ const W = (t, e, r) => f("sendMail", { email: t, subject: e, message: r }), $ = async (t) => (await h({
77
+ config: {
78
+ __args: {
79
+ name: t
80
+ }
81
+ }
82
+ })).config;
83
+ function A(t) {
84
+ const e = "==".slice(0, (4 - t.length % 4) % 4), r = t.replace(/-/g, "+").replace(/_/g, "/") + e, n = atob(r), s = new ArrayBuffer(n.length), u = new Uint8Array(s);
81
85
  for (let l = 0; l < n.length; l++)
82
86
  u[l] = n.charCodeAt(l);
83
- return i;
87
+ return s;
84
88
  }
85
89
  function S(t) {
86
90
  const e = new Uint8Array(t);
@@ -102,86 +106,86 @@ function p(t, e, r) {
102
106
  return r.map((n) => p(t, e[0], n));
103
107
  if (e instanceof Object) {
104
108
  const n = {};
105
- for (const [i, u] of Object.entries(e)) {
109
+ for (const [s, u] of Object.entries(e)) {
106
110
  if (u.derive) {
107
111
  const l = u.derive(r);
108
- l !== void 0 && (r[i] = l);
112
+ l !== void 0 && (r[s] = l);
109
113
  }
110
- if (!(i in r)) {
114
+ if (!(s in r)) {
111
115
  if (u.required)
112
- throw new Error(`Missing key: ${i}`);
116
+ throw new Error(`Missing key: ${s}`);
113
117
  continue;
114
118
  }
115
- if (r[i] == null) {
116
- n[i] = null;
119
+ if (r[s] == null) {
120
+ n[s] = null;
117
121
  continue;
118
122
  }
119
- n[i] = p(
123
+ n[s] = p(
120
124
  t,
121
125
  u.schema,
122
- r[i]
126
+ r[s]
123
127
  );
124
128
  }
125
129
  return n;
126
130
  }
127
131
  }
128
- function g(t, e) {
132
+ function w(t, e) {
129
133
  return {
130
134
  required: !0,
131
135
  schema: t,
132
136
  derive: e
133
137
  };
134
138
  }
135
- function o(t) {
139
+ function i(t) {
136
140
  return {
137
141
  required: !0,
138
142
  schema: t
139
143
  };
140
144
  }
141
- function s(t) {
145
+ function o(t) {
142
146
  return {
143
147
  required: !1,
144
148
  schema: t
145
149
  };
146
150
  }
147
- var _ = {
148
- type: o(a),
149
- id: o(c),
150
- transports: s(a)
151
- }, v = {
152
- appid: s(a),
153
- appidExclude: s(a),
154
- credProps: s(a)
155
- }, A = {
156
- appid: s(a),
157
- appidExclude: s(a),
158
- credProps: s(a)
159
- }, R = {
160
- publicKey: o({
161
- rp: o(a),
162
- user: o({
163
- id: o(c),
164
- name: o(a),
165
- displayName: o(a)
151
+ var v = {
152
+ type: i(a),
153
+ id: i(c),
154
+ transports: o(a)
155
+ }, C = {
156
+ appid: o(a),
157
+ appidExclude: o(a),
158
+ credProps: o(a)
159
+ }, E = {
160
+ appid: o(a),
161
+ appidExclude: o(a),
162
+ credProps: o(a)
163
+ }, q = {
164
+ publicKey: i({
165
+ rp: i(a),
166
+ user: i({
167
+ id: i(c),
168
+ name: i(a),
169
+ displayName: i(a)
166
170
  }),
167
- challenge: o(c),
168
- pubKeyCredParams: o(a),
169
- timeout: s(a),
170
- excludeCredentials: s([_]),
171
- authenticatorSelection: s(a),
172
- attestation: s(a),
173
- extensions: s(v)
171
+ challenge: i(c),
172
+ pubKeyCredParams: i(a),
173
+ timeout: o(a),
174
+ excludeCredentials: o([v]),
175
+ authenticatorSelection: o(a),
176
+ attestation: o(a),
177
+ extensions: o(C)
174
178
  }),
175
- signal: s(a)
176
- }, q = {
177
- type: o(a),
178
- id: o(a),
179
- rawId: o(c),
180
- authenticatorAttachment: s(a),
181
- response: o({
182
- clientDataJSON: o(c),
183
- attestationObject: o(c),
184
- transports: g(
179
+ signal: o(a)
180
+ }, J = {
181
+ type: i(a),
182
+ id: i(a),
183
+ rawId: i(c),
184
+ authenticatorAttachment: o(a),
185
+ response: i({
186
+ clientDataJSON: i(c),
187
+ attestationObject: i(c),
188
+ transports: w(
185
189
  a,
186
190
  (t) => {
187
191
  var e;
@@ -189,102 +193,103 @@ var _ = {
189
193
  }
190
194
  )
191
195
  }),
192
- clientExtensionResults: g(
193
- A,
196
+ clientExtensionResults: w(
197
+ E,
194
198
  (t) => t.getClientExtensionResults()
195
199
  )
196
- }, x = {
197
- mediation: s(a),
198
- publicKey: o({
199
- challenge: o(c),
200
- timeout: s(a),
201
- rpId: s(a),
202
- allowCredentials: s([_]),
203
- userVerification: s(a),
204
- extensions: s(v)
200
+ }, N = {
201
+ mediation: o(a),
202
+ publicKey: i({
203
+ challenge: i(c),
204
+ timeout: o(a),
205
+ rpId: o(a),
206
+ allowCredentials: o([v]),
207
+ userVerification: o(a),
208
+ extensions: o(C)
205
209
  }),
206
- signal: s(a)
207
- }, J = {
208
- type: o(a),
209
- id: o(a),
210
- rawId: o(c),
211
- authenticatorAttachment: s(a),
212
- response: o({
213
- clientDataJSON: o(c),
214
- authenticatorData: o(c),
215
- signature: o(c),
216
- userHandle: o(c)
210
+ signal: o(a)
211
+ }, j = {
212
+ type: i(a),
213
+ id: i(a),
214
+ rawId: i(c),
215
+ authenticatorAttachment: o(a),
216
+ response: i({
217
+ clientDataJSON: i(c),
218
+ authenticatorData: i(c),
219
+ signature: i(c),
220
+ userHandle: i(c)
217
221
  }),
218
- clientExtensionResults: g(
219
- A,
222
+ clientExtensionResults: w(
223
+ E,
220
224
  (t) => t.getClientExtensionResults()
221
225
  )
222
226
  };
223
- function N(t) {
224
- return p(O, R, t);
227
+ function T(t) {
228
+ return p(A, q, t);
225
229
  }
226
- function j(t) {
230
+ function K(t) {
227
231
  return p(
228
232
  S,
229
- q,
233
+ J,
230
234
  t
231
235
  );
232
236
  }
233
- function T(t) {
234
- return p(O, x, t);
237
+ function U(t) {
238
+ return p(A, N, t);
235
239
  }
236
- function K(t) {
240
+ function D(t) {
237
241
  return p(
238
242
  S,
239
- J,
243
+ j,
240
244
  t
241
245
  );
242
246
  }
243
- async function U(t) {
247
+ async function F(t) {
244
248
  const e = await navigator.credentials.create(
245
249
  t
246
250
  );
247
- return e.toJSON = () => j(e), e;
251
+ return e.toJSON = () => K(e), e;
248
252
  }
249
- async function D(t) {
253
+ async function V(t) {
250
254
  const e = await navigator.credentials.get(
251
255
  t
252
256
  );
253
- return e.toJSON = () => K(e), e;
257
+ return e.toJSON = () => D(e), e;
254
258
  }
255
- async function L(t) {
256
- const r = (await y({
259
+ async function z(t) {
260
+ const r = (await h({
257
261
  webAuthnRequestOptions: {
258
262
  __args: {
259
263
  username: t
260
264
  }
261
265
  }
262
- })).webAuthnRequestOptions, n = T({
266
+ })).webAuthnRequestOptions, n = U({
263
267
  publicKey: r
264
- }), i = await D(n);
265
- await d("webAuthnAssertion", {
268
+ }), s = await V(n);
269
+ await f("webAuthnAssertion", {
266
270
  username: t,
267
- assertion: i.toJSON()
271
+ assertion: s.toJSON()
268
272
  });
269
273
  }
270
- async function W() {
271
- const t = await y({ webAuthnCreationOptions: !0 }), e = N({
274
+ async function G() {
275
+ const t = await h({ webAuthnCreationOptions: !0 }), e = T({
272
276
  publicKey: t.webAuthnCreationOptions
273
- }), r = await U(e);
274
- await d("webAuthnRegister", {
277
+ }), r = await F(e);
278
+ await f("webAuthnRegister", {
275
279
  registration: r.toJSON()
276
280
  });
277
281
  }
278
282
  export {
279
- m as getApiUrl,
280
- V as login,
281
- B as logout,
282
- d as mutation,
283
- y as query,
284
- Q as sendMail,
285
- M as setApiUrl,
286
- b as toQuery,
287
- P as uploadFile,
288
- L as webauthnLogin,
289
- W as webauthnRegister
283
+ y as getApiUrl,
284
+ $ as getConfig,
285
+ M as login,
286
+ P as logout,
287
+ f as mutation,
288
+ h as query,
289
+ W as sendMail,
290
+ Q as setApiUrl,
291
+ _ as toQuery,
292
+ L as uploadFile,
293
+ z as webauthnLogin,
294
+ G as webauthnRegister
290
295
  };
@@ -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 r=w.create({withCredentials:!0}),o={mutation:{}};o.mutation[e]=!0,t&&(o.mutation[e]={},o.mutation[e].__args=t),n instanceof Array&&n.length==0&&(o.mutation[e]={}),Object.entries(m(n)).forEach(([d,P])=>{o.mutation[e][d]=P});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"),b=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(n=>{Object.entries(b(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]=b(r)}),t)},m=e=>b(e),y=async e=>{const t=w.create({withCredentials:!0});let n=f.jsonToGraphQLQuery(m(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 S(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 O(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:O(i,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:O(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:O(C,e=>e.getClientExtensionResults())};function F(e){return g(S,N,e)}function D(e){return g(v,T,e)}function I(e){return g(S,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 y({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 y({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=y,u.sendMail=J,u.setApiUrl=R,u.toQuery=m,u.uploadFile=j,u.webauthnLogin=M,u.webauthnRegister=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.light={},s.jsonToGraphqlQuery,s.axios))})(this,function(s,d,R){"use strict";let y;const b=()=>(y||(y=R.create({withCredentials:!0})),y),p=async(t,e=null,n=[])=>{const r={mutation:{}};r.mutation[t]=!0,n instanceof Array&&n.length!=0&&(r.mutation[t]={}),e&&(r.mutation[t]={},r.mutation[t].__args=e),Object.entries(_(n)).forEach(([l,f])=>{r.mutation[t][l]=f});const u=await b().post(w(),{query:d.jsonToGraphQLQuery(r)});if(u.data.errors)throw new Error(u.data.errors[0].message);return u.data.data[t]},j=async(t,e,n="")=>await p("login",{username:t,password:e,code:n}),J=async()=>await p("logout"),m=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(n=>{Object.entries(m(n)).forEach(([r,u])=>{e[r]=u})}),e):(Object.entries(t).forEach(([n,r])=>{if(n=="__args"||n=="__aliasFor"||n=="__variables"||n=="__directives"||n=="__all_on"||n=="__name"){e[n]=r;return}if(typeof r=="boolean"){e[n]=r;return}e[n]=m(r)}),e)},_=t=>m(t),h=async t=>{let e=d.jsonToGraphQLQuery(_(t));const n=await b().post(w(),{query:`{ ${e} }`});if(n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};let A="/api/";const N=t=>{A=t},w=()=>A;async function T(t){const e={__variables:{file:"Upload!"},fsUploadTempFile:{__args:{file:new d.VariableType("file")},name:!0,path:!0,size:!0,mime:!0}},n=new FormData;n.append("operations",JSON.stringify({query:d.jsonToGraphQLQuery({mutation:e})})),n.append("map",JSON.stringify({0:["variables.file"]})),n.append("0",t);const r=await b().post(w(),n);if(r.data.errors)throw new Error(r.data.errors[0].message);return r.data.data.fsUploadTempFile}const U=(t,e,n)=>p("sendMail",{email:t,subject:e,message:n}),K=async t=>(await h({config:{__args:{name:t}}})).config;function S(t){const e="==".slice(0,(4-t.length%4)%4),n=t.replace(/-/g,"+").replace(/_/g,"/")+e,r=atob(n),u=new ArrayBuffer(r.length),l=new Uint8Array(u);for(let f=0;f<r.length;f++)l[f]=r.charCodeAt(f);return u}function v(t){const e=new Uint8Array(t);let n="";for(const l of e)n+=String.fromCharCode(l);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var i="copy",c="convert";function g(t,e,n){if(e===i)return n;if(e===c)return t(n);if(e instanceof Array)return n.map(r=>g(t,e[0],r));if(e instanceof Object){const r={};for(const[u,l]of Object.entries(e)){if(l.derive){const f=l.derive(n);f!==void 0&&(n[u]=f)}if(!(u in n)){if(l.required)throw new Error(`Missing key: ${u}`);continue}if(n[u]==null){r[u]=null;continue}r[u]=g(t,l.schema,n[u])}return r}}function O(t,e){return{required:!0,schema:t,derive:e}}function a(t){return{required:!0,schema:t}}function o(t){return{required:!1,schema:t}}var C={type:a(i),id:a(c),transports:o(i)},q={appid:o(i),appidExclude:o(i),credProps:o(i)},E={appid:o(i),appidExclude:o(i),credProps:o(i)},x={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([C]),authenticatorSelection:o(i),attestation:o(i),extensions:o(q)}),signal:o(i)},F={type:a(i),id:a(i),rawId:a(c),authenticatorAttachment:o(i),response:a({clientDataJSON:a(c),attestationObject:a(c),transports:O(i,t=>{var e;return((e=t.getTransports)==null?void 0:e.call(t))||[]})}),clientExtensionResults:O(E,t=>t.getClientExtensionResults())},D={mediation:o(i),publicKey:a({challenge:a(c),timeout:o(i),rpId:o(i),allowCredentials:o([C]),userVerification:o(i),extensions:o(q)}),signal:o(i)},Q={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:O(E,t=>t.getClientExtensionResults())};function V(t){return g(S,x,t)}function L(t){return g(v,F,t)}function M(t){return g(S,D,t)}function P(t){return g(v,Q,t)}async function B(t){const e=await navigator.credentials.create(t);return e.toJSON=()=>L(e),e}async function I(t){const e=await navigator.credentials.get(t);return e.toJSON=()=>P(e),e}async function W(t){const n=(await h({webAuthnRequestOptions:{__args:{username:t}}})).webAuthnRequestOptions,r=M({publicKey:n}),u=await I(r);await p("webAuthnAssertion",{username:t,assertion:u.toJSON()})}async function $(){const t=await h({webAuthnCreationOptions:!0}),e=V({publicKey:t.webAuthnCreationOptions}),n=await B(e);await p("webAuthnRegister",{registration:n.toJSON()})}s.getApiUrl=w,s.getConfig=K,s.login=j,s.logout=J,s.mutation=p,s.query=h,s.sendMail=U,s.setApiUrl=N,s.toQuery=_,s.uploadFile=T,s.webauthnLogin=W,s.webauthnRegister=$,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -17,12 +17,14 @@
17
17
  "dev": "vite --host",
18
18
  "build": "tsc && vite build",
19
19
  "preview": "vite preview",
20
- "release": "npm run build && 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
+ "test": "vitest"
21
22
  },
22
23
  "devDependencies": {
23
24
  "typescript": "^5.0.2",
24
25
  "vite": "^4.3.0",
25
- "vite-plugin-dts": "^3.6.0"
26
+ "vite-plugin-dts": "^3.6.0",
27
+ "vitest": "^0.34.6"
26
28
  },
27
29
  "dependencies": {
28
30
  "@github/webauthn-json": "^2.1.1",
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;