@renown/sdk 5.1.0 → 5.2.0-dev.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.
- package/README.md +487 -1
- package/dist/e2e/fixtures/main.d.ts +2 -0
- package/dist/e2e/fixtures/main.d.ts.map +1 -0
- package/dist/e2e/fixtures/main.js +97 -0
- package/dist/e2e/fixtures/main.js.map +1 -0
- package/dist/e2e/fixtures/vite.config.d.ts +3 -0
- package/dist/e2e/fixtures/vite.config.d.ts.map +1 -0
- package/dist/e2e/fixtures/vite.config.js +10 -0
- package/dist/e2e/fixtures/vite.config.js.map +1 -0
- package/dist/e2e/renown-components.spec.d.ts +2 -0
- package/dist/e2e/renown-components.spec.d.ts.map +1 -0
- package/dist/e2e/renown-components.spec.js +155 -0
- package/dist/e2e/renown-components.spec.js.map +1 -0
- package/dist/playwright.config.d.ts +3 -0
- package/dist/playwright.config.d.ts.map +1 -0
- package/dist/playwright.config.js +25 -0
- package/dist/playwright.config.js.map +1 -0
- package/dist/src/assets/assets.d.ts +19 -0
- package/dist/src/assets/renown-hover.svg +17 -0
- package/dist/src/assets/renown-light.svg +15 -0
- package/dist/src/assets/renown-short-hover.png +0 -0
- package/dist/src/assets/renown-short.png +0 -0
- package/dist/src/assets/renown.svg +16 -0
- package/dist/src/common.d.ts +1 -1
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/components/RenownAuthButton.d.ts +62 -0
- package/dist/src/components/RenownAuthButton.d.ts.map +1 -0
- package/dist/src/components/RenownAuthButton.js +82 -0
- package/dist/src/components/RenownAuthButton.js.map +1 -0
- package/dist/src/components/RenownLoginButton.d.ts +48 -0
- package/dist/src/components/RenownLoginButton.d.ts.map +1 -0
- package/dist/src/components/RenownLoginButton.js +175 -0
- package/dist/src/components/RenownLoginButton.js.map +1 -0
- package/dist/src/components/RenownUserButton.d.ts +66 -0
- package/dist/src/components/RenownUserButton.d.ts.map +1 -0
- package/dist/src/components/RenownUserButton.js +216 -0
- package/dist/src/components/RenownUserButton.js.map +1 -0
- package/dist/src/components/icons.d.ts +25 -0
- package/dist/src/components/icons.d.ts.map +1 -0
- package/dist/src/components/icons.js +24 -0
- package/dist/src/components/icons.js.map +1 -0
- package/dist/src/components/image-data.d.ts +3 -0
- package/dist/src/components/image-data.d.ts.map +1 -0
- package/dist/src/components/image-data.js +4 -0
- package/dist/src/components/image-data.js.map +1 -0
- package/dist/src/components/index.d.ts +7 -3
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +4 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/crypto/index.d.ts +1 -0
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +1 -0
- package/dist/src/crypto/index.js.map +1 -1
- package/dist/src/crypto/signer.d.ts +21 -0
- package/dist/src/crypto/signer.d.ts.map +1 -0
- package/dist/src/crypto/signer.js +236 -0
- package/dist/src/crypto/signer.js.map +1 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.d.ts.map +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/use-user.d.ts +21 -0
- package/dist/src/hooks/use-user.d.ts.map +1 -0
- package/dist/src/hooks/use-user.js +30 -0
- package/dist/src/hooks/use-user.js.map +1 -0
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/crypto/browser.d.ts +8 -0
- package/dist/src/lib/crypto/browser.d.ts.map +1 -0
- package/dist/src/lib/crypto/browser.js +73 -0
- package/dist/src/lib/crypto/browser.js.map +1 -0
- package/dist/src/lib/crypto/index.d.ts +36 -0
- package/dist/src/lib/crypto/index.d.ts.map +1 -0
- package/dist/src/lib/crypto/index.js +150 -0
- package/dist/src/lib/crypto/index.js.map +1 -0
- package/dist/src/lib/crypto/node.d.ts +8 -0
- package/dist/src/lib/crypto/node.d.ts.map +1 -0
- package/dist/src/lib/crypto/node.js +67 -0
- package/dist/src/lib/crypto/node.js.map +1 -0
- package/dist/src/lib/renown/constants.d.ts +130 -0
- package/dist/src/lib/renown/constants.d.ts.map +1 -0
- package/dist/src/lib/renown/constants.js +40 -0
- package/dist/src/lib/renown/constants.js.map +1 -0
- package/dist/src/lib/renown/did-parser.d.ts +28 -0
- package/dist/src/lib/renown/did-parser.d.ts.map +1 -0
- package/dist/src/lib/renown/did-parser.js +57 -0
- package/dist/src/lib/renown/did-parser.js.map +1 -0
- package/dist/src/lib/renown/index.d.ts +4 -0
- package/dist/src/lib/renown/index.d.ts.map +1 -0
- package/dist/src/lib/renown/index.js +4 -0
- package/dist/src/lib/renown/index.js.map +1 -0
- package/dist/src/lib/renown/utils.d.ts +33 -0
- package/dist/src/lib/renown/utils.d.ts.map +1 -0
- package/dist/src/lib/renown/utils.js +207 -0
- package/dist/src/lib/renown/utils.js.map +1 -0
- package/dist/src/lib/session-storage.d.ts +40 -0
- package/dist/src/lib/session-storage.d.ts.map +1 -0
- package/dist/src/lib/session-storage.js +107 -0
- package/dist/src/lib/session-storage.js.map +1 -0
- package/dist/src/providers/index.d.ts +3 -0
- package/dist/src/providers/index.d.ts.map +1 -0
- package/dist/src/providers/index.js +2 -0
- package/dist/src/providers/index.js.map +1 -0
- package/dist/src/providers/renown-user-provider.d.ts +72 -0
- package/dist/src/providers/renown-user-provider.d.ts.map +1 -0
- package/dist/src/providers/renown-user-provider.js +171 -0
- package/dist/src/providers/renown-user-provider.js.map +1 -0
- package/dist/src/types.d.ts +3 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -6
- package/dist/src/components/RenownLoginAvatar.d.ts +0 -44
- package/dist/src/components/RenownLoginAvatar.d.ts.map +0 -1
- package/dist/src/components/RenownLoginAvatar.js +0 -50
- package/dist/src/components/RenownLoginAvatar.js.map +0 -1
- package/dist/src/components/types.d.ts +0 -12
- package/dist/src/components/types.d.ts.map +0 -1
- package/dist/src/components/types.js +0 -2
- package/dist/src/components/types.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { SessionStorageManager } from "../session-storage.js";
|
|
2
|
+
import { RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, RENOWN_URL } from "./constants.js";
|
|
3
|
+
import { extractEthAddressFromDid } from "./did-parser.js";
|
|
4
|
+
// Helper function to fetch user profile from renown API
|
|
5
|
+
async function fetchUserProfileFromRenown(ethAddress) {
|
|
6
|
+
try {
|
|
7
|
+
const response = await fetch(`${RENOWN_URL}/api/profile`, {
|
|
8
|
+
method: "POST",
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
},
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
ethAddress,
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
const result = (await response.json());
|
|
20
|
+
const profile = result.profile;
|
|
21
|
+
if (profile) {
|
|
22
|
+
return {
|
|
23
|
+
documentId: profile.documentId,
|
|
24
|
+
username: profile.username,
|
|
25
|
+
ethAddress: profile.ethAddress,
|
|
26
|
+
userImage: profile.userImage,
|
|
27
|
+
createdAt: profile.createdAt,
|
|
28
|
+
updatedAt: profile.updatedAt,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Error fetching user profile from renown:", error);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Helper function to fetch profile data for a user
|
|
39
|
+
export async function fetchProfileDataForUser(user) {
|
|
40
|
+
try {
|
|
41
|
+
const ethAddress = extractEthAddressFromDid(user.did);
|
|
42
|
+
if (!ethAddress) {
|
|
43
|
+
console.warn("Could not extract ETH address from DID:", user.did);
|
|
44
|
+
return user;
|
|
45
|
+
}
|
|
46
|
+
// Get profile data from renown API
|
|
47
|
+
const profile = await fetchUserProfileFromRenown(ethAddress);
|
|
48
|
+
if (profile) {
|
|
49
|
+
return {
|
|
50
|
+
...user,
|
|
51
|
+
name: profile.username || undefined,
|
|
52
|
+
avatar: profile.userImage || undefined,
|
|
53
|
+
ethAddress: profile.ethAddress || undefined,
|
|
54
|
+
documentId: profile.documentId,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// If no profile found, return user with ethAddress
|
|
58
|
+
return {
|
|
59
|
+
...user,
|
|
60
|
+
ethAddress,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error("Failed to fetch profile data for user:", error);
|
|
65
|
+
return user;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export async function openRenown(documentId) {
|
|
69
|
+
// If documentId is provided, open the profile page directly
|
|
70
|
+
if (documentId) {
|
|
71
|
+
const profileUrl = `${RENOWN_URL}/profile/${documentId}`;
|
|
72
|
+
window.open(profileUrl, "_blank")?.focus();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Otherwise, open the auth flow
|
|
76
|
+
const url = new URL(RENOWN_URL);
|
|
77
|
+
// Get DID from connectCrypto if available
|
|
78
|
+
let connectDid = "";
|
|
79
|
+
if (window.connectCrypto) {
|
|
80
|
+
try {
|
|
81
|
+
connectDid = await window.connectCrypto.did();
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error("Failed to get DID from connectCrypto:", error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.warn("connectCrypto not available - authentication may not be properly initialized");
|
|
89
|
+
}
|
|
90
|
+
url.searchParams.set("connect", connectDid);
|
|
91
|
+
url.searchParams.set("network", RENOWN_NETWORK_ID);
|
|
92
|
+
url.searchParams.set("chain", RENOWN_CHAIN_ID);
|
|
93
|
+
const returnUrl = new URL(window.location.pathname, window.location.origin);
|
|
94
|
+
url.searchParams.set("returnUrl", returnUrl.toJSON());
|
|
95
|
+
window.open(url, "_self")?.focus();
|
|
96
|
+
}
|
|
97
|
+
// Check for return from Renown authentication and handle login
|
|
98
|
+
export async function handleRenownReturn() {
|
|
99
|
+
if (typeof window === "undefined")
|
|
100
|
+
return;
|
|
101
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
102
|
+
const userDid = decodeURIComponent(urlParams.get("user") ?? "");
|
|
103
|
+
// If we have authentication parameters, attempt login
|
|
104
|
+
if (userDid && window.renown && window.connectCrypto) {
|
|
105
|
+
try {
|
|
106
|
+
await login(userDid, window.renown, window.connectCrypto);
|
|
107
|
+
// Clean up URL parameters
|
|
108
|
+
const cleanUrl = new URL(window.location.href);
|
|
109
|
+
cleanUrl.searchParams.delete("user");
|
|
110
|
+
window.history.replaceState({}, "", cleanUrl.toString());
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error("Failed to handle Renown return:", error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export async function login(userDid, renown, connectCrypto) {
|
|
118
|
+
if (!renown || !connectCrypto) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Validate that userDid is a valid pkh DID format
|
|
122
|
+
if (userDid && !userDid.startsWith("did:pkh:")) {
|
|
123
|
+
console.warn("Invalid DID format for login:", userDid, "- expected did:pkh: format");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
let user = renown.user instanceof Function ? renown.user() : renown.user;
|
|
128
|
+
user = user instanceof Promise ? await user : user;
|
|
129
|
+
if (user?.did && (user.did === userDid || !userDid)) {
|
|
130
|
+
// Fetch profile data for the user
|
|
131
|
+
const userWithProfile = await fetchProfileDataForUser(user);
|
|
132
|
+
// Set up JWT handler if reactor is available
|
|
133
|
+
// Store user data in sessionStorage for persistence
|
|
134
|
+
SessionStorageManager.setUserData({
|
|
135
|
+
user: userWithProfile,
|
|
136
|
+
userDid: userWithProfile.did,
|
|
137
|
+
loginStatus: "authorized",
|
|
138
|
+
timestamp: Date.now(),
|
|
139
|
+
});
|
|
140
|
+
return userWithProfile;
|
|
141
|
+
}
|
|
142
|
+
if (!userDid) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const newUser = await renown.login(userDid ?? "");
|
|
146
|
+
if (newUser) {
|
|
147
|
+
// Fetch profile data for the user
|
|
148
|
+
const userWithProfile = await fetchProfileDataForUser(newUser);
|
|
149
|
+
// Set up JWT handler if reactor is available
|
|
150
|
+
// Store user data in sessionStorage for persistence
|
|
151
|
+
SessionStorageManager.setUserData({
|
|
152
|
+
user: userWithProfile,
|
|
153
|
+
userDid: userWithProfile.did,
|
|
154
|
+
loginStatus: "authorized",
|
|
155
|
+
timestamp: Date.now(),
|
|
156
|
+
});
|
|
157
|
+
return userWithProfile;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error("Renown login error:", error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export async function logout() {
|
|
166
|
+
const renown = window.renown;
|
|
167
|
+
const reactor = window.reactor;
|
|
168
|
+
// Clear sessionStorage data
|
|
169
|
+
SessionStorageManager.clearUserData();
|
|
170
|
+
await renown?.logout();
|
|
171
|
+
reactor?.removeJwtHandler();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Re-authenticate using stored session data
|
|
175
|
+
* This allows calling renown.login without needing to go through the full auth flow again
|
|
176
|
+
*/
|
|
177
|
+
export async function reauthenticateFromSession() {
|
|
178
|
+
if (typeof window === "undefined" ||
|
|
179
|
+
!window.renown ||
|
|
180
|
+
!window.connectCrypto) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const storedUserDid = SessionStorageManager.getStoredUserDid();
|
|
184
|
+
if (!storedUserDid) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
await login(storedUserDid, window.renown, window.connectCrypto);
|
|
189
|
+
// Get the current user after login
|
|
190
|
+
let currentUser = window.renown.user instanceof Function
|
|
191
|
+
? window.renown.user()
|
|
192
|
+
: window.renown.user;
|
|
193
|
+
currentUser =
|
|
194
|
+
currentUser instanceof Promise ? await currentUser : currentUser;
|
|
195
|
+
if (currentUser) {
|
|
196
|
+
// Fetch profile data for the restored user
|
|
197
|
+
const userWithProfile = await fetchProfileDataForUser(currentUser);
|
|
198
|
+
return userWithProfile;
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
console.error("Failed to re-authenticate from session:", error);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/lib/renown/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AA4B3D,wDAAwD;AACxD,KAAK,UAAU,0BAA0B,CACvC,UAAkB;IAElB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,UAAU,cAAc,EAAE;YACxD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU;aACX,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,C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AAY,QAAQ;YACpC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;YACtB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QACzB,WAAW;YACT,WAAW,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;QAEnE,IAAI,WAAW,EAAE,CAAC;YAChB,2CAA2C;YAC3C,MAAM,eAAe,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;YACnE,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { User } from "./renown/utils.js";
|
|
2
|
+
export interface SessionUserData {
|
|
3
|
+
user: User;
|
|
4
|
+
userDid: string;
|
|
5
|
+
loginStatus: "authorized";
|
|
6
|
+
timestamp: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Session storage utilities for Renown authentication
|
|
10
|
+
* Stores user data in sessionStorage to persist across page reloads
|
|
11
|
+
* but clears when the browser session ends
|
|
12
|
+
*/
|
|
13
|
+
export declare class SessionStorageManager {
|
|
14
|
+
/**
|
|
15
|
+
* Store user authentication data in sessionStorage
|
|
16
|
+
*/
|
|
17
|
+
static setUserData(userData: SessionUserData): void;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve user authentication data from sessionStorage
|
|
20
|
+
*/
|
|
21
|
+
static getUserData(): SessionUserData | null;
|
|
22
|
+
/**
|
|
23
|
+
* Check if user data exists in sessionStorage
|
|
24
|
+
*/
|
|
25
|
+
static hasUserData(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Clear all user authentication data from sessionStorage
|
|
28
|
+
*/
|
|
29
|
+
static clearUserData(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Check if stored user data is still valid (not expired)
|
|
32
|
+
* You can implement expiration logic here if needed
|
|
33
|
+
*/
|
|
34
|
+
static isUserDataValid(userData: SessionUserData): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get the stored user DID for easy re-authentication
|
|
37
|
+
*/
|
|
38
|
+
static getStoredUserDid(): string | null;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=session-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../../src/lib/session-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQ9C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,YAAY,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,qBAAa,qBAAqB;IAChC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAmBnD;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,eAAe,GAAG,IAAI;IA8B5C;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,OAAO;IAU7B;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,IAAI;IAa5B;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO;IAM1D;;OAEG;IACH,MAAM,CAAC,gBAAgB,IAAI,MAAM,GAAG,IAAI;CAUzC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const SESSION_STORAGE_KEYS = {
|
|
3
|
+
USER: "renown_user",
|
|
4
|
+
LOGIN_STATUS: "renown_login_status",
|
|
5
|
+
USER_DID: "renown_user_did",
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Session storage utilities for Renown authentication
|
|
9
|
+
* Stores user data in sessionStorage to persist across page reloads
|
|
10
|
+
* but clears when the browser session ends
|
|
11
|
+
*/
|
|
12
|
+
export class SessionStorageManager {
|
|
13
|
+
/**
|
|
14
|
+
* Store user authentication data in sessionStorage
|
|
15
|
+
*/
|
|
16
|
+
static setUserData(userData) {
|
|
17
|
+
if (typeof window === "undefined")
|
|
18
|
+
return;
|
|
19
|
+
try {
|
|
20
|
+
sessionStorage.setItem(SESSION_STORAGE_KEYS.USER, JSON.stringify(userData.user));
|
|
21
|
+
sessionStorage.setItem(SESSION_STORAGE_KEYS.USER_DID, userData.userDid);
|
|
22
|
+
sessionStorage.setItem(SESSION_STORAGE_KEYS.LOGIN_STATUS, userData.loginStatus);
|
|
23
|
+
sessionStorage.setItem("renown_timestamp", userData.timestamp.toString());
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error("Failed to store user data in sessionStorage:", error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve user authentication data from sessionStorage
|
|
31
|
+
*/
|
|
32
|
+
static getUserData() {
|
|
33
|
+
if (typeof window === "undefined")
|
|
34
|
+
return null;
|
|
35
|
+
try {
|
|
36
|
+
const userStr = sessionStorage.getItem(SESSION_STORAGE_KEYS.USER);
|
|
37
|
+
const userDid = sessionStorage.getItem(SESSION_STORAGE_KEYS.USER_DID);
|
|
38
|
+
const loginStatus = sessionStorage.getItem(SESSION_STORAGE_KEYS.LOGIN_STATUS);
|
|
39
|
+
const timestampStr = sessionStorage.getItem("renown_timestamp");
|
|
40
|
+
if (!userStr || !userDid || !loginStatus || !timestampStr) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const user = JSON.parse(userStr);
|
|
44
|
+
const timestamp = parseInt(timestampStr, 10);
|
|
45
|
+
return {
|
|
46
|
+
user,
|
|
47
|
+
userDid,
|
|
48
|
+
loginStatus: loginStatus,
|
|
49
|
+
timestamp,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error("Failed to retrieve user data from sessionStorage:", error);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if user data exists in sessionStorage
|
|
59
|
+
*/
|
|
60
|
+
static hasUserData() {
|
|
61
|
+
if (typeof window === "undefined")
|
|
62
|
+
return false;
|
|
63
|
+
return !!(sessionStorage.getItem(SESSION_STORAGE_KEYS.USER) &&
|
|
64
|
+
sessionStorage.getItem(SESSION_STORAGE_KEYS.USER_DID) &&
|
|
65
|
+
sessionStorage.getItem(SESSION_STORAGE_KEYS.LOGIN_STATUS));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Clear all user authentication data from sessionStorage
|
|
69
|
+
*/
|
|
70
|
+
static clearUserData() {
|
|
71
|
+
if (typeof window === "undefined")
|
|
72
|
+
return;
|
|
73
|
+
try {
|
|
74
|
+
sessionStorage.removeItem(SESSION_STORAGE_KEYS.USER);
|
|
75
|
+
sessionStorage.removeItem(SESSION_STORAGE_KEYS.USER_DID);
|
|
76
|
+
sessionStorage.removeItem(SESSION_STORAGE_KEYS.LOGIN_STATUS);
|
|
77
|
+
sessionStorage.removeItem("renown_timestamp");
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error("Failed to clear user data from sessionStorage:", error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if stored user data is still valid (not expired)
|
|
85
|
+
* You can implement expiration logic here if needed
|
|
86
|
+
*/
|
|
87
|
+
static isUserDataValid(userData) {
|
|
88
|
+
// For now, we consider session data valid for the entire browser session
|
|
89
|
+
// You can add expiration logic here if needed
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the stored user DID for easy re-authentication
|
|
94
|
+
*/
|
|
95
|
+
static getStoredUserDid() {
|
|
96
|
+
if (typeof window === "undefined")
|
|
97
|
+
return null;
|
|
98
|
+
try {
|
|
99
|
+
return sessionStorage.getItem(SESSION_STORAGE_KEYS.USER_DID);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error("Failed to get stored user DID:", error);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=session-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../../src/lib/session-storage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,aAAa;IACnB,YAAY,EAAE,qBAAqB;IACnC,QAAQ,EAAE,iBAAiB;CACnB,CAAC;AASX;;;;GAIG;AACH,MAAM,OAAO,qBAAqB;IAChC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAyB;QAC1C,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO;QAE1C,IAAI,CAAC;YACH,cAAc,CAAC,OAAO,CACpB,oBAAoB,CAAC,IAAI,EACzB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC9B,CAAC;YACF,cAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxE,cAAc,CAAC,OAAO,CACpB,oBAAoB,CAAC,YAAY,EACjC,QAAQ,CAAC,WAAW,CACrB,CAAC;YACF,cAAc,CAAC,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAA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H,MAAM,CAAC,aAAa;QAClB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO;QAE1C,IAAI,CAAC;YACH,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YACrD,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YACzD,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;YAC7D,cAAc,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,QAAyB;QAC9C,yEAAyE;QACzE,8CAA8C;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB;QACrB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,IAAI,CAAC;QAE/C,IAAI,CAAC;YACH,OAAO,cAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { IConnectCrypto } from "../crypto/index.js";
|
|
2
|
+
import type { LoginStatus, User } from "../lib/renown/index.js";
|
|
3
|
+
import type { IRenown } from "../types.js";
|
|
4
|
+
export interface RenownUserContextValue {
|
|
5
|
+
/** Current authenticated user, null if not authenticated */
|
|
6
|
+
user: User | null;
|
|
7
|
+
/** Current login status */
|
|
8
|
+
loginStatus: LoginStatus;
|
|
9
|
+
/** Whether auth operations are in progress */
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
/** Whether the user system has been initialized */
|
|
12
|
+
isInitialized: boolean;
|
|
13
|
+
/** Login with optional DID (defaults to connectCrypto DID) */
|
|
14
|
+
login: (userDid?: string) => Promise<void>;
|
|
15
|
+
/** Logout the current user */
|
|
16
|
+
logout: () => Promise<void>;
|
|
17
|
+
/** Open Renown portal for authentication */
|
|
18
|
+
openRenown: () => void;
|
|
19
|
+
/** ConnectCrypto instance for cryptographic operations */
|
|
20
|
+
connectCrypto: IConnectCrypto | null;
|
|
21
|
+
/** Renown SDK instance */
|
|
22
|
+
renown: IRenown | null;
|
|
23
|
+
}
|
|
24
|
+
export declare const RenownUserContext: import("react").Context<RenownUserContextValue | null>;
|
|
25
|
+
interface RenownUserProviderProps {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Renown service URL
|
|
29
|
+
* @default 'https://www.renown.id'
|
|
30
|
+
*/
|
|
31
|
+
renownUrl?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Network ID (e.g., 'eip155')
|
|
34
|
+
* @default 'eip155'
|
|
35
|
+
*/
|
|
36
|
+
networkId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Chain ID (e.g., '1' for Ethereum mainnet)
|
|
39
|
+
* @default '1'
|
|
40
|
+
*/
|
|
41
|
+
chainId?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom loading component shown during initialization
|
|
44
|
+
* If not provided, renders children immediately (no loading screen)
|
|
45
|
+
*/
|
|
46
|
+
loadingComponent?: React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Custom error component shown if initialization fails
|
|
49
|
+
* Receives the error and a retry function
|
|
50
|
+
*/
|
|
51
|
+
errorComponent?: (error: Error, retry: () => void) => React.ReactNode;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* RenownUserProvider - Central user provider for Renown
|
|
55
|
+
*
|
|
56
|
+
* Automatically initializes the Renown SDK and provides user state.
|
|
57
|
+
* Handles initialization, login, logout, and session management.
|
|
58
|
+
*
|
|
59
|
+
* Usage:
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Wrap your app
|
|
62
|
+
* <RenownUserProvider renownUrl="https://www.renown.id">
|
|
63
|
+
* <YourApp />
|
|
64
|
+
* </RenownUserProvider>
|
|
65
|
+
*
|
|
66
|
+
* // In any component
|
|
67
|
+
* const { user, login, logout } = useUser()
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function RenownUserProvider({ children, renownUrl, networkId, chainId, loadingComponent, errorComponent, }: RenownUserProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=renown-user-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renown-user-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/renown-user-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAW3C,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,2BAA2B;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,8CAA8C;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,aAAa,EAAE,OAAO,CAAC;IACvB,8DAA8D;IAC9D,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,8BAA8B;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,4CAA4C;IAC5C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,0DAA0D;IAC1D,aAAa,EAAE,cAAc,GAAG,IAAI,CAAC;IACrC,0BAA0B;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,wDAE7B,CAAC;AAEF,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,SAAmC,EACnC,SAAoB,EACpB,OAAa,EACb,gBAAgB,EAChB,cAAc,GACf,EAAE,uBAAuB,2CA6KzB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { BrowserKeyStorage, ConnectCrypto } from "../crypto/index.js";
|
|
5
|
+
import { initRenown } from "../init.browser.js";
|
|
6
|
+
import { fetchProfileDataForUser, handleRenownReturn, openRenown as openRenownPortal, login as renownLogin, logout as renownLogout, } from "../lib/renown/index.js";
|
|
7
|
+
import { SessionStorageManager } from "../lib/session-storage.js";
|
|
8
|
+
export const RenownUserContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* RenownUserProvider - Central user provider for Renown
|
|
11
|
+
*
|
|
12
|
+
* Automatically initializes the Renown SDK and provides user state.
|
|
13
|
+
* Handles initialization, login, logout, and session management.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Wrap your app
|
|
18
|
+
* <RenownUserProvider renownUrl="https://www.renown.id">
|
|
19
|
+
* <YourApp />
|
|
20
|
+
* </RenownUserProvider>
|
|
21
|
+
*
|
|
22
|
+
* // In any component
|
|
23
|
+
* const { user, login, logout } = useUser()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function RenownUserProvider({ children, renownUrl = "https://www.renown.id", networkId = "eip155", chainId = "1", loadingComponent, errorComponent, }) {
|
|
27
|
+
const [user, setUser] = useState(null);
|
|
28
|
+
const [loginStatus, setLoginStatus] = useState("initial");
|
|
29
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
30
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
31
|
+
const [initError, setInitError] = useState(null);
|
|
32
|
+
const [connectCrypto, setConnectCrypto] = useState(null);
|
|
33
|
+
const [renown, setRenown] = useState(null);
|
|
34
|
+
// Initialize auth system
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const init = async () => {
|
|
37
|
+
try {
|
|
38
|
+
if (typeof window === "undefined") {
|
|
39
|
+
setIsInitialized(true);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Initialize SDK if not already initialized
|
|
43
|
+
if (!window.renown || !window.connectCrypto) {
|
|
44
|
+
// Initialize ConnectCrypto with browser key storage
|
|
45
|
+
const cryptoInstance = new ConnectCrypto(new BrowserKeyStorage());
|
|
46
|
+
// Initialize Renown SDK
|
|
47
|
+
const renownInstance = initRenown(await cryptoInstance.did(), networkId, renownUrl);
|
|
48
|
+
// Attach to window for global access
|
|
49
|
+
window.renown = renownInstance;
|
|
50
|
+
window.connectCrypto = cryptoInstance;
|
|
51
|
+
// Save to state
|
|
52
|
+
setConnectCrypto(cryptoInstance);
|
|
53
|
+
setRenown(renownInstance);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Use existing instances from window
|
|
57
|
+
setConnectCrypto(window.connectCrypto);
|
|
58
|
+
setRenown(window.renown);
|
|
59
|
+
}
|
|
60
|
+
// Check for stored session first
|
|
61
|
+
const storedUserData = SessionStorageManager.getUserData();
|
|
62
|
+
if (storedUserData &&
|
|
63
|
+
SessionStorageManager.isUserDataValid(storedUserData)) {
|
|
64
|
+
// Restore user from stored session
|
|
65
|
+
const userWithProfile = await fetchProfileDataForUser(storedUserData.user);
|
|
66
|
+
setUser(userWithProfile);
|
|
67
|
+
setLoginStatus("authorized");
|
|
68
|
+
setIsInitialized(true);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Handle return from Renown authentication
|
|
72
|
+
await handleRenownReturn();
|
|
73
|
+
// Check if user is already logged in
|
|
74
|
+
let currentUser = window.renown.user instanceof Function
|
|
75
|
+
? window.renown.user()
|
|
76
|
+
: window.renown.user;
|
|
77
|
+
currentUser =
|
|
78
|
+
currentUser instanceof Promise ? await currentUser : currentUser;
|
|
79
|
+
if (currentUser) {
|
|
80
|
+
// Fetch profile data for the logged-in user
|
|
81
|
+
const userWithProfile = await fetchProfileDataForUser(currentUser);
|
|
82
|
+
setUser(userWithProfile);
|
|
83
|
+
setLoginStatus("authorized");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
setLoginStatus("not-authorized");
|
|
87
|
+
}
|
|
88
|
+
setIsInitialized(true);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error("Failed to initialize authentication:", error);
|
|
92
|
+
setInitError(error);
|
|
93
|
+
setLoginStatus("not-authorized");
|
|
94
|
+
// Still set as initialized to prevent infinite loading
|
|
95
|
+
setIsInitialized(true);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
init();
|
|
99
|
+
}, [renownUrl, networkId, chainId]);
|
|
100
|
+
// Login handler
|
|
101
|
+
const login = useCallback(async (userDid) => {
|
|
102
|
+
if (typeof window === "undefined")
|
|
103
|
+
return;
|
|
104
|
+
const renown = window.renown;
|
|
105
|
+
const connectCrypto = window.connectCrypto;
|
|
106
|
+
if (!renown || !connectCrypto) {
|
|
107
|
+
console.error("Renown or ConnectCrypto not available");
|
|
108
|
+
setLoginStatus("not-authorized");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
setIsLoading(true);
|
|
113
|
+
setLoginStatus("checking");
|
|
114
|
+
const did = userDid || (await connectCrypto.did());
|
|
115
|
+
// Perform login
|
|
116
|
+
const loggedInUser = await renownLogin(did, renown, connectCrypto);
|
|
117
|
+
if (loggedInUser) {
|
|
118
|
+
// Fetch profile data and update state
|
|
119
|
+
const userWithProfile = await fetchProfileDataForUser(loggedInUser);
|
|
120
|
+
setUser(userWithProfile);
|
|
121
|
+
setLoginStatus("authorized");
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
setLoginStatus("not-authorized");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error("Login failed:", error);
|
|
129
|
+
setLoginStatus("not-authorized");
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
setIsLoading(false);
|
|
133
|
+
}
|
|
134
|
+
}, []);
|
|
135
|
+
// Logout handler
|
|
136
|
+
const logout = useCallback(async () => {
|
|
137
|
+
try {
|
|
138
|
+
await renownLogout();
|
|
139
|
+
setUser(null);
|
|
140
|
+
setLoginStatus("not-authorized");
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error("Logout failed:", error);
|
|
144
|
+
}
|
|
145
|
+
}, []);
|
|
146
|
+
// Open Renown portal
|
|
147
|
+
const openRenown = useCallback(() => {
|
|
148
|
+
openRenownPortal();
|
|
149
|
+
}, []);
|
|
150
|
+
// Show loading state while initializing
|
|
151
|
+
if (!isInitialized && loadingComponent) {
|
|
152
|
+
return _jsx(_Fragment, { children: loadingComponent });
|
|
153
|
+
}
|
|
154
|
+
// Show error state if initialization failed
|
|
155
|
+
if (initError && errorComponent) {
|
|
156
|
+
return _jsx(_Fragment, { children: errorComponent(initError, () => window.location.reload()) });
|
|
157
|
+
}
|
|
158
|
+
const value = {
|
|
159
|
+
user,
|
|
160
|
+
loginStatus,
|
|
161
|
+
isLoading,
|
|
162
|
+
isInitialized,
|
|
163
|
+
login,
|
|
164
|
+
logout,
|
|
165
|
+
openRenown,
|
|
166
|
+
connectCrypto,
|
|
167
|
+
renown,
|
|
168
|
+
};
|
|
169
|
+
return (_jsx(RenownUserContext.Provider, { value: value, children: children }));
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=renown-user-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renown-user-provider.js","sourceRoot":"","sources":["../../../src/providers/renown-user-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,IAAI,gBAAgB,EAC9B,KAAK,IAAI,WAAW,EACpB,MAAM,IAAI,YAAY,GACvB,MAAM,wBAAwB,CAAC;AAChC,OA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