@@ -34,9 +34,6 @@ export type CredentialsFile = {
3434 profiles : Record < string , Profile > ;
3535} ;
3636
37- /** @deprecated Use `Profile` instead */
38- export type TeamProfile = Profile ;
39-
4037export function getConfigDir ( ) : string {
4138 if ( process . env . XDG_CONFIG_HOME ) {
4239 return join ( process . env . XDG_CONFIG_HOME , 'resend' ) ;
@@ -54,30 +51,13 @@ export function getCredentialsPath(): string {
5451export function readCredentials ( ) : CredentialsFile | null {
5552 try {
5653 const data = JSON . parse ( readFileSync ( getCredentialsPath ( ) , 'utf-8' ) ) ;
57- // Support legacy format: { api_key: "re_xxx" }
58- if ( data . api_key && ! data . profiles && ! data . teams ) {
59- return {
60- active_profile : 'default' ,
61- profiles : { default : { api_key : data . api_key } } ,
62- } ;
63- }
64- // New format: { profiles, active_profile }
6554 if ( data . profiles ) {
66- const storage =
67- data . storage === 'keychain' ? 'secure_storage' : data . storage ;
6855 return {
6956 active_profile : data . active_profile ?? 'default' ,
70- ...( storage ? { storage } : { } ) ,
57+ ...( data . storage ? { storage : data . storage } : { } ) ,
7158 profiles : data . profiles ,
7259 } ;
7360 }
74- // Old format: { teams, active_team }
75- if ( data . teams ) {
76- return {
77- active_profile : data . active_team ?? 'default' ,
78- profiles : data . teams ,
79- } ;
80- }
8161 return null ;
8262 } catch {
8363 return null ;
@@ -102,8 +82,7 @@ export function resolveProfileName(flagValue?: string): string {
10282 return flagValue ;
10383 }
10484
105- // Check RESEND_PROFILE first, fall back to deprecated RESEND_TEAM
106- const envProfile = process . env . RESEND_PROFILE || process . env . RESEND_TEAM ;
85+ const envProfile = process . env . RESEND_PROFILE ;
10786 if ( envProfile ) {
10887 return envProfile ;
10988 }
@@ -116,9 +95,6 @@ export function resolveProfileName(flagValue?: string): string {
11695 return 'default' ;
11796}
11897
119- /** @deprecated Use `resolveProfileName` instead */
120- export const resolveTeamName = resolveProfileName ;
121-
12298export function resolveApiKey (
12399 flagValue ?: string ,
124100 profileName ?: string ,
@@ -190,7 +166,7 @@ export function removeApiKey(profileName?: string): string {
190166 if ( ! existsSync ( configPath ) ) {
191167 throw new Error ( 'No credentials file found.' ) ;
192168 }
193- // Try to delete legacy file
169+ // File exists but is not valid credentials — delete it
194170 unlinkSync ( configPath ) ;
195171 return configPath ;
196172 }
@@ -237,9 +213,6 @@ export function setActiveProfile(profileName: string): void {
237213 writeCredentials ( creds ) ;
238214}
239215
240- /** @deprecated Use `setActiveProfile` instead */
241- export const setActiveTeam = setActiveProfile ;
242-
243216export function listProfiles ( ) : Array < { name : string ; active : boolean } > {
244217 const creds = readCredentials ( ) ;
245218 if ( ! creds ) {
@@ -251,9 +224,6 @@ export function listProfiles(): Array<{ name: string; active: boolean }> {
251224 } ) ) ;
252225}
253226
254- /** @deprecated Use `listProfiles` instead */
255- export const listTeams = listProfiles ;
256-
257227export function validateProfileName ( name : string ) : string | undefined {
258228 if ( ! name || name . length === 0 ) {
259229 return 'Profile name must not be empty' ;
@@ -267,9 +237,6 @@ export function validateProfileName(name: string): string | undefined {
267237 return undefined ;
268238}
269239
270- /** @deprecated Use `validateProfileName` instead */
271- export const validateTeamName = validateProfileName ;
272-
273240export function renameProfile ( oldName : string , newName : string ) : void {
274241 if ( oldName === newName ) {
275242 return ;
@@ -324,7 +291,6 @@ export async function resolveApiKeyAsync(
324291 const profile =
325292 profileName ||
326293 process . env . RESEND_PROFILE ||
327- process . env . RESEND_TEAM ||
328294 creds ?. active_profile ||
329295 'default' ;
330296
@@ -337,27 +303,10 @@ export async function resolveApiKeyAsync(
337303 }
338304 }
339305
340- // File-based storage (or unmigrated profile in mixed state)
306+ // File-based storage
341307 if ( creds ) {
342308 const entry = creds . profiles [ profile ] ;
343309 if ( entry ?. api_key ) {
344- // Auto-migrate: move plaintext key to secure storage if available
345- const backend = await getCredentialBackend ( ) ;
346- if ( backend . isSecure ) {
347- try {
348- await backend . set ( SERVICE_NAME , profile , entry . api_key ) ;
349- creds . profiles [ profile ] = {
350- ...( entry . permission && { permission : entry . permission } ) ,
351- } ;
352- creds . storage = 'secure_storage' ;
353- writeCredentials ( creds ) ;
354- process . stderr . write (
355- `Notice: API key for profile "${ profile } " has been moved to ${ backend . name } \n` ,
356- ) ;
357- } catch {
358- // Non-fatal — plaintext key still works
359- }
360- }
361310 return {
362311 key : entry . api_key ,
363312 source : 'config' ,
@@ -417,7 +366,6 @@ export async function removeApiKeyAsync(profileName?: string): Promise<string> {
417366 const profile =
418367 profileName ||
419368 process . env . RESEND_PROFILE ||
420- process . env . RESEND_TEAM ||
421369 creds ?. active_profile ||
422370 'default' ;
423371
0 commit comments