mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 17:51:46 +00:00
Add definitions for okta-vue
This commit is contained in:
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for okta-vue 1.0
|
||||
// Project: https://github.com/okta/okta-oidc-js/tree/master/packages/okta-vue
|
||||
// Definitions by: Mike Dodge <https://github.com/innovation-team>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { VueConstructor, PluginFunction } from 'vue';
|
||||
import { NavigationGuard } from 'vue-router';
|
||||
|
||||
export interface OktaVueOptions {
|
||||
issuer: string;
|
||||
client_id: string;
|
||||
redirect_uri: string;
|
||||
scope: string;
|
||||
}
|
||||
export function OktaVuePlugin(vm: VueConstructor, options: OktaVueOptions): void;
|
||||
export namespace OktaVuePlugin {
|
||||
function handleCallback(): VueConstructor;
|
||||
}
|
||||
export default OktaVuePlugin;
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
$auth: {
|
||||
loginRedirect(): void;
|
||||
logout(): Promise<void>;
|
||||
isAuthenticated(): Promise<boolean>;
|
||||
handleAuthentication(): Promise<void>;
|
||||
getFromUri(): string;
|
||||
getIdToken(): Promise<string>;
|
||||
getAccessToken(): Promise<string>;
|
||||
getUser(): Promise<any>;
|
||||
authRedirectGuardd(): Promise<NavigationGuard>;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
import Auth from 'okta__okta-vue';
|
||||
|
||||
Vue.use(Auth, {
|
||||
issuer: 'https://{yourOktaDomain}.com/oauth2/default',
|
||||
client_id: '{client_id}',
|
||||
redirect_uri: 'http://localhost:{port}/implicit/callback',
|
||||
scope: 'openid profile email'
|
||||
});
|
||||
|
||||
Vue.use(Router);
|
||||
const router = new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{ path: '/implicit/callback', component: Auth.handleCallback() },
|
||||
{
|
||||
path: '/protected',
|
||||
component: {
|
||||
name: 'protected',
|
||||
template: '<div>Protected Route</div>'
|
||||
},
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
const redirectGuard = Vue.prototype.$auth.authRedirectGuard();
|
||||
router.beforeEach(redirectGuard);
|
||||
|
||||
const component = Vue.extend({
|
||||
mounted() {
|
||||
const authd = this.$auth.isAuthenticated();
|
||||
const userInfo = this.$auth.getUser();
|
||||
const handleAuth = this.$auth.handleAuthentication();
|
||||
const path = this.$auth.getFromUri();
|
||||
const idToken = this.$auth.getIdToken();
|
||||
const accessToken = this.$auth.getAccessToken();
|
||||
},
|
||||
methods: {
|
||||
logout() {
|
||||
const logoutPromise = this.$auth.logout();
|
||||
},
|
||||
redirect() {
|
||||
this.$auth.loginRedirect();
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"vue": "^2.5.9",
|
||||
"vue-router": "^3.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"okta__okta-vue-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user