autherr 2.0.39 → 2.0.41
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.
|
@@ -60,18 +60,22 @@ export function AutherrProvider({ children, clientId, baseUrl, clientPrivateKey,
|
|
|
60
60
|
// url.searchParams.set("state", state);
|
|
61
61
|
// window.location.href = url.toString();
|
|
62
62
|
// };
|
|
63
|
+
let redirecting = false;
|
|
63
64
|
const buildRedirect = async (path) => {
|
|
65
|
+
if (redirecting)
|
|
66
|
+
return;
|
|
67
|
+
redirecting = true;
|
|
64
68
|
const state = crypto.randomUUID();
|
|
65
69
|
const assertion = await createClientAssertion(clientId, clientPrivateKey);
|
|
66
|
-
const encodedAssertion = encodeURIComponent(assertion);
|
|
67
70
|
const form = document.createElement("form");
|
|
68
71
|
form.method = "POST";
|
|
69
|
-
form.action =
|
|
72
|
+
form.action =
|
|
73
|
+
`${baseUrl}/auth/${path}` +
|
|
74
|
+
`?client_id=${encodeURIComponent(clientId)}` +
|
|
75
|
+
`&redirect_uri=${encodeURIComponent(window.location.origin)}` +
|
|
76
|
+
`&state=${encodeURIComponent(state)}`;
|
|
70
77
|
form.innerHTML = `
|
|
71
|
-
<input type="hidden" name="
|
|
72
|
-
<input type="hidden" name="redirect_uri" value="${window.location.origin}" />
|
|
73
|
-
<input type="hidden" name="state" value="${state}" />
|
|
74
|
-
<input type="hidden" name="client_assertion" value="${encodedAssertion}" />
|
|
78
|
+
<input type="hidden" name="client_assertion" value="${encodeURIComponent(assertion)}" />
|
|
75
79
|
`;
|
|
76
80
|
document.body.appendChild(form);
|
|
77
81
|
form.submit();
|
package/package.json
CHANGED
|
@@ -68,59 +68,59 @@ export function AutherrProvider({
|
|
|
68
68
|
// const signup = () => buildRedirect("signup");
|
|
69
69
|
|
|
70
70
|
// NEW FINAL CODE:
|
|
71
|
+
const buildRedirect = async (path: "login" | "signup") => {
|
|
72
|
+
const state = crypto.randomUUID();
|
|
73
|
+
|
|
74
|
+
const assertion = await createClientAssertion(
|
|
75
|
+
clientId,
|
|
76
|
+
clientPrivateKey
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// ⏱️ 45 seconds TTL
|
|
80
|
+
const ttlSeconds = 45;
|
|
81
|
+
|
|
82
|
+
// IMPORTANT:
|
|
83
|
+
// - SameSite=Lax → sent on top-level navigation
|
|
84
|
+
// - Secure → HTTPS only (required in prod)
|
|
85
|
+
// - Path=/ → available to auth routes
|
|
86
|
+
document.cookie =
|
|
87
|
+
`autherr_client_assertion=${encodeURIComponent(assertion)}; ` +
|
|
88
|
+
`Max-Age=${ttlSeconds}; ` +
|
|
89
|
+
`Path=/; ` +
|
|
90
|
+
`SameSite=Lax; ` +
|
|
91
|
+
`Secure`;
|
|
92
|
+
|
|
93
|
+
const url = new URL(`${baseUrl}/auth/${path}`);
|
|
94
|
+
url.searchParams.set("client_id", clientId);
|
|
95
|
+
url.searchParams.set("redirect_uri", window.location.origin);
|
|
96
|
+
url.searchParams.set("state", state);
|
|
97
|
+
|
|
98
|
+
window.location.href = url.toString();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// let redirecting = false;
|
|
71
102
|
// const buildRedirect = async (path: "login" | "signup") => {
|
|
103
|
+
// if(redirecting) return;
|
|
104
|
+
// redirecting=true;
|
|
72
105
|
// const state = crypto.randomUUID();
|
|
106
|
+
// const assertion = await createClientAssertion(clientId, clientPrivateKey);
|
|
73
107
|
|
|
74
|
-
// const
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
// // IMPORTANT:
|
|
83
|
-
// // - SameSite=Lax → sent on top-level navigation
|
|
84
|
-
// // - Secure → HTTPS only (required in prod)
|
|
85
|
-
// // - Path=/ → available to auth routes
|
|
86
|
-
// document.cookie =
|
|
87
|
-
// `autherr_client_assertion=${encodeURIComponent(assertion)}; ` +
|
|
88
|
-
// `Max-Age=${ttlSeconds}; ` +
|
|
89
|
-
// `Path=/; ` +
|
|
90
|
-
// `SameSite=Lax; ` +
|
|
91
|
-
// `Secure`;
|
|
108
|
+
// const form = document.createElement("form");
|
|
109
|
+
// form.method = "POST";
|
|
110
|
+
// form.action =
|
|
111
|
+
// `${baseUrl}/auth/${path}` +
|
|
112
|
+
// `?client_id=${encodeURIComponent(clientId)}` +
|
|
113
|
+
// `&redirect_uri=${encodeURIComponent(window.location.origin)}` +
|
|
114
|
+
// `&state=${encodeURIComponent(state)}`;
|
|
92
115
|
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
// url.searchParams.set("state", state);
|
|
116
|
+
// form.innerHTML = `
|
|
117
|
+
// <input type="hidden" name="client_assertion" value="${encodeURIComponent(assertion)}" />
|
|
118
|
+
// `;
|
|
97
119
|
|
|
98
|
-
//
|
|
120
|
+
// document.body.appendChild(form);
|
|
121
|
+
// form.submit();
|
|
99
122
|
// };
|
|
100
123
|
|
|
101
|
-
let redirecting = false;
|
|
102
|
-
const buildRedirect = async (path: "login" | "signup") => {
|
|
103
|
-
if(redirecting) return;
|
|
104
|
-
redirecting=true;
|
|
105
|
-
const state = crypto.randomUUID();
|
|
106
|
-
const assertion = await createClientAssertion(clientId, clientPrivateKey);
|
|
107
|
-
|
|
108
|
-
const form = document.createElement("form");
|
|
109
|
-
form.method = "POST";
|
|
110
|
-
form.action =
|
|
111
|
-
`${baseUrl}/auth/${path}` +
|
|
112
|
-
`?client_id=${encodeURIComponent(clientId)}` +
|
|
113
|
-
`&redirect_uri=${encodeURIComponent(window.location.origin)}` +
|
|
114
|
-
`&state=${encodeURIComponent(state)}`;
|
|
115
|
-
|
|
116
|
-
form.innerHTML = `
|
|
117
|
-
<input type="hidden" name="client_assertion" value="${encodeURIComponent(assertion)}" />
|
|
118
|
-
`;
|
|
119
|
-
|
|
120
|
-
document.body.appendChild(form);
|
|
121
|
-
form.submit();
|
|
122
|
-
};
|
|
123
|
-
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
|