@spicenet-io/spiceflow-ui 1.9.33 → 1.9.35
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/dist/Button-4ryz2e1P.js +2 -0
- package/dist/Button-Cn16gFtO.js +2 -0
- package/dist/auth-dynamic.cjs.js +3 -1019
- package/dist/auth-dynamic.js +3 -1017
- package/dist/auth-privy.cjs.js +2 -125
- package/dist/auth-privy.js +2 -123
- package/dist/index.cjs.js +16 -14243
- package/dist/index.js +16 -14216
- package/dist/types/authorization.d.ts +0 -1
- package/dist/utils/relayer/index.d.ts +9 -0
- package/package.json +10 -17
- package/dist/Button-CWjGZdAM.js +0 -228
- package/dist/Button-D2yFTia-.js +0 -232
package/dist/auth-privy.cjs.js
CHANGED
|
@@ -1,130 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
const React = require('react');
|
|
6
|
-
const Button = require('./Button-D2yFTia-.js');
|
|
7
|
-
const reactAuth = require('@privy-io/react-auth');
|
|
8
|
-
|
|
9
|
-
const PrivyLogin = ({
|
|
10
|
-
onAuthSuccess,
|
|
11
|
-
onAuthError,
|
|
12
|
-
theme: themeMode = "light",
|
|
13
|
-
className = "",
|
|
14
|
-
buttonText = "Login with Privy",
|
|
15
|
-
autoTrigger = false
|
|
16
|
-
}) => {
|
|
17
|
-
const theme = Button.createTheme(themeMode);
|
|
18
|
-
const [isClient, setIsClient] = React.useState(false);
|
|
19
|
-
const [hasAutoTriggered, setHasAutoTriggered] = React.useState(false);
|
|
20
|
-
const { ready, authenticated, user } = reactAuth.usePrivy();
|
|
21
|
-
const { login } = reactAuth.useLogin();
|
|
22
|
-
const { logout } = reactAuth.useLogout();
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
setIsClient(true);
|
|
25
|
-
}, []);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
if (autoTrigger && ready && !authenticated && isClient && !hasAutoTriggered) {
|
|
28
|
-
setHasAutoTriggered(true);
|
|
29
|
-
handleLogin();
|
|
30
|
-
}
|
|
31
|
-
}, [autoTrigger, ready, authenticated, isClient, hasAutoTriggered]);
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
if (ready && authenticated && user && onAuthSuccess) {
|
|
34
|
-
const address = user.wallet?.address || user.email?.address;
|
|
35
|
-
if (address) {
|
|
36
|
-
onAuthSuccess(address);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, [ready, authenticated, user, onAuthSuccess]);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
}, [ready, authenticated, onAuthError]);
|
|
42
|
-
const handleLogin = () => {
|
|
43
|
-
try {
|
|
44
|
-
login();
|
|
45
|
-
} catch (error) {
|
|
46
|
-
const errorMessage = `Login failed: ${String(error)}`;
|
|
47
|
-
if (onAuthError) {
|
|
48
|
-
onAuthError(errorMessage);
|
|
49
|
-
} else {
|
|
50
|
-
console.error(errorMessage);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const handleLogout = () => {
|
|
55
|
-
try {
|
|
56
|
-
logout();
|
|
57
|
-
} catch (error) {
|
|
58
|
-
const errorMessage = `Logout failed: ${String(error)}`;
|
|
59
|
-
if (onAuthError) {
|
|
60
|
-
onAuthError(errorMessage);
|
|
61
|
-
} else {
|
|
62
|
-
console.error(errorMessage);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
if (!isClient) {
|
|
67
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "primary", disabled: true, theme, children: buttonText }) });
|
|
68
|
-
}
|
|
69
|
-
if (!ready) {
|
|
70
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "primary", disabled: true, theme, children: "Loading..." }) });
|
|
71
|
-
}
|
|
72
|
-
if (authenticated && user) {
|
|
73
|
-
const displayAddress = user.wallet?.address || user.email?.address;
|
|
74
|
-
const shortAddress = displayAddress ? `${displayAddress.slice(0, 6)}...${displayAddress.slice(-4)}` : "Connected";
|
|
75
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs(Button.Button, { variant: "primary", onClick: handleLogout, theme, children: [
|
|
76
|
-
"Logout (",
|
|
77
|
-
shortAddress,
|
|
78
|
-
")"
|
|
79
|
-
] }) });
|
|
80
|
-
}
|
|
81
|
-
if (autoTrigger) {
|
|
82
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
83
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
84
|
-
"div",
|
|
85
|
-
{
|
|
86
|
-
style: {
|
|
87
|
-
display: "flex",
|
|
88
|
-
alignItems: "center",
|
|
89
|
-
justifyContent: "center",
|
|
90
|
-
padding: "20px",
|
|
91
|
-
flexDirection: "column",
|
|
92
|
-
gap: "12px"
|
|
93
|
-
},
|
|
94
|
-
children: [
|
|
95
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
96
|
-
"div",
|
|
97
|
-
{
|
|
98
|
-
style: {
|
|
99
|
-
width: "40px",
|
|
100
|
-
height: "40px",
|
|
101
|
-
border: "3px solid #e5e7eb",
|
|
102
|
-
borderTop: "3px solid #3b82f6",
|
|
103
|
-
borderRadius: "50%",
|
|
104
|
-
animation: "spin 1s linear infinite"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#6b7280", fontSize: "14px" }, children: "Opening login..." })
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
-
"style",
|
|
114
|
-
{
|
|
115
|
-
dangerouslySetInnerHTML: {
|
|
116
|
-
__html: `
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-Cn16gFtO.js"),x=require("@privy-io/react-auth"),B=({onAuthSuccess:u,onAuthError:a,theme:p="light",className:l="",buttonText:f="Login with Privy",autoTrigger:h=!1})=>{const d=c.createTheme(p),[m,j]=o.useState(!1),[g,v]=o.useState(!1),{ready:i,authenticated:n,user:r}=x.usePrivy(),{login:b}=x.useLogin(),{logout:L}=x.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&i&&!n&&m&&!g&&(v(!0),y())},[h,i,n,m,g]),o.useEffect(()=>{if(i&&n&&r&&u){const t=r.wallet?.address||r.email?.address;t&&u(t)}},[i,n,r,u]),o.useEffect(()=>{},[i,n,a]);const y=()=>{try{b()}catch(t){const s=`Login failed: ${String(t)}`;a?a(s):console.error(s)}},S=()=>{try{L()}catch(t){const s=`Logout failed: ${String(t)}`;a?a(s):console.error(s)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:d,children:f})});if(!i)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:d,children:"Loading..."})});if(n&&r){const t=r.wallet?.address||r.email?.address,s=t?`${t.slice(0,6)}...${t.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:S,theme:d,children:["Logout (",s,")"]})})}return h?e.jsxs("div",{className:l,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx("div",{style:{width:"40px",height:"40px",border:"3px solid #e5e7eb",borderTop:"3px solid #3b82f6",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]}),e.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
117
3
|
@keyframes spin {
|
|
118
4
|
0% { transform: rotate(0deg); }
|
|
119
5
|
100% { transform: rotate(360deg); }
|
|
120
6
|
}
|
|
121
|
-
`
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
] });
|
|
126
|
-
}
|
|
127
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "primary", onClick: handleLogin, theme, children: buttonText }) });
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
exports.PrivyLogin = PrivyLogin;
|
|
7
|
+
`}})]}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:d,children:f})})};exports.PrivyLogin=B;
|
package/dist/auth-privy.js
CHANGED
|
@@ -1,128 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
import { B as Button, c as createTheme } from './Button-CWjGZdAM.js';
|
|
5
|
-
import { usePrivy, useLogin, useLogout } from '@privy-io/react-auth';
|
|
6
|
-
|
|
7
|
-
const PrivyLogin = ({
|
|
8
|
-
onAuthSuccess,
|
|
9
|
-
onAuthError,
|
|
10
|
-
theme: themeMode = "light",
|
|
11
|
-
className = "",
|
|
12
|
-
buttonText = "Login with Privy",
|
|
13
|
-
autoTrigger = false
|
|
14
|
-
}) => {
|
|
15
|
-
const theme = createTheme(themeMode);
|
|
16
|
-
const [isClient, setIsClient] = useState(false);
|
|
17
|
-
const [hasAutoTriggered, setHasAutoTriggered] = useState(false);
|
|
18
|
-
const { ready, authenticated, user } = usePrivy();
|
|
19
|
-
const { login } = useLogin();
|
|
20
|
-
const { logout } = useLogout();
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
setIsClient(true);
|
|
23
|
-
}, []);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (autoTrigger && ready && !authenticated && isClient && !hasAutoTriggered) {
|
|
26
|
-
setHasAutoTriggered(true);
|
|
27
|
-
handleLogin();
|
|
28
|
-
}
|
|
29
|
-
}, [autoTrigger, ready, authenticated, isClient, hasAutoTriggered]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (ready && authenticated && user && onAuthSuccess) {
|
|
32
|
-
const address = user.wallet?.address || user.email?.address;
|
|
33
|
-
if (address) {
|
|
34
|
-
onAuthSuccess(address);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}, [ready, authenticated, user, onAuthSuccess]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
}, [ready, authenticated, onAuthError]);
|
|
40
|
-
const handleLogin = () => {
|
|
41
|
-
try {
|
|
42
|
-
login();
|
|
43
|
-
} catch (error) {
|
|
44
|
-
const errorMessage = `Login failed: ${String(error)}`;
|
|
45
|
-
if (onAuthError) {
|
|
46
|
-
onAuthError(errorMessage);
|
|
47
|
-
} else {
|
|
48
|
-
console.error(errorMessage);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const handleLogout = () => {
|
|
53
|
-
try {
|
|
54
|
-
logout();
|
|
55
|
-
} catch (error) {
|
|
56
|
-
const errorMessage = `Logout failed: ${String(error)}`;
|
|
57
|
-
if (onAuthError) {
|
|
58
|
-
onAuthError(errorMessage);
|
|
59
|
-
} else {
|
|
60
|
-
console.error(errorMessage);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
if (!isClient) {
|
|
65
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(Button, { variant: "primary", disabled: true, theme, children: buttonText }) });
|
|
66
|
-
}
|
|
67
|
-
if (!ready) {
|
|
68
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(Button, { variant: "primary", disabled: true, theme, children: "Loading..." }) });
|
|
69
|
-
}
|
|
70
|
-
if (authenticated && user) {
|
|
71
|
-
const displayAddress = user.wallet?.address || user.email?.address;
|
|
72
|
-
const shortAddress = displayAddress ? `${displayAddress.slice(0, 6)}...${displayAddress.slice(-4)}` : "Connected";
|
|
73
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleLogout, theme, children: [
|
|
74
|
-
"Logout (",
|
|
75
|
-
shortAddress,
|
|
76
|
-
")"
|
|
77
|
-
] }) });
|
|
78
|
-
}
|
|
79
|
-
if (autoTrigger) {
|
|
80
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
81
|
-
/* @__PURE__ */ jsxs(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
style: {
|
|
85
|
-
display: "flex",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
justifyContent: "center",
|
|
88
|
-
padding: "20px",
|
|
89
|
-
flexDirection: "column",
|
|
90
|
-
gap: "12px"
|
|
91
|
-
},
|
|
92
|
-
children: [
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
"div",
|
|
95
|
-
{
|
|
96
|
-
style: {
|
|
97
|
-
width: "40px",
|
|
98
|
-
height: "40px",
|
|
99
|
-
border: "3px solid #e5e7eb",
|
|
100
|
-
borderTop: "3px solid #3b82f6",
|
|
101
|
-
borderRadius: "50%",
|
|
102
|
-
animation: "spin 1s linear infinite"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
/* @__PURE__ */ jsx("p", { style: { color: "#6b7280", fontSize: "14px" }, children: "Opening login..." })
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
),
|
|
110
|
-
/* @__PURE__ */ jsx(
|
|
111
|
-
"style",
|
|
112
|
-
{
|
|
113
|
-
dangerouslySetInnerHTML: {
|
|
114
|
-
__html: `
|
|
2
|
+
import{jsx as r,jsxs as p}from"react/jsx-runtime";import{useState as x,useEffect as d}from"react";import{B as c,c as T}from"./Button-4ryz2e1P.js";import{usePrivy as w,useLogin as P,useLogout as $}from"@privy-io/react-auth";const j=({onAuthSuccess:m,onAuthError:n,theme:v="light",className:a="",buttonText:f="Login with Privy",autoTrigger:u=!1})=>{const l=T(v),[h,b]=x(!1),[g,L]=x(!1),{ready:o,authenticated:s,user:t}=w(),{login:N}=P(),{logout:S}=$();d(()=>{b(!0)},[]),d(()=>{u&&o&&!s&&h&&!g&&(L(!0),y())},[u,o,s,h,g]),d(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),d(()=>{},[o,s,n]);const y=()=>{try{N()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{S()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(c,{variant:"primary",disabled:!0,theme:l,children:f})});if(!o)return r("div",{className:a,children:r(c,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:p(c,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?p("div",{className:a,children:[p("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r("div",{style:{width:"40px",height:"40px",border:"3px solid #e5e7eb",borderTop:"3px solid #3b82f6",borderRadius:"50%",animation:"spin 1s linear infinite"}}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]}),r("style",{dangerouslySetInnerHTML:{__html:`
|
|
115
3
|
@keyframes spin {
|
|
116
4
|
0% { transform: rotate(0deg); }
|
|
117
5
|
100% { transform: rotate(360deg); }
|
|
118
6
|
}
|
|
119
|
-
`
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
] });
|
|
124
|
-
}
|
|
125
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleLogin, theme, children: buttonText }) });
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { PrivyLogin };
|
|
7
|
+
`}})]}):r("div",{className:a,children:r(c,{variant:"primary",onClick:y,theme:l,children:f})})};export{j as PrivyLogin};
|