dome-embedded-app-sdk 0.4.3 → 0.5.0

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/docs/card-sdk.md CHANGED
@@ -1,162 +1,162 @@
1
- # Card SDK Guide
2
-
3
- The Card SDK powers embedded card experiences inside a dome.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install dome-embedded-app-sdk
9
- ```
10
-
11
- ## Starter projects
12
-
13
- - React card starter: <https://github.com/InTouchSO/card-react_starter>
14
- - Angular card starter: <https://github.com/InTouchSO/card-angular_starter>
15
-
16
- ## Initialize
17
-
18
- ```JavaScript
19
- import { CardSdk, getKeyFromBlob } from "dome-embedded-app-sdk";
20
-
21
- const my_card_decryption_blob = {...};
22
-
23
- CardSdk.init(getKeyFromBlob(my_card_decryption_blob), {
24
- onInit: (data) => {
25
- console.debug("onInit payload", data);
26
- },
27
- onInitError: ({ error_code, message }) => {
28
- console.error("Initialization error", error_code, message);
29
- }
30
- onError: ({ error_code, message }) => {
31
- console.error("Card error", error_code, message);
32
- }
33
- }).then((sdk) => this.sdk = sdk);
34
- ```
35
-
36
- `onInit` receives the user payload, permissions, role, container info, and UI metadata.
37
-
38
- ### onInit payload
39
-
40
- The payload is a `CardInitData` object with these commonly used fields:
41
-
42
- - `api_token`: token for authenticated API calls.
43
- - `iuid`: card instance identifier.
44
- - `user`: current user profile (see `CardUser`), includes `name`, `photo`, `organization`, and `getFullName()`.
45
- - `perms_v2`: permission map keyed by role abbreviation.
46
- - `role`: role metadata for the current user.
47
- - `container`: container metadata (includes `iuid`).
48
- - `ui`: UI metadata including `ui.theme`
49
-
50
- Use the exported `CardInitData` and `CardUser` types for full payload typing.
51
-
52
- ## Events
53
-
54
- - `onInit(data)`: Fired after the card payload is decrypted.
55
- - `onInitError(data)`: Fired when initialization fails.
56
- - `onError(data)`: Fired for runtime errors.
57
-
58
- ## Card permissions
59
-
60
- ```JavaScript
61
- import { CardPermission, cardPermission } from "dome-embedded-app-sdk";
62
- ```
63
-
64
- - `CardPermission`: enum of permission codes (`READ`, `WRITE`, `FORWARD`, `SHARE`, `DOWNLOAD`).
65
- - `cardPermission`: convenience alias for the enum.
66
- - `hasPerm(permission)`: Check for a specific `CardPermission`.
67
- - `canRead()` / `canWrite()`: Convenience permission checks.
68
-
69
- ## CardFS error codes
70
-
71
- ```JavaScript
72
- import { CardFsErrorCode } from "dome-embedded-app-sdk";
73
- ```
74
-
75
- `CardFsErrorCode` provides standardized error codes for cardFS operations:
76
- `NO_INTERNET`, `NO_PERMISSION`, `NOT_FOUND`, `SERVER_ERROR`, `TIMEOUT`, `INVALID_REQUEST`, `UNKNOWN`.
77
-
78
- ## CardFS (file storage)
79
-
80
- `cardFS` is a high-level API for reading, writing, deleting, and listing files. Each method either returns a promise or uses handlers for streaming updates.
81
-
82
- ### Understanding `is_stale`, `is_complete`, `is_dirty`
83
-
84
- - `is_stale`: the payload may be from cache and could be outdated; a fresh payload can arrive later.
85
- - `is_complete`: no more updates are expected for this request (final chunk or last page).
86
- - `is_dirty`: the file/listing has pending local changes that aren’t yet synchronized.
87
-
88
- #### Common scenarios
89
-
90
- - **Cached read**: `is_stale: true`, `is_complete: true` (cached result only).
91
- - **Cached + live read**: first payload `is_stale: true`, then a later payload `is_stale: false`.
92
- - **Streaming read/list**: intermediate updates `is_complete: false`, final update `is_complete: true`.
93
-
94
- ### Read
95
-
96
- ```JavaScript
97
- sdk.cardFS.read("my-journal.json", {
98
- next: (payload) => {
99
- console.debug("Read payload", payload);
100
- },
101
- error: (err) => {
102
- console.error("Read error", err);
103
- }
104
- });
105
- ```
106
-
107
- - `read(name, handler, allowStale?)`
108
- - `readById(iuid, handler, allowStale?)`
109
-
110
- `read` and `readById` fetch a file by name or id and stream updates through the handler until `is_complete` is true.
111
-
112
- `payload` includes `object`, `data`, `is_stale`, `is_complete`, and `is_dirty` flags.
113
-
114
- ### Write
115
-
116
- ```JavaScript
117
- import { CardFsFileType } from "dome-embedded-app-sdk";
118
-
119
- sdk.cardFS.write("my-journal.json", { text: "Hello" }, CardFsFileType.JSON, (update) => {
120
- console.debug("Upload status", update.status, update.progress);
121
- });
122
- ```
123
-
124
- - `write(name, fileData, fileType, onUpdate?)`
125
- - `writeById(iuid, fileData, fileType, onUpdate?)`
126
-
127
- `write` and `writeById` upload new data for a file and optionally report progress through `onUpdate`.
128
-
129
- `fileType` can be `CardFsFileType.JSON`, `CardFsFileType.TEXT`, or `CardFsFileType.BINARY`.
130
-
131
- `onUpdate` receives `{ status, progress, uploaded_bytes }` when available.
132
-
133
- ### Delete
134
-
135
- - `delete(name, onUpdate?)`
136
- - `deleteById(iuid, onUpdate?)`
137
-
138
- `delete` and `deleteById` remove a file by name or id and optionally report progress.
139
-
140
- ### List
141
-
142
- When listing folders, the folder name should not start with `/` and must end with `/` (for example: `notes/`).
143
-
144
- ```JavaScript
145
- sdk.cardFS.list("notes/", {
146
- next: (payload) => {
147
- console.debug("Folder listing", payload.documents);
148
- },
149
- error: (err) => {
150
- console.error("List error", err);
151
- }
152
- });
153
- ```
154
-
155
- `list(folderName, handler)` yields the folder data with `documents`, `is_stale`, and `is_complete` flags.
156
-
157
- `list` retrieves a folder listing and streams page updates until the final page is reached.
158
-
159
- ## Utilities
160
-
161
- - `openDeepLink(url)`: Ask the host to open a supported deep link.
162
- - `getKeyFromBlob(blob)`: Decode a `CardKeyBlob` into the secret string.
1
+ # Card SDK Guide
2
+
3
+ The Card SDK powers embedded card experiences inside a dome.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install dome-embedded-app-sdk
9
+ ```
10
+
11
+ ## Starter projects
12
+
13
+ - React card starter: <https://github.com/InTouchSO/card-react_starter>
14
+ - Angular card starter: <https://github.com/InTouchSO/card-angular_starter>
15
+
16
+ ## Initialize
17
+
18
+ ```JavaScript
19
+ import { CardSdk, getKeyFromBlob } from "dome-embedded-app-sdk";
20
+
21
+ const my_card_decryption_blob = {...};
22
+
23
+ CardSdk.init(getKeyFromBlob(my_card_decryption_blob), {
24
+ onInit: (data) => {
25
+ console.debug("onInit payload", data);
26
+ },
27
+ onInitError: ({ error_code, message }) => {
28
+ console.error("Initialization error", error_code, message);
29
+ }
30
+ onError: ({ error_code, message }) => {
31
+ console.error("Card error", error_code, message);
32
+ }
33
+ }).then((sdk) => this.sdk = sdk);
34
+ ```
35
+
36
+ `onInit` receives the user payload, permissions, role, container info, and UI metadata.
37
+
38
+ ### onInit payload
39
+
40
+ The payload is a `CardInitData` object with these commonly used fields:
41
+
42
+ - `api_token`: token for authenticated API calls.
43
+ - `iuid`: card instance identifier.
44
+ - `user`: current user profile (see `CardUser`), includes `name`, `photo`, `organization`, and `getFullName()`.
45
+ - `perms_v2`: permission map keyed by role abbreviation.
46
+ - `role`: role metadata for the current user.
47
+ - `container`: container metadata (includes `iuid`).
48
+ - `ui`: UI metadata including `ui.theme`
49
+
50
+ Use the exported `CardInitData` and `CardUser` types for full payload typing.
51
+
52
+ ## Events
53
+
54
+ - `onInit(data)`: Fired after the card payload is decrypted.
55
+ - `onInitError(data)`: Fired when initialization fails.
56
+ - `onError(data)`: Fired for runtime errors.
57
+
58
+ ## Card permissions
59
+
60
+ ```JavaScript
61
+ import { CardPermission, cardPermission } from "dome-embedded-app-sdk";
62
+ ```
63
+
64
+ - `CardPermission`: enum of permission codes (`READ`, `WRITE`, `FORWARD`, `SHARE`, `DOWNLOAD`).
65
+ - `cardPermission`: convenience alias for the enum.
66
+ - `hasPerm(permission)`: Check for a specific `CardPermission`.
67
+ - `canRead()` / `canWrite()`: Convenience permission checks.
68
+
69
+ ## CardFS error codes
70
+
71
+ ```JavaScript
72
+ import { CardFsErrorCode } from "dome-embedded-app-sdk";
73
+ ```
74
+
75
+ `CardFsErrorCode` provides standardized error codes for cardFS operations:
76
+ `NO_INTERNET`, `NO_PERMISSION`, `NOT_FOUND`, `SERVER_ERROR`, `TIMEOUT`, `INVALID_REQUEST`, `UNKNOWN`.
77
+
78
+ ## CardFS (file storage)
79
+
80
+ `cardFS` is a high-level API for reading, writing, deleting, and listing files. Each method either returns a promise or uses handlers for streaming updates.
81
+
82
+ ### Understanding `is_stale`, `is_complete`, `is_dirty`
83
+
84
+ - `is_stale`: the payload may be from cache and could be outdated; a fresh payload can arrive later.
85
+ - `is_complete`: no more updates are expected for this request (final chunk or last page).
86
+ - `is_dirty`: the file/listing has pending local changes that aren’t yet synchronized.
87
+
88
+ #### Common scenarios
89
+
90
+ - **Cached read**: `is_stale: true`, `is_complete: true` (cached result only).
91
+ - **Cached + live read**: first payload `is_stale: true`, then a later payload `is_stale: false`.
92
+ - **Streaming read/list**: intermediate updates `is_complete: false`, final update `is_complete: true`.
93
+
94
+ ### Read
95
+
96
+ ```JavaScript
97
+ sdk.cardFS.read("my-journal.json", {
98
+ next: (payload) => {
99
+ console.debug("Read payload", payload);
100
+ },
101
+ error: (err) => {
102
+ console.error("Read error", err);
103
+ }
104
+ });
105
+ ```
106
+
107
+ - `read(name, handler, allowStale?)`
108
+ - `readById(iuid, handler, allowStale?)`
109
+
110
+ `read` and `readById` fetch a file by name or id and stream updates through the handler until `is_complete` is true.
111
+
112
+ `payload` includes `object`, `data`, `is_stale`, `is_complete`, and `is_dirty` flags.
113
+
114
+ ### Write
115
+
116
+ ```JavaScript
117
+ import { CardFsFileType } from "dome-embedded-app-sdk";
118
+
119
+ sdk.cardFS.write("my-journal.json", { text: "Hello" }, CardFsFileType.JSON, (update) => {
120
+ console.debug("Upload status", update.status, update.progress);
121
+ });
122
+ ```
123
+
124
+ - `write(name, fileData, fileType, onUpdate?)`
125
+ - `writeById(iuid, fileData, fileType, onUpdate?)`
126
+
127
+ `write` and `writeById` upload new data for a file and optionally report progress through `onUpdate`.
128
+
129
+ `fileType` can be `CardFsFileType.JSON`, `CardFsFileType.TEXT`, or `CardFsFileType.BINARY`.
130
+
131
+ `onUpdate` receives `{ status, progress, uploaded_bytes }` when available.
132
+
133
+ ### Delete
134
+
135
+ - `delete(name, onUpdate?)`
136
+ - `deleteById(iuid, onUpdate?)`
137
+
138
+ `delete` and `deleteById` remove a file by name or id and optionally report progress.
139
+
140
+ ### List
141
+
142
+ When listing folders, the folder name should not start with `/` and must end with `/` (for example: `notes/`).
143
+
144
+ ```JavaScript
145
+ sdk.cardFS.list("notes/", {
146
+ next: (payload) => {
147
+ console.debug("Folder listing", payload.documents);
148
+ },
149
+ error: (err) => {
150
+ console.error("List error", err);
151
+ }
152
+ });
153
+ ```
154
+
155
+ `list(folderName, handler)` yields the folder data with `documents`, `is_stale`, and `is_complete` flags.
156
+
157
+ `list` retrieves a folder listing and streams page updates until the final page is reached.
158
+
159
+ ## Utilities
160
+
161
+ - `openDeepLink(url)`: Ask the host to open a supported deep link.
162
+ - `getKeyFromBlob(blob)`: Decode a `CardKeyBlob` into the secret string.
@@ -1,50 +1,50 @@
1
- # Viewer SDK Guide
2
-
3
- The Viewer SDK lets you build custom viewers/editors for documents inside Dome.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install dome-embedded-app-sdk
9
- ```
10
-
11
- ## Initialize
12
-
13
- ```JavaScript
14
- import { ViewerSdk } from "dome-embedded-app-sdk";
15
-
16
- ViewerSdk.init({
17
- onInitialData: ({ doc, ui }) => {
18
- console.debug("Initial data", doc, ui);
19
- },
20
- onDataChange: ({ doc }) => {
21
- console.debug("Doc changed", doc);
22
- },
23
- onCloseRequest: () => {
24
- console.debug("Close requested");
25
- },
26
- onSaveRequest: () => {
27
- console.debug("Save requested");
28
- }
29
- });
30
- ```
31
-
32
- ## Events
33
-
34
- - `onInitialData({ doc, ui, isNewFile, perms, config })`: Initial payload for the viewer.
35
- - `onDataChange({ doc, perms, userConsent })`: Updates when the document changes.
36
- - `onCloseRequest()`: Parent requests close.
37
- - `onSaveRequest()`: Parent requests save.
38
-
39
- ## Permissions
40
-
41
- - `canRead(perms)`: Returns true if read is allowed.
42
- - `canWrite(perms)`: Returns true if write is allowed.
43
-
44
- ## Viewer actions
45
-
46
- - `requestInitialData()`: Ask the host to resend initial data.
47
- - `requestSave(doc, isDataDirty)`: Ask the host to save and return a status promise.
48
- - `setDirty(isDirty)`: Notify the host about dirty state.
49
- - `sendClose(doc, isDataDirty)`: Notify the host to close.
50
- - `sendException(error)`: Report an exception to the host.
1
+ # Viewer SDK Guide
2
+
3
+ The Viewer SDK lets you build custom viewers/editors for documents inside Dome.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install dome-embedded-app-sdk
9
+ ```
10
+
11
+ ## Initialize
12
+
13
+ ```JavaScript
14
+ import { ViewerSdk } from "dome-embedded-app-sdk";
15
+
16
+ ViewerSdk.init({
17
+ onInitialData: ({ doc, ui }) => {
18
+ console.debug("Initial data", doc, ui);
19
+ },
20
+ onDataChange: ({ doc }) => {
21
+ console.debug("Doc changed", doc);
22
+ },
23
+ onCloseRequest: () => {
24
+ console.debug("Close requested");
25
+ },
26
+ onSaveRequest: () => {
27
+ console.debug("Save requested");
28
+ }
29
+ });
30
+ ```
31
+
32
+ ## Events
33
+
34
+ - `onInitialData({ doc, ui, isNewFile, perms, config })`: Initial payload for the viewer.
35
+ - `onDataChange({ doc, perms, userConsent })`: Updates when the document changes.
36
+ - `onCloseRequest()`: Parent requests close.
37
+ - `onSaveRequest()`: Parent requests save.
38
+
39
+ ## Permissions
40
+
41
+ - `canRead(perms)`: Returns true if read is allowed.
42
+ - `canWrite(perms)`: Returns true if write is allowed.
43
+
44
+ ## Viewer actions
45
+
46
+ - `requestInitialData()`: Ask the host to resend initial data.
47
+ - `requestSave(doc, isDataDirty)`: Ask the host to save and return a status promise.
48
+ - `setDirty(isDirty)`: Notify the host about dirty state.
49
+ - `sendClose(doc, isDataDirty)`: Notify the host to close.
50
+ - `sendException(error)`: Report an exception to the host.
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "dome-embedded-app-sdk",
3
- "version": "0.4.3",
4
- "source": "src/index.ts",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- },
15
- "files": [
16
- "dist",
17
- "docs"
18
- ],
19
- "scripts": {
20
- "clean": "node ./scripts/clean-dist.mjs",
21
- "build:tsc": "tsc --emitDeclarationOnly",
22
- "build:webpack": "webpack --config webpack.config.ts",
23
- "build:webpack:experimental": "webpack --config webpack.config.ts --env experimental",
24
- "build": "npm run clean && npm run build:tsc && npm run build:webpack",
25
- "build:experimental": "npm run clean && npm run build:tsc && npm run build:webpack:experimental",
26
- "release": "npm run build && npm publish",
27
- "release:experimental": "npm run build:experimental && npm publish --tag experimental",
28
- "version:patch": "npm version patch && git push && git push --tags && npm run release",
29
- "version:minor": "npm version minor && git push && git push --tags && npm run release",
30
- "version:major": "npm version major && git push && git push --tags && npm run release",
31
- "version:experimental": "npm version prerelease --preid=experimental && git push && git push --tags && git push origin HEAD:experimental && npm run release:experimental",
32
- "test-pack": "npm pack --dry-run",
33
- "watch": "webpack --watch"
34
- },
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "keywords": [
39
- "dome",
40
- "dome-sdk"
41
- ],
42
- "author": "",
43
- "license": "ISC",
44
- "description": "",
45
- "dependencies": {
46
- "cbor-x": "^1.6.0"
47
- },
48
- "devDependencies": {
49
- "@types/node": "^22.13.10",
50
- "@types/webpack": "^5.28.5",
51
- "ts-loader": "^9.5.1",
52
- "ts-node": "^10.9.2",
53
- "typescript": "^5.8.2",
54
- "webpack-cli": "^5.1.4"
55
- }
56
- }
1
+ {
2
+ "name": "dome-embedded-app-sdk",
3
+ "version": "0.5.0",
4
+ "source": "src/index.ts",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "docs"
18
+ ],
19
+ "scripts": {
20
+ "clean": "node ./scripts/clean-dist.mjs",
21
+ "build:tsc": "tsc --emitDeclarationOnly",
22
+ "build:webpack": "webpack --config webpack.config.ts",
23
+ "build:webpack:experimental": "webpack --config webpack.config.ts --env experimental",
24
+ "build": "npm run clean && npm run build:tsc && npm run build:webpack",
25
+ "build:experimental": "npm run clean && npm run build:tsc && npm run build:webpack:experimental",
26
+ "release": "npm run build && npm publish",
27
+ "release:experimental": "npm run build:experimental && npm publish --tag experimental",
28
+ "version:patch": "npm version patch && git push && git push --tags && npm run release",
29
+ "version:minor": "npm version minor && git push && git push --tags && npm run release",
30
+ "version:major": "npm version major && git push && git push --tags && npm run release",
31
+ "version:experimental": "npm version prerelease --preid=experimental && git push && git push --tags && git push origin HEAD:experimental && npm run release:experimental",
32
+ "test-pack": "npm pack --dry-run",
33
+ "watch": "webpack --watch"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "keywords": [
39
+ "dome",
40
+ "dome-sdk"
41
+ ],
42
+ "author": "",
43
+ "license": "ISC",
44
+ "description": "",
45
+ "dependencies": {
46
+ "cbor-x": "^1.6.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^22.13.10",
50
+ "@types/webpack": "^5.28.5",
51
+ "ts-loader": "^9.5.1",
52
+ "ts-node": "^10.9.2",
53
+ "typescript": "^5.8.2",
54
+ "webpack-cli": "^5.1.4"
55
+ }
56
+ }