@renown/sdk 6.0.0-dev.69 → 6.0.0-dev.77

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 (142) hide show
  1. package/dist/src/common.d.ts +5 -3
  2. package/dist/src/common.d.ts.map +1 -1
  3. package/dist/src/common.js +44 -12
  4. package/dist/src/common.js.map +1 -1
  5. package/dist/src/crypto/common.d.ts +6 -0
  6. package/dist/src/crypto/common.d.ts.map +1 -0
  7. package/dist/src/crypto/common.js +8 -0
  8. package/dist/src/crypto/common.js.map +1 -0
  9. package/dist/src/crypto/index.d.ts +1 -5
  10. package/dist/src/crypto/index.d.ts.map +1 -1
  11. package/dist/src/crypto/index.js +1 -7
  12. package/dist/src/crypto/index.js.map +1 -1
  13. package/dist/src/crypto/node.d.ts +1 -0
  14. package/dist/src/crypto/node.d.ts.map +1 -1
  15. package/dist/src/crypto/node.js +1 -1
  16. package/dist/src/crypto/node.js.map +1 -1
  17. package/dist/src/index.d.ts +1 -8
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +1 -8
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/node.d.ts +3 -3
  22. package/dist/src/node.d.ts.map +1 -1
  23. package/dist/src/node.js +3 -3
  24. package/dist/src/node.js.map +1 -1
  25. package/dist/src/profile.d.ts +3 -0
  26. package/dist/src/profile.d.ts.map +1 -0
  27. package/dist/src/profile.js +22 -0
  28. package/dist/src/profile.js.map +1 -0
  29. package/dist/src/renown-builder.d.ts +9 -1
  30. package/dist/src/renown-builder.d.ts.map +1 -1
  31. package/dist/src/renown-builder.js +16 -1
  32. package/dist/src/renown-builder.js.map +1 -1
  33. package/dist/src/types.d.ts +23 -1
  34. package/dist/src/types.d.ts.map +1 -1
  35. package/dist/src/utils.d.ts +6 -0
  36. package/dist/src/utils.d.ts.map +1 -1
  37. package/dist/src/utils.js +6 -0
  38. package/dist/src/utils.js.map +1 -1
  39. package/dist/test/renown.test.d.ts +2 -0
  40. package/dist/test/renown.test.d.ts.map +1 -0
  41. package/dist/test/renown.test.js +287 -0
  42. package/dist/test/renown.test.js.map +1 -0
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +3 -28
  45. package/dist/e2e/fixtures/main.d.ts +0 -2
  46. package/dist/e2e/fixtures/main.d.ts.map +0 -1
  47. package/dist/e2e/fixtures/main.js +0 -97
  48. package/dist/e2e/fixtures/main.js.map +0 -1
  49. package/dist/e2e/fixtures/vite.config.d.ts +0 -3
  50. package/dist/e2e/fixtures/vite.config.d.ts.map +0 -1
  51. package/dist/e2e/fixtures/vite.config.js +0 -10
  52. package/dist/e2e/fixtures/vite.config.js.map +0 -1
  53. package/dist/e2e/renown-components.spec.d.ts +0 -2
  54. package/dist/e2e/renown-components.spec.d.ts.map +0 -1
  55. package/dist/e2e/renown-components.spec.js +0 -155
  56. package/dist/e2e/renown-components.spec.js.map +0 -1
  57. package/dist/playwright.config.d.ts +0 -3
  58. package/dist/playwright.config.d.ts.map +0 -1
  59. package/dist/playwright.config.js +0 -25
  60. package/dist/playwright.config.js.map +0 -1
  61. package/dist/src/assets/assets.d.ts +0 -19
  62. package/dist/src/assets/renown-hover.svg +0 -17
  63. package/dist/src/assets/renown-light.svg +0 -15
  64. package/dist/src/assets/renown-short-hover.png +0 -0
  65. package/dist/src/assets/renown-short.png +0 -0
  66. package/dist/src/assets/renown.svg +0 -16
  67. package/dist/src/components/RenownAuthButton.d.ts +0 -62
  68. package/dist/src/components/RenownAuthButton.d.ts.map +0 -1
  69. package/dist/src/components/RenownAuthButton.js +0 -82
  70. package/dist/src/components/RenownAuthButton.js.map +0 -1
  71. package/dist/src/components/RenownLoginButton.d.ts +0 -48
  72. package/dist/src/components/RenownLoginButton.d.ts.map +0 -1
  73. package/dist/src/components/RenownLoginButton.js +0 -175
  74. package/dist/src/components/RenownLoginButton.js.map +0 -1
  75. package/dist/src/components/RenownUserButton.d.ts +0 -66
  76. package/dist/src/components/RenownUserButton.d.ts.map +0 -1
  77. package/dist/src/components/RenownUserButton.js +0 -216
  78. package/dist/src/components/RenownUserButton.js.map +0 -1
  79. package/dist/src/components/icons.d.ts +0 -25
  80. package/dist/src/components/icons.d.ts.map +0 -1
  81. package/dist/src/components/icons.js +0 -24
  82. package/dist/src/components/icons.js.map +0 -1
  83. package/dist/src/components/image-data.d.ts +0 -3
  84. package/dist/src/components/image-data.d.ts.map +0 -1
  85. package/dist/src/components/image-data.js +0 -4
  86. package/dist/src/components/image-data.js.map +0 -1
  87. package/dist/src/components/index.d.ts +0 -8
  88. package/dist/src/components/index.d.ts.map +0 -1
  89. package/dist/src/components/index.js +0 -5
  90. package/dist/src/components/index.js.map +0 -1
  91. package/dist/src/hooks/index.d.ts +0 -2
  92. package/dist/src/hooks/index.d.ts.map +0 -1
  93. package/dist/src/hooks/index.js +0 -2
  94. package/dist/src/hooks/index.js.map +0 -1
  95. package/dist/src/hooks/use-user.d.ts +0 -21
  96. package/dist/src/hooks/use-user.d.ts.map +0 -1
  97. package/dist/src/hooks/use-user.js +0 -30
  98. package/dist/src/hooks/use-user.js.map +0 -1
  99. package/dist/src/index.browser.d.ts +0 -4
  100. package/dist/src/index.browser.d.ts.map +0 -1
  101. package/dist/src/index.browser.js +0 -4
  102. package/dist/src/index.browser.js.map +0 -1
  103. package/dist/src/index.node.d.ts +0 -4
  104. package/dist/src/index.node.d.ts.map +0 -1
  105. package/dist/src/index.node.js +0 -4
  106. package/dist/src/index.node.js.map +0 -1
  107. package/dist/src/lib/renown/constants.d.ts +0 -130
  108. package/dist/src/lib/renown/constants.d.ts.map +0 -1
  109. package/dist/src/lib/renown/constants.js +0 -40
  110. package/dist/src/lib/renown/constants.js.map +0 -1
  111. package/dist/src/lib/renown/credential.d.ts +0 -2
  112. package/dist/src/lib/renown/credential.d.ts.map +0 -1
  113. package/dist/src/lib/renown/credential.js +0 -68
  114. package/dist/src/lib/renown/credential.js.map +0 -1
  115. package/dist/src/lib/renown/did-parser.d.ts +0 -28
  116. package/dist/src/lib/renown/did-parser.d.ts.map +0 -1
  117. package/dist/src/lib/renown/did-parser.js +0 -57
  118. package/dist/src/lib/renown/did-parser.js.map +0 -1
  119. package/dist/src/lib/renown/index.d.ts +0 -4
  120. package/dist/src/lib/renown/index.d.ts.map +0 -1
  121. package/dist/src/lib/renown/index.js +0 -4
  122. package/dist/src/lib/renown/index.js.map +0 -1
  123. package/dist/src/lib/renown/utils.d.ts +0 -33
  124. package/dist/src/lib/renown/utils.d.ts.map +0 -1
  125. package/dist/src/lib/renown/utils.js +0 -188
  126. package/dist/src/lib/renown/utils.js.map +0 -1
  127. package/dist/src/lib/session-storage.d.ts +0 -40
  128. package/dist/src/lib/session-storage.d.ts.map +0 -1
  129. package/dist/src/lib/session-storage.js +0 -107
  130. package/dist/src/lib/session-storage.js.map +0 -1
  131. package/dist/src/providers/index.d.ts +0 -3
  132. package/dist/src/providers/index.d.ts.map +0 -1
  133. package/dist/src/providers/index.js +0 -2
  134. package/dist/src/providers/index.js.map +0 -1
  135. package/dist/src/providers/renown-user-provider.d.ts +0 -76
  136. package/dist/src/providers/renown-user-provider.d.ts.map +0 -1
  137. package/dist/src/providers/renown-user-provider.js +0 -166
  138. package/dist/src/providers/renown-user-provider.js.map +0 -1
  139. package/dist/test/script.test.d.ts +0 -2
  140. package/dist/test/script.test.d.ts.map +0 -1
  141. package/dist/test/script.test.js +0 -144
  142. package/dist/test/script.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/renown/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
