{"_id":"@cregis/market-app-web-sdk","_rev":"2-8e322262512b6833c8de782251ccb6e8","name":"@cregis/market-app-web-sdk","dist-tags":{"latest":"1.0.15"},"versions":{"1.0.14":{"name":"@cregis/market-app-web-sdk","version":"1.0.14","_id":"@cregis/market-app-web-sdk@1.0.14","maintainers":[{"name":"pinfan","email":"18098351706@163.com"},{"name":"hsyuan","email":"hsyuan0811@gmail.com"},{"name":"hanbg","email":"goohanbg@gmail.com"},{"name":"lwjxj","email":"1097408921@qq.com"}],"dist":{"shasum":"8ce48d1af57790645dfdb70abfc13791c25c25b2","tarball":"https://registry.npmjs.org/@cregis/market-app-web-sdk/-/market-app-web-sdk-1.0.14.tgz","fileCount":25,"integrity":"sha512-uBlUCHO00wbT4TT79oB9mut7HJu1VoefE+DdH6mZfVHFmPeX3RyGJdhBTZZZsDBh8Rx4Z/wV8gjPhDkdcYK6jg==","signatures":[{"sig":"MEUCIQDaD1L5SKzElWkT2Im9YyC9cAn5PynO5yQDqah51+SADwIgG0wgQEgJr5ZAw60OdMD6lKaHIZoPo9iVNH7T03TMRuQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48506},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./http":{"types":"./dist/http.d.ts","import":"./dist/http.js"},"./config":{"types":"./dist/config.d.ts","import":"./dist/config.js"},"./runtime":{"types":"./dist/runtime.d.ts","import":"./dist/runtime.js"},"./api/auth":{"types":"./dist/api/auth.d.ts","import":"./dist/api/auth.js"},"./auth-state":{"types":"./dist/auth-state.d.ts","import":"./dist/auth-state.js"},"./route-guard":{"types":"./dist/route-guard.d.ts","import":"./dist/route-guard.js"},"./use-app-shell":{"types":"./dist/use-app-shell.d.ts","import":"./dist/use-app-shell.js"},"./use-sso-bridge":{"types":"./dist/use-sso-bridge.d.ts","import":"./dist/use-sso-bridge.js"},"./use-app-permission":{"types":"./dist/use-app-permission.d.ts","import":"./dist/use-app-permission.js"},"./components/MarketAppShell.vue":{"import":"./dist/components/MarketAppShell.vue","default":"./dist/components/MarketAppShell.vue"},"./components/MarketAppMenuTree.vue":{"import":"./dist/components/MarketAppMenuTree.vue","default":"./dist/components/MarketAppMenuTree.vue"},"./components/MarketAppSsoBridge.vue":{"import":"./dist/components/MarketAppSsoBridge.vue","default":"./dist/components/MarketAppSsoBridge.vue"}},"gitHead":"cfd005de45e6da3c5ae49fc7e0fd85efb094f95b","scripts":{"lint":"eslint --config eslint.config.cjs . --ext .vue,.js,.jsx,.ts,.tsx","build":"node ./scripts/build.mjs","format":"prettier --write .","lint:fix":"eslint --config eslint.config.cjs . --ext .vue,.js,.jsx,.ts,.tsx --fix","typecheck":"tsc --noEmit","format:check":"prettier --check .","prepublishOnly":"npm run build"},"_npmUser":{"name":"hsyuan","email":"hsyuan0811@gmail.com"},"_npmVersion":"10.9.4","description":"Reusable frontend integration layer for third-party app-market web applications.","directories":{},"_nodeVersion":"22.22.1","_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.0","axios":"^1.7.2","eslint":"^10.4.1","globals":"^17.6.0","prettier":"^3.8.3","typescript":"^5.0.0","vue-router":"^4.4.0","element-plus":"^2.14.3","eslint-plugin-vue":"^10.9.2","eslint-define-config":"^2.1.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.6","@typescript-eslint/parser":"^8.61.0","@typescript-eslint/eslint-plugin":"^8.61.0"},"peerDependencies":{"vue":"^3.0.0","axios":"^1.0.0","vue-router":"^4.0.0","element-plus":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/market-app-web-sdk_1.0.14_1786959550928_0.08188650705356859","host":"s3://npm-registry-packages-npm-production"}},"1.0.15":{"name":"@cregis/market-app-web-sdk","version":"1.0.15","description":"Reusable frontend integration layer for third-party app-market web applications.","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./api/auth":{"types":"./dist/api/auth.d.ts","import":"./dist/api/auth.js"},"./auth-state":{"types":"./dist/auth-state.d.ts","import":"./dist/auth-state.js"},"./components/MarketAppMenuTree.vue":{"import":"./dist/components/MarketAppMenuTree.vue","default":"./dist/components/MarketAppMenuTree.vue"},"./components/MarketAppShell.vue":{"import":"./dist/components/MarketAppShell.vue","default":"./dist/components/MarketAppShell.vue"},"./components/MarketAppSsoBridge.vue":{"import":"./dist/components/MarketAppSsoBridge.vue","default":"./dist/components/MarketAppSsoBridge.vue"},"./config":{"types":"./dist/config.d.ts","import":"./dist/config.js"},"./http":{"types":"./dist/http.d.ts","import":"./dist/http.js"},"./route-guard":{"types":"./dist/route-guard.d.ts","import":"./dist/route-guard.js"},"./runtime":{"types":"./dist/runtime.d.ts","import":"./dist/runtime.js"},"./use-app-permission":{"types":"./dist/use-app-permission.d.ts","import":"./dist/use-app-permission.js"},"./use-app-shell":{"types":"./dist/use-app-shell.d.ts","import":"./dist/use-app-shell.js"},"./use-market-app-router":{"types":"./dist/use-market-app-router.d.ts","import":"./dist/use-market-app-router.js"},"./use-sso-bridge":{"types":"./dist/use-sso-bridge.d.ts","import":"./dist/use-sso-bridge.js"}},"scripts":{"build":"node ./scripts/build.mjs","prepublishOnly":"npm run build","typecheck":"tsc --noEmit","lint":"eslint --config eslint.config.cjs . --ext .vue,.js,.jsx,.ts,.tsx","lint:fix":"eslint --config eslint.config.cjs . --ext .vue,.js,.jsx,.ts,.tsx --fix","format":"prettier --write .","format:check":"prettier --check ."},"peerDependencies":{"axios":"^1.0.0","element-plus":"^2.0.0","vue":"^3.0.0","vue-router":"^4.0.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^8.61.0","@typescript-eslint/parser":"^8.61.0","axios":"^1.7.2","element-plus":"^2.14.3","eslint":"^10.4.1","eslint-config-prettier":"^10.1.8","eslint-define-config":"^2.1.0","eslint-plugin-prettier":"^5.5.6","eslint-plugin-vue":"^10.9.2","globals":"^17.6.0","prettier":"^3.8.3","typescript":"^5.0.0","vue":"^3.5.0","vue-router":"^4.4.0"},"_id":"@cregis/market-app-web-sdk@1.0.15","gitHead":"9dcc097641e29d70cd0a4ebf6dbc3e04ddff06f5","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-zThSFthvBo/lFMHuqv4jaz7YYXmh3FQjRBAVLzMdT6CgO/Bj0pHNhHuJaLdiWwVANfvm95lBndJtrL1mJoGUUg==","shasum":"7542434a870b32a5e55e3d5240d7db729ecde29f","tarball":"https://registry.npmjs.org/@cregis/market-app-web-sdk/-/market-app-web-sdk-1.0.15.tgz","fileCount":27,"unpackedSize":52535,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQChf1lTRBG3bo7SBXszX/XS+jDKgFUPfrw6HXH6u56ZcQIhAPow4ZVAVJhAlAkUIfJoLjVwPAQ44kY1DIflT2KEh6Iy"}]},"_npmUser":{"name":"hsyuan","email":"hsyuan0811@gmail.com"},"directories":{},"maintainers":[{"name":"pinfan","email":"18098351706@163.com"},{"name":"hsyuan","email":"hsyuan0811@gmail.com"},{"name":"hanbg","email":"goohanbg@gmail.com"},{"name":"lwjxj","email":"1097408921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/market-app-web-sdk_1.0.15_1788339842773_0.2354302760736211"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-17T09:39:10.669Z","modified":"2026-09-02T09:04:03.236Z","1.0.14":"2026-08-17T09:39:11.066Z","1.0.15":"2026-09-02T09:04:02.921Z"},"description":"Reusable frontend integration layer for third-party app-market web applications.","maintainers":[{"name":"pinfan","email":"18098351706@163.com"},{"name":"hsyuan","email":"hsyuan0811@gmail.com"},{"name":"hanbg","email":"goohanbg@gmail.com"},{"name":"lwjxj","email":"1097408921@qq.com"}],"readme":"# market-app-web-sdk\n\n`@cregis/market-app-web-sdk` is the reusable frontend integration layer for App Market third-party applications.\n\n## What it provides\n\n1. SSO bridge flow\n2. Local auth state storage\n3. HTTP auth interception and re-auth trigger\n4. Route guard and visible-menu navigation\n5. App shell layout helpers\n6. App-scoped permission helpers\n7. Third-party-mode route and permission adaptation\n\n## Install\n\n```bash\nnpm install @cregis/market-app-web-sdk\n```\n\n## Quick Start\n\n### 1. Initialize the SDK\n\n```ts\nimport { initCregisMarketAppConfig } from '@cregis/market-app-web-sdk'\n\ninitCregisMarketAppConfig({\n  sdkServerUrl: import.meta.env.VITE_MARKET_APP_SERVER_URL || 'http://127.0.0.1:48088',\n})\n```\n\nNotes:\n\n1. In third-party mode, `sdkServerUrl` should point to the real third-party backend\n2. In internal mode, the SDK automatically resolves the API base to `{origin}/app-market-api/{appCode}`\n3. Frontends must never hold `appThirdId/appSecret`\n4. If the backend wants to push API errors to `marketing` by default, set `app-market.app-api-error-enabled=true` in the server SDK config\n\n### 2. Create an HTTP client\n\n```ts\nimport { createMarketAppHttp } from '@cregis/market-app-web-sdk'\n\nexport const http = createMarketAppHttp()\n```\n\nThe backend is expected to return the standard structure below on success:\n\n```json\n{\n  \"code\": 200,\n  \"msg\": \"success\",\n  \"data\": {}\n}\n```\n\nUsing `MarketAppCommonResult<T>` from `marketing-app-security-sdk` is recommended, but any backend response with the same JSON shape is also supported.\n\n### 3. Install the route guard\n\n```ts\nimport { installMarketAppRouteGuard } from '@cregis/market-app-web-sdk'\n\ninstallMarketAppRouteGuard(router)\n```\n\n### 4. Use the SSO bridge\n\n```vue\n<template>\n  <MarketAppSsoBridge\n    :bootstrap-login=\"bootstrapLogin\"\n    :fetch-menu-access=\"getCurrentMenuAccess\"\n    :fetch-data-permission=\"getCurrentDataPermission\"\n    :fetch-menus=\"getCurrentMenus\"\n  />\n</template>\n```\n\n## Mode Detection\n\nThe SDK decides the runtime mode from the current path:\n\n1. `/app-market/{appCode}/...` -> internal mode\n2. Anything else -> third-party mode\n\nIn internal mode, the SDK automatically:\n\n1. Resolves the router base to `/app-market/{appCode}`\n2. Resolves the API base to `{origin}/app-market-api/{appCode}`\n\nIn third-party mode, the SDK uses the configured `sdkServerUrl`.\n\n## Permission Convention\n\nBusiness pages are expected to declare permission suffixes, for example:\n\n```ts\nmeta: { menuAccess: ['class:query'] }\n```\n\nThe SDK automatically matches them against the current app-scoped permission set.\n\n## Environment Variable\n\nDefault env variable:\n\n1. `VITE_MARKET_APP_SERVER_URL`\n\n## Security Rules\n\n1. Do not expose `appThirdId/appSecret` to the frontend\n2. Do not call normal `marketing` admin APIs from the third-party frontend\n3. Keep backend authorization checks even when buttons are hidden in the UI\n4. Keep the backend `allow-origins` list aligned with the real page origins\n\n## Docs\n\nUnified documents:\n\n1. `docs/三方独立应用接入.md`\n2. `docs/三方独立应用架构设计文档.md`\n","readmeFilename":"README.md"}