All files / services/core credential.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98                                                                                                                                                                                                   
/**
 * Represents a credential, either Basic (username/password) or Bearer token.
 */
export type AuthCredential = BasicAuthCredential | BearerAuthCredential | MicrosoftAuthCredential | EntraClientAuthCredential;
 
/**
 * Credential type for HTTP Basic authentication.
 */
export type BasicAuthCredential = {
	type: 'basic';
 
	/**
	 * The username to be used for authentication.
	 */
	username: string;
 
	/**
	 * The password to be used for authentication.
	 */
	password: string;
};
 
/**
 * Credential type for Bearer token authentication.
 */
export type BearerAuthCredential = {
	type: 'bearer';
 
	/**
	 * The prefix to be used in the Authorization header (e.g., "Bearer").
	 */
	prefix: string;
 
	/**
	 * The token to be used for authentication.
	 */
	token: string;
};
 
/**
 * Credential type for Microsoft Entra ID authentication.
 */
export type MicrosoftAuthCredential = {
	type: 'microsoft';
 
	/**
	 * The ID of the associated authentication session.
	 */
	sessionId?: string;
 
	/**
	 * The access token to be used for authentication.
	 */
	accessToken?: string;
 
	/**
	 * The scopes associated with the access token.
	 */
	scopes: string[];
};
 
/**
 * Credential type for Microsoft Entra ID Client Credentials Flow (OAuth 2.0).
 * Used for service-to-service authentication without user interaction.
 */
export type EntraClientAuthCredential = {
	type: 'entra-client-credentials';
 
	/**
	 * The Azure AD tenant ID.
	 */
	tenantId: string;
 
	/**
	 * The application (client) ID registered in Azure AD.
	 */
	clientId: string;
 
	/**
	 * The client secret for the application.
	 */
	clientSecret: string;
 
	/**
	 * The scopes to request (e.g., "https://graph.microsoft.com/.default").
	 */
	scopes: string[];
 
	/**
	 * The cached access token obtained from the token endpoint.
	 */
	accessToken?: string;
 
	/**
	 * The expiration time (Unix timestamp in milliseconds) of the cached access token.
	 */
	accessTokenExpiresAt?: number;
};