@@ -1,33 +0,0 @@
1
- import type { IRenown } from "@renown/sdk";
2
- import type { IRenownCrypto } from "../../crypto/index.js";
3
- export type LoginStatus = "initial" | "checking" | "authorized" | "not-authorized";
4
- export interface User {
5
- did: string;
6
- address: string;
7
- name?: string;
8
- email?: string;
9
- avatar?: string;
10
- ethAddress?: string;
11
- documentId?: string;
12
- }
13
- export declare function fetchProfileDataForUser(user: User): Promise<User>;
14
- declare global {
15
- interface Window {
16
- renown?: IRenown;
17
- reactor?: {
18
- setGenerateJwtHandler: (handler: (driveUrl: string) => Promise<string>) => void;
19
- removeJwtHandler: () => void;
20
- };
21
- renownCrypto?: IRenownCrypto;
22
- }
23
- }
24
- export declare function openRenown(documentId?: string): void;
25
- export declare function handleRenownReturn(): Promise<void>;
26
- export declare function login(userDid: string | undefined, renown: IRenown | undefined, renownCrypto: IRenownCrypto | undefined): Promise<User | undefined>;
27
- export declare function logout(): Promise<void>;
28
- /**
29
- * Re-authenticate using stored session data
30
- * This allows calling renown.login without needing to go through the full auth flow again
31
- */
32
- export declare function reauthenticateFromSession(): Promise<User | null>;
33
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/renown/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAe3D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,UAAU,GACV,YAAY,GACZ,gBAAgB,CAAC;AAErB,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAqDD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BvE;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE;YACR,qBAAqB,EAAE,CACrB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,KAC3C,IAAI,CAAC;YACV,gBAAgB,EAAE,MAAM,IAAI,CAAC;SAC9B,CAAC;QACF,YAAY,CAAC,EAAE,aAAa,CAAC;KAC9B;CACF;AAED,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,QA0B7C;AAGD,wBAAsB,kBAAkB,kBAkBvC;AAED,wBAAsB,KAAK,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,YAAY,EAAE,aAAa,GAAG,SAAS,6BA4DxC;AAED,wBAAsB,MAAM,kBAS3B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CA4BtE"}
@@ -1,188 +0,0 @@
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 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 renownCrypto if available
78
- const connectDid = window.renownCrypto?.did;
79
- if (!connectDid) {
80
- throw new Error("Keypair not found - authentication may not be properly initialized");
81
- }
82
- url.searchParams.set("connect", connectDid);
83
- url.searchParams.set("network", RENOWN_NETWORK_ID);
84
- url.searchParams.set("chain", RENOWN_CHAIN_ID);
85
- const returnUrl = new URL(window.location.pathname, window.location.origin);
86
- url.searchParams.set("returnUrl", returnUrl.toJSON());
87
- window.open(url, "_self")?.focus();
88
- }
89
- // Check for return from Renown authentication and handle login
90
- export async function handleRenownReturn() {
91
- if (typeof window === "undefined")
92
- return;
93
- const urlParams = new URLSearchParams(window.location.search);
94
- const userDid = decodeURIComponent(urlParams.get("user") ?? "");
95
- // If we have authentication parameters, attempt login
96
- if (userDid && window.renown && window.renownCrypto) {
97
- try {
98
- await login(userDid, window.renown, window.renownCrypto);
99
- // Clean up URL parameters
100
- const cleanUrl = new URL(window.location.href);
101
- cleanUrl.searchParams.delete("user");
102
- window.history.replaceState({}, "", cleanUrl.toString());
103
- }
104
- catch (error) {
105
- console.error("Failed to handle Renown return:", error);
106
- }
107
- }
108
- }
109
- export async function login(userDid, renown, renownCrypto) {
110
- if (!renown || !renownCrypto) {
111
- return;
112
- }
113
- // Validate that userDid is a valid pkh DID format
114
- if (userDid && !userDid.startsWith("did:pkh:")) {
115
- console.warn("Invalid DID format for login:", userDid, "- expected did:pkh: format");
116
- return;
117
- }
118
- try {
119
- const user = renown.user;
120
- if (user?.did && (user.did === userDid || !userDid)) {
121
- // Fetch profile data for the user
122
- const userWithProfile = await fetchProfileDataForUser(user);
123
- // Set up JWT handler if reactor is available
124
- // Store user data in sessionStorage for persistence
125
- SessionStorageManager.setUserData({
126
- user: userWithProfile,
127
- userDid: userWithProfile.did,
128
- loginStatus: "authorized",
129
- timestamp: Date.now(),
130
- });
131
- return userWithProfile;
132
- }
133
- if (!userDid) {
134
- return;
135
- }
136
- const newUser = await renown.login(userDid);
137
- // Fetch profile data for the user
138
- const userWithProfile = await fetchProfileDataForUser(newUser);
139
- // Set up JWT handler if reactor is available
140
- // Store user data in sessionStorage for persistence
141
- SessionStorageManager.setUserData({
142
- user: userWithProfile,
143
- userDid: userWithProfile.did,
144
- loginStatus: "authorized",
145
- timestamp: Date.now(),
146
- });
147
- return userWithProfile;
148
- }
149
- catch (error) {
150
- console.error("Renown login error:", error);
151
- throw error;
152
- }
153
- }
154
- export async function logout() {
155
- const renown = window.renown;
156
- const reactor = window.reactor;
157
- // Clear sessionStorage data
158
- SessionStorageManager.clearUserData();
159
- await renown?.logout();
160
- reactor?.removeJwtHandler();
161
- }
162
- /**
163
- * Re-authenticate using stored session data
164
- * This allows calling renown.login without needing to go through the full auth flow again
165
- */
166
- export async function reauthenticateFromSession() {
167
- if (typeof window === "undefined" || !window.renown || !window.renownCrypto) {
168
- return null;
169
- }
170
- const storedUserDid = SessionStorageManager.getStoredUserDid();
171
- if (!storedUserDid) {
172
- return null;
173
- }
174
- try {
175
- const currentUser = await login(storedUserDid, window.renown, window.renownCrypto);
176
- if (currentUser) {
177
- // Fetch profile data for the restored user
178
- const userWithProfile = await fetchProfileDataForUser(currentUser);
179
- return userWithProfile;
180
- }
181
- return null;
182
- }
183
- catch (error) {
184
- console.error("Failed to re-authenticate from session:", error);
185
- return null;
186
- }
187
- }
188
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CASpC,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAE/B,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO;gBACL,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,UAAU,EAAE,OAAO,CAAC,UAA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AM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,aAAa,GAAG,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC/D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,KAAK,CAC7B,aAAa,EACb,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,YAAY,CACpB,CAAC;QAEF,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"}
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,107 +0,0 @@
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
@@ -1 +0,0 @@
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,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AY,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,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"}
@@ -1,3 +0,0 @@
1
- export { RenownUserProvider, RenownUserContext, } from "./renown-user-provider.js";
2
- export type { RenownUserContextValue } from "./renown-user-provider.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export { RenownUserProvider, RenownUserContext, } from "./renown-user-provider.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC"}
@@ -1,76 +0,0 @@
1
- import type { IRenownCrypto } 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 renownCrypto 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
- /** RenownCrypto instance for cryptographic operations */
20
- renownCrypto: IRenownCrypto | 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
- * Name of the application. Will be part of the credential.
29
- */
30
- appName?: string;
31
- /**
32
- * Renown service URL
33
- * @default 'https://www.renown.id'
34
- */
35
- renownUrl?: string;
36
- /**
37
- * Network ID (e.g., 'eip155')
38
- * @default 'eip155'
39
- */
40
- networkId?: string;
41
- /**
42
- * Chain ID (e.g., '1' for Ethereum mainnet)
43
- * @default '1'
44
- */
45
- chainId?: string;
46
- /**
47
- * Custom loading component shown during initialization
48
- * If not provided, renders children immediately (no loading screen)
49
- */
50
- loadingComponent?: React.ReactNode;
51
- /**
52
- * Custom error component shown if initialization fails
53
- * Receives the error and a retry function
54
- */
55
- errorComponent?: (error: Error, retry: () => void) => React.ReactNode;
56
- }
57
- /**
58
- * RenownUserProvider - Central user provider for Renown
59
- *
60
- * Automatically initializes the Renown SDK and provides user state.
61
- * Handles initialization, login, logout, and session management.
62
- *
63
- * Usage:
64
- * ```tsx
65
- * // Wrap your app
66
- * <RenownUserProvider renownUrl="https://www.renown.id">
67
- * <YourApp />
68
- * </RenownUserProvider>
69
- *
70
- * // In any component
71
- * const { user, login, logout } = useUser()
72
- * ```
73
- */
74
- export declare function RenownUserProvider({ children, appName, renownUrl, networkId, chainId, loadingComponent, errorComponent, }: RenownUserProviderProps): import("react/jsx-runtime").JSX.Element;
75
- export {};
76
- //# sourceMappingURL=renown-user-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renown-user-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/renown-user-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAShE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,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,6DAA6D;IAC7D,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,yDAAyD;IACzD,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,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;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;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,OAAY,EACZ,SAAmC,EACnC,SAAoB,EACpB,OAAa,EACb,gBAAgB,EAChB,cAAc,GACf,EAAE,uBAAuB,2CAgKzB"}
@@ -1,166 +0,0 @@
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, RenownCryptoBuilder } from "../crypto/index.js";
5
- import { RenownBuilder } 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, appName = "", 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 [renownCrypto, setRenownCrypto] = 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.renownCrypto) {
44
- // Initialize RenownCrypto with browser key storage
45
- const keyStorage = await BrowserKeyStorage.create();
46
- const cryptoInstance = await new RenownCryptoBuilder()
47
- .withKeyPairStorage(keyStorage)
48
- .build();
49
- const renownInstance = await new RenownBuilder(appName)
50
- .withCrypto(cryptoInstance)
51
- .build();
52
- // Attach to window for global access
53
- window.renown = renownInstance;
54
- window.renownCrypto = cryptoInstance;
55
- // Save to state
56
- setRenownCrypto(cryptoInstance);
57
- setRenown(renownInstance);
58
- }
59
- else {
60
- // Use existing instances from window
61
- setRenown(window.renown);
62
- setRenownCrypto(window.renownCrypto);
63
- }
64
- // Check for stored session first
65
- const storedUserData = SessionStorageManager.getUserData();
66
- if (storedUserData &&
67
- SessionStorageManager.isUserDataValid(storedUserData)) {
68
- // Restore user from stored session
69
- const userWithProfile = await fetchProfileDataForUser(storedUserData.user);
70
- setUser(userWithProfile);
71
- setLoginStatus("authorized");
72
- setIsInitialized(true);
73
- return;
74
- }
75
- // Handle return from Renown authentication
76
- await handleRenownReturn();
77
- const currentUser = window.renown.user;
78
- if (currentUser) {
79
- // Fetch profile data for the logged-in user
80
- const userWithProfile = await fetchProfileDataForUser(currentUser);
81
- setUser(userWithProfile);
82
- setLoginStatus("authorized");
83
- }
84
- else {
85
- setLoginStatus("not-authorized");
86
- }
87
- setIsInitialized(true);
88
- }
89
- catch (error) {
90
- console.error("Failed to initialize authentication:", error);
91
- setInitError(error);
92
- setLoginStatus("not-authorized");
93
- // Still set as initialized to prevent infinite loading
94
- setIsInitialized(true);
95
- }
96
- };
97
- init().catch(console.error);
98
- }, [renownUrl, networkId, chainId]);
99
- // Login handler
100
- const login = useCallback(async (userDid) => {
101
- if (typeof window === "undefined")
102
- return;
103
- const renown = window.renown;
104
- const renownCrypto = window.renownCrypto;
105
- if (!renown || !renownCrypto) {
106
- console.error("Renown or RenownCrypto not available");
107
- setLoginStatus("not-authorized");
108
- return;
109
- }
110
- try {
111
- setIsLoading(true);
112
- setLoginStatus("checking");
113
- const did = userDid ?? renownCrypto.did;
114
- // Perform login
115
- const loggedInUser = await renownLogin(did, renown, renownCrypto);
116
- if (loggedInUser) {
117
- // Fetch profile data and update state
118
- const userWithProfile = await fetchProfileDataForUser(loggedInUser);
119
- setUser(userWithProfile);
120
- setLoginStatus("authorized");
121
- }
122
- else {
123
- setLoginStatus("not-authorized");
124
- }
125
- }
126
- catch (error) {
127
- console.error("Login failed:", error);
128
- setLoginStatus("not-authorized");
129
- }
130
- finally {
131
- setIsLoading(false);
132
- }
133
- }, []);
134
- // Logout handler
135
- const logout = useCallback(async () => {
136
- try {
137
- await renownLogout();
138
- setUser(null);
139
- setLoginStatus("not-authorized");
140
- }
141
- catch (error) {
142
- console.error("Logout failed:", error);
143
- }
144
- }, []);
145
- // Show loading state while initializing
146
- if (!isInitialized && loadingComponent) {
147
- return _jsx(_Fragment, { children: loadingComponent });
148
- }
149
- // Show error state if initialization failed
150
- if (initError && errorComponent) {
151
- return _jsx(_Fragment, { children: errorComponent(initError, () => window.location.reload()) });
152
- }
153
- const value = {
154
- user,
155
- loginStatus,
156
- isLoading,
157
- isInitialized,
158
- login,
159
- logout,
160
- openRenown: openRenownPortal,
161
- renownCrypto,
162
- renown,
163
- };
164
- return (_jsx(RenownUserContext.Provider, { value: value, children: children }));
165
- }
166
- //# sourceMappingURL=renown-user-provider.js.map