Skip to content

Commit 2d9282b

Browse files
committed
Fix Copilot issues: update fromJWT docs and remove TokenCallback duplication
- Updated Token.fromJWT() documentation to reflect that it handles decoding failures gracefully instead of throwing errors - Removed duplicate TokenCallback type definition from IDBSQLClient.ts - Now imports TokenCallback from ExternalTokenProvider.ts to maintain a single source of truth
1 parent 98fe7f5 commit 2d9282b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/connection/auth/tokenProvider/Token.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ export default class Token {
9898

9999
/**
100100
* Creates a Token from a JWT string, extracting the expiration time from the payload.
101+
* If the JWT cannot be decoded, the token is created without expiration info.
102+
* The server will validate the token anyway, so decoding failures are handled gracefully.
101103
* @param jwt - The JWT token string
102104
* @param options - Additional token options (tokenType, refreshToken, scopes)
103-
* @returns A new Token instance with expiration extracted from the JWT
104-
* @throws Error if the JWT cannot be decoded
105+
* @returns A new Token instance with expiration extracted from the JWT (if available)
105106
*/
106107
static fromJWT(
107108
jwt: string,

lib/contracts/IDBSQLClient.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import IAuthentication from '../connection/contracts/IAuthentication';
44
import { ProxyOptions } from '../connection/contracts/IConnectionOptions';
55
import OAuthPersistence from '../connection/auth/DatabricksOAuth/OAuthPersistence';
66
import ITokenProvider from '../connection/auth/tokenProvider/ITokenProvider';
7+
import { TokenCallback } from '../connection/auth/tokenProvider/ExternalTokenProvider';
78

89
export interface ClientOptions {
910
logger?: IDBSQLLogger;
1011
}
1112

12-
/**
13-
* Type for the callback function that retrieves tokens from external sources.
14-
*/
15-
export type TokenCallback = () => Promise<string>;
16-
1713
type AuthOptions =
1814
| {
1915
authType?: 'access-token';

0 commit comments

Comments
 (0)