Skip to content

Commit accb16c

Browse files
authored
feat: deprecate DeviceOauthService and types - W-19362390 (#1227)
* feat: deprecate DeviceOauthService and types * chore: deprecate the public methods too
1 parent 2357f89 commit accb16c

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/deviceOauthService.ts

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,24 @@ import { AuthInfo, DEFAULT_CONNECTED_APP_INFO } from './org/authInfo';
1717
import { SFDX_HTTP_HEADERS } from './org/connection';
1818
import { SfError } from './sfError';
1919
import { Messages } from './messages';
20+
import { Lifecycle } from './lifecycleEvents';
2021

2122
Messages.importMessagesDirectory(__dirname);
2223
const messages = Messages.loadMessages('@salesforce/core', 'auth');
2324

25+
/**
26+
* @deprecated Will be removed mid January 2026
27+
*/
2428
export type DeviceCodeResponse = {
2529
device_code: string;
2630
interval: number;
2731
user_code: string;
2832
verification_uri: string;
2933
} & JsonMap;
3034

35+
/**
36+
* @deprecated Will be removed mid January 2026
37+
*/
3138
export type DeviceCodePollingResponse = {
3239
access_token: string;
3340
refresh_token: string;
@@ -68,20 +75,9 @@ async function makeRequest<T extends JsonMap>(options: HttpRequest): Promise<T>
6875
}
6976

7077
/**
71-
* Handles device based login flows
78+
* THIS CLASS IS DEPRECATED AND WILL BE REMOVED MID JANUARY 2026.
7279
*
73-
* Usage:
74-
* ```
75-
* const oauthConfig = {
76-
* loginUrl: this.flags.instanceurl,
77-
* clientId: this.flags.clientid,
78-
* };
79-
* const deviceOauthService = await DeviceOauthService.create(oauthConfig);
80-
* const loginData = await deviceOauthService.requestDeviceLogin();
81-
* console.log(loginData);
82-
* const approval = await deviceOauthService.awaitDeviceApproval(loginData);
83-
* const authInfo = await deviceOauthService.authorizeAndSave(approval);
84-
* ```
80+
* @deprecated Use other oauth flows instead
8581
*/
8682
export class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
8783
public static RESPONSE_TYPE = 'device_code';
@@ -95,15 +91,14 @@ export class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
9591

9692
public constructor(options: OAuth2Config) {
9793
super(options);
94+
void Lifecycle.getInstance().emitWarning('Device Oauth flow is deprecated and will be removed mid January 2026');
9895
this.options = options;
9996
if (!this.options.clientId) this.options.clientId = DEFAULT_CONNECTED_APP_INFO.clientId;
10097
if (!this.options.loginUrl) this.options.loginUrl = AuthInfo.getDefaultInstanceUrl();
10198
}
10299

103100
/**
104-
* Begin the authorization flow by requesting the login
105-
*
106-
* @returns {Promise<DeviceCodeResponse>}
101+
* @deprecated Will be removed mid January 2026
107102
*/
108103
public async requestDeviceLogin(): Promise<DeviceCodeResponse> {
109104
const deviceFlowRequestUrl = this.getDeviceFlowRequestUrl();
@@ -112,9 +107,7 @@ export class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
112107
}
113108

114109
/**
115-
* Polls the server until successful response OR max attempts have been made
116-
*
117-
* @returns {Promise<Nullable<DeviceCodePollingResponse>>}
110+
* @deprecated Will be removed mid January 2026
118111
*/
119112
public async awaitDeviceApproval(loginData: DeviceCodeResponse): Promise<Nullable<DeviceCodePollingResponse>> {
120113
const deviceFlowRequestUrl = this.getDeviceFlowRequestUrl();
@@ -124,9 +117,7 @@ export class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
124117
}
125118

126119
/**
127-
* Creates and saves new AuthInfo
128-
*
129-
* @returns {Promise<AuthInfo>}
120+
* @deprecated Will be removed mid January 2026
130121
*/
131122
public async authorizeAndSave(approval: DeviceCodePollingResponse): Promise<AuthInfo> {
132123
const authInfo = await AuthInfo.create({

0 commit comments

Comments
 (0)