aurelia-contrib / aurelia-open-id-connect

An aurelia adapter for the IdentityModel/oidc-client-js
https://zamboni-app.azurewebsites.net
MIT License
54 stars 18 forks source link

Converting to ES6 issue with userManagerSettings. #23

Closed chdev77 closed 7 years ago

chdev77 commented 7 years ago

Our project is using ES6 so my attempt at using the plugin is not going well. I keep getting this error no matter how I write the configuration. I've tried using typescript and I get the same issue.

Unhandled rejection TypeError: Cannot read property 'userManagerSettings' of undefined

Here is the open-id-connect-configuration.js I've created. While userManagerSettings is a TS interface, I don't understand why it's not seeing it correctly. It's probably obvious to some but I honestly have no idea what I'm doing wrong here. Many Thanks

import environment from "./environment";
import { OpenIdConnectConfiguration } from "aurelia-open-id-connect";
import { UserManagerSettings, WebStorageStateStore } from "oidc-client";

const oidcConfig = {
    loginRedirectModuleId: "home",
    logoutRedirectModuleId: "home",
    userManagerSettings: {
        // number of seconds in advance of access token expiry
        // to raise the access token expiring event
        accessTokenExpiringNotificationTime: 1,
        authority: environment.urls.authority,
        automaticSilentRenew: false, // true,
        //interval in milliseconds to check the user's session
        checkSessionInterval: 10000,
        client_id: "aurelia",
        filterProtocolClaims: true,
        loadUserInfo: false,
        post_logout_redirect_uri: `${environment.urls.host}/signout-oidc`,
        redirect_uri: `${environment.urls.host}/signin-oidc`,
        response_type: "id_token token",
        scope: "openid email roles profile",
        //number of millisecods to wait for the authorization
        // server to response to silent renew request
        silentRequestTimeout: 10000,
        silent_redirect_uri: `${environment.urls.host}/signin-oidc`,
        userStore: new WebStorageStateStore(w => {
            w.prefix = "oidc",
            w.store = window.localStorage
        })
    }
};

export default oidcConfig;
chdev77 commented 7 years ago

It was a newb issue....so this was my fix.

import environment from "./environment";
import { OpenIdConnectConfiguration } from "aurelia-open-id-connect";
import { UserManagerSettings, WebStorageStateStore } from "oidc-client";

export const oidcConfig = {
    loginRedirectModuleId: "home",
    logoutRedirectModuleId: "home",
    userManagerSettings: {
        // number of seconds in advance of access token expiry
        // to raise the access token expiring event
        accessTokenExpiringNotificationTime: 1,
        authority: environment.urls.authority,
        automaticSilentRenew: false, // true,
        //interval in milliseconds to check the user's session
        checkSessionInterval: 10000,
        client_id: "aurelia",
        filterProtocolClaims: true,
        loadUserInfo: false,
        post_logout_redirect_uri: `${environment.urls.host}/signout-oidc`,
        redirect_uri: `${environment.urls.host}/signin-oidc`,
        response_type: "id_token token",
        scope: "openid email roles profile",
        //number of millisecods to wait for the authorization
        // server to response to silent renew request
        silentRequestTimeout: 10000,
        silent_redirect_uri: `${environment.urls.host}/signin-oidc`,
        userStore: new WebStorageStateStore(w => {
            w.prefix = "oidc",
            w.store = window.localStorage
        })
    }
};