Repository: stripe/stripe-node
Pull request #662 (2019-07-25 04:22:22)

Remove `safe-buffer` dependency
`safe-buffer` does nothing when native `Buffer.from` API is available and it's available since Nodes.JS 5.10 (https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_array), so, there is no sense to bring it as production dependency (one of four) when your declared minimum supported Node.JS version is 6.x.

brandur-stripe: Thanks @tinovyatkin!

@rattrayalex-stripe Want to take a quick look to confirm this one? The [safe-buffer](https://www.npmjs.com/package/safe-buffer) project page seems to confirm that it's indeed safe to remove.
rattrayalex-stripe: Gave everything a quick look and it does indeed seem this is safe. 

Thanks so much @tinovyatkin !

Patch:
diff --git a/lib/MultipartDataGenerator.js b/lib/MultipartDataGenerator.js
index 76b8cb29..9c819bd7 100644
--- a/lib/MultipartDataGenerator.js
+++ b/lib/MultipartDataGenerator.js
@@ -1,6 +1,5 @@
 'use strict';
 
-const Buffer = require('safe-buffer').Buffer;
 const utils = require('./utils');
 
 // Method for formatting HTTP body for the multipart/form-data specification
diff --git a/lib/Webhooks.js b/lib/Webhooks.js
index cb5a45a4..892e0ae2 100644
--- a/lib/Webhooks.js
+++ b/lib/Webhooks.js
@@ -1,6 +1,5 @@
 'use strict';
 
-const Buffer = require('safe-buffer').Buffer;
 const crypto = require('crypto');
 
 const utils = require('./utils');
diff --git a/lib/resources/Files.js b/lib/resources/Files.js
index 424475c0..d2541b8e 100644
--- a/lib/resources/Files.js
+++ b/lib/resources/Files.js
@@ -1,6 +1,5 @@
 'use strict';
 
-const Buffer = require('safe-buffer').Buffer;
 const utils = require('../utils');
 const multipartDataGenerator = require('../MultipartDataGenerator');
 const Error = require('../Error');
diff --git a/lib/utils.js b/lib/utils.js
index 4bbccd90..96b24987 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -1,6 +1,5 @@
 'use strict';
 
-const Buffer = require('safe-buffer').Buffer;
 const EventEmitter = require('events').EventEmitter;
 const exec = require('child_process').exec;
 const qs = require('qs');
diff --git a/package.json b/package.json
index 8db2e321..d63c89f4 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,6 @@
   "dependencies": {
     "lodash.isplainobject": "^4.0.6",
     "qs": "^6.6.0",
-    "safe-buffer": "^5.1.1",
     "uuid": "^3.3.2"
   },
   "license": "MIT",
diff --git a/yarn.lock b/yarn.lock
index 7f942287..de84b5f9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1869,7 +1869,7 @@ rxjs@^6.4.0:
   dependencies:
     tslib "^1.9.0"
 
-safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.1:
+safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.1.1:
   version "5.1.2"
   resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
   integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==


Test patch:
diff --git a/test/Webhook.spec.js b/test/Webhook.spec.js
index f1f1c089..2a3a9d71 100644
--- a/test/Webhook.spec.js
+++ b/test/Webhook.spec.js
@@ -2,7 +2,6 @@
 
 const stripe = require('../testUtils').getSpyableStripe();
 const expect = require('chai').expect;
-const Buffer = require('safe-buffer').Buffer;
 
 const EVENT_PAYLOAD = {
   id: 'evt_test_webhook',
diff --git a/test/utils.spec.js b/test/utils.spec.js
index 8f8fd8ab..0582fdd0 100644
--- a/test/utils.spec.js
+++ b/test/utils.spec.js
@@ -4,7 +4,6 @@ require('../testUtils');
 
 const utils = require('../lib/utils');
 const expect = require('chai').expect;
-const Buffer = require('safe-buffer').Buffer;
 
 describe('utils', () => {
   describe('makeURLInterpolator', () => {