has_secure_passkey 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/components/web_authn.js +2 -3
- data/app/assets/javascripts/has_secure_passkey.js +89 -106
- data/lib/has_secure_passkey/version.rb +1 -1
- metadata +2 -4
- data/app/assets/javascripts/@github--webauthn-json.js +0 -1
- data/app/assets/javascripts/@rails--request.js +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d4e249f4c8a171cf5aa0675aeca1af7e2c7940ae5e2a06acaa852d9ecc6d4a
|
4
|
+
data.tar.gz: edfdfcf82e4cf95027ec39ba1e0f1260bb4ec96752ba6b467129d9f7e2d5512f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f5b84cfcb632fcbae5ce4b1c23b6826274766983f61e9cea6ea172911677bbf53589a978658ef869e098f1205bf1355cbba1c1f4b3ae89f9ad6fa96d139576
|
7
|
+
data.tar.gz: 0e7f79e4a319b9f0d01a77d1960898e11264f40cc5cf1a62ccd0b6477f308565647a4d1fc11a536ae5229127f96c8e427ab03a458d4085d8c2bf17bb2d8add96
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as WebAuthnJSON from "
|
2
|
-
import { post } from "
|
1
|
+
import * as WebAuthnJSON from "@github/webauthn-json"
|
2
|
+
import { post } from "@rails/request"
|
3
3
|
|
4
4
|
export default class WebAuthn extends HTMLElement {
|
5
5
|
static observedAttributes = ["action", "callback", "options"];
|
@@ -10,7 +10,6 @@ export default class WebAuthn extends HTMLElement {
|
|
10
10
|
|
11
11
|
connectedCallback() {
|
12
12
|
this.progressBar = Turbo.navigator.delegate.adapter.progressBar
|
13
|
-
this.style.display = "none"
|
14
13
|
this.setAttribute("data-turbo-temporary", 1)
|
15
14
|
this.setAttribute("data-turbo-track", "reload")
|
16
15
|
this.run()
|
@@ -12,28 +12,12 @@ var __export = (target, all) => {
|
|
12
12
|
// app/assets/javascripts/@github--webauthn-json.js
|
13
13
|
var exports__github_webauthn_json = {};
|
14
14
|
__export(exports__github_webauthn_json, {
|
15
|
-
supported: () =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
},
|
20
|
-
schema: () => {
|
21
|
-
{
|
22
|
-
return c;
|
23
|
-
}
|
24
|
-
},
|
25
|
-
get: () => {
|
26
|
-
{
|
27
|
-
return get;
|
28
|
-
}
|
29
|
-
},
|
30
|
-
create: () => {
|
31
|
-
{
|
32
|
-
return create;
|
33
|
-
}
|
34
|
-
}
|
15
|
+
supported: () => supported,
|
16
|
+
schema: () => c,
|
17
|
+
get: () => get,
|
18
|
+
create: () => create
|
35
19
|
});
|
36
|
-
|
20
|
+
function base64urlToBuffer(e) {
|
37
21
|
const r = "==".slice(0, (4 - e.length % 4) % 4);
|
38
22
|
const t = e.replace(/-/g, "+").replace(/_/g, "/") + r;
|
39
23
|
const n = atob(t);
|
@@ -42,8 +26,8 @@ var base64urlToBuffer = function(e) {
|
|
42
26
|
for (let e2 = 0;e2 < n.length; e2++)
|
43
27
|
o[e2] = n.charCodeAt(e2);
|
44
28
|
return i;
|
45
|
-
}
|
46
|
-
|
29
|
+
}
|
30
|
+
function bufferToBase64url(e) {
|
47
31
|
const r = new Uint8Array(e);
|
48
32
|
let t = "";
|
49
33
|
for (const e2 of r)
|
@@ -51,63 +35,40 @@ var bufferToBase64url = function(e) {
|
|
51
35
|
const n = btoa(t);
|
52
36
|
const i = n.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
53
37
|
return i;
|
54
|
-
}
|
55
|
-
var
|
38
|
+
}
|
39
|
+
var e = "copy";
|
40
|
+
var r = "convert";
|
41
|
+
function convert(t, n, i) {
|
56
42
|
if (n === e)
|
57
43
|
return i;
|
58
44
|
if (n === r)
|
59
45
|
return t(i);
|
60
46
|
if (n instanceof Array)
|
61
|
-
return i.map((
|
47
|
+
return i.map((e2) => convert(t, n[0], e2));
|
62
48
|
if (n instanceof Object) {
|
63
|
-
const
|
64
|
-
for (const [
|
49
|
+
const e2 = {};
|
50
|
+
for (const [r2, o] of Object.entries(n)) {
|
65
51
|
if (o.derive) {
|
66
|
-
const
|
67
|
-
|
52
|
+
const e3 = o.derive(i);
|
53
|
+
e3 !== undefined && (i[r2] = e3);
|
68
54
|
}
|
69
|
-
if (
|
70
|
-
i[
|
55
|
+
if (r2 in i)
|
56
|
+
i[r2] != null ? e2[r2] = convert(t, o.schema, i[r2]) : e2[r2] = null;
|
71
57
|
else if (o.required)
|
72
|
-
throw new Error(`Missing key: ${
|
58
|
+
throw new Error(`Missing key: ${r2}`);
|
73
59
|
}
|
74
|
-
return
|
60
|
+
return e2;
|
75
61
|
}
|
76
|
-
};
|
77
|
-
var derived = function(e, r) {
|
78
|
-
return { required: true, schema: e, derive: r };
|
79
|
-
};
|
80
|
-
var required = function(e) {
|
81
|
-
return { required: true, schema: e };
|
82
|
-
};
|
83
|
-
var optional = function(e) {
|
84
|
-
return { required: false, schema: e };
|
85
|
-
};
|
86
|
-
var createRequestFromJSON = function(e) {
|
87
|
-
return convert(base64urlToBuffer, o, e);
|
88
|
-
};
|
89
|
-
var createResponseToJSON = function(e) {
|
90
|
-
return convert(bufferToBase64url, a, e);
|
91
|
-
};
|
92
|
-
async function create(e) {
|
93
|
-
const r = await navigator.credentials.create(createRequestFromJSON(e));
|
94
|
-
return createResponseToJSON(r);
|
95
62
|
}
|
96
|
-
|
97
|
-
return
|
98
|
-
}
|
99
|
-
|
100
|
-
return
|
101
|
-
}
|
102
|
-
|
103
|
-
|
104
|
-
return getResponseToJSON(r);
|
63
|
+
function derived(e2, r2) {
|
64
|
+
return { required: true, schema: e2, derive: r2 };
|
65
|
+
}
|
66
|
+
function required(e2) {
|
67
|
+
return { required: true, schema: e2 };
|
68
|
+
}
|
69
|
+
function optional(e2) {
|
70
|
+
return { required: false, schema: e2 };
|
105
71
|
}
|
106
|
-
var supported = function() {
|
107
|
-
return !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential);
|
108
|
-
};
|
109
|
-
var e = "copy";
|
110
|
-
var r = "convert";
|
111
72
|
var t = { type: required(e), id: required(r), transports: optional(e) };
|
112
73
|
var n = { appid: optional(e), appidExclude: optional(e), credProps: optional(e) };
|
113
74
|
var i = { appid: optional(e), appidExclude: optional(e), credProps: optional(e) };
|
@@ -119,46 +80,31 @@ var a = { type: required(e), id: required(e), rawId: required(r), authenticatorA
|
|
119
80
|
var u = { mediation: optional(e), publicKey: required({ challenge: required(r), timeout: optional(e), rpId: optional(e), allowCredentials: optional([t]), userVerification: optional(e), extensions: optional(n) }), signal: optional(e) };
|
120
81
|
var s = { type: required(e), id: required(e), rawId: required(r), authenticatorAttachment: optional(e), response: required({ clientDataJSON: required(r), authenticatorData: required(r), signature: required(r), userHandle: required(r) }), clientExtensionResults: derived(i, (e2) => e2.getClientExtensionResults()) };
|
121
82
|
var c = { credentialCreationOptions: o, publicKeyCredentialWithAttestation: a, credentialRequestOptions: u, publicKeyCredentialWithAssertion: s };
|
83
|
+
function createRequestFromJSON(e2) {
|
84
|
+
return convert(base64urlToBuffer, o, e2);
|
85
|
+
}
|
86
|
+
function createResponseToJSON(e2) {
|
87
|
+
return convert(bufferToBase64url, a, e2);
|
88
|
+
}
|
89
|
+
async function create(e2) {
|
90
|
+
const r2 = await navigator.credentials.create(createRequestFromJSON(e2));
|
91
|
+
return createResponseToJSON(r2);
|
92
|
+
}
|
93
|
+
function getRequestFromJSON(e2) {
|
94
|
+
return convert(base64urlToBuffer, u, e2);
|
95
|
+
}
|
96
|
+
function getResponseToJSON(e2) {
|
97
|
+
return convert(bufferToBase64url, s, e2);
|
98
|
+
}
|
99
|
+
async function get(e2) {
|
100
|
+
const r2 = await navigator.credentials.get(getRequestFromJSON(e2));
|
101
|
+
return getResponseToJSON(r2);
|
102
|
+
}
|
103
|
+
function supported() {
|
104
|
+
return !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential);
|
105
|
+
}
|
122
106
|
|
123
107
|
// app/assets/javascripts/@rails--request.js
|
124
|
-
var getCookie = function(t2) {
|
125
|
-
const e2 = document.cookie ? document.cookie.split("; ") : [];
|
126
|
-
const n2 = `${encodeURIComponent(t2)}=`;
|
127
|
-
const s2 = e2.find((t3) => t3.startsWith(n2));
|
128
|
-
if (s2) {
|
129
|
-
const t3 = s2.split("=").slice(1).join("=");
|
130
|
-
if (t3)
|
131
|
-
return decodeURIComponent(t3);
|
132
|
-
}
|
133
|
-
};
|
134
|
-
var compact = function(t2) {
|
135
|
-
const e2 = {};
|
136
|
-
for (const n2 in t2) {
|
137
|
-
const s2 = t2[n2];
|
138
|
-
s2 !== undefined && (e2[n2] = s2);
|
139
|
-
}
|
140
|
-
return e2;
|
141
|
-
};
|
142
|
-
var metaContent = function(t2) {
|
143
|
-
const e2 = document.head.querySelector(`meta[name="${t2}"]`);
|
144
|
-
return e2 && e2.content;
|
145
|
-
};
|
146
|
-
var stringEntriesFromFormData = function(t2) {
|
147
|
-
return [...t2].reduce((t3, [e2, n2]) => t3.concat(typeof n2 === "string" ? [[e2, n2]] : []), []);
|
148
|
-
};
|
149
|
-
var mergeEntries = function(t2, e2) {
|
150
|
-
for (const [n2, s2] of e2)
|
151
|
-
if (!(s2 instanceof window.File))
|
152
|
-
if (t2.has(n2) && !n2.includes("[]")) {
|
153
|
-
t2.delete(n2);
|
154
|
-
t2.set(n2, s2);
|
155
|
-
} else
|
156
|
-
t2.append(n2, s2);
|
157
|
-
};
|
158
|
-
async function post(t2, e2) {
|
159
|
-
const n2 = new FetchRequest("post", t2, e2);
|
160
|
-
return n2.perform();
|
161
|
-
}
|
162
108
|
class FetchResponse {
|
163
109
|
constructor(t2) {
|
164
110
|
this.response = t2;
|
@@ -233,6 +179,40 @@ class RequestInterceptor {
|
|
233
179
|
this.interceptor = undefined;
|
234
180
|
}
|
235
181
|
}
|
182
|
+
function getCookie(t2) {
|
183
|
+
const e2 = document.cookie ? document.cookie.split("; ") : [];
|
184
|
+
const n2 = `${encodeURIComponent(t2)}=`;
|
185
|
+
const s2 = e2.find((t3) => t3.startsWith(n2));
|
186
|
+
if (s2) {
|
187
|
+
const t3 = s2.split("=").slice(1).join("=");
|
188
|
+
if (t3)
|
189
|
+
return decodeURIComponent(t3);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
function compact(t2) {
|
193
|
+
const e2 = {};
|
194
|
+
for (const n2 in t2) {
|
195
|
+
const s2 = t2[n2];
|
196
|
+
s2 !== undefined && (e2[n2] = s2);
|
197
|
+
}
|
198
|
+
return e2;
|
199
|
+
}
|
200
|
+
function metaContent(t2) {
|
201
|
+
const e2 = document.head.querySelector(`meta[name="${t2}"]`);
|
202
|
+
return e2 && e2.content;
|
203
|
+
}
|
204
|
+
function stringEntriesFromFormData(t2) {
|
205
|
+
return [...t2].reduce((t3, [e2, n2]) => t3.concat(typeof n2 === "string" ? [[e2, n2]] : []), []);
|
206
|
+
}
|
207
|
+
function mergeEntries(t2, e2) {
|
208
|
+
for (const [n2, s2] of e2)
|
209
|
+
if (!(s2 instanceof window.File))
|
210
|
+
if (t2.has(n2) && !n2.includes("[]")) {
|
211
|
+
t2.delete(n2);
|
212
|
+
t2.set(n2, s2);
|
213
|
+
} else
|
214
|
+
t2.append(n2, s2);
|
215
|
+
}
|
236
216
|
|
237
217
|
class FetchRequest {
|
238
218
|
constructor(t2, e2, n2 = {}) {
|
@@ -334,6 +314,10 @@ class FetchRequest {
|
|
334
314
|
return e2 && !t2 ? JSON.stringify(this.body) : this.body;
|
335
315
|
}
|
336
316
|
}
|
317
|
+
async function post(t2, e2) {
|
318
|
+
const n2 = new FetchRequest("post", t2, e2);
|
319
|
+
return n2.perform();
|
320
|
+
}
|
337
321
|
|
338
322
|
// app/assets/javascripts/components/web_authn.js
|
339
323
|
class WebAuthn extends HTMLElement {
|
@@ -343,7 +327,6 @@ class WebAuthn extends HTMLElement {
|
|
343
327
|
}
|
344
328
|
connectedCallback() {
|
345
329
|
this.progressBar = Turbo.navigator.delegate.adapter.progressBar;
|
346
|
-
this.style.display = "none";
|
347
330
|
this.setAttribute("data-turbo-temporary", 1);
|
348
331
|
this.setAttribute("data-turbo-track", "reload");
|
349
332
|
this.run();
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_secure_passkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-11-
|
10
|
+
date: 2024-11-07 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -46,8 +46,6 @@ files:
|
|
46
46
|
- MIT-LICENSE
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
|
-
- app/assets/javascripts/@github--webauthn-json.js
|
50
|
-
- app/assets/javascripts/@rails--request.js
|
51
49
|
- app/assets/javascripts/components/has_secure_passkey.js
|
52
50
|
- app/assets/javascripts/components/web_authn.js
|
53
51
|
- app/assets/javascripts/has_secure_passkey.js
|
@@ -1 +0,0 @@
|
|
1
|
-
function base64urlToBuffer(e){const r="==".slice(0,(4-e.length%4)%4);const t=e.replace(/-/g,"+").replace(/_/g,"/")+r;const n=atob(t);const i=new ArrayBuffer(n.length);const o=new Uint8Array(i);for(let e=0;e<n.length;e++)o[e]=n.charCodeAt(e);return i}function bufferToBase64url(e){const r=new Uint8Array(e);let t="";for(const e of r)t+=String.fromCharCode(e);const n=btoa(t);const i=n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return i}var e="copy";var r="convert";function convert(t,n,i){if(n===e)return i;if(n===r)return t(i);if(n instanceof Array)return i.map((e=>convert(t,n[0],e)));if(n instanceof Object){const e={};for(const[r,o]of Object.entries(n)){if(o.derive){const e=o.derive(i);void 0!==e&&(i[r]=e)}if(r in i)null!=i[r]?e[r]=convert(t,o.schema,i[r]):e[r]=null;else if(o.required)throw new Error(`Missing key: ${r}`)}return e}}function derived(e,r){return{required:true,schema:e,derive:r}}function required(e){return{required:true,schema:e}}function optional(e){return{required:false,schema:e}}var t={type:required(e),id:required(r),transports:optional(e)};var n={appid:optional(e),appidExclude:optional(e),credProps:optional(e)};var i={appid:optional(e),appidExclude:optional(e),credProps:optional(e)};var o={publicKey:required({rp:required(e),user:required({id:required(r),name:required(e),displayName:required(e)}),challenge:required(r),pubKeyCredParams:required(e),timeout:optional(e),excludeCredentials:optional([t]),authenticatorSelection:optional(e),attestation:optional(e),extensions:optional(n)}),signal:optional(e)};var a={type:required(e),id:required(e),rawId:required(r),authenticatorAttachment:optional(e),response:required({clientDataJSON:required(r),attestationObject:required(r),transports:derived(e,(e=>{var r;return(null==(r=e.getTransports)?void 0:r.call(e))||[]}))}),clientExtensionResults:derived(i,(e=>e.getClientExtensionResults()))};var u={mediation:optional(e),publicKey:required({challenge:required(r),timeout:optional(e),rpId:optional(e),allowCredentials:optional([t]),userVerification:optional(e),extensions:optional(n)}),signal:optional(e)};var s={type:required(e),id:required(e),rawId:required(r),authenticatorAttachment:optional(e),response:required({clientDataJSON:required(r),authenticatorData:required(r),signature:required(r),userHandle:required(r)}),clientExtensionResults:derived(i,(e=>e.getClientExtensionResults()))};var c={credentialCreationOptions:o,publicKeyCredentialWithAttestation:a,credentialRequestOptions:u,publicKeyCredentialWithAssertion:s};function createRequestFromJSON(e){return convert(base64urlToBuffer,o,e)}function createResponseToJSON(e){return convert(bufferToBase64url,a,e)}async function create(e){const r=await navigator.credentials.create(createRequestFromJSON(e));return createResponseToJSON(r)}function getRequestFromJSON(e){return convert(base64urlToBuffer,u,e)}function getResponseToJSON(e){return convert(bufferToBase64url,s,e)}async function get(e){const r=await navigator.credentials.get(getRequestFromJSON(e));return getResponseToJSON(r)}function supported(){return!!(navigator.credentials&&navigator.credentials.create&&navigator.credentials.get&&window.PublicKeyCredential)}export{create,get,c as schema,supported};
|
@@ -1,2 +0,0 @@
|
|
1
|
-
class FetchResponse{constructor(t){this.response=t}get statusCode(){return this.response.status}get redirected(){return this.response.redirected}get ok(){return this.response.ok}get unauthenticated(){return this.statusCode===401}get unprocessableEntity(){return this.statusCode===422}get authenticationURL(){return this.response.headers.get("WWW-Authenticate")}get contentType(){const t=this.response.headers.get("Content-Type")||"";return t.replace(/;.*$/,"")}get headers(){return this.response.headers}get html(){return this.contentType.match(/^(application|text)\/(html|xhtml\+xml)$/)?this.text:Promise.reject(new Error(`Expected an HTML response but got "${this.contentType}" instead`))}get json(){return this.contentType.match(/^application\/.*json$/)?this.responseJson||(this.responseJson=this.response.json()):Promise.reject(new Error(`Expected a JSON response but got "${this.contentType}" instead`))}get text(){return this.responseText||(this.responseText=this.response.text())}get isTurboStream(){return this.contentType.match(/^text\/vnd\.turbo-stream\.html/)}get isScript(){return this.contentType.match(/\b(?:java|ecma)script\b/)}async renderTurboStream(){if(!this.isTurboStream)return Promise.reject(new Error(`Expected a Turbo Stream response but got "${this.contentType}" instead`));window.Turbo?await window.Turbo.renderStreamMessage(await this.text):console.warn("You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js")}async activeScript(){if(!this.isScript)return Promise.reject(new Error(`Expected a Script response but got "${this.contentType}" instead`));{const t=document.createElement("script");const e=document.querySelector("meta[name=csp-nonce]");const n=e&&e.content;n&&t.setAttribute("nonce",n);t.innerHTML=await this.text;document.body.appendChild(t)}}}class RequestInterceptor{static register(t){this.interceptor=t}static get(){return this.interceptor}static reset(){this.interceptor=void 0}}function getCookie(t){const e=document.cookie?document.cookie.split("; "):[];const n=`${encodeURIComponent(t)}=`;const s=e.find((t=>t.startsWith(n)));if(s){const t=s.split("=").slice(1).join("=");if(t)return decodeURIComponent(t)}}function compact(t){const e={};for(const n in t){const s=t[n];s!==void 0&&(e[n]=s)}return e}function metaContent(t){const e=document.head.querySelector(`meta[name="${t}"]`);return e&&e.content}function stringEntriesFromFormData(t){return[...t].reduce(((t,[e,n])=>t.concat(typeof n==="string"?[[e,n]]:[])),[])}function mergeEntries(t,e){for(const[n,s]of e)if(!(s instanceof window.File))if(t.has(n)&&!n.includes("[]")){t.delete(n);t.set(n,s)}else t.append(n,s)}class FetchRequest{constructor(t,e,n={}){this.method=t;this.options=n;this.originalUrl=e.toString()}async perform(){try{const t=RequestInterceptor.get();t&&await t(this)}catch(t){console.error(t)}const t=this.responseKind==="turbo-stream"&&window.Turbo?window.Turbo.fetch:window.fetch;const e=new FetchResponse(await t(this.url,this.fetchOptions));if(e.unauthenticated&&e.authenticationURL)return Promise.reject(window.location.href=e.authenticationURL);e.isScript&&await e.activeScript();const n=e.ok||e.unprocessableEntity;n&&e.isTurboStream&&await e.renderTurboStream();return e}addHeader(t,e){const n=this.additionalHeaders;n[t]=e;this.options.headers=n}sameHostname(){if(!this.originalUrl.startsWith("http:"))return true;try{return new URL(this.originalUrl).hostname===window.location.hostname}catch(t){return true}}get fetchOptions(){return{method:this.method.toUpperCase(),headers:this.headers,body:this.formattedBody,signal:this.signal,credentials:this.credentials,redirect:this.redirect}}get headers(){const t={"X-Requested-With":"XMLHttpRequest","Content-Type":this.contentType,Accept:this.accept};this.sameHostname()&&(t["X-CSRF-Token"]=this.csrfToken);return compact(Object.assign(t,this.additionalHeaders))}get csrfToken(){return getCookie(metaContent("csrf-param"))||metaContent("csrf-token")}get contentType(){return this.options.contentType?this.options.contentType:this.body==null||this.body instanceof window.FormData?void 0:this.body instanceof window.File?this.body.type:"application/json"}get accept(){switch(this.responseKind){case"html":return"text/html, application/xhtml+xml";case"turbo-stream":return"text/vnd.turbo-stream.html, text/html, application/xhtml+xml";case"json":return"application/json, application/vnd.api+json";case"script":return"text/javascript, application/javascript";default:return"*/*"}}get body(){return this.options.body}get query(){const t=(this.originalUrl.split("?")[1]||"").split("#")[0];const e=new URLSearchParams(t);let n=this.options.query;n=n instanceof window.FormData?stringEntriesFromFormData(n):n instanceof window.URLSearchParams?n.entries():Object.entries(n||{});mergeEntries(e,n);const s=e.toString();return s.length>0?`?${s}`:""}get url(){return this.originalUrl.split("?")[0].split("#")[0]+this.query}get responseKind(){return this.options.responseKind||"html"}get signal(){return this.options.signal}get redirect(){return this.options.redirect||"follow"}get credentials(){return this.options.credentials||"same-origin"}get additionalHeaders(){return this.options.headers||{}}get formattedBody(){const t=Object.prototype.toString.call(this.body)==="[object String]";const e=this.headers["Content-Type"]==="application/json";return e&&!t?JSON.stringify(this.body):this.body}}async function get(t,e){const n=new FetchRequest("get",t,e);return n.perform()}async function post(t,e){const n=new FetchRequest("post",t,e);return n.perform()}async function put(t,e){const n=new FetchRequest("put",t,e);return n.perform()}async function patch(t,e){const n=new FetchRequest("patch",t,e);return n.perform()}async function destroy(t,e){const n=new FetchRequest("delete",t,e);return n.perform()}export{FetchRequest,FetchResponse,RequestInterceptor,destroy,get,patch,post,put};
|
2
|
-
//# sourceMappingURL=index.js.map
|