@renown/sdk 5.1.0-dev.9 → 5.1.0

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 (117) hide show
  1. package/README.md +1 -487
  2. package/dist/src/common.d.ts +1 -1
  3. package/dist/src/common.d.ts.map +1 -1
  4. package/dist/src/components/RenownLoginAvatar.d.ts +44 -0
  5. package/dist/src/components/RenownLoginAvatar.d.ts.map +1 -0
  6. package/dist/src/components/RenownLoginAvatar.js +50 -0
  7. package/dist/src/components/RenownLoginAvatar.js.map +1 -0
  8. package/dist/src/components/index.d.ts +3 -7
  9. package/dist/src/components/index.d.ts.map +1 -1
  10. package/dist/src/components/index.js +1 -4
  11. package/dist/src/components/index.js.map +1 -1
  12. package/dist/src/components/types.d.ts +12 -0
  13. package/dist/src/components/types.d.ts.map +1 -0
  14. package/dist/src/components/types.js +2 -0
  15. package/dist/src/components/types.js.map +1 -0
  16. package/dist/src/constants.d.ts +1 -1
  17. package/dist/src/constants.d.ts.map +1 -1
  18. package/dist/src/constants.js +1 -1
  19. package/dist/src/constants.js.map +1 -1
  20. package/dist/src/index.d.ts +1 -8
  21. package/dist/src/index.d.ts.map +1 -1
  22. package/dist/src/index.js +1 -8
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/types.d.ts +2 -3
  25. package/dist/src/types.d.ts.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +6 -26
  28. package/dist/e2e/fixtures/main.d.ts +0 -2
  29. package/dist/e2e/fixtures/main.d.ts.map +0 -1
  30. package/dist/e2e/fixtures/main.js +0 -97
  31. package/dist/e2e/fixtures/main.js.map +0 -1
  32. package/dist/e2e/fixtures/vite.config.d.ts +0 -3
  33. package/dist/e2e/fixtures/vite.config.d.ts.map +0 -1
  34. package/dist/e2e/fixtures/vite.config.js +0 -10
  35. package/dist/e2e/fixtures/vite.config.js.map +0 -1
  36. package/dist/e2e/renown-components.spec.d.ts +0 -2
  37. package/dist/e2e/renown-components.spec.d.ts.map +0 -1
  38. package/dist/e2e/renown-components.spec.js +0 -155
  39. package/dist/e2e/renown-components.spec.js.map +0 -1
  40. package/dist/playwright.config.d.ts +0 -3
  41. package/dist/playwright.config.d.ts.map +0 -1
  42. package/dist/playwright.config.js +0 -25
  43. package/dist/playwright.config.js.map +0 -1
  44. package/dist/src/assets/assets.d.ts +0 -19
  45. package/dist/src/assets/renown-hover.svg +0 -17
  46. package/dist/src/assets/renown-light.svg +0 -15
  47. package/dist/src/assets/renown-short-hover.png +0 -0
  48. package/dist/src/assets/renown-short.png +0 -0
  49. package/dist/src/assets/renown.svg +0 -16
  50. package/dist/src/components/RenownAuthButton.d.ts +0 -62
  51. package/dist/src/components/RenownAuthButton.d.ts.map +0 -1
  52. package/dist/src/components/RenownAuthButton.js +0 -82
  53. package/dist/src/components/RenownAuthButton.js.map +0 -1
  54. package/dist/src/components/RenownLoginButton.d.ts +0 -48
  55. package/dist/src/components/RenownLoginButton.d.ts.map +0 -1
  56. package/dist/src/components/RenownLoginButton.js +0 -175
  57. package/dist/src/components/RenownLoginButton.js.map +0 -1
  58. package/dist/src/components/RenownUserButton.d.ts +0 -66
  59. package/dist/src/components/RenownUserButton.d.ts.map +0 -1
  60. package/dist/src/components/RenownUserButton.js +0 -216
  61. package/dist/src/components/RenownUserButton.js.map +0 -1
  62. package/dist/src/components/icons.d.ts +0 -25
  63. package/dist/src/components/icons.d.ts.map +0 -1
  64. package/dist/src/components/icons.js +0 -24
  65. package/dist/src/components/icons.js.map +0 -1
  66. package/dist/src/components/image-data.d.ts +0 -3
  67. package/dist/src/components/image-data.d.ts.map +0 -1
  68. package/dist/src/components/image-data.js +0 -4
  69. package/dist/src/components/image-data.js.map +0 -1
  70. package/dist/src/hooks/index.d.ts +0 -2
  71. package/dist/src/hooks/index.d.ts.map +0 -1
  72. package/dist/src/hooks/index.js +0 -2
  73. package/dist/src/hooks/index.js.map +0 -1
  74. package/dist/src/hooks/use-user.d.ts +0 -21
  75. package/dist/src/hooks/use-user.d.ts.map +0 -1
  76. package/dist/src/hooks/use-user.js +0 -30
  77. package/dist/src/hooks/use-user.js.map +0 -1
  78. package/dist/src/lib/crypto/browser.d.ts +0 -8
  79. package/dist/src/lib/crypto/browser.d.ts.map +0 -1
  80. package/dist/src/lib/crypto/browser.js +0 -73
  81. package/dist/src/lib/crypto/browser.js.map +0 -1
  82. package/dist/src/lib/crypto/index.d.ts +0 -36
  83. package/dist/src/lib/crypto/index.d.ts.map +0 -1
  84. package/dist/src/lib/crypto/index.js +0 -150
  85. package/dist/src/lib/crypto/index.js.map +0 -1
  86. package/dist/src/lib/crypto/node.d.ts +0 -8
  87. package/dist/src/lib/crypto/node.d.ts.map +0 -1
  88. package/dist/src/lib/crypto/node.js +0 -67
  89. package/dist/src/lib/crypto/node.js.map +0 -1
  90. package/dist/src/lib/renown/constants.d.ts +0 -130
  91. package/dist/src/lib/renown/constants.d.ts.map +0 -1
  92. package/dist/src/lib/renown/constants.js +0 -40
  93. package/dist/src/lib/renown/constants.js.map +0 -1
  94. package/dist/src/lib/renown/did-parser.d.ts +0 -28
  95. package/dist/src/lib/renown/did-parser.d.ts.map +0 -1
  96. package/dist/src/lib/renown/did-parser.js +0 -57
  97. package/dist/src/lib/renown/did-parser.js.map +0 -1
  98. package/dist/src/lib/renown/index.d.ts +0 -4
  99. package/dist/src/lib/renown/index.d.ts.map +0 -1
  100. package/dist/src/lib/renown/index.js +0 -4
  101. package/dist/src/lib/renown/index.js.map +0 -1
  102. package/dist/src/lib/renown/utils.d.ts +0 -33
  103. package/dist/src/lib/renown/utils.d.ts.map +0 -1
  104. package/dist/src/lib/renown/utils.js +0 -207
  105. package/dist/src/lib/renown/utils.js.map +0 -1
  106. package/dist/src/lib/session-storage.d.ts +0 -40
  107. package/dist/src/lib/session-storage.d.ts.map +0 -1
  108. package/dist/src/lib/session-storage.js +0 -107
  109. package/dist/src/lib/session-storage.js.map +0 -1
  110. package/dist/src/providers/index.d.ts +0 -3
  111. package/dist/src/providers/index.d.ts.map +0 -1
  112. package/dist/src/providers/index.js +0 -2
  113. package/dist/src/providers/index.js.map +0 -1
  114. package/dist/src/providers/renown-user-provider.d.ts +0 -72
  115. package/dist/src/providers/renown-user-provider.d.ts.map +0 -1
  116. package/dist/src/providers/renown-user-provider.js +0 -171
  117. package/dist/src/providers/renown-user-provider.js.map +0 -1
