Angular-auth-oidc-client: Buffer is not defined

Created on 2 Aug 2018  路  6Comments  路  Source: damienbod/angular-auth-oidc-client

Hello,

Since I last dropped my node_modules and reinstalled them, an error appeared:

Buffer is not defined

In /modules/angular-auth-oidc-client.es5.js TokenHelperService.urlBase64Decode

The "compiled" code is the following:

    TokenHelperService.prototype.urlBase64Decode = function (str) {
        var /** @type {?} */ output = str.replace('-', '+').replace('_', '/');
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += '==';
                break;
            case 3:
                output += '=';
                break;
            default:
                throw Error('Illegal base64url string!');
        }
        return new Buffer(output, 'base64').toString('binary');
    };

But went I look at the source code, I see :

    urlBase64Decode(str: string) {
        let output = str.replace('-', '+').replace('_', '/');
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += '==';
                break;
            case 3:
                output += '=';
                break;
            default:
                throw Error('Illegal base64url string!');
        }

        return typeof window !== 'undefined' ? window.atob(output) : new Buffer(output, 'base64').toString('binary');
    }

I assume there is a release/publish problem, the package on npm not being the latest version ?

Best regards

bug

Most helpful comment

@damienbod

Ran a test using 6.0.5, it appears to be working as of now. I also changed my package to use ^6.0.0 and all is still well. Thanks for the prompt response.

All 6 comments

I am also having this issue. It appears it was introduced in version 6.0.3. To help with the problem for now I updated my package.json to specify the following: "angular-auth-oidc-client": "6.0.2". This works for now.

@bereachad sorry, will fix this now. What browser are you using? I tested with the latest Edge, Firefox, Chrome versions.

@damienbod I tested in chrome, I am getting issues where it is stating that buffer is not defined when using version 6.0.3. If you want I can recreate issue locally and give you exact console output.

@bereachad, @Booster2ooo Thanks, I made a version 6.0.5 which should fix this, could you test this?

If this does not work, I will have to roll back the changes for the SSR support, which added this buffer change.

I will test later tonight.

Thanks Damien

@damienbod

Ran a test using 6.0.5, it appears to be working as of now. I also changed my package to use ^6.0.0 and all is still well. Thanks for the prompt response.

@Booster2ooo @bereachad

Thanks for reporting.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daudihusbands picture daudihusbands  路  3Comments

brentos99 picture brentos99  路  4Comments

jhossy picture jhossy  路  4Comments

Jonesie picture Jonesie  路  4Comments

haidelber picture haidelber  路  3Comments