Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/javascript/PKCE-backend/code_flow_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// On the server logs, you should have the auth code, as well as the token
// from exchanging it. This exchange is invisible to the app user

const fetch = require('node-fetch');
function fetch(...args) {
// eslint-disable-next-line no-new-func
return new Function("return import('node-fetch')")().then((mod) => mod.default(...args));
}
const app = require('express')();

const hostname = 'localhost';
Expand Down
5 changes: 4 additions & 1 deletion examples/javascript/simple-backend/code_flow_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// On the server logs, you should have the auth code, as well as the token
// from exchanging it. This exchange is invisible to the app user

const fetch = require('node-fetch');
function fetch(...args) {
// eslint-disable-next-line no-new-func
return new Function("return import('node-fetch')")().then((mod) => mod.default(...args));
}
const app = require('express')();

const hostname = 'localhost';
Expand Down
12,842 changes: 12,801 additions & 41 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"@babel/register": "^7.11.5",
"@testing-library/dom": "^7.24.5",
"@types/node": "^14.11.2",
"@types/node-fetch": "^2.5.7",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^3.10.1",
"babel-plugin-istanbul": "^6.0.0",
Expand All @@ -104,10 +103,7 @@
"sinon": "^9.0.3",
"typescript": "^4.0.3"
},
"peerDependencies": {
"@types/node-fetch": "^2.5.7"
},
"dependencies": {
"node-fetch": "^2.6.1"
"node-fetch": "^3.1.0"
}
}
5 changes: 4 additions & 1 deletion src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ let fetch;
if (isBrowserEnv()) {
fetch = window.fetch.bind(window);
} else {
fetch = require('node-fetch'); // eslint-disable-line global-require
fetch = function (...args) {
// eslint-disable-next-line no-new-func
return new Function("return import('node-fetch')")().then((mod) => mod.default(...args));
};
}

let crypto;
Expand Down
5 changes: 4 additions & 1 deletion src/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ let fetch;
if (typeof window !== 'undefined') {
fetch = window.fetch.bind(window);
} else {
fetch = require('node-fetch'); // eslint-disable-line global-require
fetch = function (...args) {
// eslint-disable-next-line no-new-func
return new Function("return import('node-fetch')")().then((mod) => mod.default(...args));
};
}

const b64 = typeof btoa === 'undefined'
Expand Down
14 changes: 12 additions & 2 deletions test/unit/response.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { Response } from 'node-fetch';
import { httpHeaderSafeJson } from '../../src/utils';
import { httpHeaderSafeJson } from '../../src/utils.js';
import {
DropboxResponse,
parseResponse,
Expand All @@ -10,6 +9,17 @@ import {
import { DropboxResponseError } from '../../src/error.js';

chai.use(chaiAsPromised);

let Response;

before((done) => {
// eslint-disable-next-line no-new-func
new Function("return import('node-fetch')")().then((mod) => {
Response = mod.Response;
done();
});
});

describe('DropboxResponse', () => {
describe('Status', () => {
it('can be set in the constructor', () => {
Expand Down