File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ import { spinner } from "../utilities/windows.js";
2323import { isLinuxServer } from "../utilities/linux.js" ;
2424import { VERSION } from "../version.js" ;
2525import { env } from "std-env" ;
26+ import {
27+ isPersonalAccessToken ,
28+ NotPersonalAccessTokenError ,
29+ } from "../utilities/isPersonalAccessToken.js" ;
2630
2731export const LoginCommandOptions = CommonCommandOptions . extend ( {
2832 apiUrl : z . string ( ) ,
@@ -84,6 +88,12 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
8488 const accessTokenFromEnv = env . TRIGGER_ACCESS_TOKEN ;
8589
8690 if ( accessTokenFromEnv ) {
91+ if ( ! isPersonalAccessToken ( accessTokenFromEnv ) ) {
92+ throw new NotPersonalAccessTokenError (
93+ "Your TRIGGER_ACCESS_TOKEN is not a Personal Access Token, they start with 'tr_pat_'. You can generate one here: https://cloud.trigger.dev/account/tokens"
94+ ) ;
95+ }
96+
8797 const auth = {
8898 accessToken : accessTokenFromEnv ,
8999 apiUrl : env . TRIGGER_API_URL ?? opts . defaultApiUrl ?? "https://api.trigger.dev" ,
@@ -292,6 +302,10 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
292302 span . end ( ) ;
293303
294304 if ( options ?. embedded ) {
305+ if ( e instanceof NotPersonalAccessTokenError ) {
306+ throw e ;
307+ }
308+
295309 return {
296310 ok : false as const ,
297311 error : e instanceof Error ? e . message : String ( e ) ,
Original file line number Diff line number Diff line change 1+ const tokenPrefix = "tr_pat_" ;
2+
3+ export function isPersonalAccessToken ( token : string ) {
4+ return token . startsWith ( tokenPrefix ) ;
5+ }
6+
7+ export class NotPersonalAccessTokenError extends Error {
8+ constructor ( message : string ) {
9+ super ( message ) ;
10+ this . name = "NotPersonalAccessTokenError" ;
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments