@arizondigital/catalyst-sso 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +8 -0
  2. package/package.json +22 -0
  3. package/src/index.js +86 -0
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # catalyst-sso
2
+
3
+ Integer Catalyst SSO
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install arizondigital/catalyst-sso
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@arizondigital/catalyst-sso",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "0.1.1",
7
+ "description": "Integer Catalyst SSO package",
8
+ "license": "MIT",
9
+ "author": "Arizon Digital",
10
+ "type": "module",
11
+ "main": "src/index.js",
12
+ "peerDependencies": {
13
+ "react": "^18 || ^19",
14
+ "react-dom": "^18 || ^19"
15
+ },
16
+ "dependencies": {
17
+ "catalyst-sso": "github:Arizon-Digital/SSOAppShopper#develop-catalyst"
18
+ },
19
+ "scripts": {
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ }
22
+ }
package/src/index.js ADDED
@@ -0,0 +1,86 @@
1
+
2
+
3
+
4
+ "use client";
5
+
6
+ import React, { useEffect, useState } from "react";
7
+
8
+ console.log("SSO Package Loaded.......123");
9
+
10
+ function SsoButtonPlaceholder({ buttonText, loginUrl }) {
11
+ const handleLogin = () => {
12
+ if (loginUrl) {
13
+ window.location.href = loginUrl;
14
+ }
15
+ };
16
+
17
+ return (
18
+ <button
19
+ onClick={handleLogin}
20
+ style={{
21
+ padding: "12px 20px",
22
+ backgroundColor: "#111827",
23
+ color: "#ffffff",
24
+ border: "none",
25
+ borderRadius: "8px",
26
+ cursor: "pointer",
27
+ fontSize: "16px",
28
+ fontWeight: "600",
29
+ margin: "10px",
30
+ }}
31
+ >
32
+ {buttonText}
33
+ </button>
34
+ );
35
+ }
36
+
37
+ export function OktaSamlButton() {
38
+ const [buttonName, setButtonName] = useState("Login With Okta");
39
+ const [redirectUrl, setRedirectUrl] = useState("");
40
+
41
+ useEffect(() => {
42
+ fetch(
43
+ "https://sso-app-merchant-dev.vercel.app/api/pqhmp0hlit/okta/saml"
44
+ )
45
+ .then((response) => response.json())
46
+ .then((data) => {
47
+ console.log("API Response:", data);
48
+
49
+ setButtonName(data.button_name);
50
+ setRedirectUrl(data.redirect_url);
51
+ })
52
+ .catch((error) => {
53
+ console.error("Error fetching data:", error);
54
+ });
55
+ }, []);
56
+
57
+ return (
58
+ <SsoButtonPlaceholder
59
+ buttonText={buttonName}
60
+ loginUrl={redirectUrl}
61
+ />
62
+ );
63
+ }
64
+
65
+ export function EntraSamlButton({
66
+ loginUrl = "",
67
+ isSandbox = false,
68
+ storeHash = "",
69
+ }) {
70
+ const [redirectUrl, setRedirectUrl] = useState(loginUrl);
71
+
72
+ useEffect(() => {
73
+ if (isSandbox && storeHash) {
74
+ setRedirectUrl(
75
+ `https://sso-app-merchant-dev.vercel.app/api/entra/login`
76
+ );
77
+ }
78
+ }, [isSandbox, storeHash]);
79
+
80
+ return (
81
+ <SsoButtonPlaceholder
82
+ buttonText="Login With Entra"
83
+ loginUrl={redirectUrl}
84
+ />
85
+ );
86
+ }