cribl-control-plane 0.0.59 → 0.0.60

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.
Files changed (33) hide show
  1. package/README.md +0 -7
  2. package/RUNTIMES.md +6 -6
  3. package/dist/commonjs/hooks/clientcredentials.d.ts +3 -4
  4. package/dist/commonjs/hooks/clientcredentials.d.ts.map +1 -1
  5. package/dist/commonjs/hooks/clientcredentials.js +47 -40
  6. package/dist/commonjs/hooks/clientcredentials.js.map +1 -1
  7. package/dist/commonjs/lib/config.d.ts +3 -3
  8. package/dist/commonjs/lib/config.js +3 -3
  9. package/dist/commonjs/lib/config.js.map +1 -1
  10. package/dist/commonjs/lib/oauth2-sessions.d.ts +18 -0
  11. package/dist/commonjs/lib/oauth2-sessions.d.ts.map +1 -0
  12. package/dist/commonjs/lib/oauth2-sessions.js +105 -0
  13. package/dist/commonjs/lib/oauth2-sessions.js.map +1 -0
  14. package/dist/esm/hooks/clientcredentials.d.ts +3 -4
  15. package/dist/esm/hooks/clientcredentials.d.ts.map +1 -1
  16. package/dist/esm/hooks/clientcredentials.js +47 -40
  17. package/dist/esm/hooks/clientcredentials.js.map +1 -1
  18. package/dist/esm/lib/config.d.ts +3 -3
  19. package/dist/esm/lib/config.js +3 -3
  20. package/dist/esm/lib/config.js.map +1 -1
  21. package/dist/esm/lib/oauth2-sessions.d.ts +18 -0
  22. package/dist/esm/lib/oauth2-sessions.d.ts.map +1 -0
  23. package/dist/esm/lib/oauth2-sessions.js +101 -0
  24. package/dist/esm/lib/oauth2-sessions.js.map +1 -0
  25. package/examples/package-lock.json +1 -1
  26. package/jsr.json +1 -1
  27. package/package.json +1 -1
  28. package/src/hooks/clientcredentials.ts +66 -56
  29. package/src/lib/config.ts +3 -3
  30. package/src/lib/oauth2-sessions.ts +147 -0
  31. package/docs/sdks/auth/README.md +0 -6
  32. package/docs/sdks/criblcontrolplane/README.md +0 -7
  33. package/docs/sdks/versions/README.md +0 -6
package/README.md CHANGED
@@ -236,14 +236,10 @@ run();
236
236
  <details open>
237
237
  <summary>Available methods</summary>
238
238
 
239
- ### [auth](docs/sdks/auth/README.md)
240
-
241
-
242
239
  #### [auth.tokens](docs/sdks/tokens/README.md)
243
240
 
