{"_id":"@agewallet/js-sdk","_rev":"6-65d925b2529c8d5b05a542d0854fc7f0","name":"@agewallet/js-sdk","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@agewallet/js-sdk","version":"1.0.0","_id":"@agewallet/js-sdk@1.0.0","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"dist":{"shasum":"89b2988b5f756e82d5618ca769efe8d7e5b1816d","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.0.tgz","fileCount":8,"integrity":"sha512-7FY9ryh0iKfeEKGNfJSDypBzL5ycACGP+Bzto3bZ37rQj8KA/X/gFMGC5DL0hJLyULQEejuX27CjlNdtTwlLaQ==","signatures":[{"sig":"MEUCIQDE0u4WQGypTRXTN2leDf7lcz1eC6awMMkWJeGrLO70igIgX/u7f2WEtZA9XMBBILdefAa/f7zva8DF6MQH4GhJ9p0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":303185},"main":"./dist/agewallet.umd.cjs","type":"module","types":"./dist/agewallet.d.ts","module":"./dist/agewallet.js","exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"gitHead":"2cc0f9cd2cf34f564627d62d1642218c33f0bcda","scripts":{"dev":"vite tests/public","build":"npm run build:demo && npm run build:lib","build:lib":"vite build --config vite.lib.config.js","build:demo":"vite build"},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"_npmVersion":"10.9.3","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.0.0","vitest":"^1.0.0","@upstash/redis":"^1.28.0"},"_npmOperationalInternal":{"tmp":"tmp/js-sdk_1.0.0_1764631809383_0.5888398633062377","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@agewallet/js-sdk","version":"1.0.1","_id":"@agewallet/js-sdk@1.0.1","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"dist":{"shasum":"8026fb81fcb4cd10d9a947a3e1fca6211af72b3b","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.1.tgz","fileCount":8,"integrity":"sha512-0nB88RxCJNAt66XLqMYgK5rvQlwBMQEQFRDeUjZihUV8up6Qgd0Wy52Km/EdqUiw+c/bi8nFGBJYYnXdBDB3kw==","signatures":[{"sig":"MEUCIDPV7KQ9nYjO3TVNv6y4jSOa6IlwQCfgnD5VK+woplHBAiEA9qr6C7odtRFYd4+B97w7xAX9rgnmKaCMwa/H3xgPTZ0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":303186},"main":"./dist/agewallet.umd.cjs","type":"module","types":"./dist/agewallet.d.ts","module":"./dist/agewallet.js","exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"gitHead":"ee261949f5ef3c59f9cc715b19e645873e06c176","scripts":{"dev":"vite tests/public","build":"npm run build:demo && npm run build:lib","build:lib":"vite build --config vite.lib.config.js","build:demo":"vite build"},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"_npmVersion":"10.9.3","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.0.0","vitest":"^1.0.0","@upstash/redis":"^1.28.0"},"_npmOperationalInternal":{"tmp":"tmp/js-sdk_1.0.1_1764632211195_0.14535255554901494","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@agewallet/js-sdk","version":"1.0.2","_id":"@agewallet/js-sdk@1.0.2","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"homepage":"https://github.com/agewallet-client/agewallet-js-sdk#readme","bugs":{"url":"https://github.com/agewallet-client/agewallet-js-sdk/issues"},"dist":{"shasum":"6dcc8f9f3a4d9b09c264d8f3c083af46103d2626","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.2.tgz","fileCount":8,"integrity":"sha512-pVuzb2neR+es2LDviXR+WJqyRoipBusHIFLbLaoTdbQu/7kN6ORQnwRACMLZlbHFa2wSq8ZxdndZ41gUc35/Dg==","signatures":[{"sig":"MEUCIQCv588DdNH33HpK195EaOzZL19GM08UIk2WUsI3nCYnEwIgTo1Sx4/zHHp5ci52Y2piGVAdXwz/C8wwQ2jb8NcKNl4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":318710},"main":"./dist/agewallet.umd.cjs","type":"module","types":"./dist/agewallet.d.ts","module":"./dist/agewallet.js","exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"gitHead":"fe1a1eba772b41815fd882f864e2848daa6c80eb","scripts":{"dev":"vite examples/frontend","test":"vitest run","build":"npm run build:demo && npm run build:lib","build:lib":"vite build --config vite.lib.config.js","build:demo":"vite build","test:watch":"vitest"},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"repository":{"url":"git+https://github.com/agewallet-client/agewallet-js-sdk.git","type":"git"},"_npmVersion":"10.9.3","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.0.0","vitest":"^1.0.0","happy-dom":"^20.0.11","@upstash/redis":"^1.28.0"},"_npmOperationalInternal":{"tmp":"tmp/js-sdk_1.0.2_1766186097546_0.2431634377652947","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@agewallet/js-sdk","version":"1.0.3","_id":"@agewallet/js-sdk@1.0.3","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"homepage":"https://github.com/agewallet-client/agewallet-js-sdk#readme","bugs":{"url":"https://github.com/agewallet-client/agewallet-js-sdk/issues"},"dist":{"shasum":"342277e9cca06b8ddbf9e2c5a510ab6cbf0b501a","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.3.tgz","fileCount":8,"integrity":"sha512-p1qDSJRTEKLQl0rYfj+43mOy4L2dcwOYUcTqcZmbtN3bz9KG7Rf8H7Lwc9j2dRvKiaHhlNuJakKUJQyLWF3EIg==","signatures":[{"sig":"MEUCIQCAfeMbniuhwRkmJs6ljvZQvZQtto4SfwhlRwCUOFWfFgIgdmF2oDyfRlFyqen2J4Mia6gkw+z7ZY8cRPuTn9qCtqQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":317633},"main":"./dist/agewallet.umd.cjs","type":"module","types":"./dist/agewallet.d.ts","module":"./dist/agewallet.js","exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"gitHead":"7a0054690ec407195931232474d70901c1aeb092","scripts":{"dev":"vite examples/frontend","test":"vitest run","build":"npm run build:demo && npm run build:lib","build:lib":"vite build --config vite.lib.config.js","build:demo":"vite build","test:watch":"vitest"},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"repository":{"url":"git+https://github.com/agewallet-client/agewallet-js-sdk.git","type":"git"},"_npmVersion":"10.9.3","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.0.0","vitest":"^1.0.0","happy-dom":"^20.0.11","@upstash/redis":"^1.28.0"},"_npmOperationalInternal":{"tmp":"tmp/js-sdk_1.0.3_1766188861299_0.9256568976049975","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@agewallet/js-sdk","version":"1.0.4","_id":"@agewallet/js-sdk@1.0.4","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"homepage":"https://github.com/agewallet-client/agewallet-js-sdk#readme","bugs":{"url":"https://github.com/agewallet-client/agewallet-js-sdk/issues"},"dist":{"shasum":"629bade4b72dfdc4c4796cc56f19375ba76ca093","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.4.tgz","fileCount":8,"integrity":"sha512-m+43LvHWu4ZTumkdH7PQVaKZL04OWkXRK47sw9P7aL7qyM+CEcnqpTSTylRLukYxrgxrIymRenNxn5jNHdzKOg==","signatures":[{"sig":"MEUCIBGEbYfHv1+QVisVHd/jBzyaoTgzBL24n+Wa85jmHhWaAiEAqhymWz/fB0vw6BXHIRCC2sdgsbU2yAwIyqgluNf942g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":317561},"main":"./dist/agewallet.umd.cjs","type":"module","types":"./dist/agewallet.d.ts","module":"./dist/agewallet.js","exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"gitHead":"8cfba265da616ed1a086356cf3bbbe5be79729ce","scripts":{"dev":"vite examples/frontend","test":"vitest run","build":"npm run build:demo && npm run build:lib","build:lib":"vite build --config vite.lib.config.js && vite build --config vite.browser.config.js","build:demo":"vite build","test:watch":"vitest"},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"repository":{"url":"git+https://github.com/agewallet-client/agewallet-js-sdk.git","type":"git"},"_npmVersion":"10.9.3","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^5.0.0","vitest":"^1.0.0","happy-dom":"^20.0.11","@upstash/redis":"^1.28.0"},"_npmOperationalInternal":{"tmp":"tmp/js-sdk_1.0.4_1766190174066_0.15900634605616903","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@agewallet/js-sdk","version":"1.0.5","type":"module","main":"./dist/agewallet.umd.cjs","module":"./dist/agewallet.js","types":"./dist/agewallet.d.ts","repository":{"type":"git","url":"git+https://github.com/agewallet-client/agewallet-js-sdk.git"},"exports":{".":{"import":"./dist/agewallet.js","require":"./dist/agewallet.umd.cjs"}},"scripts":{"test":"vitest run","test:watch":"vitest","dev":"vite examples/frontend","build:demo":"vite build","build:lib":"vite build --config vite.lib.config.js && vite build --config vite.browser.config.js","build":"npm run build:demo && npm run build:lib"},"devDependencies":{"@upstash/redis":"^1.28.0","happy-dom":"^20.0.11","vite":"^5.0.0","vitest":"^1.0.0"},"_id":"@agewallet/js-sdk@1.0.5","gitHead":"b6b473362dfb921d2afb50742e5e3c7e638ea0ca","description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","bugs":{"url":"https://github.com/agewallet-client/agewallet-js-sdk/issues"},"homepage":"https://github.com/agewallet-client/agewallet-js-sdk#readme","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-V0TGophpKycAcNMk7iAPi4y/Iu7g97v2XvFbmP1IJpNZLNWzH3tss/YjO3+LZyQodfY6nuCxbHBNYYDcjlxuFg==","shasum":"0a59db81d86d8b7656dc100f7c63da439d8e6cbf","tarball":"https://registry.npmjs.org/@agewallet/js-sdk/-/js-sdk-1.0.5.tgz","fileCount":8,"unpackedSize":312334,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDPPYVysF3ya6RtVtmpovXlK4yEjwcge9k4xA5Bx8yoTAIhAL31FZm3QGblfnLrpp91QsGfAxDx689U96/k3420Gu3J"}]},"_npmUser":{"name":"ashleygoodman","email":"ashley@agewallet.com"},"directories":{},"maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/js-sdk_1.0.5_1772283548338_0.8874152661664485"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-01T23:30:09.316Z","modified":"2026-02-28T12:59:08.655Z","1.0.0":"2025-12-01T23:30:09.700Z","1.0.1":"2025-12-01T23:36:51.428Z","1.0.2":"2025-12-19T23:14:57.723Z","1.0.3":"2025-12-20T00:01:01.446Z","1.0.4":"2025-12-20T00:22:54.277Z","1.0.5":"2026-02-28T12:59:08.531Z"},"bugs":{"url":"https://github.com/agewallet-client/agewallet-js-sdk/issues"},"homepage":"https://github.com/agewallet-client/agewallet-js-sdk#readme","repository":{"type":"git","url":"git+https://github.com/agewallet-client/agewallet-js-sdk.git"},"description":"The official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.","maintainers":[{"name":"ashleygoodman","email":"ashley@agewallet.com"}],"readme":"# AgeWallet JavaScript SDK\n\nThe official, zero-dependency JavaScript SDK for integrating AgeWallet Age Verification into modern web applications.\n\nDesigned for versatility, it supports everything from static landing pages to Single Page Applications (React, Vue, Angular) and Server-Side Node.js environments.\n\n## Features\n\n- **Universal Support:** Works in all modern browsers and Node.js 19+ (Server-Side Rendering).\n\n- **Secure by Default:** Automatically handles OIDC Authorization Code Flow with PKCE (S256) and State verification.\n\n- **Flexible Modes:**\n\n  - **Overlay Mode:** Drop-in age gate for marketing sites.\n\n  - **Headless Mode:** Full control for SPAs and custom UIs.\n\n  - **API Mode:** Secure content fetching for premium video/assets.\n\n  - **Zero Dependencies:** Lightweight and fast.\n\n## Installation\n\n### Option 1: NPM (Recommended for Bundlers)\n\n    npm install @agewallet/js-sdk\n\n\n    import { AgeWallet } from '@agewallet/js-sdk';\n\n### Option 2: CDN (Browser Script)\n\n    <script src=\"https://unpkg.com/@agewallet/js-sdk@latest/dist/agewallet.min.js\"></script>\n    <script>\n      // Access via global window.AgeWallet\n      const aw = new AgeWallet({ ... });\n    </script>\n\n## Quick Start: Standard Overlay\n\nThe fastest way to protect a landing page. This renders a fixed-position age gate over your content until the user verifies.\n\n    import { AgeWallet } from '@agewallet/js-sdk';\n\n    const aw = new AgeWallet({\n        clientId: 'YOUR_CLIENT_ID',\n        clientSecret: 'YOUR_CLIENT_SECRET', // Only required for Confidential Clients\n        mode: 'overlay',\n        redirectUri: window.location.origin + '/' // Single callback URL (see note below)\n    });\n\n    aw.init();\n\n### ⚠️ Important: Single Redirect URI\n\nAgeWallet requires **one redirect URI per Client ID**. All pages on your site must use the same `redirectUri` value (typically your homepage or a dedicated `/callback` route).\n\nThe SDK automatically handles deep linking — if a user lands on `/shop/product-123` and needs to verify, they will be returned to `/shop/product-123` after verification, even though the OAuth callback goes through your single redirect URI.\n\n## Configuration\n\n| Option | Type | Default | Description |\n| :--- | :--- | :--- | :--- |\n| `clientId` | `string` | **Required** | Your AgeWallet Application ID. |\n| `clientSecret` | `string` | `''` | Required for Confidential Clients. Leave empty for Public Clients (SPA). |\n| `redirectUri` | `string` | `window.location` | The single OAuth callback URL (e.g., `window.location.origin + '/'`). Must be whitelisted in Dashboard. One per Client ID. |\n| `mode` | `string` | `'overlay'` | `'overlay'` (Default) or `'api'` (Secure Fetch). |\n| `render` | `boolean` | `true` | Set to `false` for Headless Mode (no UI injected). |\n| `storage` | `string` \\| `object` | `'cookie'` | `'cookie'`, `'local'`, or a custom object implementing `SessionHandlerInterface`. |\n| `targetSelector` | `string` | `'body'` | CSS selector for the container where the Gate UI will be rendered. |\n| `api` | `object` | `{}` | Required for `api` mode. Must contain an `endpoint` URL. |\n| `environment` | `string` | `'browser'` | `'browser'` (Default) or `'node'` (Server-Side). |\n| `ui` | `object` | `{}` | Customize text and logo (see below). |\n| `onVerified` | `function` | `null` | Callback fired when verification succeeds. Receives content (API mode) or null (Overlay mode). |\n| `onUnverified` | `function` | `null` | Callback fired when verification is required. Receives the `authUrl` string. |\n\n## Advanced Usage\n\n### Headless Mode (React / Vue)\n\nFor full control over the UI, disable the built-in renderer and use event handlers.\n\n    const aw = new AgeWallet({\n        clientId: 'YOUR_ID',\n        render: false, // Disable SDK UI\n        redirectUri: 'https://mysite.com/callback',\n\n        // Called when user needs to verify\n        onUnverified: (authUrl) => {\n            // Show your own \"Verify Age\" button linking to authUrl\n            setVerifyLink(authUrl);\n            setShowGate(true);\n        },\n\n        // Called when verification is successful\n        onVerified: (content) => {\n            // Content is null in overlay mode, or data in API mode\n            setShowGate(false);\n            setVerified(true);\n        }\n    });\n\n    aw.init();\n\n### Local Storage (SPA Friendly)\n\nBy default, the SDK uses `document.cookie` for compatibility. For Single Page Apps where you prefer `localStorage`:\n\n    const aw = new AgeWallet({\n        // ... credentials ...\n        storage: 'local' // Tokens stored in localStorage (Key: aw_verified)\n    });\n\n### Custom Branding\n\nYou can customize the look and feel of the built-in age gate by passing a `ui` object.\n\n    const aw = new AgeWallet({\n        // ... credentials ...\n        ui: {\n            title: \"Restricted Access\",\n            description: \"Please verify your age to enter the VIP lounge.\",\n            buttonText: \"I am 18+\",\n            logo: \"https://example.com/my-logo.png\", // Optional\n        }\n    });\n\n**CSS Overrides:** The SDK uses BEM-style classes. You can override them in your own CSS:\n\n    /* Change the \"Agree\" button color */\n    .aw-gate__btn--yes {\n        background-color: #ff0055 !important;\n    }\n\n## Server-Side Verification (Node.js)\n\nThe SDK works natively in Node.js (v19+) for server-side rendering (SSR) or API protection.\n\n**Configuration:** Set `environment: 'node'` to enable server-compatible cryptography.\n\n    import { AgeWallet } from '@agewallet/js-sdk';\n\n    // 1. Initialize\n    // You must provide a custom storage handler for the server (e.g., Redis, DB)\n    const myStorage = {\n        get: async (key) => { /* return value from DB */ },\n        set: async (key, val) => { /* save value to DB */ },\n        remove: async (key) => { /* delete from DB */ }\n    };\n\n    const aw = new AgeWallet({\n        clientId: 'YOUR_ID',\n        clientSecret: 'YOUR_SECRET',\n        redirectUri: 'https://mysite.com/callback',\n        environment: 'node', // <--- Crucial for Node.js support\n        mode: 'api',\n        storage: myStorage\n    });\n\n    // 2. Generate Auth URL (for unverified users)\n    const authData = await aw.generateAuthUrl();\n    // Redirect user to: authData.url\n\n    // 3. Handle Callback\n    // Call this when the user returns to your callback URL.\n    // It might contain ?code=... (Verification) OR ?error=... (Failure)\n\n    if (req.query.code) {\n        // Handle Standard Verification\n        await aw.handleCallback(req.query.code, req.query.state);\n    }\n\n    // 4. Check Status\n    const token = await aw.storage.getVerificationToken();\n\n    if (token) {\n       // User is verified\n    }\n\n## Examples & Recipes\n\nThis repository includes complete multi-page example sites in the `examples/` directory, demonstrating real-world integration patterns with deep link support.\n\n### Frontend Examples\n\nEach example is a 3-page mini-site (Home, About, Shop) demonstrating how verification persists across pages and deep links.\n\n- **[Overlay Mode](examples/sites/overlay/):** The standard full-screen gate integration with deep link preservation.\n- **[API Mode](examples/sites/api/):** Securely fetching content from a backend only after verification.\n- **[Headless Mode](examples/sites/headless/):** Building a completely custom UI (React/Vue style) without the SDK's default styling.\n- **[Local Storage](examples/sites/local/):** Persisting tokens in `localStorage` for Single Page Apps.\n- **[Custom Branding](examples/sites/branding/):** Customizing the default gate's logo, text, and colors via CSS variable overrides.\n\n### Backend Examples\n\n- **[SSR + Redis](examples/sites/redis/):** A fully server-rendered Node.js example using Upstash Redis for session management. Demonstrates deep link restoration entirely on the server.\n- **[Netlify Functions](examples/backend/netlify-functions/):** Serverless token proxy functions for secure client secret handling.\n","readmeFilename":"README.md"}