{"_id":"@alogame/web-sdk","_rev":"5-fcb66f1166b53b290ff03c595d7f10ab","name":"@alogame/web-sdk","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.1":{"name":"@alogame/web-sdk","version":"1.0.1","keywords":["alogame","sdk","authentication","login","html5","h5","game"],"author":{"name":"Alogame"},"license":"MIT","_id":"@alogame/web-sdk@1.0.1","maintainers":[{"name":"alogame","email":"thohd@alogame.vn"}],"homepage":"https://sdk-docs.oeg.vn/docs/web/install","bugs":{"url":"https://support.oeg.vn"},"umd":"dist/oeg-web-sdk.min.js","dist":{"shasum":"c1d7644c2daf237e23c0090abd26743a9cd6308b","tarball":"https://registry.npmjs.org/@alogame/web-sdk/-/web-sdk-1.0.1.tgz","fileCount":55,"integrity":"sha512-sTaa2WwYU78IcGFaRLYHMMFFxE8BF10JOzx/TZKD57SZxo852SaBy5lQD01Vo4Qa0zBXUKrUKZybWX+KCSKvAw==","signatures":[{"sig":"MEQCIE+jlWRG/el1OYhx2bjWtOCNUrwwxU7hfdNM9nFXhyjvAiBm3bQKL6ecT51dA3p8rk8RU9VsNW6XzXe2+cTnu9yi/Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":859407},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","unpkg":"dist/oeg-web-sdk.min.js","module":"dist/index.esm.js","scripts":{"lint":"tsc --noEmit && eslint src tests","size":"size-limit","test":"vitest run","build":"rollup -c","prepare":"husky","test:e2e":"playwright test","sync:docs":"npm run build && node scripts/sync-docs.mjs","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"alogame","email":"thohd@alogame.vn"},"jsdelivr":"dist/oeg-web-sdk.min.js","repository":{"url":"git+https://gitlab.oeg.vn/oeg-tech/sdk/web-sdk.git","type":"git"},"size-limit":[{"gzip":true,"path":"dist/oeg-web-sdk.min.js","limit":"150KB"}],"_npmVersion":"10.8.2","description":"Alogame Web SDK — authentication & login for browser-based HTML5 (H5) games","directories":{},"lint-staged":{"{src,tests}/**/*.ts":"eslint --fix"},"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"msw":"^2.0.11","vite":"^5.0.8","husky":"^9.1.7","jsdom":"^29.0.2","tslib":"^2.8.1","eslint":"^9.39.4","rollup":"^4.9.6","vitest":"^1.1.0","fast-check":"^3.15.1","size-limit":"^11.0.1","typescript":"^5.3.3","@types/node":"^20.10.6","lint-staged":"^17.0.8","@playwright/test":"^1.40.1","typescript-eslint":"^8.63.0","@vitest/coverage-v8":"^1.1.0","@rollup/plugin-terser":"^0.4.4","rollup-plugin-postcss":"^4.0.2","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-typescript":"^11.1.6","@rollup/plugin-node-resolve":"^15.2.3","@size-limit/preset-small-lib":"^12.1.0"},"_npmOperationalInternal":{"tmp":"tmp/web-sdk_1.0.1_1783655137068_0.43117683427498","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@alogame/web-sdk","version":"1.0.2","keywords":["alogame","sdk","authentication","login","html5","h5","game"],"author":{"name":"Alogame"},"license":"MIT","_id":"@alogame/web-sdk@1.0.2","maintainers":[{"name":"alogame","email":"thohd@alogame.vn"}],"homepage":"https://sdk-docs.oeg.vn/docs/web/install","bugs":{"url":"https://support.oeg.vn"},"umd":"dist/oeg-web-sdk.min.js","dist":{"shasum":"d5b5dad337d04f1691eff67569b6bd9fe28ac8da","tarball":"https://registry.npmjs.org/@alogame/web-sdk/-/web-sdk-1.0.2.tgz","fileCount":10,"integrity":"sha512-XSn7Nng9xwd1u0Ibg2hPB0o7oiXQPNOkUarzstlRvGnKWGIBfHgxW0ZefSNh4Y26DKZFqOGI/ljQaPsO51GgJg==","signatures":[{"sig":"MEUCIQCzd09fLJ7xyhFcdIUjNYTAuWHGJzOVFsuXOCsWNY6xbgIgOMalomVu2jRRfNkzBH87EyrnQao4eB2iwY9opkeG9nk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":825039},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","unpkg":"dist/oeg-web-sdk.min.js","module":"dist/index.esm.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"tsc --noEmit && eslint src tests","size":"size-limit","test":"vitest run","build":"rollup -c","prepare":"husky","test:e2e":"playwright test","sync:docs":"npm run build && node scripts/sync-docs.mjs","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"alogame","email":"thohd@alogame.vn"},"jsdelivr":"dist/oeg-web-sdk.min.js","repository":{"url":"git+https://gitlab.oeg.vn/oeg-tech/sdk/web-sdk.git","type":"git"},"size-limit":[{"gzip":true,"path":"dist/oeg-web-sdk.min.js","limit":"150KB"}],"_npmVersion":"10.8.2","description":"Alogame Web SDK — authentication & login for browser-based HTML5 (H5) games","directories":{},"lint-staged":{"{src,tests}/**/*.ts":"eslint --fix"},"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"msw":"^2.0.11","vite":"^5.0.8","husky":"^9.1.7","jsdom":"^29.0.2","tslib":"^2.8.1","eslint":"^9.39.4","rollup":"^4.9.6","vitest":"^1.1.0","fast-check":"^3.15.1","size-limit":"^11.0.1","typescript":"^5.3.3","@types/node":"^20.10.6","lint-staged":"^17.0.8","@playwright/test":"^1.40.1","rollup-plugin-dts":"^6.4.1","typescript-eslint":"^8.63.0","@vitest/coverage-v8":"^1.1.0","@rollup/plugin-terser":"^0.4.4","rollup-plugin-postcss":"^4.0.2","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-typescript":"^11.1.6","@rollup/plugin-node-resolve":"^15.2.3","@size-limit/preset-small-lib":"^12.1.0"},"_npmOperationalInternal":{"tmp":"tmp/web-sdk_1.0.2_1783657105772_0.07745713607512017","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@alogame/web-sdk","version":"1.0.3","keywords":["alogame","sdk","authentication","login","html5","h5","game"],"author":{"name":"Alogame"},"license":"MIT","_id":"@alogame/web-sdk@1.0.3","maintainers":[{"name":"alogame","email":"thohd@alogame.vn"}],"homepage":"https://sdk-docs.oeg.vn/docs/web/install","bugs":{"url":"https://support.oeg.vn"},"umd":"dist/oeg-web-sdk.min.js","dist":{"shasum":"66ad11c782499b3dacb5cd9b499687bd4b29f435","tarball":"https://registry.npmjs.org/@alogame/web-sdk/-/web-sdk-1.0.3.tgz","fileCount":10,"integrity":"sha512-jB/HYOU5gD+jB2b+SMduBzld5zUM9PWEe4a7v159eOxIdTHcQ85z2d3GNwkWiUmoZLciKEpZ54eg/6FTmawXQg==","signatures":[{"sig":"MEUCID6JPbPJf/c8clTAvNiSJYVdQasMo7RTON6R2DDyUNFjAiEAklzK1OXGoxOalFsh4Yxnx6FkzNn2TtidKCZ3J9LNskQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":986639},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","unpkg":"dist/oeg-web-sdk.min.js","module":"dist/index.esm.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"tsc --noEmit && eslint src tests","size":"size-limit","test":"vitest run","build":"rollup -c","prepare":"husky","test:e2e":"playwright test","sync:docs":"npm run build && node scripts/sync-docs.mjs","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"alogame","email":"thohd@alogame.vn"},"jsdelivr":"dist/oeg-web-sdk.min.js","repository":{"url":"git+https://gitlab.oeg.vn/oeg-tech/sdk/web-sdk.git","type":"git"},"size-limit":[{"gzip":true,"path":"dist/oeg-web-sdk.min.js","limit":"150KB"}],"_npmVersion":"10.8.2","description":"Alogame Web SDK — authentication & login for browser-based HTML5 (H5) games","directories":{},"lint-staged":{"{src,tests}/**/*.ts":"eslint --fix"},"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"msw":"^2.0.11","vite":"^5.0.8","husky":"^9.1.7","jsdom":"^29.0.2","tslib":"^2.8.1","eslint":"^9.39.4","rollup":"^4.9.6","vitest":"^1.1.0","fast-check":"^3.15.1","size-limit":"^11.0.1","typescript":"^5.3.3","@types/node":"^20.10.6","lint-staged":"^17.0.8","@playwright/test":"^1.40.1","rollup-plugin-dts":"^6.4.1","typescript-eslint":"^8.63.0","@vitest/coverage-v8":"^1.1.0","@rollup/plugin-terser":"^0.4.4","rollup-plugin-postcss":"^4.0.2","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-typescript":"^11.1.6","@rollup/plugin-node-resolve":"^15.2.3","@size-limit/preset-small-lib":"^12.1.0"},"_npmOperationalInternal":{"tmp":"tmp/web-sdk_1.0.3_1784189665381_0.8596544345415262","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@alogame/web-sdk","version":"1.0.6","description":"Alogame Web SDK — authentication & login for browser-based HTML5 (H5) games","type":"module","main":"dist/index.cjs","module":"dist/index.esm.js","umd":"dist/oeg-web-sdk.min.js","unpkg":"dist/oeg-web-sdk.min.js","jsdelivr":"dist/oeg-web-sdk.min.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://gitlab.oeg.vn/oeg-tech/sdk/web-sdk.git"},"homepage":"https://sdk-docs.oeg.vn/docs/web/install","bugs":{"url":"https://support.oeg.vn"},"scripts":{"build":"rollup -c","sync:docs":"npm run build && node scripts/sync-docs.mjs","test":"vitest run","test:watch":"vitest","test:e2e":"playwright test","typecheck":"tsc --noEmit","size":"size-limit","lint":"tsc --noEmit && eslint src tests","prepare":"husky || true"},"keywords":["alogame","sdk","authentication","login","html5","h5","game"],"author":{"name":"Alogame"},"license":"MIT","devDependencies":{"@playwright/test":"^1.40.1","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","@size-limit/preset-small-lib":"^12.1.0","@types/node":"^20.10.6","@vitest/coverage-v8":"^1.1.0","eslint":"^9.39.4","fast-check":"^3.15.1","husky":"^9.1.7","jsdom":"^29.0.2","lint-staged":"^17.0.8","msw":"^2.0.11","rollup":"^4.9.6","rollup-plugin-dts":"^6.4.1","rollup-plugin-postcss":"^4.0.2","size-limit":"^11.0.1","tslib":"^2.8.1","typescript":"^5.3.3","typescript-eslint":"^8.63.0","vite":"^5.0.8","vitest":"^1.1.0"},"size-limit":[{"path":"dist/oeg-web-sdk.min.js","limit":"150KB","gzip":true}],"lint-staged":{"{src,tests}/**/*.ts":"eslint --fix"},"_id":"@alogame/web-sdk@1.0.6","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-RryAuoM2rHDRrhUHCQoxQYnpVuHt7zC2RxkFguBltkDtfpEQqEGTeWgZKKbhYVfclCRMgfyIpOP6NA/oHcEeog==","shasum":"1a2814187034bc65d36006c5322b84d99541781c","tarball":"https://registry.npmjs.org/@alogame/web-sdk/-/web-sdk-1.0.6.tgz","fileCount":10,"unpackedSize":1026998,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAes0KFj3agr3axpUpegvpBK8eOFVxoHxeogFRBQJUa0AiBQBEZFEDvYOZFoOfu7Tk6R+rp+vn2vcOiuthz4MRrILA=="}]},"_npmUser":{"name":"alogametech","email":"thohd@alogame.vn"},"directories":{},"maintainers":[{"name":"alogametech","email":"thohd@alogame.vn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/web-sdk_1.0.6_1784529692104_0.6977303602571887"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-10T03:45:36.897Z","modified":"2026-07-20T06:41:32.421Z","1.0.1":"2026-07-10T03:45:37.262Z","1.0.2":"2026-07-10T04:18:25.967Z","1.0.3":"2026-07-16T08:14:25.561Z","1.0.6":"2026-07-20T06:41:32.264Z"},"bugs":{"url":"https://support.oeg.vn"},"author":{"name":"Alogame"},"license":"MIT","homepage":"https://sdk-docs.oeg.vn/docs/web/install","keywords":["alogame","sdk","authentication","login","html5","h5","game"],"repository":{"type":"git","url":"git+https://gitlab.oeg.vn/oeg-tech/sdk/web-sdk.git"},"description":"Alogame Web SDK — authentication & login for browser-based HTML5 (H5) games","maintainers":[{"name":"alogametech","email":"thohd@alogame.vn"}],"readme":"# Alogame Web SDK\n\nHigh-performance TypeScript SDK for browser-based authentication and payment integration with OEG games.\n\n## Features\n\n- ✅ **Zero Runtime Dependencies** — Pure TypeScript/JavaScript, no third-party libraries\n- ✅ **Two-Layer Architecture** — Headless core + Shadow DOM UI for style isolation\n- ✅ **Tiny Bundle** — 9.6KB gzipped UMD bundle (well under 150KB limit)\n- ✅ **Multi-Format Distribution** — ESM + CommonJS + UMD for all environments\n- ✅ **Full TypeScript Support** — Strict mode with complete `.d.ts` declarations\n- ✅ **Production Ready** — 83 unit and integration tests with 80%+ coverage\n- ✅ **Authentication** — Regular login, registration, guest mode, session persistence\n- ✅ **Payment Integration** — Open the CMS-configured `payment_url` with SSO session handoff\n- ✅ **Event-Driven** — Pub/sub architecture for reactive state management\n- ✅ **i18n Support** — Vietnamese and English localization\n\n## Installation\n\n### Via NPM\n```bash\nnpm install @alogame/web-sdk\n```\n\n### Via CDN (UMD Bundle)\n```html\n<script src=\"https://cdn.alogame.vn/web-sdk/1.0.0/oeg-web-sdk.min.js\"></script>\n<script>\n  OEGWebSdk.init({\n    gameId: 30,\n    baseUrl: 'https://api-sdk.oeg.vn',\n    language: 'vi',\n    floatingButton: true\n  });\n</script>\n```\n\n## Quick Start\n\n### 1. Initialize\n\n```typescript\nimport { OEGWebSdk, OEGAuth, OEGPayment } from '@alogame/web-sdk';\n\nconst sdk = await OEGWebSdk.init({\n  gameId: 30,\n  baseUrl: 'https://api-sdk.oeg.vn',\n  language: 'en',  // or 'vi'\n  floatingButton: true\n});\n```\n\n### 2. Authenticate\n\n```typescript\n// Regular login\nconst loginResult = await OEGAuth.login('username', 'password');\nif (loginResult.success) {\n  console.log('User:', loginResult.user);\n}\n\n// Guest login\nconst guestResult = await OEGAuth.loginGuest();\n\n// Register\nconst registerResult = await OEGAuth.register(\n  'newuser',\n  'Password123!',\n  'Full Name'\n);\n```\n\n### 3. Check Login Status\n\n```typescript\nif (OEGAuth.isLoggedIn) {\n  console.log('Current user:', OEGAuth.currentUser);\n} else {\n  console.log('Not logged in');\n}\n```\n\n### 4. Open Payment Page\n\nThe SDK reads `core.payment_url` from `/v2/config`, wraps it with SSO exchange, and opens the Alogame payment portal. Call this from any game UI button after login.\n\n```typescript\nconst paymentResult = await OEGPayment.openPaymentPage();\n// Alias: await OEGPayment.open();\n// Backward-compatible: await OEGPayment.pay();\n\nif (paymentResult.success) {\n  console.log('Opened payment page:', paymentResult.openedUrl);\n} else {\n  console.error(paymentResult.error);\n}\n```\n\nIf you only need to render your own link/button, read the raw CMS URL:\n\n```typescript\nconst paymentUrl = OEGPayment.getPaymentUrl(); // same as OEGPayment.paymentUrl\n```\n\n### 5. Listen to Events\n\n```typescript\n// Auth state changes\nOEGAuth.onAuthStateChanged((user) => {\n  if (user) {\n    console.log('User logged in:', user.username);\n  } else {\n    console.log('User logged out');\n  }\n});\n\n// Payment completion\nOEGPayment.onPaymentCompleted(() => {\n  console.log('Payment completed!');\n});\n```\n\n### 6. Logout\n\n```typescript\nawait OEGAuth.logout();\nconsole.log('User logged out');\n```\n\n### CDN Usage (Browser)\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n  <script src=\"https://cdn.alogame.vn/web-sdk/1.0.0/oeg-web-sdk.min.js\"></script>\n</head>\n<body>\n  <button id=\"loginBtn\">Login</button>\n  <button id=\"payBtn\" disabled>Pay</button>\n  \n  <script>\n    const { OEGWebSdk, OEGAuth, OEGPayment } = window.OEGWebSdk;\n\n    // Initialize\n    OEGWebSdk.init({\n      gameId: 30,\n      baseUrl: 'https://api-sdk.oeg.vn',\n      language: 'vi',\n      floatingButton: true\n    }).then(() => {\n      const sdk = OEGWebSdk.getInstance();\n      \n      // Login button\n      document.getElementById('loginBtn').addEventListener('click', async () => {\n        const result = await OEGAuth.login('testuser', 'password');\n        if (result.success) {\n          alert('Logged in: ' + result.user.username);\n          document.getElementById('payBtn').disabled = false;\n        }\n      });\n\n      // Payment button — can be placed anywhere in the game UI\n      document.getElementById('payBtn').addEventListener('click', async () => {\n        const result = await OEGPayment.openPaymentPage();\n        if (!result.success) {\n          alert(result.error || 'Cannot open payment page');\n        }\n      });\n    });\n  </script>\n</body>\n</html>\n```\n\n## Development\n\n### Build\n```bash\nnpm run build\n```\n\nOutputs:\n- `dist/oeg-web-sdk.min.js` — UMD bundle for CDN\n- `dist/index.esm.js` — ESM bundle for npm\n- `dist/index.js` — CommonJS bundle\n- `dist/index.d.ts` — TypeScript declarations\n\n### Test\n```bash\nnpm test                 # Unit tests\nnpm run test:watch      # Watch mode\nnpm run test:e2e        # E2E tests with Playwright\n```\n\n### Type Check\n```bash\nnpm run typecheck\n```\n\n### Bundle Size\n```bash\nnpm run size\n```\n\n## Architecture\n\n### Two-Layer Design\n\n**Core Layer** (`src/core/`)\n- Headless, zero DOM dependency\n- HTTP client with interceptors\n- Session/token management\n- Event emitter\n- Storage adapter (localStorage → sessionStorage → memory)\n\n**UI Layer** (`src/ui/`)\n- Shadow DOM modals (no style pollution)\n- Login modal\n- Payment modal\n- OTP verification modal\n\n**Facades** (`src/facades/`)\n- Public API surface\n- `OEGWebSdk` singleton\n- Type-safe interfaces\n\n## API Reference\n\n### OEGWebSdk\n\n#### `static init(config: SdkConfig): Promise<OEGWebSdk>`\nInitialize the SDK with configuration. `gameId` is a number issued by OEG; `floatingButton` defaults to `true`. Do not pass any secret key in browser code.\n\n#### `static getInstance(): OEGWebSdk`\nGet the singleton instance.\n\n#### `openLogin(): Promise<AuthUser | null>`\nOpen login modal. Returns authenticated user or null if canceled.\n\n#### `getPaymentUrl(): string`\nReturn the raw CMS `core.payment_url` from `/v2/config`.\n\n#### `openPaymentPage(): Promise<PaymentResult>`\nOpen the configured Alogame payment page with SSO session handoff. Requires login.\n\n#### `openPayment(): Promise<boolean>`\nLegacy payment modal API. New integrations should use `openPaymentPage()` / `OEGPayment.openPaymentPage()`.\n\n#### `isReady(): boolean`\nCheck if SDK is initialized and ready.\n\n#### `on(event: string, handler: Function): void`\nSubscribe to SDK events (`loginCompleted`, `paymentCompleted`, `sessionExpired`).\n\n#### `destroy(): void`\nCleanup and destroy SDK instance.\n\n## Error Handling\n\nAll SDK errors follow the `OEGError` interface:\n\n```typescript\ninterface OEGError {\n  code: ErrorCode;\n  message: string;\n  httpStatus?: number;\n}\n```\n\nError codes:\n- `INVALID_CREDENTIALS` — Login failed\n- `SESSION_EXPIRED` — Token expired\n- `NETWORK_ERROR` — Network failure\n- `NETWORK_TIMEOUT` — Request timeout\n- `VALIDATION_ERROR` — Input validation failed\n- `PAYMENT_FAILED` — Payment failed\n- `PAYMENT_CANCELLED` — User canceled payment\n\n## CSP Requirements\n\nWhen using the SDK, ensure your Content Security Policy allows:\n\n```\nscript-src https://accounts.google.com https://connect.facebook.net https://cdn.alogame.vn;\nstyle-src 'unsafe-inline';\nimg-src data: https:;\n```\n\n## Browser Support\n\n- Chrome 90+\n- Firefox 88+\n- Safari 14+\n- Edge 90+\n\n## License\n\nMIT © OEG Team\n","readmeFilename":"README.md"}