@ebubekirylmaz/link-test 1.2.30 → 1.2.32
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/package.json
CHANGED
|
@@ -14,18 +14,37 @@ export default function CognitoLogin() {
|
|
|
14
14
|
|
|
15
15
|
const handleLogin = async () => {
|
|
16
16
|
try {
|
|
17
|
+
// 1️⃣ Login with Cognito
|
|
17
18
|
await login(username, password);
|
|
18
19
|
|
|
20
|
+
// 2️⃣ Get Cognito tokens
|
|
19
21
|
const tokens = await getTokens();
|
|
20
22
|
|
|
21
23
|
if (!tokens?.accessToken) {
|
|
22
|
-
throw new Error("No access token received");
|
|
24
|
+
throw new Error("No Cognito access token received");
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const res = await fetch("/api/oauth", {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
appId: "greycollar-api",
|
|
32
|
+
projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
33
|
+
identityProvider: "COGNITO",
|
|
34
|
+
refreshToken: tokens.accessToken, // 🔥 Cognito ACCESS token
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
throw new Error("Backend OAuth exchange failed");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const data = await res.json();
|
|
43
|
+
|
|
44
|
+
// 4️⃣ Store INTERNAL tokens (same as Demo)
|
|
45
|
+
storage.set("link", "accessToken", data.accessToken);
|
|
46
|
+
storage.set("link", "refreshToken", data.refreshToken);
|
|
47
|
+
storage.set("link", "identityProvider", "COGNITO");
|
|
29
48
|
|
|
30
49
|
window.location.href = "/";
|
|
31
50
|
} catch (e) {
|