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.d.mts
CHANGED
|
@@ -432,6 +432,13 @@ interface AuthClientOptions {
|
|
|
432
432
|
/** Where the server mounted the routes. Default: `/api/auth`. */
|
|
433
433
|
basePath?: string;
|
|
434
434
|
fetch?: typeof fetch;
|
|
435
|
+
/**
|
|
436
|
+
* The language the person reads, for what Cauthy mails them (a sign-in
|
|
437
|
+
* link, a new password, a confirmation): a tag like `es` or `es-CO`, or a
|
|
438
|
+
* function that answers it when the person can change it. Default: the
|
|
439
|
+
* page's own (`<html lang>`), else the browser's.
|
|
440
|
+
*/
|
|
441
|
+
locale?: string | (() => string | undefined);
|
|
435
442
|
}
|
|
436
443
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
437
444
|
|
package/dist/react.d.ts
CHANGED
|
@@ -432,6 +432,13 @@ interface AuthClientOptions {
|
|
|
432
432
|
/** Where the server mounted the routes. Default: `/api/auth`. */
|
|
433
433
|
basePath?: string;
|
|
434
434
|
fetch?: typeof fetch;
|
|
435
|
+
/**
|
|
436
|
+
* The language the person reads, for what Cauthy mails them (a sign-in
|
|
437
|
+
* link, a new password, a confirmation): a tag like `es` or `es-CO`, or a
|
|
438
|
+
* function that answers it when the person can change it. Default: the
|
|
439
|
+
* page's own (`<html lang>`), else the browser's.
|
|
440
|
+
*/
|
|
441
|
+
locale?: string | (() => string | undefined);
|
|
435
442
|
}
|
|
436
443
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
437
444
|
|
package/dist/react.js
CHANGED
|
@@ -139,13 +139,17 @@ var UNAVAILABLE = { code: "unavailable", message: "Sign-in is unavailable right
|
|
|
139
139
|
function createAuthClient(options = {}) {
|
|
140
140
|
const base = (options.basePath ?? "/api/auth").replace(/\/+$/, "");
|
|
141
141
|
const doFetch = (...args) => (options.fetch ?? fetch)(...args);
|
|
142
|
+
const locale = () => {
|
|
143
|
+
const said = typeof options.locale === "function" ? options.locale() : options.locale;
|
|
144
|
+
return (said ?? (typeof document === "undefined" ? "" : document.documentElement?.lang) ?? "").trim();
|
|
145
|
+
};
|
|
142
146
|
async function post(path, form, bad) {
|
|
143
147
|
if (bad) return { ok: false, error: { code: bad.code, message: bad.message, field: bad.field } };
|
|
144
148
|
try {
|
|
145
149
|
const res = await doFetch(`${base}${path}`, {
|
|
146
150
|
method: "POST",
|
|
147
151
|
credentials: "same-origin",
|
|
148
|
-
headers: { "content-type": "application/json", accept: "application/json" },
|
|
152
|
+
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {} },
|
|
149
153
|
body: JSON.stringify(form)
|
|
150
154
|
});
|
|
151
155
|
const body = await res.json().catch(() => null);
|