@databricks/sdk-auth 0.34.0 → 0.35.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.
Files changed (79) hide show
  1. package/dist/auth.d.ts +42 -40
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +38 -42
  4. package/dist/auth.js.map +1 -1
  5. package/dist/credentials/default/chain.d.ts +26 -22
  6. package/dist/credentials/default/chain.d.ts.map +1 -1
  7. package/dist/credentials/default/chain.js +74 -84
  8. package/dist/credentials/default/chain.js.map +1 -1
  9. package/dist/credentials/default/default-credentials.d.ts +12 -9
  10. package/dist/credentials/default/default-credentials.d.ts.map +1 -1
  11. package/dist/credentials/default/default-credentials.js +29 -20
  12. package/dist/credentials/default/default-credentials.js.map +1 -1
  13. package/dist/credentials/default/errors.d.ts +7 -4
  14. package/dist/credentials/default/errors.d.ts.map +1 -1
  15. package/dist/credentials/default/errors.js +17 -13
  16. package/dist/credentials/default/errors.js.map +1 -1
  17. package/dist/credentials/default/u2m-strategy.d.ts +6 -2
  18. package/dist/credentials/default/u2m-strategy.d.ts.map +1 -1
  19. package/dist/credentials/default/u2m-strategy.js +21 -20
  20. package/dist/credentials/default/u2m-strategy.js.map +1 -1
  21. package/dist/credentials/errors.d.ts +15 -12
  22. package/dist/credentials/errors.d.ts.map +1 -1
  23. package/dist/credentials/errors.js +40 -41
  24. package/dist/credentials/errors.js.map +1 -1
  25. package/dist/credentials/host-metadata.d.ts +22 -19
  26. package/dist/credentials/host-metadata.d.ts.map +1 -1
  27. package/dist/credentials/host-metadata.js +88 -109
  28. package/dist/credentials/host-metadata.js.map +1 -1
  29. package/dist/credentials/index.browser.d.ts +4 -11
  30. package/dist/credentials/index.browser.js +5 -9
  31. package/dist/credentials/index.d.ts +7 -14
  32. package/dist/credentials/index.js +8 -10
  33. package/dist/credentials/m2m.d.ts +29 -28
  34. package/dist/credentials/m2m.d.ts.map +1 -1
  35. package/dist/credentials/m2m.js +66 -81
  36. package/dist/credentials/m2m.js.map +1 -1
  37. package/dist/credentials/pat.d.ts +6 -5
  38. package/dist/credentials/pat.d.ts.map +1 -1
  39. package/dist/credentials/pat.js +33 -37
  40. package/dist/credentials/pat.js.map +1 -1
  41. package/dist/credentials/u2m.d.ts +17 -20
  42. package/dist/credentials/u2m.d.ts.map +1 -1
  43. package/dist/credentials/u2m.js +107 -135
  44. package/dist/credentials/u2m.js.map +1 -1
  45. package/dist/index.d.ts +6 -8
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +12 -7
  48. package/dist/index.js.map +1 -1
  49. package/dist/oidc/env.d.ts +6 -2
  50. package/dist/oidc/env.d.ts.map +1 -1
  51. package/dist/oidc/env.js +19 -16
  52. package/dist/oidc/env.js.map +1 -1
  53. package/dist/oidc/file.d.ts +6 -2
  54. package/dist/oidc/file.d.ts.map +1 -1
  55. package/dist/oidc/file.js +23 -25
  56. package/dist/oidc/file.js.map +1 -1
  57. package/dist/oidc/index.browser.d.ts +3 -13
  58. package/dist/oidc/index.browser.js +4 -11
  59. package/dist/oidc/index.d.ts +5 -14
  60. package/dist/oidc/index.js +6 -12
  61. package/dist/oidc/oidc.d.ts +8 -5
  62. package/dist/oidc/oidc.d.ts.map +1 -1
  63. package/dist/oidc/oidc.js +11 -7
  64. package/dist/oidc/oidc.js.map +1 -1
  65. package/dist/oidc/tokensource.d.ts +41 -41
  66. package/dist/oidc/tokensource.d.ts.map +1 -1
  67. package/dist/oidc/tokensource.js +47 -52
  68. package/dist/oidc/tokensource.js.map +1 -1
  69. package/dist/package.js +6 -0
  70. package/dist/package.js.map +1 -0
  71. package/package.json +3 -3
  72. package/dist/credentials/index.browser.d.ts.map +0 -1
  73. package/dist/credentials/index.browser.js.map +0 -1
  74. package/dist/credentials/index.d.ts.map +0 -1
  75. package/dist/credentials/index.js.map +0 -1
  76. package/dist/oidc/index.browser.d.ts.map +0 -1
  77. package/dist/oidc/index.browser.js.map +0 -1
  78. package/dist/oidc/index.d.ts.map +0 -1
  79. package/dist/oidc/index.js.map +0 -1
package/dist/auth.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ //#region src/auth.d.ts
1
2
  /**
2
3
  * Core authentication interfaces and types for the Databricks SDK.
3
4
  *
@@ -9,54 +10,54 @@
9
10
  /**
10
11
  * Represents a header that can be used to sign requests.
11
12
  */
