UNPKG

cdp-wallet-onramp-kit

Version:

Complete toolkit for Coinbase Developer Platform (CDP) Embedded Wallets and Onramp integration with reusable components, utilities, and documentation

102 lines (83 loc) 4.26 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.setupDocs = setupDocs; const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = __importDefault(require("path")); const chalk_1 = __importDefault(require("chalk")); async function setupDocs(options) { const { dir, force } = options; const targetDir = path_1.default.resolve(process.cwd(), dir); console.log(chalk_1.default.blue(`📚 Setting up CDP Wallet & Onramp documentation in ${targetDir}`)); // Ensure target directory exists await fs_extra_1.default.ensureDir(targetDir); // Copy documentation files // In published package, templates are in src/templates, not dist/templates const templateDir = path_1.default.join(__dirname, '..', '..', 'src', 'templates'); const docsSource = path_1.default.join(templateDir, 'docs'); const docsTarget = path_1.default.join(targetDir, 'cdp'); if (await fs_extra_1.default.pathExists(docsTarget) && !force) { console.log(chalk_1.default.yellow('⚠️ Documentation already exists. Use --force to overwrite.')); return; } // Copy all docs await fs_extra_1.default.copy(docsSource, docsTarget); // Copy integration prompts to root of doc directory const walletPromptSource = path_1.default.join(templateDir, 'embedded-wallet-integration-prompt.md'); const onrampPromptSource = path_1.default.join(templateDir, 'onramp-integration-prompt.md'); if (await fs_extra_1.default.pathExists(walletPromptSource)) { await fs_extra_1.default.copy(walletPromptSource, path_1.default.join(targetDir, 'embedded-wallet-integration-prompt.md')); } if (await fs_extra_1.default.pathExists(onrampPromptSource)) { await fs_extra_1.default.copy(onrampPromptSource, path_1.default.join(targetDir, 'onramp-integration-prompt.md')); } // Create a combined integration guide const combinedGuide = `# CDP Wallet & Onramp Integration Guide This directory contains comprehensive documentation for integrating both Coinbase Developer Platform (CDP) Embedded Wallets and Onramp functionality into your Next.js application. ## Quick Start 1. **For AI Coding Agents**: Use the integration prompts: - \`embedded-wallet-integration-prompt.md\` - Complete wallet integration guide - \`onramp-integration-prompt.md\` - Complete onramp integration guide 2. **For Developers**: Browse the documentation: - \`cdp/embedded-wallet/\` - Embedded wallet docs and examples - \`cdp/onramp/\` - Onramp docs and examples ## Documentation Structure - **Embedded Wallets**: \`embedded-wallet/\` directory with wallet documentation - **Onramp API**: \`onramp-api/\` directory with high-level guides - **REST API**: \`onramp-offramp-rest-api/\` directory with complete API documentation ## Available Components Install the package to use pre-built components: \`\`\`bash npm install cdp-wallet-onramp-kit \`\`\` ### Components Included: - \`CDPProvider\` - Provider wrapper for your app - \`WalletAuth\` - Pre-built wallet authentication - \`CustomWalletAuth\` - Custom authentication with full control - \`OnrampButton\` - Simple buy button - \`OnrampWidget\` - Complete purchase widget ### Utilities Included: - CDP authentication helpers - Validation schemas - API route templates ## Environment Setup Add to your \`.env.local\`: \`\`\`bash # Required for both wallet and onramp NEXT_PUBLIC_CDP_PROJECT_ID=your-project-id # Required for onramp (server-side only) CDP_API_KEY_PRIVATE_KEY=your-private-key CDP_API_KEY_NAME=your-key-name \`\`\` ## Next Steps 1. Configure CORS in CDP Portal: https://portal.cdp.coinbase.com 2. Choose your integration approach (see docs for details) 3. Install required packages and start building! Generated by cdp-wallet-onramp-kit v1.0.0 `; await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'README.md'), combinedGuide); console.log(chalk_1.default.green(`✅ Documentation copied to ${targetDir}`)); console.log(chalk_1.default.blue(`📖 Read ${path_1.default.join(targetDir, 'README.md')} to get started`)); }