@djangocfg/api 2.1.482 → 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.cjs
CHANGED
|
@@ -920,6 +920,24 @@ var localStorageBackend = {
|
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
|
+
var sessionStorageBackend = {
|
|
924
|
+
get(key) {
|
|
925
|
+
if (!isBrowser) return null;
|
|
926
|
+
try {
|
|
927
|
+
return window.sessionStorage.getItem(key);
|
|
928
|
+
} catch {
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
set(key, value) {
|
|
933
|
+
if (!isBrowser) return;
|
|
934
|
+
try {
|
|
935
|
+
if (value === null) window.sessionStorage.removeItem(key);
|
|
936
|
+
else window.sessionStorage.setItem(key, value);
|
|
937
|
+
} catch {
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
};
|
|
923
941
|
var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
924
942
|
var cookieBackend = {
|
|
925
943
|
get(key) {
|
|
@@ -927,7 +945,8 @@ var cookieBackend = {
|
|
|
927
945
|
try {
|
|
928
946
|
const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
|
|
929
947
|
const m = document.cookie.match(re);
|
|
930
|
-
|
|
948
|
+
const value = m?.[1];
|
|
949
|
+
return value === void 0 ? null : decodeURIComponent(value);
|
|
931
950
|
} catch {
|
|
932
951
|
return null;
|
|
933
952
|
}
|
|
@@ -953,7 +972,8 @@ function detectLocale() {
|
|
|
953
972
|
try {
|
|
954
973
|
if (typeof document !== "undefined") {
|
|
955
974
|
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
956
|
-
|
|
975
|
+
const locale = m?.[1];
|
|
976
|
+
if (locale !== void 0) return decodeURIComponent(locale);
|
|
957
977
|
}
|
|
958
978
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
959
979
|
return navigator.language;
|
|
@@ -1103,7 +1123,7 @@ var auth = {
|
|
|
1103
1123
|
},
|
|
1104
1124
|
setStorageMode(mode) {
|
|
1105
1125
|
_storageMode = mode;
|
|
1106
|
-
_storage = mode === "cookie" ? cookieBackend : localStorageBackend;
|
|
1126
|
+
_storage = mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
1107
1127
|
notifySessionChanged();
|
|
1108
1128
|
},
|
|
1109
1129
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -1367,7 +1387,7 @@ __name(_getDpopKeyPair, "_getDpopKeyPair");
|
|
|
1367
1387
|
function _b64urlFromBytes(bytes) {
|
|
1368
1388
|
const arr = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
1369
1389
|
let s = "";
|
|
1370
|
-
for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i]);
|
|
1390
|
+
for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i] ?? 0);
|
|
1371
1391
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1372
1392
|
}
|
|
1373
1393
|
__name(_b64urlFromBytes, "_b64urlFromBytes");
|
|
@@ -1385,7 +1405,8 @@ async function _makeDpopProof(method, url) {
|
|
|
1385
1405
|
const pair = await _getDpopKeyPair();
|
|
1386
1406
|
const jwk = await _publicJwk(pair.publicKey);
|
|
1387
1407
|
const header = { typ: "dpop+jwt", alg: "ES256", jwk };
|
|
1388
|
-
const
|
|
1408
|
+
const withoutFragment = url.split("#")[0] ?? url;
|
|
1409
|
+
const htu = withoutFragment.split("?")[0] ?? withoutFragment;
|
|
1389
1410
|
const jti = crypto.randomUUID && crypto.randomUUID() || _b64urlFromBytes(crypto.getRandomValues(new Uint8Array(16)));
|
|
1390
1411
|
const payload = { htm: method.toUpperCase(), htu, iat: Math.floor(Date.now() / 1e3), jti };
|
|
1391
1412
|
const signingInput = `${_b64urlFromString(JSON.stringify(header))}.${_b64urlFromString(JSON.stringify(payload))}`;
|
|
@@ -1586,9 +1607,9 @@ var CfgAccountsApiKey = class {
|
|
|
1586
1607
|
});
|
|
1587
1608
|
}
|
|
1588
1609
|
};
|
|
1589
|
-
var
|
|
1610
|
+
var CfgAccountsOtp = class {
|
|
1590
1611
|
static {
|
|
1591
|
-
__name(this, "
|
|
1612
|
+
__name(this, "CfgAccountsOtp");
|
|
1592
1613
|
}
|
|
1593
1614
|
/**
|
|
1594
1615
|
* Marketing-consent checkbox policy for the caller's jurisdiction.
|
|
@@ -1959,7 +1980,7 @@ function useCfgAccountsOtpConsentPolicyRetrieve(args, config) {
|
|
|
1959
1980
|
return (0, import_swr2.default)(
|
|
1960
1981
|
key,
|
|
1961
1982
|
async () => {
|
|
1962
|
-
const res = await
|
|
1983
|
+
const res = await CfgAccountsOtp.cfgAccountsOtpConsentPolicyRetrieve({ ...args ?? {}, throwOnError: true });
|
|
1963
1984
|
const data = res.data;
|
|
1964
1985
|
const parsed = ConsentPolicySchema.safeParse(data);
|
|
1965
1986
|
if (!parsed.success) {
|