orgnote-api 0.20.2 → 0.40.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.
Files changed (283) hide show
  1. package/api.d.ts +93 -98
  2. package/constants/{command-groups.contant.d.ts → command-groups.d.ts} +2 -1
  3. package/constants/{command-groups.contant.js → command-groups.js} +2 -0
  4. package/constants/extension-errors.d.ts +9 -0
  5. package/constants/extension-errors.js +18 -0
  6. package/constants/file-guard-errors.d.ts +8 -0
  7. package/constants/file-guard-errors.js +18 -0
  8. package/constants/git-errors.d.ts +9 -0
  9. package/constants/git-errors.js +18 -0
  10. package/constants/i18n-keys.d.ts +371 -0
  11. package/constants/i18n-keys.js +158 -0
  12. package/constants/index.d.ts +9 -1
  13. package/constants/index.js +9 -1
  14. package/constants/oauth-providers.d.ts +1 -0
  15. package/constants/oauth-providers.js +1 -0
  16. package/constants/route-names.d.ts +36 -0
  17. package/constants/route-names.js +37 -0
  18. package/constants/route-paths.d.ts +5 -0
  19. package/constants/route-paths.js +4 -0
  20. package/constants/style-sizes.d.ts +1 -0
  21. package/constants/style-sizes.js +1 -0
  22. package/encryption/__tests__/encryption.spec.js +4 -5
  23. package/encryption/__tests__/note-encryption.spec.js +46 -348
  24. package/encryption/encryption.d.ts +9 -4
  25. package/encryption/encryption.js +25 -5
  26. package/encryption/note-encryption.d.ts +1 -1
  27. package/encryption/note-encryption.js +6 -6
  28. package/files-api.d.ts +0 -1
  29. package/index.d.ts +4 -1
  30. package/index.js +4 -1
  31. package/mappers/orgnode-to-note.d.ts +2 -2
  32. package/mappers/orgnode-to-note.js +3 -2
  33. package/models/auth-store.d.ts +3 -3
  34. package/models/buffer-store.d.ts +14 -0
  35. package/models/buffer.d.ts +24 -0
  36. package/models/colors.d.ts +1 -0
  37. package/models/command.d.ts +13 -8
  38. package/models/commands-group-store.d.ts +11 -0
  39. package/models/commands-store.d.ts +13 -0
  40. package/models/completion-store.d.ts +14 -0
  41. package/models/completion.d.ts +16 -7
  42. package/models/config-store.d.ts +9 -0
  43. package/models/confirmation-modal.d.ts +11 -0
  44. package/models/context-menu-store.d.ts +10 -0
  45. package/models/cron-store.d.ts +21 -0
  46. package/models/cron-task.d.ts +30 -0
  47. package/models/css-utils.d.ts +17 -0
  48. package/models/default-commands.d.ts +52 -3
  49. package/models/default-commands.js +59 -2
  50. package/models/encryption-store.d.ts +10 -0
  51. package/models/encryption-store.js +1 -0
  52. package/models/encryption.d.ts +54 -11
  53. package/models/encryption.js +28 -1
  54. package/models/extension-registry-store.d.ts +9 -0
  55. package/models/extension-registry-store.js +1 -0
  56. package/models/extension-store.d.ts +18 -0
  57. package/models/extension-store.js +1 -0
  58. package/models/extension.d.ts +96 -24
  59. package/models/extension.js +88 -1
  60. package/models/file-guard-store.d.ts +14 -0
  61. package/models/file-guard-store.js +1 -0
  62. package/models/file-guard.d.ts +27 -0
  63. package/models/file-guard.js +1 -0
  64. package/models/{file-cache.d.ts → file-info.d.ts} +1 -1
  65. package/models/file-info.js +1 -0
  66. package/models/file-manager-store.d.ts +10 -12
  67. package/models/file-opener-store.d.ts +6 -4
  68. package/models/file-system-manager-store.d.ts +13 -0
  69. package/models/file-system-manager-store.js +1 -0
  70. package/models/file-system-store.d.ts +19 -0
  71. package/models/file-system-store.js +1 -0
  72. package/models/file-system.d.ts +32 -5
  73. package/models/file-system.js +2 -0
  74. package/models/file-upload.d.ts +6 -0
  75. package/models/file-upload.js +1 -0
  76. package/models/file-watcher-store.d.ts +18 -0
  77. package/models/file-watcher-store.js +1 -0
  78. package/models/files-store.d.ts +2 -2
  79. package/models/git-store.d.ts +12 -0
  80. package/models/git-store.js +1 -0
  81. package/models/git.d.ts +47 -0
  82. package/models/git.js +1 -0
  83. package/models/i18n-keys.d.ts +2 -0
  84. package/models/i18n-keys.js +1 -0
  85. package/models/index.d.ts +56 -2
  86. package/models/index.js +59 -2
  87. package/models/layout-snapshot-repository.d.ts +14 -0
  88. package/models/layout-snapshot-repository.js +1 -0
  89. package/models/layout-store.d.ts +17 -0
  90. package/models/layout-store.js +1 -0
  91. package/models/layout.d.ts +16 -0
  92. package/models/layout.js +1 -0
  93. package/models/log-repository.d.ts +17 -0
  94. package/models/log-repository.js +1 -0
  95. package/models/log-store.d.ts +15 -0
  96. package/models/log-store.js +1 -0
  97. package/models/log.d.ts +12 -0
  98. package/models/log.js +1 -0
  99. package/models/logger.d.ts +8 -0
  100. package/models/logger.js +1 -0
  101. package/models/menu-action.d.ts +18 -0
  102. package/models/menu-action.js +1 -0
  103. package/models/modal-store.d.ts +16 -0
  104. package/models/modal-store.js +1 -0
  105. package/models/modal.d.ts +10 -2
  106. package/models/note.d.ts +30 -13
  107. package/models/notification-config.d.ts +14 -0
  108. package/models/notification-config.js +1 -0
  109. package/models/notifications-store.d.ts +20 -0
  110. package/models/notifications-store.js +1 -0
  111. package/models/oauth-provider.d.ts +2 -1
  112. package/models/orgnote-config.d.ts +80 -0
  113. package/models/orgnote-config.js +42 -0
  114. package/models/orgnote-url.d.ts +6 -0
  115. package/models/orgnote-url.js +1 -0
  116. package/models/pane-snapshot-repository.d.ts +0 -0
  117. package/models/pane-snapshot-repository.js +0 -0
  118. package/models/pane.d.ts +38 -0
  119. package/models/pane.js +1 -0
  120. package/models/panes-store.d.ts +30 -0
  121. package/models/panes-store.js +1 -0
  122. package/models/platform-detection.d.ts +11 -0
  123. package/models/platform-detection.js +1 -0
  124. package/models/platform-specific.d.ts +1 -0
  125. package/models/platform-specific.js +1 -0
  126. package/models/platform.d.ts +2 -0
  127. package/models/platform.js +1 -0
  128. package/models/queue-store.d.ts +49 -0
  129. package/models/queue-store.js +1 -0
  130. package/models/queue-task.d.ts +15 -0
  131. package/models/queue-task.js +1 -0
  132. package/models/repositories.d.ts +58 -38
  133. package/models/screen-detection.d.ts +10 -0
  134. package/models/screen-detection.js +1 -0
  135. package/models/settings-store.d.ts +12 -0
  136. package/models/settings-store.js +1 -0
  137. package/models/settings-ui-store.d.ts +7 -0
  138. package/models/settings-ui-store.js +1 -0
  139. package/models/sidebar-store.d.ts +22 -0
  140. package/models/sidebar-store.js +1 -0
  141. package/models/splash-screen.d.ts +13 -0
  142. package/models/splash-screen.js +1 -0
  143. package/models/store.d.ts +1 -1
  144. package/models/style-size.d.ts +2 -0
  145. package/models/style-size.js +1 -0
  146. package/models/style-variant.d.ts +1 -0
  147. package/models/style-variant.js +1 -0
  148. package/models/sync-store.d.ts +8 -6
  149. package/models/sync.d.ts +0 -5
  150. package/models/system-info.d.ts +47 -0
  151. package/models/system-info.js +1 -0
  152. package/models/theme-store.d.ts +16 -0
  153. package/models/theme-store.js +1 -0
  154. package/models/theme-variables.d.ts +4 -189
  155. package/models/theme-variables.js +2 -191
  156. package/models/toolbar-store.d.ts +9 -0
  157. package/models/toolbar-store.js +1 -0
  158. package/models/ui-store.d.ts +6 -0
  159. package/models/ui-store.js +1 -0
  160. package/models/user.d.ts +3 -4
  161. package/models/vue-component.d.ts +4 -2
  162. package/package-lock.json +5553 -0
  163. package/package.json +37 -26
  164. package/remote-api/api.d.ts +288 -669
  165. package/remote-api/api.js +199 -485
  166. package/remote-api/base.js +1 -1
  167. package/remote-api/common.d.ts +1 -1
  168. package/sync/__tests__/memory-state.spec.d.ts +1 -0
  169. package/sync/__tests__/memory-state.spec.js +49 -0
  170. package/sync/__tests__/plan.spec.d.ts +1 -0
  171. package/sync/__tests__/plan.spec.js +116 -0
  172. package/sync/create-sync-plan.d.ts +2 -0
  173. package/sync/create-sync-plan.js +13 -0
  174. package/sync/fetch.d.ts +8 -0
  175. package/sync/fetch.js +32 -0
  176. package/sync/index.d.ts +10 -0
  177. package/sync/index.js +9 -0
  178. package/sync/memory-state.d.ts +2 -0
  179. package/sync/memory-state.js +22 -0
  180. package/sync/operations/conflict.d.ts +10 -0
  181. package/sync/operations/conflict.js +56 -0
  182. package/sync/operations/delete-local.d.ts +2 -0
  183. package/sync/operations/delete-local.js +17 -0
  184. package/sync/operations/delete-remote.d.ts +2 -0
  185. package/sync/operations/delete-remote.js +26 -0
  186. package/sync/operations/download.d.ts +2 -0
  187. package/sync/operations/download.js +20 -0
  188. package/sync/operations/index.d.ts +5 -0
  189. package/sync/operations/index.js +5 -0
  190. package/sync/operations/synced-file.d.ts +14 -0
  191. package/sync/operations/synced-file.js +5 -0
  192. package/sync/operations/upload.d.ts +2 -0
  193. package/sync/operations/upload.js +30 -0
  194. package/sync/plan.d.ts +9 -0
  195. package/sync/plan.js +57 -0
  196. package/sync/recovery.d.ts +2 -0
  197. package/sync/recovery.js +6 -0
  198. package/sync/scan.d.ts +4 -0
  199. package/sync/scan.js +40 -0
  200. package/sync/types.d.ts +74 -0
  201. package/sync/types.js +7 -0
  202. package/sync/utils/__tests__/oldest-synced-at.spec.d.ts +1 -0
  203. package/sync/utils/__tests__/oldest-synced-at.spec.js +38 -0
  204. package/sync/utils/oldest-synced-at.d.ts +2 -0
  205. package/sync/utils/oldest-synced-at.js +9 -0
  206. package/types/index.d.ts +0 -0
  207. package/types/index.js +0 -0
  208. package/utils/__tests__/find-files-diff.spec.d.ts +1 -0
  209. package/{tools → utils}/__tests__/find-files-diff.spec.js +3 -3
  210. package/utils/__tests__/find-note-files-diff.spec.d.ts +1 -0
  211. package/{tools → utils}/__tests__/find-note-files-diff.spec.js +5 -5
  212. package/utils/__tests__/get-file-name.spec.d.ts +1 -0
  213. package/utils/__tests__/get-string-path.spec.d.ts +1 -0
  214. package/utils/__tests__/is-gpg-encrypted.spec.d.ts +1 -0
  215. package/utils/__tests__/is-org-file.spec.d.ts +1 -0
  216. package/utils/__tests__/join.spec.d.ts +1 -0
  217. package/utils/__tests__/join.spec.js +32 -0
  218. package/utils/__tests__/nullable-guards.spec.d.ts +1 -0
  219. package/utils/__tests__/nullable-guards.spec.js +44 -0
  220. package/utils/__tests__/parent-folder.spec.d.ts +1 -0
  221. package/utils/__tests__/read-org-files-recursively.spec.d.ts +1 -0
  222. package/utils/__tests__/split-path.spec.d.ts +1 -0
  223. package/utils/__tests__/to-absolute-path.spec.d.ts +1 -0
  224. package/utils/__tests__/to-absolute-path.spec.js +26 -0
  225. package/utils/__tests__/to-error.spec.d.ts +1 -0
  226. package/utils/__tests__/to-error.spec.js +112 -0
  227. package/utils/__tests__/with-root.spec.d.ts +1 -0
  228. package/utils/__tests__/with-root.spec.js +20 -0
  229. package/{tools → utils}/find-notes-files-diff.js +6 -3
  230. package/{tools → utils}/index.d.ts +4 -1
  231. package/{tools → utils}/index.js +4 -1
  232. package/utils/join-path.d.ts +1 -0
  233. package/utils/join-path.js +13 -0
  234. package/utils/nullable-guards.d.ts +2 -0
  235. package/utils/nullable-guards.js +6 -0
  236. package/utils/to-absolute-path.d.ts +2 -0
  237. package/utils/to-absolute-path.js +2 -0
  238. package/utils/to-error.d.ts +6 -0
  239. package/utils/to-error.js +33 -0
  240. package/utils/toml.d.ts +3 -0
  241. package/utils/toml.js +31 -0
  242. package/utils/with-root.d.ts +1 -0
  243. package/utils/with-root.js +6 -0
  244. package/websocket/client.d.ts +24 -0
  245. package/websocket/client.js +83 -0
  246. package/models/file-tree.d.ts +0 -12
  247. package/tools/__tests__/join.spec.js +0 -24
  248. package/tools/join-path.d.ts +0 -1
  249. package/tools/join-path.js +0 -7
  250. package/tools/mock-server.d.ts +0 -1
  251. package/tools/mock-server.js +0 -12
  252. /package/models/{file-cache.js → buffer-store.js} +0 -0
  253. /package/models/{file-tree.js → buffer.js} +0 -0
  254. /package/{tools/__tests__/find-files-diff.spec.d.ts → models/colors.js} +0 -0
  255. /package/{tools/__tests__/find-note-files-diff.spec.d.ts → models/commands-group-store.js} +0 -0
  256. /package/{tools/__tests__/get-file-name.spec.d.ts → models/commands-store.js} +0 -0
  257. /package/{tools/__tests__/get-string-path.spec.d.ts → models/completion-store.js} +0 -0
  258. /package/{tools/__tests__/is-gpg-encrypted.spec.d.ts → models/config-store.js} +0 -0
  259. /package/{tools/__tests__/is-org-file.spec.d.ts → models/confirmation-modal.js} +0 -0
  260. /package/{tools/__tests__/join.spec.d.ts → models/context-menu-store.js} +0 -0
  261. /package/{tools/__tests__/parent-folder.spec.d.ts → models/cron-store.js} +0 -0
  262. /package/{tools/__tests__/read-org-files-recursively.spec.d.ts → models/cron-task.js} +0 -0
  263. /package/{tools/__tests__/split-path.spec.d.ts → models/css-utils.js} +0 -0
  264. /package/{tools → utils}/__tests__/get-file-name.spec.js +0 -0
  265. /package/{tools → utils}/__tests__/get-string-path.spec.js +0 -0
  266. /package/{tools → utils}/__tests__/is-gpg-encrypted.spec.js +0 -0
  267. /package/{tools → utils}/__tests__/is-org-file.spec.js +0 -0
  268. /package/{tools → utils}/__tests__/parent-folder.spec.js +0 -0
  269. /package/{tools → utils}/__tests__/read-org-files-recursively.spec.js +0 -0
  270. /package/{tools → utils}/__tests__/split-path.spec.js +0 -0
  271. /package/{tools → utils}/find-notes-files-diff.d.ts +0 -0
  272. /package/{tools → utils}/get-file-name.d.ts +0 -0
  273. /package/{tools → utils}/get-file-name.js +0 -0
  274. /package/{tools → utils}/get-parent-dir.d.ts +0 -0
  275. /package/{tools → utils}/get-parent-dir.js +0 -0
  276. /package/{tools → utils}/get-string-path.d.ts +0 -0
  277. /package/{tools → utils}/get-string-path.js +0 -0
  278. /package/{tools → utils}/is-gpg-encrypted.d.ts +0 -0
  279. /package/{tools → utils}/is-gpg-encrypted.js +0 -0
  280. /package/{tools → utils}/is-org-file.d.ts +0 -0
  281. /package/{tools → utils}/is-org-file.js +0 -0
  282. /package/{tools → utils}/split-path.d.ts +0 -0
  283. /package/{tools → utils}/split-path.js +0 -0
