Cli-microsoft365: Fix Nodejs 10x `Buffer()` deprication warning

Created on 16 Aug 2019  路  8Comments  路  Source: pnp/cli-microsoft365

When I run command using the CLI with Nodejs 10.x, I get the following message:

C:\p\office365-cli (orgassets-list -> origin) (@pnp/[email protected])
位 o365 spo orgassetslibrary list --debug
(node:7184) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Expected:

  • No deprecation warnings
bug pr-merged

Most helpful comment

The reason this issue is visible only on Windows is because we're using the deprecated call in the WindowsTokenStorage, here:

https://github.com/pnp/office365-cli/blob/5e0d6efa37b3b0478a0de13bcf7df5319eeced8a/src/auth/WindowsTokenStorage.ts#L100

and here:

https://github.com/pnp/office365-cli/blob/5e0d6efa37b3b0478a0de13bcf7df5319eeced8a/src/auth/WindowsTokenStorage.ts#L134

I'll try to get it fixed before we ship v2.

All 8 comments

@VelinGeorgiev is this coming from a feature branch? It seems that the dev branch doesn't have this command.

That alers pops on every commamd. Try o365 login and you'll get it if you use Nodejs10

I ran o365 login on Node 10.15.3 and didn't get the warning.

Well we have to see where in the solution use Buffer() and change it to Buffer.alloc() || Buffer()

I'm not sure if we use it in our code at all. I suspect our downstream dependencies, but let's have another look to get a solid repro case.

I can see the issue when running the CLI in Node v10.16.3 on Windows.

The reason this issue is visible only on Windows is because we're using the deprecated call in the WindowsTokenStorage, here:

https://github.com/pnp/office365-cli/blob/5e0d6efa37b3b0478a0de13bcf7df5319eeced8a/src/auth/WindowsTokenStorage.ts#L100

and here:

https://github.com/pnp/office365-cli/blob/5e0d6efa37b3b0478a0de13bcf7df5319eeced8a/src/auth/WindowsTokenStorage.ts#L134

I'll try to get it fixed before we ship v2.

Merged manually. Thanks!

Was this page helpful?
0 / 5 - 0 ratings