Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript support #23

Closed
vargaadam opened this issue May 20, 2019 · 6 comments
Closed

TypeScript support #23

vargaadam opened this issue May 20, 2019 · 6 comments
Labels
question Further information is requested

Comments

@vargaadam
Copy link

Hi,

Are you planning to add TypeScript support in the future?

Thanks!

@nlien
Copy link
Contributor

nlien commented May 20, 2019

It's not something we currently have considered, so the short answer is 'no'.
But we're happy to receive PR's 😉

@nlien nlien closed this as completed May 20, 2019
@nlien nlien added the question Further information is requested label May 20, 2019
@razbakov
Copy link

That would be very useful. Would you accept PR or should I create definition in separate repository?

  import { PluginObject, PluginFunction } from 'vue'

  export class VueKeyCloakInstance {
    ready: boolean;              // Flag indicating whether Keycloak has initialised and is ready
    authenticated: boolean;
    userName: string;            // Username from Keycloak. Collected from tokenParsed['preferred_username']
    fullName: string;            // Full name from Keycloak. Collected from tokenParsed['name']
    login: Function;             // [Keycloak] login function
    loginFn: Function;           // Alias for login
    logoutFn: Function;          // Keycloak logout function
    createLoginUrl: Function;    // Keycloak createLoginUrl function
    createLogoutUrl: Function;   // Keycloak createLogoutUrl function
    createRegisterUrl: Function; // Keycloak createRegisterUrl function
    register: Function;          // Keycloak register function
    accountManagement: Function; // Keycloak accountManagement function
    createAccountUrl: Function;  // Keycloak createAccountUrl function
    loadUserProfile: Function;   // Keycloak loadUserProfile function
    loadUserInfo: Function;      // Keycloak loadUserInfo function
    subject: string;             // The user id
    idToken: string;             // The base64 encoded ID token.
    idTokenParsed: object;       // The parsed id token as a JavaScript object.
    realmAccess: object;         // The realm roles associated with the token.
    resourceAccess: object;      // The resource roles associated with the token.
    refreshToken: string;        // The base64 encoded refresh token that can be used to retrieve a new token.
    refreshTokenParsed: object;  // The parsed refresh token as a JavaScript object.
    timeSkew: number;            // The estimated time difference between the browser time and the Keycloak server in seconds. This value is just an estimation, but is accurate enough when determining if a token is expired or not.
    responseMode: string;        // Response mode passed in init (default value is fragment).
    responseType: string;        // Response type sent to Keycloak with login requests. This is determined based on the flow value used during initialization, but can be overridden by setting this value.
    hasRealmRole: Function;      // Keycloak hasRealmRole function
    hasResourceRole: Function;   // Keycloak hasResourceRole function
    token: string;               // The base64 encoded token that can be sent in the Authorization header in requests to services
    tokenParsed: string;         // The parsed token as a JavaScript object
  }

  export type VueKeyCloakOptions = {
    config?: {
      authUrl?: string;
      authRealm?: string;
      authClientId?: string;
      logoutRedirectUri?: string;
    };
    init?: {
      onLoad: string;
    };
    onReady(keycloak: VueKeyCloakInstance): void;
  }
  export class VueKeyCloak implements PluginObject<VueKeyCloakOptions> {
    install: PluginFunction<VueKeyCloakOptions>;
    static install(pVue: typeof Vue, options?:VueKeyCloakOptions | undefined): void;

    constructor(options: VueKeyCloakOptions);
  }

@nlien
Copy link
Contributor

nlien commented Sep 5, 2019

Please feel free to submit a PR

@lukaslaskovski
Copy link

That would be very useful. Would you accept PR or should I create definition in separate repository?

  import { PluginObject, PluginFunction } from 'vue'

  export class VueKeyCloakInstance {
    ready: boolean;              // Flag indicating whether Keycloak has initialised and is ready
    authenticated: boolean;
    userName: string;            // Username from Keycloak. Collected from tokenParsed['preferred_username']
    fullName: string;            // Full name from Keycloak. Collected from tokenParsed['name']
    login: Function;             // [Keycloak] login function
    loginFn: Function;           // Alias for login
    logoutFn: Function;          // Keycloak logout function
    createLoginUrl: Function;    // Keycloak createLoginUrl function
    createLogoutUrl: Function;   // Keycloak createLogoutUrl function
    createRegisterUrl: Function; // Keycloak createRegisterUrl function
    register: Function;          // Keycloak register function
    accountManagement: Function; // Keycloak accountManagement function
    createAccountUrl: Function;  // Keycloak createAccountUrl function
    loadUserProfile: Function;   // Keycloak loadUserProfile function
    loadUserInfo: Function;      // Keycloak loadUserInfo function
    subject: string;             // The user id
    idToken: string;             // The base64 encoded ID token.
    idTokenParsed: object;       // The parsed id token as a JavaScript object.
    realmAccess: object;         // The realm roles associated with the token.
    resourceAccess: object;      // The resource roles associated with the token.
    refreshToken: string;        // The base64 encoded refresh token that can be used to retrieve a new token.
    refreshTokenParsed: object;  // The parsed refresh token as a JavaScript object.
    timeSkew: number;            // The estimated time difference between the browser time and the Keycloak server in seconds. This value is just an estimation, but is accurate enough when determining if a token is expired or not.
    responseMode: string;        // Response mode passed in init (default value is fragment).
    responseType: string;        // Response type sent to Keycloak with login requests. This is determined based on the flow value used during initialization, but can be overridden by setting this value.
    hasRealmRole: Function;      // Keycloak hasRealmRole function
    hasResourceRole: Function;   // Keycloak hasResourceRole function
    token: string;               // The base64 encoded token that can be sent in the Authorization header in requests to services
    tokenParsed: string;         // The parsed token as a JavaScript object
  }

  export type VueKeyCloakOptions = {
    config?: {
      authUrl?: string;
      authRealm?: string;
      authClientId?: string;
      logoutRedirectUri?: string;
    };
    init?: {
      onLoad: string;
    };
    onReady(keycloak: VueKeyCloakInstance): void;
  }
  export class VueKeyCloak implements PluginObject<VueKeyCloakOptions> {
    install: PluginFunction<VueKeyCloakOptions>;
    static install(pVue: typeof Vue, options?:VueKeyCloakOptions | undefined): void;

    constructor(options: VueKeyCloakOptions);
  }

Did you make PR anywhere ? I need TS support too :)

@razbakov
Copy link

@lukaslaskovski here is PR, but I haven't work with TypeScript for multiple months already, so I am not quite sure if it will work out of the box. Please check if it works.

@lukaslaskovski
Copy link

@nlien @anderius Can this PR (#64 ) be merged ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

Successfully merging a pull request may close this issue.

4 participants