Skip to content

Commit 293d05b

Browse files
Merge pull request #52 from 3nethz/feat/vue-sdk
chore(vue): initialize vue.js sample app
2 parents 32d07ed + 29a6723 commit 293d05b

28 files changed

+952
-0
lines changed

.gitkeep

Whitespace-only changes.

recipes/vue-vite/.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
2+
charset = utf-8
3+
indent_size = 2
4+
indent_style = space
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
end_of_line = lf
9+
max_line_length = 100

recipes/vue-vite/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

recipes/vue-vite/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
19+
20+
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
23+
.idea
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?
29+
30+
*.tsbuildinfo

recipes/vue-vite/.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
{
3+
"$schema": "https://json.schemastore.org/prettierrc",
4+
"semi": false,
5+
"singleQuote": true,
6+
"printWidth": 100
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"Vue.volar",
4+
"vitest.explorer",
5+
"dbaeumer.vscode-eslint",
6+
"EditorConfig.EditorConfig",
7+
"esbenp.prettier-vscode"
8+
]
9+
}

recipes/vue-vite/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Asgardeo Auth Vue.js SDK Usage Example (Single Page Application)
2+
3+
This sample is developed to demonstrate the basic usage of the Asgardeo Auth Vue.js SDK.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
- `Node.js` (version 20 or above).
9+
10+
### Register an Application
11+
//TODO
12+
13+
Make sure to add `http://localhost:5173` as a Redirect URL and also add it under allowed origins.
14+
15+
### Download the Sample
16+
//TODO
17+
18+
### Configure the Sample
19+
20+
Update the authentication configuration in your `main.ts` file with your registered app details.
21+
22+
**Note:** You will need to paste in the `client ID` generated for the application you registered.
23+
24+
```typescript
25+
import "./assets/main.css";
26+
import { createApp } from "vue";
27+
import App from "./App.vue";
28+
import router from "./router";
29+
import { asgardeoPlugin } from "./auth/authprovider";
30+
31+
const app = createApp(App);
32+
33+
app.use(router);
34+
app.use(asgardeoPlugin, {
35+
signInRedirectURL: "http://localhost:5173/",
36+
signOutRedirectURL: "http://localhost:5173/",
37+
clientID: "<ADD_CLIENT_ID_HERE>",
38+
baseUrl: "https://api.asgardeo.io/t/<org_name>",
39+
});
40+
41+
app.mount("#app");
42+
```
43+
44+
### Run the Application
45+
46+
```bash
47+
npm install && npm run dev
48+
```
49+
50+
The app should open at [`http://localhost:5173`](http://localhost:5173)
51+
52+
### Change the Application's Development Server Port
53+
54+
By default, the Vite development server runs on port `5173`. In case you wish to change this to something else, follow the steps below.
55+
56+
1. Update the port in your Vite configuration file (`vite.config.js` or `vite.config.ts`):
57+
```javascript
58+
export default defineConfig({
59+
// Other config options...
60+
server: {
61+
port: YOUR_PREFERRED_PORT
62+
}
63+
})
64+
```
65+
66+
2. Update the `signInRedirectURL` & `signOutRedirectURL` in `main.ts` to match your new port.
67+
68+
3. Go to the Asgardeo Console and navigate to the protocol tab of your application:
69+
- Update the Authorized Redirect URL.
70+
- Update the Allowed Origins.
71+
72+
## Using the Auth Plugin
73+
74+
The Asgardeo Auth plugin is available throughout your Vue application. Here's how to use it in your components:
75+
76+
```vue
77+
<script setup>
78+
import { useAsgardeo } from '@asgardeo/vue';
79+
80+
const { isAuthenticated, signIn, signOut, getBasicUserInfo } = useAsgardeo();
81+
</script>
82+
83+
<template>
84+
<div>
85+
<button v-if="!isAuthenticated" @click="signIn">Login</button>
86+
<button v-else @click="signOut">Logout</button>
87+
</div>
88+
</template>
89+
```
90+
91+
//TODO
92+
93+
## Contribute
94+
95+
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.
96+
97+
### Reporting Issues
98+
99+
We encourage you to report issues, improvements, and feature requests by creating [Github Issues](https://github.com/asgardeo/web-ui-sdks/issues).
100+
101+
Important: Please be advised that security issues must be reported to [email protected], 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.
102+
103+
## License
104+
105+
This project is licensed under the Apache License 2.0. See the [LICENSE](../../LICENSE) file for details.

recipes/vue-vite/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

recipes/vue-vite/eslint.config.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import pluginVue from 'eslint-plugin-vue'
20+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
21+
import pluginVitest from '@vitest/eslint-plugin'
22+
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
23+
24+
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
25+
// import { configureVueProject } from '@vue/eslint-config-typescript'
26+
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
27+
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
28+
29+
export default defineConfigWithVueTs(
30+
{
31+
name: 'app/files-to-lint',
32+
files: ['**/*.{ts,mts,tsx,vue}'],
33+
},
34+
{
35+
name: 'app/files-to-ignore',
36+
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
37+
},
38+
pluginVue.configs['flat/essential'],
39+
vueTsConfigs.recommended,
40+
{
41+
...pluginVitest.configs.recommended,
42+
files: ['src/**/__tests__/*'],
43+
},
44+
skipFormatting,
45+
)

recipes/vue-vite/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
-->
18+
19+
<!doctype html>
20+
<html lang="">
21+
<head>
22+
<meta charset="UTF-8" />
23+
<link rel="icon" href="/favicon.ico" />
24+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
25+
<title>Vue Sample</title>
26+
</head>
27+
<body>
28+
<div id="app"></div>
29+
<script type="module" src="/src/main.ts"></script>
30+
</body>
31+
</html>

0 commit comments

Comments
 (0)