diff --git a/.gitkeep b/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/recipes/vue-vite/.editorconfig b/recipes/vue-vite/.editorconfig new file mode 100644 index 00000000..7f5b23fc --- /dev/null +++ b/recipes/vue-vite/.editorconfig @@ -0,0 +1,9 @@ +[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}] +charset = utf-8 +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +end_of_line = lf +max_line_length = 100 diff --git a/recipes/vue-vite/.gitattributes b/recipes/vue-vite/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/recipes/vue-vite/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/recipes/vue-vite/.gitignore b/recipes/vue-vite/.gitignore new file mode 100644 index 00000000..8ee54e8d --- /dev/null +++ b/recipes/vue-vite/.gitignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +*.tsbuildinfo diff --git a/recipes/vue-vite/.prettierrc.json b/recipes/vue-vite/.prettierrc.json new file mode 100644 index 00000000..17a23d07 --- /dev/null +++ b/recipes/vue-vite/.prettierrc.json @@ -0,0 +1,7 @@ + +{ + "$schema": "https://json.schemastore.org/prettierrc", + "semi": false, + "singleQuote": true, + "printWidth": 100 +} diff --git a/recipes/vue-vite/.vscode/extensions.json b/recipes/vue-vite/.vscode/extensions.json new file mode 100644 index 00000000..a06a8c69 --- /dev/null +++ b/recipes/vue-vite/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "Vue.volar", + "vitest.explorer", + "dbaeumer.vscode-eslint", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode" + ] +} diff --git a/recipes/vue-vite/README.md b/recipes/vue-vite/README.md new file mode 100644 index 00000000..a03c2370 --- /dev/null +++ b/recipes/vue-vite/README.md @@ -0,0 +1,105 @@ +# Asgardeo Auth Vue.js SDK Usage Example (Single Page Application) + +This sample is developed to demonstrate the basic usage of the Asgardeo Auth Vue.js SDK. + +## Getting Started + +### Prerequisites +- `Node.js` (version 20 or above). + +### Register an Application +//TODO + +Make sure to add `http://localhost:5173` as a Redirect URL and also add it under allowed origins. + +### Download the Sample +//TODO + +### Configure the Sample + +Update the authentication configuration in your `main.ts` file with your registered app details. + +**Note:** You will need to paste in the `client ID` generated for the application you registered. + +```typescript +import "./assets/main.css"; +import { createApp } from "vue"; +import App from "./App.vue"; +import router from "./router"; +import { asgardeoPlugin } from "./auth/authprovider"; + +const app = createApp(App); + +app.use(router); +app.use(asgardeoPlugin, { + signInRedirectURL: "http://localhost:5173/", + signOutRedirectURL: "http://localhost:5173/", + clientID: "", + baseUrl: "https://api.asgardeo.io/t/", +}); + +app.mount("#app"); +``` + +### Run the Application + +```bash +npm install && npm run dev +``` + +The app should open at [`http://localhost:5173`](http://localhost:5173) + +### Change the Application's Development Server Port + +By default, the Vite development server runs on port `5173`. In case you wish to change this to something else, follow the steps below. + +1. Update the port in your Vite configuration file (`vite.config.js` or `vite.config.ts`): + ```javascript + export default defineConfig({ + // Other config options... + server: { + port: YOUR_PREFERRED_PORT + } + }) + ``` + +2. Update the `signInRedirectURL` & `signOutRedirectURL` in `main.ts` to match your new port. + +3. Go to the Asgardeo Console and navigate to the protocol tab of your application: + - Update the Authorized Redirect URL. + - Update the Allowed Origins. + +## Using the Auth Plugin + +The Asgardeo Auth plugin is available throughout your Vue application. Here's how to use it in your components: + +```vue + + + +``` + +//TODO + +## Contribute + +Please read [Contributing to the Code Base](../../CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. + +### Reporting Issues + +We encourage you to report issues, improvements, and feature requests by creating [Github Issues](https://github.com/asgardeo/web-ui-sdks/issues). + +Important: Please be advised that security issues must be reported to security@wso2.com, not as GitHub issues, in order to reach the proper audience. We strongly advise following the WSO2 Security Vulnerability Reporting Guidelines when reporting security issues. + +## License + +This project is licensed under the Apache License 2.0. See the [LICENSE](../../LICENSE) file for details. \ No newline at end of file diff --git a/recipes/vue-vite/env.d.ts b/recipes/vue-vite/env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/recipes/vue-vite/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/recipes/vue-vite/eslint.config.ts b/recipes/vue-vite/eslint.config.ts new file mode 100644 index 00000000..5c8a6786 --- /dev/null +++ b/recipes/vue-vite/eslint.config.ts @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import pluginVue from 'eslint-plugin-vue' +import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript' +import pluginVitest from '@vitest/eslint-plugin' +import skipFormatting from '@vue/eslint-config-prettier/skip-formatting' + +// To allow more languages other than `ts` in `.vue` files, uncomment the following lines: +// import { configureVueProject } from '@vue/eslint-config-typescript' +// configureVueProject({ scriptLangs: ['ts', 'tsx'] }) +// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup + +export default defineConfigWithVueTs( + { + name: 'app/files-to-lint', + files: ['**/*.{ts,mts,tsx,vue}'], + }, + { + name: 'app/files-to-ignore', + ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], + }, + pluginVue.configs['flat/essential'], + vueTsConfigs.recommended, + { + ...pluginVitest.configs.recommended, + files: ['src/**/__tests__/*'], + }, + skipFormatting, +) diff --git a/recipes/vue-vite/index.html b/recipes/vue-vite/index.html new file mode 100644 index 00000000..ec77f85e --- /dev/null +++ b/recipes/vue-vite/index.html @@ -0,0 +1,31 @@ + + + + + + + + + Vue Sample + + +
+ + + diff --git a/recipes/vue-vite/package.json b/recipes/vue-vite/package.json new file mode 100644 index 00000000..8dd1d778 --- /dev/null +++ b/recipes/vue-vite/package.json @@ -0,0 +1,42 @@ +{ + "name": "vue-sample", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "run-p type-check \"build-only {@}\" --", + "preview": "vite preview", + "test:unit": "vitest", + "build-only": "vite build", + "type-check": "vue-tsc --build", + "lint": "eslint . --fix", + "format": "prettier --write src/" + }, + "dependencies": { + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@tsconfig/node22": "^22.0.0", + "@types/jsdom": "^21.1.7", + "@types/node": "^22.13.4", + "@vitejs/plugin-vue": "^5.2.1", + "@vitest/eslint-plugin": "1.1.31", + "@vue/eslint-config-prettier": "^10.2.0", + "@vue/eslint-config-typescript": "^14.4.0", + "@vue/test-utils": "^2.4.6", + "@vue/tsconfig": "^0.7.0", + "eslint": "^9.20.1", + "eslint-plugin-vue": "^9.32.0", + "jiti": "^2.4.2", + "jsdom": "^26.0.0", + "npm-run-all2": "^7.0.2", + "prettier": "^3.5.1", + "typescript": "5.1.6", + "vite": "^6.1.0", + "vite-plugin-vue-devtools": "^7.7.2", + "vitest": "^3.0.5", + "vue-tsc": "^2.2.2" + } +} diff --git a/recipes/vue-vite/public/favicon.ico b/recipes/vue-vite/public/favicon.ico new file mode 100644 index 00000000..67b0e598 Binary files /dev/null and b/recipes/vue-vite/public/favicon.ico differ diff --git a/recipes/vue-vite/src/App.vue b/recipes/vue-vite/src/App.vue new file mode 100644 index 00000000..47d86f9e --- /dev/null +++ b/recipes/vue-vite/src/App.vue @@ -0,0 +1,89 @@ + + + + + + + diff --git a/recipes/vue-vite/src/assets/base.css b/recipes/vue-vite/src/assets/base.css new file mode 100644 index 00000000..9699aec2 --- /dev/null +++ b/recipes/vue-vite/src/assets/base.css @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: + color 0.5s, + background-color 0.5s; + line-height: 1.6; + font-family: + Inter, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + Oxygen, + Ubuntu, + Cantarell, + 'Fira Sans', + 'Droid Sans', + 'Helvetica Neue', + sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/recipes/vue-vite/src/assets/logo.svg b/recipes/vue-vite/src/assets/logo.svg new file mode 100644 index 00000000..c357a821 --- /dev/null +++ b/recipes/vue-vite/src/assets/logo.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + diff --git a/recipes/vue-vite/src/assets/main.css b/recipes/vue-vite/src/assets/main.css new file mode 100644 index 00000000..36fb845b --- /dev/null +++ b/recipes/vue-vite/src/assets/main.css @@ -0,0 +1,35 @@ +@import './base.css'; + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + font-weight: normal; +} + +a, +.green { + text-decoration: none; + color: hsla(160, 100%, 37%, 1); + transition: 0.4s; + padding: 3px; +} + +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } +} + +@media (min-width: 1024px) { + body { + display: flex; + place-items: center; + } + + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } +} diff --git a/recipes/vue-vite/src/components/AuthLayout.vue b/recipes/vue-vite/src/components/AuthLayout.vue new file mode 100644 index 00000000..0d6d5fc8 --- /dev/null +++ b/recipes/vue-vite/src/components/AuthLayout.vue @@ -0,0 +1,165 @@ + + + + + + + diff --git a/recipes/vue-vite/src/images/footer.png b/recipes/vue-vite/src/images/footer.png new file mode 100644 index 00000000..ac178abd Binary files /dev/null and b/recipes/vue-vite/src/images/footer.png differ diff --git a/recipes/vue-vite/src/main.ts b/recipes/vue-vite/src/main.ts new file mode 100644 index 00000000..d10afa6c --- /dev/null +++ b/recipes/vue-vite/src/main.ts @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import './assets/main.css' + +import { createApp } from 'vue' +import App from './App.vue' +import router from './router' + +const app = createApp(App) + +app.use(router) + +app.mount('#app') diff --git a/recipes/vue-vite/src/router/index.ts b/recipes/vue-vite/src/router/index.ts new file mode 100644 index 00000000..13fb7e71 --- /dev/null +++ b/recipes/vue-vite/src/router/index.ts @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { createRouter, createWebHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: '/', + name: 'home', + component: HomeView, + }, + { + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/AboutView.vue'), + }, + ], +}) + +export default router diff --git a/recipes/vue-vite/src/views/AboutView.vue b/recipes/vue-vite/src/views/AboutView.vue new file mode 100644 index 00000000..092be08a --- /dev/null +++ b/recipes/vue-vite/src/views/AboutView.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/recipes/vue-vite/src/views/HomeView.vue b/recipes/vue-vite/src/views/HomeView.vue new file mode 100644 index 00000000..724e7a9f --- /dev/null +++ b/recipes/vue-vite/src/views/HomeView.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/recipes/vue-vite/tsconfig.app.json b/recipes/vue-vite/tsconfig.app.json new file mode 100644 index 00000000..9328499b --- /dev/null +++ b/recipes/vue-vite/tsconfig.app.json @@ -0,0 +1,11 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "exclude": ["src/**/__tests__/*"], + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "paths": { + "@/*": ["./src/*"] + } + } +} diff --git a/recipes/vue-vite/tsconfig.json b/recipes/vue-vite/tsconfig.json new file mode 100644 index 00000000..100cf6a8 --- /dev/null +++ b/recipes/vue-vite/tsconfig.json @@ -0,0 +1,14 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.vitest.json" + } + ] +} diff --git a/recipes/vue-vite/tsconfig.node.json b/recipes/vue-vite/tsconfig.node.json new file mode 100644 index 00000000..c4575a8e --- /dev/null +++ b/recipes/vue-vite/tsconfig.node.json @@ -0,0 +1,18 @@ +{ + "extends": "@tsconfig/node22/tsconfig.json", + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "nightwatch.conf.*", + "playwright.config.*", + "eslint.config.*" + ], + "compilerOptions": { + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["node"] + } +} diff --git a/recipes/vue-vite/tsconfig.vitest.json b/recipes/vue-vite/tsconfig.vitest.json new file mode 100644 index 00000000..23211cfb --- /dev/null +++ b/recipes/vue-vite/tsconfig.vitest.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.app.json", + "include": ["src/**/__tests__/*", "env.d.ts"], + "exclude": [], + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo", + "lib": [], + "types": ["node", "jsdom"] + } +} diff --git a/recipes/vue-vite/vite.config.ts b/recipes/vue-vite/vite.config.ts new file mode 100644 index 00000000..b8d33500 --- /dev/null +++ b/recipes/vue-vite/vite.config.ts @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { fileURLToPath, URL } from 'node:url' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueDevTools from 'vite-plugin-vue-devtools' + +export default defineConfig({ + plugins: [ + vue(), + vueDevTools(), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + }, + }, +}) diff --git a/recipes/vue-vite/vitest.config.ts b/recipes/vue-vite/vitest.config.ts new file mode 100644 index 00000000..a292eb1a --- /dev/null +++ b/recipes/vue-vite/vitest.config.ts @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { fileURLToPath } from 'node:url' +import { mergeConfig, defineConfig, configDefaults } from 'vitest/config' +import viteConfig from './vite.config' + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + environment: 'jsdom', + exclude: [...configDefaults.exclude, 'e2e/**'], + root: fileURLToPath(new URL('./', import.meta.url)), + }, + }), +)