dome-embedded-app-sdk 0.2.4-experimental.5 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-sdk.d.ts +184 -0
- package/dist/dome-sdk.d.ts +25 -340
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/viewer-sdk.d.ts +53 -0
- package/package.json +6 -4
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { DomeEmbeddedAppSdk, ClientMessageType } from "./dome-sdk";
|
|
2
|
+
type CardPermissionsMap = Record<string, string>;
|
|
3
|
+
interface CardUserRole {
|
|
4
|
+
key?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
abbr?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CardKeyBlobV1 {
|
|
10
|
+
v: 1;
|
|
11
|
+
seed: number;
|
|
12
|
+
obf: number[];
|
|
13
|
+
}
|
|
14
|
+
export type CardKeyBlob = CardKeyBlobV1;
|
|
15
|
+
export declare function getKeyFromBlob(blob: CardKeyBlob): Uint8Array;
|
|
16
|
+
export declare enum CardPermission {
|
|
17
|
+
READ = "r",
|
|
18
|
+
WRITE = "w",
|
|
19
|
+
FORWARD = "f",
|
|
20
|
+
SHARE = "s",
|
|
21
|
+
DOWNLOAD = "d"
|
|
22
|
+
}
|
|
23
|
+
export declare const cardPermission: typeof CardPermission;
|
|
24
|
+
export interface CardEventHandler {
|
|
25
|
+
onInit: (data: any) => void;
|
|
26
|
+
onError: (data: {
|
|
27
|
+
error_code: string | number;
|
|
28
|
+
message: string;
|
|
29
|
+
data: any;
|
|
30
|
+
}) => void;
|
|
31
|
+
onFileChange: (data: {
|
|
32
|
+
iuid: string;
|
|
33
|
+
data: {
|
|
34
|
+
data: {
|
|
35
|
+
type: string;
|
|
36
|
+
value: any;
|
|
37
|
+
};
|
|
38
|
+
link: {
|
|
39
|
+
url: string;
|
|
40
|
+
};
|
|
41
|
+
meta: any;
|
|
42
|
+
perms: any;
|
|
43
|
+
from_cache: boolean;
|
|
44
|
+
};
|
|
45
|
+
}) => void;
|
|
46
|
+
onRefreshRequest?: (data: any) => void;
|
|
47
|
+
}
|
|
48
|
+
export type CardFsCallback<T = any> = (payload: T) => void;
|
|
49
|
+
export interface CardFsReadResult {
|
|
50
|
+
name?: string;
|
|
51
|
+
iuid?: string | null;
|
|
52
|
+
object?: any;
|
|
53
|
+
data?: any;
|
|
54
|
+
is_stale: boolean;
|
|
55
|
+
is_complete: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface CardFsReadHandler {
|
|
58
|
+
next: CardFsCallback<CardFsReadResult>;
|
|
59
|
+
error?: CardFsCallback<Error>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Use CardSdk to create webapp cards
|
|
63
|
+
*/
|
|
64
|
+
export declare class CardSdk extends DomeEmbeddedAppSdk {
|
|
65
|
+
private static instance;
|
|
66
|
+
private handler;
|
|
67
|
+
private cryptoA01;
|
|
68
|
+
private static readonly FS_RESPONSE_TIMEOUT_MS;
|
|
69
|
+
private static readonly FS_READ_RETENTION_MS;
|
|
70
|
+
private static readonly CARD_FS_ACK_TIMEOUT_MS;
|
|
71
|
+
private static readonly DEFAULT_ROLE_PERMISSIONS;
|
|
72
|
+
dataStore: any;
|
|
73
|
+
private accessToken;
|
|
74
|
+
devMode: boolean;
|
|
75
|
+
permission: CardPermissionsMap | null;
|
|
76
|
+
userRole: CardUserRole | null;
|
|
77
|
+
cardFS: {
|
|
78
|
+
read: (name: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
|
|
79
|
+
readById: (iuid: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
|
|
80
|
+
write: (name: string, fileData: any, onResult?: CardFsCallback) => Promise<any>;
|
|
81
|
+
writeById: (iuid: string, fileData: any, onResult?: CardFsCallback) => Promise<any>;
|
|
82
|
+
delete: (name: string, onResult?: CardFsCallback) => Promise<any>;
|
|
83
|
+
deleteById: (iuid: string, onResult?: CardFsCallback) => Promise<any>;
|
|
84
|
+
list: (onResult?: CardFsCallback) => Promise<any>;
|
|
85
|
+
};
|
|
86
|
+
private fsReadRequests;
|
|
87
|
+
private fsWriteRequests;
|
|
88
|
+
private cardFsCache;
|
|
89
|
+
private containerIuid?;
|
|
90
|
+
private pendingAcks;
|
|
91
|
+
private buildCardFsMessagePayload;
|
|
92
|
+
private assertValidReadHandler;
|
|
93
|
+
private invokeReadHandlerNext;
|
|
94
|
+
private invokeReadHandlerError;
|
|
95
|
+
private sanitizeReadData;
|
|
96
|
+
private getCardIuid;
|
|
97
|
+
private ensureCardFsCache;
|
|
98
|
+
private supportsParentCardFs;
|
|
99
|
+
private shouldUseCardFsFallback;
|
|
100
|
+
private constructor();
|
|
101
|
+
/**
|
|
102
|
+
* Static initialization method to get or create the singleton instance of CardSdk.
|
|
103
|
+
* @param secret - The card developer secret key
|
|
104
|
+
* @param handler - (Optional) Handler for different events emitted by the SDK
|
|
105
|
+
* @returns The singleton CardSdk instance
|
|
106
|
+
*/
|
|
107
|
+
static init(secret: string, handler?: CardEventHandler, options?: {
|
|
108
|
+
devMode?: boolean;
|
|
109
|
+
}): Promise<CardSdk>;
|
|
110
|
+
/**
|
|
111
|
+
* Method to set or update the handler object.
|
|
112
|
+
* @param handler - Custom handler for different message types
|
|
113
|
+
*/
|
|
114
|
+
setHandler(handler: CardEventHandler): void;
|
|
115
|
+
/**
|
|
116
|
+
* Sends a deep link request to the parent directly from the card.
|
|
117
|
+
*/
|
|
118
|
+
openDeepLink(href: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Checks if the user has the requested permission.
|
|
121
|
+
* @param permission - A value from CardPermission enum (e.g CardPermission.READ, CardPermission.WRITE)
|
|
122
|
+
* @returns Boolean based on the permission presence
|
|
123
|
+
*/
|
|
124
|
+
hasPerm(permission: CardPermission): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Checks if the permissions allow reading
|
|
127
|
+
* @returns - True if the permission string allows read access to user
|
|
128
|
+
*/
|
|
129
|
+
canRead(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Checks if the permissions allow writing
|
|
132
|
+
* @returns - True if the permission string allows write access to user
|
|
133
|
+
*/
|
|
134
|
+
canWrite(): boolean;
|
|
135
|
+
private deriveSecretSeed;
|
|
136
|
+
private getCardIuidEnc;
|
|
137
|
+
private requestAf1DataFromParent;
|
|
138
|
+
private fetchAf1Data;
|
|
139
|
+
private initializeCardSdk;
|
|
140
|
+
private sendInit;
|
|
141
|
+
private getWebappDetails;
|
|
142
|
+
private sendMessageWithAck;
|
|
143
|
+
private resolvePendingAckByType;
|
|
144
|
+
protected handleMessage: (type: ClientMessageType, data: any) => void;
|
|
145
|
+
private cardsFsRead;
|
|
146
|
+
private cardsFsReadById;
|
|
147
|
+
private cardsFsReadInternal;
|
|
148
|
+
private cardsFsWrite;
|
|
149
|
+
private cardsFsWriteById;
|
|
150
|
+
private cardsFsWriteInternal;
|
|
151
|
+
private cardsFsDelete;
|
|
152
|
+
private cardsFsDeleteById;
|
|
153
|
+
private cardsFsDeleteInternal;
|
|
154
|
+
private cardsFsList;
|
|
155
|
+
private handleFsReadDataMessage;
|
|
156
|
+
private clearFsReadRequest;
|
|
157
|
+
private failFsReadRequest;
|
|
158
|
+
private clearFsWriteRequest;
|
|
159
|
+
private failFsWriteRequest;
|
|
160
|
+
private handleFsWriteSuccess;
|
|
161
|
+
private handleFsWriteError;
|
|
162
|
+
private cardsFsReadFallback;
|
|
163
|
+
private cardsFsWriteFallback;
|
|
164
|
+
private cardsFsDeleteFallback;
|
|
165
|
+
private cardsFsListFallback;
|
|
166
|
+
private authHeader;
|
|
167
|
+
private fetchDocumentMetadataByTarget;
|
|
168
|
+
private fetchDocumentMetadataByIuid;
|
|
169
|
+
private normalizeDocumentsResponse;
|
|
170
|
+
private fetchDocumentMetadataByName;
|
|
171
|
+
private fetchAllDocuments;
|
|
172
|
+
private fetchDocumentPayload;
|
|
173
|
+
private fetchDocumentData;
|
|
174
|
+
private buildFileFormData;
|
|
175
|
+
private upsertDocumentViaApi;
|
|
176
|
+
private formatErrorMessage;
|
|
177
|
+
private sendEventError;
|
|
178
|
+
setFileDirty(data: {
|
|
179
|
+
iuid: string;
|
|
180
|
+
ts_m: number;
|
|
181
|
+
}): void;
|
|
182
|
+
getUsername(userObj: any): string;
|
|
183
|
+
}
|
|
184
|
+
export {};
|
package/dist/dome-sdk.d.ts
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
export declare enum ViewerMessageType {
|
|
2
2
|
CONNECTION_SUCCESS = "CONNECTION_SUCCESS",
|
|
3
|
-
INIT = "INIT"
|
|
4
|
-
REQUEST_SAVE = "REQUEST_SAVE"
|
|
5
|
-
REQUEST_CLOSE = "REQUEST_CLOSE"
|
|
6
|
-
REQUEST_INITIAL_DATA = "REQUEST_INITIAL_DATA"
|
|
7
|
-
SET_DIRTY = "SET_DIRTY"
|
|
8
|
-
SEND_CLOSE = "SEND_CLOSE"
|
|
3
|
+
INIT = "INIT",
|
|
4
|
+
REQUEST_SAVE = "REQUEST_SAVE",
|
|
5
|
+
REQUEST_CLOSE = "REQUEST_CLOSE",
|
|
6
|
+
REQUEST_INITIAL_DATA = "REQUEST_INITIAL_DATA",
|
|
7
|
+
SET_DIRTY = "SET_DIRTY",
|
|
8
|
+
SEND_CLOSE = "SEND_CLOSE",
|
|
9
9
|
SEND_EXCEPTION = "SEND_EXCEPTION"
|
|
10
10
|
}
|
|
11
|
-
declare enum ClientMessageType {
|
|
11
|
+
export declare enum ClientMessageType {
|
|
12
12
|
CONNECT = "CONNECT",
|
|
13
|
-
REQUEST_CLOSE = "REQUEST_CLOSE"
|
|
14
|
-
REQUEST_SAVE = "REQUEST_SAVE"
|
|
15
|
-
SAVE_ERROR = "SAVE_ERROR"
|
|
16
|
-
SAVE_SUCCESS = "SAVE_SUCCESS"
|
|
13
|
+
REQUEST_CLOSE = "REQUEST_CLOSE",
|
|
14
|
+
REQUEST_SAVE = "REQUEST_SAVE",
|
|
15
|
+
SAVE_ERROR = "SAVE_ERROR",
|
|
16
|
+
SAVE_SUCCESS = "SAVE_SUCCESS",
|
|
17
17
|
DATA_CHANGE = "DATA_CHANGE",
|
|
18
18
|
FILE_DATA = "FILE_DATA",
|
|
19
19
|
WRITE_FILE_ACK = "WRITE_FILE_ACK",
|
|
20
20
|
READ_FILE_ACK = "READ_FILE_ACK",
|
|
21
|
-
DELETE_FILE_ACK = "DELETE_FILE_ACK"
|
|
22
|
-
LIST_FILES_ACK = "LIST_FILES_ACK"
|
|
21
|
+
DELETE_FILE_ACK = "DELETE_FILE_ACK",
|
|
22
|
+
LIST_FILES_ACK = "LIST_FILES_ACK",
|
|
23
23
|
INIT_ACK = "INIT_ACK",
|
|
24
24
|
AF1_DATA_TOKEN_ACK = "AF1_DATA_TOKEN_ACK",
|
|
25
25
|
ERROR = "ERROR",
|
|
26
26
|
REFRESH = "REFRESH"
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export declare enum CardMessageType {
|
|
29
|
+
APP_READY = "APP_READY",
|
|
30
|
+
INIT = "INIT",
|
|
31
|
+
READ_FILE = "READ_FILE",
|
|
32
|
+
WRITE_FILE = "WRITE_FILE",
|
|
33
|
+
DELETE_FILE = "DELETE_FILE",
|
|
34
|
+
LIST_FILES = "LIST_FILES",
|
|
35
|
+
FILE_DIRTY = "FILE_DIRTY",
|
|
36
|
+
OPEN_DEEPLINK = "OPEN_DEEPLINK",
|
|
37
|
+
AF1_DATA_TOKEN = "AF1_DATA_TOKEN"
|
|
31
38
|
}
|
|
32
39
|
export interface HostInfo {
|
|
33
40
|
type: string;
|
|
@@ -48,42 +55,7 @@ export interface HostCapabilities {
|
|
|
48
55
|
export type HostDetails = HostInfo & {
|
|
49
56
|
capabilities?: HostCapabilities;
|
|
50
57
|
};
|
|
51
|
-
export
|
|
52
|
-
onInitialData: (data: {
|
|
53
|
-
doc: Document;
|
|
54
|
-
ui: UiProps;
|
|
55
|
-
isNewFile: boolean;
|
|
56
|
-
perms: any;
|
|
57
|
-
config?: Record<string, any>;
|
|
58
|
-
}) => void;
|
|
59
|
-
onDataChange?: (data: {
|
|
60
|
-
doc: Document;
|
|
61
|
-
perms: any;
|
|
62
|
-
userConsent: "override" | null;
|
|
63
|
-
}) => void;
|
|
64
|
-
onCloseRequest: () => void;
|
|
65
|
-
onSaveRequest: () => void;
|
|
66
|
-
}
|
|
67
|
-
export interface Document {
|
|
68
|
-
data: any;
|
|
69
|
-
name: string;
|
|
70
|
-
type: string;
|
|
71
|
-
}
|
|
72
|
-
export interface UiProps {
|
|
73
|
-
theme: string;
|
|
74
|
-
}
|
|
75
|
-
type CardPermissionsMap = Record<string, string>;
|
|
76
|
-
interface CardUserRole {
|
|
77
|
-
key?: string;
|
|
78
|
-
name?: string;
|
|
79
|
-
description?: string | null;
|
|
80
|
-
abbr?: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* DomeEmbeddedAppSdk:
|
|
84
|
-
* Base SDK class providing methods to send messages to the parent application.
|
|
85
|
-
*/
|
|
86
|
-
declare class DomeEmbeddedAppSdk {
|
|
58
|
+
export declare class DomeEmbeddedAppSdk {
|
|
87
59
|
private readonly targetOrigin;
|
|
88
60
|
protected isAppReady: boolean;
|
|
89
61
|
protected port2: MessagePort | null;
|
|
@@ -92,303 +64,16 @@ declare class DomeEmbeddedAppSdk {
|
|
|
92
64
|
protected parentCapabilities: HostCapabilities | null;
|
|
93
65
|
private readonly handleDeepLinkClick;
|
|
94
66
|
constructor();
|
|
95
|
-
/**
|
|
96
|
-
* Detects the host (iOS, Android, or Web) and saves it.
|
|
97
|
-
*/
|
|
98
67
|
private detectHost;
|
|
99
|
-
/**
|
|
100
|
-
* Listens for deep link anchor clicks on web to forward them to the parent app.
|
|
101
|
-
*/
|
|
102
68
|
private setupDeepLinkInterception;
|
|
103
|
-
/**
|
|
104
|
-
* Sends an OPEN_DEEPLINK message when the href uses an allowed protocol.
|
|
105
|
-
* @returns true if the message was dispatched, false otherwise.
|
|
106
|
-
*/
|
|
107
69
|
protected emitDeepLink(href: string): boolean;
|
|
108
70
|
protected updateParentContext(host?: HostInfo | null, capabilities?: HostCapabilities | null): void;
|
|
109
71
|
getHost(): HostDetails;
|
|
110
|
-
/**
|
|
111
|
-
* Method to send messages to the parent application.
|
|
112
|
-
* Ensures the parent window exists and sends a structured message with type and data.
|
|
113
|
-
* @param type - The type of message being sent
|
|
114
|
-
* @param data - (Optional) payload data for the message
|
|
115
|
-
*/
|
|
116
72
|
protected sendMessage(type: ViewerMessageType | CardMessageType, data?: any): void;
|
|
117
|
-
/**
|
|
118
|
-
* Notifies the parent application that the app is ready, if it hasn’t already.
|
|
119
|
-
*/
|
|
120
73
|
protected sendAppInit(): void;
|
|
121
|
-
|
|
122
|
-
* Safely invokes a function from the handler object if it exists.
|
|
123
|
-
* and logs a warning if the handler is not provided for the given message type.
|
|
124
|
-
*
|
|
125
|
-
* @param eventName - Name of the event method to be invoked from the handler.
|
|
126
|
-
* @param handlerObj - The handler object that contains the message handling methods.
|
|
127
|
-
* @param data - (Optional) The data to be passed to the handler function if invoked.
|
|
128
|
-
*/
|
|
129
|
-
protected safeInvoke<T extends ViewerEventHandler | CardEventHandler>(eventName: keyof T, handlerObj: T, data?: any): void;
|
|
74
|
+
protected safeInvoke<T extends Record<string, any>>(eventName: keyof T, handlerObj: T, data?: any): void;
|
|
130
75
|
protected setupParentConnection(): Promise<void>;
|
|
131
76
|
private notifyConnectionSuccess;
|
|
132
77
|
private handlePortMessage;
|
|
133
78
|
protected handleMessage(type: string, data: any): void;
|
|
134
79
|
}
|
|
135
|
-
/**
|
|
136
|
-
* ViewerSdk:
|
|
137
|
-
* A subclass of DomeEmbeddedAppSdk specifically for document viewer applications.
|
|
138
|
-
* It includes additional methods and properties to manage app interactions.
|
|
139
|
-
*/
|
|
140
|
-
export declare class ViewerSdk extends DomeEmbeddedAppSdk {
|
|
141
|
-
private static instance;
|
|
142
|
-
private static initialized;
|
|
143
|
-
private handler;
|
|
144
|
-
private pendingRequests;
|
|
145
|
-
private pendingInitAck;
|
|
146
|
-
private constructor();
|
|
147
|
-
/**
|
|
148
|
-
* Static initialization method to get or create the singleton instance of ViewerSdk.
|
|
149
|
-
* Allows setting the handler during initialization.
|
|
150
|
-
* @param handler - (Optional) Custom handler for different message types
|
|
151
|
-
* @returns The singleton ViewerSdk instance
|
|
152
|
-
*/
|
|
153
|
-
static init(handler?: ViewerEventHandler): ViewerSdk;
|
|
154
|
-
/**
|
|
155
|
-
* Method to set or update the handler object.
|
|
156
|
-
* @param handler - Custom handler for different message types
|
|
157
|
-
*/
|
|
158
|
-
setHandler(handler: ViewerEventHandler): void;
|
|
159
|
-
/**
|
|
160
|
-
* Checks if the given permissions string allows reading.
|
|
161
|
-
* @param perms - The permissions string.
|
|
162
|
-
* @returns - True if the permission string includes read access.
|
|
163
|
-
*/
|
|
164
|
-
canRead(perms?: string): boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Checks if the given permissions string allows writing.
|
|
167
|
-
* @param perms - The permissions string.
|
|
168
|
-
* @returns - True if the permission string includes write access.
|
|
169
|
-
*/
|
|
170
|
-
canWrite(perms?: string): boolean;
|
|
171
|
-
initializeViewerSdk(): void;
|
|
172
|
-
/**
|
|
173
|
-
* Sends a request to the parent application to retrieve initial data.
|
|
174
|
-
*/
|
|
175
|
-
requestInitialData(): void;
|
|
176
|
-
/**
|
|
177
|
-
* Sends a request to the parent application to save data.
|
|
178
|
-
* @param doc - payload data to be saved
|
|
179
|
-
* @param isDataDirty - Boolean indicating indicating modified data
|
|
180
|
-
*/
|
|
181
|
-
requestSave(doc: Document, isDataDirty: boolean): Promise<SaveStatusData>;
|
|
182
|
-
private handleOnSave;
|
|
183
|
-
/**
|
|
184
|
-
* Sets the viewer's "dirty" state, indicating modified data.
|
|
185
|
-
* @param isDirty - Boolean indicating whether the viewer has modified data
|
|
186
|
-
*/
|
|
187
|
-
setDirty(isDirty: boolean): void;
|
|
188
|
-
/**
|
|
189
|
-
* Sends a close request to the parent, with information on whether the data is dirty.
|
|
190
|
-
* @param doc - Latest document data
|
|
191
|
-
* @param isDataDirty - Boolean indicating indicating modified data
|
|
192
|
-
*/
|
|
193
|
-
sendClose(doc: Document, isDataDirty: boolean): void;
|
|
194
|
-
/**
|
|
195
|
-
* Sends an exception to parent.
|
|
196
|
-
* @param error - An error object with name and message or an error string
|
|
197
|
-
*/
|
|
198
|
-
sendException(error: {
|
|
199
|
-
name?: string;
|
|
200
|
-
message: string;
|
|
201
|
-
} | string): void;
|
|
202
|
-
protected handleMessage(type: ClientMessageType, data: any): void;
|
|
203
|
-
}
|
|
204
|
-
export declare enum CardMessageType {
|
|
205
|
-
APP_READY = "APP_READY",// Indicates the app is ready to be interacted with
|
|
206
|
-
INIT = "INIT",// Event to send the init key to the viewer
|
|
207
|
-
READ_FILE = "READ_FILE",
|
|
208
|
-
WRITE_FILE = "WRITE_FILE",
|
|
209
|
-
DELETE_FILE = "DELETE_FILE",
|
|
210
|
-
LIST_FILES = "LIST_FILES",
|
|
211
|
-
FILE_DIRTY = "FILE_DIRTY",
|
|
212
|
-
OPEN_DEEPLINK = "OPEN_DEEPLINK",// Sends a deep link href back to the parent
|
|
213
|
-
AF1_DATA_TOKEN = "AF1_DATA_TOKEN"
|
|
214
|
-
}
|
|
215
|
-
export declare enum CardPermission {
|
|
216
|
-
READ = "r",
|
|
217
|
-
WRITE = "w",
|
|
218
|
-
FORWARD = "f",
|
|
219
|
-
SHARE = "s",
|
|
220
|
-
DOWNLOAD = "d"
|
|
221
|
-
}
|
|
222
|
-
export declare const cardPermission: typeof CardPermission;
|
|
223
|
-
export interface CardEventHandler {
|
|
224
|
-
onInit: (data: any) => void;
|
|
225
|
-
onError: (data: {
|
|
226
|
-
error_code: string | number;
|
|
227
|
-
message: string;
|
|
228
|
-
data: any;
|
|
229
|
-
}) => void;
|
|
230
|
-
onFileChange: (data: {
|
|
231
|
-
iuid: string;
|
|
232
|
-
data: {
|
|
233
|
-
data: {
|
|
234
|
-
type: string;
|
|
235
|
-
value: any;
|
|
236
|
-
};
|
|
237
|
-
link: {
|
|
238
|
-
url: string;
|
|
239
|
-
};
|
|
240
|
-
meta: any;
|
|
241
|
-
perms: any;
|
|
242
|
-
from_cache: boolean;
|
|
243
|
-
};
|
|
244
|
-
}) => void;
|
|
245
|
-
onRefreshRequest: (data: any) => void;
|
|
246
|
-
}
|
|
247
|
-
export type CardFsCallback<T = any> = (payload: T) => void;
|
|
248
|
-
export interface CardFsReadResult {
|
|
249
|
-
name?: string;
|
|
250
|
-
iuid?: string | null;
|
|
251
|
-
object?: any;
|
|
252
|
-
data?: any;
|
|
253
|
-
is_stale: boolean;
|
|
254
|
-
is_complete: boolean;
|
|
255
|
-
}
|
|
256
|
-
export interface CardFsReadHandler {
|
|
257
|
-
next: CardFsCallback<CardFsReadResult>;
|
|
258
|
-
error?: CardFsCallback<Error>;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Use CardSdk to create webapp cards
|
|
262
|
-
*/
|
|
263
|
-
export declare class CardSdk extends DomeEmbeddedAppSdk {
|
|
264
|
-
private static instance;
|
|
265
|
-
private handler;
|
|
266
|
-
private cryptoA01;
|
|
267
|
-
private static readonly FS_RESPONSE_TIMEOUT_MS;
|
|
268
|
-
private static readonly FS_READ_RETENTION_MS;
|
|
269
|
-
private static readonly CARD_FS_ACK_TIMEOUT_MS;
|
|
270
|
-
private static readonly DEFAULT_ROLE_PERMISSIONS;
|
|
271
|
-
dataStore: any;
|
|
272
|
-
private accessToken;
|
|
273
|
-
devMode: boolean;
|
|
274
|
-
permission: CardPermissionsMap | null;
|
|
275
|
-
userRole: CardUserRole | null;
|
|
276
|
-
cardFS: {
|
|
277
|
-
read: (name: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
|
|
278
|
-
readById: (iuid: string, handler: CardFsReadHandler, allowStale?: boolean) => void;
|
|
279
|
-
write: (name: string, fileData: any, onResult?: CardFsCallback) => Promise<any>;
|
|
280
|
-
writeById: (iuid: string, fileData: any, onResult?: CardFsCallback) => Promise<any>;
|
|
281
|
-
delete: (name: string, onResult?: CardFsCallback) => Promise<any>;
|
|
282
|
-
deleteById: (iuid: string, onResult?: CardFsCallback) => Promise<any>;
|
|
283
|
-
list: (onResult?: CardFsCallback) => Promise<any>;
|
|
284
|
-
};
|
|
285
|
-
private fsReadRequests;
|
|
286
|
-
private fsWriteRequests;
|
|
287
|
-
private cardFsCache;
|
|
288
|
-
private containerIuid?;
|
|
289
|
-
private pendingAcks;
|
|
290
|
-
private buildCardFsMessagePayload;
|
|
291
|
-
private assertValidReadHandler;
|
|
292
|
-
private invokeReadHandlerNext;
|
|
293
|
-
private invokeReadHandlerError;
|
|
294
|
-
private sanitizeReadData;
|
|
295
|
-
private getCardIuid;
|
|
296
|
-
private ensureCardFsCache;
|
|
297
|
-
private supportsParentCardFs;
|
|
298
|
-
private shouldUseCardFsFallback;
|
|
299
|
-
private constructor();
|
|
300
|
-
/**
|
|
301
|
-
* Static initialization method to get or create the singleton instance of CardSdk.
|
|
302
|
-
* @param secret - The card developer secret key
|
|
303
|
-
* @param handler - (Optional) Handler for different events emitted by the SDK
|
|
304
|
-
* @returns The singleton CardSdk instance
|
|
305
|
-
*/
|
|
306
|
-
static init(secret: string, handler?: CardEventHandler, options?: {
|
|
307
|
-
devMode?: boolean;
|
|
308
|
-
}): Promise<CardSdk>;
|
|
309
|
-
/**
|
|
310
|
-
* Method to set or update the handler object.
|
|
311
|
-
* @param handler - Custom handler for different message types
|
|
312
|
-
*/
|
|
313
|
-
setHandler(handler: CardEventHandler): void;
|
|
314
|
-
/**
|
|
315
|
-
* Sends a deep link request to the parent directly from the card.
|
|
316
|
-
*/
|
|
317
|
-
openDeepLink(href: string): void;
|
|
318
|
-
/**
|
|
319
|
-
* Checks if the user has the requested permission.
|
|
320
|
-
* @param permission - A value from CardPermission enum (e.g CardPermission.READ, CardPermission.WRITE)
|
|
321
|
-
* @returns Boolean based on the permission presence
|
|
322
|
-
*/
|
|
323
|
-
hasPerm(permission: CardPermission): boolean;
|
|
324
|
-
/**
|
|
325
|
-
* Checks if the permissions allow reading
|
|
326
|
-
* @returns - True if the permission string allows read access to user
|
|
327
|
-
*/
|
|
328
|
-
canRead(): boolean;
|
|
329
|
-
/**
|
|
330
|
-
* Checks if the permissions allow writing
|
|
331
|
-
* @returns - True if the permission string allows write access to user
|
|
332
|
-
*/
|
|
333
|
-
canWrite(): boolean;
|
|
334
|
-
private deriveSecretSeed;
|
|
335
|
-
private getCardIuidEnc;
|
|
336
|
-
private requestAf1DataFromParent;
|
|
337
|
-
private fetchAf1Data;
|
|
338
|
-
private initializeCardSdk;
|
|
339
|
-
private sendInit;
|
|
340
|
-
private getWebappDetails;
|
|
341
|
-
private sendMessageWithAck;
|
|
342
|
-
private resolvePendingAckByType;
|
|
343
|
-
protected handleMessage: (type: ClientMessageType, data: any) => void;
|
|
344
|
-
private cardsFsRead;
|
|
345
|
-
private cardsFsReadById;
|
|
346
|
-
private cardsFsReadInternal;
|
|
347
|
-
private cardsFsWrite;
|
|
348
|
-
private cardsFsWriteById;
|
|
349
|
-
private cardsFsWriteInternal;
|
|
350
|
-
private cardsFsDelete;
|
|
351
|
-
private cardsFsDeleteById;
|
|
352
|
-
private cardsFsDeleteInternal;
|
|
353
|
-
private cardsFsList;
|
|
354
|
-
private handleFsReadDataMessage;
|
|
355
|
-
private clearFsReadRequest;
|
|
356
|
-
private failFsReadRequest;
|
|
357
|
-
private clearFsWriteRequest;
|
|
358
|
-
private failFsWriteRequest;
|
|
359
|
-
private handleFsWriteSuccess;
|
|
360
|
-
private handleFsWriteError;
|
|
361
|
-
private cardsFsReadFallback;
|
|
362
|
-
private cardsFsWriteFallback;
|
|
363
|
-
private cardsFsDeleteFallback;
|
|
364
|
-
private cardsFsListFallback;
|
|
365
|
-
private authHeader;
|
|
366
|
-
private jsonHeaders;
|
|
367
|
-
private fetchDocumentMetadataByTarget;
|
|
368
|
-
private fetchDocumentMetadataByIuid;
|
|
369
|
-
private normalizeDocumentsResponse;
|
|
370
|
-
private extractHttpErrorMessage;
|
|
371
|
-
private fetchDocumentMetadataByName;
|
|
372
|
-
private fetchAllDocuments;
|
|
373
|
-
private fetchDocumentPayload;
|
|
374
|
-
private fetchDocumentData;
|
|
375
|
-
private buildFileFormData;
|
|
376
|
-
private upsertDocumentViaApi;
|
|
377
|
-
/**
|
|
378
|
-
* Get document associated with the current card
|
|
379
|
-
*/
|
|
380
|
-
getDocumentAttachedToCard(card_iuid: string, document_name?: string): Promise<any>;
|
|
381
|
-
/**
|
|
382
|
-
* Save document attached to current card
|
|
383
|
-
*/
|
|
384
|
-
postDocumentAttachedToCard(card_iuid: string, document: any): Promise<any>;
|
|
385
|
-
getCardDocument(card_iuid: string, doc_name: string): Promise<Response>;
|
|
386
|
-
private formatErrorMessage;
|
|
387
|
-
private sendEventError;
|
|
388
|
-
setFileDirty(data: {
|
|
389
|
-
iuid: string;
|
|
390
|
-
ts_m: number;
|
|
391
|
-
}): void;
|
|
392
|
-
getUsername(userObj: any): string;
|
|
393
|
-
}
|
|
394
|
-
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DomeEmbeddedAppSdk, ViewerMessageType, CardMessageType, ClientMessageType, } from "./dome-sdk";
|
|
2
|
+
export type { HostInfo, HostCapabilities, HostDetails } from "./dome-sdk";
|
|
3
|
+
export { ViewerSdk } from "./viewer-sdk";
|
|
4
|
+
export type { ViewerEventHandler, Document, UiProps } from "./viewer-sdk";
|
|
5
|
+
export { CardSdk, CardPermission, cardPermission, getKeyFromBlob } from "./card-sdk";
|
|
6
|
+
export type { CardEventHandler, CardFsCallback, CardFsReadResult, CardFsReadHandler, CardKeyBlob, CardKeyBlobV1, } from "./card-sdk";
|
|
2
7
|
export { CryptoA01 } from "./crypto";
|
|
3
|
-
export type { ViewerMessageType, ViewerEventHandler, Document, UiProps } from "./dome-sdk";
|
|
4
|
-
export type { CardMessageType, CardEventHandler } from "./dome-sdk";
|
|
5
|
-
export { CardPermission, cardPermission } from "./dome-sdk";
|