@adobe/helix-onedrive-support 6.1.5 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/semantic-release.yaml +1 -1
- package/.nycrc.json +3 -3
- package/CHANGELOG.md +21 -0
- package/package.json +5 -5
- package/src/OneDrive.js +12 -18
- package/src/SharePointSite.js +1 -10
package/.nycrc.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [6.2.2](https://github.com/adobe/helix-onedrive-support/compare/v6.2.1...v6.2.2) (2022-03-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-fetch to v3.0.7 ([15f9380](https://github.com/adobe/helix-onedrive-support/commit/15f9380b04d28a68b1e39be38c8c913a0cf48fec))
|
|
7
|
+
|
|
8
|
+
## [6.2.1](https://github.com/adobe/helix-onedrive-support/compare/v6.2.0...v6.2.1) (2022-03-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use http1 for ms access ([#251](https://github.com/adobe/helix-onedrive-support/issues/251)) ([c91a629](https://github.com/adobe/helix-onedrive-support/commit/c91a629fa8c18c0dcdb2a0d21a225de940db05ea)), closes [#250](https://github.com/adobe/helix-onedrive-support/issues/250)
|
|
14
|
+
|
|
15
|
+
# [6.2.0](https://github.com/adobe/helix-onedrive-support/compare/v6.1.5...v6.2.0) (2022-03-01)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* allow to set authentication resource ([#246](https://github.com/adobe/helix-onedrive-support/issues/246)) ([21d7445](https://github.com/adobe/helix-onedrive-support/commit/21d7445736bfe7452b710187cc81e71b37df8542))
|
|
21
|
+
|
|
1
22
|
## [6.1.5](https://github.com/adobe/helix-onedrive-support/compare/v6.1.4...v6.1.5) (2022-02-28)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-onedrive-support",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "Helix OneDrive Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/adobe/helix-onedrive-support#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@adobe/helix-fetch": "3.0.
|
|
26
|
+
"@adobe/helix-fetch": "3.0.7",
|
|
27
27
|
"adal-node": "https://github.com/adobe-rnd/azure-activedirectory-library-for-nodejs.git#adobe"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"commitizen": "4.2.4",
|
|
36
36
|
"cz-conventional-changelog": "3.3.0",
|
|
37
37
|
"dotenv": "16.0.0",
|
|
38
|
-
"eslint": "8.
|
|
38
|
+
"eslint": "8.11.0",
|
|
39
39
|
"eslint-plugin-header": "3.1.1",
|
|
40
40
|
"eslint-plugin-import": "2.25.4",
|
|
41
41
|
"jsdoc-to-markdown": "7.1.1",
|
|
42
42
|
"junit-report-builder": "3.0.0",
|
|
43
|
-
"lint-staged": "12.3.
|
|
44
|
-
"mocha": "9.2.
|
|
43
|
+
"lint-staged": "12.3.7",
|
|
44
|
+
"mocha": "9.2.2",
|
|
45
45
|
"mocha-multi-reporters": "1.5.1",
|
|
46
46
|
"nock": "13.2.4",
|
|
47
47
|
"nyc": "15.1.0",
|
package/src/OneDrive.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
const EventEmitter = require('events');
|
|
15
15
|
const { promisify } = require('util');
|
|
16
16
|
const { AuthenticationContext, MemoryCache } = require('adal-node');
|
|
17
|
-
const
|
|
17
|
+
const { fetch, reset } = require('@adobe/helix-fetch').keepAliveNoCache({ userAgent: 'helix-fetch' });
|
|
18
18
|
|
|
19
19
|
const Workbook = require('./Workbook.js');
|
|
20
20
|
const StatusCodeError = require('./StatusCodeError.js');
|
|
@@ -22,16 +22,8 @@ const { driveItemFromURL, driveItemToURL } = require('./utils.js');
|
|
|
22
22
|
const { splitByExtension, sanitize, editDistance } = require('./fuzzy-helper.js');
|
|
23
23
|
const SharePointSite = require('./SharePointSite.js');
|
|
24
24
|
|
|
25
|
-
const { fetch, reset } = process.env.HELIX_FETCH_FORCE_HTTP1
|
|
26
|
-
? fetchAPI.context({
|
|
27
|
-
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
|
|
28
|
-
userAgent: 'helix-fetch', // static user agent for test recordings
|
|
29
|
-
})
|
|
30
|
-
/* istanbul ignore next */
|
|
31
|
-
: fetchAPI;
|
|
32
|
-
|
|
33
25
|
const AZ_AUTHORITY_HOST_URL = 'https://login.windows.net';
|
|
34
|
-
const
|
|
26
|
+
const AZ_DEFAULT_RESOURCE = 'https://graph.microsoft.com'; // '00000002-0000-0000-c000-000000000000'; ??
|
|
35
27
|
const AZ_DEFAULT_TENANT = 'common';
|
|
36
28
|
|
|
37
29
|
/**
|
|
@@ -65,6 +57,7 @@ class OneDrive extends EventEmitter {
|
|
|
65
57
|
* @param {number} [opts.expiresOn] Expiration time.
|
|
66
58
|
* @param {Logger} [opts.log] A logger.
|
|
67
59
|
* @param {boolean} [opts.localAuthCache] Whether to use local auth cache
|
|
60
|
+
* @param {string} [opts.resource] Azure resource to authenticate against. defaults to MS Graph.
|
|
68
61
|
*/
|
|
69
62
|
constructor(opts) {
|
|
70
63
|
super(opts);
|
|
@@ -75,6 +68,7 @@ class OneDrive extends EventEmitter {
|
|
|
75
68
|
this.password = opts.password || '';
|
|
76
69
|
this._log = opts.log || console;
|
|
77
70
|
this.tenant = opts.tenant || AZ_DEFAULT_TENANT;
|
|
71
|
+
this.resource = opts.resource || AZ_DEFAULT_RESOURCE;
|
|
78
72
|
|
|
79
73
|
if (!opts.noShareLinkCache && !process.env.HELIX_ONEDRIVE_NO_SHARE_LINK_CACHE) {
|
|
80
74
|
this.shareLinkCache = opts.shareLinkCache || globalShareLinkCache;
|
|
@@ -168,7 +162,7 @@ class OneDrive extends EventEmitter {
|
|
|
168
162
|
|
|
169
163
|
let code;
|
|
170
164
|
try {
|
|
171
|
-
code = await context.acquireUserCode(
|
|
165
|
+
code = await context.acquireUserCode(this.resource, this.clientId, 'en');
|
|
172
166
|
} catch (e) {
|
|
173
167
|
log.error('Error while requesting user code', e);
|
|
174
168
|
throw e;
|
|
@@ -180,7 +174,7 @@ class OneDrive extends EventEmitter {
|
|
|
180
174
|
}
|
|
181
175
|
|
|
182
176
|
try {
|
|
183
|
-
return await context.acquireTokenWithDeviceCode(
|
|
177
|
+
return await context.acquireTokenWithDeviceCode(this.resource, this.clientId, code);
|
|
184
178
|
} catch (e) {
|
|
185
179
|
log.error('Error while requesting access token with device code', e);
|
|
186
180
|
throw e;
|
|
@@ -192,7 +186,7 @@ class OneDrive extends EventEmitter {
|
|
|
192
186
|
async getAccessToken() {
|
|
193
187
|
const { log, authContext: context } = this;
|
|
194
188
|
try {
|
|
195
|
-
return await context.acquireToken(
|
|
189
|
+
return await context.acquireToken(this.resource, this.username, this.clientId);
|
|
196
190
|
} catch (e) {
|
|
197
191
|
if (e.message !== 'Entry not found in cache.') {
|
|
198
192
|
log.warn(`Unable to acquire token from cache: ${e}`);
|
|
@@ -208,13 +202,13 @@ class OneDrive extends EventEmitter {
|
|
|
208
202
|
this.refreshToken,
|
|
209
203
|
this.clientId,
|
|
210
204
|
this.clientSecret,
|
|
211
|
-
|
|
205
|
+
this.resource,
|
|
212
206
|
);
|
|
213
207
|
return await this.augmentAndCacheResponse(resp);
|
|
214
208
|
} else if (this.username && this.password) {
|
|
215
209
|
log.debug('acquire token with ROPC.');
|
|
216
210
|
return await context.acquireTokenWithUsernamePassword(
|
|
217
|
-
|
|
211
|
+
this.resource,
|
|
218
212
|
this.username,
|
|
219
213
|
this.password,
|
|
220
214
|
this.clientId,
|
|
@@ -222,7 +216,7 @@ class OneDrive extends EventEmitter {
|
|
|
222
216
|
} else if (this.clientSecret) {
|
|
223
217
|
log.debug('acquire token with client credentials.');
|
|
224
218
|
return await context.acquireTokenWithClientCredentials(
|
|
225
|
-
|
|
219
|
+
this.resource,
|
|
226
220
|
this.clientId,
|
|
227
221
|
this.clientSecret,
|
|
228
222
|
);
|
|
@@ -240,7 +234,7 @@ class OneDrive extends EventEmitter {
|
|
|
240
234
|
/**
|
|
241
235
|
*/
|
|
242
236
|
createLoginUrl(redirectUri, state) {
|
|
243
|
-
return `${this.authorityUrl}/oauth2/authorize?response_type=code&scope=/.default&client_id=${this.clientId}&redirect_uri=${redirectUri}&state=${state}&resource=${
|
|
237
|
+
return `${this.authorityUrl}/oauth2/authorize?response_type=code&scope=/.default&client_id=${this.clientId}&redirect_uri=${redirectUri}&state=${state}&resource=${this.resource}`;
|
|
244
238
|
}
|
|
245
239
|
|
|
246
240
|
async augmentAndCacheResponse(response) {
|
|
@@ -270,7 +264,7 @@ class OneDrive extends EventEmitter {
|
|
|
270
264
|
const resp = await context.acquireTokenWithAuthorizationCode(
|
|
271
265
|
code,
|
|
272
266
|
redirectUri,
|
|
273
|
-
|
|
267
|
+
this.resource,
|
|
274
268
|
this.clientId,
|
|
275
269
|
this.clientSecret,
|
|
276
270
|
);
|
package/src/SharePointSite.js
CHANGED
|
@@ -10,18 +10,9 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const { fetch } = require('@adobe/helix-fetch').keepAliveNoCache({ userAgent: 'helix-fetch' });
|
|
14
14
|
const StatusCodeError = require('./StatusCodeError.js');
|
|
15
15
|
|
|
16
|
-
/* istanbul ignore next */
|
|
17
|
-
const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
|
|
18
|
-
? fetchAPI.context({
|
|
19
|
-
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
|
|
20
|
-
userAgent: 'helix-fetch', // static user agent for test recordings
|
|
21
|
-
})
|
|
22
|
-
/* istanbul ignore next */
|
|
23
|
-
: fetchAPI;
|
|
24
|
-
|
|
25
16
|
/**
|
|
26
17
|
* Helper class accessing folders and files using the SharePoint V1 API.
|
|
27
18
|
*/
|