@djangocfg/api 2.1.481 → 2.1.483
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/README.md +1 -1
- package/dist/auth.cjs +64 -25
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +14 -1
- package/dist/auth.d.ts +14 -1
- package/dist/auth.mjs +64 -25
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +29 -8
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +22 -2
- package/dist/clients.d.ts +22 -2
- package/dist/clients.mjs +29 -8
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +29 -8
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +29 -8
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +31 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -4
- package/dist/index.d.ts +32 -4
- package/dist/index.mjs +31 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/api.ts +3 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +2 -2
- package/src/_api/generated/_cfg_accounts/index.ts +1 -1
- package/src/_api/generated/_cfg_accounts/openapi.json +21 -43
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +1 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +1 -0
- package/src/_api/generated/_cfg_totp/openapi.json +5 -0
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +1 -0
- package/src/_api/generated/helpers/auth.ts +27 -6
- package/src/_api/generated/index.ts +1 -1
- package/src/_api/generated/openapi.json +26 -43
- package/src/_api/generated/sdk.gen.ts +1 -1
- package/src/_api/generated/types.gen.ts +28 -0
- package/src/auth/context/AccountsContext.tsx +1 -0
- package/src/auth/context/AuthContext.tsx +3 -2
- package/src/auth/context/types.ts +1 -1
- package/src/auth/hooks/useAuthForm.ts +3 -2
- package/src/auth/hooks/useAuthFormState.ts +3 -0
- package/src/auth/hooks/useAuthRedirect.ts +2 -2
- package/src/auth/hooks/useGithubAuth.ts +34 -21
- package/src/auth/hooks/useTwoFactorVerify.ts +5 -3
- package/src/auth/types/form.ts +3 -1
- package/src/index.ts +5 -1
package/dist/hooks.mjs
CHANGED
|
@@ -886,6 +886,24 @@ var localStorageBackend = {
|
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
888
|
};
|
|
889
|
+
var sessionStorageBackend = {
|
|
890
|
+
get(key) {
|
|
891
|
+
if (!isBrowser) return null;
|
|
892
|
+
try {
|
|
893
|
+
return window.sessionStorage.getItem(key);
|
|
894
|
+
} catch {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
set(key, value) {
|
|
899
|
+
if (!isBrowser) return;
|
|
900
|
+
try {
|
|
901
|
+
if (value === null) window.sessionStorage.removeItem(key);
|
|
902
|
+
else window.sessionStorage.setItem(key, value);
|
|
903
|
+
} catch {
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
};
|
|
889
907
|
var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
890
908
|
var cookieBackend = {
|
|
891
909
|
get(key) {
|
|
@@ -893,7 +911,8 @@ var cookieBackend = {
|
|
|
893
911
|
try {
|
|
894
912
|
const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
|
|
895
913
|
const m = document.cookie.match(re);
|
|
896
|
-
|
|
914
|
+
const value = m?.[1];
|
|
915
|
+
return value === void 0 ? null : decodeURIComponent(value);
|
|
897
916
|
} catch {
|
|
898
917
|
return null;
|
|
899
918
|
}
|
|
@@ -919,7 +938,8 @@ function detectLocale() {
|
|
|
919
938
|
try {
|
|
920
939
|
if (typeof document !== "undefined") {
|
|
921
940
|
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
922
|
-
|
|
941
|
+
const locale = m?.[1];
|
|
942
|
+
if (locale !== void 0) return decodeURIComponent(locale);
|
|
923
943
|
}
|
|
924
944
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
925
945
|
return navigator.language;
|
|
@@ -1069,7 +1089,7 @@ var auth = {
|
|
|
1069
1089
|
},
|
|
1070
1090
|
setStorageMode(mode) {
|
|
1071
1091
|
_storageMode = mode;
|
|
1072
|
-
_storage = mode === "cookie" ? cookieBackend : localStorageBackend;
|
|
1092
|
+
_storage = mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
1073
1093
|
notifySessionChanged();
|
|
1074
1094
|
},
|
|
1075
1095
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -1333,7 +1353,7 @@ __name(_getDpopKeyPair, "_getDpopKeyPair");
|
|
|
1333
1353
|
function _b64urlFromBytes(bytes) {
|
|
1334
1354
|
const arr = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
1335
1355
|
let s = "";
|
|
1336
|
-
for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i]);
|
|
1356
|
+
for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i] ?? 0);
|
|
1337
1357
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1338
1358
|
}
|
|
1339
1359
|
__name(_b64urlFromBytes, "_b64urlFromBytes");
|
|
@@ -1351,7 +1371,8 @@ async function _makeDpopProof(method, url) {
|
|
|
1351
1371
|
const pair = await _getDpopKeyPair();
|
|
1352
1372
|
const jwk = await _publicJwk(pair.publicKey);
|
|
1353
1373
|
const header = { typ: "dpop+jwt", alg: "ES256", jwk };
|
|
1354
|
-
const
|
|
1374
|
+
const withoutFragment = url.split("#")[0] ?? url;
|
|
1375
|
+
const htu = withoutFragment.split("?")[0] ?? withoutFragment;
|
|
1355
1376
|
const jti = crypto.randomUUID && crypto.randomUUID() || _b64urlFromBytes(crypto.getRandomValues(new Uint8Array(16)));
|
|
1356
1377
|
const payload = { htm: method.toUpperCase(), htu, iat: Math.floor(Date.now() / 1e3), jti };
|
|
1357
1378
|
const signingInput = `${_b64urlFromString(JSON.stringify(header))}.${_b64urlFromString(JSON.stringify(payload))}`;
|
|
@@ -1552,9 +1573,9 @@ var CfgAccountsApiKey = class {
|
|
|
1552
1573
|
});
|
|
1553
1574
|
}
|
|
1554
1575
|
};
|
|
1555
|
-
var
|
|
1576
|
+
var CfgAccountsOtp = class {
|
|
1556
1577
|
static {
|
|
1557
|
-
__name(this, "
|
|
1578
|
+
__name(this, "CfgAccountsOtp");
|
|
1558
1579
|
}
|
|
1559
1580
|
/**
|
|
1560
1581
|
* Marketing-consent checkbox policy for the caller's jurisdiction.
|
|
@@ -1925,7 +1946,7 @@ function useCfgAccountsOtpConsentPolicyRetrieve(args, config) {
|
|
|
1925
1946
|
return useSWR2(
|
|
1926
1947
|
key,
|
|
1927
1948
|
async () => {
|
|
1928
|
-
const res = await
|
|
1949
|
+
const res = await CfgAccountsOtp.cfgAccountsOtpConsentPolicyRetrieve({ ...args ?? {}, throwOnError: true });
|
|
1929
1950
|
const data = res.data;
|
|
1930
1951
|
const parsed = ConsentPolicySchema.safeParse(data);
|
|
1931
1952
|
if (!parsed.success) {
|