244
241
  * [get](docs/sdks/tokens/README.md#get) - Log in and fetch an authentication token
245
242
 
246
-
247
243
  ### [destinations](docs/sdks/destinations/README.md)
248
244
 
249
245
  * [list](docs/sdks/destinations/README.md#list) - List all Destinations
@@ -340,9 +336,6 @@ run();
340
336
  * [create](docs/sdks/hectokens/README.md#create) - Add an HEC token and optional metadata to a Splunk HEC Source
341
337
  * [update](docs/sdks/hectokens/README.md#update) - Update metadata for an HEC token for a Splunk HEC Source
342
338
 
343
- ### [versions](docs/sdks/versions/README.md)
344
-
345
-
346
339
  #### [versions.branches](docs/sdks/branches/README.md)
347
340
 
348
341
  * [list](docs/sdks/branches/README.md#list) - List all branches in the Git repository used for Cribl configuration
package/RUNTIMES.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  This SDK is intended to be used in JavaScript runtimes that support ECMAScript 2020 or newer. The SDK uses the following features:
4
4
 
5
- * [Web Fetch API][web-fetch]
6
- * [Web Streams API][web-streams] and in particular `ReadableStream`
7
- * [Async iterables][async-iter] using `Symbol.asyncIterator`
5
+ - [Web Fetch API][web-fetch]
6
+ - [Web Streams API][web-streams] and in particular `ReadableStream`
7
+ - [Async iterables][async-iter] using `Symbol.asyncIterator`
8
8
 
9
9
  [web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
10
10
  [web-streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
@@ -25,7 +25,7 @@ Runtime environments that are explicitly supported are:
25
25
 
26
26
  The following `tsconfig.json` options are recommended for projects using this
27
27
  SDK in order to get static type support for features like async iterables,
28
- streams and `fetch`-related APIs ([`for await...of`][for-await-of],
28
+ streams and `fetch`-related APIs ([`for await...of`][for-await-of],
29
29
  [`AbortSignal`][abort-signal], [`Request`][request], [`Response`][response] and
30
30
  so on):
31
31
 
@@ -38,11 +38,11 @@ so on):
38
38
  {
39
39
  "compilerOptions": {
40
40
  "target": "es2020", // or higher
41
- "lib": ["es2020", "dom", "dom.iterable"],
41
+ "lib": ["es2020", "dom", "dom.iterable"]
42
42
  }
43
43
  }
44
44
  ```
45
45
 
46
46
  While `target` can be set to older ECMAScript versions, it may result in extra,
47
47
  unnecessary compatibility code being generated if you are not targeting old
48
- runtimes.
48
+ runtimes.
@@ -2,8 +2,9 @@ import { SDKOptions } from "../lib/config.js";
2
2
  import { AfterErrorContext, AfterErrorHook, BeforeRequestContext, BeforeRequestHook, SDKInitHook } from "./types.js";
3
3
  export declare class ClientCredentialsHook implements SDKInitHook, BeforeRequestHook, AfterErrorHook {
4
4
  private client?;
5
- private sessions;
5
+ private sessionStore;
6
6
  sdkInit(opts: SDKOptions): SDKOptions;
7
+ private isHookDisabled;
7
8
  beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise<Request>;
8
9
  afterError(hookCtx: AfterErrorContext, response: Response | null, error: unknown): Promise<{
9
10
  response: Response | null;
@@ -13,8 +14,6 @@ export declare class ClientCredentialsHook implements SDKInitHook, BeforeRequest
13
14
  private getCredentials;
14
15
  private getCredentialsGlobal;
15
16
  private getSessionKey;
16
- private hasRequiredScopes;
17
- private getScopes;
18
- private hasTokenExpired;
17
+ private getRequiredScopes;
19
18
  }
20
19
  //# sourceMappingURL=clientcredentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientcredentials.d.ts","sourceRoot":"","sources":["../../../src/hooks/clientcredentials.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EAEjB,WAAW,EACZ,MAAM,YAAY,CAAC;AAgBpB,qBAAa,qBACX,YAAW,WAAW,EAAE,iBAAiB,EAAE,cAAc;IAEzD,OAAO,CAAC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E,QAAQ,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;YA2B3C,cAAc;YAuEd,cAAc;YAiBd,oBAAoB;IAmClC,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,iBAAiB;CAS1B"}
@@ -37,22 +37,31 @@ var __importStar = (this && this.__importStar) || (function () {
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ClientCredentialsHook = void 0;
40
+ const z = __importStar(require("zod"));
40
41
  const base64_js_1 = require("../lib/base64.js");
41
42
  const env_js_1 = require("../lib/env.js");
42
43
  const http_js_1 = require("../lib/http.js");
44
+ const oauth2_sessions_js_1 = require("../lib/oauth2-sessions.js");
43
45
  const schemas_js_1 = require("../lib/schemas.js");
44
46
  const models = __importStar(require("../models/index.js"));
47
+ const TokenResponseDataSchema = z.object({
48
+ access_token: z.string(),
49
+ token_type: z.string(),
50
+ expires_in: z.number().optional(),
51
+ });
45
52
  class ClientCredentialsHook {
46
53
  constructor() {
47
- this.sessions = {};
54
+ this.sessionStore = new oauth2_sessions_js_1.OAuth2SessionStore();
48
55
  }
49
56
  sdkInit(opts) {
50
57
  this.client = opts.httpClient || new http_js_1.HTTPClient();
51
58
  return opts;
52
59
  }
60
+ isHookDisabled(hookCtx) {
61
+ return !hookCtx.oAuth2Scopes;
62
+ }
53
63
  async beforeRequest(hookCtx, request) {
54
- if (!hookCtx.oAuth2Scopes) {
55
- // OAuth2 not in use
64
+ if (this.isHookDisabled(hookCtx)) {
56
65
  return request;
57
66
  }
58
67
  const credentials = await this.getCredentials(hookCtx);
@@ -60,12 +69,11 @@ class ClientCredentialsHook {
60
69
  return request;
61
70
  }
62
71
  const sessionKey = this.getSessionKey(credentials);
63
- let session = this.sessions[sessionKey];
64
- if (!session
65
- || !this.hasRequiredScopes(session.scopes, hookCtx.oAuth2Scopes)
66
- || this.hasTokenExpired(session.expiresAt)) {
67
- session = await this.doTokenRequest(hookCtx, credentials, this.getScopes(hookCtx.oAuth2Scopes, session));
68
- this.sessions[sessionKey] = session;
72
+ const requiredScopes = this.getRequiredScopes(credentials, hookCtx.oAuth2Scopes);
73
+ let session = this.sessionStore.getSession(sessionKey, requiredScopes);
74
+ if (!session) {
75
+ session = await this.doTokenRequest(hookCtx, credentials, requiredScopes);
76
+ this.sessionStore.storeSession(sessionKey, requiredScopes, session);
69
77
  }
70
78
  request.headers.set("Authorization", `Bearer ${session.token}`);
71
79
  return request;
@@ -84,7 +92,8 @@ class ClientCredentialsHook {
84
92
  }
85
93
  if (response && response?.status === 401) {
86
94
  const sessionKey = this.getSessionKey(credentials);
87
- delete this.sessions[sessionKey];
95
+ const requiredScopes = this.getRequiredScopes(credentials, hookCtx.oAuth2Scopes);
96
+ this.sessionStore.deleteSession(sessionKey, requiredScopes);
88
97
  }
89
98
  return { response, error };
90
99
  }
@@ -116,28 +125,25 @@ class ClientCredentialsHook {
116
125
  throw new Error("Failed to fetch token");
117
126
  }
118
127
  if (res.status < 200 || res.status >= 300) {
119
- throw new Error("Unexpected status code");
120
- }
121
- const data = await res.json();
122
- if (!data || typeof data !== "object") {
123
- throw new Error("Unexpected response format");
124
- }
125
- if (data.token_type?.toLowerCase() !== "bearer") {
126
- throw new Error("Unexpected token type");
127
- }
128
- let expiresAt;
129
- if (data.expires_in) {
130
- expiresAt = Date.now() + data.expires_in * 1000;
128
+ let errorMessage = `Received unexpected status code ${res.status} while fetching token`;
129
+ try {
130
+ errorMessage += `: ${await res.text()}`;
131
+ }
132
+ catch {
133
+ // ignore response body
134
+ }
135
+ throw new Error(errorMessage);
131
136
  }
132
- const sess = {
133
- credentials,
134
- token: data.access_token,
137
+ const rawData = await res.json();
138
+ const tokenResponseData = (0, schemas_js_1.parse)(rawData, (val) => TokenResponseDataSchema.parse(val), "Invalid token response format");
139
+ const session = {
140
+ token: tokenResponseData.access_token,
135
141
  scopes,
136
142
  };
137
- if (expiresAt !== undefined) {
138
- sess.expiresAt = expiresAt;
143
+ if (tokenResponseData.expires_in !== undefined) {
144
+ session.expiresAt = Date.now() + tokenResponseData.expires_in * 1000;
139
145
  }
140
- return sess;
146
+ return session;
141
147
  }
142
148
  async getCredentials(hookCtx) {
143
149
  const source = hookCtx.securitySource;
@@ -152,10 +158,12 @@ class ClientCredentialsHook {
152
158
  }
153
159
  async getCredentialsGlobal(security) {
154
160
  const out = (0, schemas_js_1.parse)(security, (val) => models.Security$outboundSchema.parse(val), "unexpected security type");
161
+ const DEFAULT_TOKEN_URL = "https://login.cribl.cloud/oauth/token";
162
+ const envTokenURL = (0, env_js_1.env)().CRIBLCONTROLPLANE_TOKEN_URL ?? DEFAULT_TOKEN_URL;
155
163
  const additionalProperties = {};
156
164
  for (const [key, value] of Object.entries(out?.clientOauth ?? {})) {
157
- if (key !== "clientID" && key !== "clientSecret" && key !== "tokenURL"
158
- && typeof value === "string") {
165
+ if (typeof value === "string"
166
+ && !["clientID", "clientSecret", "tokenURL", "scopes"].includes(key)) {
159
167
  additionalProperties[key] = value;
160
168
  }
161
169
  }
@@ -164,8 +172,10 @@ class ClientCredentialsHook {
164
172
  ?? "",
165
173
  clientSecret: out?.clientOauth?.clientSecret
166
174
  ?? (0, env_js_1.env)().CRIBLCONTROLPLANE_CLIENT_SECRET ?? "",
167
- tokenURL: out?.clientOauth?.tokenURL ?? (0, env_js_1.env)().CRIBLCONTROLPLANE_TOKEN_URL
168
- ?? "",
175
+ tokenURL: out?.clientOauth?.tokenURL !== DEFAULT_TOKEN_URL
176
+ ? out?.clientOauth?.tokenURL
177
+ : envTokenURL,
178
+ scopes: undefined,
169
179
  additionalProperties,
170
180
  };
171
181
  }
@@ -173,14 +183,11 @@ class ClientCredentialsHook {
173
183
  const key = `${credentials.clientID}:${credentials.clientSecret}`;
174
184
  return (0, base64_js_1.stringToBase64)(key);
175
185
  }
176
- hasRequiredScopes(scopes, requiredScopes) {
177
- return requiredScopes.every((scope) => scopes.includes(scope));
178
- }
179
- getScopes(requiredScopes, sess) {
180
- return [...new Set((sess?.scopes ?? []).concat(requiredScopes))];
181
- }
182
- hasTokenExpired(expiresAt) {
183
- return !expiresAt || Date.now() + 60000 > expiresAt;
186
+ getRequiredScopes(credentials, oAuth2Scopes) {
187
+ if (credentials.scopes !== undefined) {
188
+ return credentials.scopes;
189
+ }
190
+ return oAuth2Scopes;
184
191
  }
185
192
  }
186
193
  exports.ClientCredentialsHook = ClientCredentialsHook;
@@ -1 +1 @@
1
- {"version":3,"file":"clientcredentials.js","sourceRoot":"","sources":["../../../src/hooks/clientcredentials.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkD;AAElD,0CAAoC;AACpC,4CAA4C;AAC5C,kDAA0C;AAC1C,2DAA6C;AAwB7C,MAAa,qBAAqB;IAAlC;QAIU,aAAQ,GAA4B,EAAE,CAAC;IAgNjD,CAAC;IA9MC,OAAO,CAAC,IAAgB;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,oBAAU,EAAE,CAAC;QAElD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,OAA6B,EAC7B,OAAgB;QAEhB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC1B,oBAAoB;YACpB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;YACnE,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEnD,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACx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AAM,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;YAClE,IACE,OAAO,KAAK,KAAK,QAAQ;mBACtB,CAAC,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EACpE,CAAC;gBACD,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;QACH,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,IAAI,IAAA,YAAG,GAAE,CAAC,2BAA2B;mBACpE,EAAE;YACP,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,YAAY;mBACvC,IAAA,YAAG,GAAE,CAAC,+BAA+B,IAAI,EAAE;YAChD,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,KAAK,iBAAiB;gBACxD,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ;gBAC5B,CAAC,CAAC,WAAW;YACf,MAAM,EAAE,SAAS;YACjB,oBAAoB;SACrB,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,WAAwB;QAC5C,MAAM,GAAG,GAAG,GAAG,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;QAClE,OAAO,IAAA,0BAAc,EAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEO,iBAAiB,CACvB,WAAwB,EACxB,YAAsB;QAEtB,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,WAAW,CAAC,MAAM,CAAC;QAC5B,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA5ND,sDA4NC"}
@@ -35,8 +35,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
35
35
  export declare const SDK_METADATA: {
36
36
  readonly language: "typescript";
37
37
  readonly openapiDocVersion: "4.14.0-837595d5";
38
- readonly sdkVersion: "0.0.59";
39
- readonly genVersion: "2.721.0";
40
- readonly userAgent: "speakeasy-sdk/typescript 0.0.59 2.721.0 4.14.0-837595d5 cribl-control-plane";
38
+ readonly sdkVersion: "0.0.60";
39
+ readonly genVersion: "2.723.11";
40
+ readonly userAgent: "speakeasy-sdk/typescript 0.0.60 2.723.11 4.14.0-837595d5 cribl-control-plane";
41
41
  };
42
42
  //# sourceMappingURL=config.d.ts.map
@@ -28,8 +28,8 @@ function serverURLFromOptions(options) {
28
28
  exports.SDK_METADATA = {
29
29
  language: "typescript",
30
30
  openapiDocVersion: "4.14.0-837595d5",
31
- sdkVersion: "0.0.59",
32
- genVersion: "2.721.0",
33
- userAgent: "speakeasy-sdk/typescript 0.0.59 2.721.0 4.14.0-837595d5 cribl-control-plane",
31
+ sdkVersion: "0.0.60",
32
+ genVersion: "2.723.11",
33
+ userAgent: "speakeasy-sdk/typescript 0.0.60 2.723.11 4.14.0-837595d5 cribl-control-plane",
34
34
  };
35
35
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0CH,oDAeC;AAnDD,qCAA8C;AAE9C;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,GAAG;CACK,CAAC;AA6BX,SAAgB,oBAAoB,CAAC,OAAmB;IACtD,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAElC,MAAM,MAAM,GAAW,EAAE,CAAC;IAE1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;QACzC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,IAAI,kBAAU,CAAC,MAAM,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,wBAAwB,SAAS,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,SAAS,GAAG,kBAAU,CAAC,SAAS,CAAC,IAA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ACP,8EAA8E;CACxE,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type OAuth2Session = {
2
+ token: string;
3
+ expiresAt?: number;
4
+ scopes: string[];
5
+ };
6
+ export declare class OAuth2SessionStore {
7
+ #private;
8
+ cache: Map<string, Map<string, OAuth2Session>>;
9
+ getSession(ownerKey: string, scopes: string[]): OAuth2Session | undefined;
10
+ storeSession(ownerKey: string, scopes: string[], entry: OAuth2Session): void;
11
+ deleteSession(ownerKey: string, scopes: string[]): OAuth2Session | undefined;
12
+ statistics(): {
13
+ total: number;
14
+ active: number;
15
+ expired: number;
16
+ };
17
+ }
18
+ //# sourceMappingURL=oauth2-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-sessions.d.ts","sourceRoot":"","sources":["../../../src/lib/oauth2-sessions.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,qBAAa,kBAAkB;;IAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAa;IAE3D,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,aAAa,GAAG,SAAS;IA6B5B,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,aAAa,GACnB,IAAI;IAUP,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACf,aAAa,GAAG,SAAS;IAkB5B,UAAU,IAAI;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB;CA8DF"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
6
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
7
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
8
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9
+ };
10
+ var _OAuth2SessionStore_instances, _OAuth2SessionStore_getScopesKey, _OAuth2SessionStore_hasRequiredScopes, _OAuth2SessionStore_hasTokenExpired;
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OAuth2SessionStore = void 0;
13
+ class OAuth2SessionStore {
14
+ constructor() {
15
+ _OAuth2SessionStore_instances.add(this);
16
+ this.cache = new Map();
17
+ }
18
+ getSession(ownerKey, scopes) {
19
+ const tokens = this.cache.get(ownerKey);
20
+ if (!tokens) {
21
+ return;
22
+ }
23
+ const scopeKey = __classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_getScopesKey).call(this, scopes);
24
+ // First look for an exact match
25
+ const exactMatch = tokens.get(scopeKey);
26
+ if (exactMatch !== undefined && !__classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_hasTokenExpired).call(this, exactMatch.expiresAt)) {
27
+ return exactMatch;
28
+ }
29
+ // If no exact match was found or it was expired, look for a superset match
30
+ for (const [_, session] of tokens) {
31
+ if (__classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_hasRequiredScopes).call(this, session.scopes, scopes)
32
+ && !__classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_hasTokenExpired).call(this, session.expiresAt)) {
33
+ return session;
34
+ }
35
+ }
36
+ return undefined;
37
+ }
38
+ storeSession(ownerKey, scopes, entry) {
39
+ let tokens = this.cache.get(ownerKey);
40
+ if (tokens == null) {
41
+ tokens = new Map();
42
+ this.cache.set(ownerKey, tokens);
43
+ }
44
+ tokens.set(__classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_getScopesKey).call(this, scopes), entry);
45
+ }
46
+ deleteSession(ownerKey, scopes) {
47
+ const tokens = this.cache.get(ownerKey);
48
+ if (!tokens) {
49
+ return;
50
+ }
51
+ const scopeKey = __classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_getScopesKey).call(this, scopes);
52
+ const outgoing = tokens.get(scopeKey);
53
+ tokens.delete(scopeKey);
54
+ // Clean up empty owner maps
55
+ if (tokens.size === 0) {
56
+ this.cache.delete(ownerKey);
57
+ }
58
+ return outgoing;
59
+ }
60
+ statistics() {
61
+ let total = 0;
62
+ let active = 0;
63
+ let expired = 0;
64
+ for (const [_, sessions] of this.cache) {
65
+ for (const [_, session] of sessions) {
66
+ total += 1;
67
+ if (__classPrivateFieldGet(this, _OAuth2SessionStore_instances, "m", _OAuth2SessionStore_hasTokenExpired).call(this, session.expiresAt)) {
68
+ expired += 1;
69
+ }
70
+ else {
71
+ active += 1;
72
+ }
73
+ }
74
+ }
75
+ return { total, active, expired };
76
+ }
77
+ }
78
+ exports.OAuth2SessionStore = OAuth2SessionStore;
79
+ _OAuth2SessionStore_instances = new WeakSet(), _OAuth2SessionStore_getScopesKey = function _OAuth2SessionStore_getScopesKey(scopes) {
80
+ if (!scopes?.length) {
81
+ return "";
82
+ }
83
+ const p = new URLSearchParams();
84
+ const sorted = scopes.slice().sort();
85
+ for (const scope of sorted) {
86
+ p.append("s", scope);
87
+ }
88
+ return p.toString();
89
+ }, _OAuth2SessionStore_hasRequiredScopes = function _OAuth2SessionStore_hasRequiredScopes(sessionScopes, requiredScopes) {
90
+ // If no scopes are required, any token works
91
+ if (requiredScopes.length === 0) {
92
+ return true;
93
+ }
94
+ // Check if session has all required scopes
95
+ const sessionScopeSet = new Set(sessionScopes);
96
+ for (const requiredScope of requiredScopes) {
97
+ if (!sessionScopeSet.has(requiredScope)) {
98
+ return false;
99
+ }
100
+ }
101
+ return true;
102
+ }, _OAuth2SessionStore_hasTokenExpired = function _OAuth2SessionStore_hasTokenExpired(expiresAt) {
103
+ return expiresAt !== undefined && Date.now() + 60000 >= expiresAt;
104
+ };
105
+ //# sourceMappingURL=oauth2-sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-sessions.js","sourceRoot":"","sources":["../../../src/lib/oauth2-sessions.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;AAQH,MAAa,kBAAkB;IAA/B;;QACE,UAAK,GAA4C,IAAI,GAAG,EAAE,CAAC;IAuI7D,CAAC;IArIC,UAAU,CACR,QAAgB,EAChB,MAAgB;QAEhB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAG,uBAAA,IAAI,uEAAc,MAAlB,IAAI,EAAe,MAAM,CAAC,CAAC;QAE5C,gCAAgC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxC,IACE,UAAU,KAAK,SAAS,IAAI,CAAC,uBAAA,IAAI,0EAAiB,MAArB,IAAI,EAAkB,UAAU,CAAC,SAAS,CAAC,EACxE,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,2EAA2E;QAC3E,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,MAAM,EAAE,CAAC;YAClC,IACE,uBAAA,IAAI,4EAAmB,MAAvB,IAAI,EAAoB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;mBAC5C,CAAC,uBAAA,IAAI,0EAAiB,MAArB,IAAI,EAAkB,OAAO,CAAC,SAAS,CAAC,EAC5C,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC;QACH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,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,SAAS,CAAC;AACpE,CAAC"}
@@ -2,8 +2,9 @@ import { SDKOptions } from "../lib/config.js";
2
2
  import { AfterErrorContext, AfterErrorHook, BeforeRequestContext, BeforeRequestHook, SDKInitHook } from "./types.js";
3
3
  export declare class ClientCredentialsHook implements SDKInitHook, BeforeRequestHook, AfterErrorHook {
4
4
  private client?;
5
- private sessions;
5
+ private sessionStore;
6
6
  sdkInit(opts: SDKOptions): SDKOptions;
7
+ private isHookDisabled;
7
8
  beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise<Request>;
8
9
  afterError(hookCtx: AfterErrorContext, response: Response | null, error: unknown): Promise<{
9
10
  response: Response | null;
@@ -13,8 +14,6 @@ export declare class ClientCredentialsHook implements SDKInitHook, BeforeRequest
13
14
  private getCredentials;
14
15
  private getCredentialsGlobal;
15
16
  private getSessionKey;
16
- private hasRequiredScopes;
17
- private getScopes;
18
- private hasTokenExpired;
17
+ private getRequiredScopes;
19
18
  }
20
19
  //# sourceMappingURL=clientcredentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientcredentials.d.ts","sourceRoot":"","sources":["../../../src/hooks/clientcredentials.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EAEjB,WAAW,EACZ,MAAM,YAAY,CAAC;AAgBpB,qBAAa,qBACX,YAAW,WAAW,EAAE,iBAAiB,EAAE,cAAc;IAEzD,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAA+B;IAE/C,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAM/B,aAAa,CACjB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC;IAiCb,UAAU,C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* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
+ import * as z from "zod";
4
5
  import { stringToBase64 } from "../lib/base64.js";
5
6
  import { env } from "../lib/env.js";
6
7
  import { HTTPClient } from "../lib/http.js";
8
+ import { OAuth2SessionStore } from "../lib/oauth2-sessions.js";
7
9
  import { parse } from "../lib/schemas.js";
8
10
  import * as models from "../models/index.js";
11
+ const TokenResponseDataSchema = z.object({
12
+ access_token: z.string(),
13
+ token_type: z.string(),
14
+ expires_in: z.number().optional(),
15
+ });
9
16
  export class ClientCredentialsHook {
10
17
  constructor() {
11
- this.sessions = {};
18
+ this.sessionStore = new OAuth2SessionStore();
12
19
  }
13
20
  sdkInit(opts) {
14
21
  this.client = opts.httpClient || new HTTPClient();
15
22
  return opts;
16
23
  }
24
+ isHookDisabled(hookCtx) {
25
+ return !hookCtx.oAuth2Scopes;
26
+ }
17
27
  async beforeRequest(hookCtx, request) {
18
- if (!hookCtx.oAuth2Scopes) {
19
- // OAuth2 not in use
28
+ if (this.isHookDisabled(hookCtx)) {
20
29
  return request;
21
30
  }
22
31
  const credentials = await this.getCredentials(hookCtx);
@@ -24,12 +33,11 @@ export class ClientCredentialsHook {
24
33
  return request;
25
34
  }
26
35
  const sessionKey = this.getSessionKey(credentials);
27
- let session = this.sessions[sessionKey];
28
- if (!session
29
- || !this.hasRequiredScopes(session.scopes, hookCtx.oAuth2Scopes)
30
- || this.hasTokenExpired(session.expiresAt)) {
31
- session = await this.doTokenRequest(hookCtx, credentials, this.getScopes(hookCtx.oAuth2Scopes, session));
32
- this.sessions[sessionKey] = session;
36
+ const requiredScopes = this.getRequiredScopes(credentials, hookCtx.oAuth2Scopes);
37
+ let session = this.sessionStore.getSession(sessionKey, requiredScopes);
38
+ if (!session) {
39
+ session = await this.doTokenRequest(hookCtx, credentials, requiredScopes);
40
+ this.sessionStore.storeSession(sessionKey, requiredScopes, session);
33
41
  }
34
42
  request.headers.set("Authorization", `Bearer ${session.token}`);
35
43
  return request;
@@ -48,7 +56,8 @@ export class ClientCredentialsHook {
48
56
  }
49
57
  if (response && response?.status === 401) {
50
58
  const sessionKey = this.getSessionKey(credentials);
51
- delete this.sessions[sessionKey];
59
+ const requiredScopes = this.getRequiredScopes(credentials, hookCtx.oAuth2Scopes);
60
+ this.sessionStore.deleteSession(sessionKey, requiredScopes);
52
61
  }
53
62
  return { response, error };
54
63
  }
@@ -80,28 +89,25 @@ export class ClientCredentialsHook {
80
89
  throw new Error("Failed to fetch token");
81
90
  }
82
91
  if (res.status < 200 || res.status >= 300) {
83
- throw new Error("Unexpected status code");
84
- }
85
- const data = await res.json();
86
- if (!data || typeof data !== "object") {
87
- throw new Error("Unexpected response format");
88
- }
89
- if (data.token_type?.toLowerCase() !== "bearer") {
90
- throw new Error("Unexpected token type");
91
- }
92
- let expiresAt;
93
- if (data.expires_in) {
94
- expiresAt = Date.now() + data.expires_in * 1000;
92
+ let errorMessage = `Received unexpected status code ${res.status} while fetching token`;
93
+ try {
94
+ errorMessage += `: ${await res.text()}`;
95
+ }
96
+ catch {
97
+ // ignore response body
98
+ }
99
+ throw new Error(errorMessage);
95
100
  }
96
- const sess = {
97
- credentials,
98
- token: data.access_token,
101
+ const rawData = await res.json();
102
+ const tokenResponseData = parse(rawData, (val) => TokenResponseDataSchema.parse(val), "Invalid token response format");
103
+ const session = {
104
+ token: tokenResponseData.access_token,
99
105
  scopes,
100
106
  };
101
- if (expiresAt !== undefined) {
102
- sess.expiresAt = expiresAt;
107
+ if (tokenResponseData.expires_in !== undefined) {
108
+ session.expiresAt = Date.now() + tokenResponseData.expires_in * 1000;
103
109
  }
104
- return sess;
110
+ return session;
105
111
  }
106
112
  async getCredentials(hookCtx) {
107
113
  const source = hookCtx.securitySource;
@@ -116,10 +122,12 @@ export class ClientCredentialsHook {
116
122
  }
117
123
  async getCredentialsGlobal(security) {
118
124
  const out = parse(security, (val) => models.Security$outboundSchema.parse(val), "unexpected security type");
125
+ const DEFAULT_TOKEN_URL = "https://login.cribl.cloud/oauth/token";
126
+ const envTokenURL = env().CRIBLCONTROLPLANE_TOKEN_URL ?? DEFAULT_TOKEN_URL;
119
127
  const additionalProperties = {};
120
128
  for (const [key, value] of Object.entries(out?.clientOauth ?? {})) {
121
- if (key !== "clientID" && key !== "clientSecret" && key !== "tokenURL"
122
- && typeof value === "string") {
129
+ if (typeof value === "string"
130
+ && !["clientID", "clientSecret", "tokenURL", "scopes"].includes(key)) {
123
131
  additionalProperties[key] = value;
124
132
  }
125
133
  }
@@ -128,8 +136,10 @@ export class ClientCredentialsHook {
128
136
  ?? "",
129
137
  clientSecret: out?.clientOauth?.clientSecret
130
138
  ?? env().CRIBLCONTROLPLANE_CLIENT_SECRET ?? "",
131
- tokenURL: out?.clientOauth?.tokenURL ?? env().CRIBLCONTROLPLANE_TOKEN_URL
132
- ?? "",
139
+ tokenURL: out?.clientOauth?.tokenURL !== DEFAULT_TOKEN_URL
140
+ ? out?.clientOauth?.tokenURL
141
+ : envTokenURL,
142
+ scopes: undefined,
133
143
  additionalProperties,
134
144
  };
135
145
  }
@@ -137,14 +147,11 @@ export class ClientCredentialsHook {
137
147
  const key = `${credentials.clientID}:${credentials.clientSecret}`;
138
148
  return stringToBase64(key);
139
149
  }
140
- hasRequiredScopes(scopes, requiredScopes) {
141
- return requiredScopes.every((scope) => scopes.includes(scope));
142
- }
143
- getScopes(requiredScopes, sess) {
144
- return [...new Set((sess?.scopes ?? []).concat(requiredScopes))];
145
- }
146
- hasTokenExpired(expiresAt) {
147
- return !expiresAt || Date.now() + 60000 > expiresAt;
150
+ getRequiredScopes(credentials, oAuth2Scopes) {
151
+ if (credentials.scopes !== undefined) {
152
+ return credentials.scopes;
153
+ }
154
+ return oAuth2Scopes;
148
155
  }
149
156
  }
150
157
  //# sourceMappingURL=clientcredentials.js.map