microsoft-graph-client 1.0.50 → 1.0.51

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.
@@ -1 +1 @@
1
- {"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../src/auth/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAuB;gBAErB,MAAM,EAAE,iBAAiB;IAI5C;;;OAGG;IACI,SAAS,IAAI,MAAM;IAc1B;;;OAGG;IACI,UAAU,IAAI,IAAI;CAG1B"}
1
+ {"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../src/auth/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAuB;gBAErB,MAAM,EAAE,iBAAiB;IAI5C;;;OAGG;IACI,SAAS,IAAI,MAAM;IAmB1B;;;OAGG;IACI,UAAU,IAAI,IAAI;CAG1B"}
@@ -1,4 +1,5 @@
1
1
  import { Client } from '@microsoft/microsoft-graph-client';
2
+ import { buildMiddlewareChain } from './middleware.js';
2
3
  /**
3
4
  * Authenticator handles Microsoft Graph authentication using a pre-obtained access token.
4
5
  *
@@ -19,10 +20,12 @@ export class Authenticator {
19
20
  return this.sdkClient;
20
21
  }
21
22
  const token = this.config.accessToken;
23
+ // An explicit chain, not `authProvider`: the SDK's default chain retries,
24
+ // and there is no flag to turn that off. See `buildMiddlewareChain`.
22
25
  this.sdkClient = Client.initWithMiddleware({
23
- authProvider: {
26
+ middleware: buildMiddlewareChain({
24
27
  getAccessToken: () => Promise.resolve(token),
25
- },
28
+ }, this.config.timeoutMs),
26
29
  });
27
30
  return this.sdkClient;
28
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authenticator.js","sourceRoot":"","sources":["../../src/auth/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAG3D;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAoB;IAC1B,SAAS,GAAkB,IAAI,CAAC;IAExC,YAAmB,MAAyB;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACzC,YAAY,EAAE;gBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;aAC7C;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
1
+ {"version":3,"file":"authenticator.js","sourceRoot":"","sources":["../../src/auth/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAoB;IAC1B,SAAS,GAAkB,IAAI,CAAC;IAExC,YAAmB,MAAyB;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtC,0EAA0E;QAC1E,qEAAqE;QACrE,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACzC,UAAU,EAAE,oBAAoB,CAC9B;gBACE,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;aAC7C,EACD,IAAI,CAAC,MAAM,CAAC,SAAS,CACtB;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ import type { AuthenticationProvider, Middleware } from '@microsoft/microsoft-graph-client';
2
+ /**
3
+ * Ceiling on a single Graph request. The SDK sets none, so a request that is
4
+ * accepted and then stalls waits forever, which inside an agent's turn is
5
+ * indistinguishable from a crash. Matches the Data Center clients.
6
+ */
7
+ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
8
+ /**
9
+ * The SDK's default chain, minus retrying, plus a timeout.
10
+ *
11
+ * `Client.initWithMiddleware({ authProvider })` — and `Client.init`, which
12
+ * delegates to it — builds `MiddlewareFactory.getDefaultMiddlewareChain`, and
13
+ * that chain contains a `RetryHandler`: 3 extra attempts on 429/503/504,
14
+ * honouring `Retry-After`. There is no option to opt out, so the chain has to be
15
+ * spelled out. Note the SDK rejects `authProvider` and `middleware` together
16
+ * (`AmbiguityInInitialization`), which is why `AuthenticationHandler` is
17
+ * constructed here rather than passed as a provider.
18
+ *
19
+ * Retrying is left out deliberately. These are one-shot commands run inside an
20
+ * agent's turn, and a library that quietly waits and retries is deciding on the
21
+ * caller's behalf, with no way for the caller to see that it happened. A failed
22
+ * call reports what went wrong and the caller chooses. That decision was never
23
+ * made for Graph: the retry arrived as a side effect of reaching for
24
+ * `initWithMiddleware` to supply an auth provider — see the first commit of
25
+ * `authenticator.ts`, whose comment reads "Create Graph client with auth
26
+ * provider".
27
+ */
28
+ export declare function buildMiddlewareChain(authProvider: AuthenticationProvider, timeoutMs?: number): Middleware[];
29
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/auth/middleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAW,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAErG;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AA2BjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,sBAAsB,EACpC,SAAS,GAAE,MAAmC,GAC7C,UAAU,EAAE,CAQd"}
@@ -0,0 +1,61 @@
1
+ import { AuthenticationHandler, HTTPMessageHandler, RedirectHandler, RedirectHandlerOptions, TelemetryHandler, } from '@microsoft/microsoft-graph-client';
2
+ /**
3
+ * Ceiling on a single Graph request. The SDK sets none, so a request that is
4
+ * accepted and then stalls waits forever, which inside an agent's turn is
5
+ * indistinguishable from a crash. Matches the Data Center clients.
6
+ */
7
+ export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
8
+ /**
9
+ * Gives every request an abort deadline.
10
+ *
11
+ * The signal is created per request rather than once per client: a single shared
12
+ * `AbortSignal.timeout` would start counting at construction and abort every
13
+ * later request on the same client. A caller who supplied their own signal keeps
14
+ * it.
15
+ */
16
+ class TimeoutHandler {
17
+ timeoutMs;
18
+ next;
19
+ constructor(timeoutMs) {
20
+ this.timeoutMs = timeoutMs;
21
+ }
22
+ async execute(context) {
23
+ if (context.options?.signal === undefined) {
24
+ context.options = { ...context.options, signal: AbortSignal.timeout(this.timeoutMs) };
25
+ }
26
+ await this.next?.execute(context);
27
+ }
28
+ setNext(next) {
29
+ this.next = next;
30
+ }
31
+ }
32
+ /**
33
+ * The SDK's default chain, minus retrying, plus a timeout.
34
+ *
35
+ * `Client.initWithMiddleware({ authProvider })` — and `Client.init`, which
36
+ * delegates to it — builds `MiddlewareFactory.getDefaultMiddlewareChain`, and
37
+ * that chain contains a `RetryHandler`: 3 extra attempts on 429/503/504,
38
+ * honouring `Retry-After`. There is no option to opt out, so the chain has to be
39
+ * spelled out. Note the SDK rejects `authProvider` and `middleware` together
40
+ * (`AmbiguityInInitialization`), which is why `AuthenticationHandler` is
41
+ * constructed here rather than passed as a provider.
42
+ *
43
+ * Retrying is left out deliberately. These are one-shot commands run inside an
44
+ * agent's turn, and a library that quietly waits and retries is deciding on the
45
+ * caller's behalf, with no way for the caller to see that it happened. A failed
46
+ * call reports what went wrong and the caller chooses. That decision was never
47
+ * made for Graph: the retry arrived as a side effect of reaching for
48
+ * `initWithMiddleware` to supply an auth provider — see the first commit of
49
+ * `authenticator.ts`, whose comment reads "Create Graph client with auth
50
+ * provider".
51
+ */
52
+ export function buildMiddlewareChain(authProvider, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) {
53
+ return [
54
+ new AuthenticationHandler(authProvider),
55
+ new TimeoutHandler(timeoutMs),
56
+ new RedirectHandler(new RedirectHandlerOptions()),
57
+ new TelemetryHandler(),
58
+ new HTTPMessageHandler(),
59
+ ];
60
+ }
61
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/auth/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,mCAAmC,CAAC;AAG3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,cAAc;IAGkB;IAF5B,IAAI,CAAc;IAE1B,YAAoC,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElD,KAAK,CAAC,OAAO,CAAC,OAAgB;QACnC,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACxF,CAAC;QACD,MAAM,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEM,OAAO,CAAC,IAAgB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAoC,EACpC,YAAoB,0BAA0B;IAE9C,OAAO;QACL,IAAI,qBAAqB,CAAC,YAAY,CAAC;QACvC,IAAI,cAAc,CAAC,SAAS,CAAC;QAC7B,IAAI,eAAe,CAAC,IAAI,sBAAsB,EAAE,CAAC;QACjD,IAAI,gBAAgB,EAAE;QACtB,IAAI,kBAAkB,EAAE;KACzB,CAAC;AACJ,CAAC"}
@@ -21,6 +21,14 @@ export interface GraphClientConfig {
21
21
  * The caller is responsible for token refresh.
22
22
  */
23
23
  accessToken: string;
24
+ /**
25
+ * Ceiling on a single request, in ms. Defaults to 30s.
26
+ *
27
+ * The Graph SDK sets no timeout of its own, so without this a request that is
28
+ * accepted and then stalls waits forever. The caller owns the bound because
29
+ * only the caller knows its own deadline.
30
+ */
31
+ timeoutMs?: number;
24
32
  }
25
33
  /**
26
34
  * Default scopes for Microsoft Graph API.
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"m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CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AA8BhF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,yBAAyB;IACzB,qBAAqB;IACrB,qBAAqB;IACrB,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAuChF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,yBAAyB;IACzB,qBAAqB;IACrB,qBAAqB;IACrB,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph-client",
3
- "version": "1.0.50",
3
+ "version": "1.0.51",
4
4
  "publish": true,
5
5
  "description": "TypeScript client library for Microsoft Graph API with built-in authentication",
6
6
  "type": "module",
@@ -43,10 +43,10 @@
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsc -p tsconfig.build.json",
46
+ "check-types": "tsc --noEmit -p tsconfig.json",
46
47
  "clean": "rm -rf dist",
47
48
  "lint": "eslint src tests",
48
49
  "lint:fix": "eslint src tests --fix",
49
- "test": "vitest run",
50
- "test:integration": "vitest run tests/integration"
50
+ "test": "vitest run"
51
51
  }
52
52
  }