{"_id":"@accounthub/sdk","_rev":"7-f747be0ef77559f866a9317a5d186c43","name":"@accounthub/sdk","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.0":{"name":"@accounthub/sdk","version":"1.0.0","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.0","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"dist":{"shasum":"1f78c67688c4c34f2288d6c0b622ee727c0921cd","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.0.tgz","fileCount":6,"integrity":"sha512-pejHibjr7m1NnuKb58I7yjMDI/1XXAyDi3qCQ1jp4lSqQolXRcgs0XqI2FrwUI5VhceXk57IerT58gHK8fAD7Q==","signatures":[{"sig":"MEQCIHWTuYk9EPh4Kd6id5f1N8WmkcTOYVfzDAVzuPR4i9YoAiAURLpa7nwpjXpcKfCZudSeWihpSYwMetxmnvLLs6yIyA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":197197},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"b2860c6f1824c341a3e01a233ca533defa3e3e62","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"qgming","email":"qgming@qq.com"},"_npmVersion":"10.9.3","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.0_1770392224925_0.3416392519902587","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@accounthub/sdk","version":"1.0.1","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.1","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"dist":{"shasum":"eace848f4cd6fe2abb7c88deead957be58a4383a","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.1.tgz","fileCount":7,"integrity":"sha512-WkgAOk8Ie8v1nAj9FgHG6PnD1ktdpmmFPS3/vpqLL1QSmAeI/Q3vMWHr1pnDHv1tlkE8rihWbWGLsTUOY0Uq1w==","signatures":[{"sig":"MEQCIDwNvEFQNRhtgcvdcBITP/r8cMzdpJn65FgHasbU7lnmAiA9BNEz/7v+77A+cBn50vM+vQxyV4oeedO898dWfBlgKA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":208018},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a28a41eefee3ae58c04b6ec0bb6ba836648c1433","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"qgming","email":"qgming@qq.com"},"_npmVersion":"10.9.3","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.1_1770448701651_0.49663682373786244","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@accounthub/sdk","version":"1.0.2","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.2","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"homepage":"https://github.com/qgming/accounthubsdk#readme","bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"dist":{"shasum":"aa2fbda3524eb230cde0d75b662ad32107f78a03","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.2.tgz","fileCount":7,"integrity":"sha512-fYtQ1I/IJEmmbd2gbR7M00+b4ANfx8OHD29EcE5WPq/Ry66V4nmbffIV6Bj9m3ZYoCQxiBx7aKzVXjEuC/ktRg==","signatures":[{"sig":"MEQCIBaYordnr7yV+Ne+vGVltn5SxYw9OSKmaunyOJ/DJi7MAiBd9PgtdQYr9AwFL3HbbzQiqL+AdxvWApYI56rtY+/oBg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accounthub%2fsdk@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":183299},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"104f04567abe9d2118ecf1ee9935a1a50543c7f8","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3b0fc184-22dc-49b3-b5b2-f1dd35d61d5f"}},"repository":{"url":"git+https://github.com/qgming/accounthubsdk.git","type":"git"},"_npmVersion":"11.11.0","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@noble/hashes":"^1.8.0","@noble/ciphers":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.2_1772370115960_0.7429261422141646","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@accounthub/sdk","version":"1.0.3","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.3","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"homepage":"https://github.com/qgming/accounthubsdk#readme","bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"dist":{"shasum":"ba38d7003240b189a650e3d1c34d457ec3bb7eae","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.3.tgz","fileCount":7,"integrity":"sha512-y59PDVdPZUJbMJNLc1WP/Hr2gFQ4hAoSdSphF26DzO6KT4uiaSQMHTaG2DkjqIjevfJFhGCADS9CJruY0RqotA==","signatures":[{"sig":"MEUCIQDUr2wMoSzIzmysaG1f9KDNMRTwwOyxaQF0Cfs3plHAiwIgXsNChK+ewXbdbFsj+lAUXBWplJQAK/Z8QNBpmX7pPnk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accounthub%2fsdk@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":212278},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"15832da33716b21637f9ad816cfa4d71cca8799a","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3b0fc184-22dc-49b3-b5b2-f1dd35d61d5f"}},"repository":{"url":"git+https://github.com/qgming/accounthubsdk.git","type":"git"},"_npmVersion":"11.11.0","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@noble/hashes":"^1.8.0","@noble/ciphers":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.3_1772630076867_0.43145149291169327","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@accounthub/sdk","version":"1.0.4","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.4","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"homepage":"https://github.com/qgming/accounthubsdk#readme","bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"dist":{"shasum":"dab55e654c2658934e2e8a7cd44832a5896fe985","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.4.tgz","fileCount":7,"integrity":"sha512-EXEZkh8CMfqsZwfQOl4sVhGv1m3P7SYuxI08RJMQ5oBGeh6hBDUcu9pqEGPSmvDOdv91ldWutsIo6Gv32w3ZSg==","signatures":[{"sig":"MEYCIQDlwH4HNPj0SThzIXnRWqjIRQ8vSifhbrkQxKvthpitigIhALpNO6EzYxBPDkL600B1SmaIVyDe+Y6oDFaPXqfmok0f","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accounthub%2fsdk@1.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":273122},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a1e0376d972dc5d9582cde556daee8e5166106e1","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3b0fc184-22dc-49b3-b5b2-f1dd35d61d5f"}},"repository":{"url":"git+https://github.com/qgming/accounthubsdk.git","type":"git"},"_npmVersion":"11.11.1","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@noble/hashes":"^1.8.0","@noble/ciphers":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.4_1773399202366_0.7308014025128997","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@accounthub/sdk","version":"1.0.5","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","_id":"@accounthub/sdk@1.0.5","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"homepage":"https://github.com/qgming/accounthubsdk#readme","bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"dist":{"shasum":"32987e9d4596db683389d7405b5f035fc7b5366b","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.5.tgz","fileCount":7,"integrity":"sha512-bLbQGHtWuwcc38eN0Li/OhV+w8xRY590+ovEQUQsAgsCjKBW0b6aVBSDFvMgAZAyolGTy2/ftWgtlAQY399LPw==","signatures":[{"sig":"MEUCIQCjQpTIO+vXmohSuUawvriIBdXidS88AoBB2/aerg/9xgIgd3q/SWqVYqowSTmDXLLnULnxLFHMWHpBGoVK9/dMC+4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accounthub%2fsdk@1.0.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":277227},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"355b6a3029552740f4a91b1a2eecd665887fe880","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3b0fc184-22dc-49b3-b5b2-f1dd35d61d5f"}},"repository":{"url":"git+https://github.com/qgming/accounthubsdk.git","type":"git"},"_npmVersion":"11.12.0","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","directories":{},"_nodeVersion":"22.22.1","dependencies":{"@noble/hashes":"^1.8.0","@noble/ciphers":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@supabase/supabase-js":"^2.39.0"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.5_1774422423660_0.5544426841109809","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@accounthub/sdk","version":"1.0.6","description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","dev":"tsup src/index.ts --format cjs,esm --dts --watch","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/qgming/accounthubsdk.git"},"peerDependencies":{"@supabase/supabase-js":"^2.0.0"},"devDependencies":{"@supabase/supabase-js":"^2.39.0","tsup":"^8.0.0","typescript":"^5.3.0"},"dependencies":{"@noble/ciphers":"^1.3.0","@noble/hashes":"^1.8.0"},"gitHead":"1aa3b8a2846f4ca8d8aeb08b342c7105671870a7","_id":"@accounthub/sdk@1.0.6","bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"homepage":"https://github.com/qgming/accounthubsdk#readme","_nodeVersion":"22.22.1","_npmVersion":"11.12.0","dist":{"integrity":"sha512-wlsA32xMaNaR/YW/DBbmkxL92KeGU2i3RrBg/CqBsJ2K3vAf51Ykj3bY3SrrCIBcoY8pYanGAQezgRAXyhdm0A==","shasum":"1c9d9d16c59baf6a633265f739e7c469616301c3","tarball":"https://registry.npmjs.org/@accounthub/sdk/-/sdk-1.0.6.tgz","fileCount":7,"unpackedSize":277291,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@accounthub%2fsdk@1.0.6","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG1HK2Iyh7qYno/yEuOwBG5lI3TQejqe9XWxDtMjskHJAiALUqFmuXnLc8x4TeKdy4FpfZ6lqi3+QKJlKMJKwyCXJw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3b0fc184-22dc-49b3-b5b2-f1dd35d61d5f"}},"directories":{},"maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.6_1774436114467_0.48796385695765676"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-06T15:37:04.845Z","modified":"2026-03-25T10:55:14.943Z","1.0.0":"2026-02-06T15:37:05.070Z","1.0.1":"2026-02-07T07:18:21.818Z","1.0.2":"2026-03-01T13:01:56.123Z","1.0.3":"2026-03-04T13:14:37.050Z","1.0.4":"2026-03-13T10:53:22.525Z","1.0.5":"2026-03-25T07:07:03.807Z","1.0.6":"2026-03-25T10:55:14.625Z"},"bugs":{"url":"https://github.com/qgming/accounthubsdk/issues"},"license":"MIT","homepage":"https://github.com/qgming/accounthubsdk#readme","keywords":["accounthub","sdk","authentication","membership","payment","supabase","typescript"],"repository":{"type":"git","url":"git+https://github.com/qgming/accounthubsdk.git"},"description":"AccountHub SDK - 纯 TypeScript SDK，支持在 Vue、React、React Native 等任何前端环境中使用","maintainers":[{"name":"qgming","email":"qgming@qq.com"}],"readme":"# AccountHub SDK\n\n<div align=\"center\">\n\n[![npm version](https://img.shields.io/npm/v/@accounthub/sdk.svg?style=flat-square)](https://www.npmjs.com/package/@accounthub/sdk)\n[![npm downloads](https://img.shields.io/npm/dm/@accounthub/sdk.svg?style=flat-square)](https://www.npmjs.com/package/@accounthub/sdk)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg?style=flat-square)](https://www.typescriptlang.org/)\n\n**企业级多应用账户管理 SDK**\n\n配合 [AccountHub 管理后台](https://github.com/qgming/accounthub) 使用，为应用提供用户认证、会员管理、支付集成、版本更新、兑换码和应用配置功能。\n\n</div>\n\n---\n\n## 安装\n\n```bash\nnpm install @accounthub/sdk @supabase/supabase-js\n```\n\n> `@supabase/supabase-js` 为必需的 peer dependency。\n\n---\n\n## 快速开始\n\n```typescript\nimport { initializeAccountHub } from \"@accounthub/sdk\";\n\nconst sdk = initializeAccountHub({\n  supabaseUrl: \"https://your-project.supabase.co\",\n  supabaseAnonKey: \"your-anon-key\",\n  appId: \"your-app-uuid\",\n  appKey: \"your-app-key\",\n});\n\n// 登录\nconst { user } = await sdk.auth.signIn({ email, password });\n\n// 获取会员状态\nconst membership = await sdk.membership.getUserMembership(user.id);\n\n// 获取配置（加密数据自动解密）\nconst config = await sdk.config.getConfig(\"announcement\");\n\n// 检查更新\nconst update = await sdk.update.checkUpdate({ currentVersion: \"1.0.0\" });\n\n// AI 对话（需要部署 Supabase Edge Function: ai-proxy）\nconst ai = await sdk.ai.chat(\"getme-assistant\", {\n  messages: [{ role: \"user\", content: \"你好，请用一句话介绍你自己。\" }],\n});\nconsole.log(ai.choices[0]?.message?.content);\n\n// 兑换码\nawait sdk.redemption.redeemCode(\"XXXX-XXXX-XXXX-XXXX\");\n```\n\n---\n\n## 文档\n\n| 文档 | 内容 |\n|------|------|\n| [REFERENCE.md](docs/REFERENCE.md) | **AI 辅助编码用** — 完整类型定义、所有 API 签名速查、框架集成模板 |\n| [api-auth.md](docs/api-auth.md) | 认证模块：注册、登录、OTP、资料管理、状态监听 |\n| [api-membership.md](docs/api-membership.md) | 会员模块：创建、状态管理、过期检查、取消 |\n| [api-payment.md](docs/api-payment.md) | 支付模块：套餐查询、会话创建、状态验证、渠道配置 |\n| [api-config.md](docs/api-config.md) | 配置模块：读取、端到端解密、缓存管理 |\n| [api-update.md](docs/api-update.md) | 更新模块：版本检查、平台检测、版本比较工具 |\n| [api-ai.md](docs/api-ai.md) | AI 模块：对话（非流式/流式）、语音转文字、图片生成 |\n| [api-redemption.md](docs/api-redemption.md) | 兑换码模块：验证、兑换、历史记录 |\n\n---\n\n## 框架支持\n\n- **React** / **Next.js**\n- **Vue 3** / **Nuxt**\n- **React Native**\n- 任何支持 TypeScript 的 JavaScript 环境\n\n集成示例见 [REFERENCE.md — 框架集成模板](docs/REFERENCE.md#框架集成模板)。\n\n---\n\n## 更新日志\n\n### v1.0.5 (2026-03-25)\n\n**支付模块重构与显示优化**\n\n**💳 支付方式简化**\n- 移除冗余支付方式：`wechat`、`stripe`、`manual`\n- 仅支持三种支付方式：`alipay`（支付宝官方）、`wxpay`（微信官方）、`epay`（易支付）\n- 新增具体配置类型：`AlipayConfig`、`WxpayConfig`、`EpayConfig`\n\n**🎨 易支付显示优化**\n- `PaymentChannelConfig` 新增 `display_method` 和 `display_name` 字段\n- 易支付渠道自动转换为实际支付方式显示：\n  - `epay` + `config.type='wxpay'` → `display_method='wxpay'`, `display_name='微信支付'`\n  - `epay` + `config.type='alipay'` → `display_method='alipay'`, `display_name='支付宝'`\n- `getPaymentChannel()` 和 `getPaymentChannels()` 自动应用显示优化\n\n**🔧 类型安全提升**\n- `PaymentMethod` 类型从 `'alipay' | 'wechat' | 'stripe' | 'manual' | 'epay'` 简化为 `'alipay' | 'wxpay' | 'epay'`\n- 新增 `AlipayConfig` 接口：支付宝官方配置类型\n- 新增 `WxpayConfig` 接口：微信官方配置类型\n- 新增 `EpayConfig` 接口：易支付配置类型（支持 `type: 'alipay' | 'wxpay'`）\n\n**✨ 用户体验改进**\n- 前端无需额外处理，SDK 自动将易支付渠道显示为用户熟悉的\"微信支付\"或\"支付宝\"\n- 保持底层数据结构统一（`payment_method='epay'`），同时提供用户友好的显示层\n\n**⚠️ 破坏性变更**\n\n| 变更项 | v1.0.4 | v1.0.5 |\n|--------|--------|--------|\n| `PaymentMethod` 类型 | 含 `'wechat'` \\| `'stripe'` \\| `'manual'` | 仅 `'alipay'` \\| `'wxpay'` \\| `'epay'` |\n\n迁移：将代码中的 `'wechat'` → `'wxpay'`，移除 `'stripe'` 和 `'manual'` 的使用。\n\n---\n\n### v1.0.4 (2026-03-13)\n\n**配置模块性能与离线体验全面升级**\n\n**🚀 离线优先架构**\n- 新增 `PersistentCacheManager`：持久化缓存管理器，缓存永不过期\n- 新增 `UpdateScheduler`：智能后台更新调度，支持节流和指数退避策略\n- 新增 `ConfigUpdateOptions`：灵活的配置更新策略（离线优先、节流时间、超时控制、重试策略）\n- 默认策略：优先返回缓存，后台静默更新（24h 节流，1.2s 超时）\n\n**⚡ 异步解密优化**\n- 新增 `AsyncCrypto`：支持 Web Worker 异步解密（浏览器）和 setTimeout 分片（React Native）\n- 新增 `getConfigAsync()`：完全异步的配置获取方法\n- 新增 `batchGetConfigsAsync()`：批量异步获取配置\n- 密钥派生和解密操作不再阻塞主线程\n\n**⏱️ 超时控制**\n- 新增 `TimeoutController`：统一的超时管理工具\n- 新增 `TimeoutError` 类型和 `isTimeoutError()` 判断函数\n- 支持手动更新和后台更新的独立超时配置\n\n**📊 缓存元数据**\n- 缓存元数据包含：时间戳、更新尝试次数、最后成功更新时间、版本号\n- 支持 `getCacheInfo()` 查询缓存状态\n- LRU 策略：内存缓存最多 100 条，持久化缓存无限制\n\n**🔧 API 增强**\n- `getConfig()` 新增选项：`forceRefresh`（强制刷新）、`fallbackValue`（降级默认值）、`timeout`（自定义超时）\n- `Config` 构造函数支持 `ConfigUpdateOptions` 配置更新策略\n- 导出 `TimeoutError` 和 `isTimeoutError` 供外部使用\n\n**⚠️ 破坏性变更**\n\n| 变更项 | v1.0.3 | v1.0.4 |\n|--------|--------|--------|\n| `Config` 构造函数 | `new Config(storage)` | `new Config(storage, updateOptions?)` |\n| 默认行为 | 每次请求都查询数据库 | 优先返回缓存，后台更新 |\n\n迁移：如需保持旧行为，传入 `{ offlineFirst: false }` 配置。\n\n---\n\n### v1.0.3 (2026-03-04)\n\n- ✨ 新增 `AI` 模块：`chat` / `chatStream` / `speechToText` / `generateImage`\n- ✨ Auth 新增 `trackActive()`：静默上报最近在线时间\n- 🔧 顶层导出补齐 AI 相关类型与错误码\n\n---\n\n### v1.0.2 (2026-03-01)\n\n**安全性与稳定性增强**\n\n**🔐 配置端到端加密**\n- 新增 `core/crypto.ts`：AES-256-GCM + PBKDF2-SHA256（10 万次迭代）密钥派生\n- Config 模块自动解密 `{ _enc: \"enc:v1:...\" }` 格式的加密配置，应用代码无感知\n- 派生密钥在实例生命周期内缓存，避免重复 PBKDF2 计算\n\n**💾 缓存内存泄漏修复**\n- `Config`：`MAX_CACHE_SIZE = 100`，超出时 LRU 淘汰\n- `Update`：`MAX_CACHE_SIZE = 50`，超出时 LRU 淘汰\n\n**🏷️ 类型安全全面提升**\n- 事件负载 `auth:statechange`、`membership:*` 消除 `any`\n- `getPaymentChannel/s()`、`validateCode()`、`getUserRedemptions()` 返回类型精确化\n- `auth/types.ts`：`session` 从 `any` 改为 `Session`\n- `core/client.ts`：存储适配器从 `as any` 改为 `as SupportedStorage`\n\n**🛡️ 存储健壮性**\n- `WebStorage` 所有方法添加 try-catch，防止隐私模式 / SSR 抛出未捕获异常\n\n**🔄 兑换码错误处理重构**\n- 提取 `parseEdgeFunctionError` 和 `mapDataErrorToCode` 私有方法，消除 ~90 行重复代码\n\n**🔧 会员逻辑修复**\n- `createMembership` 改为依赖数据库唯一约束（PostgreSQL 23505）消除竞态条件\n- `cancelMembership` 状态从 `\"cancelled\"` 修正为 `\"inactive\"`（与 DB CHECK 约束一致）\n- 初始会员状态从 `\"trial\"` 修正为 `\"inactive\"`\n\n**⚠️ 破坏性变更**\n\n| 变更项 | v1.x | v1.0.2 |\n|--------|------|--------|\n| `MembershipStatus` | 含 `\"trial\"` / `\"suspended\"` / `\"cancelled\"` | 仅 `\"active\"` \\| `\"inactive\"` \\| `\"expired\"` |\n\n迁移：将代码中的 `\"trial\"` → `\"inactive\"`，`\"cancelled\"` → `\"inactive\"`，`\"suspended\"` → `\"inactive\"` 或 `\"expired\"`。\n\n---\n\n### v1.0.1 (2026-02-07)\n\n- ✨ 新增 `createMembershipCheckoutSession` 便捷方法\n- ✨ 新增 `getPaymentBySessionId` / `verifyPaymentBySessionId`\n- ✨ `CheckoutSession` 新增 `paymentId` 字段\n- ✨ 导出 `PaymentChannelConfig` 类型\n\n---\n\n### v1.0.0 (2026-02-06)\n\n- 初始版本发布，包含认证、会员、支付、更新、兑换码、配置全部功能模块\n\n---\n\n## 相关链接\n\n- [AccountHub 管理后台](https://github.com/qgming/accounthub)\n- [Supabase 文档](https://supabase.com/docs)\n\n---\n\n## 许可证\n\nMIT\n","readmeFilename":"README.md"}