dome-embedded-app-sdk
Version:
Build Dome cards and document viewers with a single SDK. Cards let you extend a dome with custom functionality, while viewers let you render and edit documents inside Dome.
176 lines (175 loc) • 7.24 kB
TypeScript
import { DomeEmbeddedAppSdk, CardClientMessageType } from "./dome-sdk";
import { CardFsFileType, CardPermission } from "./types/card-sdk.types";
import type { CardEventHandler, CardFsCallback, CardFsListHandler, CardFsReadHandler, CardFsWriteUpdatePayload, CardKeyBlob, CardPermissionsMap, CardUser, CardUserRole } from "./types/card-sdk.types";
export { CardFsErrorCode, CardFsFileType, CardPermission, cardPermission } from "./types/card-sdk.types";
export type { CardEventHandler, CardFileChangePayload, CardFsCallback, CardFsErrorPayload, CardFsListHandler, CardFsListResult, CardFsReadHandler, CardFsReadResult, CardFsReadUpdatePayload, CardFsWriteUpdatePayload, CardInitData, CardInitErrorPayload, CardKeyBlob, CardKeyBlobV1, CardPermissionsMap, CardRefreshRequestPayload, CardUiProps, CardUser, CardUserCover, CardUserCoverPhoto, CardUserName, CardUserOrganization, CardUserPhoto, CardUserRole, } from "./types/card-sdk.types";
export declare function getKeyFromBlobStr(blobStr: string): string;
export declare function getKeyFromBlob(blob: CardKeyBlob): string;
/**
* Use CardSdk to create webapp cards
*/
export declare class CardSdk extends DomeEmbeddedAppSdk {
private static instance;
private handler;
private cryptoA01;
private static readonly FS_RESPONSE_TIMEOUT_MS;
private static readonly FS_READ_RETENTION_MS;
private static readonly CARD_FS_ACK_TIMEOUT_MS;
private static readonly MAX_CONSOLE_ARG_CHARS;
private static readonly MAX_CONSOLE_LOG_ENTRIES;
private static readonly MAX_CONSOLE_STRING_PREVIEW_CHARS;
private static readonly DEFAULT_ROLE_PERMISSIONS;
dataStore: any;
private accessToken;
devMode: boolean;
permission: CardPermissionsMap | null;
userRole: CardUserRole | null;
cardFS: {
read: (name: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
readById: (iuid: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
write: (name: string, fileData: any, fileType: CardFsFileType, onUpdate?: CardFsCallback<CardFsWriteUpdatePayload>) => Promise<any>;
writeById: (iuid: string, fileData: any, fileType: CardFsFileType, onUpdate?: CardFsCallback<CardFsWriteUpdatePayload>) => Promise<any>;
delete: (name: string, onUpdate?: CardFsCallback) => Promise<any>;
deleteById: (iuid: string, onUpdate?: CardFsCallback) => Promise<any>;
list: (folderName: string, handler: CardFsListHandler) => void;
};
private fsReadRequests;
private fsWriteRequests;
private fsListRequests;
private cardFsCache;
private containerIuid?;
private pendingAcks;
private consoleCaptureInstalled;
private consoleCaptureEnabled;
private consoleCaptureMinLevel;
private consoleLogBuffer;
private consoleLogWriteIndex;
private consoleLogSize;
private buildCardFsMessagePayload;
private formatFolderPath;
private assertValidReadHandler;
private assertValidListHandler;
private invokeReadHandlerNext;
private invokeReadHandlerError;
private sanitizeReadData;
private normalizeReadData;
private encodeTextPayload;
private encodeJsonPayload;
private normalizeWriteData;
private base64EncodeBinaryData;
private getWriteDataSizeBytes;
private getCardIuid;
private ensureCardFsCache;
private supportsParentCardFs;
private shouldUseCardFsFallback;
private constructor();
/**
* Static initialization method to get or create the singleton instance of CardSdk.
* @param secret - The card developer secret key
* @param handler - (Optional) Handler for different events emitted by the SDK
* @returns The singleton CardSdk instance
*/
static init(secret: string, handler?: CardEventHandler, options?: {
devMode?: boolean;
}): Promise<CardSdk>;
/**
* Method to set or update the handler object.
* @param handler - Custom handler for different message types
*/
setHandler(handler: CardEventHandler): void;
isCardFsFallbackEnabled(): boolean;
/**
* Sends a deep link request to the parent directly from the card.
*/
openDeepLink(href: string): void;
/**
* Checks if the user has the requested permission.
* @param permission - A value from CardPermission enum (e.g CardPermission.READ, CardPermission.WRITE)
* @returns Boolean based on the permission presence
*/
hasPerm(permission: CardPermission): boolean;
/**
* Checks if the permissions allow reading
* @returns - True if the permission string allows read access to user
*/
canRead(): boolean;
/**
* Checks if the permissions allow writing
* @returns - True if the permission string allows write access to user
*/
canWrite(): boolean;
private deriveSecretSeed;
private getCardIuidEnc;
private requestAf1DataFromParent;
private fetchAf1Data;
private initializeCardSdk;
private sendInit;
private getWebappDetails;
private sendMessageWithAck;
private resolvePendingAckByType;
protected handleMessage: (type: CardClientMessageType, data: any) => void;
private cardFSRead;
private cardFSReadById;
private cardFSReadInternal;
private isCardFsAckType;
private cardFSWrite;
private cardFSWriteById;
private cardFSWriteInternal;
private cardFSDelete;
private cardFSDeleteById;
private cardFSDeleteInternal;
private cardFSList;
private cardFSListFallbackStream;
private resetFsReadProgressTimeout;
private resetFsWriteProgressTimeout;
private resetFsListProgressTimeout;
private handleFsReadDataMessage;
private handleFsAckMessage;
private clearFsReadRequest;
private sendConsoleLogs;
private setupConsoleCapture;
private applyLoggingConfig;
private isConsoleLogLevel;
private shouldCaptureLevel;
private recordConsoleEntry;
private clearConsoleLogs;
private getConsoleLogs;
private serializeConsoleArg;
private truncateSerializedArg;
private buildTruncatedPreview;
private failFsReadRequest;
private clearFsWriteRequest;
private clearFsListRequest;
private failFsWriteRequest;
private failFsListRequest;
private handleFsWriteSuccess;
private handleFsListDataMessage;
private createCardFsError;
private toCardFsErrorPayload;
private cardFSReadFallback;
private cardFSWriteFallback;
private cardFSDeleteFallback;
private cardFSListFallback;
private authHeader;
private fetchDocumentMetadataByTarget;
private fetchDocumentMetadataByIuid;
private normalizeDocumentsResponse;
private normalizeListResult;
private getCardFsErrorCode;
private isBinaryReadPayload;
private decodeBase64BinaryData;
private fetchDocumentMetadataByName;
private fetchFolderListing;
private fetchDocumentPayload;
private fetchDocumentData;
private buildFileFormData;
private upsertDocumentViaApi;
private formatErrorMessage;
private sendEventError;
setFileDirty(data: {
iuid: string;
ts_m: number;
}): void;
getUsername(userObj: CardUser | null | undefined): string;
private attachUserFullName;
}