@squidcloud/client
Version:
A typescript implementation of the Squid client
64 lines (63 loc) • 2.23 kB
TypeScript
import { AppId, ClientId } from './communication.public-types';
/**
* @category Auth
*/
export type AuthType = 'Bearer' | 'ApiKey';
/**
* The payload of a JWT token when Bearer authentication is used.
* @category Auth
*/
export interface AuthWithBearer {
/** Specifies the Bearer authentication type. */
type: 'Bearer';
/** The unique identifier of the authenticated user. */
userId: string;
/** The expiration timestamp of the token, in seconds. */
expiration: number;
/** Additional attributes associated with the token. */
attributes: Record<string, any>;
/** The raw JWT token string, if available. */
jwt?: string;
}
/**
* The authentication object for the current request when an API key is used.
* @category Auth
*/
export interface AuthWithApiKey {
/** Specifies the API key authentication type. */
type: 'ApiKey';
/** The API key string used for authentication. */
apiKey: string;
}
/**
* The authentication object for the current request.
* @category Auth
*/
export type Auth = AuthWithBearer | AuthWithApiKey;
/**
* Represents an authentication token with its type and associated details.
* @category Auth
*/
export interface AuthToken {
/** The type of authentication (e.g., 'Bearer' or 'ApiKey'). */
type: AuthType;
/** The token string used for authentication. */
token: string;
/** The ID of the integration associated with the token, if applicable. */
integrationId?: string;
}
/** * The context of a request to a service, providing metadata about the request source. */
export interface RunContext {
/** Your applicationId. */
appId: AppId;
/**
* The id of the client that initiated this request. This is only relevant in cases that the request was initiated by
* a client such as when securing an api call or a DB operation. This id will not be available for triggers,
* schedulers, webhooks and other functions that are not directly initiated by a user action.
*/
clientId?: ClientId;
/** The IP address of the client that initiated this request. */
sourceIp?: string;
/** The headers of the request. Headers are in lower-case. */
headers?: Record<string, any>;
}