├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── config.yml └── workflows │ └── release.yml ├── .gitignore ├── .husky └── pre-commit ├── .prettierrc ├── LICENSE ├── README-zh_CN.md ├── README.md ├── examples ├── miniapp-taro │ ├── .editorconfig │ ├── .eslintrc │ ├── .gitignore │ ├── babel.config.js │ ├── config │ │ ├── dev.js │ │ ├── index.js │ │ └── prod.js │ ├── package-lock.json │ ├── package.json │ ├── project.config.json │ ├── project.tt.json │ ├── src │ │ ├── app.config.ts │ │ ├── app.less │ │ ├── app.ts │ │ ├── index.html │ │ └── pages │ │ │ └── index │ │ │ ├── index.config.ts │ │ │ ├── index.less │ │ │ └── index.tsx │ ├── tsconfig.json │ └── types │ │ └── global.d.ts ├── miniapp-tt │ ├── app.json │ ├── app.ts │ ├── app.ttss │ ├── miniprogram_npm │ │ ├── @authing │ │ │ ├── miniapp-jsencrypt │ │ │ │ ├── index.js │ │ │ │ ├── lib │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.js.map │ │ │ │ │ ├── jsencrypt.js │ │ │ │ │ └── jsencrypt.js.map │ │ │ │ └── package.json │ │ │ ├── miniapp-sm2encrypt │ │ │ │ ├── index.js │ │ │ │ ├── lib │ │ │ │ │ ├── ec.js │ │ │ │ │ ├── ec.js.map │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.js.map │ │ │ │ │ ├── sm2.js │ │ │ │ │ ├── sm2.js.map │ │ │ │ │ ├── sm3.js │ │ │ │ │ ├── sm3.js.map │ │ │ │ │ ├── utils.js │ │ │ │ │ └── utils.js.map │ │ │ │ └── package.json │ │ │ └── miniapp-tt │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ └── jsbn │ │ │ ├── example.js │ │ │ ├── example.js.map │ │ │ ├── index.js │ │ │ ├── index.js.map │ │ │ ├── package.json │ │ │ └── test │ │ │ ├── es6-import.js │ │ │ └── es6-import.js.map │ ├── package-lock.json │ ├── package.json │ ├── pages │ │ └── index │ │ │ ├── index.json │ │ │ ├── index.ts │ │ │ ├── index.ttml │ │ │ └── index.ttss │ ├── project.config.json │ └── tsconfig.json ├── miniapp-uniapp │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── jsconfig.json │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── public │ │ └── index.html │ ├── sfc.d.ts │ ├── shime-vue.d.ts │ └── src │ │ ├── App.vue │ │ ├── main.js │ │ ├── manifest.json │ │ ├── pages.json │ │ ├── pages │ │ └── index │ │ │ └── index.vue │ │ ├── static │ │ └── logo.png │ │ └── uni.scss ├── miniapp-wx │ ├── .eslintrc.js │ ├── README.md │ ├── miniapp │ │ ├── app.js │ │ ├── app.json │ │ ├── app.wxss │ │ ├── envList.js │ │ ├── miniprogram_npm │ │ │ ├── @authing │ │ │ │ ├── miniapp-jsencrypt │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.js.map │ │ │ │ ├── miniapp-sm2encrypt │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.js.map │ │ │ │ ├── miniapp-wx │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.js.map │ │ │ │ └── web │ │ │ │ │ ├── index.js │ │ │ │ │ └── index.js.map │ │ │ ├── axios │ │ │ │ ├── index.js │ │ │ │ └── index.js.map │ │ │ ├── follow-redirects │ │ │ │ ├── index.js │ │ │ │ └── index.js.map │ │ │ └── jsbn │ │ │ │ ├── index.js │ │ │ │ └── index.js.map │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── pages │ │ │ └── index │ │ │ │ ├── index.json │ │ │ │ ├── index.ts │ │ │ │ ├── index.wxml │ │ │ │ └── index.wxss │ │ └── sitemap.json │ ├── project.config.json │ ├── project.private.config.json │ ├── tsconfig.json │ ├── uploadCloudFunction.sh │ └── uploadError.txt ├── web │ ├── cdn │ │ ├── index.html │ │ ├── index.js │ │ ├── package-lock.json │ │ ├── package.json │ │ └── webpack.config.js │ ├── spa │ │ ├── angular │ │ │ ├── .browserslistrc │ │ │ ├── .gitignore │ │ │ ├── .vscode │ │ │ │ ├── extensions.json │ │ │ │ ├── launch.json │ │ │ │ └── tasks.json │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── README.zh-CN.md │ │ │ ├── angular.json │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── app │ │ │ │ │ ├── app.component.html │ │ │ │ │ ├── app.component.ts │ │ │ │ │ └── app.module.ts │ │ │ │ ├── assets │ │ │ │ │ └── .gitkeep │ │ │ │ ├── environments │ │ │ │ │ ├── environment.prod.ts │ │ │ │ │ └── environment.ts │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html │ │ │ │ ├── main.ts │ │ │ │ ├── polyfills.ts │ │ │ │ └── styles.css │ │ │ ├── tsconfig.app.json │ │ │ ├── tsconfig.json │ │ │ └── yarn.lock │ │ ├── react │ │ │ ├── .env │ │ │ ├── .gitignore │ │ │ ├── .prettierrc │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── README.zh-CN.md │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html │ │ │ │ ├── logo192.png │ │ │ │ ├── logo512.png │ │ │ │ ├── manifest.json │ │ │ │ └── robots.txt │ │ │ ├── src │ │ │ │ ├── App.tsx │ │ │ │ ├── index.css │ │ │ │ ├── index.tsx │ │ │ │ └── react-app-env.d.ts │ │ │ ├── tsconfig.json │ │ │ └── yarn.lock │ │ └── vue │ │ │ ├── README.md │ │ │ ├── README.zh-CN.md │ │ │ ├── vue2 │ │ │ ├── .browserslistrc │ │ │ ├── .env │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── .prettierrc │ │ │ ├── LICENSE │ │ │ ├── babel.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ │ ├── favicon.ico │ │ │ │ └── index.html │ │ │ ├── src │ │ │ │ ├── App.vue │ │ │ │ └── main.js │ │ │ ├── vue.config.js │ │ │ └── yarn.lock │ │ │ └── vue3 │ │ │ ├── .browserslistrc │ │ │ ├── .env │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── .prettierrc │ │ │ ├── LICENSE │ │ │ ├── babel.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ │ ├── src │ │ │ ├── App.vue │ │ │ └── main.js │ │ │ ├── vue.config.js │ │ │ └── yarn.lock │ └── sso │ │ ├── angular │ │ ├── README.md │ │ ├── doc-assets │ │ │ ├── sso-app-panel-address.png │ │ │ ├── sso-appid.png │ │ │ ├── sso-authorization-configuration.png │ │ │ ├── sso-callback.png │ │ │ ├── sso-create-app.png │ │ │ └── sso-panel.png │ │ ├── website1 │ │ │ ├── .browserslistrc │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── .vscode │ │ │ │ ├── extensions.json │ │ │ │ ├── launch.json │ │ │ │ └── tasks.json │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── angular.json │ │ │ ├── karma.conf.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── app │ │ │ │ │ ├── app.component.css │ │ │ │ │ ├── app.component.html │ │ │ │ │ ├── app.component.spec.ts │ │ │ │ │ ├── app.component.ts │ │ │ │ │ └── app.module.ts │ │ │ │ ├── assets │ │ │ │ │ └── .gitkeep │ │ │ │ ├── environments │ │ │ │ │ ├── environment.prod.ts │ │ │ │ │ └── environment.ts │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html │ │ │ │ ├── main.ts │ │ │ │ ├── polyfills.ts │ │ │ │ ├── styles.css │ │ │ │ └── test.ts │ │ │ ├── tsconfig.app.json │ │ │ ├── tsconfig.json │ │ │ └── tsconfig.spec.json │ │ └── website2 │ │ │ ├── .browserslistrc │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── .vscode │ │ │ ├── extensions.json │ │ │ ├── launch.json │ │ │ └── tasks.json │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── angular.json │ │ │ ├── karma.conf.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── src │ │ │ ├── app │ │ │ │ ├── app.component.css │ │ │ │ ├── app.component.html │ │ │ │ ├── app.component.spec.ts │ │ │ │ ├── app.component.ts │ │ │ │ └── app.module.ts │ │ │ ├── assets │ │ │ │ └── .gitkeep │ │ │ ├── environments │ │ │ │ ├── environment.prod.ts │ │ │ │ └── environment.ts │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── main.ts │ │ │ ├── polyfills.ts │ │ │ ├── styles.css │ │ │ └── test.ts │ │ │ ├── tsconfig.app.json │ │ │ ├── tsconfig.json │ │ │ └── tsconfig.spec.json │ │ ├── cdn │ │ ├── README.md │ │ ├── website1 │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── webpack.config.js │ │ └── website2 │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── webpack.config.js │ │ ├── react │ │ ├── README.md │ │ ├── doc-assets │ │ │ ├── sso-app-panel-address.png │ │ │ ├── sso-appid.png │ │ │ ├── sso-authorization-configuration.png │ │ │ ├── sso-callback.png │ │ │ ├── sso-create-app.png │ │ │ └── sso-panel.png │ │ ├── website1 │ │ │ ├── .env │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ │ ├── favicon.ico │ │ │ │ ├── index.html │ │ │ │ ├── logo192.png │ │ │ │ ├── logo512.png │ │ │ │ ├── manifest.json │ │ │ │ └── robots.txt │ │ │ ├── src │ │ │ │ ├── App.tsx │ │ │ │ ├── index.tsx │ │ │ │ └── react-app-env.d.ts │ │ │ ├── tsconfig.json │ │ │ └── yarn.lock │ │ └── website2 │ │ │ ├── .env │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ └── robots.txt │ │ │ ├── src │ │ │ ├── App.tsx │ │ │ ├── index.tsx │ │ │ └── react-app-env.d.ts │ │ │ ├── tsconfig.json │ │ │ └── yarn.lock │ │ ├── vue2 │ │ ├── README.md │ │ ├── doc-assets │ │ │ ├── sso-app-panel-address.png │ │ │ ├── sso-appid.png │ │ │ ├── sso-authorization-configuration.png │ │ │ ├── sso-callback.png │ │ │ ├── sso-create-app.png │ │ │ └── sso-panel.png │ │ ├── website1 │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── babel.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ │ ├── favicon.ico │ │ │ │ └── index.html │ │ │ ├── src │ │ │ │ ├── App.vue │ │ │ │ └── main.js │ │ │ ├── vue.config.js │ │ │ └── yarn.lock │ │ └── website2 │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── babel.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ │ ├── src │ │ │ ├── App.vue │ │ │ └── main.js │ │ │ ├── vue.config.js │ │ │ └── yarn.lock │ │ └── vue3 │ │ ├── README.md │ │ ├── doc-assets │ │ ├── sso-app-panel-address.png │ │ ├── sso-appid.png │ │ ├── sso-authorization-configuration.png │ │ ├── sso-callback.png │ │ ├── sso-create-app.png │ │ └── sso-panel.png │ │ ├── website1 │ │ ├── .browserslistrc │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── babel.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ ├── src │ │ │ ├── App.vue │ │ │ └── main.js │ │ ├── vue.config.js │ │ └── yarn.lock │ │ └── website2 │ │ ├── .browserslistrc │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── babel.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── App.vue │ │ └── main.js │ │ ├── vue.config.js │ │ └── yarn.lock └── weixin-official-account │ ├── index.html │ ├── index.js │ ├── package-lock.json │ ├── package.json │ └── webpack.config.js ├── lerna.json ├── package-lock.json ├── package.json ├── packages ├── miniapp-jsencrypt │ ├── README.md │ ├── lib │ │ ├── index.js │ │ ├── jsencrypt.d.ts │ │ └── jsencrypt.js │ └── package.json ├── miniapp-sm2encrypt │ ├── README.md │ ├── lib │ │ ├── ec.js │ │ ├── index.js │ │ ├── sm2.js │ │ ├── sm2encrypt.d.ts │ │ ├── sm3.js │ │ └── utils.js │ ├── package-lock.json │ └── package.json ├── miniapp-taro │ ├── README.md │ └── package.json ├── miniapp-tt │ ├── README.md │ └── package.json ├── miniapp-uniapp │ ├── README.md │ └── package.json ├── miniapp-wx │ ├── README.md │ └── package.json ├── miniapp │ ├── LICENSE │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── scripts │ │ ├── build.js │ │ ├── config.js │ │ ├── getWebpackConfig.js │ │ ├── utils.js │ │ └── webpack.base.config.js │ ├── src │ │ ├── Authing.ts │ │ ├── AuthingMove.ts │ │ ├── helpers │ │ │ ├── StorageProvider.ts │ │ │ ├── index.ts │ │ │ ├── request.ts │ │ │ ├── return.ts │ │ │ └── utils.ts │ │ ├── index.ts │ │ └── types.ts │ └── tsconfig.json ├── web │ ├── README.md │ ├── README.zh-CN.md │ ├── package-lock.json │ ├── package.json │ ├── rollup.config.ts │ ├── src │ │ ├── Authing.ts │ │ ├── axios.ts │ │ ├── constants.ts │ │ ├── global.ts │ │ ├── index.ts │ │ ├── storage │ │ │ ├── InMemoryStorgeProvider.ts │ │ │ ├── LocalStorageProvider.ts │ │ │ ├── NullStorageProvider.ts │ │ │ ├── SessionStorageProvider.ts │ │ │ └── interface.ts │ │ ├── types.ts │ │ └── utils.ts │ └── tsconfig.json └── weixin-official-account │ ├── README-zh_CN.md │ ├── README.md │ ├── assets │ └── 1.png │ ├── package-lock.json │ ├── package.json │ ├── scripts │ ├── build.js │ ├── webpack.esm.config.js │ └── webpack.global.config.js │ ├── src │ ├── index.ts │ └── types.ts │ └── tsconfig.json ├── scripts ├── oss.js └── transfer-miniapp-libs.js └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [Makefile] 12 | indent_style = tab -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/**/* 2 | node_module/**/* 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | sourceType: 'module', 6 | ecmaVersion: 'es2015' 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | rules: { 15 | indent: [ 16 | 'error', 17 | 2 18 | ], 19 | 'linebreak-style': [ 20 | 'error', 21 | 'unix' 22 | ], 23 | quotes: [ 24 | 'error', 25 | 'single' 26 | ], 27 | semi: [ 28 | 'error', 29 | 'never' 30 | ], 31 | "indent": [ "error", "tab", { "SwitchCase": 1 } ], 32 | // `eslint/no-unused-vars` will check all qualified ts files, include d.ts 33 | // using interface to define function types is compliant, but `eslint/no-unused-vars` will prompt for unused parameters...... 34 | // so set `args === none` here 35 | // and leave `no-unused-vars` to `@typescript-eslint/no-unused-vars` 36 | "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false, varsIgnorePattern: '.*' }], 37 | "@typescript-eslint/no-unused-vars": ['error'], 38 | '@typescript-eslint/no-explicit-any': 'off', 39 | '@typescript-eslint/no-var-requires': 'off', 40 | '@typescript-eslint/no-empty-interface': 'off', 41 | 'prefer-const': 'off', 42 | '@typescript-eslint/ban-ts-comment': 'off', 43 | 'prettier/prettier': 'off', 44 | '@typescript-eslint/no-this-alias': 'off' 45 | } 46 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: For reporting bugs or errors in the Authing JS SDK 4 | title: 'Issue: Open an issue' 5 | labels: bug 6 | assignees: zhaoyiming0803 7 | 8 | --- 9 | 10 | 23 | 24 | - **Version**: 25 | 28 | 29 | - **Platform**: 30 | 33 | 34 | #### Severity: 35 | 43 | 44 | #### Description: 45 | 50 | 51 | #### Steps to reproduce the error: 52 | 55 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Questions 4 | url: https://forum.authing.cn/ 5 | about: For general questions, support requests and discussions 6 | - name: Document 7 | url: https://docs.authing.cn/v2/reference/ 8 | about: Authing JS SDK 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | node_modules 4 | .DS_Store 5 | dist 6 | .angular 7 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npm run lint 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | semi: false 2 | singleQuote: true 3 | printWidth: 80 4 | trailingComma: 'none' 5 | arrowParens: 'avoid' 6 | tabWidth: 2 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/miniapp-taro/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /examples/miniapp-taro/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["taro/react"], 3 | "rules": { 4 | "react/jsx-uses-react": "off", 5 | "react/react-in-jsx-scope": "off" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/miniapp-taro/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | deploy_versions/ 3 | .temp/ 4 | .rn_temp/ 5 | node_modules/ 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /examples/miniapp-taro/babel.config.js: -------------------------------------------------------------------------------- 1 | // babel-preset-taro 更多选项和默认值: 2 | // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md 3 | module.exports = { 4 | presets: [ 5 | ['taro', { 6 | framework: 'react', 7 | ts: true 8 | }] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/miniapp-taro/config/dev.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | NODE_ENV: '"development"' 4 | }, 5 | defineConstants: { 6 | }, 7 | mini: {}, 8 | h5: {} 9 | } 10 | -------------------------------------------------------------------------------- /examples/miniapp-taro/config/prod.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | NODE_ENV: '"production"' 4 | }, 5 | defineConstants: { 6 | }, 7 | mini: {}, 8 | h5: { 9 | /** 10 | * WebpackChain 插件配置 11 | * @docs https://github.com/neutrinojs/webpack-chain 12 | */ 13 | // webpackChain (chain) { 14 | // /** 15 | // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。 16 | // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer 17 | // */ 18 | // chain.plugin('analyzer') 19 | // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) 20 | 21 | // /** 22 | // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。 23 | // * @docs https://github.com/chrisvfritz/prerender-spa-plugin 24 | // */ 25 | // const path = require('path') 26 | // const Prerender = require('prerender-spa-plugin') 27 | // const staticDir = path.join(__dirname, '..', 'dist') 28 | // chain 29 | // .plugin('prerender') 30 | // .use(new Prerender({ 31 | // staticDir, 32 | // routes: [ '/pages/index/index' ], 33 | // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') }) 34 | // })) 35 | // } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/miniapp-taro/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "miniprogramRoot": "./dist", 3 | "projectname": "miniapp-taro", 4 | "description": "@authing/miniapp-taro mode", 5 | "appid": "wx9d4531dea21e20d5", 6 | "setting": { 7 | "urlCheck": true, 8 | "es6": false, 9 | "enhance": false, 10 | "compileHotReLoad": false, 11 | "postcss": false, 12 | "minified": false 13 | }, 14 | "compileType": "miniprogram" 15 | } 16 | -------------------------------------------------------------------------------- /examples/miniapp-taro/project.tt.json: -------------------------------------------------------------------------------- 1 | { 2 | "miniprogramRoot": "./", 3 | "projectname": "miniapp-taro", 4 | "appid": "testAppId", 5 | "setting": { 6 | "es6": false, 7 | "minified": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/miniapp-taro/src/app.config.ts: -------------------------------------------------------------------------------- 1 | export default defineAppConfig({ 2 | pages: [ 3 | 'pages/index/index' 4 | ], 5 | window: { 6 | backgroundTextStyle: 'light', 7 | navigationBarBackgroundColor: '#fff', 8 | navigationBarTitleText: 'WeChat', 9 | navigationBarTextStyle: 'black' 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /examples/miniapp-taro/src/app.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-taro/src/app.less -------------------------------------------------------------------------------- /examples/miniapp-taro/src/app.ts: -------------------------------------------------------------------------------- 1 | import { Component, PropsWithChildren } from 'react' 2 | import './app.less' 3 | 4 | class App extends Component { 5 | 6 | componentDidMount () {} 7 | 8 | componentDidShow () {} 9 | 10 | componentDidHide () {} 11 | 12 | render () { 13 | // this.props.children 是将要会渲染的页面 14 | return this.props.children 15 | } 16 | } 17 | 18 | export default App 19 | -------------------------------------------------------------------------------- /examples/miniapp-taro/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | miniapp-taro 12 | 13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/miniapp-taro/src/pages/index/index.config.ts: -------------------------------------------------------------------------------- 1 | export default definePageConfig({ 2 | navigationBarTitleText: '首页' 3 | }) 4 | -------------------------------------------------------------------------------- /examples/miniapp-taro/src/pages/index/index.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-taro/src/pages/index/index.less -------------------------------------------------------------------------------- /examples/miniapp-taro/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "removeComments": false, 6 | "preserveConstEnums": true, 7 | "moduleResolution": "node", 8 | "experimentalDecorators": true, 9 | "noImplicitAny": false, 10 | "allowSyntheticDefaultImports": true, 11 | "outDir": "lib", 12 | "noUnusedLocals": true, 13 | "noUnusedParameters": true, 14 | "strictNullChecks": true, 15 | "sourceMap": true, 16 | "baseUrl": ".", 17 | "rootDir": ".", 18 | "jsx": "react-jsx", 19 | "allowJs": true, 20 | "resolveJsonModule": true, 21 | "typeRoots": [ 22 | "node_modules/@types" 23 | ] 24 | }, 25 | "include": ["./src", "./types"], 26 | "compileOnSave": false 27 | } 28 | -------------------------------------------------------------------------------- /examples/miniapp-taro/types/global.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module '*.png'; 4 | declare module '*.gif'; 5 | declare module '*.jpg'; 6 | declare module '*.jpeg'; 7 | declare module '*.svg'; 8 | declare module '*.css'; 9 | declare module '*.less'; 10 | declare module '*.scss'; 11 | declare module '*.sass'; 12 | declare module '*.styl'; 13 | 14 | declare namespace NodeJS { 15 | interface ProcessEnv { 16 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd' 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /examples/miniapp-tt/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index" 4 | ], 5 | "window":{ 6 | "backgroundTextStyle":"light", 7 | "navigationBarBackgroundColor": "#fff", 8 | "navigationBarTitleText": "Mini Program", 9 | "navigationBarTextStyle":"black" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/miniapp-tt/app.ts: -------------------------------------------------------------------------------- 1 | App({ 2 | onLaunch: function () { 3 | 4 | } 5 | }) 6 | -------------------------------------------------------------------------------- /examples/miniapp-tt/app.ttss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-tt/app.ttss -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-jsencrypt/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/index.js'); -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-jsencrypt/lib/index.js: -------------------------------------------------------------------------------- 1 | import{JSEncrypt}from"./jsencrypt";export function encryptFunction(t,n){const r=new JSEncrypt({});r.setPublicKey(n);return r.encrypt(t).toString()} 2 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-jsencrypt/lib/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"node_modules/@authing/miniapp-jsencrypt/lib/index.js","names":["JSEncrypt","encryptFunction","plainText","publicKey","encrypt","setPublicKey","toString"],"sources":["node_modules/@authing/miniapp-jsencrypt/lib/index.js"],"sourcesContent":["import { JSEncrypt } from './jsencrypt'\n\nexport function encryptFunction (plainText, publicKey) {\n const encrypt = new JSEncrypt({})\n\n encrypt.setPublicKey(publicKey)\n\n const encStr = encrypt.encrypt(plainText)\n\n return encStr.toString()\n}\n"],"mappings":"OAASA,cAAiB,qBAEnB,SAASC,gBAAiBC,EAAWC,GAC1C,MAAMC,EAAU,IAAIJ,UAAU,CAAC,GAE/BI,EAAQC,aAAaF,GAIrB,OAFeC,EAAQA,QAAQF,GAEjBI,UAChB"} -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-jsencrypt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-jsencrypt", 3 | "version": "5.1.16", 4 | "description": "JavaScript encrypt module for miniapp", 5 | "main": "lib/index.js", 6 | "module": "lib/index.js", 7 | "types": "lib/jsencrypt.d.ts", 8 | "files": [ 9 | "lib" 10 | ], 11 | "scripts": { 12 | "release:official": "npm publish --verbose --access public", 13 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 14 | }, 15 | "author": "https://github.com/authing", 16 | "license": "MIT", 17 | "publishConfig": { 18 | "access": "public", 19 | "registry": "https://registry.npmjs.org" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-sm2encrypt/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/index.js'); -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-sm2encrypt/lib/index.js: -------------------------------------------------------------------------------- 1 | import{doEncrypt}from"./sm2";export function encryptFunction(n,r){return doEncrypt(n,r)} 2 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-sm2encrypt/lib/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"node_modules/@authing/miniapp-sm2encrypt/lib/index.js","names":["doEncrypt","encryptFunction","plainText","publicKey"],"sources":["node_modules/@authing/miniapp-sm2encrypt/lib/index.js"],"sourcesContent":["import { doEncrypt } from './sm2'\n\nexport function encryptFunction (plainText, publicKey) {\n return doEncrypt(plainText, publicKey)\n}\n"],"mappings":"OAASA,cAAiB,eAEnB,SAASC,gBAAiBC,EAAWC,GAC1C,OAAOH,UAAUE,EAAWC,EAC9B"} -------------------------------------------------------------------------------- /examples/miniapp-tt/miniprogram_npm/@authing/miniapp-sm2encrypt/lib/sm2.js: -------------------------------------------------------------------------------- 1 | import{BigInteger}from"jsbn";import*as _ from"./utils";import{sm3}from"./sm3";const C1C2C3=0;function doEncrypt(t,e,r=1){t="string"==typeof t?_.hexToArray(_.utf8ToHex(t)):Array.prototype.slice.call(t),e=_.getGlobalCurve().decodePointHex(e);const o=_.generateKeyPairHex(),n=new BigInteger(o.privateKey,16);let a=o.publicKey;a.length>128&&(a=a.substr(a.length-128));const i=e.multiply(n),l=_.hexToArray(_.leftPad(i.getX().toBigInteger().toRadix(16),64)),g=_.hexToArray(_.leftPad(i.getY().toBigInteger().toRadix(16),64)),c=_.arrayToHex(sm3([].concat(l,t,g)));let s=1,y=0,p=[];const m=[].concat(l,g),x=()=>{p=sm3([...m,s>>24&255,s>>16&255,s>>8&255,255&s]),s++,y=0};x();for(let e=0,r=t.length;eloginByCode 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/miniapp-tt/pages/index/index.ttss: -------------------------------------------------------------------------------- 1 | .intro { 2 | margin: 30px; 3 | text-align: center; 4 | } -------------------------------------------------------------------------------- /examples/miniapp-tt/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "setting": { 3 | "urlCheck": true, 4 | "es6": true, 5 | "postcss": true, 6 | "minified": true, 7 | "newFeature": true, 8 | "autoCompile": true, 9 | "compileHotReLoad": true, 10 | "nativeCompile": true, 11 | "useCompilerPlugins": [ 12 | "typescript" 13 | ] 14 | }, 15 | "appid": "ttcad4bc6955e5062401", 16 | "projectname": "miniapp-tt", 17 | "douyinProjectType": "native" 18 | } 19 | -------------------------------------------------------------------------------- /examples/miniapp-tt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | "noImplicitAny": true, 5 | "module": "CommonJS", 6 | "target": "ES2020", 7 | "allowJs": true, 8 | "allowSyntheticDefaultImports": true, 9 | "esModuleInterop": true, 10 | "experimentalDecorators": true, 11 | "noImplicitThis": true, 12 | "noImplicitReturns": true, 13 | "alwaysStrict": true, 14 | "noFallthroughCasesInSwitch": true, 15 | "noUnusedLocals": true, 16 | "noUnusedParameters": true, 17 | "strict": true, 18 | "strictPropertyInitialization": true, 19 | "lib": ["es2020"], 20 | "types": ["@douyin-microapp/typings"] 21 | }, 22 | "include": [ 23 | "./**/*.ts" 24 | ], 25 | "exclude": [ 26 | "node_modules" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | unpackage/ 4 | dist/ 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Editor directories and files 16 | .project 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw* 24 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/README.md: -------------------------------------------------------------------------------- 1 | # miniapp-uniapp 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": [ 4 | "@dcloudio/types", 5 | "miniprogram-api-typings", 6 | "mini-types" 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/postcss.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | module.exports = { 3 | parser: require('postcss-comment'), 4 | plugins: [ 5 | require('postcss-import')({ 6 | resolve (id, basedir, importOptions) { 7 | if (id.startsWith('~@/')) { 8 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3)) 9 | } else if (id.startsWith('@/')) { 10 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2)) 11 | } else if (id.startsWith('/') && !id.startsWith('//')) { 12 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1)) 13 | } 14 | return id 15 | } 16 | }), 17 | require('autoprefixer')({ 18 | remove: process.env.UNI_PLATFORM !== 'h5' 19 | }), 20 | require('@dcloudio/vue-cli-plugin-uni/packages/postcss') 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 14 | 15 | 16 | 17 | 18 | 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/sfc.d.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | declare module "vue/types/options" { 3 | type Hooks = App.AppInstance & Page.PageInstance; 4 | interface ComponentOptions extends Hooks { 5 | /** 6 | * 组件类型 7 | */ 8 | mpType?: string; 9 | } 10 | } -------------------------------------------------------------------------------- /examples/miniapp-uniapp/shime-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.vue" { 2 | import Vue from 'vue' 3 | export default Vue 4 | } -------------------------------------------------------------------------------- /examples/miniapp-uniapp/src/App.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 18 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | 4 | Vue.config.productionTip = false 5 | 6 | App.mpType = 'app' 7 | 8 | const app = new Vue({ 9 | ...App 10 | }) 11 | app.$mount() 12 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/src/pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages 3 | { 4 | "path": "pages/index/index", 5 | "style": { 6 | "navigationBarTitleText": "uni-app" 7 | } 8 | } 9 | ], 10 | "globalStyle": { 11 | "navigationBarTextStyle": "black", 12 | "navigationBarTitleText": "uni-app", 13 | "navigationBarBackgroundColor": "#F8F8F8", 14 | "backgroundColor": "#F8F8F8" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/miniapp-uniapp/src/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-uniapp/src/static/logo.png -------------------------------------------------------------------------------- /examples/miniapp-wx/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Eslint config file 3 | * Documentation: https://eslint.org/docs/user-guide/configuring/ 4 | * Install the Eslint extension before using this feature. 5 | */ 6 | module.exports = { 7 | env: { 8 | es6: true, 9 | browser: true, 10 | node: true, 11 | }, 12 | ecmaFeatures: { 13 | modules: true, 14 | }, 15 | parserOptions: { 16 | ecmaVersion: 2018, 17 | sourceType: 'module', 18 | }, 19 | globals: { 20 | wx: true, 21 | App: true, 22 | Page: true, 23 | getCurrentPages: true, 24 | getApp: true, 25 | Component: true, 26 | requirePlugin: true, 27 | requireMiniProgram: true, 28 | }, 29 | // extends: 'eslint:recommended', 30 | rules: {}, 31 | } 32 | -------------------------------------------------------------------------------- /examples/miniapp-wx/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-wx demo -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/app.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | App({ 3 | onLaunch: function () { 4 | if (!wx.cloud) { 5 | console.error('请使用 2.2.3 或以上的基础库以使用云能力'); 6 | } else { 7 | wx.cloud.init({ 8 | // env 参数说明: 9 | // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 10 | // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 11 | // 如不填则使用默认环境(第一个创建的环境) 12 | // env: 'my-env-id', 13 | traceUser: true, 14 | }); 15 | } 16 | 17 | this.globalData = {}; 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index" 4 | ], 5 | "window": { 6 | "backgroundColor": "#F6F6F6", 7 | "backgroundTextStyle": "light", 8 | "navigationBarBackgroundColor": "#F6F6F6", 9 | "navigationBarTitleText": "Authing miniapp-wx SDK demo", 10 | "navigationBarTextStyle": "black" 11 | }, 12 | "sitemapLocation": "sitemap.json", 13 | "style": "v2" 14 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/app.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-wx/miniapp/app.wxss -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/envList.js: -------------------------------------------------------------------------------- 1 | const envList = [{"envId":"cloud1-5giiuu4617230f2c","alias":"cloud1"}] 2 | const isMac = true 3 | module.exports = { 4 | envList, 5 | isMac 6 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "miniapp", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@authing/miniapp-jsencrypt": "^5.1.8", 13 | "@authing/miniapp-sm2encrypt": "^5.1.8", 14 | "@authing/miniapp-wx": "^5.1.16-alpha.4" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | 4 | } 5 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/pages/index/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/miniapp-wx/miniapp/pages/index/index.wxss -------------------------------------------------------------------------------- /examples/miniapp-wx/miniapp/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniapp/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", 3 | "packOptions": { 4 | "ignore": [], 5 | "include": [] 6 | }, 7 | "miniprogramRoot": "miniapp/", 8 | "compileType": "miniprogram", 9 | "setting": { 10 | "useCompilerPlugins": [ 11 | "typescript" 12 | ], 13 | "urlCheck": true, 14 | "coverView": true, 15 | "es6": true, 16 | "postcss": true, 17 | "lazyloadPlaceholderEnable": false, 18 | "preloadBackgroundData": false, 19 | "minified": true, 20 | "autoAudits": false, 21 | "uglifyFileName": false, 22 | "uploadWithSourceMap": true, 23 | "enhance": true, 24 | "useMultiFrameRuntime": true, 25 | "showShadowRootInWxmlPanel": true, 26 | "packNpmManually": true, 27 | "packNpmRelationList": [ 28 | { 29 | "packageJsonPath": "./miniapp/package.json", 30 | "miniprogramNpmDistDir": "./miniapp" 31 | } 32 | ], 33 | "minifyWXSS": true, 34 | "useStaticServer": true, 35 | "showES6CompileOption": false, 36 | "checkInvalidKey": true, 37 | "babelSetting": { 38 | "ignore": [], 39 | "disablePlugins": [], 40 | "outputPath": "" 41 | }, 42 | "disableUseStrict": false, 43 | "minifyWXML": true 44 | }, 45 | "simulatorType": "wechat", 46 | "simulatorPluginLibVersion": {}, 47 | "condition": {}, 48 | "srcMiniprogramRoot": "miniapp/", 49 | "appid": "wx9d4531dea21e20d5", 50 | "libVersion": "2.25.0", 51 | "editorSetting": { 52 | "tabIndent": "insertSpaces", 53 | "tabSize": 2 54 | } 55 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/project.private.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "setting": { 3 | "compileHotReLoad": true, 4 | "urlCheck": false 5 | }, 6 | "condition": {}, 7 | "projectname": "miniapp-wx", 8 | "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" 9 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions":{ 3 | "strictNullChecks":true, 4 | "noImplicitAny":true, 5 | "module":"CommonJS", 6 | "target":"ES2020", 7 | "allowJs":true, 8 | "allowSyntheticDefaultImports":true, 9 | "esModuleInterop":true, 10 | "experimentalDecorators":true, 11 | "noImplicitThis":true, 12 | "noImplicitReturns":true, 13 | "alwaysStrict":true, 14 | "noFallthroughCasesInSwitch":true, 15 | "noUnusedLocals":true, 16 | "noUnusedParameters":true, 17 | "strict":true, 18 | "strictPropertyInitialization":true, 19 | "lib":["ES2020", "DOM"], 20 | "typeRoots":[ 21 | "./typings" 22 | ] 23 | }, 24 | "include":[ 25 | "./**/*.ts" 26 | ], 27 | "exclude":[ 28 | "node_modules" 29 | ] 30 | } -------------------------------------------------------------------------------- /examples/miniapp-wx/uploadCloudFunction.sh: -------------------------------------------------------------------------------- 1 | "/Applications/wechatwebdevtools.app/Contents/MacOS/cli" cloud functions deploy --e cloud1-5giiuu4617230f2c --n quickstartFunctions --r --project "/Users/zhaoyiming/Desktop/github/authing.js/examples/miniapp-wx" --report_first --report -------------------------------------------------------------------------------- /examples/miniapp-wx/uploadError.txt: -------------------------------------------------------------------------------- 1 | Error: TencentCloud API error: { 2 | "Response": { 3 | "Error": { 4 | "Code": "FailedOperation.UpdateFunctionCode", 5 | "Message": "当前函数处于Creating状态,无法进行此操作,请稍后重试。" 6 | }, 7 | "RequestId": "78083388-a286-4014-b8e4-c1f5f22f6a06" 8 | } 9 | } -------------------------------------------------------------------------------- /examples/web/cdn/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/web/cdn/index.js: -------------------------------------------------------------------------------- 1 | var authing = new AuthingFactory.Authing({ 2 | domain: 'https://mlbkhepjgjiihaap.authing.cn', 3 | appId: '6322c6a6c8f7e51c04309097', 4 | redirectUri: 'http://localhost:8000', 5 | userPoolId: '62e221f85f5ac5cc47037a39' 6 | }) 7 | 8 | if (authing.isRedirectCallback()) { 9 | console.log('redirect') 10 | authing.handleRedirectCallback().then((loginState) => { 11 | console.log('loginState: ', loginState) 12 | window.location.replace('/') 13 | }) 14 | } else { 15 | authing.getLoginState().then(loginState => { 16 | console.log('loginState: ', loginState) 17 | }) 18 | } 19 | 20 | var loginWithPopup = document.querySelector('#loginWithPopup') 21 | var loginWithRedirect = document.querySelector('#loginWithRedirect') 22 | var logoutWithRedirect = document.querySelector('#logoutWithRedirect') 23 | var getUserInfo = document.querySelector('#getUserInfo') 24 | 25 | loginWithPopup.onclick = function () { 26 | authing.loginWithPopup().then(loginState => { 27 | console.log('loginState: ', loginState) 28 | }) 29 | } 30 | 31 | loginWithRedirect.onclick = function () { 32 | authing.loginWithRedirect() 33 | } 34 | 35 | logoutWithRedirect.onclick = function () { 36 | authing.logoutWithRedirect({ 37 | redirectUri: 'https://www.baidu.com' 38 | }) 39 | } 40 | 41 | getUserInfo.onclick = function () { 42 | authing.getUserInfo().then(userInfo => { 43 | console.log('userInfo: ', userInfo) 44 | }) 45 | } 46 | -------------------------------------------------------------------------------- /examples/web/cdn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "NODE_ENV=dev webpack-dev-server --progress --color --config webpack.config.js" 8 | }, 9 | "author": "https://github.com/authing", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/react": "^16.9.32", 13 | "@types/react-dom": "^16.9.6", 14 | "@types/react-router": "^5.1.18", 15 | "@types/react-router-dom": "^5.1.3", 16 | "css-loader": "^2.1.1", 17 | "html-webpack-plugin": "^3.2.0", 18 | "style-loader": "^0.23.1", 19 | "ts-loader": "^8.4.0", 20 | "typescript": "^4.7.4", 21 | "webpack": "^4.30.0", 22 | "webpack-cli": "^3.3.1", 23 | "webpack-dev-server": "^3.10.3", 24 | "webpack-merge": "^4.2.1" 25 | }, 26 | "dependencies": { 27 | "@authing/guard-react": "^5.0.3", 28 | "react": "^16.13.1", 29 | "react-dom": "^16.13.1", 30 | "react-router": "^5.1.2", 31 | "react-router-dom": "^5.1.2" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/web/cdn/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | 4 | function resolve(dir, file = '') { 5 | return path.resolve(__dirname, './', dir, file); 6 | } 7 | 8 | module.exports = { 9 | mode: 'none', 10 | entry: resolve('index.js'), 11 | output: { 12 | filename: 'bundle.js', 13 | path: resolve('dist'), 14 | }, 15 | resolve: { 16 | extensions: ['.js'], 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.css$/, 22 | use: ['style-loader', 'css-loader'], 23 | }, 24 | ], 25 | }, 26 | plugins: [ 27 | new HtmlWebpackPlugin({ 28 | template: resolve('./index.html'), 29 | filename: 'index.html', 30 | env: process.env.NODE_ENV, 31 | minify: { 32 | removeComments: true, 33 | collapseWhitespace: true, 34 | removeRedundantAttributes: true, 35 | useShortDoctype: true, 36 | removeEmptyAttributes: true, 37 | removeStyleLinkTypeAttributes: true, 38 | keepClosingSlash: true, 39 | minifyCSS: true, 40 | minifyJS: true, 41 | minifyURLs: true, 42 | }, 43 | }), 44 | ], 45 | devServer: { 46 | host: 'localhost', 47 | inline: false, // 启用热更新 48 | port: 8000, 49 | progress: true, 50 | contentBase: resolve('./'), 51 | compress: true, 52 | disableHostCheck: true, 53 | historyApiFallback: true, 54 | hot: true, 55 | open: true, 56 | openPage: '../', 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /examples/web/spa/angular/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /examples/web/spa/angular/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /examples/web/spa/angular/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/spa/angular/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /examples/web/spa/angular/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /examples/web/spa/angular/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/spa/angular/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spa-demo-angular", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve --port 3000 --ssl", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "^14.0.0", 13 | "@angular/common": "^14.0.0", 14 | "@angular/compiler": "^14.0.0", 15 | "@angular/core": "^14.0.0", 16 | "@angular/forms": "^14.0.0", 17 | "@angular/platform-browser": "^14.0.0", 18 | "@angular/platform-browser-dynamic": "^14.0.0", 19 | "@angular/router": "^14.0.0", 20 | "@authing/web": "^5.0.2-alpha.12", 21 | "rxjs": "~7.5.0", 22 | "tslib": "^2.3.0", 23 | "zone.js": "~0.11.4" 24 | }, 25 | "devDependencies": { 26 | "@angular-devkit/build-angular": "^14.0.6", 27 | "@angular/cli": "~14.0.6", 28 | "@angular/compiler-cli": "^14.0.0", 29 | "typescript": "~4.7.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Angular 快速集成 Authing Demo

3 |

4 | 5 | 6 | 7 | 8 | 9 |

10 |

11 | 12 |

13 |

14 | 15 |

16 |

17 | 18 |

19 |
20 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | 6 | @NgModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | imports: [ 11 | BrowserModule 12 | ], 13 | providers: [], 14 | bootstrap: [AppComponent] 15 | }) 16 | export class AppModule { } 17 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/angular/src/assets/.gitkeep -------------------------------------------------------------------------------- /examples/web/spa/angular/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/angular/src/favicon.ico -------------------------------------------------------------------------------- /examples/web/spa/angular/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SpaDemoAngular 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /examples/web/spa/angular/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | body { 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | color: #2c3e50; 9 | } 10 | 11 | p button { 12 | margin-right: 8px; 13 | } 14 | -------------------------------------------------------------------------------- /examples/web/spa/angular/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/web/spa/angular/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2020", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/web/spa/react/.env: -------------------------------------------------------------------------------- 1 | PORT = 3000 2 | HTTPS = true 3 | 4 | # 应用 ID 5 | REACT_APP_SDK_APPID = 应用 ID 6 | 7 | # 应用的认证地址 8 | REACT_APP_SDK_DOMAIN = 应用的认证地址 9 | 10 | # 登录回调地址 11 | REACT_APP_SDK_REDIRECT_URI = 登录回调地址 12 | 13 | # 应用侧向 Authing 请求的权限,以空格分隔,默认为 'openid profile' 14 | # 成功获取的权限会出现在 Access Token 的 scope 字段中 15 | REACT_APP_SDK_SCOPE = openid profile order:read 16 | 17 | # 用于验证 Access Token 是否有权限访问的 API。 18 | # 例如: http://localhost:5000/api/protected 19 | REACT_APP_RESOURCE_API = http://localhost:5000/api/protected 20 | 21 | # 用户池 ID 22 | USER_POOL_ID = 用户池 ID 23 | -------------------------------------------------------------------------------- /examples/web/spa/react/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/web/spa/react/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": false 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/spa/react/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/spa/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spa-demo-react", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@authing/web": "^5.0.2-alpha.12", 7 | "@types/node": "^16.7.13", 8 | "@types/react": "^18.0.0", 9 | "@types/react-dom": "^18.0.0", 10 | "react": "^18.2.0", 11 | "react-dom": "^18.2.0", 12 | "react-scripts": "5.0.1", 13 | "typescript": "^4.4.2" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app" 23 | ] 24 | }, 25 | "browserslist": { 26 | "production": [ 27 | ">0.2%", 28 | "not dead", 29 | "not op_mini all" 30 | ], 31 | "development": [ 32 | "last 1 chrome version", 33 | "last 1 firefox version", 34 | "last 1 safari version" 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/web/spa/react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/react/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/spa/react/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/react/public/logo192.png -------------------------------------------------------------------------------- /examples/web/spa/react/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/react/public/logo512.png -------------------------------------------------------------------------------- /examples/web/spa/react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/web/spa/react/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/web/spa/react/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 3 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 4 | sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | color: #2c3e50; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | p button { 16 | margin-right: 8px; 17 | } 18 | -------------------------------------------------------------------------------- /examples/web/spa/react/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | const root = ReactDOM.createRoot( 7 | document.getElementById('root') as HTMLElement 8 | ); 9 | root.render(); 10 | -------------------------------------------------------------------------------- /examples/web/spa/react/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/web/spa/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/.env: -------------------------------------------------------------------------------- 1 | # 应用 ID 2 | VUE_APP_SDK_APPID = 应用 ID 3 | 4 | # 应用的认证地址 5 | VUE_APP_SDK_DOMAIN = 应用的认证地址 6 | 7 | # 登录回调地址 8 | VUE_APP_SDK_REDIRECT_URI = 登录回调地址 9 | 10 | # 应用侧向 Authing 请求的权限,以空格分隔,默认为 'openid profile' 11 | # 成功获取的权限会出现在 Access Token 的 scope 字段中 12 | VUE_APP_SDK_SCOPE = openid profile order:read 13 | 14 | # 用于验证 Access Token 是否有权限访问的 API。 15 | # 例如: http://localhost:5000/api/protected 16 | VUE_APP_RESOURCE_API = 资源接口地址 17 | 18 | # 用户池 ID 19 | USER_POOL_ID = 用户池 ID 20 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"], 7 | parserOptions: { 8 | parser: "babel-eslint", 9 | }, 10 | rules: { 11 | "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", 12 | "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": false 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"], 3 | }; 4 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spa-demo-vue2", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.0.2-alpha.12", 12 | "core-js": "^3.6.5", 13 | "vue": "^2.6.11" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/eslint-config-prettier": "^6.0.0", 20 | "babel-eslint": "^10.1.0", 21 | "eslint": "^6.7.2", 22 | "eslint-plugin-prettier": "^3.3.1", 23 | "eslint-plugin-vue": "^6.2.2", 24 | "prettier": "^2.2.1", 25 | "vue-template-compiler": "^2.6.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/vue/vue2/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Vue 2.x 快速集成 Authing 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | 4 | Vue.config.productionTip = false; 5 | 6 | new Vue({ 7 | render: (h) => h(App), 8 | }).$mount("#app"); 9 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue2/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 3000, 4 | https: true 5 | } 6 | } -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/.env: -------------------------------------------------------------------------------- 1 | # 应用 ID 2 | VUE_APP_SDK_APPID = 应用 ID 3 | 4 | # 应用的认证地址 5 | VUE_APP_SDK_DOMAIN = 应用的认证地址 6 | 7 | # 登录回调地址 8 | VUE_APP_SDK_REDIRECT_URI = 登录回调地址 9 | 10 | # 应用侧向 Authing 请求的权限,以空格分隔,默认为 'openid profile' 11 | # 成功获取的权限会出现在 Access Token 的 scope 字段中 12 | VUE_APP_SDK_SCOPE = openid profile order:read 13 | 14 | # 用于验证 Access Token 是否有权限访问的 API。 15 | # 例如: http://localhost:5000/api/protected 16 | VUE_APP_RESOURCE_API = http://localhost:5000/api/protected 17 | 18 | # 用户池 ID 19 | USER_POOL_ID = 用户池 ID -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"], 7 | parserOptions: { 8 | parser: "babel-eslint", 9 | }, 10 | rules: { 11 | // "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", 12 | "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": false 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"], 3 | }; 4 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue3", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.0.2-alpha.12", 12 | "core-js": "^3.6.5", 13 | "vue": "^3.0.0" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/compiler-sfc": "^3.0.0", 20 | "@vue/eslint-config-prettier": "^6.0.0", 21 | "babel-eslint": "^10.1.0", 22 | "eslint": "^6.7.2", 23 | "eslint-plugin-prettier": "^3.3.1", 24 | "eslint-plugin-vue": "^7.0.0", 25 | "prettier": "^2.2.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/spa/vue/vue3/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Vue 3.x 快速集成 Authing 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from "vue"; 2 | import App from "./App.vue"; 3 | 4 | createApp(App).mount("#app"); 5 | -------------------------------------------------------------------------------- /examples/web/spa/vue/vue3/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 3000, 4 | https: true, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /examples/web/sso/angular/README.md: -------------------------------------------------------------------------------- 1 | # authing/web demo for Angular 2 | 3 | 4 | 1. 进入 `website1` 和 `website2` 目录,分别运行以下命令: 5 | 6 | ``` shell 7 | npm ci 8 | npm run dev 9 | ``` 10 | 11 | 2. 分别修改 `website1` 和 `website2` 中的 `app.component.ts` 中实例化 SDK 的配置: 12 | 13 | ``` typescript 14 | private authing = new Authing({ 15 | // 控制台 -> 应用 -> 单点登录 SSO -> 配置 -> 应用面板地址,如:https://my-awesome-sso.authing.cn 16 | domain: 'AUTHING_DOMAIN_URL', 17 | 18 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 端点信息 -> APP ID 19 | appId: 'AUTHING_APP_ID', 20 | 21 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 认证配置 -> 登录回调 URL 22 | redirectUri: 'YOUR_REDIRECT_URL', 23 | 24 | // 控制台 -> 设置 -> 基础设置 -> 基础信息 -> 用户池 ID 25 | userPoolId: 'AUTHING_USER_POOL_ID' 26 | }) 27 | ``` -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-app-panel-address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-app-panel-address.png -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-appid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-appid.png -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-authorization-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-authorization-configuration.png -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-callback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-callback.png -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-create-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-create-app.png -------------------------------------------------------------------------------- /examples/web/sso/angular/doc-assets/sso-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/doc-assets/sso-panel.png -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](./README.md)、[website2](../website2/README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website1`,并将创建好的名为 `website1` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website1` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website1` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8000` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `./src/app/app.component.ts` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8000` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 服务启动后,浏览器打开 https://localhost:8000 即可 37 | 38 | ## 开发教程 39 | 40 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 41 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/website1'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website1", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "dev": "ng serve --port 8000 --ssl", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "^14.0.0", 14 | "@angular/common": "^14.0.0", 15 | "@angular/compiler": "^14.0.0", 16 | "@angular/core": "^14.0.0", 17 | "@angular/forms": "^14.0.0", 18 | "@angular/platform-browser": "^14.0.0", 19 | "@angular/platform-browser-dynamic": "^14.0.0", 20 | "@angular/router": "^14.0.0", 21 | "@authing/web": "^5.1.8", 22 | "rxjs": "~7.5.0", 23 | "tslib": "^2.3.0", 24 | "zone.js": "~0.11.4" 25 | }, 26 | "devDependencies": { 27 | "@angular-devkit/build-angular": "^14.0.6", 28 | "@angular/cli": "~14.0.6", 29 | "@angular/compiler-cli": "^14.0.0", 30 | "@types/jasmine": "~4.0.0", 31 | "jasmine-core": "~4.1.0", 32 | "karma": "~6.3.0", 33 | "karma-chrome-launcher": "~3.1.0", 34 | "karma-coverage": "~2.2.0", 35 | "karma-jasmine": "~5.0.0", 36 | "karma-jasmine-html-reporter": "~1.7.0", 37 | "typescript": "~4.7.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website1/src/app/app.component.css -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |

{{ title }}

3 |

4 | 5 | redirect to website2 6 | 7 |

8 |

9 | 10 | 11 |

12 |

13 | 14 |

15 |

16 | 17 |

18 |

19 | 20 |

21 |

22 | 23 |

24 |
25 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'website1'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.componentInstance; 22 | expect(app.title).toEqual('website1'); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('.content span')?.textContent).toContain('website1 app is running!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | 6 | @NgModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | imports: [ 11 | BrowserModule 12 | ], 13 | providers: [], 14 | bootstrap: [AppComponent] 15 | }) 16 | export class AppModule { } 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website1/src/assets/.gitkeep -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website1/src/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Website1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().forEach(context); 27 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2020", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website1/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](../website1/README.md)、[website2](./README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website2`,并将创建好的名为 `website2` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website2` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website2` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8001` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `./src/app/app.component.ts` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8001` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 37 | ## 开发教程 38 | 39 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 40 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/website2'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website2", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "dev": "ng serve --port 8001 --ssl", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "^14.0.0", 14 | "@angular/common": "^14.0.0", 15 | "@angular/compiler": "^14.0.0", 16 | "@angular/core": "^14.0.0", 17 | "@angular/forms": "^14.0.0", 18 | "@angular/platform-browser": "^14.0.0", 19 | "@angular/platform-browser-dynamic": "^14.0.0", 20 | "@angular/router": "^14.0.0", 21 | "@authing/web": "^5.1.8", 22 | "rxjs": "~7.5.0", 23 | "tslib": "^2.3.0", 24 | "zone.js": "~0.11.4" 25 | }, 26 | "devDependencies": { 27 | "@angular-devkit/build-angular": "^14.0.6", 28 | "@angular/cli": "~14.0.6", 29 | "@angular/compiler-cli": "^14.0.0", 30 | "@types/jasmine": "~4.0.0", 31 | "jasmine-core": "~4.1.0", 32 | "karma": "~6.3.0", 33 | "karma-chrome-launcher": "~3.1.0", 34 | "karma-coverage": "~2.2.0", 35 | "karma-jasmine": "~5.0.0", 36 | "karma-jasmine-html-reporter": "~1.7.0", 37 | "typescript": "~4.7.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website2/src/app/app.component.css -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Website 2

3 |
4 |

5 | Access Token:
6 | 9 |

10 |

11 | Access Token Info:
12 | 15 |

16 |

17 | Expire At: {{ loginState?.expireAt }} 18 |

19 |
20 | 21 |

22 | userInfo: 23 |

24 |
25 | 26 |
27 |
28 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'website2'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.componentInstance; 22 | expect(app.title).toEqual('website2'); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('.content span')?.textContent).toContain('website2 app is running!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | 6 | @NgModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | imports: [ 11 | BrowserModule 12 | ], 13 | providers: [], 14 | bootstrap: [AppComponent] 15 | }) 16 | export class AppModule { } 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website2/src/assets/.gitkeep -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/angular/website2/src/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Website2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().forEach(context); 27 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2020", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/web/sso/angular/website2/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/README.md: -------------------------------------------------------------------------------- 1 | # authing/web demo for CDN 2 | 3 | 1. 进入 `website1` 和 `website2` 目录,分别运行以下命令: 4 | 5 | ``` shell 6 | npm ci 7 | npm run dev 8 | ``` 9 | 10 | 2. 分别修改 `website1` 和 `website2` 中的 `index.js` 中实例化 SDK 的配置: 11 | 12 | ``` javascript 13 | var authing = new AuthingFactory.Authing({ 14 | // 控制台 -> 应用 -> 单点登录 SSO -> 配置 -> 应用面板地址,如:https://my-awesome-sso.authing.cn 15 | domain: 'AUTHING_DOMAIN_URL', 16 | 17 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 端点信息 -> APP ID 18 | appId: 'AUTHING_APP_ID', 19 | 20 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 认证配置 -> 登录回调 URL 21 | redirectUri: 'YOUR_REDIRECT_URL', 22 | 23 | // 控制台 -> 设置 -> 基础设置 -> 基础信息 -> 用户池 ID 24 | userPoolId: 'AUTHING_USER_POOL_ID' 25 | }) 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | website1 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "NODE_ENV=dev webpack-dev-server --progress --color --config webpack.config.js" 8 | }, 9 | "author": "https://github.com/authing", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/react": "^16.9.32", 13 | "@types/react-dom": "^16.9.6", 14 | "@types/react-router": "^5.1.18", 15 | "@types/react-router-dom": "^5.1.3", 16 | "css-loader": "^2.1.1", 17 | "html-webpack-plugin": "^3.2.0", 18 | "style-loader": "^0.23.1", 19 | "ts-loader": "^8.4.0", 20 | "typescript": "^4.7.4", 21 | "webpack": "^4.30.0", 22 | "webpack-cli": "^3.3.1", 23 | "webpack-dev-server": "^3.10.3", 24 | "webpack-merge": "^4.2.1" 25 | }, 26 | "dependencies": { 27 | "@authing/guard-react": "^5.0.3", 28 | "@authing/web": "^5.1.8", 29 | "react": "^16.13.1", 30 | "react-dom": "^16.13.1", 31 | "react-router": "^5.1.2", 32 | "react-router-dom": "^5.1.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website1/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | 4 | function resolve(dir, file = '') { 5 | return path.resolve(__dirname, './', dir, file); 6 | } 7 | 8 | module.exports = { 9 | mode: 'none', 10 | entry: resolve('index.js'), 11 | output: { 12 | filename: 'bundle.js', 13 | path: resolve('dist'), 14 | }, 15 | resolve: { 16 | extensions: ['.js'], 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.css$/, 22 | use: ['style-loader', 'css-loader'], 23 | }, 24 | ], 25 | }, 26 | plugins: [ 27 | new HtmlWebpackPlugin({ 28 | template: resolve('./index.html'), 29 | filename: 'index.html', 30 | env: process.env.NODE_ENV, 31 | minify: { 32 | removeComments: true, 33 | collapseWhitespace: true, 34 | removeRedundantAttributes: true, 35 | useShortDoctype: true, 36 | removeEmptyAttributes: true, 37 | removeStyleLinkTypeAttributes: true, 38 | keepClosingSlash: true, 39 | minifyCSS: true, 40 | minifyJS: true, 41 | minifyURLs: true, 42 | }, 43 | }), 44 | ], 45 | devServer: { 46 | host: 'localhost', 47 | inline: false, // 启用热更新 48 | port: 8000, 49 | progress: true, 50 | contentBase: resolve('./'), 51 | compress: true, 52 | disableHostCheck: true, 53 | historyApiFallback: true, 54 | hot: true, 55 | open: true, 56 | openPage: '../', 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | website2 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "NODE_ENV=dev webpack-dev-server --progress --color --config webpack.config.js" 8 | }, 9 | "author": "https://github.com/authing", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/react": "^16.9.32", 13 | "@types/react-dom": "^16.9.6", 14 | "@types/react-router": "^5.1.18", 15 | "@types/react-router-dom": "^5.1.3", 16 | "css-loader": "^2.1.1", 17 | "html-webpack-plugin": "^3.2.0", 18 | "style-loader": "^0.23.1", 19 | "ts-loader": "^8.4.0", 20 | "typescript": "^4.7.4", 21 | "webpack": "^4.30.0", 22 | "webpack-cli": "^3.3.1", 23 | "webpack-dev-server": "^3.10.3", 24 | "webpack-merge": "^4.2.1" 25 | }, 26 | "dependencies": { 27 | "@authing/guard-react": "^5.0.3", 28 | "@authing/web": "^5.1.8", 29 | "react": "^16.13.1", 30 | "react-dom": "^16.13.1", 31 | "react-router": "^5.1.2", 32 | "react-router-dom": "^5.1.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/web/sso/cdn/website2/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | 4 | function resolve(dir, file = '') { 5 | return path.resolve(__dirname, './', dir, file); 6 | } 7 | 8 | module.exports = { 9 | mode: 'none', 10 | entry: resolve('index.js'), 11 | output: { 12 | filename: 'bundle.js', 13 | path: resolve('dist'), 14 | }, 15 | resolve: { 16 | extensions: ['.js'], 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.css$/, 22 | use: ['style-loader', 'css-loader'], 23 | }, 24 | ], 25 | }, 26 | plugins: [ 27 | new HtmlWebpackPlugin({ 28 | template: resolve('./index.html'), 29 | filename: 'index.html', 30 | env: process.env.NODE_ENV, 31 | minify: { 32 | removeComments: true, 33 | collapseWhitespace: true, 34 | removeRedundantAttributes: true, 35 | useShortDoctype: true, 36 | removeEmptyAttributes: true, 37 | removeStyleLinkTypeAttributes: true, 38 | keepClosingSlash: true, 39 | minifyCSS: true, 40 | minifyJS: true, 41 | minifyURLs: true, 42 | }, 43 | }), 44 | ], 45 | devServer: { 46 | host: 'localhost', 47 | inline: false, // 启用热更新 48 | port: 8001, 49 | progress: true, 50 | contentBase: resolve('./'), 51 | compress: true, 52 | disableHostCheck: true, 53 | historyApiFallback: true, 54 | hot: true, 55 | open: true, 56 | openPage: '../', 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /examples/web/sso/react/README.md: -------------------------------------------------------------------------------- 1 | # authing/web demo for React 2 | 3 | 1. 进入 `website1` 和 `website2` 目录,分别运行以下命令: 4 | 5 | ``` shell 6 | npm ci 7 | npm run dev 8 | ``` 9 | 10 | 2. 分别修改 `website1` 和 `website2` 中的 `App.tsx` 中实例化 SDK 的配置: 11 | 12 | ``` typescript 13 | const authing = useMemo(() => { 14 | return new Authing({ 15 | // 控制台 -> 应用 -> 单点登录 SSO -> 配置 -> 应用面板地址,如:https://my-awesome-sso.authing.cn 16 | domain: 'AUTHING_DOMAIN_URL', 17 | 18 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 端点信息 -> APP ID 19 | appId: 'AUTHING_APP_ID', 20 | 21 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 认证配置 -> 登录回调 URL 22 | redirectUri: 'YOUR_REDIRECT_URL', 23 | 24 | // 控制台 -> 设置 -> 基础设置 -> 基础信息 -> 用户池 ID 25 | userPoolId: 'AUTHING_USER_POOL_ID' 26 | }) 27 | }, []) 28 | ``` 29 | -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-app-panel-address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-app-panel-address.png -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-appid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-appid.png -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-authorization-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-authorization-configuration.png -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-callback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-callback.png -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-create-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-create-app.png -------------------------------------------------------------------------------- /examples/web/sso/react/doc-assets/sso-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/doc-assets/sso-panel.png -------------------------------------------------------------------------------- /examples/web/sso/react/website1/.env: -------------------------------------------------------------------------------- 1 | PORT = 8000 2 | HTTPS = true 3 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](./README.md)、[website2](../website2/README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website1`,并将创建好的名为 `website1` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website1` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website1` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8000` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `App.tsx` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8000` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 服务启动后,浏览器打开 https://localhost:8000 即可 37 | 38 | 39 | ## 开发教程 40 | 41 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 42 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website1", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@authing/web": "^5.1.8", 7 | "@types/node": "^16.7.13", 8 | "@types/react": "^18.0.0", 9 | "@types/react-dom": "^18.0.0", 10 | "react": "^18.2.0", 11 | "react-dom": "^18.2.0", 12 | "react-scripts": "5.0.1", 13 | "typescript": "^4.4.2" 14 | }, 15 | "scripts": { 16 | "dev": "react-scripts start" 17 | }, 18 | "eslintConfig": { 19 | "extends": [ 20 | "react-app" 21 | ] 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website1/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/react/website1/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website1/public/logo192.png -------------------------------------------------------------------------------- /examples/web/sso/react/website1/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website1/public/logo512.png -------------------------------------------------------------------------------- /examples/web/sso/react/website1/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import ReactDOM from 'react-dom/client' 4 | 5 | import App from './App' 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement) 8 | 9 | root.render() 10 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/web/sso/react/website1/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/.env: -------------------------------------------------------------------------------- 1 | PORT = 8001 2 | HTTPS = true -------------------------------------------------------------------------------- /examples/web/sso/react/website2/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](../website1/README.md)、[website2](./README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website2`,并将创建好的名为 `website2` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website2` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website2` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8001` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `App.tsx` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8001` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | ## 开发教程 37 | 38 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 39 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website2", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@authing/web": "^5.1.8", 7 | "@types/node": "^16.7.13", 8 | "@types/react": "^18.0.0", 9 | "@types/react-dom": "^18.0.0", 10 | "react": "^18.2.0", 11 | "react-dom": "^18.2.0", 12 | "react-scripts": "5.0.1", 13 | "typescript": "^4.4.2" 14 | }, 15 | "scripts": { 16 | "dev": "react-scripts start" 17 | }, 18 | "eslintConfig": { 19 | "extends": [ 20 | "react-app" 21 | ] 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website2/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/react/website2/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website2/public/logo192.png -------------------------------------------------------------------------------- /examples/web/sso/react/website2/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/react/website2/public/logo512.png -------------------------------------------------------------------------------- /examples/web/sso/react/website2/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import App from './App'; 4 | 5 | const root = ReactDOM.createRoot( 6 | document.getElementById('root') as HTMLElement 7 | ); 8 | root.render(); 9 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/web/sso/react/website2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/README.md: -------------------------------------------------------------------------------- 1 | # authing/web demo for Vue2 2 | 3 | 1. 进入 `website1` 和 `website2` 目录,分别运行以下命令: 4 | 5 | ``` shell 6 | npm ci 7 | npm run dev 8 | ``` 9 | 10 | 2. 分别修改 `website1` 和 `website2` 中的 `App.vue` 中实例化 SDK 的配置: 11 | 12 | ``` javascript 13 | this.authing = new Authing({ 14 | // 控制台 -> 应用 -> 单点登录 SSO -> 配置 -> 应用面板地址,如:https://my-awesome-sso.authing.cn 15 | domain: 'AUTHING_DOMAIN_URL', 16 | 17 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 端点信息 -> APP ID 18 | appId: 'AUTHING_APP_ID', 19 | 20 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 认证配置 -> 登录回调 URL 21 | redirectUri: 'YOUR_REDIRECT_URL', 22 | 23 | // 控制台 -> 设置 -> 基础设置 -> 基础信息 -> 用户池 ID 24 | userPoolId: 'AUTHING_USER_POOL_ID' 25 | }) 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-app-panel-address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-app-panel-address.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-appid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-appid.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-authorization-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-authorization-configuration.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-callback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-callback.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-create-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-create-app.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/doc-assets/sso-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/doc-assets/sso-panel.png -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'], 7 | parserOptions: { 8 | parser: 'babel-eslint' 9 | }, 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](./README.md)、[website2](../website2/README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website1`,并将创建好的名为 `website1` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website1` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website1` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8000` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `src/App.vue` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8000` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 服务启动后,浏览器打开 https://localhost:8000 即可 37 | 38 | ## 开发教程 39 | 40 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 41 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'] 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website1", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.1.8", 12 | "core-js": "^3.6.5", 13 | "vue": "^2.6.11" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/eslint-config-prettier": "^6.0.0", 20 | "babel-eslint": "^10.1.0", 21 | "eslint": "^6.7.2", 22 | "eslint-plugin-prettier": "^3.3.1", 23 | "eslint-plugin-vue": "^6.2.2", 24 | "prettier": "^2.2.1", 25 | "vue-template-compiler": "^2.6.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/website1/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | website1 - authing-sso-demo-vue2 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App) 8 | }).$mount('#app') 9 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website1/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8000, 4 | https: true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'], 7 | parserOptions: { 8 | parser: 'babel-eslint' 9 | }, 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](../website1/README.md)、[website2](./README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website2`,并将创建好的名为 `website2` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website2` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website2` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8001` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `src/App.vue` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8001` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 37 | ## 开发教程 38 | 39 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 40 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'] 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website2", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.1.8", 12 | "core-js": "^3.6.5", 13 | "vue": "^2.6.11" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/eslint-config-prettier": "^6.0.0", 20 | "babel-eslint": "^10.1.0", 21 | "eslint": "^6.7.2", 22 | "eslint-plugin-prettier": "^3.3.1", 23 | "eslint-plugin-vue": "^6.2.2", 24 | "prettier": "^2.2.1", 25 | "vue-template-compiler": "^2.6.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue2/website2/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | website2 - authing-sso-demo-vue2 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App) 8 | }).$mount('#app') 9 | -------------------------------------------------------------------------------- /examples/web/sso/vue2/website2/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8001, 4 | https: true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/README.md: -------------------------------------------------------------------------------- 1 | # authing/web demo for Vue3 2 | 3 | 1. 进入 `website1` 和 `website2` 目录,分别运行以下命令: 4 | 5 | ``` shell 6 | npm ci 7 | npm run dev 8 | ``` 9 | 10 | 2. 分别修改 `website1` 和 `website2` 中的 `App.vue` 中实例化 SDK 的配置: 11 | 12 | ``` typescript 13 | setup () { 14 | const authing = new Authing({ 15 | // 控制台 -> 应用 -> 单点登录 SSO -> 配置 -> 应用面板地址,如:https://my-awesome-sso.authing.cn 16 | domain: 'AUTHING_DOMAIN_URL', 17 | 18 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 端点信息 -> APP ID 19 | appId: 'AUTHING_APP_ID', 20 | 21 | // 控制台 -> 自建应用 -> 点击进入相应的应用 -> 认证配置 -> 登录回调 URL 22 | redirectUri: 'YOUR_REDIRECT_URL', 23 | 24 | // 控制台 -> 设置 -> 基础设置 -> 基础信息 -> 用户池 ID 25 | userPoolId: 'AUTHING_USER_POOL_ID' 26 | }) 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-app-panel-address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-app-panel-address.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-appid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-appid.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-authorization-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-authorization-configuration.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-callback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-callback.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-create-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-create-app.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/doc-assets/sso-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/doc-assets/sso-panel.png -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'], 7 | parserOptions: { 8 | parser: 'babel-eslint' 9 | }, 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](./README.md)、[website2](../website2/README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website1`,并将创建好的名为 `website1` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website1` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website1` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8000` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `src/App.vue` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8000` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | 服务启动后,浏览器打开 https://localhost:8000 即可 37 | 38 | ## 开发教程 39 | 40 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 41 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'] 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website1", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.1.8", 12 | "core-js": "^3.6.5", 13 | "vue": "^3.0.0" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/compiler-sfc": "^3.0.0", 20 | "@vue/eslint-config-prettier": "^6.0.0", 21 | "babel-eslint": "^10.1.0", 22 | "eslint": "^6.7.2", 23 | "eslint-plugin-prettier": "^3.3.1", 24 | "eslint-plugin-vue": "^7.0.0", 25 | "prettier": "^2.2.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/website1/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website1/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8000, 4 | https: true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'], 7 | parserOptions: { 8 | parser: 'babel-eslint' 9 | }, 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/README.md: -------------------------------------------------------------------------------- 1 | ## 目标效果 2 | 3 | 按照 [website1](../website1/README.md)、[website2](./README.md) 的引导,将两个项目都启动起来 4 | 5 | 在 website1 启动,正常登录之后,通过 website1 里的链接直接跳转到 website2,就可以发现,website2 可以直接取到用户信息了。 6 | 7 | ## 确认配置信息 8 | 9 | 首先需要在 Authing 控制台创建`自建应用`,假定叫 `website2`,并将创建好的名为 `website2` 的应用加入到`单点登录`面板,最后需要确认这几个信息: 10 | 11 | - 应用 `website2` 的 `App ID` 12 | - 单点登录的`应用面板地址`,需要在控制台『单点登录 - 配置』中获取 13 | - 登录回调地址,需要在控制台『自建应用 - `website2` 应用配置 - 登录回调 URL』中指定为 `https://localhost:8001` 14 | - **授权配置**:`授权模式`开启 `authorization_code`、`refresh_token` 15 | - **授权配置**:`返回类型`开启 `code` 16 | 17 | ## 更新 Demo 配置 18 | 19 | 接着需要更新 `src/App.vue` 里的配置信息为你自己建立的应用信息: 20 | 21 | - appId:上一步获取到的`App ID` 22 | - domain:上一步获取到的`应用面板地址` 23 | - redirectUri:上一步确认的 `https://localhost:8001` 24 | 25 | ## 运行此程序 26 | 27 | ``` shell 28 | 29 | # 安装依赖 30 | npm ci 31 | 32 | # 启动服务 33 | npm run dev 34 | ``` 35 | 36 | ## 开发教程 37 | 38 | 开发教程请参考:[使用 Authing 实现单点登录](https://docs.authing.cn/v3/reference/sdk/web/quick.html)。 39 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'] 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website2", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@authing/web": "^5.1.8", 12 | "core-js": "^3.6.5", 13 | "vue": "^3.0.0" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.15", 17 | "@vue/cli-plugin-eslint": "~4.5.15", 18 | "@vue/cli-service": "~4.5.15", 19 | "@vue/compiler-sfc": "^3.0.0", 20 | "@vue/eslint-config-prettier": "^6.0.0", 21 | "babel-eslint": "^10.1.0", 22 | "eslint": "^6.7.2", 23 | "eslint-plugin-prettier": "^3.3.1", 24 | "eslint-plugin-vue": "^7.0.0", 25 | "prettier": "^2.2.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/examples/web/sso/vue3/website2/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /examples/web/sso/vue3/website2/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8001, 4 | https: true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/weixin-official-account/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/weixin-official-account/index.js: -------------------------------------------------------------------------------- 1 | import { AuthingWxmp } from '@authing/weixin-official-account' 2 | 3 | 4 | const authingWx = new AuthingWxmp({ 5 | // 此社会化身份源的唯一标志,你在 Authing 控制台创建微信身份源的时候填写的 6 | identifier: "AUTHING_IDENTIFIER", 7 | 8 | appId: "AUTHING_APP_ID", 9 | 10 | // Authing 控制台 -> 选择已创建的小程序应用 -> 应用配置 -> -> 认证配置 -> 认证地址 11 | host: "https://my-awesome-app.authing.cn", 12 | 13 | // Authing 控制台 -> 选择已创建的小程序应用 -> 应用配置 -> -> 认证配置 -> 登录回调 URL 14 | redirectUrl: '' 15 | }) 16 | 17 | const query = (function (){ 18 | const query = {} 19 | 20 | const queryString = window.location.search.split('?')[1] 21 | 22 | if (!queryString) { 23 | return query 24 | } 25 | 26 | queryString.split('&').forEach(item => { 27 | const [key, value] = item.split('=') 28 | query[key] = value 29 | }) 30 | 31 | return query 32 | })(); 33 | 34 | 35 | if (+query.init === 1) { 36 | window.location = authingWx.getAuthorizationUrl() 37 | } else { 38 | const { ok, userInfo, message } = authingWx.getUserInfo() 39 | if (ok) { 40 | console.log('userInfo: ', userInfo) 41 | } else if (message) { 42 | console.log(message) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/weixin-official-account/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weixin-official-account", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "webpack-dev-server --progress --color --config webpack.config.js" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@authing/weixin-official-account": "^5.0.0-alpha.15" 13 | }, 14 | "devDependencies": { 15 | "html-webpack-plugin": "^3.2.0", 16 | "webpack": "^4.30.0", 17 | "webpack-cli": "^3.3.1", 18 | "webpack-dev-server": "^3.10.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "npm", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "useWorkspaces": true, 7 | "version": "5.1.21-alpha.1" 8 | } 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root", 3 | "private": true, 4 | "scripts": { 5 | "prepare": "husky install", 6 | "autoinstall": "npm ci && lerna run autoinstall", 7 | "build:miniapp": "cd packages/miniapp && npm run autoinstall && npm run build", 8 | "link": "lerna link", 9 | "lint": "eslint --ext .ts packages/**/src/**", 10 | "lint:fix": "eslint --fix --ext .ts packages/**/src/**", 11 | "transfer-miniapp-libs": "node scripts/transfer-miniapp-libs.js", 12 | "oss": "node scripts/oss.js" 13 | }, 14 | "workspaces": [ 15 | "packages/*" 16 | ], 17 | "engines": { 18 | "node": ">=16.13.1" 19 | }, 20 | "author": "https://github.com/authing", 21 | "devDependencies": { 22 | "@babel/plugin-transform-runtime": "^7.16.10", 23 | "@babel/preset-env": "^7.16.11", 24 | "@tarojs/taro": "^3.5.4", 25 | "@typescript-eslint/eslint-plugin": "^5.32.0", 26 | "@typescript-eslint/parser": "^5.10.1", 27 | "ali-oss": "^6.16.0", 28 | "babel-loader": "^8.2.5", 29 | "chalk": "^2.3.2", 30 | "eslint": "^8.7.0", 31 | "eslint-config-prettier": "^8.3.0", 32 | "eslint-plugin-prettier": "^4.0.0", 33 | "fs-extra": "^10.1.0", 34 | "husky": "^8.0.1", 35 | "loader-utils": "^2.0.2", 36 | "prettier": "^2.5.1", 37 | "rimraf": "^2.6.2", 38 | "ts-loader": "^9.3.1", 39 | "typescript": "4.2.2", 40 | "webpack": "^5.72.1", 41 | "webpack-cli": "^4.9.2", 42 | "webpack-merge": "^5.8.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/miniapp-jsencrypt/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-jsencrypt 2 | 3 | JavaScript rsa encrypt module for miniapp 4 | 5 | ## Usage 6 | 7 | Use in Authing miniapp SDK 8 | 9 | ``` typescript 10 | import { Authing } from '@authing/miniapp-wx' 11 | 12 | import { encryptFunction } from '@authing/miniapp-jsencrypt' 13 | 14 | const authing = new Authing({ 15 | appId: 'AUTHING_APP_ID', 16 | 17 | // 公有云部署:Authing 控制台 -> 选择已创建的小程序应用 -> 应用配置 -> 认证配置 -> 认证地址 18 | // 私有化部署:填写你的私有服务地址 19 | host: 'https://my-authing-app.example.com', 20 | 21 | // 用户池 ID 22 | userPoolId: '62e221xxxxxxxxxxx7037a39', 23 | 24 | // 非必传,密码默认将以明文传输 25 | encryptFunction 26 | }) 27 | ``` 28 | 29 | Use alone 30 | 31 | ``` typescript 32 | import { encryptFunction } from '@authing/miniapp-jsencrypt' 33 | 34 | export async function getPublicKey () { 35 | const host = 'https://core.authing.cn' 36 | 37 | const api = `${host}/api/v3/system` 38 | 39 | const res = await axios.get(api) 40 | 41 | return res.data.data.rsa.publicKey 42 | } 43 | 44 | const publicKey = await getPublicKey() 45 | 46 | encryptFunction('this is planText', publicKey) 47 | ``` 48 | -------------------------------------------------------------------------------- /packages/miniapp-jsencrypt/lib/index.js: -------------------------------------------------------------------------------- 1 | import { JSEncrypt } from './jsencrypt' 2 | 3 | export function encryptFunction (plainText, publicKey) { 4 | const encrypt = new JSEncrypt({}) 5 | 6 | encrypt.setPublicKey(publicKey) 7 | 8 | const encStr = encrypt.encrypt(plainText) 9 | 10 | return encStr.toString() 11 | } 12 | -------------------------------------------------------------------------------- /packages/miniapp-jsencrypt/lib/jsencrypt.d.ts: -------------------------------------------------------------------------------- 1 | interface Options { 2 | default_key_size?: number 3 | default_public_exponent?: string 4 | log?: boolean 5 | } 6 | 7 | export declare class JSEncrypt { 8 | options: Options 9 | constructor(options: Options) 10 | setPublicKey: (publicKey: string) => void 11 | encrypt: (plainText: string) => string | false 12 | // expand more ....... 13 | } 14 | 15 | export declare function encryptFunction(plainText: string, publicKey: string): string 16 | -------------------------------------------------------------------------------- /packages/miniapp-jsencrypt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-jsencrypt", 3 | "version": "5.1.21-alpha.1", 4 | "description": "JavaScript encrypt module for miniapp", 5 | "main": "lib/index.js", 6 | "module": "lib/index.js", 7 | "types": "lib/jsencrypt.d.ts", 8 | "files": [ 9 | "lib" 10 | ], 11 | "scripts": { 12 | "release:official": "npm publish --verbose --access public", 13 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 14 | }, 15 | "author": "https://github.com/authing", 16 | "license": "MIT", 17 | "publishConfig": { 18 | "access": "public", 19 | "registry": "https://registry.npmjs.org" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/miniapp-sm2encrypt/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-sm2encrypt 2 | 3 | JavaScript sm2 encrypt module for miniapp 4 | 5 | ## Usage 6 | 7 | Use in Authing miniapp SDK 8 | 9 | ``` typescript 10 | import { Authing } from '@authing/miniapp-wx' 11 | 12 | import { encryptFunction } from '@authing/miniapp-sm2encrypt' 13 | 14 | const authing = new Authing({ 15 | appId: 'AUTHING_APP_ID', 16 | 17 | // 公有云部署:Authing 控制台 -> 选择已创建的小程序应用 -> 应用配置 -> 认证配置 -> 认证地址 18 | // 私有化部署:填写你的私有服务地址 19 | host: 'https://my-authing-app.example.com', 20 | 21 | // 用户池 ID 22 | userPoolId: '62e221xxxxxxxxxxx7037a39', 23 | 24 | // 非必传,密码默认将以明文传输 25 | encryptFunction 26 | }) 27 | ``` 28 | 29 | Use alone 30 | 31 | ``` typescript 32 | import { encryptFunction } from '@authing/miniapp-sm2encrypt' 33 | 34 | export async function getPublicKey () { 35 | const host = 'https://core.authing.cn' 36 | 37 | const api = `${host}/api/v3/system` 38 | 39 | const res = await axios.get(api) 40 | 41 | return res.data.data.sm2.publicKey 42 | } 43 | 44 | const publicKey = await getPublicKey() 45 | 46 | encryptFunction('this is planText', publicKey) 47 | ``` 48 | -------------------------------------------------------------------------------- /packages/miniapp-sm2encrypt/lib/index.js: -------------------------------------------------------------------------------- 1 | import { doEncrypt } from './sm2' 2 | 3 | export function encryptFunction (plainText, publicKey) { 4 | return doEncrypt(plainText, publicKey) 5 | } 6 | -------------------------------------------------------------------------------- /packages/miniapp-sm2encrypt/lib/sm2encrypt.d.ts: -------------------------------------------------------------------------------- 1 | export declare function doEncrypt(data: string, publicKey: string, cipherMode?: number):any 2 | 3 | export declare function encryptFunction(plainText: string, publicKey: string): string -------------------------------------------------------------------------------- /packages/miniapp-sm2encrypt/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-sm2encrypt", 3 | "version": "5.1.21-alpha.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@authing/miniapp-sm2encrypt", 9 | "version": "5.1.8", 10 | "license": "MIT", 11 | "dependencies": { 12 | "jsbn": "^1.1.0" 13 | } 14 | }, 15 | "node_modules/jsbn": { 16 | "version": "1.1.0", 17 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", 18 | "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" 19 | } 20 | }, 21 | "dependencies": { 22 | "jsbn": { 23 | "version": "1.1.0", 24 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", 25 | "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/miniapp-sm2encrypt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-sm2encrypt", 3 | "version": "5.1.21-alpha.1", 4 | "description": "JavaScript sm2 encrypt module for miniapp", 5 | "main": "lib/index.js", 6 | "module": "lib/index.js", 7 | "types": "lib/sm2encrypt.d.ts", 8 | "files": [ 9 | "lib" 10 | ], 11 | "scripts": { 12 | "autoinstall": "npm ci", 13 | "release:official": "npm publish --verbose --access public", 14 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 15 | }, 16 | "author": "https://github.com/authing", 17 | "license": "MIT", 18 | "publishConfig": { 19 | "access": "public", 20 | "registry": "https://registry.npmjs.org" 21 | }, 22 | "dependencies": { 23 | "jsbn": "^1.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/miniapp-taro/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-taro 2 | 3 | Authing miniapp SDK for Taro 4 | 5 | ## Usage 6 | 7 | reference [examples](../../examples/miniapp-taro/src/pages/index/index.tsx) 8 | 9 | ## Doc 10 | 11 | https://docs.authing.cn/v3/reference/sdk/miniapp/quick.html 12 | -------------------------------------------------------------------------------- /packages/miniapp-taro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-taro", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing miniapp JS SDK for Taro", 5 | "main": "dist/bundle-taro.js", 6 | "types": "dist/typings/src/index.d.ts", 7 | "author": "https://github.com/authing", 8 | "license": "MIT", 9 | "files": [ 10 | "dist" 11 | ], 12 | "scripts": { 13 | "release:official": "npm publish --verbose --access public", 14 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 15 | }, 16 | "publishConfig": { 17 | "access": "public", 18 | "registry": "https://registry.npmjs.org" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/authing/authing-js-sdk" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/authing/authing-js-sdk/issues" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/miniapp-tt/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-tt 2 | 3 | Authing JS SDK for douyin minprogram 4 | 5 | ## Usage 6 | 7 | reference [examples](../../examples/miniapp-tt/miniapp/pages/index/index.ts) 8 | 9 | ## Doc 10 | 11 | https://docs.authing.cn/v3/reference/sdk/miniapp/quick.html 12 | -------------------------------------------------------------------------------- /packages/miniapp-tt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-tt", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing miniapp JS SDK for TT", 5 | "main": "dist/bundle-tt.js", 6 | "types": "dist/typings/src/index.d.ts", 7 | "author": "https://github.com/authing", 8 | "license": "MIT", 9 | "files": [ 10 | "dist" 11 | ], 12 | "scripts": { 13 | "release:official": "npm publish --verbose --access public", 14 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 15 | }, 16 | "publishConfig": { 17 | "access": "public", 18 | "registry": "https://registry.npmjs.org" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/authing/authing-js-sdk" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/authing/authing-js-sdk/issues" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/miniapp-uniapp/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-uniapp 2 | 3 | Authing JS SDK for uniapp 4 | 5 | ## Usage 6 | 7 | reference [examples](../../examples/miniapp-uniapp/src/pages/index/index.vue) 8 | 9 | ## Doc 10 | 11 | https://docs.authing.cn/v3/reference/sdk/miniapp/quick.html -------------------------------------------------------------------------------- /packages/miniapp-uniapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-uniapp", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing miniapp JS SDK for uniapp", 5 | "main": "dist/bundle-uniapp.js", 6 | "types": "dist/typings/src/index.d.ts", 7 | "author": "https://github.com/authing", 8 | "license": "MIT", 9 | "files": [ 10 | "dist" 11 | ], 12 | "scripts": { 13 | "release:official": "npm publish --verbose --access public", 14 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 15 | }, 16 | "publishConfig": { 17 | "access": "public", 18 | "registry": "https://registry.npmjs.org" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/authing/authing-js-sdk" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/authing/authing-js-sdk/issues" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/miniapp-wx/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp-wx 2 | 3 | Authing JS SDK for weixin minprogram 4 | 5 | ## Usage 6 | 7 | reference [examples](../../examples/miniapp-wx/miniapp/pages/index/index.ts) 8 | 9 | ## Doc 10 | 11 | https://docs.authing.cn/v3/reference/sdk/miniapp/quick.html 12 | -------------------------------------------------------------------------------- /packages/miniapp-wx/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp-wx", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing miniapp JS SDK for WX", 5 | "main": "dist/bundle-wx.js", 6 | "types": "dist/typings/src/index.d.ts", 7 | "author": "https://github.com/authing", 8 | "license": "MIT", 9 | "files": [ 10 | "dist" 11 | ], 12 | "scripts": { 13 | "release:official": "npm publish --verbose --access public", 14 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 15 | }, 16 | "publishConfig": { 17 | "access": "public", 18 | "registry": "https://registry.npmjs.org" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/authing/authing-js-sdk" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/authing/authing-js-sdk/issues" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/miniapp/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Authing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/miniapp/README.md: -------------------------------------------------------------------------------- 1 | # @authing/miniapp 2 | 3 | For internal use only, as source code of `@authing/miniapp-taro`, `@authing/miniapp-uniapp`, `@authing/miniapp-wx` -------------------------------------------------------------------------------- /packages/miniapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/miniapp", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing miniapp sdk source code", 5 | "main": "src/index.ts", 6 | "module": "src/index.ts", 7 | "scripts": { 8 | "autoinstall": "npm ci", 9 | "dev": "node ./scripts/build.js watch", 10 | "build": "node ./scripts/build.js", 11 | "release:official": "npm publish --verbose --access public", 12 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 13 | }, 14 | "dependencies": { 15 | "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", 16 | "@authing/authingmove-core": "^1.0.1-alpha.14" 17 | }, 18 | "devDependencies": { 19 | "@authing/authingmove-webpack-plugin": "^1.0.1-alpha.14" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/Authing/authing-js-sdk.git" 24 | }, 25 | "author": "https://github.com/authing", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/Authing/authing-js-sdk/issues" 29 | }, 30 | "homepage": "https://github.com/Authing/authing-js-sdk#readme", 31 | "publishConfig": { 32 | "access": "public", 33 | "registry": "https://registry.npmjs.org" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/miniapp/scripts/config.js: -------------------------------------------------------------------------------- 1 | exports.platforms = [ 2 | 'wx', 3 | 'ali', 4 | 'baidu', 5 | 'qq', 6 | 'tt', 7 | 'jd', 8 | 'ks', 9 | 'qa_webview', 10 | 'qa_ux', 11 | 'Mpx', 12 | 'Taro', 13 | 'uni' 14 | ] 15 | -------------------------------------------------------------------------------- /packages/miniapp/scripts/getWebpackConfig.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | const { merge } = require('webpack-merge') 3 | 4 | const webpackBaseConfig = require('./webpack.base.config') 5 | const AuthingMoveWebpackPlugin = require('@authing/authingmove-webpack-plugin') 6 | const { resolve } = require('./utils') 7 | 8 | module.exports = function getWebpackConfig (options) { 9 | const { 10 | __authing_move_src_mode__, 11 | __authing_move_mode__, 12 | compilerMode 13 | } = options 14 | const entry = resolve('src', 'index.ts') 15 | const output = { 16 | filename: `bundle-${__authing_move_mode__.toLowerCase()}.js`, 17 | path: resolve('dist') 18 | } 19 | const plugins = [ 20 | new webpack.DefinePlugin({ 21 | __authing_move_src_mode__: JSON.stringify(__authing_move_src_mode__), 22 | __authing_move_mode__: JSON.stringify(__authing_move_mode__) 23 | }), 24 | new AuthingMoveWebpackPlugin({ 25 | srcMode: __authing_move_src_mode__, 26 | mode: __authing_move_mode__ 27 | }) 28 | ] 29 | 30 | return merge({}, webpackBaseConfig, { 31 | mode: compilerMode, 32 | entry, 33 | output, 34 | plugins 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /packages/miniapp/scripts/utils.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | exports.parseArgv = function parseArgv () { 4 | return process.argv.slice(2).reduce((map, arg) => { 5 | const [key, value] = arg.replace(/-/img, '').split('=') 6 | map[key] = !value ? true : value.split(',') 7 | return map 8 | }, {}) 9 | } 10 | 11 | exports.resolve = function resolve (dir, file = '') { 12 | return path.resolve(__dirname, '../', dir, file) 13 | } 14 | 15 | exports.getArgsFromTerminal = arg => process.env[`npm_config_${arg}`] 16 | -------------------------------------------------------------------------------- /packages/miniapp/scripts/webpack.base.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | output: { 3 | library: { 4 | type: 'module' 5 | } 6 | }, 7 | experiments: { 8 | outputModule: true 9 | }, 10 | resolve: { 11 | extensions: ['.ts', '.js'] 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.ts$/, 17 | use: 'ts-loader', 18 | exclude: /node_modules/ 19 | } 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/miniapp/src/AuthingMove.ts: -------------------------------------------------------------------------------- 1 | import AuthingMove from '@authing/authingmove-core' 2 | 3 | import apiProxy from '@authing/authingmove-api-proxy' 4 | 5 | AuthingMove.use(apiProxy) 6 | 7 | export { AuthingMove } 8 | -------------------------------------------------------------------------------- /packages/miniapp/src/helpers/StorageProvider.ts: -------------------------------------------------------------------------------- 1 | import { 2 | GetStorageCallbackData, 3 | RemoveStorageFailData, 4 | RemoveStorageSuccessData, 5 | SetStorageCallbackData 6 | } from '@authing/authingmove-core' 7 | 8 | import { AuthingMove } from '../AuthingMove' 9 | 10 | import { IStorageProvider } from '../types' 11 | 12 | export class StorageProvider implements IStorageProvider { 13 | get(key: string): Promise { 14 | return AuthingMove.getStorage({ 15 | key 16 | }) 17 | } 18 | 19 | set(key: string, data: unknown): Promise { 20 | return AuthingMove.setStorage({ 21 | key, 22 | data 23 | }) 24 | } 25 | 26 | remove( 27 | key: string 28 | ): Promise { 29 | return AuthingMove.removeStorage({ 30 | key 31 | }) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/miniapp/src/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './StorageProvider' 2 | export * from './request' 3 | export * from './utils' 4 | export * from './return' 5 | -------------------------------------------------------------------------------- /packages/miniapp/src/helpers/return.ts: -------------------------------------------------------------------------------- 1 | import { ErrorData, SDKResponseSuccess, SDKResponseError } from '../types' 2 | 3 | export function returnSuccess (data: T): SDKResponseSuccess { 4 | return [null, data] 5 | } 6 | 7 | export function returnError (errorData: ErrorData): SDKResponseError { 8 | return [errorData, undefined] 9 | } 10 | -------------------------------------------------------------------------------- /packages/miniapp/src/helpers/utils.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Platforms, 3 | PlatformsMenu, 4 | } from '../types' 5 | 6 | 7 | export function getLoginStateKey(appId: string): string { 8 | return ['authing', appId, 'login-state'].join(':') 9 | } 10 | 11 | export function getPlatformLoginCodeKey (appId: string,platform: Platforms | undefined): string { 12 | 13 | return ['authing', appId, `${platform ? platform : 'wx' }-login-code`].join(':') 14 | } 15 | 16 | declare const wx: any 17 | declare const tt: any 18 | 19 | export function getCurrentMiniProgram():PlatformsMenu { 20 | if (typeof tt!== 'undefined' && typeof tt.getSystemInfo !== 'undefined') { 21 | return PlatformsMenu.tt 22 | } else if (typeof wx !== 'undefined' && typeof wx.getSystemInfo !== 'undefined') { 23 | return PlatformsMenu.wx 24 | } else { 25 | return PlatformsMenu.wx 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /packages/miniapp/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from '@authing/authingmove-core' 2 | 3 | export * from './Authing' 4 | 5 | export * from './types' 6 | -------------------------------------------------------------------------------- /packages/miniapp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "outDir": "dist", 5 | "target": "es5", 6 | "lib": ["dom", "esnext"], 7 | "allowJs": false, 8 | "skipLibCheck": true, 9 | "esModuleInterop": true, 10 | "allowSyntheticDefaultImports": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "noFallthroughCasesInSwitch": true, 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "declaration": true, 18 | "declarationDir": "./dist/typings", 19 | "noEmit": false, 20 | "downlevelIteration": true 21 | }, 22 | "include": [ 23 | "src/**/*.ts" 24 | ], 25 | "exclude": [ 26 | "node_modules", 27 | "dist" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /packages/web/rollup.config.ts: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import typescript from 'rollup-plugin-typescript2'; 4 | import json from '@rollup/plugin-json'; 5 | import { terser } from 'rollup-plugin-terser'; 6 | 7 | const pkg = require('./package.json'); 8 | 9 | const libraryName = 'AuthingFactory'; 10 | 11 | export default { 12 | input: `src/index.ts`, 13 | output: [ 14 | { file: pkg.main, name: libraryName, format: 'umd', sourcemap: true }, 15 | { file: pkg.module, format: 'esm', sourcemap: true }, 16 | ], 17 | // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash') 18 | external: ['axios'], 19 | 20 | watch: { 21 | include: 'src/**', 22 | }, 23 | plugins: [ 24 | // Allow json resolution 25 | json(), 26 | // Compile TypeScript files 27 | typescript({ useTsconfigDeclarationDir: true }), 28 | // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) 29 | commonjs(), 30 | // Allow node_modules resolution, so you can use 'external' to control 31 | // which external modules to include in the bundle 32 | // https://github.com/rollup/rollup-plugin-node-resolve#usage 33 | resolve(), 34 | 35 | terser(), 36 | ], 37 | }; 38 | -------------------------------------------------------------------------------- /packages/web/src/axios.ts: -------------------------------------------------------------------------------- 1 | import axios, { AxiosError, AxiosRequestConfig } from 'axios' 2 | 3 | import { version } from '../package.json' 4 | 5 | function isAxiosError(e: any): e is AxiosError { 6 | return e.isAxiosError 7 | } 8 | 9 | async function axiosPromiseWrapper(p: Promise) { 10 | try { 11 | return await p 12 | } catch (e) { 13 | if (isAxiosError(e)) { 14 | if ((e.response?.data as any)?.error) { 15 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 16 | const { error, error_description } = e.response!.data as any 17 | throw new Error(`认证服务器返回错误 ${error}: ${error_description}`) 18 | } 19 | } 20 | throw e 21 | } 22 | } 23 | 24 | export async function axiosGet( 25 | url: string, 26 | options?: AxiosRequestConfig 27 | ) { 28 | const _options = mergeOptions(options) 29 | return axiosPromiseWrapper(axios.get(url, _options)) 30 | } 31 | 32 | export async function axiosPost( 33 | url: string, 34 | data?: any, 35 | options?: AxiosRequestConfig 36 | ) { 37 | const _options = mergeOptions(options) 38 | return axiosPromiseWrapper(axios.post(url, data, _options)) 39 | } 40 | 41 | function mergeOptions (options?: AxiosRequestConfig): AxiosRequestConfig { 42 | const _options = Object.assign({}, options || {}, { 43 | headers: { 44 | ...options?.headers, 45 | 'x-authing-request-from': 'sdk-web', 46 | 'x-authing-sdk-version': version 47 | } 48 | }) 49 | return _options 50 | } 51 | -------------------------------------------------------------------------------- /packages/web/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const SDK_IDENTIFIER = 'authing-spa' 2 | export const STORAGE_VERSION = '1' 3 | 4 | export const STORAGE_KEY_PREFIX = `${SDK_IDENTIFIER}:${STORAGE_VERSION}` 5 | 6 | export const DEFAULT_IFRAME_LOGINSTATE_TIMEOUT = 5000 7 | 8 | export const DEFAULT_POPUP_WIDTH = 800 9 | export const DEFAULT_POPUP_HEIGHT = 600 10 | 11 | export const DEFAULT_SCOPE = 'openid profile' 12 | 13 | export const MSG_PENDING_AUTHZ = 14 | '另一个认证流程正在进行中,请不要同时发起多个认证' 15 | export const MSG_CROSS_ORIGIN_ISOLATED = 16 | '当前页面运行在隔离模式下, 无法进行此方式登录, 请使用 loginWithRedirect' 17 | -------------------------------------------------------------------------------- /packages/web/src/index.ts: -------------------------------------------------------------------------------- 1 | export { Authing } from './Authing' 2 | -------------------------------------------------------------------------------- /packages/web/src/storage/InMemoryStorgeProvider.ts: -------------------------------------------------------------------------------- 1 | import { MayBePromise } from '../types' 2 | import { StorageProvider } from './interface' 3 | 4 | export class InMemoryStorageProvider implements StorageProvider { 5 | private readonly storage = Object.create(null) 6 | 7 | get(key: string): MayBePromise { 8 | return this.storage[key] ?? null 9 | } 10 | 11 | put(key: string, value: T): MayBePromise { 12 | this.storage[key] = value 13 | } 14 | 15 | delete(key: string): MayBePromise { 16 | delete this.storage[key] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/web/src/storage/LocalStorageProvider.ts: -------------------------------------------------------------------------------- 1 | import { MayBePromise } from '../types' 2 | import { StorageProvider } from './interface' 3 | 4 | export class LocalStorageProvider implements StorageProvider { 5 | get(key: string): MayBePromise { 6 | const jsonItem = localStorage.getItem(key) 7 | if (jsonItem === null) { 8 | return null 9 | } 10 | return JSON.parse(jsonItem) as T 11 | } 12 | 13 | put(key: string, value: T): MayBePromise { 14 | localStorage.setItem(key, JSON.stringify(value)) 15 | } 16 | 17 | delete(key: string): MayBePromise { 18 | localStorage.removeItem(key) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web/src/storage/NullStorageProvider.ts: -------------------------------------------------------------------------------- 1 | import { MayBePromise } from '../types' 2 | import { StorageProvider } from './interface' 3 | 4 | export class NullStorageProvider implements StorageProvider { 5 | get(): MayBePromise { 6 | return null 7 | } 8 | 9 | put(): MayBePromise { 10 | // null 11 | } 12 | 13 | delete(): MayBePromise { 14 | // null 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/web/src/storage/SessionStorageProvider.ts: -------------------------------------------------------------------------------- 1 | import { MayBePromise } from '../types' 2 | import { StorageProvider } from './interface' 3 | 4 | export class SessionStorageProvider implements StorageProvider { 5 | get(key: string): MayBePromise { 6 | const jsonItem = sessionStorage.getItem(key) 7 | if (jsonItem === null) { 8 | return null 9 | } 10 | return JSON.parse(jsonItem) as T 11 | } 12 | 13 | put(key: string, value: T): MayBePromise { 14 | sessionStorage.setItem(key, JSON.stringify(value)) 15 | } 16 | 17 | delete(key: string): MayBePromise { 18 | sessionStorage.removeItem(key) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/web/src/storage/interface.ts: -------------------------------------------------------------------------------- 1 | import { MayBePromise } from '../types' 2 | 3 | export interface StorageProvider { 4 | get(key: string): MayBePromise 5 | put(key: string, value: VALUE): MayBePromise 6 | delete(key: string): MayBePromise 7 | } 8 | -------------------------------------------------------------------------------- /packages/web/src/types.ts: -------------------------------------------------------------------------------- 1 | export type StrDict = Record 2 | 3 | export type RedirectResponseMode = 'fragment' | 'query' 4 | 5 | export type ImplicitResponseType = 'id_token token' | 'id_token' 6 | 7 | export type MayBePromise = T | Promise 8 | 9 | export type MsgListener = (e: MessageEvent) => void 10 | -------------------------------------------------------------------------------- /packages/weixin-official-account/assets/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Authing/authing-js-sdk/1aa9b2ca7ff923acf9c54c62f7b766fd89e5c306/packages/weixin-official-account/assets/1.png -------------------------------------------------------------------------------- /packages/weixin-official-account/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/weixin-official-account", 3 | "version": "5.1.21-alpha.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@authing/weixin-official-account", 9 | "version": "5.1.8", 10 | "license": "MIT" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/weixin-official-account/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@authing/weixin-official-account", 3 | "version": "5.1.21-alpha.1", 4 | "description": "Authing SDK for Weixin official account", 5 | "module": "dist/esm/weixin-official-account.min.js", 6 | "types": "dist/typings/index.d.ts", 7 | "files": [ 8 | "dist" 9 | ], 10 | "buildOptions": { 11 | "formats": [ 12 | "esm", 13 | "global" 14 | ] 15 | }, 16 | "scripts": { 17 | "autoinstall": "npm ci", 18 | "build": "node scripts/build.js", 19 | "release:official": "npm publish --verbose --access public", 20 | "release:alpha": "npm publish --verbose --tag=alpha --access public" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/Authing/authing-js-sdk.git" 25 | }, 26 | "author": "https://github.com/authing", 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/Authing/authing-js-sdk/issues" 30 | }, 31 | "homepage": "https://github.com/Authing/authing-js-sdk#readme", 32 | "publishConfig": { 33 | "access": "public", 34 | "registry": "https://registry.npmjs.org" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/weixin-official-account/scripts/build.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const rm = require('rimraf') 3 | const webpack = require('webpack') 4 | const webpackEsmBundlerConfig = require('./webpack.esm.config') 5 | const webpackGlobalConfig = require('./webpack.global.config') 6 | 7 | try { 8 | rm.sync(path.resolve(__dirname, '../', 'dist')) 9 | } catch (e) { 10 | console.error('\n\n build weixin-official-account, failed to delete dist directory, please operate manually \n\n') 11 | } 12 | 13 | readyGo() 14 | 15 | function readyGo () { 16 | webpack(webpackEsmBundlerConfig, (error) => { 17 | if (error) { 18 | console.error('build weixin-official-account esm bundler error: ', error) 19 | } 20 | }) 21 | webpack(webpackGlobalConfig, (error) => { 22 | if (error) { 23 | console.error('build weixin-official-account global error: ', error) 24 | } 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /packages/weixin-official-account/scripts/webpack.esm.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | function resolve (dir, file = '') { 4 | return path.resolve(__dirname, '../', dir, file) 5 | } 6 | 7 | module.exports = { 8 | mode: 'production', 9 | entry: resolve('src/index.ts'), 10 | output: { 11 | filename: 'weixin-official-account.min.js', 12 | path: resolve('dist/esm'), 13 | library: { 14 | type: 'module' 15 | } 16 | }, 17 | experiments: { 18 | outputModule: true 19 | }, 20 | resolve: { 21 | extensions: ['.ts', '.js'] 22 | }, 23 | module: { 24 | rules: [ 25 | { 26 | test: /\.ts$/, 27 | use: 'ts-loader', 28 | exclude: /node_modules/ 29 | } 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/weixin-official-account/scripts/webpack.global.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | function resolve (dir, file = '') { 4 | return path.resolve(__dirname, '../', dir, file) 5 | } 6 | 7 | module.exports = { 8 | mode: 'production', 9 | devtool: 'source-map', 10 | entry: resolve('src/index.ts'), 11 | output: { 12 | filename: 'weixin-official-account.min.js', 13 | path: resolve('dist/global'), 14 | library: { 15 | name: 'AuthingFactory', 16 | type: 'global' 17 | } 18 | }, 19 | resolve: { 20 | extensions: ['.ts', '.js'] 21 | }, 22 | module: { 23 | rules: [ 24 | { 25 | test: /\.ts$/, 26 | use: 'ts-loader', 27 | exclude: /node_modules/ 28 | } 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/weixin-official-account/src/types.ts: -------------------------------------------------------------------------------- 1 | export interface AuthingWxmpOptions { 2 | appId: string 3 | host: string 4 | identifier: string 5 | redirectUrl: string 6 | } 7 | -------------------------------------------------------------------------------- /packages/weixin-official-account/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "target": "es5", 7 | "lib": ["dom", "esnext"], 8 | "allowJs": false, 9 | "skipLibCheck": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "strict": true, 13 | "forceConsistentCasingInFileNames": true, 14 | "noFallthroughCasesInSwitch": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "declaration": true, 19 | "declarationDir": "./dist/typings", 20 | "noEmit": false, 21 | "downlevelIteration": true 22 | }, 23 | "include": [ 24 | "src/**/*.ts" 25 | ], 26 | "exclude": [ 27 | "node_modules", 28 | "dist" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /scripts/transfer-miniapp-libs.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const fs = require('fs-extra') 3 | const rm = require('rimraf') 4 | 5 | const resolve = (dir, file = '') =>{ 6 | return path.resolve(__dirname, '../', dir, file) 7 | } 8 | 9 | const platforms = ['taro', 'uni', 'wx', 'tt'] 10 | 11 | readyGo() 12 | 13 | function readyGo () { 14 | platforms.forEach(platform => { 15 | copyFiles(platform) 16 | }) 17 | } 18 | 19 | function copyFiles (platform) { 20 | const _platform = platform === 'uni' ? 'uniapp' : platform 21 | 22 | rm.sync(resolve(`packages/miniapp-${_platform}/dist`)) 23 | 24 | // copy bundle 25 | fs.copySync( 26 | resolve(`packages/miniapp/dist/bundle-${platform}.js`), 27 | resolve(`packages/miniapp-${_platform}/dist/bundle-${_platform}.js`), 28 | ) 29 | 30 | // copy typings 31 | fs.copySync( 32 | resolve('packages/miniapp/dist/typings'), 33 | resolve(`packages/miniapp-${_platform}/dist/typings`) 34 | ) 35 | } 36 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "outDir": "dist", 5 | "target": "es5", 6 | "lib": ["dom", "esnext"], 7 | "allowJs": false, 8 | "skipLibCheck": true, 9 | "esModuleInterop": true, 10 | "allowSyntheticDefaultImports": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "noFallthroughCasesInSwitch": true, 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "noEmit": false, 18 | "jsx": "react", 19 | "downlevelIteration": true 20 | }, 21 | "include": [ 22 | "packages/*/src" 23 | ] 24 | } 25 | --------------------------------------------------------------------------------