Skip to content

Commit ef119e7

Browse files
committed
examples
1 parent 3132105 commit ef119e7

5 files changed

Lines changed: 391 additions & 3 deletions

File tree

components/Layout.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ export function Layout({ children, title = 'Base Verify Demo' }: LayoutProps) {
231231
Base Verify Docs
232232
</button>
233233
<span style={{ color: '#d1d5db', fontSize: '0.8rem' }}></span>
234+
<button
235+
onClick={() => router.push('/examples')}
236+
style={{
237+
background: 'none',
238+
border: 'none',
239+
color: '#9ca3af',
240+
fontSize: '0.75rem',
241+
cursor: 'pointer',
242+
textDecoration: 'underline',
243+
padding: 0
244+
}}
245+
onMouseEnter={(e) => {
246+
e.currentTarget.style.color = '#1a1a1a';
247+
}}
248+
onMouseLeave={(e) => {
249+
e.currentTarget.style.color = '#9ca3af';
250+
}}
251+
>
252+
Examples
253+
</button>
254+
<span style={{ color: '#d1d5db', fontSize: '0.8rem' }}></span>
234255
<button
235256
onClick={() => router.push('/coinbase')}
236257
style={{

env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ NEXT_PUBLIC_ONCHAINKIT_API_KEY="your_onchainkit_api_key_here"
1212
NEXT_PUBLIC_BASE_VERIFY_API_URL="https://verify.base.dev/v1"
1313
NEXT_PUBLIC_BASE_VERIFY_MINI_APP_URL="https://verify.base.dev"
1414
BASE_VERIFY_SECRET_KEY="sk_live_your_secret_key_here_64_character_hex_string"
15+
NEXT_PUBLIC_BASE_VERIFY_PUBLISHER_KEY="pk_live_your_publisher_key_here_64_character_hex_string"
1516

1617
# Your application's URL
1718
NEXT_PUBLIC_APP_URL="https://baseverifydemo.com"

lib/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export const config = {
99
// Secret key for authenticating with Base Verify backend (server-side only)
1010
baseVerifySecretKey: process.env.BASE_VERIFY_SECRET_KEY,
1111

12+
// Publisher key for client-side API calls (public, requires origin validation)
13+
baseVerifyPublisherKey: process.env.NEXT_PUBLIC_BASE_VERIFY_PUBLISHER_KEY,
14+
1215
// Current app URL for redirects
1316
appUrl: process.env.NEXT_PUBLIC_APP_URL || 'https://baseverifydemo.com',
1417
}

lib/signature-generator.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,24 @@ function buildSIWEMessage(options: SIWEOptions): { message: string; nonce: strin
4141
// Add base provider URN
4242
resources.push(`urn:verify:provider:${provider}`);
4343

44-
// Add traits as embedded provider URNs: urn:verify:provider:provider:trait_type:value
44+
// Add traits as embedded provider URNs: urn:verify:provider:provider:trait_type:operation:value
4545
Object.entries(traits).forEach(([key, value]) => {
4646
const safeKey = key;
4747
const safeValue = String(value);
48-
// TODO: eq here is hardcoded, other options are gt and
49-
resources.push(`urn:verify:provider:${provider}:${safeKey}:eq:${safeValue}`);
48+
49+
// Parse operation from value if present (e.g., "gt:100" -> operation: "gt", value: "100")
50+
// Supported operations: eq, gt, gte, lt, lte, in
51+
const operationMatch = safeValue.match(/^(eq|gt|gte|lt|lte|in):(.+)$/);
52+
53+
if (operationMatch) {
54+
// Value contains operation prefix
55+
const operation = operationMatch[1];
56+
const actualValue = operationMatch[2];
57+
resources.push(`urn:verify:provider:${provider}:${safeKey}:${operation}:${actualValue}`);
58+
} else {
59+
// No operation prefix, default to 'eq'
60+
resources.push(`urn:verify:provider:${provider}:${safeKey}:eq:${safeValue}`);
61+
}
5062
});
5163
}
5264

0 commit comments

Comments
 (0)