cauthy-auth 0.9.0 → 0.10.0
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/client.d.mts +7 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +5 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +5 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +7 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +5 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +5 -1
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.js +5 -1
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +5 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +5 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +5 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -105,13 +105,17 @@ var UNAVAILABLE = { code: "unavailable", message: "Sign-in is unavailable right
|
|
|
105
105
|
function createAuthClient(options = {}) {
|
|
106
106
|
const base = (options.basePath ?? "/api/auth").replace(/\/+$/, "");
|
|
107
107
|
const doFetch = (...args) => (options.fetch ?? fetch)(...args);
|
|
108
|
+
const locale = () => {
|
|
109
|
+
const said = typeof options.locale === "function" ? options.locale() : options.locale;
|
|
110
|
+
return (said ?? (typeof document === "undefined" ? "" : document.documentElement?.lang) ?? "").trim();
|
|
111
|
+
};
|
|
108
112
|
async function post(path, form, bad) {
|
|
109
113
|
if (bad) return { ok: false, error: { code: bad.code, message: bad.message, field: bad.field } };
|
|
110
114
|
try {
|
|
111
115
|
const res = await doFetch(`${base}${path}`, {
|
|
112
116
|
method: "POST",
|
|
113
117
|
credentials: "same-origin",
|
|
114
|
-
headers: { "content-type": "application/json", accept: "application/json" },
|
|
118
|
+
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {} },
|
|
115
119
|
body: JSON.stringify(form)
|
|
116
120
|
});
|
|
117
121
|
const body = await res.json().catch(() => null);
|