@@ -1,10 +1,10 @@
1
1
  import { encryptViaKeys, decryptViaKeys, encryptViaPassword, decryptViaPassword, NoKeysProvidedError, NoPasswordProvidedError, IncorrectOrMissingPrivateKeyPasswordError, encrypt, decrypt, armor, unarmor, ImpossibleToDecryptWithProvidedKeysError, } from "../encryption.js";
2
2
  import { test, expect } from 'vitest';
3
3
  import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from "./encryption-keys.js";
4
- import { ModelsPublicNoteEncryptionTypeEnum } from "../../remote-api/index.js";
4
+ import { EncryptionType } from "../../models/encryption.js";
5
5
  test('Should encrypt text as armored message via keys', async () => {
6
6
  const res = await encryptViaKeys({
7
- type: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
7
+ type: EncryptionType.GpgKeys,
8
8
  content: 'Hello world',
9
9
  publicKey: armoredPublicKey,
10
10
  privateKey: armoredPrivateKey,
@@ -15,7 +15,7 @@ test('Should encrypt text as armored message via keys', async () => {
15
15
  });
16
16
  test('Should encrypt text via keys', async () => {
17
17
  const res = await encryptViaKeys({
18
- type: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
18
+ type: EncryptionType.GpgKeys,
19
19
  content: 'Hello world',
20
20
  publicKey: armoredPublicKey,
21
21
  privateKey: armoredPrivateKey,
@@ -66,7 +66,7 @@ YQ==
66
66
  test('Should encrypt via password', async () => {
67
67
  const password = 'test';
68
68
  const res = await encryptViaPassword({
69
- type: ModelsPublicNoteEncryptionTypeEnum.GpgPassword,
69
+ type: EncryptionType.GpgPassword,
70
70
  content: 'Hello world',
71
71
  password,
72
72
  format: 'armored',
@@ -262,7 +262,6 @@ test('Should armor and unarmor encrypted file', async () => {
262
262
  "-----BEGIN PGP MESSAGE-----
263
263
 
264
264
  SGVsbG8gd29ybGQ=
265
- =7asC
266
265
  -----END PGP MESSAGE-----
267
266
  "
268
267
  `);
@@ -1,365 +1,63 @@
1
1
  import { expect, test } from 'vitest';
2
2
  import { decryptNote, encryptNote } from "../note-encryption.js";
3
3
  import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from "./encryption-keys.js";
4
- import { ModelsPublicNoteEncryptionTypeEnum } from "../../remote-api/index.js";
5
- test('Should encrypt note content via password', async () => {
6
- const noteText = `#+ID: qweqwe
7
-
8
- #+TITLE: Hello worlld
9
-
10
- * Hello?`;
11
- const note = {
12
- id: 'id',
13
- meta: {
14
- title: 'My note title',
15
- images: [],
16
- published: false,
17
- description: 'Awesome description',
18
- },
19
- author: {
20
- id: '1',
21
- name: 'John Doe',
22
- email: 'test@mail.com',
23
- },
24
- };
25
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
26
- content: noteText,
27
- type: 'gpgPassword',
28
- password: '123',
29
- format: 'armored',
30
- });
31
- expect(encryptedNoteText.startsWith('-----BEGIN PGP MESSAGE-----')).toBe(true);
32
- expect(encryptedNote).toMatchSnapshot();
33
- });
34
- test('Should encrypt note content via password to binary format', async () => {
35
- const noteText = `#+ID: qweqwe
36
-
37
- #+TITLE: Hello worlld
38
-
39
- * Hello?`;
40
- const note = {
41
- id: 'id',
42
- meta: {
43
- title: 'My note title',
44
- images: [],
45
- published: false,
46
- description: 'Awesome description',
47
- },
48
- author: {
49
- id: '1',
50
- name: 'John Doe',
51
- email: 'test@mail.com',
52
- },
53
- };
54
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
55
- content: noteText,
56
- type: 'gpgPassword',
57
- password: '123',
58
- format: 'binary',
59
- });
60
- expect(encryptedNote).toMatchSnapshot();
61
- expect(encryptedNoteText).toBeInstanceOf(Uint8Array);
62
- });
63
- test('Should decrypt note content via password', async () => {
64
- const noteText = `-----BEGIN PGP MESSAGE-----
65
-
66
- wy4ECQMI/CCaKMJEqy/gyROJeRgW9I738dDFBltFlxIjhxrN7nQ6gkX4GgX6
67
- zt3v0mABvaBJA7corlU8su21TpPApOs/+DMWpVlbI3Zer7QfQK1fSBoSTbCR
68
- 2k3g68Afayke2nLkDNkH62tdOPiTkx7bSlp1zL4uU440IM1g6dC72JkmtoTJ
69
- 5Bjlwt4ZhxFsh+c=
70
- =csID
71
- -----END PGP MESSAGE-----`;
72
- const note = {
73
- id: 'id',
74
- meta: {
75
- title: 'My note title',
76
- images: [],
77
- published: false,
78
- description: 'Awesome description',
79
- },
80
- };
81
- const decryptedNote = await decryptNote(note, {
82
- content: noteText,
83
- type: 'gpgPassword',
84
- password: '123',
85
- });
86
- expect(decryptedNote).toMatchSnapshot();
87
- });
4
+ import { EncryptionType } from "../../models/encryption.js";
5
+ import { faker } from '@faker-js/faker';
6
+ // Helper function to generate a NoteInfo object
7
+ function generateNoteInfo(overrides = {}) {
8
+ return {
9
+ id: faker.string.uuid(),
10
+ meta: {
11
+ title: faker.lorem.sentence(),
12
+ images: faker.helpers.uniqueArray(() => faker.image.url(), 3),
13
+ published: faker.datatype.boolean(),
14
+ description: faker.lorem.paragraph(),
15
+ },
16
+ createdAt: faker.date.past().toISOString(),
17
+ updatedAt: faker.date.recent().toISOString(),
18
+ touchedAt: faker.date.recent().toISOString(),
19
+ deletedAt: faker.datatype.boolean()
20
+ ? faker.date.recent().toISOString()
21
+ : undefined,
22
+ filePath: faker.helpers.uniqueArray(() => faker.system.filePath(), 2),
23
+ isMy: faker.datatype.boolean(),
24
+ author: faker.datatype.boolean()
25
+ ? {
26
+ id: faker.string.uuid(),
27
+ name: faker.person.fullName(),
28
+ email: faker.internet.email(),
29
+ }
30
+ : undefined,
31
+ bookmarked: faker.datatype.boolean(),
32
+ encrypted: faker.datatype.boolean(),
33
+ ...overrides,
34
+ };
35
+ }
88
36
  test('Should encrypt note via keys', async () => {
89
- const noteText = `#+ID: qweqwe
90
- #+TITLE: Hello worlld
91
-
92
- * Hello?`;
93
- const note = {
94
- id: 'id',
95
- meta: {
96
- title: 'My note title for encryption via keys',
97
- images: [],
98
- published: false,
99
- description: 'Awesome description',
100
- },
101
- author: {
102
- id: '1',
103
- name: 'John Doe',
104
- email: 'test@mail.com',
105
- },
106
- };
37
+ const noteText = faker.lorem.paragraphs();
38
+ const note = generateNoteInfo();
107
39
  const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
108
40
  content: noteText,
109
- type: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
110
- publicKey: armoredPublicKey,
111
- privateKey: armoredPrivateKey,
112
- privateKeyPassphrase,
41
+ type: EncryptionType.GpgKeys,
42
+ publicKey: armoredPublicKey, // Используем armoredPublicKey
43
+ privateKey: armoredPrivateKey, // Используем armoredPrivateKey
44
+ privateKeyPassphrase, // Используем privateKeyPassphrase
113
45
  format: 'armored',
114
46
  });
115
47
  expect(encryptedNoteText.startsWith('-----BEGIN PGP MESSAGE-----')).toBe(true);
116
48
  expect(encryptedNote).toMatchSnapshot();
117
49
  });
118
- test('Should decrypt note via provided keys', async () => {
50
+ test('Should decrypt note via keys', async () => {
119
51
  const encryptedNoteText = `-----BEGIN PGP MESSAGE-----
120
-
121
- wcFMA/vryg+TTn0rAQ//TBFRjKmjRQoLhSrgeH+NbsZXbxvo7Ey4k+BQ9XA5
122
- +CMpXH9uFUxsSaI5+McUSEt32VI17HRpXQDCL9nwaWqWOanMaRe0tXXhtox2
123
- gfe2f/6zsge9ux+mXF2BG4z+V5T8XIOrfzxosVprdJHZHM3x7cW5USQ0t2i2
124
- FiOUWxSZO1899J3yICpMvhDXvTLVZuKpSNQho5PyXSeZa83eN+uYkhgt9lsk
125
- 0KW88Nr435S6n6mVw/zpitXIgEKpkqh46mhG+1W3aC0lYx6j9lHm3bjtdb4r
126
- 2mtZbWKwfdBggEy8qEeiUeslvKd6uWtEccomzFgJkaqWVGknLmrBdHfztRIV
127
- fbZhxHz+J3GFOIgXf/5+fv+zg0nTazgz1mDUfnTHw3+qcAyEJ0ADdyg9EZc+
128
- bKbK0GwzMDPQeM+cCRDWUTiIa1ruyEETiwMdhWUDztF8XxY2o8jXPerZ0NhG
129
- R8l+SvAdYQQXPfxEh9lA3thkyz/Vp72pW46lUeJHGSq/fS6KIdLHLP9Z2e1J
130
- aCFpNMgyAN+BaXwnbLZfz6k5hV8awbRScSWQLEg69D9b287SFDPOYW7OZikn
131
- CKXL7xyQ5LrWJZN9Z/UPGjy+PdEw1SBhyluW6DQ+Sz1j4K8USTLqY89EInDl
132
- G7AxHGujR9UkUGyUvvc71XW7jEOogiDgn1ZMoj9Y58LSweUB8vfkY3VF84Fy
133
- zGVvLFWnFbtnWuoQC4OOXv1F6ETdmEsSMEMWKzRLDGPyqNX7FhG3cejlEuiK
134
- EsT5oQhz00RECmnR8mJkGmJhzWmmeoQvaucFqhTOZjvYl9ivuEMBZ2jtkdHn
135
- R6UNcNZRpCbfnl7YoikqbGBgqDFYydFGHXKHDpYhcQYWJsMDUayzUiPtzmaE
136
- tgfTgNNqgPxkLnWA99KYNU8DH+FwgaYBuw9dwdqwcjxSbZjHhCFGUfsqM+ik
137
- O9gcoAwVO1usODlESU7OWuSF2tIv5DBG5rhlSyxBp4d4aWmaumTswAdojy2O
138
- sM70ETbg0mC8niW9lNsgJp55oFmlksvzjUIit5rBEr55rtPcJSgakPpR2yvd
139
- Q4XjybUmV0IdONMhk/OlqaBPtnA0RG+qTcm7oP1qH/m5zRA0ZplVQ5ylkQwr
140
- LwGq5JQpJkgxxgLIrUbbtzYBShXSr5c1XXR0LIRiNgtb6s1s4mt+fbyExdJF
141
- +ceuu+/xYrW/YTuEJpHxLiZ+aNPW5g5Y7Hbqu3hp3UL/kD44cc8JjZh18spX
142
- p/ncojDhF2r2vhR+CndYcMkpGMV+t1pGKC8wlcFc7lb9GJASnqMGvhQmvIaG
143
- gO/x7UjuTZSBW+kITHHZJDqYryKUv1j0CkHxIn9tWsYOpa1giOFtXX5v0AAM
144
- AJR/s/beLlqwCsUdYnw1TkP/0u0ZK3RPio1nJ7S6ckPfsM7DqCWD8ILD8Cdr
145
- cuzQrWaE30t5PXx53xBPO+6t5wKfDL35WHWG1Irmvz9UuT7tDS3IzwtF4ijF
146
- PX6alTbxGnoHgZ4bG4J1wfpTNPppP1gJeVg67VqOypzdZi+SjofMWnFgRFmD
147
- yEN8xpFUs7A9xryVZOosp9Sfe3IbBkO99sAQ7jV4EoMYk3/GKA==
148
- =LjkG
149
- -----END PGP MESSAGE-----`;
150
- const note = {
151
- id: 'id',
152
- meta: {
153
- title: 'My note title for decryption via keys',
154
- images: [],
155
- published: false,
156
- description: 'Awesome description',
157
- },
158
- };
52
+ ${faker.lorem.paragraphs()}
53
+ -----END PGP MESSAGE-----`;
54
+ const note = generateNoteInfo();
159
55
  const decryptedNote = await decryptNote(note, {
160
56
  content: encryptedNoteText,
161
- type: 'gpgKeys',
162
- publicKey: armoredPublicKey,
163
- privateKey: armoredPrivateKey,
164
- privateKeyPassphrase,
165
- });
166
- expect(decryptedNote).toMatchSnapshot();
167
- });
168
- test('Should not encrypt public note', async () => {
169
- const noteText = `#+ID: qweqwe
170
- #+TITLE: Hello worlld
171
-
172
- * Hello?`;
173
- const note = {
174
- id: 'id',
175
- meta: {
176
- title: 'My note title',
177
- images: [],
178
- published: true,
179
- description: 'Awesome description',
180
- },
181
- author: {
182
- id: '1',
183
- name: 'John Doe',
184
- email: 'test@mail.com',
185
- },
186
- };
187
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
188
- content: noteText,
189
- type: 'gpgPassword',
190
- password: '123',
191
- format: 'armored',
192
- });
193
- expect(encryptedNoteText.startsWith('-----BEGIN PGP MESSAGE-----')).toBe(false);
194
- expect(encryptedNote).toMatchSnapshot();
195
- });
196
- test('Should encrypt note with empty encrypted property', async () => {
197
- const noteText = `#+ID: qweqwe
198
- #+TITLE: Hello worlld
199
-
200
- * Hello?`;
201
- const note = {
202
- id: 'id',
203
- meta: {
204
- title: 'My note title',
205
- images: [],
206
- published: false,
207
- description: 'Awesome description',
208
- },
209
- author: {
210
- id: '1',
211
- name: 'John Doe',
212
- email: 'test@mail.com',
213
- },
214
- };
215
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
216
- content: noteText,
217
- type: 'gpgPassword',
218
- password: '123',
219
- format: 'armored',
220
- });
221
- expect(encryptedNoteText.startsWith('-----BEGIN PGP MESSAGE-----')).toBe(true);
222
- expect(encryptedNote).toMatchSnapshot();
223
- });
224
- test('Should not decrypt note without provided encrypted type', async () => {
225
- const noteText = `#+ID: qweqwe
226
- #+TITLE: Hello worlld
227
-
228
- * Hello?`;
229
- const note = {
230
- id: 'id',
231
- meta: {
232
- title: 'My note title',
233
- images: [],
234
- published: false,
235
- description: 'Awesome description',
236
- },
237
- encrypted: undefined,
238
- author: {
239
- id: '1',
240
- name: 'John Doe',
241
- email: 'test@mail.com',
242
- },
243
- };
244
- const decryptedInfo = await decryptNote(note, {
245
- content: noteText,
246
- type: 'gpgPassword',
247
- password: '123',
248
- });
249
- expect(decryptedInfo).toMatchSnapshot();
250
- });
251
- test('Should decrypt note and note meta', async () => {
252
- const meta = {
253
- title: 'My note title',
254
- images: ['./image1.png'],
255
- published: false,
256
- description: 'Awesome description',
257
- fileTags: ['tag1', 'tag2'],
258
- };
259
- const note = {
260
- id: 'id',
261
- meta: { ...meta },
262
- };
263
- const noteText = `#+TITLE: My note title
264
- #+DESCRIPTION: Awesome description
265
- #+PUBLISHED: false
266
- #+FILETAGS: :tag1:tag2:
267
-
268
- [[./image1.png]]
269
-
270
- Hello world`;
271
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
272
- content: noteText,
273
- type: 'gpgPassword',
274
- password: '123',
275
- });
276
- const [decryptedNote, decryptedNoteText] = await decryptNote(encryptedNote, {
277
- content: encryptedNoteText,
278
- type: 'gpgPassword',
279
- password: '123',
280
- });
281
- expect(decryptedNote.meta).toEqual(meta);
282
- expect(decryptedNoteText).toEqual(noteText);
283
- });
284
- test('Should set not encrypted status when params type does not provided', async () => {
285
- const note = {
286
- id: 'id',
287
- meta: {
288
- title: 'My note title for decryption via keys',
289
- images: [],
290
- published: false,
291
- description: 'Awesome description',
292
- },
293
- };
294
- const noteText = `-----BEGIN PGP MESSAGE-----
295
-
296
- wcFMA/vryg+TTn0rAQ//TBFRjKmjRQoLhSrgeH+NbsZXbxvo7Ey4k+BQ9XA5
297
- +CMpXH9uFUxsSaI5+McUSEt32VI17HRpXQDCL9nwaWqWOanMaRe0tXXhtox2
298
- gfe2f/6zsge9ux+mXF2BG4z+V5T8XIOrfzxosVprdJHZHM3x7cW5USQ0t2i2
299
- FiOUWxSZO1899J3yICpMvhDXvTLVZuKpSNQho5PyXSeZa83eN+uYkhgt9lsk
300
- 0KW88Nr435S6n6mVw/zpitXIgEKpkqh46mhG+1W3aC0lYx6j9lHm3bjtdb4r
301
- 2mtZbWKwfdBggEy8qEeiUeslvKd6uWtEccomzFgJkaqWVGknLmrBdHfztRIV
302
- fbZhxHz+J3GFOIgXf/5+fv+zg0nTazgz1mDUfnTHw3+qcAyEJ0ADdyg9EZc+
303
- bKbK0GwzMDPQeM+cCRDWUTiIa1ruyEETiwMdhWUDztF8XxY2o8jXPerZ0NhG
304
- R8l+SvAdYQQXPfxEh9lA3thkyz/Vp72pW46lUeJHGSq/fS6KIdLHLP9Z2e1J
305
- aCFpNMgyAN+BaXwnbLZfz6k5hV8awbRScSWQLEg69D9b287SFDPOYW7OZikn
306
- CKXL7xyQ5LrWJZN9Z/UPGjy+PdEw1SBhyluW6DQ+Sz1j4K8USTLqY89EInDl
307
- G7AxHGujR9UkUGyUvvc71XW7jEOogiDgn1ZMoj9Y58LSweUB8vfkY3VF84Fy
308
- zGVvLFWnFbtnWuoQC4OOXv1F6ETdmEsSMEMWKzRLDGPyqNX7FhG3cejlEuiK
309
- EsT5oQhz00RECmnR8mJkGmJhzWmmeoQvaucFqhTOZjvYl9ivuEMBZ2jtkdHn
310
- R6UNcNZRpCbfnl7YoikqbGBgqDFYydFGHXKHDpYhcQYWJsMDUayzUiPtzmaE
311
- tgfTgNNqgPxkLnWA99KYNU8DH+FwgaYBuw9dwdqwcjxSbZjHhCFGUfsqM+ik
312
- O9gcoAwVO1usODlESU7OWuSF2tIv5DBG5rhlSyxBp4d4aWmaumTswAdojy2O
313
- sM70ETbg0mC8niW9lNsgJp55oFmlksvzjUIit5rBEr55rtPcJSgakPpR2yvd
314
- Q4XjybUmV0IdONMhk/OlqaBPtnA0RG+qTcm7oP1qH/m5zRA0ZplVQ5ylkQwr
315
- LwGq5JQpJkgxxgLIrUbbtzYBShXSr5c1XXR0LIRiNgtb6s1s4mt+fbyExdJF
316
- +ceuu+/xYrW/YTuEJpHxLiZ+aNPW5g5Y7Hbqu3hp3UL/kD44cc8JjZh18spX
317
- p/ncojDhF2r2vhR+CndYcMkpGMV+t1pGKC8wlcFc7lb9GJASnqMGvhQmvIaG
318
- gO/x7UjuTZSBW+kITHHZJDqYryKUv1j0CkHxIn9tWsYOpa1giOFtXX5v0AAM
319
- AJR/s/beLlqwCsUdYnw1TkP/0u0ZK3RPio1nJ7S6ckPfsM7DqCWD8ILD8Cdr
320
- cuzQrWaE30t5PXx53xBPO+6t5wKfDL35WHWG1Irmvz9UuT7tDS3IzwtF4ijF
321
- PX6alTbxGnoHgZ4bG4J1wfpTNPppP1gJeVg67VqOypzdZi+SjofMWnFgRFmD
322
- yEN8xpFUs7A9xryVZOosp9Sfe3IbBkO99sAQ7jV4EoMYk3/GKA==
323
- =LjkG
324
- -----END PGP MESSAGE-----`;
325
- const decryptedNote = await decryptNote(note, {
326
- content: noteText,
327
- type: 'disabled',
57
+ type: EncryptionType.GpgKeys,
58
+ publicKey: armoredPublicKey, // Используем armoredPublicKey
59
+ privateKey: armoredPrivateKey, // Используем armoredPrivateKey
60
+ privateKeyPassphrase, // Используем privateKeyPassphrase
328
61
  });
329
62
  expect(decryptedNote).toMatchSnapshot();
330
63
  });
331
- test('Should encrypt note to binary format', async () => {
332
- const noteText = `#+ID: qweqwe
333
- #+TITLE: Hello worlld
334
-
335
- * Hello?`;
336
- const note = {
337
- id: 'id',
338
- meta: {
339
- title: 'My note title',
340
- images: [],
341
- published: false,
342
- description: 'Awesome description',
343
- },
344
- author: {
345
- id: '1',
346
- name: 'John Doe',
347
- email: 'test@mail.com',
348
- },
349
- };
350
- const [encryptedNote, encryptedNoteText] = await encryptNote(note, {
351
- content: noteText,
352
- type: 'gpgPassword',
353
- password: '123',
354
- format: 'binary',
355
- });
356
- expect(encryptedNoteText).toBeInstanceOf(Uint8Array);
357
- expect(encryptedNote).toMatchSnapshot();
358
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
359
- const [_, decryptedNoteText] = await decryptNote(encryptedNote, {
360
- content: encryptedNoteText,
361
- type: 'gpgPassword',
362
- password: '123',
363
- });
364
- expect(decryptedNoteText).toEqual(noteText);
365
- });
@@ -3,19 +3,24 @@ import { OrgNoteEncryption, OrgNotePasswordEncryption, WithDecryptionContent } f
3
3
  import { OrgNoteGpgEncryption, WithEncryptionContent } from '../models/index.js';
4
4
  import { enums } from 'openpgp';
5
5
  export declare class IncorrectOrMissingPrivateKeyPasswordError extends Error {
6
+ constructor(message?: string);
6
7
  }
7
8
  export declare class ImpossibleToDecryptWithProvidedKeysError extends Error {
9
+ constructor(message?: string);
8
10
  }
9
11
  export declare class IncorrectEncryptionPasswordError extends Error {
12
+ constructor(message?: string);
10
13
  }
11
14
  export declare class NoKeysProvidedError extends Error {
15
+ constructor(message?: string);
12
16
  }
13
17
  export declare class NoPasswordProvidedError extends Error {
18
+ constructor(message?: string);
14
19
  }
15
- export declare const encryptViaKeys: <T extends WithEncryptionContent<OrgNoteGpgEncryption>>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
16
- export declare const encryptViaPassword: <T extends WithEncryptionContent<OrgNotePasswordEncryption>>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
17
- export declare const decryptViaPassword: <T extends Omit<WithDecryptionContent<OrgNotePasswordEncryption>, "type">>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
18
- export declare const decryptViaKeys: <T extends Omit<WithDecryptionContent<OrgNoteGpgEncryption>, "type">>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
20
+ export declare const encryptViaKeys: <T extends WithEncryptionContent<OrgNoteGpgEncryption>>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array<ArrayBufferLike> : string>;
21
+ export declare const encryptViaPassword: <T extends WithEncryptionContent<OrgNotePasswordEncryption>>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array<ArrayBufferLike> : string>;
22
+ export declare const decryptViaPassword: <T extends Omit<WithDecryptionContent<OrgNotePasswordEncryption>, "type">>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array<ArrayBufferLike> : string>;
23
+ export declare const decryptViaKeys: <T extends Omit<WithDecryptionContent<OrgNoteGpgEncryption>, "type">>(args_0: T) => Promise<T["format"] extends "binary" ? Uint8Array<ArrayBufferLike> : string>;
19
24
  export declare const encrypt: <T extends WithEncryptionContent<OrgNoteEncryption>>(encryptionParams: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
20
25
  export declare const decrypt: <T extends WithDecryptionContent<OrgNoteEncryption>>(decryptionParams: T) => Promise<T["format"] extends "binary" ? Uint8Array : string>;
21
26
  export declare function _encryptViaKeys<T extends WithEncryptionContent<OrgNoteGpgEncryption>>({ content, publicKey: armoredPublicKey, privateKey: armoredPrivateKey, privateKeyPassphrase, format, }: T): Promise<T['format'] extends 'binary' ? Uint8Array : string>;
@@ -1,15 +1,35 @@
1
1
  import { createMessage, decrypt as _decrypt, decryptKey, encrypt as _encrypt, readKey, readMessage, readPrivateKey, } from 'openpgp';
2
- import { ModelsPublicNoteEncryptionTypeEnum } from "../remote-api/index.js";
2
+ import { EncryptionType, } from "../models/encryption.js";
3
3
  import { armor as _armor, unarmor as _unarmor, enums } from 'openpgp';
4
4
  export class IncorrectOrMissingPrivateKeyPasswordError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'IncorrectOrMissingPrivateKeyPasswordError';
8
+ }
5
9
  }
6
10
  export class ImpossibleToDecryptWithProvidedKeysError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = 'ImpossibleToDecryptWithProvidedKeysError';
14
+ }
7
15
  }
8
16
  export class IncorrectEncryptionPasswordError extends Error {
17
+ constructor(message) {
18
+ super(message);
19
+ this.name = 'IncorrectEncryptionPasswordError';
20
+ }
9
21
  }
10
22
  export class NoKeysProvidedError extends Error {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = 'NoKeysProvidedError';
26
+ }
11
27
  }
12
28
  export class NoPasswordProvidedError extends Error {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'NoPasswordProvidedError';
32
+ }
13
33
  }
14
34
  const noPrivateKeyPassphraseProvidedErrorMsg = 'Error: Signing key is not decrypted.';
15
35
  const incorrectPrivateKeyPassphraseErrorMsg = 'Error decrypting private key: Incorrect key passphrase';
@@ -26,24 +46,24 @@ export const decryptViaPassword = withCustomErrors(_decryptViaPassword);
26
46
  export const decryptViaKeys = withCustomErrors(_decryptViaKeys);
27
47
  export const encrypt = async (encryptionParams) => {
28
48
  if (!encryptionParams.type ||
29
- encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled) {
49
+ encryptionParams.type === EncryptionType.Disabled) {
30
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
51
  return encryptionParams.content;
32
52
  }
33
53
  const res = (encryptionParams.type ===
34
- ModelsPublicNoteEncryptionTypeEnum.GpgKeys
54
+ EncryptionType.GpgKeys
35
55
  ? await encryptViaKeys(encryptionParams)
36
56
  : await encryptViaPassword(encryptionParams));
37
57
  return res;
38
58
  };
39
59
  export const decrypt = async (decryptionParams) => {
40
60
  if (!decryptionParams.type ||
41
- decryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled) {
61
+ decryptionParams.type === EncryptionType.Disabled) {
42
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
63
  return decryptionParams.content;
44
64
  }
45
65
  const decryptedNote = (decryptionParams.type ===
46
- ModelsPublicNoteEncryptionTypeEnum.GpgKeys
66
+ EncryptionType.GpgKeys
47
67
  ? await decryptViaKeys(decryptionParams)
48
68
  : await decryptViaPassword(decryptionParams));
49
69
  return decryptedNote;
@@ -1,7 +1,7 @@
1
1
  import { OrgNoteEncryption, WithEncryptionContent, WithNoteDecryptionContent } from '../models/encryption.js';
2
2
  export interface AbstractEncryptedNote {
3
3
  encrypted?: boolean;
4
- meta: {
4
+ meta?: {
5
5
  [key: string]: any;
6
6
  published?: boolean;
7
7
  };
@@ -1,25 +1,25 @@
1
- import { ModelsPublicNoteEncryptionTypeEnum } from "../remote-api/index.js";
2
1
  import { decrypt, encrypt } from "./encryption.js";
2
+ import { EncryptionType } from "../models/encryption.js";
3
3
  import { parse, withMetaInfo } from 'org-mode-ast';
4
4
  import { isGpgEncrypted } from '../index.js';
5
5
  // TODO: master change signature for encrypt notes without content
6
6
  export async function encryptNote(note, encryptionParams) {
7
7
  note.encrypted = false;
8
8
  if (!encryptionParams.type ||
9
- encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled ||
10
- note.meta.published) {
9
+ encryptionParams.type === EncryptionType.Disabled ||
10
+ note.meta?.published) {
11
11
  return [note, encryptionParams.content];
12
12
  }
13
- note.meta = { id: note.meta.id, published: note.meta.published };
13
+ note.meta = { id: note.meta?.id, published: note.meta?.published };
14
14
  const encryptedContent = await encrypt(encryptionParams);
15
15
  const encryptedNote = { ...note, encrypted: true };
16
16
  return [encryptedNote, encryptedContent];
17
17
  }
18
18
  export async function decryptNote(note, encryptionParams) {
19
19
  const isContentEncrypted = isGpgEncrypted(encryptionParams.content);
20
- if (note.meta.published ||
20
+ if (note.meta?.published ||
21
21
  !encryptionParams.type ||
22
- encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled ||
22
+ encryptionParams.type === EncryptionType.Disabled ||
23
23
  !isContentEncrypted) {
24
24
  note.encrypted = isContentEncrypted;
25
25
  return [note, encryptionParams.content];
package/files-api.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Axios } from 'axios';
3
2
  import { Stream } from 'stream';
4
3
  export declare const initFilesApi: (axiosInstance: Axios) => {
package/index.d.ts CHANGED
@@ -2,8 +2,11 @@ export * from './api.js';
2
2
  export * from './models/index.js';
3
3
  import type * as ast from 'org-mode-ast';
4
4
  export * from './encryption/index.js';
5
- export * from './tools/index.js';
5
+ export * from './utils/index.js';
6
6
  export * from './files-api.js';
7
7
  export * from './mappers/index.js';
8
8
  export * from './constants/index.js';
9
+ export * from './utils/with-root.js';
10
+ export * from './sync/index.js';
9
11
  export { ast };
12
+ export * from './websocket/client.js';
package/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  export * from "./api.js";
2
2
  export * from "./models/index.js";
3
3
  export * from "./encryption/index.js";
4
- export * from "./tools/index.js";
4
+ export * from "./utils/index.js";
5
5
  export * from "./files-api.js";
6
6
  export * from "./mappers/index.js";
7
7
  export * from "./constants/index.js";
8
+ export * from "./utils/with-root.js";
9
+ export * from "./sync/index.js";
10
+ export * from "./websocket/client.js";
@@ -1,3 +1,3 @@
1
1
  import { OrgNode } from 'org-mode-ast';
2
- import { FileInfo, Note } from "../models/index.js";
3
- export declare function orgnodeToNote(orgnode: OrgNode, fileInfo: FileInfo): Note;
2
+ import { DiskFile, NoteInfo } from "../models/index.js";
3
+ export declare function orgnodeToNoteInfo(orgnode: OrgNode, fileInfo: DiskFile, isMy?: boolean): NoteInfo;
@@ -1,7 +1,8 @@
1
- import { splitPath } from "../tools/index.js";
2
- export function orgnodeToNote(orgnode, fileInfo) {
1
+ import { splitPath } from "../utils/index.js";
2
+ export function orgnodeToNoteInfo(orgnode, fileInfo, isMy) {
3
3
  return {
4
4
  id: orgnode.meta.id,
5
+ isMy,
5
6
  meta: orgnode.meta,
6
7
  filePath: splitPath(fileInfo.path),
7
8
  touchedAt: fileInfo.atime && new Date(fileInfo.atime).toISOString(),
@@ -1,10 +1,10 @@
1
1
  import type { Ref } from 'vue';
2
- import { Store } from './store.js';
2
+ import { StoreDefinition } from './store.js';
3
3
  import { PersonalInfo } from './user.js';
4
4
  import { OAuthProvider } from './oauth-provider.js';
5
5
  export interface AuthStore {
6
6
  token: Ref<string>;
7
- user: Ref<PersonalInfo>;
7
+ user: Ref<PersonalInfo | null>;
8
8
  provider: Ref<OAuthProvider>;
9
9
  auth: (params: {
10
10
  provider: string;
@@ -18,4 +18,4 @@ export interface AuthStore {
18
18
  subscribe: (token: string, email?: string) => Promise<void>;
19
19
  removeUserAccount: () => Promise<void>;
20
20
  }
21
- export type AuthStoreDefinition = Store<AuthStore>;
21
+ export type AuthStoreDefinition = StoreDefinition<AuthStore>;