cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
65 lines (64 loc) • 2.69 kB
TypeScript
import { Client, FetchClient, IAuthentication, ICredentials } from "@c8y/client";
import { C8yClient } from "./c8yclient";
export interface C8yAuthOptions extends ICredentials {
sendImmediately?: boolean;
userAlias?: string;
type?: string;
xsrfToken?: string;
}
export type C8yPactAuthObject = {
user: string;
userAlias?: string;
type?: string;
token?: string;
} | {
userAlias: string;
user?: string;
type?: string;
token?: string;
};
type C8yPactAuthObjectType = keyof C8yPactAuthObject;
export declare const C8yPactAuthObjectKeys: C8yPactAuthObjectType[];
export type C8yAuthOptionType = "BasicAuth" | "CookieAuth" | "BearerAuth" | undefined;
export type C8yAuthentication = IAuthentication;
/**
* Checks if the given object is a C8yAuthOptions.
*
* @param obj The object to check.
* @param options Options to check for additional properties.
* @returns True if the object is a C8yAuthOptions, false otherwise.
*/
export declare function isAuthOptions(obj: any): obj is C8yAuthOptions;
export declare function toC8yAuthentication(obj: C8yAuthOptions | IAuthentication | undefined): C8yAuthentication | undefined;
export declare function getAuthType(auth?: C8yAuthOptions | C8yPactAuthObject | string): C8yAuthOptionType;
export declare function hasAuthentication(client: C8yClient | Client | FetchClient): boolean;
export declare function toPactAuthObject(obj: C8yAuthOptions | IAuthentication | ICredentials): C8yPactAuthObject;
export declare function isPactAuthObject(obj: any): obj is C8yPactAuthObject;
export declare function normalizeAuthHeaders(headers: {
[key: string]: any;
}): {
[key: string]: any;
};
export declare function getAuthOptionsFromEnv(env: any): C8yAuthOptions | undefined;
export declare function authWithTenant(env: any, options: C8yAuthOptions): C8yAuthOptions;
export declare function getAuthOptionsFromBasicAuthHeader(authHeader: string): {
user: string;
password: string;
} | undefined;
/**
* Extracts the authentication options from a JWT token.
* @param jwtToken The JWT token to extract the authentication options from.
* @returns The extracted authentication options.
*/
export declare function getAuthOptionsFromJWT(jwtToken: string): C8yAuthOptions;
/**
* Extracts the tenant from the basic auth object.
* @param auth The basic auth object containing the user property.
* @returns The tenant or undefined if not found.
*/
export declare function tenantFromBasicAuth(auth: {
user?: string | undefined;
} | string): string | undefined;
export declare function encodeBase64(str: string): string;
export declare function decodeBase64(base64: string): string;
export {};