12
- export interface Header {
13
- key: string;
14
- value: string;
13
+ interface Header {
14
+ key: string;
15
+ value: string;
15
16
  }
16
17
  /**
17
18
  * Anything that can return authentication headers.
18
19
  */
19
- export interface Credentials {
20
- /**
21
- * Short identifier for the authentication strategy, e.g. `pat` or
22
- * `oauth-m2m`. Used for logging and for selecting between strategies.
23
- */
24
- name(): string;
25
- /**
26
- * Returns headers to authenticate requests.
27
- */
28
- authHeaders(): Promise<Header[]>;
20
+ interface Credentials {
21
+ /**
22
+ * Short identifier for the authentication strategy, e.g. `pat` or
23
+ * `oauth-m2m`. Used for logging and for selecting between strategies.
24
+ */
25
+ name(): string;
26
+ /**
27
+ * Returns headers to authenticate requests.
28
+ */
29
+ authHeaders(): Promise<Header[]>;
29
30
  }
30
31
  /**
31
32
  * Represents a token that can be used to sign requests.
32
33
  */
33
- export interface Token {
34
- /**
35
- * The raw value to sign requests with.
36
- * It typically is an access token but can represent other types of tokens
37
- * (e.g., ID tokens).
38
- */
39
- value: string;
40
- /**
41
- * The type of token. If empty, the token type is assumed to be "Bearer".
42
- */
43
- type?: string;
44
- /**
45
- * The time at which the token expires.
46
- * If undefined, the token is considered to be valid indefinitely.
47
- */
48
- expiry?: Date;
34
+ interface Token {
35
+ /**
36
+ * The raw value to sign requests with.
37
+ * It typically is an access token but can represent other types of tokens
38
+ * (e.g., ID tokens).
39
+ */
40
+ value: string;
41
+ /**
42
+ * The type of token. If empty, the token type is assumed to be "Bearer".
43
+ */
44
+ type?: string;
45
+ /**
46
+ * The time at which the token expires.
47
+ * If undefined, the token is considered to be valid indefinitely.
48
+ */
49
+ expiry?: Date;
49
50
  }
50
51
  /**
51
52
  * Anything that can return a token.
52
53
  */
53
- export interface TokenProvider {
54
- /**
55
- * Returns a token or throws an error.
56
- * The returned Token should be considered immutable and should not be
57
- * modified.
58
- */
59
- token(): Promise<Token>;
54
+ interface TokenProvider {
55
+ /**
56
+ * Returns a token or throws an error.
57
+ * The returned Token should be considered immutable and should not be
58
+ * modified.
59
+ */
60
+ token(): Promise<Token>;
60
61
  }
61
62
  /**
62
63
  * Adapter to allow the use of ordinary functions as TokenProvider.
@@ -64,12 +65,11 @@ export interface TokenProvider {
64
65
  * @example
65
66
  * const provider = tokenProviderFn(async () => ({ value: 'my-token' }));
66
67
  */
67
- export declare function tokenProviderFn(fn: () => Promise<Token>): TokenProvider;
68
+ declare function tokenProviderFn(fn: () => Promise<Token>): TokenProvider;
68
69
  /**
69
70
  * Combines TokenProvider and Credentials interfaces.
70
71
  */
71
- export interface TokenCredentials extends TokenProvider, Credentials {
72
- }
72
+ interface TokenCredentials extends TokenProvider, Credentials {}
73
73
  /**
74
74
  * Creates a TokenCredentials that uses the given TokenProvider to return
75
75
  * authentication headers.
@@ -77,5 +77,7 @@ export interface TokenCredentials extends TokenProvider, Credentials {
77
77
  * @param name - Short identifier for the auth strategy (e.g. `oauth-m2m`).
78
78
  * @param provider - Source of tokens used to build the Authorization header.
79
79
  */
80
- export declare function newTokenCredentials(name: string, provider: TokenProvider): TokenCredentials;
80
+ declare function newTokenCredentials(name: string, provider: TokenProvider): TokenCredentials;
81
+ //#endregion
82
+ export { Credentials, Header, Token, TokenCredentials, TokenProvider, newTokenCredentials, tokenProviderFn };
81
83
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WA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,WAAA;;;;;;;;iBASzC,mBAAA,CACd,IAAA,UACA,QAAA,EAAU,aAAA,GACT,gBAAA"}
package/dist/auth.js CHANGED
@@ -1,47 +1,43 @@
1
+ //#region src/auth.ts
1
2
  /**
2
- * Core authentication interfaces and types for the Databricks SDK.
3
- *
4
- * This module is not meant to be used directly by consumers of the SDK
5
- * and is subject to change without notice.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Adapter to allow the use of ordinary functions as TokenProvider.
11
- *
12
- * @example
13
- * const provider = tokenProviderFn(async () => ({ value: 'my-token' }));
14
- */
15
- export function tokenProviderFn(fn) {
16
- return { token: fn };
3
+ * Adapter to allow the use of ordinary functions as TokenProvider.
4
+ *
5
+ * @example
6
+ * const provider = tokenProviderFn(async () => ({ value: 'my-token' }));
7
+ */
8
+ function tokenProviderFn(fn) {
9
+ return { token: fn };
17
10
  }
18
11
  /**
19
- * Creates a TokenCredentials that uses the given TokenProvider to return
20
- * authentication headers.
21
- *
22
- * @param name - Short identifier for the auth strategy (e.g. `oauth-m2m`).
23
- * @param provider - Source of tokens used to build the Authorization header.
24
- */
25
- export function newTokenCredentials(name, provider) {
26
- return new TokenCredentialsImpl(name, provider);
27
- }
28
- class TokenCredentialsImpl {
29
- strategyName;
30
- provider;
31
- constructor(strategyName, provider) {
32
- this.strategyName = strategyName;
33
- this.provider = provider;
34
- }
35
- name() {
36
- return this.strategyName;
37
- }
38
- async token() {
39
- return this.provider.token();
40
- }
41
- async authHeaders() {
42
- const t = await this.token();
43
- const scheme = t.type ?? 'Bearer';
44
- return [{ key: 'Authorization', value: `${scheme} ${t.value}` }];
45
- }
12
+ * Creates a TokenCredentials that uses the given TokenProvider to return
13
+ * authentication headers.
14
+ *
15
+ * @param name - Short identifier for the auth strategy (e.g. `oauth-m2m`).
16
+ * @param provider - Source of tokens used to build the Authorization header.
17
+ */
18
+ function newTokenCredentials(name, provider) {
19
+ return new TokenCredentialsImpl(name, provider);
46
20
  }
21
+ var TokenCredentialsImpl = class {
22
+ constructor(strategyName, provider) {
23
+ this.strategyName = strategyName;
24
+ this.provider = provider;
25
+ }
26
+ name() {
27
+ return this.strategyName;
28
+ }
29
+ async token() {
30
+ return this.provider.token();
31
+ }
32
+ async authHeaders() {
33
+ const t = await this.token();
34
+ return [{
35
+ key: "Authorization",
36
+ value: `${t.type ?? "Bearer"} ${t.value}`
37
+ }];
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ export { newTokenCredentials, tokenProviderFn };
47
43
  //# sourceMappingURL=auth.js.map
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6DH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,EAAwB;IACtD,OAAO,EAAC,KAAK,EAAE,EAAE,EAAC,CAAC;AACrB,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,QAAuB;IAEvB,OAAO,IAAI,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,oBAAoB;IAEL;IACA;IAFnB,YACmB,YAAoB,EACpB,QAAuB;QADvB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,aAAQ,GAAR,QAAQ,CAAe;IACvC,CAAC;IAEJ,IAAI;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC;QAClC,OAAO,CAAC,EAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE,EAAC,CAAC,CAAC;IACjE,CAAC;CACF"}
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * Core authentication interfaces and types for the Databricks SDK.\n *\n * This module is not meant to be used directly by consumers of the SDK\n * and is subject to change without notice.\n *\n * @packageDocumentation\n */\n\n/**\n * Represents a header that can be used to sign requests.\n */\nexport interface Header {\n key: string;\n value: string;\n}\n\n/**\n * Anything that can return authentication headers.\n */\nexport interface Credentials {\n /**\n * Short identifier for the authentication strategy, e.g. `pat` or\n * `oauth-m2m`. Used for logging and for selecting between strategies.\n */\n name(): string;\n\n /**\n * Returns headers to authenticate requests.\n */\n authHeaders(): Promise<Header[]>;\n}\n\n/**\n * Represents a token that can be used to sign requests.\n */\nexport interface Token {\n /**\n * The raw value to sign requests with.\n * It typically is an access token but can represent other types of tokens\n * (e.g., ID tokens).\n */\n value: string;\n\n /**\n * The type of token. If empty, the token type is assumed to be \"Bearer\".\n */\n type?: string;\n\n /**\n * The time at which the token expires.\n * If undefined, the token is considered to be valid indefinitely.\n */\n expiry?: Date;\n}\n\n/**\n * Anything that can return a token.\n */\nexport interface TokenProvider {\n /**\n * Returns a token or throws an error.\n * The returned Token should be considered immutable and should not be\n * modified.\n */\n token(): Promise<Token>;\n}\n\n/**\n * Adapter to allow the use of ordinary functions as TokenProvider.\n *\n * @example\n * const provider = tokenProviderFn(async () => ({ value: 'my-token' }));\n */\nexport function tokenProviderFn(fn: () => Promise<Token>): TokenProvider {\n return {token: fn};\n}\n\n/**\n * Combines TokenProvider and Credentials interfaces.\n */\nexport interface TokenCredentials extends TokenProvider, Credentials {}\n\n/**\n * Creates a TokenCredentials that uses the given TokenProvider to return\n * authentication headers.\n *\n * @param name - Short identifier for the auth strategy (e.g. `oauth-m2m`).\n * @param provider - Source of tokens used to build the Authorization header.\n */\nexport function newTokenCredentials(\n name: string,\n provider: TokenProvider\n): TokenCredentials {\n return new TokenCredentialsImpl(name, provider);\n}\n\nclass TokenCredentialsImpl implements TokenCredentials {\n constructor(\n private readonly strategyName: string,\n private readonly provider: TokenProvider\n ) {}\n\n name(): string {\n return this.strategyName;\n }\n\n async token(): Promise<Token> {\n return this.provider.token();\n }\n\n async authHeaders(): Promise<Header[]> {\n const t = await this.token();\n const scheme = t.type ?? 'Bearer';\n return [{key: 'Authorization', value: `${scheme} ${t.value}`}];\n }\n}\n"],"mappings":";;;;;;;AA0EA,SAAgB,gBAAgB,IAAyC;AACvE,QAAO,EAAC,OAAO,IAAG;;;;;;;;;AAepB,SAAgB,oBACd,MACA,UACkB;AAClB,QAAO,IAAI,qBAAqB,MAAM,SAAS;;AAGjD,IAAM,uBAAN,MAAuD;CACrD,YACE,AAAiB,cACjB,AAAiB,UACjB;EAFiB;EACA;;CAGnB,OAAe;AACb,SAAO,KAAK;;CAGd,MAAM,QAAwB;AAC5B,SAAO,KAAK,SAAS,OAAO;;CAG9B,MAAM,cAAiC;EACrC,MAAM,IAAI,MAAM,KAAK,OAAO;AAE5B,SAAO,CAAC;GAAC,KAAK;GAAiB,OAAO,GADvB,EAAE,QAAQ,SACuB,GAAG,EAAE;GAAQ,CAAC"}
@@ -1,15 +1,17 @@
1
- import type { Profile } from '@databricks/sdk-core/profiles';
2
- import type { Credentials, Header } from '../../auth';
1
+ import { Credentials, Header } from "../../auth.js";
2
+ import { Profile } from "@databricks/sdk-core/profiles";
3
+
4
+ //#region src/credentials/default/chain.d.ts
3
5
  /**
4
6
  * A named strategy that inspects a profile and either returns configured
5
7
  * credentials or `undefined` if it is not applicable. The `name` matches the
6
8
  * `name()` of the credentials it produces, so it can be selected by a
7
9
  * profile's `authType`.
8
10
  */
9
- export interface Strategy {
10
- /** Short identifier, e.g. `pat`, `oauth-m2m`, or `databricks-cli`. */
11
- readonly name: string;
12
- readonly configure: (profile: Profile) => Credentials | undefined;
11
+ interface Strategy {
12
+ /** Short identifier, e.g. `pat`, `oauth-m2m`, or `databricks-cli`. */
13
+ readonly name: string;
14
+ readonly configure: (profile: Profile) => Credentials | undefined;
13
15
  }
14
16
  /**
15
17
  * Lazy {@link Credentials} that resolves to a configured strategy on the
@@ -19,26 +21,28 @@ export interface Strategy {
19
21
  * selected. Otherwise the strategies are tried in order and the first
20
22
  * configured one wins.
21
23
  */
22
- export declare class DefaultCredentials implements Credentials {
23
- private readonly strategies;
24
- private readonly loadProfile;
25
- private resolved;
26
- constructor(strategies: readonly Strategy[], loadProfile: () => Promise<Profile>);
27
- /**
28
- * Returns `default` until a strategy has been resolved, then delegates to
29
- * the resolved strategy so callers (logging, telemetry) can tell which
30
- * authentication method won.
31
- */
32
- name(): string;
33
- authHeaders(): Promise<Header[]>;
34
- private resolveChain;
35
- private resolveByAuthType;
24
+ declare class DefaultCredentials implements Credentials {
25
+ private readonly strategies;
26
+ private readonly loadProfile;
27
+ private resolved;
28
+ constructor(strategies: readonly Strategy[], loadProfile: () => Promise<Profile>);
29
+ /**
30
+ * Returns `default` until a strategy has been resolved, then delegates to
31
+ * the resolved strategy so callers (logging, telemetry) can tell which
32
+ * authentication method won.
33
+ */
34
+ name(): string;
35
+ authHeaders(): Promise<Header[]>;
36
+ private resolveChain;
37
+ private resolveByAuthType;
36
38
  }
37
39
  /** PAT strategy: configured when `token` is set in the profile. */
38
- export declare const patStrategy: Strategy;
40
+ declare const patStrategy: Strategy;
39
41
  /**
40
42
  * OAuth M2M strategy: configured when `clientId` and `clientSecret` are
41
43
  * both set in the profile.
42
44
  */
43
- export declare const m2mStrategy: Strategy;
45
+ declare const m2mStrategy: Strategy;
46
+ //#endregion
47
+ export { DefaultCredentials, Strategy, m2mStrategy, patStrategy };
44
48
  //# sourceMappingURL=chain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/credentials/default/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM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,81 @@
1
- import { newM2mCredentials } from '../m2m';
2
- import { newPatCredentials } from '../pat';
3
- import { DefaultCredentialsError } from './errors';
4
- const AUTH_DOC_URL = 'https://docs.databricks.com/aws/en/dev-tools/auth/index';
1
+ import { newM2mCredentials } from "../m2m.js";
2
+ import { newPatCredentials } from "../pat.js";
3
+ import { DefaultCredentialsError } from "./errors.js";
4
+
5
+ //#region src/credentials/default/chain.ts
6
+ const AUTH_DOC_URL = "https://docs.databricks.com/aws/en/dev-tools/auth/index";
5
7
  const NO_AUTH_CONFIGURED_MESSAGE = `cannot configure default credentials, please check ${AUTH_DOC_URL} to configure credentials for your preferred authentication method`;
6
8
  /**
7
- * Lazy {@link Credentials} that resolves to a configured strategy on the
8
- * first `authHeaders()` call.
9
- *
10
- * If the profile sets `authType`, the strategy whose name matches it is
11
- * selected. Otherwise the strategies are tried in order and the first
12
- * configured one wins.
13
- */
14
- export class DefaultCredentials {
15
- strategies;
16
- loadProfile;
17
- resolved;
18
- constructor(strategies, loadProfile) {
19
- this.strategies = strategies;
20
- this.loadProfile = loadProfile;
21
- }
22
- /**
23
- * Returns `default` until a strategy has been resolved, then delegates to
24
- * the resolved strategy so callers (logging, telemetry) can tell which
25
- * authentication method won.
26
- */
27
- name() {
28
- return this.resolved?.name() ?? 'default';
29
- }
30
- async authHeaders() {
31
- this.resolved ??= await this.resolveChain();
32
- return this.resolved.authHeaders();
33
- }
34
- async resolveChain() {
35
- const profile = await this.loadProfile();
36
- if (profile.authType !== undefined) {
37
- return this.resolveByAuthType(profile, profile.authType);
38
- }
39
- for (const strategy of this.strategies) {
40
- const built = strategy.configure(profile);
41
- if (built !== undefined) {
42
- return built;
43
- }
44
- }
45
- throw new DefaultCredentialsError('NO_AUTH_CONFIGURED', NO_AUTH_CONFIGURED_MESSAGE);
46
- }
47
- resolveByAuthType(profile, authType) {
48
- const strategy = this.strategies.find(s => s.name === authType);
49
- if (strategy === undefined) {
50
- throw new DefaultCredentialsError('AUTH_TYPE_NOT_FOUND', `auth type "${authType}" not found, please check ${AUTH_DOC_URL} for a list of supported auth types`);
51
- }
52
- const built = strategy.configure(profile);
53
- if (built === undefined) {
54
- throw new DefaultCredentialsError('NO_AUTH_CONFIGURED', NO_AUTH_CONFIGURED_MESSAGE);
55
- }
56
- return built;
57
- }
58
- }
9
+ * Lazy {@link Credentials} that resolves to a configured strategy on the
10
+ * first `authHeaders()` call.
11
+ *
12
+ * If the profile sets `authType`, the strategy whose name matches it is
13
+ * selected. Otherwise the strategies are tried in order and the first
14
+ * configured one wins.
15
+ */
16
+ var DefaultCredentials = class {
17
+ resolved;
18
+ constructor(strategies, loadProfile) {
19
+ this.strategies = strategies;
20
+ this.loadProfile = loadProfile;
21
+ }
22
+ /**
23
+ * Returns `default` until a strategy has been resolved, then delegates to
24
+ * the resolved strategy so callers (logging, telemetry) can tell which
25
+ * authentication method won.
26
+ */
27
+ name() {
28
+ return this.resolved?.name() ?? "default";
29
+ }
30
+ async authHeaders() {
31
+ this.resolved ??= await this.resolveChain();
32
+ return this.resolved.authHeaders();
33
+ }
34
+ async resolveChain() {
35
+ const profile = await this.loadProfile();
36
+ if (profile.authType !== void 0) return this.resolveByAuthType(profile, profile.authType);
37
+ for (const strategy of this.strategies) {
38
+ const built = strategy.configure(profile);
39
+ if (built !== void 0) return built;
40
+ }
41
+ throw new DefaultCredentialsError("NO_AUTH_CONFIGURED", NO_AUTH_CONFIGURED_MESSAGE);
42
+ }
43
+ resolveByAuthType(profile, authType) {
44
+ const strategy = this.strategies.find((s) => s.name === authType);
45
+ if (strategy === void 0) throw new DefaultCredentialsError("AUTH_TYPE_NOT_FOUND", `auth type "${authType}" not found, please check ${AUTH_DOC_URL} for a list of supported auth types`);
46
+ const built = strategy.configure(profile);
47
+ if (built === void 0) throw new DefaultCredentialsError("NO_AUTH_CONFIGURED", NO_AUTH_CONFIGURED_MESSAGE);
48
+ return built;
49
+ }
50
+ };
59
51
  /** PAT strategy: configured when `token` is set in the profile. */
60
- export const patStrategy = {
61
- name: 'pat',
62
- configure: profile => {
63
- if (profile.host === undefined)
64
- return undefined;
65
- if (profile.token === undefined)
66
- return undefined;
67
- return newPatCredentials(profile.token.value);
68
- },
52
+ const patStrategy = {
53
+ name: "pat",
54
+ configure: (profile) => {
55
+ if (profile.host === void 0) return void 0;
56
+ if (profile.token === void 0) return void 0;
57
+ return newPatCredentials(profile.token.value);
58
+ }
69
59
  };
70
60
  /**
71
- * OAuth M2M strategy: configured when `clientId` and `clientSecret` are
72
- * both set in the profile.
73
- */
74
- export const m2mStrategy = {
75
- name: 'oauth-m2m',
76
- configure: profile => {
77
- if (profile.host === undefined)
78
- return undefined;
79
- if (profile.clientId === undefined)
80
- return undefined;
81
- if (profile.clientSecret === undefined)
82
- return undefined;
83
- return newM2mCredentials({
84
- host: profile.host,
85
- clientId: profile.clientId,
86
- clientSecret: profile.clientSecret.value,
87
- ...(profile.accountId !== undefined && { accountId: profile.accountId }),
88
- });
89
- },
61
+ * OAuth M2M strategy: configured when `clientId` and `clientSecret` are
62
+ * both set in the profile.
63
+ */
64
+ const m2mStrategy = {
65
+ name: "oauth-m2m",
66
+ configure: (profile) => {
67
+ if (profile.host === void 0) return void 0;
68
+ if (profile.clientId === void 0) return void 0;
69
+ if (profile.clientSecret === void 0) return void 0;
70
+ return newM2mCredentials({
71
+ host: profile.host,
72
+ clientId: profile.clientId,
73
+ clientSecret: profile.clientSecret.value,
74
+ ...profile.accountId !== void 0 && { accountId: profile.accountId }
75
+ });
76
+ }
90
77
  };
78
+
79
+ //#endregion
80
+ export { DefaultCredentials, m2mStrategy, patStrategy };
91
81
  //# sourceMappingURL=chain.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/credentials/default/chain.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAC,uBAAuB,EAAC,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OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,EAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAC,CAAC;SACvE,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"chain.js","names":[],"sources":["../../../src/credentials/default/chain.ts"],"sourcesContent":["import type {Profile} from '@databricks/sdk-core/profiles';\n\nimport type {Credentials, Header} from '../../auth';\nimport {newM2mCredentials} from '../m2m';\nimport {newPatCredentials} from '../pat';\n\nimport {DefaultCredentialsError} from './errors';\n\n/**\n * A named strategy that inspects a profile and either returns configured\n * credentials or `undefined` if it is not applicable. The `name` matches the\n * `name()` of the credentials it produces, so it can be selected by a\n * profile's `authType`.\n */\nexport interface Strategy {\n /** Short identifier, e.g. `pat`, `oauth-m2m`, or `databricks-cli`. */\n readonly name: string;\n readonly configure: (profile: Profile) => Credentials | undefined;\n}\n\nconst AUTH_DOC_URL = 'https://docs.databricks.com/aws/en/dev-tools/auth/index';\nconst NO_AUTH_CONFIGURED_MESSAGE = `cannot configure default credentials, please check ${AUTH_DOC_URL} to configure credentials for your preferred authentication method`;\n\n/**\n * Lazy {@link Credentials} that resolves to a configured strategy on the\n * first `authHeaders()` call.\n *\n * If the profile sets `authType`, the strategy whose name matches it is\n * selected. Otherwise the strategies are tried in order and the first\n * configured one wins.\n */\nexport class DefaultCredentials implements Credentials {\n private resolved: Credentials | undefined;\n\n constructor(\n private readonly strategies: readonly Strategy[],\n private readonly loadProfile: () => Promise<Profile>\n ) {}\n\n /**\n * Returns `default` until a strategy has been resolved, then delegates to\n * the resolved strategy so callers (logging, telemetry) can tell which\n * authentication method won.\n */\n name(): string {\n return this.resolved?.name() ?? 'default';\n }\n\n async authHeaders(): Promise<Header[]> {\n this.resolved ??= await this.resolveChain();\n return this.resolved.authHeaders();\n }\n\n private async resolveChain(): Promise<Credentials> {\n const profile = await this.loadProfile();\n if (profile.authType !== undefined) {\n return this.resolveByAuthType(profile, profile.authType);\n }\n for (const strategy of this.strategies) {\n const built = strategy.configure(profile);\n if (built !== undefined) {\n return built;\n }\n }\n throw new DefaultCredentialsError(\n 'NO_AUTH_CONFIGURED',\n NO_AUTH_CONFIGURED_MESSAGE\n );\n }\n\n private resolveByAuthType(profile: Profile, authType: string): Credentials {\n const strategy = this.strategies.find(s => s.name === authType);\n if (strategy === undefined) {\n throw new DefaultCredentialsError(\n 'AUTH_TYPE_NOT_FOUND',\n `auth type \"${authType}\" not found, please check ${AUTH_DOC_URL} for a list of supported auth types`\n );\n }\n const built = strategy.configure(profile);\n if (built === undefined) {\n throw new DefaultCredentialsError(\n 'NO_AUTH_CONFIGURED',\n NO_AUTH_CONFIGURED_MESSAGE\n );\n }\n return built;\n }\n}\n\n/** PAT strategy: configured when `token` is set in the profile. */\nexport const patStrategy: Strategy = {\n name: 'pat',\n configure: profile => {\n if (profile.host === undefined) return undefined;\n if (profile.token === undefined) return undefined;\n return newPatCredentials(profile.token.value);\n },\n};\n\n/**\n * OAuth M2M strategy: configured when `clientId` and `clientSecret` are\n * both set in the profile.\n */\nexport const m2mStrategy: Strategy = {\n name: 'oauth-m2m',\n configure: profile => {\n if (profile.host === undefined) return undefined;\n if (profile.clientId === undefined) return undefined;\n if (profile.clientSecret === undefined) return undefined;\n return newM2mCredentials({\n host: profile.host,\n clientId: profile.clientId,\n clientSecret: profile.clientSecret.value,\n ...(profile.accountId !== undefined && {accountId: profile.accountId}),\n });\n },\n};\n"],"mappings":";;;;;AAoBA,MAAM,eAAe;AACrB,MAAM,6BAA6B,sDAAsD,aAAa;;;;;;;;;AAUtG,IAAa,qBAAb,MAAuD;CACrD,AAAQ;CAER,YACE,AAAiB,YACjB,AAAiB,aACjB;EAFiB;EACA;;;;;;;CAQnB,OAAe;AACb,SAAO,KAAK,UAAU,MAAM,IAAI;;CAGlC,MAAM,cAAiC;AACrC,OAAK,aAAa,MAAM,KAAK,cAAc;AAC3C,SAAO,KAAK,SAAS,aAAa;;CAGpC,MAAc,eAAqC;EACjD,MAAM,UAAU,MAAM,KAAK,aAAa;AACxC,MAAI,QAAQ,aAAa,OACvB,QAAO,KAAK,kBAAkB,SAAS,QAAQ,SAAS;AAE1D,OAAK,MAAM,YAAY,KAAK,YAAY;GACtC,MAAM,QAAQ,SAAS,UAAU,QAAQ;AACzC,OAAI,UAAU,OACZ,QAAO;;AAGX,QAAM,IAAI,wBACR,sBACA,2BACD;;CAGH,AAAQ,kBAAkB,SAAkB,UAA+B;EACzE,MAAM,WAAW,KAAK,WAAW,MAAK,MAAK,EAAE,SAAS,SAAS;AAC/D,MAAI,aAAa,OACf,OAAM,IAAI,wBACR,uBACA,cAAc,SAAS,4BAA4B,aAAa,qCACjE;EAEH,MAAM,QAAQ,SAAS,UAAU,QAAQ;AACzC,MAAI,UAAU,OACZ,OAAM,IAAI,wBACR,sBACA,2BACD;AAEH,SAAO;;;;AAKX,MAAa,cAAwB;CACnC,MAAM;CACN,YAAW,YAAW;AACpB,MAAI,QAAQ,SAAS,OAAW,QAAO;AACvC,MAAI,QAAQ,UAAU,OAAW,QAAO;AACxC,SAAO,kBAAkB,QAAQ,MAAM,MAAM;;CAEhD;;;;;AAMD,MAAa,cAAwB;CACnC,MAAM;CACN,YAAW,YAAW;AACpB,MAAI,QAAQ,SAAS,OAAW,QAAO;AACvC,MAAI,QAAQ,aAAa,OAAW,QAAO;AAC3C,MAAI,QAAQ,iBAAiB,OAAW,QAAO;AAC/C,SAAO,kBAAkB;GACvB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,cAAc,QAAQ,aAAa;GACnC,GAAI,QAAQ,cAAc,UAAa,EAAC,WAAW,QAAQ,WAAU;GACtE,CAAC;;CAEL"}
@@ -1,11 +1,13 @@
1
- import type { Profile } from '@databricks/sdk-core/profiles';
2
- import type { Credentials } from '../../auth';
1
+ import { Credentials } from "../../auth.js";
2
+ import { Profile } from "@databricks/sdk-core/profiles";
3
+
4
+ //#region src/credentials/default/default-credentials.d.ts
3
5
  interface DefaultCredentialsOptions {
4
- /**
5
- * Pre-resolved profile. When omitted, the profile is resolved on first
6
- * use from the default config file and environment variables.
7
- */
8
- profile?: Profile;
6
+ /**
7
+ * Pre-resolved profile. When omitted, the profile is resolved on first
8
+ * use from the default config file and environment variables.
9
+ */
10
+ profile?: Profile;
9
11
  }
10
12
  /**
11
13
  * Returns a lazy {@link Credentials} that resolves to the first configured
@@ -20,6 +22,7 @@ interface DefaultCredentialsOptions {
20
22
  * resolved on first use from the default config file (~/.databrickscfg)
21
23
  * and environment variables.
22
24
  */
23
- export declare function defaultCredentials(options?: DefaultCredentialsOptions): Credentials;
24
- export {};
25
+ declare function defaultCredentials(options?: DefaultCredentialsOptions): Credentials;
26
+ //#endregion
27
+ export { defaultCredentials };
25
28
  //# sourceMappingURL=default-credentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-credentials.d.ts","sourceRoot":"","sources":["../../../src/credentials/default/default-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAQ5C,UAAU,yBAAyB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,yBAAyB,GAClC,WAAW,CAKb"}
1
+ {"version":3,"file":"default-credentials.d.ts","names":[],"sources":["../../../src/credentials/default/default-credentials.ts"],"mappings":";;;;UAWU,yBAAA;;AARkC;;;EAa1C,OAAA,GAAU,OAAA;AAAA;AAgBZ;;;;;;;;;;;;;AAAA,iBAAgB,kBAAA,CACd,OAAA,GAAU,yBAAA,GACT,WAAA"}
@@ -1,23 +1,32 @@
1
- import { resolve } from '@databricks/sdk-core/profiles';
2
- import { DefaultCredentials, m2mStrategy, patStrategy } from './chain';
3
- import { u2mStrategy } from './u2m-strategy';
4
- const STRATEGIES = [patStrategy, m2mStrategy, u2mStrategy];
1
+ import { DefaultCredentials, m2mStrategy, patStrategy } from "./chain.js";
2
+ import { u2mStrategy } from "./u2m-strategy.js";
3
+ import { resolve } from "@databricks/sdk-core/profiles";
4
+
5
+ //#region src/credentials/default/default-credentials.ts
6
+ const STRATEGIES = [
7
+ patStrategy,
8
+ m2mStrategy,
9
+ u2mStrategy
10
+ ];
5
11
  /**
6
- * Returns a lazy {@link Credentials} that resolves to the first configured
7
- * authentication strategy on first use.
8
- *
9
- * Strategies are tried in this order:
10
- * 1. PAT (`pat`).
11
- * 2. OAuth M2M (`oauth-m2m`).
12
- * 3. Databricks CLI (`databricks-cli`).
13
- *
14
- * When no profile is provided via `options.profile`, the profile is
15
- * resolved on first use from the default config file (~/.databrickscfg)
16
- * and environment variables.
17
- */
18
- export function defaultCredentials(options) {
19
- const explicit = options?.profile;
20
- const loadProfile = () => explicit !== undefined ? Promise.resolve(explicit) : resolve();
21
- return new DefaultCredentials(STRATEGIES, loadProfile);
12
+ * Returns a lazy {@link Credentials} that resolves to the first configured
13
+ * authentication strategy on first use.
14
+ *
15
+ * Strategies are tried in this order:
16
+ * 1. PAT (`pat`).
17
+ * 2. OAuth M2M (`oauth-m2m`).
18
+ * 3. Databricks CLI (`databricks-cli`).
19
+ *
20
+ * When no profile is provided via `options.profile`, the profile is
21
+ * resolved on first use from the default config file (~/.databrickscfg)
22
+ * and environment variables.
23
+ */
24
+ function defaultCredentials(options) {
25
+ const explicit = options?.profile;
26
+ const loadProfile = () => explicit !== void 0 ? Promise.resolve(explicit) : resolve();
27
+ return new DefaultCredentials(STRATEGIES, loadProfile);
22
28
  }
29
+
30
+ //#endregion
31
+ export { defaultCredentials };
23
32
  //# sourceMappingURL=default-credentials.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-credentials.js","sourceRoot":"","sources":["../../../src/credentials/default/default-credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAItD,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAErE,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,GAAwB,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AAUhF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAmC;IAEnC,MAAM,QAAQ,GAAG,OAAO,EAAE,OAAO,CAAC;IAClC,MAAM,WAAW,GAAG,GAAqB,EAAE,CACzC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjE,OAAO,IAAI,kBAAkB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC"}
1
+ {"version":3,"file":"default-credentials.js","names":[],"sources":["../../../src/credentials/default/default-credentials.ts"],"sourcesContent":["import type {Profile} from '@databricks/sdk-core/profiles';\nimport {resolve} from '@databricks/sdk-core/profiles';\n\nimport type {Credentials} from '../../auth';\n\nimport {DefaultCredentials, m2mStrategy, patStrategy} from './chain';\nimport type {Strategy} from './chain';\nimport {u2mStrategy} from './u2m-strategy';\n\nconst STRATEGIES: readonly Strategy[] = [patStrategy, m2mStrategy, u2mStrategy];\n\ninterface DefaultCredentialsOptions {\n /**\n * Pre-resolved profile. When omitted, the profile is resolved on first\n * use from the default config file and environment variables.\n */\n profile?: Profile;\n}\n\n/**\n * Returns a lazy {@link Credentials} that resolves to the first configured\n * authentication strategy on first use.\n *\n * Strategies are tried in this order:\n * 1. PAT (`pat`).\n * 2. OAuth M2M (`oauth-m2m`).\n * 3. Databricks CLI (`databricks-cli`).\n *\n * When no profile is provided via `options.profile`, the profile is\n * resolved on first use from the default config file (~/.databrickscfg)\n * and environment variables.\n */\nexport function defaultCredentials(\n options?: DefaultCredentialsOptions\n): Credentials {\n const explicit = options?.profile;\n const loadProfile = (): Promise<Profile> =>\n explicit !== undefined ? Promise.resolve(explicit) : resolve();\n return new DefaultCredentials(STRATEGIES, loadProfile);\n}\n"],"mappings":";;;;;AASA,MAAM,aAAkC;CAAC;CAAa;CAAa;CAAY;;;;;;;;;;;;;;AAuB/E,SAAgB,mBACd,SACa;CACb,MAAM,WAAW,SAAS;CAC1B,MAAM,oBACJ,aAAa,SAAY,QAAQ,QAAQ,SAAS,GAAG,SAAS;AAChE,QAAO,IAAI,mBAAmB,YAAY,YAAY"}
@@ -1,13 +1,16 @@
1
+ //#region src/credentials/default/errors.d.ts
1
2
  /** Discriminant codes for {@link DefaultCredentialsError}. */
2
- export type DefaultCredentialsErrorCode = 'NO_AUTH_CONFIGURED' | 'AUTH_TYPE_NOT_FOUND';
3
+ type DefaultCredentialsErrorCode = 'NO_AUTH_CONFIGURED' | 'AUTH_TYPE_NOT_FOUND';
3
4
  /**
4
5
  * Error thrown when the default credentials chain cannot resolve a
5
6
  * strategy to authenticate with.
6
7
  *
7
8
  * Use the `code` field to distinguish between error causes.
8
9
  */
9
- export declare class DefaultCredentialsError extends Error {
10
- readonly code: DefaultCredentialsErrorCode;
11
- constructor(code: DefaultCredentialsErrorCode, message: string);
10
+ declare class DefaultCredentialsError extends Error {
11
+ readonly code: DefaultCredentialsErrorCode;
12
+ constructor(code: DefaultCredentialsErrorCode, message: string);
12
13
  }
14
+ //#endregion
15
+ export { DefaultCredentialsError, DefaultCredentialsErrorCode };
13
16
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/credentials/default/errors.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,2BAA2B,GACnC,oBAAoB,GACpB,qBAAqB,CAAC;AAE1B;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;gBAE/B,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM;CAK/D"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../../src/credentials/default/errors.ts"],"mappings":";;KACY,2BAAA;;;;;AAUZ;;cAAa,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA,EAAM,2BAAA;cAEH,IAAA,EAAM,2BAAA,EAA6B,OAAA;AAAA"}