@adobe/helix-onedrive-support 10.2.2 → 10.3.0

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.
@@ -2,7 +2,7 @@ version: 2.1
2
2
  executors:
3
3
  node18:
4
4
  docker:
5
- - image: cimg/node:18.16
5
+ - image: cimg/node:18.17
6
6
 
7
7
  orbs:
8
8
  codecov: codecov/codecov@3.2.5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [10.3.0](https://github.com/adobe/helix-onedrive-support/compare/v10.2.2...v10.3.0) (2023-07-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * cacheplugin can suggest auth via client credentials ([#411](https://github.com/adobe/helix-onedrive-support/issues/411)) ([bd1d02a](https://github.com/adobe/helix-onedrive-support/commit/bd1d02a99550262a26caf1a0a34de555482401a3))
7
+
1
8
  ## [10.2.2](https://github.com/adobe/helix-onedrive-support/compare/v10.2.1...v10.2.2) (2023-07-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-onedrive-support",
3
- "version": "10.2.2",
3
+ "version": "10.3.0",
4
4
  "description": "Helix OneDrive Support",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -28,7 +28,7 @@
28
28
  "homepage": "https://github.com/adobe/helix-onedrive-support#readme",
29
29
  "dependencies": {
30
30
  "@adobe/fetch": "4.0.13",
31
- "@adobe/helix-shared-tokencache": "1.2.10",
31
+ "@adobe/helix-shared-tokencache": "1.3.0",
32
32
  "@azure/msal-node": "1.18.0",
33
33
  "jose": "4.14.4"
34
34
  },
@@ -36,7 +36,7 @@
36
36
  "@adobe/eslint-config-helix": "2.0.2",
37
37
  "@semantic-release/changelog": "6.0.3",
38
38
  "@semantic-release/git": "10.0.1",
39
- "@aws-sdk/client-s3": "3.370.0",
39
+ "@aws-sdk/client-s3": "3.374.0",
40
40
  "ajv": "8.12.0",
41
41
  "c8": "8.0.0",
42
42
  "codecov": "3.8.3",
@@ -53,7 +53,7 @@
53
53
  "mocha": "10.2.0",
54
54
  "mocha-multi-reporters": "1.5.1",
55
55
  "nock": "13.3.2",
56
- "npm": "9.8.0",
56
+ "npm": "9.8.1",
57
57
  "semantic-release": "21.0.7"
58
58
  },
59
59
  "lint-staged": {
@@ -9,7 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import {AuthenticationResult, ClientApplication, ICachePlugin} from "@azure/msal-node";
12
+ import {AuthenticationResult, ClientApplication } from "@azure/msal-node";
13
+ import { CachePlugin } from "@adobe/helix-shared-tokencache";
13
14
 
14
15
  export enum AcquireMethod {
15
16
  BY_CLIENT_CREDENTIAL = 'byClientCredential',
@@ -30,7 +31,7 @@ export declare interface OneDriveAuthOptions {
30
31
  /**
31
32
  * use cache plugin instead for default (global) token cache.
32
33
  */
33
- cachePlugin?: ICachePlugin,
34
+ cachePlugin?: CachePlugin,
34
35
 
35
36
  /**
36
37
  * Disables the cache for the tenant lookup.
@@ -82,7 +82,7 @@ export class OneDriveAuth {
82
82
  throw new Error(`Authentication method unknown: ${this.acquireMethod}, should be none or one of: ${validAcquireMethods}`);
83
83
  }
84
84
  if (this.acquireMethod === AcquireMethod.BY_DEVICE_CODE && !this.onCode) {
85
- throw new Error(`Authontication method ${AcquireMethod.BY_DEVICE_CODE} requires 'onCode' parameter`);
85
+ throw new Error(`Authentication method ${AcquireMethod.BY_DEVICE_CODE} requires 'onCode' parameter`);
86
86
  }
87
87
  if (!this.acquireMethod && this.onCode) {
88
88
  this.acquireMethod = AcquireMethod.BY_DEVICE_CODE;
@@ -133,7 +133,7 @@ export class OneDriveAuth {
133
133
  cachePlugin,
134
134
  };
135
135
  }
136
- this._app = this.onCode
136
+ this._app = this.acquireMethod === AcquireMethod.BY_DEVICE_CODE
137
137
  ? new PublicClientApplication(msalConfig)
138
138
  : new ConfidentialClientApplication(msalConfig);
139
139
  }
@@ -328,7 +328,9 @@ export class OneDriveAuth {
328
328
  scopes: this.scopes,
329
329
  });
330
330
  }
331
- if (this.acquireMethod === AcquireMethod.BY_CLIENT_CREDENTIAL) {
331
+ if (this.acquireMethod === AcquireMethod.BY_CLIENT_CREDENTIAL
332
+ // check if plugin wants us to use client credentials
333
+ || (await this.cachePlugin.getPluginMetadata() || {}).useClientCredentials) {
332
334
  log.debug('acquire token with client credentials.');
333
335
  return await app.acquireTokenByClientCredential({
334
336
  scopes: this.scopes,