@net-protocol/profiles 0.1.4 → 0.1.6

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 CHANGED
@@ -104,6 +104,7 @@ function UpdateProfile() {
104
104
  | X Username | Your X (Twitter) handle | Stored without @ prefix (e.g., `myusername`) |
105
105
  | Bio | Short profile bio | Max 280 characters |
106
106
  | Display Name | User-chosen display name | Max 25 characters |
107
+ | Token Address | ERC-20 token that represents you | Valid EVM address (0x-prefixed) |
107
108
  | Canvas | Custom HTML profile page | For advanced customization |
108
109
 
109
110
  ## Storage Keys
@@ -111,7 +112,8 @@ function UpdateProfile() {
111
112
  | Key | Description | Data Format |
112
113
  |-----|-------------|-------------|
113
114
  | `PROFILE_PICTURE_STORAGE_KEY` | Profile picture URL | Plain string (URL) |
114
- | `PROFILE_METADATA_STORAGE_KEY` | Profile metadata JSON | `{ x_username: "handle", bio: "...", display_name: "..." }` |
115
+ | `PROFILE_X_USERNAME_STORAGE_KEY` | X username (legacy, prefer metadata) | Plain string |
116
+ | `PROFILE_METADATA_STORAGE_KEY` | Profile metadata JSON | `{ x_username: "handle", bio: "...", display_name: "...", token_address: "0x..." }` |
115
117
  | `PROFILE_CANVAS_STORAGE_KEY` | Custom HTML canvas | HTML string |
116
118
 
117
119
  ## API Reference
@@ -121,7 +123,7 @@ function UpdateProfile() {
121
123
  - `useProfilePicture({ chainId, userAddress })` - Fetch profile picture URL
122
124
  - `useProfileXUsername({ chainId, userAddress })` - Fetch X username
123
125
  - `useProfileCanvas({ chainId, userAddress })` - Fetch canvas HTML
124
- - `useBasicUserProfileMetadata({ chainId, userAddress })` - Batch fetch picture & username
126
+ - `useBasicUserProfileMetadata({ chainId, userAddress })` - Batch fetch picture, username, bio, display name, and token address
125
127
 
126
128
  ### Utilities (from `@net-protocol/profiles`)
127
129
 
@@ -136,6 +138,8 @@ function UpdateProfile() {
136
138
  - `isValidXUsername(username)` - Validate X username format
137
139
  - `isValidBio(bio)` - Validate bio format (max 280 chars, no control chars)
138
140
  - `isValidDisplayName(displayName)` - Validate display name format (max 25 chars, no control chars)
141
+ - `getTokenAddressStorageArgs(tokenAddress)` - Prepare token address update args
142
+ - `isValidTokenAddress(address)` - Validate EVM token address format
139
143
 
140
144
  ## Dependencies
141
145
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProfileStorageArgs, a as ProfileMetadata } from './types-DSRRz8Ug.mjs';
2
- export { B as BasicUserProfileMetadata, b as UseProfileOptions, U as UserDisplayName, c as UserProfile } from './types-DSRRz8Ug.mjs';
1
+ import { P as ProfileStorageArgs, a as ProfileMetadata } from './types-DDKLfc0r.mjs';
2
+ export { B as BasicUserProfileMetadata, b as UseProfileOptions, U as UserDisplayName, c as UserProfile } from './types-DDKLfc0r.mjs';
3
3
  export { STORAGE_CONTRACT } from '@net-protocol/storage';
4
4
 
5
5
  /**
@@ -22,6 +22,8 @@ declare const PROFILE_METADATA_STORAGE_KEY = "net-beta0.0.1-profile-metadata";
22
22
  declare const PROFILE_PICTURE_TOPIC = "profile-picture";
23
23
  declare const PROFILE_METADATA_TOPIC = "profile-metadata";
24
24
  declare const PROFILE_CANVAS_TOPIC = "profile-canvas";
25
+ declare const PROFILE_CSS_STORAGE_KEY = "net-beta0.0.1-profile-css";
26
+ declare const PROFILE_CSS_TOPIC = "profile-css";
25
27
 
26
28
  /**
27
29
  * Convert a string value to hex for storage
@@ -154,5 +156,96 @@ declare function getTokenAddressStorageArgs(tokenAddress: string): ProfileStorag
154
156
  * Returns true if valid (0x-prefixed, 40 hex characters)
155
157
  */
156
158
  declare function isValidTokenAddress(address: string): boolean;
159
+ /**
160
+ * Maximum CSS size in bytes (10KB — CSS should be small)
161
+ */
162
+ declare const MAX_CSS_SIZE: number;
163
+ /**
164
+ * Prepare transaction arguments for updating profile custom CSS
165
+ *
166
+ * @param cssContent - CSS string to store
167
+ * @returns Arguments for Storage.put() - [bytesKey, topic, bytesValue]
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const args = getProfileCSSStorageArgs(".profile-themed { --primary: 210 40% 98%; }");
172
+ * writeContract({
173
+ * abi: STORAGE_CONTRACT.abi,
174
+ * address: STORAGE_CONTRACT.address,
175
+ * functionName: "put",
176
+ * args: [args.bytesKey, args.topic, args.bytesValue],
177
+ * });
178
+ * ```
179
+ */
180
+ declare function getProfileCSSStorageArgs(cssContent: string): ProfileStorageArgs;
181
+ /**
182
+ * Sanitize user CSS to prevent injection attacks.
183
+ * - Strips </style> (which could break out of the style element during SSR)
184
+ * - Strips <script> tags
185
+ * - Removes javascript: URIs, expression(), behavior: (legacy IE vectors)
186
+ * - Removes @import rules (could load external resources / exfiltrate data)
187
+ */
188
+ declare function sanitizeCSS(css: string): string;
189
+ /**
190
+ * Validate CSS content
191
+ * Returns true if valid (non-empty, within size limit, no script injection)
192
+ */
193
+ declare function isValidCSS(css: string): boolean;
194
+
195
+ /**
196
+ * Single source of truth for profile CSS theming.
197
+ *
198
+ * This file defines:
199
+ * 1. THEME_SELECTORS — the stable set of CSS selectors/variables available for theming
200
+ * 2. DEMO_THEMES — example CSS themes users can apply
201
+ * 3. buildCSSPrompt() — generates an AI prompt describing what can be themed
202
+ *
203
+ * When the profile page structure changes, update THEME_SELECTORS here and
204
+ * everything downstream (AI prompt, docs, validation) stays in sync.
205
+ */
206
+ /**
207
+ * A themeable selector or CSS variable group
208
+ */
209
+ interface ThemeSelector {
210
+ /** CSS selector or variable name */
211
+ selector: string;
212
+ /** Human-readable description of what it targets */
213
+ description: string;
214
+ /** Category for grouping in documentation */
215
+ category: "variable" | "layout" | "component";
216
+ }
217
+ /**
218
+ * All themeable selectors available for profile CSS.
219
+ *
220
+ * CSS variables (category: "variable") are the most stable —
221
+ * they survive page restructuring because they're part of the
222
+ * shadcn/Tailwind design system.
223
+ *
224
+ * Layout and component selectors may break when the page structure changes.
225
+ */
226
+ declare const THEME_SELECTORS: ThemeSelector[];
227
+ /**
228
+ * Demo themes that users can choose from as starting points.
229
+ * Each is a complete CSS string ready to store on-chain.
230
+ *
231
+ * Themes include CSS variable overrides, @keyframes animations,
232
+ * backdrop-filter effects, and full component selector coverage
233
+ * including .profile-content overrides.
234
+ */
235
+ declare const DEMO_THEMES: Record<string, {
236
+ name: string;
237
+ css: string;
238
+ }>;
239
+ /**
240
+ * Build an AI prompt that describes the available theming surface.
241
+ * Feed this to an LLM alongside a user's description to generate CSS.
242
+ *
243
+ * The prompt includes per-selector documentation, animation guidance,
244
+ * !important rules for beating Tailwind utilities, and supported
245
+ * properties like backdrop-filter and box-shadow.
246
+ *
247
+ * @returns A prompt string listing all available selectors and usage rules
248
+ */
249
+ declare function buildCSSPrompt(): string;
157
250
 
158
- export { PROFILE_CANVAS_STORAGE_KEY, PROFILE_CANVAS_TOPIC, PROFILE_METADATA_STORAGE_KEY, PROFILE_METADATA_TOPIC, PROFILE_PICTURE_STORAGE_KEY, PROFILE_PICTURE_TOPIC, PROFILE_X_USERNAME_STORAGE_KEY, ProfileMetadata, ProfileStorageArgs, getBioStorageArgs, getBytesArgsForStorage, getDisplayNameStorageArgs, getProfileCanvasStorageArgs, getProfileMetadataStorageArgs, getProfilePictureStorageArgs, getTokenAddressStorageArgs, getValueArgForStorage, getXUsernameStorageArgs, isValidBio, isValidDisplayName, isValidTokenAddress, isValidUrl, isValidXUsername, parseProfileMetadata };
251
+ export { DEMO_THEMES, MAX_CSS_SIZE, PROFILE_CANVAS_STORAGE_KEY, PROFILE_CANVAS_TOPIC, PROFILE_CSS_STORAGE_KEY, PROFILE_CSS_TOPIC, PROFILE_METADATA_STORAGE_KEY, PROFILE_METADATA_TOPIC, PROFILE_PICTURE_STORAGE_KEY, PROFILE_PICTURE_TOPIC, PROFILE_X_USERNAME_STORAGE_KEY, ProfileMetadata, ProfileStorageArgs, THEME_SELECTORS, type ThemeSelector, buildCSSPrompt, getBioStorageArgs, getBytesArgsForStorage, getDisplayNameStorageArgs, getProfileCSSStorageArgs, getProfileCanvasStorageArgs, getProfileMetadataStorageArgs, getProfilePictureStorageArgs, getTokenAddressStorageArgs, getValueArgForStorage, getXUsernameStorageArgs, isValidBio, isValidCSS, isValidDisplayName, isValidTokenAddress, isValidUrl, isValidXUsername, parseProfileMetadata, sanitizeCSS };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProfileStorageArgs, a as ProfileMetadata } from './types-DSRRz8Ug.js';
2
- export { B as BasicUserProfileMetadata, b as UseProfileOptions, U as UserDisplayName, c as UserProfile } from './types-DSRRz8Ug.js';
1
+ import { P as ProfileStorageArgs, a as ProfileMetadata } from './types-DDKLfc0r.js';
2
+ export { B as BasicUserProfileMetadata, b as UseProfileOptions, U as UserDisplayName, c as UserProfile } from './types-DDKLfc0r.js';
3
3
  export { STORAGE_CONTRACT } from '@net-protocol/storage';
4
4
 
5
5
  /**
@@ -22,6 +22,8 @@ declare const PROFILE_METADATA_STORAGE_KEY = "net-beta0.0.1-profile-metadata";
22
22
  declare const PROFILE_PICTURE_TOPIC = "profile-picture";
23
23
  declare const PROFILE_METADATA_TOPIC = "profile-metadata";
24
24
  declare const PROFILE_CANVAS_TOPIC = "profile-canvas";
25
+ declare const PROFILE_CSS_STORAGE_KEY = "net-beta0.0.1-profile-css";
26
+ declare const PROFILE_CSS_TOPIC = "profile-css";
25
27
 
26
28
  /**
27
29
  * Convert a string value to hex for storage
@@ -154,5 +156,96 @@ declare function getTokenAddressStorageArgs(tokenAddress: string): ProfileStorag
154
156
  * Returns true if valid (0x-prefixed, 40 hex characters)
155
157
  */
156
158
  declare function isValidTokenAddress(address: string): boolean;
159
+ /**
160
+ * Maximum CSS size in bytes (10KB — CSS should be small)
161
+ */
162
+ declare const MAX_CSS_SIZE: number;
163
+ /**
164
+ * Prepare transaction arguments for updating profile custom CSS
165
+ *
166
+ * @param cssContent - CSS string to store
167
+ * @returns Arguments for Storage.put() - [bytesKey, topic, bytesValue]
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const args = getProfileCSSStorageArgs(".profile-themed { --primary: 210 40% 98%; }");
172
+ * writeContract({
173
+ * abi: STORAGE_CONTRACT.abi,
174
+ * address: STORAGE_CONTRACT.address,
175
+ * functionName: "put",
176
+ * args: [args.bytesKey, args.topic, args.bytesValue],
177
+ * });
178
+ * ```
179
+ */
180
+ declare function getProfileCSSStorageArgs(cssContent: string): ProfileStorageArgs;
181
+ /**
182
+ * Sanitize user CSS to prevent injection attacks.
183
+ * - Strips </style> (which could break out of the style element during SSR)
184
+ * - Strips <script> tags
185
+ * - Removes javascript: URIs, expression(), behavior: (legacy IE vectors)
186
+ * - Removes @import rules (could load external resources / exfiltrate data)
187
+ */
188
+ declare function sanitizeCSS(css: string): string;
189
+ /**
190
+ * Validate CSS content
191
+ * Returns true if valid (non-empty, within size limit, no script injection)
192
+ */
193
+ declare function isValidCSS(css: string): boolean;
194
+
195
+ /**
196
+ * Single source of truth for profile CSS theming.
197
+ *
198
+ * This file defines:
199
+ * 1. THEME_SELECTORS — the stable set of CSS selectors/variables available for theming
200
+ * 2. DEMO_THEMES — example CSS themes users can apply
201
+ * 3. buildCSSPrompt() — generates an AI prompt describing what can be themed
202
+ *
203
+ * When the profile page structure changes, update THEME_SELECTORS here and
204
+ * everything downstream (AI prompt, docs, validation) stays in sync.
205
+ */
206
+ /**
207
+ * A themeable selector or CSS variable group
208
+ */
209
+ interface ThemeSelector {
210
+ /** CSS selector or variable name */
211
+ selector: string;
212
+ /** Human-readable description of what it targets */
213
+ description: string;
214
+ /** Category for grouping in documentation */
215
+ category: "variable" | "layout" | "component";
216
+ }
217
+ /**
218
+ * All themeable selectors available for profile CSS.
219
+ *
220
+ * CSS variables (category: "variable") are the most stable —
221
+ * they survive page restructuring because they're part of the
222
+ * shadcn/Tailwind design system.
223
+ *
224
+ * Layout and component selectors may break when the page structure changes.
225
+ */
226
+ declare const THEME_SELECTORS: ThemeSelector[];
227
+ /**
228
+ * Demo themes that users can choose from as starting points.
229
+ * Each is a complete CSS string ready to store on-chain.
230
+ *
231
+ * Themes include CSS variable overrides, @keyframes animations,
232
+ * backdrop-filter effects, and full component selector coverage
233
+ * including .profile-content overrides.
234
+ */
235
+ declare const DEMO_THEMES: Record<string, {
236
+ name: string;
237
+ css: string;
238
+ }>;
239
+ /**
240
+ * Build an AI prompt that describes the available theming surface.
241
+ * Feed this to an LLM alongside a user's description to generate CSS.
242
+ *
243
+ * The prompt includes per-selector documentation, animation guidance,
244
+ * !important rules for beating Tailwind utilities, and supported
245
+ * properties like backdrop-filter and box-shadow.
246
+ *
247
+ * @returns A prompt string listing all available selectors and usage rules
248
+ */
249
+ declare function buildCSSPrompt(): string;
157
250
 
158
- export { PROFILE_CANVAS_STORAGE_KEY, PROFILE_CANVAS_TOPIC, PROFILE_METADATA_STORAGE_KEY, PROFILE_METADATA_TOPIC, PROFILE_PICTURE_STORAGE_KEY, PROFILE_PICTURE_TOPIC, PROFILE_X_USERNAME_STORAGE_KEY, ProfileMetadata, ProfileStorageArgs, getBioStorageArgs, getBytesArgsForStorage, getDisplayNameStorageArgs, getProfileCanvasStorageArgs, getProfileMetadataStorageArgs, getProfilePictureStorageArgs, getTokenAddressStorageArgs, getValueArgForStorage, getXUsernameStorageArgs, isValidBio, isValidDisplayName, isValidTokenAddress, isValidUrl, isValidXUsername, parseProfileMetadata };
251
+ export { DEMO_THEMES, MAX_CSS_SIZE, PROFILE_CANVAS_STORAGE_KEY, PROFILE_CANVAS_TOPIC, PROFILE_CSS_STORAGE_KEY, PROFILE_CSS_TOPIC, PROFILE_METADATA_STORAGE_KEY, PROFILE_METADATA_TOPIC, PROFILE_PICTURE_STORAGE_KEY, PROFILE_PICTURE_TOPIC, PROFILE_X_USERNAME_STORAGE_KEY, ProfileMetadata, ProfileStorageArgs, THEME_SELECTORS, type ThemeSelector, buildCSSPrompt, getBioStorageArgs, getBytesArgsForStorage, getDisplayNameStorageArgs, getProfileCSSStorageArgs, getProfileCanvasStorageArgs, getProfileMetadataStorageArgs, getProfilePictureStorageArgs, getTokenAddressStorageArgs, getValueArgForStorage, getXUsernameStorageArgs, isValidBio, isValidCSS, isValidDisplayName, isValidTokenAddress, isValidUrl, isValidXUsername, parseProfileMetadata, sanitizeCSS };