package/README.md CHANGED
@@ -1,489 +1,3 @@
1
1
  # Renown SDK
2
2
 
3
- A comprehensive SDK for integrating Renown authentication and user profile management into your React applications.
4
-
5
- ## Features
6
-
7
- - 🔐 **Authentication** - Complete authentication flow with session management
8
- - 👤 **User Profiles** - Fetch and manage user profile data
9
- - ⚛️ **React Integration** - Provider and hooks for seamless React integration
10
- - 🎨 **UI Components** - Ready-to-use login and auth components
11
- - 🔄 **Session Persistence** - Automatic session restoration across page reloads
12
- - 🌐 **Renown Portal** - Easy integration with Renown authentication portal
13
- - 📦 **Type-Safe** - Full TypeScript support
14
-
15
- ## Installation
16
-
17
- ```bash
18
- npm install @renown/sdk
19
- # or
20
- yarn add @renown/sdk
21
- # or
22
- pnpm add @renown/sdk
23
- ```
24
-
25
- ## Quick Start
26
-
27
- ### 1. Wrap Your App with RenownUserProvider
28
-
29
- The SDK automatically initializes - just wrap your app!
30
-
31
- ```typescript
32
- // app/layout.tsx or app.tsx
33
- import { RenownUserProvider } from '@renown/sdk'
34
-
35
- export default function RootLayout({ children }) {
36
- return (
37
- <html>
38
- <body>
39
- <RenownUserProvider>
40
- {children}
41
- </RenownUserProvider>
42
- </body>
43
- </html>
44
- )
45
- }
46
- ```
47
-
48
- ### 2. Use Authentication in Components
49
-
50
- **Option A: Use the RenownAuthButton component**
51
-
52
- ```typescript
53
- import { RenownAuthButton } from '@renown/sdk'
54
-
55
- export function Header() {
56
- return (
57
- <header>
58
- <h1>My App</h1>
59
- <RenownAuthButton showLogoutButton />
60
- </header>
61
- )
62
- }
63
- ```
64
-
65
- **Option B: Build custom UI with useUser hook**
66
-
67
- ```typescript
68
- import { useUser } from '@renown/sdk'
69
-
70
- export function CustomAuth() {
71
- const { user, openRenown, logout } = useUser()
72
-
73
- if (!user) return <button onClick={openRenown}>Login</button>
74
- return <button onClick={logout}>Logout</button>
75
- }
76
- ```
77
-
78
- ## UI Components
79
-
80
- The SDK includes a ready-to-use React component for authentication:
81
-
82
- ### RenownAuthButton
83
-
84
- Smart button that adapts to auth state - shows login button when not authenticated, and user info when authenticated:
85
-
86
- ```typescript
87
- import { RenownAuthButton } from '@renown/sdk'
88
-
89
- <RenownAuthButton showLogoutButton />
90
- ```
91
-
92
- For detailed component documentation and examples, see [COMPONENTS.md](./COMPONENTS.md).
93
-
94
- ## API Reference
95
-
96
- ### Components
97
-
98
- #### `<RenownUserProvider>`
99
-
100
- Central authentication provider that automatically initializes the SDK.
101
-
102
- **Props:**
103
- - `children`: React.ReactNode - **Required.** Your application components
104
- - `renownUrl?`: string - Renown service URL (default: 'https://www.renown.id')
105
- - `networkId?`: string - Network ID (default: 'eip155')
106
- - `chainId?`: string - Chain ID (default: '1')
107
- - `loadingComponent?`: React.ReactNode - Custom loading UI
108
- - `errorComponent?`: (error, retry) => React.ReactNode - Custom error UI
109
-
110
- **Example:**
111
- ```typescript
112
- <RenownUserProvider>
113
- <App />
114
- </RenownUserProvider>
115
- ```
116
-
117
- **Custom Configuration:**
118
- ```typescript
119
- <RenownUserProvider
120
- renownUrl={process.env.NEXT_PUBLIC_RENOWN_URL}
121
- loadingComponent={<Spinner />}
122
- errorComponent={(error, retry) => <ErrorScreen error={error} onRetry={retry} />}
123
- >
124
- <App />
125
- </RenownUserProvider>
126
- ```
127
-
128
- ### Hooks
129
-
130
- #### `useUser()`
131
-
132
- Access authentication state and methods throughout your application.
133
-
134
- **Returns:**
135
- ```typescript
136
- {
137
- user: User | null // Current authenticated user
138
- loginStatus: LoginStatus // 'initial' | 'checking' | 'authorized' | 'not-authorized'
139
- isLoading: boolean // Loading state for auth operations
140
- isInitialized: boolean // Whether auth system is initialized
141
- login: (userDid?: string) => Promise<void> // Login with optional DID
142
- logout: () => Promise<void> // Logout current user
143
- openRenown: () => void // Open Renown portal
144
- }
145
- ```
146
-
147
- **Example:**
148
- ```typescript
149
- function UserProfile() {
150
- const { user, loginStatus, openRenown, logout } = useUser()
151
-
152
- switch (loginStatus) {
153
- case 'authorized':
154
- return (
155
- <div>
156
- <h1>{user?.name || 'User'}</h1>
157
- <p>{user?.did}</p>
158
- {user?.avatar && <img src={user.avatar} alt="Avatar" />}
159
- <button onClick={logout}>Logout</button>
160
- </div>
161
- )
162
- case 'not-authorized':
163
- return <button onClick={openRenown}>Login</button>
164
- default:
165
- return <div>Checking auth...</div>
166
- }
167
- }
168
- ```
169
-
170
- ### Types
171
-
172
- #### `User`
173
-
174
- ```typescript
175
- interface User {
176
- did: string // Decentralized identifier
177
- address: string // Ethereum address
178
- name?: string // Display name from profile
179
- email?: string // Email address
180
- avatar?: string // Avatar image URL
181
- ethAddress?: string // Ethereum address
182
- }
183
- ```
184
-
185
- #### `LoginStatus`
186
-
187
- ```typescript
188
- type LoginStatus =
189
- | 'initial' // Not yet checked
190
- | 'checking' // Currently checking auth
191
- | 'authorized' // User is authenticated
192
- | 'not-authorized' // User is not authenticated
193
- ```
194
-
195
- ### Utility Functions
196
-
197
- #### `fetchProfileDataForUser(user: User): Promise<User>`
198
-
199
- Fetches additional profile data from the Renown API for a given user.
200
-
201
- ```typescript
202
- import { fetchProfileDataForUser } from '@renown/sdk'
203
-
204
- const userWithProfile = await fetchProfileDataForUser(user)
205
- ```
206
-
207
- #### `login(userDid: string, renown: IRenown, connectCrypto: IConnectCrypto)`
208
-
209
- Performs login and stores session data.
210
-
211
- #### `logout()`
212
-
213
- Logs out the current user and clears session data.
214
-
215
- #### `openRenown()`
216
-
217
- Opens the Renown authentication portal.
218
-
219
- #### `handleRenownReturn()`
220
-
221
- Handles return from Renown authentication flow.
222
-
223
- ### Session Management
224
-
225
- #### `SessionStorageManager`
226
-
227
- Manages user session persistence in sessionStorage.
228
-
229
- **Methods:**
230
- - `setUserData(data)` - Store user data
231
- - `getUserData()` - Retrieve stored user data
232
- - `clearUserData()` - Clear session data
233
- - `isUserDataValid(data)` - Check if session data is valid
234
-
235
- ```typescript
236
- import { SessionStorageManager } from '@renown/sdk'
237
-
238
- // Store user session
239
- SessionStorageManager.setUserData({
240
- user: currentUser,
241
- userDid: currentUser.did,
242
- loginStatus: 'authorized',
243
- timestamp: Date.now()
244
- })
245
-
246
- // Check session
247
- const storedData = SessionStorageManager.getUserData()
248
- if (storedData && SessionStorageManager.isUserDataValid(storedData)) {
249
- // Session is valid
250
- }
251
- ```
252
-
253
- ## Advanced Usage
254
-
255
- ### Custom Authentication Flow
256
-
257
- You can implement custom authentication flows by directly using the SDK functions:
258
-
259
- ```typescript
260
- import { login, logout, initRenown, ConnectCrypto, BrowserKeyStorage } from '@renown/sdk'
261
-
262
- async function customLogin() {
263
- // Initialize
264
- const connectCrypto = new ConnectCrypto(new BrowserKeyStorage())
265
- const renown = await initRenown(
266
- await connectCrypto.did(),
267
- 'eip155',
268
- 'https://www.renown.id'
269
- )
270
-
271
- // Login
272
- const userDid = await connectCrypto.did()
273
- const user = await login(userDid, renown, connectCrypto)
274
-
275
- return user
276
- }
277
- ```
278
-
279
- ### Conditional Rendering Based on Auth
280
-
281
- ```typescript
282
- function ProtectedContent() {
283
- const { user, loginStatus, openRenown } = useUser()
284
-
285
- if (loginStatus !== 'authorized') {
286
- return (
287
- <div>
288
- <h1>Please login to continue</h1>
289
- <button onClick={openRenown}>Login</button>
290
- </div>
291
- )
292
- }
293
-
294
- return <div>Protected content for {user?.name}</div>
295
- }
296
- ```
297
-
298
- ### Handling Authentication Events
299
-
300
- ```typescript
301
- function AuthListener() {
302
- const { user, loginStatus } = useUser()
303
-
304
- useEffect(() => {
305
- if (loginStatus === 'authorized' && user) {
306
- console.log('User logged in:', user)
307
- // Analytics, notifications, etc.
308
- }
309
- }, [loginStatus, user])
310
-
311
- return null
312
- }
313
- ```
314
-
315
- ## Configuration
316
-
317
- ### RenownUserProvider Configuration
318
-
319
- The RenownUserProvider accepts optional configuration props:
320
-
321
- ```typescript
322
- <RenownUserProvider
323
- renownUrl="https://www.renown.id" // Custom Renown URL
324
- networkId="eip155" // Network ID (default)
325
- chainId="1" // Chain ID (default)
326
- >
327
- <App />
328
- </RenownUserProvider>
329
- ```
330
-
331
- ### Environment Variables
332
-
333
- Use environment variables for dynamic configuration:
334
-
335
- ```typescript
336
- <RenownUserProvider
337
- renownUrl={process.env.NEXT_PUBLIC_RENOWN_URL || 'https://www.renown.id'}
338
- >
339
- <App />
340
- </RenownUserProvider>
341
- ```
342
-
343
- ```bash
344
- # .env
345
- NEXT_PUBLIC_RENOWN_URL=https://www.renown.id
346
- ```
347
-
348
- ## Examples
349
-
350
- ### Next.js App Router
351
-
352
- ```typescript
353
- // app/layout.tsx
354
- import { RenownUserProvider } from '@renown/sdk'
355
-
356
- export default function RootLayout({ children }) {
357
- return (
358
- <html lang="en">
359
- <body>
360
- <RenownUserProvider>
361
- {children}
362
- </RenownUserProvider>
363
- </body>
364
- </html>
365
- )
366
- }
367
-
368
- // components/Navbar.tsx - Using RenownAuthButton
369
- 'use client'
370
-
371
- import { RenownAuthButton } from '@renown/sdk'
372
-
373
- export function Navbar() {
374
- return (
375
- <nav>
376
- <h1>My App</h1>
377
- <RenownAuthButton showLogoutButton />
378
- </nav>
379
- )
380
- }
381
-
382
- // app/profile/page.tsx - Using useUser hook
383
- 'use client'
384
-
385
- import { useUser } from '@renown/sdk'
386
-
387
- export default function ProfilePage() {
388
- const { user, openRenown, logout } = useUser()
389
-
390
- if (!user) {
391
- return (
392
- <div>
393
- <h1>Login Required</h1>
394
- <button onClick={openRenown}>Login with Renown</button>
395
- </div>
396
- )
397
- }
398
-
399
- return (
400
- <div>
401
- <h1>Profile</h1>
402
- <p>DID: {user.did}</p>
403
- <p>Name: {user.name}</p>
404
- <button onClick={logout}>Logout</button>
405
- </div>
406
- )
407
- }
408
- ```
409
-
410
- ### React SPA
411
-
412
- ```typescript
413
- // main.tsx
414
- import { RenownUserProvider } from '@renown/sdk'
415
- import App from './App'
416
-
417
- ReactDOM.createRoot(document.getElementById('root')!).render(
418
- <React.StrictMode>
419
- <RenownUserProvider>
420
- <App />
421
- </RenownUserProvider>
422
- </React.StrictMode>
423
- )
424
-
425
- // App.tsx - Using RenownAuthButton
426
- import { RenownAuthButton } from '@renown/sdk'
427
-
428
- function App() {
429
- return (
430
- <div>
431
- <h1>My App</h1>
432
- <RenownAuthButton showLogoutButton />
433
- </div>
434
- )
435
- }
436
- ```
437
-
438
- ## Troubleshooting
439
-
440
- ### RenownUserProvider Context Error
441
-
442
- **Error:** `useUser must be used within an RenownUserProvider`
443
-
444
- **Solution:** Ensure your component is wrapped by `<RenownUserProvider>`:
445
-
446
- ```typescript
447
- <RenownUserProvider>
448
- <YourComponent /> {/* ✅ Can use useUser */}
449
- </RenownUserProvider>
450
- ```
451
-
452
- ### Custom Renown URL
453
-
454
- To use a different Renown instance:
455
-
456
- ```typescript
457
- <RenownUserProvider renownUrl="https://your-renown-instance.com">
458
- <App />
459
- </RenownUserProvider>
460
- ```
461
-
462
- ### Session Not Persisting
463
-
464
- If sessions aren't persisting across page reloads:
465
-
466
- 1. Check that sessionStorage is available (not in incognito mode)
467
- 2. Verify the session hasn't expired (24 hour timeout by default)
468
- 3. Check browser console for any errors during initialization
469
-
470
- ## Contributing
471
-
472
- Contributions are welcome! Please read our contributing guidelines before submitting PRs.
473
-
474
- ## License
475
-
476
- AGPL-3.0-only
477
-
478
- ## Documentation
479
-
480
- Full documentation is available in the Powerhouse Academy:
481
- - [Overview & Quick Start](../../apps/academy/docs/academy/04-APIReferences/renown-sdk/00-Overview.md)
482
- - [Authentication Guide](../../apps/academy/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md)
483
- - [API Reference](../../apps/academy/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md)
484
-
485
- ## Support
486
-
487
- For issues and questions:
488
- - GitHub Issues: [powerhouse-inc/powerhouse](https://github.com/powerhouse-inc/powerhouse)
489
- - Documentation: [Powerhouse Academy](https://docs.powerhouse.io)
3
+ This package contains methods to interact with Renown and manage the user's session.
@@ -4,7 +4,7 @@ import type { CreateBearerTokenOptions } from "./utils.js";
4
4
  export declare class Renown implements IRenown {
5
5
  #private;
6
6
  constructor(store: RenownStorage, eventEmitter: RenownEventEmitter, connectId: string, baseUrl?: string);
7
- get user(): import("./types.js").InternalUser | undefined;
7
+ get user(): User | undefined;
8
8
  set connectId(connectId: string);
9
9
  login(did: string): Promise<User>;
10
10
  logout(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,IAAI,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAO3D,qBAAa,MAAO,YAAW,OAAO;;gBAOlC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,kBAAkB,EAChC,SAAS,EAAE,MAAM,EACjB,OAAO,SAAqB;IAY9B,IAAI,IAAI,kDAEP;IAWD,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,EAY9B;IAEK,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCvC,MAAM;IAKN,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EAC7B,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GACxC,MAAM,IAAI;IA6BP,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,iBAAiB,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB;CAapC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,IAAI,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAO3D,qBAAa,MAAO,YAAW,OAAO;;gBAOlC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,kBAAkB,EAChC,SAAS,EAAE,MAAM,EACjB,OAAO,SAAqB;IAY9B,IAAI,IAAI,qBAEP;IAWD,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,EAY9B;IAEK,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCvC,MAAM;IAKN,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EAC7B,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GACxC,MAAM,IAAI;IA6BP,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,iBAAiB,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB;CAapC"}
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import type { LoginAvatarProps } from "./types.js";
3
+ /**
4
+ * Headless Renown Login Avatar component
5
+ * Provides login button when not authenticated, and user avatar when authenticated
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <RenownLoginAvatar
10
+ * isLoggedIn={true}
11
+ * user={{ username: 'alice', avatar: 'https://...', ethAddress: '0x...' }}
12
+ * onLoginClick={() => console.log('Login')}
13
+ * profileBaseUrl="https://renown.io"
14
+ * renderAvatar={({ user, onClick }) => (
15
+ * <img src={user.avatar} alt={user.username} onClick={onClick} />
16
+ * )}
17
+ * renderButton={({ onClick }) => (
18
+ * <button onClick={onClick}>Log in</button>
19
+ * )}
20
+ * />
21
+ * ```
22
+ */
23
+ export interface RenownLoginAvatarProps extends LoginAvatarProps {
24
+ /**
25
+ * Custom render function for the avatar when logged in
26
+ */
27
+ renderAvatar?: (props: {
28
+ user: NonNullable<LoginAvatarProps["user"]>;
29
+ onClick: () => void;
30
+ }) => React.ReactNode;
31
+ /**
32
+ * Custom render function for the login button when not logged in
33
+ */
34
+ renderButton?: (props: {
35
+ onClick: () => void;
36
+ }) => React.ReactNode;
37
+ /**
38
+ * Base URL for the profile page (e.g., "https://renown.io/profile")
39
+ * Defaults to "https://renown.io/profile"
40
+ */
41
+ profileBaseUrl?: string;
42
+ }
43
+ export declare function RenownLoginAvatar({ isLoggedIn, user, onLoginClick, profileBaseUrl, renderAvatar, renderButton, }: RenownLoginAvatarProps): import("react/jsx-runtime").JSX.Element;
44
+ //# sourceMappingURL=RenownLoginAvatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenownLoginAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/RenownLoginAvatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,KAAK,KAAK,CAAC,SAAS,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC;IAEnE;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,cAA4C,EAC5C,YAAY,EACZ,YAAY,GACb,EAAE,sBAAsB,2CA+ExB"}
@@ -0,0 +1,50 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ export function RenownLoginAvatar({ isLoggedIn, user, onLoginClick, profileBaseUrl = "https://renown.io/profile", renderAvatar, renderButton, }) {
4
+ if (isLoggedIn && user) {
5
+ const handleProfileClick = () => {
6
+ const identifier = user.ethAddress || user.username;
7
+ window.open(`${profileBaseUrl}/${identifier}`, "_blank");
8
+ };
9
+ if (renderAvatar) {
10
+ return _jsx(_Fragment, { children: renderAvatar({ user, onClick: handleProfileClick }) });
11
+ }
12
+ // Default avatar rendering
13
+ return (_jsxs("div", { onClick: handleProfileClick, style: {
14
+ display: "inline-flex",
15
+ alignItems: "center",
16
+ gap: "0.5rem",
17
+ cursor: "pointer",
18
+ }, children: [user.avatar ? (_jsx("img", { src: user.avatar, alt: user.username, style: {
19
+ width: "2.5rem",
20
+ height: "2.5rem",
21
+ borderRadius: "50%",
22
+ objectFit: "cover",
23
+ } })) : (_jsx("div", { style: {
24
+ width: "2.5rem",
25
+ height: "2.5rem",
26
+ borderRadius: "50%",
27
+ backgroundColor: "#9333ea",
28
+ color: "white",
29
+ display: "flex",
30
+ alignItems: "center",
31
+ justifyContent: "center",
32
+ fontWeight: "bold",
33
+ fontSize: "0.875rem",
34
+ }, children: user.username.substring(0, 2).toUpperCase() })), _jsx("span", { style: { fontSize: "0.875rem", fontWeight: "500" }, children: user.username })] }));
35
+ }
36
+ if (renderButton) {
37
+ return _jsx(_Fragment, { children: renderButton({ onClick: onLoginClick || (() => { }) }) });
38
+ }
39
+ // Default button rendering
40
+ return (_jsx("button", { onClick: onLoginClick, style: {
41
+ padding: "0.5rem 1rem",
42
+ border: "1px solid #d1d5db",
43
+ borderRadius: "0.375rem",
44
+ backgroundColor: "white",
45
+ cursor: "pointer",
46
+ fontSize: "0.875rem",
47
+ fontWeight: "500",
48
+ }, children: "Log in" }));
49
+ }
50
+ //# sourceMappingURL=RenownLoginAvatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenownLoginAvatar.js","sourceRoot":"","sources":["../../../src/components/RenownLoginAvatar.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA4C1B,MAAM,UAAU,iBAAiB,CAAC,EAChC,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,cAAc,GAAG,2BAA2B,EAC5C,YAAY,EACZ,YAAY,GACW;IACvB,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,IAAI,UAAU,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC3D,CAAC,CAAC;QAEF,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,4BAAG,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,GAAI,CAAC;QACpE,CAAC;QAED,2BAA2B;QAC3B,OAAO,CACL,eACE,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE;gBACL,OAAO,EAAE,aAAa;gBACtB,UAAU,EAAE,QAAQ;gBACpB,GAAG,EAAE,QAAQ;gBACb,MAAM,EAAE,SAAS;aAClB,aAEA,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CACb,cACE,GAAG,EAAE,IAAI,CAAC,MAAM,EAChB,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,KAAK,EAAE;wBACL,KAAK,EAAE,QAAQ;wBACf,MAAM,EAAE,QAAQ;wBAChB,YAAY,EAAE,KAAK;wBACnB,SAAS,EAAE,OAAO;qBACnB,GACD,CACH,CAAC,CAAC,CAAC,CACF,cACE,KAAK,EAAE;wBACL,KAAK,EAAE,QAAQ;wBACf,MAAM,EAAE,QAAQ;wBAChB,YAAY,EAAE,KAAK;wBACnB,eAAe,EAAE,SAAS;wBAC1B,KAAK,EAAE,OAAO;wBACd,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE,QAAQ;wBACpB,cAAc,EAAE,QAAQ;wBACxB,UAAU,EAAE,MAAM;wBAClB,QAAQ,EAAE,UAAU;qBACrB,YAEA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GACxC,CACP,EACD,eAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YACrD,IAAI,CAAC,QAAQ,GACT,IACH,CACP,CAAC;IACJ,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,4BAAG,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAAE,CAAC,GAAI,CAAC;IACtE,CAAC;IAED,2BAA2B;IAC3B,OAAO,CACL,iBACE,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE;YACL,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,mBAAmB;YAC3B,YAAY,EAAE,UAAU;YACxB,eAAe,EAAE,OAAO;YACxB,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,KAAK;SAClB,uBAGM,CACV,CAAC;AACJ,CAAC"}
@@ -1,8 +1,4 @@
1
- export { RenownAuthButton } from "./RenownAuthButton.js";
2
- export type { RenownAuthButtonProps, RenownAuthButtonRenderProps, } from "./RenownAuthButton.js";
3
- export { RenownLoginButton } from "./RenownLoginButton.js";
4
- export type { RenownLoginButtonProps } from "./RenownLoginButton.js";
5
- export { RenownUserButton } from "./RenownUserButton.js";
6
- export type { RenownUserButtonProps } from "./RenownUserButton.js";
7
- export { RenownLogo, CopyIcon, ExternalLinkIcon, DisconnectIcon, SpinnerIcon, UserIcon, } from "./icons.js";
1
+ export { RenownLoginAvatar } from "./RenownLoginAvatar.js";
2
+ export type { RenownLoginAvatarProps } from "./RenownLoginAvatar.js";
3
+ export type { RenownUser, LoginAvatarProps } from "./types.js";
8
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EACV,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EACL,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,5 +1,2 @@
1
- export { RenownAuthButton } from "./RenownAuthButton.js";
2
- export { RenownLoginButton } from "./RenownLoginButton.js";
3
- export { RenownUserButton } from "./RenownUserButton.js";
4
- export { RenownLogo, CopyIcon, ExternalLinkIcon, DisconnectIcon, SpinnerIcon, UserIcon, } from "./icons.js";
1
+ export { RenownLoginAvatar } from "./RenownLoginAvatar.js";
5
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EACL,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface RenownUser {
2
+ username: string;
3
+ avatar?: string;
4
+ ethAddress?: string;
5
+ }
6
+ export interface LoginAvatarProps {
7
+ isLoggedIn: boolean;
8
+ user?: RenownUser;
9
+ onLoginClick?: () => void;
10
+ profileBaseUrl?: string;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- export declare const DEFAULT_RENOWN_URL = "https://www.renown.id";
1
+ export declare const DEFAULT_RENOWN_URL = "https://auth.renown.id";
2
2
  export declare const DEFAULT_RENOWN_NETWORK_ID = "eip155";
3
3
  export declare const DEFAULT_RENOWN_CHAIN_ID = "1";
4
4
  export declare const DOMAIN_TYPE: readonly [{
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EASpC,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;EAGhC,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;;;;;;EAI1B,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;EAGd,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMnB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EASpC,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;;;;EAGhC,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;;;;;;EAI1B,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;EAGd,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMnB,CAAC"}