@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.
- package/dist/auth.d.ts +42 -40
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +38 -42
- package/dist/auth.js.map +1 -1
- package/dist/credentials/default/chain.d.ts +26 -22
- package/dist/credentials/default/chain.d.ts.map +1 -1
- package/dist/credentials/default/chain.js +74 -84
- package/dist/credentials/default/chain.js.map +1 -1
- package/dist/credentials/default/default-credentials.d.ts +12 -9
- package/dist/credentials/default/default-credentials.d.ts.map +1 -1
- package/dist/credentials/default/default-credentials.js +29 -20
- package/dist/credentials/default/default-credentials.js.map +1 -1
- package/dist/credentials/default/errors.d.ts +7 -4
- package/dist/credentials/default/errors.d.ts.map +1 -1
- package/dist/credentials/default/errors.js +17 -13
- package/dist/credentials/default/errors.js.map +1 -1
- package/dist/credentials/default/u2m-strategy.d.ts +6 -2
- package/dist/credentials/default/u2m-strategy.d.ts.map +1 -1
- package/dist/credentials/default/u2m-strategy.js +21 -20
- package/dist/credentials/default/u2m-strategy.js.map +1 -1
- package/dist/credentials/errors.d.ts +15 -12
- package/dist/credentials/errors.d.ts.map +1 -1
- package/dist/credentials/errors.js +40 -41
- package/dist/credentials/errors.js.map +1 -1
- package/dist/credentials/host-metadata.d.ts +22 -19
- package/dist/credentials/host-metadata.d.ts.map +1 -1
- package/dist/credentials/host-metadata.js +88 -109
- package/dist/credentials/host-metadata.js.map +1 -1
- package/dist/credentials/index.browser.d.ts +4 -11
- package/dist/credentials/index.browser.js +5 -9
- package/dist/credentials/index.d.ts +7 -14
- package/dist/credentials/index.js +8 -10
- package/dist/credentials/m2m.d.ts +29 -28
- package/dist/credentials/m2m.d.ts.map +1 -1
- package/dist/credentials/m2m.js +66 -81
- package/dist/credentials/m2m.js.map +1 -1
- package/dist/credentials/pat.d.ts +6 -5
- package/dist/credentials/pat.d.ts.map +1 -1
- package/dist/credentials/pat.js +33 -37
- package/dist/credentials/pat.js.map +1 -1
- package/dist/credentials/u2m.d.ts +17 -20
- package/dist/credentials/u2m.d.ts.map +1 -1
- package/dist/credentials/u2m.js +107 -135
- package/dist/credentials/u2m.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/oidc/env.d.ts +6 -2
- package/dist/oidc/env.d.ts.map +1 -1
- package/dist/oidc/env.js +19 -16
- package/dist/oidc/env.js.map +1 -1
- package/dist/oidc/file.d.ts +6 -2
- package/dist/oidc/file.d.ts.map +1 -1
- package/dist/oidc/file.js +23 -25
- package/dist/oidc/file.js.map +1 -1
- package/dist/oidc/index.browser.d.ts +3 -13
- package/dist/oidc/index.browser.js +4 -11
- package/dist/oidc/index.d.ts +5 -14
- package/dist/oidc/index.js +6 -12
- package/dist/oidc/oidc.d.ts +8 -5
- package/dist/oidc/oidc.d.ts.map +1 -1
- package/dist/oidc/oidc.js +11 -7
- package/dist/oidc/oidc.js.map +1 -1
- package/dist/oidc/tokensource.d.ts +41 -41
- package/dist/oidc/tokensource.d.ts.map +1 -1
- package/dist/oidc/tokensource.js +47 -52
- package/dist/oidc/tokensource.js.map +1 -1
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/package.json +3 -3
- package/dist/credentials/index.browser.d.ts.map +0 -1
- package/dist/credentials/index.browser.js.map +0 -1
- package/dist/credentials/index.d.ts.map +0 -1
- package/dist/credentials/index.js.map +0 -1
- package/dist/oidc/index.browser.d.ts.map +0 -1
- package/dist/oidc/index.browser.js.map +0 -1
- package/dist/oidc/index.d.ts.map +0 -1
- package/dist/oidc/index.js.map +0 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { M2mCredentialsError, PatCredentialsError } from './errors';
|
|
7
|
-
export { newM2mCredentials } from './m2m';
|
|
8
|
-
export { newPatCredentials } from './pat';
|
|
9
|
-
//# sourceMappingURL=index.browser.js.map
|
|
1
|
+
import { M2mCredentialsError, PatCredentialsError } from "./errors.js";
|
|
2
|
+
import { newM2mCredentials } from "./m2m.js";
|
|
3
|
+
import { newPatCredentials } from "./pat.js";
|
|
4
|
+
|
|
5
|
+
export { M2mCredentialsError, PatCredentialsError, newM2mCredentials, newPatCredentials };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
export { newPatCredentials } from './pat';
|
|
9
|
-
export { newU2mCredentials } from './u2m';
|
|
10
|
-
export type { U2mCredentialsOptions } from './u2m';
|
|
11
|
-
export { defaultCredentials } from './default/default-credentials';
|
|
12
|
-
export { DefaultCredentialsError } from './default/errors';
|
|
13
|
-
export type { DefaultCredentialsErrorCode } from './default/errors';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { defaultCredentials } from "./default/default-credentials.js";
|
|
2
|
+
import { DefaultCredentialsError, DefaultCredentialsErrorCode } from "./default/errors.js";
|
|
3
|
+
import { M2mCredentialsError, M2mCredentialsErrorCode, PatCredentialsError, PatCredentialsErrorCode, U2mCredentialsError, U2mCredentialsErrorCode } from "./errors.js";
|
|
4
|
+
import { M2mCredentialsOptions, newM2mCredentials } from "./m2m.js";
|
|
5
|
+
import { newPatCredentials } from "./pat.js";
|
|
6
|
+
import { U2mCredentialsOptions, newU2mCredentials } from "./u2m.js";
|
|
7
|
+
export { DefaultCredentialsError, type DefaultCredentialsErrorCode, M2mCredentialsError, type M2mCredentialsErrorCode, type M2mCredentialsOptions, PatCredentialsError, type PatCredentialsErrorCode, U2mCredentialsError, type U2mCredentialsErrorCode, type U2mCredentialsOptions, defaultCredentials, newM2mCredentials, newPatCredentials, newU2mCredentials };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { defaultCredentials
|
|
9
|
-
export { DefaultCredentialsError } from './default/errors';
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { M2mCredentialsError, PatCredentialsError, U2mCredentialsError } from "./errors.js";
|
|
2
|
+
import { newM2mCredentials } from "./m2m.js";
|
|
3
|
+
import { newPatCredentials } from "./pat.js";
|
|
4
|
+
import { newU2mCredentials } from "./u2m.js";
|
|
5
|
+
import { DefaultCredentialsError } from "./default/errors.js";
|
|
6
|
+
import { defaultCredentials } from "./default/default-credentials.js";
|
|
7
|
+
|
|
8
|
+
export { DefaultCredentialsError, M2mCredentialsError, PatCredentialsError, U2mCredentialsError, defaultCredentials, newM2mCredentials, newPatCredentials, newU2mCredentials };
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { TokenCredentials } from '../auth';
|
|
1
|
+
import { TokenCredentials } from "../auth.js";
|
|
2
|
+
|
|
3
|
+
//#region src/credentials/m2m.d.ts
|
|
5
4
|
/** Options for {@link newM2mCredentials}. */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
interface M2mCredentialsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Databricks host (workspace or account) used to discover the OAuth token
|
|
8
|
+
* endpoint.
|
|
9
|
+
*/
|
|
10
|
+
host: string;
|
|
11
|
+
/**
|
|
12
|
+
* OAuth client ID issued to the service principal.
|
|
13
|
+
*/
|
|
14
|
+
clientId: string;
|
|
15
|
+
/**
|
|
16
|
+
* OAuth client secret issued to the service principal.
|
|
17
|
+
*/
|
|
18
|
+
clientSecret: string;
|
|
19
|
+
/**
|
|
20
|
+
* Databricks account ID. Required for account hosts.
|
|
21
|
+
*/
|
|
22
|
+
accountId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* OAuth scopes to request. When omitted or empty, defaults to
|
|
25
|
+
* `['all-apis']`.
|
|
26
|
+
*/
|
|
27
|
+
scopes?: string[];
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Creates a TokenCredentials that authenticates as a Databricks service
|
|
@@ -36,5 +35,7 @@ export interface M2mCredentialsOptions {
|
|
|
36
35
|
* when token-endpoint discovery fails, or when the token endpoint returns
|
|
37
36
|
* an error.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
declare function newM2mCredentials(options: M2mCredentialsOptions): TokenCredentials;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { M2mCredentialsOptions, newM2mCredentials };
|
|
40
41
|
//# sourceMappingURL=m2m.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m2m.d.ts","
|
|
1
|
+
{"version":3,"file":"m2m.d.ts","names":[],"sources":["../../src/credentials/m2m.ts"],"mappings":";;;;UAaiB,qBAAA;EAAqB;;;;EAKpC,IAAA;EAqBA;;;EAhBA,QAAA;EA8B+B;;;EAzB/B,YAAA;EA0BA;;;EArBA,SAAA;;;;;EAMA,MAAA;AAAA;;;;;;;;;;iBAcc,iBAAA,CACd,OAAA,EAAS,qBAAA,GACR,gBAAA"}
|
package/dist/credentials/m2m.js
CHANGED
|
@@ -1,91 +1,76 @@
|
|
|
1
|
+
import { newTokenCredentials, tokenProviderFn } from "../auth.js";
|
|
2
|
+
import { M2mCredentialsError } from "./errors.js";
|
|
3
|
+
import { resolveTokenEndpoint } from "./host-metadata.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/credentials/m2m.ts
|
|
1
7
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { newTokenCredentials, tokenProviderFn } from '../auth';
|
|
6
|
-
import { M2mCredentialsError } from './errors';
|
|
7
|
-
import { resolveTokenEndpoint } from './host-metadata';
|
|
8
|
-
const DEFAULT_SCOPES = ['all-apis'];
|
|
8
|
+
* Machine-to-machine (M2M) OAuth credentials for the Databricks SDK.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_SCOPES = ["all-apis"];
|
|
9
11
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const getTokenEndpoint = async () => {
|
|
41
|
-
if (cachedTokenEndpoint === undefined) {
|
|
42
|
-
try {
|
|
43
|
-
cachedTokenEndpoint = await resolveTokenEndpoint(options.host, options.accountId);
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
throw new M2mCredentialsError('DISCOVERY_FAILED', `discovering token endpoint failed: ${stringifyError(e)}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return cachedTokenEndpoint;
|
|
50
|
-
};
|
|
51
|
-
const provider = tokenProviderFn(async () => {
|
|
52
|
-
const tokenEndpoint = await getTokenEndpoint();
|
|
53
|
-
return fetchAccessToken(tokenEndpoint, basicAuth, body);
|
|
54
|
-
});
|
|
55
|
-
return newTokenCredentials('oauth-m2m', provider);
|
|
12
|
+
* Creates a TokenCredentials that authenticates as a Databricks service
|
|
13
|
+
* principal using the OAuth client credentials grant.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Host plus client credentials.
|
|
16
|
+
* @throws M2mCredentialsError when host, clientId, or clientSecret is empty,
|
|
17
|
+
* when token-endpoint discovery fails, or when the token endpoint returns
|
|
18
|
+
* an error.
|
|
19
|
+
*/
|
|
20
|
+
function newM2mCredentials(options) {
|
|
21
|
+
if (options.clientId === "") throw new M2mCredentialsError("CLIENT_ID_REQUIRED", "clientId is required");
|
|
22
|
+
if (options.clientSecret === "") throw new M2mCredentialsError("CLIENT_SECRET_REQUIRED", "clientSecret is required");
|
|
23
|
+
if (options.host === "") throw new M2mCredentialsError("HOST_REQUIRED", "host is required");
|
|
24
|
+
const scopes = options.scopes !== void 0 && options.scopes.length > 0 ? options.scopes : DEFAULT_SCOPES;
|
|
25
|
+
const body = new URLSearchParams({
|
|
26
|
+
grant_type: "client_credentials",
|
|
27
|
+
scope: scopes.join(" ")
|
|
28
|
+
}).toString();
|
|
29
|
+
const basicAuth = btoa(`${encodeURIComponent(options.clientId)}:${encodeURIComponent(options.clientSecret)}`);
|
|
30
|
+
let cachedTokenEndpoint;
|
|
31
|
+
const getTokenEndpoint = async () => {
|
|
32
|
+
if (cachedTokenEndpoint === void 0) try {
|
|
33
|
+
cachedTokenEndpoint = await resolveTokenEndpoint(options.host, options.accountId);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new M2mCredentialsError("DISCOVERY_FAILED", `discovering token endpoint failed: ${stringifyError(e)}`);
|
|
36
|
+
}
|
|
37
|
+
return cachedTokenEndpoint;
|
|
38
|
+
};
|
|
39
|
+
return newTokenCredentials("oauth-m2m", tokenProviderFn(async () => {
|
|
40
|
+
return fetchAccessToken(await getTokenEndpoint(), basicAuth, body);
|
|
41
|
+
}));
|
|
56
42
|
}
|
|
57
43
|
async function fetchAccessToken(tokenEndpoint, basicAuth, body) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...(expiry !== undefined && { expiry }),
|
|
78
|
-
};
|
|
44
|
+
const response = await fetch(tokenEndpoint, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Basic ${basicAuth}`,
|
|
48
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
49
|
+
},
|
|
50
|
+
body
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const text = await response.text();
|
|
54
|
+
throw new M2mCredentialsError("TOKEN_REQUEST_FAILED", `token request failed with status ${response.status.toString()}: ${text}`);
|
|
55
|
+
}
|
|
56
|
+
const parsed = tokenResponseSchema.parse(await response.json());
|
|
57
|
+
const expiry = parsed.expires_in !== void 0 ? new Date(Date.now() + parsed.expires_in * 1e3) : void 0;
|
|
58
|
+
return {
|
|
59
|
+
value: parsed.access_token,
|
|
60
|
+
...parsed.token_type !== void 0 && { type: parsed.token_type },
|
|
61
|
+
...expiry !== void 0 && { expiry }
|
|
62
|
+
};
|
|
79
63
|
}
|
|
80
64
|
const tokenResponseSchema = z.object({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
access_token: z.string(),
|
|
66
|
+
token_type: z.string().optional(),
|
|
67
|
+
expires_in: z.number().optional()
|
|
84
68
|
});
|
|
85
69
|
function stringifyError(e) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
return String(e);
|
|
70
|
+
if (e instanceof Error) return e.message;
|
|
71
|
+
return String(e);
|
|
90
72
|
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { newM2mCredentials };
|
|
91
76
|
//# sourceMappingURL=m2m.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m2m.js","
|
|
1
|
+
{"version":3,"file":"m2m.js","names":[],"sources":["../../src/credentials/m2m.ts"],"sourcesContent":["/**\n * Machine-to-machine (M2M) OAuth credentials for the Databricks SDK.\n */\n\nimport {z} from 'zod';\n\nimport type {Token, TokenCredentials} from '../auth';\nimport {newTokenCredentials, tokenProviderFn} from '../auth';\n\nimport {M2mCredentialsError} from './errors';\nimport {resolveTokenEndpoint} from './host-metadata';\n\n/** Options for {@link newM2mCredentials}. */\nexport interface M2mCredentialsOptions {\n /**\n * Databricks host (workspace or account) used to discover the OAuth token\n * endpoint.\n */\n host: string;\n\n /**\n * OAuth client ID issued to the service principal.\n */\n clientId: string;\n\n /**\n * OAuth client secret issued to the service principal.\n */\n clientSecret: string;\n\n /**\n * Databricks account ID. Required for account hosts.\n */\n accountId?: string;\n\n /**\n * OAuth scopes to request. When omitted or empty, defaults to\n * `['all-apis']`.\n */\n scopes?: string[];\n}\n\nconst DEFAULT_SCOPES: readonly string[] = ['all-apis'];\n\n/**\n * Creates a TokenCredentials that authenticates as a Databricks service\n * principal using the OAuth client credentials grant.\n *\n * @param options - Host plus client credentials.\n * @throws M2mCredentialsError when host, clientId, or clientSecret is empty,\n * when token-endpoint discovery fails, or when the token endpoint returns\n * an error.\n */\nexport function newM2mCredentials(\n options: M2mCredentialsOptions\n): TokenCredentials {\n if (options.clientId === '') {\n throw new M2mCredentialsError('CLIENT_ID_REQUIRED', 'clientId is required');\n }\n if (options.clientSecret === '') {\n throw new M2mCredentialsError(\n 'CLIENT_SECRET_REQUIRED',\n 'clientSecret is required'\n );\n }\n if (options.host === '') {\n throw new M2mCredentialsError('HOST_REQUIRED', 'host is required');\n }\n\n const scopes =\n options.scopes !== undefined && options.scopes.length > 0\n ? options.scopes\n : DEFAULT_SCOPES;\n\n const body = new URLSearchParams({\n grant_type: 'client_credentials',\n scope: scopes.join(' '),\n }).toString();\n\n // Client ID and secret are URL-encoded before Basic auth encoding to\n // avoid ambiguity with special characters in either value, matching the\n // behavior of golang.org/x/oauth2.\n const basicAuth = btoa(\n `${encodeURIComponent(options.clientId)}:${encodeURIComponent(options.clientSecret)}`\n );\n\n let cachedTokenEndpoint: string | undefined;\n const getTokenEndpoint = async (): Promise<string> => {\n if (cachedTokenEndpoint === undefined) {\n try {\n cachedTokenEndpoint = await resolveTokenEndpoint(\n options.host,\n options.accountId\n );\n } catch (e) {\n throw new M2mCredentialsError(\n 'DISCOVERY_FAILED',\n `discovering token endpoint failed: ${stringifyError(e)}`\n );\n }\n }\n return cachedTokenEndpoint;\n };\n\n const provider = tokenProviderFn(async () => {\n const tokenEndpoint = await getTokenEndpoint();\n return fetchAccessToken(tokenEndpoint, basicAuth, body);\n });\n\n return newTokenCredentials('oauth-m2m', provider);\n}\n\nasync function fetchAccessToken(\n tokenEndpoint: string,\n basicAuth: string,\n body: string\n): Promise<Token> {\n const response = await fetch(tokenEndpoint, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${basicAuth}`,\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body,\n });\n if (!response.ok) {\n const text = await response.text();\n throw new M2mCredentialsError(\n 'TOKEN_REQUEST_FAILED',\n `token request failed with status ${response.status.toString()}: ${text}`\n );\n }\n const parsed = tokenResponseSchema.parse(await response.json());\n const expiry =\n parsed.expires_in !== undefined\n ? new Date(Date.now() + parsed.expires_in * 1000)\n : undefined;\n return {\n value: parsed.access_token,\n ...(parsed.token_type !== undefined && {type: parsed.token_type}),\n ...(expiry !== undefined && {expiry}),\n };\n}\n\nconst tokenResponseSchema = z.object({\n access_token: z.string(),\n token_type: z.string().optional(),\n expires_in: z.number().optional(),\n});\n\nfunction stringifyError(e: unknown): string {\n if (e instanceof Error) {\n return e.message;\n }\n return String(e);\n}\n"],"mappings":";;;;;;;;;AA0CA,MAAM,iBAAoC,CAAC,WAAW;;;;;;;;;;AAWtD,SAAgB,kBACd,SACkB;AAClB,KAAI,QAAQ,aAAa,GACvB,OAAM,IAAI,oBAAoB,sBAAsB,uBAAuB;AAE7E,KAAI,QAAQ,iBAAiB,GAC3B,OAAM,IAAI,oBACR,0BACA,2BACD;AAEH,KAAI,QAAQ,SAAS,GACnB,OAAM,IAAI,oBAAoB,iBAAiB,mBAAmB;CAGpE,MAAM,SACJ,QAAQ,WAAW,UAAa,QAAQ,OAAO,SAAS,IACpD,QAAQ,SACR;CAEN,MAAM,OAAO,IAAI,gBAAgB;EAC/B,YAAY;EACZ,OAAO,OAAO,KAAK,IAAI;EACxB,CAAC,CAAC,UAAU;CAKb,MAAM,YAAY,KAChB,GAAG,mBAAmB,QAAQ,SAAS,CAAC,GAAG,mBAAmB,QAAQ,aAAa,GACpF;CAED,IAAI;CACJ,MAAM,mBAAmB,YAA6B;AACpD,MAAI,wBAAwB,OAC1B,KAAI;AACF,yBAAsB,MAAM,qBAC1B,QAAQ,MACR,QAAQ,UACT;WACM,GAAG;AACV,SAAM,IAAI,oBACR,oBACA,sCAAsC,eAAe,EAAE,GACxD;;AAGL,SAAO;;AAQT,QAAO,oBAAoB,aALV,gBAAgB,YAAY;AAE3C,SAAO,iBADe,MAAM,kBAAkB,EACP,WAAW,KAAK;GACvD,CAE+C;;AAGnD,eAAe,iBACb,eACA,WACA,MACgB;CAChB,MAAM,WAAW,MAAM,MAAM,eAAe;EAC1C,QAAQ;EACR,SAAS;GACP,eAAe,SAAS;GACxB,gBAAgB;GACjB;EACD;EACD,CAAC;AACF,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,QAAM,IAAI,oBACR,wBACA,oCAAoC,SAAS,OAAO,UAAU,CAAC,IAAI,OACpE;;CAEH,MAAM,SAAS,oBAAoB,MAAM,MAAM,SAAS,MAAM,CAAC;CAC/D,MAAM,SACJ,OAAO,eAAe,SAClB,IAAI,KAAK,KAAK,KAAK,GAAG,OAAO,aAAa,IAAK,GAC/C;AACN,QAAO;EACL,OAAO,OAAO;EACd,GAAI,OAAO,eAAe,UAAa,EAAC,MAAM,OAAO,YAAW;EAChE,GAAI,WAAW,UAAa,EAAC,QAAO;EACrC;;AAGH,MAAM,sBAAsB,EAAE,OAAO;CACnC,cAAc,EAAE,QAAQ;CACxB,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,YAAY,EAAE,QAAQ,CAAC,UAAU;CAClC,CAAC;AAEF,SAAS,eAAe,GAAoB;AAC1C,KAAI,aAAa,MACf,QAAO,EAAE;AAEX,QAAO,OAAO,EAAE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { Credentials } from '../auth';
|
|
1
|
+
import { Credentials } from "../auth.js";
|
|
2
|
+
|
|
3
|
+
//#region src/credentials/pat.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Creates a Credentials that can be used to authenticate with a Personal
|
|
7
6
|
* Access Token.
|
|
@@ -11,5 +10,7 @@ import type { Credentials } from '../auth';
|
|
|
11
10
|
* @throws PatCredentialsError with code `TOKEN_REQUIRED` if the token is empty
|
|
12
11
|
* after trimming, or `TOKEN_MALFORMED` if it contains internal whitespace.
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
declare function newPatCredentials(token: string): Credentials;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { newPatCredentials };
|
|
15
16
|
//# sourceMappingURL=pat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pat.d.ts","
|
|
1
|
+
{"version":3,"file":"pat.d.ts","names":[],"sources":["../../src/credentials/pat.ts"],"mappings":";;;;;;;;;;;;iBAiBgB,iBAAA,CAAkB,KAAA,WAAgB,WAAA"}
|
package/dist/credentials/pat.js
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
|
+
import { PatCredentialsError } from "./errors.js";
|
|
2
|
+
|
|
3
|
+
//#region src/credentials/pat.ts
|
|
1
4
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const trimmed = token.trim();
|
|
16
|
-
if (trimmed === '') {
|
|
17
|
-
throw new PatCredentialsError('TOKEN_REQUIRED', 'token is required');
|
|
18
|
-
}
|
|
19
|
-
// Internal whitespace would corrupt the header even after trimming, so
|
|
20
|
-
// reject it rather than silently producing a malformed `Bearer` value.
|
|
21
|
-
if (/\s/.test(trimmed)) {
|
|
22
|
-
throw new PatCredentialsError('TOKEN_MALFORMED', 'token must not contain whitespace');
|
|
23
|
-
}
|
|
24
|
-
return new PatCredentials(trimmed);
|
|
25
|
-
}
|
|
26
|
-
class PatCredentials {
|
|
27
|
-
token;
|
|
28
|
-
constructor(token) {
|
|
29
|
-
this.token = token;
|
|
30
|
-
}
|
|
31
|
-
name() {
|
|
32
|
-
return 'pat';
|
|
33
|
-
}
|
|
34
|
-
authHeaders() {
|
|
35
|
-
return Promise.resolve([
|
|
36
|
-
{ key: 'Authorization', value: `Bearer ${this.token}` },
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
5
|
+
* Creates a Credentials that can be used to authenticate with a Personal
|
|
6
|
+
* Access Token.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The personal access token.
|
|
9
|
+
* @returns Credentials for PAT authentication.
|
|
10
|
+
* @throws PatCredentialsError with code `TOKEN_REQUIRED` if the token is empty
|
|
11
|
+
* after trimming, or `TOKEN_MALFORMED` if it contains internal whitespace.
|
|
12
|
+
*/
|
|
13
|
+
function newPatCredentials(token) {
|
|
14
|
+
const trimmed = token.trim();
|
|
15
|
+
if (trimmed === "") throw new PatCredentialsError("TOKEN_REQUIRED", "token is required");
|
|
16
|
+
if (/\s/.test(trimmed)) throw new PatCredentialsError("TOKEN_MALFORMED", "token must not contain whitespace");
|
|
17
|
+
return new PatCredentials(trimmed);
|
|
39
18
|
}
|
|
19
|
+
var PatCredentials = class {
|
|
20
|
+
constructor(token) {
|
|
21
|
+
this.token = token;
|
|
22
|
+
}
|
|
23
|
+
name() {
|
|
24
|
+
return "pat";
|
|
25
|
+
}
|
|
26
|
+
authHeaders() {
|
|
27
|
+
return Promise.resolve([{
|
|
28
|
+
key: "Authorization",
|
|
29
|
+
value: `Bearer ${this.token}`
|
|
30
|
+
}]);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { newPatCredentials };
|
|
40
36
|
//# sourceMappingURL=pat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pat.js","
|
|
1
|
+
{"version":3,"file":"pat.js","names":[],"sources":["../../src/credentials/pat.ts"],"sourcesContent":["/**\n * Personal Access Token (PAT) credentials for the Databricks SDK.\n */\n\nimport type {Credentials, Header} from '../auth';\n\nimport {PatCredentialsError} from './errors';\n\n/**\n * Creates a Credentials that can be used to authenticate with a Personal\n * Access Token.\n *\n * @param token - The personal access token.\n * @returns Credentials for PAT authentication.\n * @throws PatCredentialsError with code `TOKEN_REQUIRED` if the token is empty\n * after trimming, or `TOKEN_MALFORMED` if it contains internal whitespace.\n */\nexport function newPatCredentials(token: string): Credentials {\n const trimmed = token.trim();\n if (trimmed === '') {\n throw new PatCredentialsError('TOKEN_REQUIRED', 'token is required');\n }\n // Internal whitespace would corrupt the header even after trimming, so\n // reject it rather than silently producing a malformed `Bearer` value.\n if (/\\s/.test(trimmed)) {\n throw new PatCredentialsError(\n 'TOKEN_MALFORMED',\n 'token must not contain whitespace'\n );\n }\n return new PatCredentials(trimmed);\n}\n\nclass PatCredentials implements Credentials {\n constructor(private readonly token: string) {}\n\n name(): string {\n return 'pat';\n }\n\n authHeaders(): Promise<Header[]> {\n return Promise.resolve([\n {key: 'Authorization', value: `Bearer ${this.token}`},\n ]);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,kBAAkB,OAA4B;CAC5D,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,YAAY,GACd,OAAM,IAAI,oBAAoB,kBAAkB,oBAAoB;AAItE,KAAI,KAAK,KAAK,QAAQ,CACpB,OAAM,IAAI,oBACR,mBACA,oCACD;AAEH,QAAO,IAAI,eAAe,QAAQ;;AAGpC,IAAM,iBAAN,MAA4C;CAC1C,YAAY,AAAiB,OAAe;EAAf;;CAE7B,OAAe;AACb,SAAO;;CAGT,cAAiC;AAC/B,SAAO,QAAQ,QAAQ,CACrB;GAAC,KAAK;GAAiB,OAAO,UAAU,KAAK;GAAQ,CACtD,CAAC"}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* in ahead of time via `databricks auth login`.
|
|
5
|
-
*
|
|
6
|
-
* Node.js only. Not exported from the browser entry point.
|
|
7
|
-
*/
|
|
8
|
-
import type { TokenCredentials } from '../auth';
|
|
1
|
+
import { TokenCredentials } from "../auth.js";
|
|
2
|
+
|
|
3
|
+
//#region src/credentials/u2m.d.ts
|
|
9
4
|
/** Options for the Databricks CLI auth strategy. */
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
interface U2mCredentialsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The Databricks CLI profile name, as configured via `databricks auth
|
|
8
|
+
* login`.
|
|
9
|
+
*/
|
|
10
|
+
profile: string;
|
|
11
|
+
/**
|
|
12
|
+
* Path to the `databricks` CLI binary. If omitted, the binary is searched
|
|
13
|
+
* for in `PATH`.
|
|
14
|
+
*/
|
|
15
|
+
cliPath?: string;
|
|
21
16
|
}
|
|
22
17
|
/**
|
|
23
18
|
* Creates a TokenCredentials that obtains Databricks access tokens by
|
|
@@ -27,5 +22,7 @@ export interface U2mCredentialsOptions {
|
|
|
27
22
|
* @throws U2mCredentialsError when `profile` is empty, or when the CLI cannot
|
|
28
23
|
* be located, is out of date, or fails to return a usable token.
|
|
29
24
|
*/
|
|
30
|
-
|
|
25
|
+
declare function newU2mCredentials(options: U2mCredentialsOptions): TokenCredentials;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { U2mCredentialsOptions, newU2mCredentials };
|
|
31
28
|
//# sourceMappingURL=u2m.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"u2m.d.ts","
|
|
1
|
+
{"version":3,"file":"u2m.d.ts","names":[],"sources":["../../src/credentials/u2m.ts"],"mappings":";;;AAoDA;AAAA,UAtBiB,qBAAA;;;;;EAKf,OAAA;EAmBiB;;;;EAbjB,OAAA;AAAA;;;;;;;;;iBAWc,iBAAA,CACd,OAAA,EAAS,qBAAA,GACR,gBAAA"}
|