orgnote-api 0.17.0 → 0.17.2
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/api.d.ts +112 -0
- package/dist/api.js +1 -0
- package/dist/encryption/__tests__/encryption-keys.d.ts +3 -0
- package/{encryption/__tests__/encryption-keys.ts → dist/encryption/__tests__/encryption-keys.js} +0 -2
- package/dist/encryption/__tests__/encryption.spec.d.ts +1 -0
- package/dist/encryption/__tests__/encryption.spec.js +287 -0
- package/dist/encryption/__tests__/note-encryption.spec.d.ts +1 -0
- package/dist/encryption/__tests__/note-encryption.spec.js +364 -0
- package/dist/encryption/encryption.d.ts +27 -0
- package/dist/encryption/encryption.js +156 -0
- package/dist/encryption/index.js +2 -0
- package/dist/encryption/note-encryption.d.ts +12 -0
- package/dist/encryption/note-encryption.js +42 -0
- package/dist/files-api.d.ts +7 -0
- package/dist/files-api.js +22 -0
- package/dist/index.js +5 -0
- package/dist/models/command.d.ts +29 -0
- package/dist/models/command.js +1 -0
- package/dist/models/completion.d.ts +22 -0
- package/dist/models/completion.js +1 -0
- package/dist/models/default-commands.d.ts +30 -0
- package/dist/models/default-commands.js +41 -0
- package/dist/models/editor.d.ts +23 -0
- package/dist/models/editor.js +1 -0
- package/dist/models/encryption.d.ts +31 -0
- package/dist/models/encryption.js +1 -0
- package/dist/models/extension.d.ts +34 -0
- package/dist/models/extension.js +1 -0
- package/dist/models/file-system.d.ts +23 -0
- package/dist/models/file-system.js +1 -0
- package/{models/index.ts → dist/models/index.d.ts} +2 -0
- package/dist/models/index.js +13 -0
- package/dist/models/modal.d.ts +10 -0
- package/dist/models/modal.js +1 -0
- package/dist/models/note.d.ts +23 -0
- package/dist/models/note.js +1 -0
- package/dist/models/sync.d.ts +34 -0
- package/dist/models/sync.js +1 -0
- package/dist/models/theme-variables.d.ts +192 -0
- package/dist/models/theme-variables.js +194 -0
- package/{models/vue-component.ts → dist/models/vue-component.d.ts} +1 -1
- package/dist/models/vue-component.js +1 -0
- package/dist/models/widget-type.d.ts +5 -0
- package/dist/models/widget-type.js +6 -0
- package/dist/models/widget.d.ts +51 -0
- package/dist/models/widget.js +1 -0
- package/dist/remote-api/api.d.ts +1525 -0
- package/{remote-api/api.ts → dist/remote-api/api.js} +246 -1149
- package/dist/remote-api/base.d.ts +66 -0
- package/{remote-api/base.ts → dist/remote-api/base.js} +13 -36
- package/dist/remote-api/common.d.ts +65 -0
- package/{remote-api/common.ts → dist/remote-api/common.js} +31 -48
- package/{remote-api/configuration.ts → dist/remote-api/configuration.d.ts} +3 -22
- package/dist/remote-api/configuration.js +95 -0
- package/dist/remote-api/index.d.ts +13 -0
- package/{remote-api/index.ts → dist/remote-api/index.js} +0 -3
- package/dist/tools/__tests__/find-files-diff.spec.d.ts +1 -0
- package/dist/tools/__tests__/find-files-diff.spec.js +110 -0
- package/dist/tools/__tests__/find-note-files-diff.spec.d.ts +1 -0
- package/dist/tools/__tests__/find-note-files-diff.spec.js +168 -0
- package/dist/tools/__tests__/get-file-name.spec.d.ts +1 -0
- package/dist/tools/__tests__/get-file-name.spec.js +14 -0
- package/dist/tools/__tests__/get-string-path.spec.d.ts +1 -0
- package/dist/tools/__tests__/get-string-path.spec.js +27 -0
- package/dist/tools/__tests__/is-gpg-encrypted.spec.d.ts +1 -0
- package/{tools/__tests__/is-gpg-encrypted.spec.ts → dist/tools/__tests__/is-gpg-encrypted.spec.js} +4 -8
- package/dist/tools/__tests__/is-org-file.spec.d.ts +1 -0
- package/dist/tools/__tests__/is-org-file.spec.js +54 -0
- package/dist/tools/__tests__/join.spec.d.ts +1 -0
- package/dist/tools/__tests__/join.spec.js +14 -0
- package/dist/tools/__tests__/read-org-files-recursively.spec.d.ts +1 -0
- package/dist/tools/__tests__/read-org-files-recursively.spec.js +51 -0
- package/dist/tools/extend-notes-files-diff.d.ts +3 -0
- package/dist/tools/extend-notes-files-diff.js +21 -0
- package/dist/tools/find-notes-files-diff.d.ts +5 -0
- package/dist/tools/find-notes-files-diff.js +108 -0
- package/dist/tools/get-file-name.d.ts +2 -0
- package/dist/tools/get-file-name.js +6 -0
- package/dist/tools/get-string-path.d.ts +1 -0
- package/dist/tools/get-string-path.js +6 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/is-gpg-encrypted.d.ts +1 -0
- package/dist/tools/is-gpg-encrypted.js +6 -0
- package/dist/tools/is-org-file.d.ts +2 -0
- package/dist/tools/is-org-file.js +4 -0
- package/dist/tools/join.d.ts +1 -0
- package/dist/tools/join.js +3 -0
- package/dist/tools/mock-server.d.ts +1 -0
- package/dist/tools/mock-server.js +12 -0
- package/package.json +6 -14
- package/api.ts +0 -123
- package/encryption/__tests__/__snapshots__/note-encryption.spec.ts.snap +0 -231
- package/encryption/__tests__/encryption.spec.ts +0 -352
- package/encryption/__tests__/note-encryption.spec.ts +0 -425
- package/encryption/encryption.ts +0 -264
- package/encryption/note-encryption.ts +0 -77
- package/files-api.ts +0 -25
- package/models/command.ts +0 -45
- package/models/completion.ts +0 -30
- package/models/default-commands.ts +0 -44
- package/models/editor.ts +0 -27
- package/models/encryption.ts +0 -50
- package/models/extension.ts +0 -45
- package/models/modal.ts +0 -12
- package/models/note.ts +0 -26
- package/models/theme-variables.ts +0 -194
- package/models/widget-type.ts +0 -5
- package/models/widget.ts +0 -59
- package/remote-api/.gitignore +0 -4
- package/remote-api/.npmignore +0 -1
- package/remote-api/.openapi-generator/FILES +0 -8
- package/remote-api/.openapi-generator/VERSION +0 -1
- package/remote-api/.openapi-generator-ignore +0 -23
- package/remote-api/git_push.sh +0 -57
- package/tools/__tests__/find-notes-files-diff.spec.ts +0 -176
- package/tools/__tests__/get-string-path.spec.ts +0 -32
- package/tools/__tests__/is-org-file.spec.ts +0 -62
- package/tools/find-notes-files-diff.ts +0 -48
- package/tools/get-string-path.ts +0 -6
- package/tools/index.ts +0 -3
- package/tools/is-gpg-encrypted.ts +0 -6
- package/tools/is-org-file.ts +0 -7
- package/tools/mock-server.ts +0 -16
- /package/{encryption/index.ts → dist/encryption/index.d.ts} +0 -0
- /package/{index.ts → dist/index.d.ts} +0 -0
package/api.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Command,
|
|
3
|
-
CSSVariable,
|
|
4
|
-
ThemeVariable,
|
|
5
|
-
Note,
|
|
6
|
-
InlineEmbeddedWidget,
|
|
7
|
-
MultilineEmbeddedWidget,
|
|
8
|
-
OrgLineClass,
|
|
9
|
-
WidgetBuilder,
|
|
10
|
-
CommandPreview,
|
|
11
|
-
OrgNoteEncryption,
|
|
12
|
-
Modal,
|
|
13
|
-
} from './models';
|
|
14
|
-
import type { NavigationFailure } from 'vue-router';
|
|
15
|
-
import { WidgetType } from './models/widget-type';
|
|
16
|
-
import type { Component } from 'vue';
|
|
17
|
-
import { NodeType } from 'org-mode-ast';
|
|
18
|
-
import { EditorExtension } from './models/editor';
|
|
19
|
-
|
|
20
|
-
type WithNodeType<T> = { nodeType: NodeType } & T;
|
|
21
|
-
|
|
22
|
-
export type WidgetMeta =
|
|
23
|
-
| ({ type: WidgetType.Inline } & WithNodeType<InlineEmbeddedWidget>)
|
|
24
|
-
| ({ type: WidgetType.Multiline } & WithNodeType<MultilineEmbeddedWidget>)
|
|
25
|
-
| ({ type: WidgetType.LineClass } & WithNodeType<OrgLineClass>);
|
|
26
|
-
|
|
27
|
-
export interface OrgNoteApi {
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
getExtension?<T>(config: string): T;
|
|
30
|
-
|
|
31
|
-
system: {
|
|
32
|
-
reload: (params?: { verbose: boolean }) => Promise<void>;
|
|
33
|
-
setNewFilesAvailable: (status?: boolean) => void;
|
|
34
|
-
};
|
|
35
|
-
navigation: {
|
|
36
|
-
openNote: (id: string) => Promise<void | NavigationFailure>;
|
|
37
|
-
editNote: (id: string) => Promise<void | NavigationFailure>;
|
|
38
|
-
};
|
|
39
|
-
ui: {
|
|
40
|
-
applyTheme: (theme: { [key in ThemeVariable]: string | number }) => void;
|
|
41
|
-
applyCssVariables: (styles: {
|
|
42
|
-
[key in CSSVariable]: string | number;
|
|
43
|
-
}) => void;
|
|
44
|
-
setThemeByMode: (themeName?: string) => void;
|
|
45
|
-
setDarkTheme: (themeName?: string) => void;
|
|
46
|
-
setLightTheme: (themeName?: string) => void;
|
|
47
|
-
applyStyles: (scopeName: string, styles: string) => void;
|
|
48
|
-
removeStyles: (scopeName: string) => void;
|
|
49
|
-
resetTheme: () => void;
|
|
50
|
-
openModal: (modal: Modal) => void;
|
|
51
|
-
};
|
|
52
|
-
interaction: {
|
|
53
|
-
confirm: (title: string, message: string) => Promise<boolean>;
|
|
54
|
-
};
|
|
55
|
-
currentNote: {
|
|
56
|
-
get: () => Note;
|
|
57
|
-
};
|
|
58
|
-
editor: {
|
|
59
|
-
extensions: {
|
|
60
|
-
add: (...extension: EditorExtension[]) => void;
|
|
61
|
-
remove: (...extension: EditorExtension[]) => void;
|
|
62
|
-
};
|
|
63
|
-
widgets: {
|
|
64
|
-
add: (...widgetMeta: WidgetMeta[]) => void;
|
|
65
|
-
createWidgetBuilder: (
|
|
66
|
-
cmp: Component,
|
|
67
|
-
props?: { [key: string]: unknown }
|
|
68
|
-
) => WidgetBuilder;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
// Available only on mobile apps
|
|
72
|
-
fileSystem: {
|
|
73
|
-
readPath: () => Promise<string>;
|
|
74
|
-
};
|
|
75
|
-
commands: {
|
|
76
|
-
add(...commands: Command[]): void;
|
|
77
|
-
remove(...commands: Command[]): void;
|
|
78
|
-
get(name: string): Command;
|
|
79
|
-
getAll(): Command[];
|
|
80
|
-
addCommandToSidebar(...commands: CommandPreview[]): void;
|
|
81
|
-
removeCommandFromSidebar(...commands: CommandPreview[]): void;
|
|
82
|
-
addCommandToEditorPanel(...commands: CommandPreview[]): void;
|
|
83
|
-
removeCommandFromEditorPanel(...commands: CommandPreview[]): void;
|
|
84
|
-
};
|
|
85
|
-
configuration: () => OrgNoteConfig;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// TODO: master move model to the backend service
|
|
89
|
-
export interface OrgNoteConfig {
|
|
90
|
-
editor: {
|
|
91
|
-
showSpecialSymbols: boolean;
|
|
92
|
-
showPropertyDrawer: boolean;
|
|
93
|
-
};
|
|
94
|
-
developer: {
|
|
95
|
-
developerMode: boolean;
|
|
96
|
-
maximumLogsCount: number;
|
|
97
|
-
};
|
|
98
|
-
completion: {
|
|
99
|
-
showGroup: boolean;
|
|
100
|
-
defaultCompletionLimit: number;
|
|
101
|
-
};
|
|
102
|
-
system: {
|
|
103
|
-
language: string;
|
|
104
|
-
};
|
|
105
|
-
synchronization: {
|
|
106
|
-
type: 'none' | 'api';
|
|
107
|
-
};
|
|
108
|
-
vault: {
|
|
109
|
-
/* File system available only for mobile devices */
|
|
110
|
-
type: 'inmemory' | 'filesystem';
|
|
111
|
-
path?: string;
|
|
112
|
-
};
|
|
113
|
-
ui: {
|
|
114
|
-
showUserProfiles: boolean;
|
|
115
|
-
theme: 'light' | 'dark' | 'auto';
|
|
116
|
-
darkThemeName?: string;
|
|
117
|
-
lightThemeName?: string;
|
|
118
|
-
};
|
|
119
|
-
extensions: {
|
|
120
|
-
sources: string[];
|
|
121
|
-
};
|
|
122
|
-
encryption: OrgNoteEncryption;
|
|
123
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Should decrypt note content via password 1`] = `
|
|
4
|
-
[
|
|
5
|
-
{
|
|
6
|
-
"encrypted": false,
|
|
7
|
-
"id": "id",
|
|
8
|
-
"meta": {
|
|
9
|
-
"headings": [
|
|
10
|
-
{
|
|
11
|
-
"level": 1,
|
|
12
|
-
"title": "Hello?",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
"id": "qweqwe",
|
|
16
|
-
"title": "Hello worlld",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
"#+ID: qweqwe
|
|
20
|
-
#+TITLE: Hello worlld
|
|
21
|
-
|
|
22
|
-
* Hello?",
|
|
23
|
-
]
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
exports[`Should decrypt note via provided keys 1`] = `
|
|
27
|
-
[
|
|
28
|
-
{
|
|
29
|
-
"encrypted": false,
|
|
30
|
-
"id": "id",
|
|
31
|
-
"meta": {
|
|
32
|
-
"headings": [
|
|
33
|
-
{
|
|
34
|
-
"level": 1,
|
|
35
|
-
"title": "Hello?",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
"id": "qweqwe",
|
|
39
|
-
"title": "Hello worlld",
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
"#+ID: qweqwe
|
|
43
|
-
#+TITLE: Hello worlld
|
|
44
|
-
|
|
45
|
-
* Hello?",
|
|
46
|
-
]
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
exports[`Should encrypt note and decrypt it into binary format 1`] = `
|
|
50
|
-
{
|
|
51
|
-
"author": {
|
|
52
|
-
"email": "test@mail.com",
|
|
53
|
-
"id": "1",
|
|
54
|
-
"name": "John Doe",
|
|
55
|
-
},
|
|
56
|
-
"encrypted": true,
|
|
57
|
-
"id": "id",
|
|
58
|
-
"meta": {
|
|
59
|
-
"id": undefined,
|
|
60
|
-
"published": false,
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
exports[`Should encrypt note content via password 1`] = `
|
|
66
|
-
{
|
|
67
|
-
"author": {
|
|
68
|
-
"email": "test@mail.com",
|
|
69
|
-
"id": "1",
|
|
70
|
-
"name": "John Doe",
|
|
71
|
-
},
|
|
72
|
-
"encrypted": true,
|
|
73
|
-
"id": "id",
|
|
74
|
-
"meta": {
|
|
75
|
-
"id": undefined,
|
|
76
|
-
"published": false,
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
exports[`Should encrypt note content via password to binary format 1`] = `
|
|
82
|
-
{
|
|
83
|
-
"author": {
|
|
84
|
-
"email": "test@mail.com",
|
|
85
|
-
"id": "1",
|
|
86
|
-
"name": "John Doe",
|
|
87
|
-
},
|
|
88
|
-
"encrypted": true,
|
|
89
|
-
"id": "id",
|
|
90
|
-
"meta": {
|
|
91
|
-
"id": undefined,
|
|
92
|
-
"published": false,
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
exports[`Should encrypt note to binary format 1`] = `
|
|
98
|
-
{
|
|
99
|
-
"author": {
|
|
100
|
-
"email": "test@mail.com",
|
|
101
|
-
"id": "1",
|
|
102
|
-
"name": "John Doe",
|
|
103
|
-
},
|
|
104
|
-
"encrypted": true,
|
|
105
|
-
"id": "id",
|
|
106
|
-
"meta": {
|
|
107
|
-
"id": undefined,
|
|
108
|
-
"published": false,
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
112
|
-
|
|
113
|
-
exports[`Should encrypt note via keys 1`] = `
|
|
114
|
-
{
|
|
115
|
-
"author": {
|
|
116
|
-
"email": "test@mail.com",
|
|
117
|
-
"id": "1",
|
|
118
|
-
"name": "John Doe",
|
|
119
|
-
},
|
|
120
|
-
"encrypted": true,
|
|
121
|
-
"id": "id",
|
|
122
|
-
"meta": {
|
|
123
|
-
"id": undefined,
|
|
124
|
-
"published": false,
|
|
125
|
-
},
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
|
|
129
|
-
exports[`Should encrypt note with empty encrypted property 1`] = `
|
|
130
|
-
{
|
|
131
|
-
"author": {
|
|
132
|
-
"email": "test@mail.com",
|
|
133
|
-
"id": "1",
|
|
134
|
-
"name": "John Doe",
|
|
135
|
-
},
|
|
136
|
-
"encrypted": true,
|
|
137
|
-
"id": "id",
|
|
138
|
-
"meta": {
|
|
139
|
-
"id": undefined,
|
|
140
|
-
"published": false,
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
|
|
145
|
-
exports[`Should not decrypt note without provided encrypted type 1`] = `
|
|
146
|
-
[
|
|
147
|
-
{
|
|
148
|
-
"author": {
|
|
149
|
-
"email": "test@mail.com",
|
|
150
|
-
"id": "1",
|
|
151
|
-
"name": "John Doe",
|
|
152
|
-
},
|
|
153
|
-
"encrypted": false,
|
|
154
|
-
"id": "id",
|
|
155
|
-
"meta": {
|
|
156
|
-
"description": "Awesome description",
|
|
157
|
-
"images": [],
|
|
158
|
-
"published": false,
|
|
159
|
-
"title": "My note title",
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
"#+ID: qweqwe
|
|
163
|
-
#+TITLE: Hello worlld
|
|
164
|
-
|
|
165
|
-
* Hello?",
|
|
166
|
-
]
|
|
167
|
-
`;
|
|
168
|
-
|
|
169
|
-
exports[`Should not encrypt public note 1`] = `
|
|
170
|
-
{
|
|
171
|
-
"author": {
|
|
172
|
-
"email": "test@mail.com",
|
|
173
|
-
"id": "1",
|
|
174
|
-
"name": "John Doe",
|
|
175
|
-
},
|
|
176
|
-
"encrypted": false,
|
|
177
|
-
"id": "id",
|
|
178
|
-
"meta": {
|
|
179
|
-
"description": "Awesome description",
|
|
180
|
-
"images": [],
|
|
181
|
-
"published": true,
|
|
182
|
-
"title": "My note title",
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
`;
|
|
186
|
-
|
|
187
|
-
exports[`Should set not encrypted status when params type does not provided 1`] = `
|
|
188
|
-
[
|
|
189
|
-
{
|
|
190
|
-
"encrypted": true,
|
|
191
|
-
"id": "id",
|
|
192
|
-
"meta": {
|
|
193
|
-
"description": "Awesome description",
|
|
194
|
-
"images": [],
|
|
195
|
-
"published": false,
|
|
196
|
-
"title": "My note title for decryption via keys",
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
"-----BEGIN PGP MESSAGE-----
|
|
200
|
-
|
|
201
|
-
wcFMA/vryg+TTn0rAQ//TBFRjKm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FwgaYBuw9dwdqwcjxSbZjHhCFGUfsqM+ik
|
|
217
|
-
O9gcoAwVO1usODlESU7OWuSF2tIv5DBG5rhlSyxBp4d4aWmaumTswAdojy2O
|
|
218
|
-
sM70ETbg0mC8niW9lNsgJp55oFmlksvzjUIit5rBEr55rtPcJSgakPpR2yvd
|
|
219
|
-
Q4XjybUmV0IdONMhk/OlqaBPtnA0RG+qTcm7oP1qH/m5zRA0ZplVQ5ylkQwr
|
|
220
|
-
LwGq5JQpJkgxxgLIrUbbtzYBShXSr5c1XXR0LIRiNgtb6s1s4mt+fbyExdJF
|
|
221
|
-
+ceuu+/xYrW/YTuEJpHxLiZ+aNPW5g5Y7Hbqu3hp3UL/kD44cc8JjZh18spX
|
|
222
|
-
p/ncojDhF2r2vhR+CndYcMkpGMV+t1pGKC8wlcFc7lb9GJASnqMGvhQmvIaG
|
|
223
|
-
gO/x7UjuTZSBW+kITHHZJDqYryKUv1j0CkHxIn9tWsYOpa1giOFtXX5v0AAM
|
|
224
|
-
AJR/s/beLlqwCsUdYnw1TkP/0u0ZK3RPio1nJ7S6ckPfsM7DqCWD8ILD8Cdr
|
|
225
|
-
cuzQrWaE30t5PXx53xBPO+6t5wKfDL35WHWG1Irmvz9UuT7tDS3IzwtF4ijF
|
|
226
|
-
PX6alTbxGnoHgZ4bG4J1wfpTNPppP1gJeVg67VqOypzdZi+SjofMWnFgRFmD
|
|
227
|
-
yEN8xpFUs7A9xryVZOosp9Sfe3IbBkO99sAQ7jV4EoMYk3/GKA==
|
|
228
|
-
=LjkG
|
|
229
|
-
-----END PGP MESSAGE-----",
|
|
230
|
-
]
|
|
231
|
-
`;
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
encryptViaKeys,
|
|
3
|
-
decryptViaKeys,
|
|
4
|
-
encryptViaPassword,
|
|
5
|
-
decryptViaPassword,
|
|
6
|
-
NoKeysProvidedError,
|
|
7
|
-
NoPasswordProvidedError,
|
|
8
|
-
IncorrectOrMissingPrivateKeyPasswordError,
|
|
9
|
-
encrypt,
|
|
10
|
-
decrypt,
|
|
11
|
-
_encryptViaKeys,
|
|
12
|
-
armor,
|
|
13
|
-
unarmor,
|
|
14
|
-
} from '../encryption';
|
|
15
|
-
import { test, expect } from 'vitest';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
armoredPublicKey,
|
|
19
|
-
armoredPrivateKey,
|
|
20
|
-
privateKeyPassphrase,
|
|
21
|
-
} from './encryption-keys';
|
|
22
|
-
// import { armor } from 'openpgp';
|
|
23
|
-
|
|
24
|
-
test('Should encrypt text as armored message via keys', async () => {
|
|
25
|
-
const res = await encryptViaKeys({
|
|
26
|
-
content: 'Hello world',
|
|
27
|
-
publicKey: armoredPublicKey,
|
|
28
|
-
privateKey: armoredPrivateKey,
|
|
29
|
-
privateKeyPassphrase: privateKeyPassphrase,
|
|
30
|
-
format: 'armored',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
expect(res.startsWith('-----BEGIN PGP MESSAGE-----')).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('Should encrypt text via keys', async () => {
|
|
37
|
-
const res = await encryptViaKeys({
|
|
38
|
-
content: 'Hello world',
|
|
39
|
-
publicKey: armoredPublicKey,
|
|
40
|
-
privateKey: armoredPrivateKey,
|
|
41
|
-
privateKeyPassphrase,
|
|
42
|
-
format: 'armored',
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
expect(res.startsWith('-----BEGIN PGP MESSAGE-----')).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('Should decrypt via provided keys', async () => {
|
|
49
|
-
const decryptedMessage = await decryptViaKeys({
|
|
50
|
-
content: `-----BEGIN PGP MESSAGE-----
|
|
51
|
-
|
|
52
|
-
wcFMA/vryg+TTn0rARAAhXuEjOHa856iCNVmdeIGHF+IEoeEwTc5tIcr6Lri
|
|
53
|
-
V6xs//3WnwVwUlyxYrum3yCpx8t5gyWTXFfT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XAJEHWEE4ZR3vQa1sWEnmxyAdNp
|
|
69
|
-
H9UFoIhGf9mSPlbBTMKEcAJmqzEIrb6z4psmmt6oYLXDR8PCxxK+g0xdrmbO
|
|
70
|
-
Az//AD0eRm8XHCHpwGf8YYWrNHOidDYpgmJTy7qFUwknWS+t3NlkU3CsCR+j
|
|
71
|
-
i9Km3edjOwPpJtgI0LeRRqXs3eUhLQARC5nFePbRWnFSXPBuFxBVZyL9AYrS
|
|
72
|
-
KQn4dM1p4eTtsiEu1NaTzRtQNZAFHcJpZ8qAL67LHoNdFe/atpCdlyV3yur9
|
|
73
|
-
RvAA3cB7cj7wab3beX+cTqxdhpGePZh0TrNd3liV69FtbnYfeDrtUYIL1jfT
|
|
74
|
-
EJN3l+qpveimyX655RrgFX3DNGrVbbhpx+FDF9Ky9kqb2BJBTFKoCBxbf0dS
|
|
75
|
-
sniNAsC/t/k6ErG8NKNQsNh1aeN6plXnxeVi1vv6SvO2mwZRVvDNT1hg9Cyc
|
|
76
|
-
UO1Pw43TRLO50HgR9+ERNXL491TJA0aCj14oXwsm0Dtg6EOltX0GUDwcPjv6
|
|
77
|
-
6QMreKTATPLytbhCdPO+JOzObsptU/IlsQQWlMz8yKXwqyuN8z8SOaddJIHR
|
|
78
|
-
YQ==
|
|
79
|
-
=f4F1
|
|
80
|
-
-----END PGP MESSAGE-----
|
|
81
|
-
`,
|
|
82
|
-
privateKey: armoredPrivateKey,
|
|
83
|
-
privateKeyPassphrase,
|
|
84
|
-
});
|
|
85
|
-
expect(decryptedMessage).toEqual('Hello world');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('Should encrypt via password', async () => {
|
|
89
|
-
const password = 'test';
|
|
90
|
-
const res = await encryptViaPassword({
|
|
91
|
-
content: 'Hello world',
|
|
92
|
-
password,
|
|
93
|
-
format: 'armored',
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
expect(res.startsWith('-----BEGIN PGP MESSAGE-----')).toBeTruthy();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('Should decrypt via password', async () => {
|
|
100
|
-
const password = 'test';
|
|
101
|
-
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
102
|
-
|
|
103
|
-
wy4ECQMI6KFWGqyVV+DgYl0qUEeTe1kAdjkoR4FxFJxx+6QiOP+sZ6h7bn//
|
|
104
|
-
aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
105
|
-
5iO5mEqoXWXg6nAvNxciA56dKuI=
|
|
106
|
-
=B4Tc
|
|
107
|
-
-----END PGP MESSAGE-----
|
|
108
|
-
`;
|
|
109
|
-
|
|
110
|
-
expect(await decryptViaPassword({ content: encryptedMsg, password })).toEqual(
|
|
111
|
-
'Hello world'
|
|
112
|
-
);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('Should raise incorrect or missing private key error', async () => {
|
|
116
|
-
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
117
|
-
|
|
118
|
-
wcFMA/vryg+TTn0rARAAhXuEjOHa856iCNVmdeIGHF+IEoeEwTc5tIcr6Lri
|
|
119
|
-
V6xs//3WnwVwUlyxYrum3yCpx8t5gyWTXFfTNH08VoVqPVP45fkk1H7jdC6Q
|
|
120
|
-
I+tHfn8nXZApdKQlMOku+XMXtRuqvOUQHutqHj4ka3qC+wGIPcOsy2TIoFsS
|
|
121
|
-
xauk13hMggmVHOdQkMzWA1QlxDcz6lFl86SvX18uc7H62s36gHxARmOLZfBd
|
|
122
|
-
nRFdnPgLKNOPGWb6QvYfvxiv03vGSsKlb0tIpwP1Ot0nyZax+yH9CJmIEni/
|
|
123
|
-
rW9Wu/Ph+PRcB2L9kp/X4Opol3RwJ0lI9ilTRw9+GGFipXhCmJcjPJC7WNIg
|
|
124
|
-
vg0/xVUjSmlxQQAZlC9/sefvoXjY0CP+h+djtoZsxLpN4P4iTO1reuoVD0iO
|
|
125
|
-
UwT9JCUR1uDEiNXvh6Am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rgFX3DNGrVbbhpx+FDF9Ky9kqb2BJBTFKoCBxbf0dS
|
|
141
|
-
sniNAsC/t/k6ErG8NKNQsNh1aeN6plXnxeVi1vv6SvO2mwZRVvDNT1hg9Cyc
|
|
142
|
-
UO1Pw43TRLO50HgR9+ERNXL491TJA0aCj14oXwsm0Dtg6EOltX0GUDwcPjv6
|
|
143
|
-
6QMreKTATPLytbhCdPO+JOzObsptU/IlsQQWlMz8yKXwqyuN8z8SOaddJIHR
|
|
144
|
-
YQ==
|
|
145
|
-
=f4F1
|
|
146
|
-
-----END PGP MESSAGE-----`;
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
await decryptViaPassword({ content: encryptedMsg, password: 'password' });
|
|
150
|
-
} catch (e) {
|
|
151
|
-
expect(e).toBeInstanceOf(NoKeysProvidedError);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test('Should raise IncorrectOrMissingPrivateKeyPasswordError error when incorrect armored key provided', async () => {
|
|
156
|
-
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
157
|
-
|
|
158
|
-
wy4ECQMI6KFWGqyVV+DgYl0qUEeTe1kAdjkoR4FxFJxx+6QiOP+sZ6h7bn//
|
|
159
|
-
aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
160
|
-
5iO5mEqoXWXg6nAvNxciA56dKuI=
|
|
161
|
-
=B4Tc
|
|
162
|
-
-----END PGP MESSAGE-----
|
|
163
|
-
`;
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
await decryptViaKeys({
|
|
167
|
-
content: encryptedMsg,
|
|
168
|
-
publicKey: armoredPublicKey,
|
|
169
|
-
privateKey: privateKeyPassphrase,
|
|
170
|
-
});
|
|
171
|
-
} catch (e) {
|
|
172
|
-
expect(e).toBeInstanceOf(IncorrectOrMissingPrivateKeyPasswordError);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('Should raise NoPasswordProvidedError error when try to use keys instead of password', async () => {
|
|
177
|
-
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
178
|
-
|
|
179
|
-
wy4ECQMI6KFWGqyVV+DgYl0qUEeTe1kAdjkoR4FxFJxx+6QiOP+sZ6h7bn//
|
|
180
|
-
aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
181
|
-
5iO5mEqoXWXg6nAvNxciA56dKuI=
|
|
182
|
-
=B4Tc
|
|
183
|
-
-----END PGP MESSAGE-----
|
|
184
|
-
`;
|
|
185
|
-
|
|
186
|
-
try {
|
|
187
|
-
await decryptViaKeys({
|
|
188
|
-
content: encryptedMsg,
|
|
189
|
-
privateKey: armoredPrivateKey,
|
|
190
|
-
privateKeyPassphrase,
|
|
191
|
-
});
|
|
192
|
-
} catch (e) {
|
|
193
|
-
expect(e).toBeInstanceOf(NoPasswordProvidedError);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test('Should encrypt and decrypt text by provided configs via password', async () => {
|
|
198
|
-
const text = 'Hello world';
|
|
199
|
-
const password = '123';
|
|
200
|
-
|
|
201
|
-
const res = await encrypt({
|
|
202
|
-
content: text,
|
|
203
|
-
type: 'gpgPassword',
|
|
204
|
-
password,
|
|
205
|
-
format: 'armored',
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
expect(res.startsWith('-----BEGIN PGP MESSAGE-----')).toBeTruthy();
|
|
209
|
-
|
|
210
|
-
const decryptedMessage = await decrypt({
|
|
211
|
-
content: res,
|
|
212
|
-
type: 'gpgPassword',
|
|
213
|
-
password,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
expect(decryptedMessage).toEqual(text);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
test('Should encrypt and decrypt text by provided configs via keys', async () => {
|
|
220
|
-
const text = 'Hello world';
|
|
221
|
-
const res = await encrypt({
|
|
222
|
-
content: text,
|
|
223
|
-
type: 'gpgKeys',
|
|
224
|
-
format: 'armored',
|
|
225
|
-
publicKey: armoredPublicKey,
|
|
226
|
-
privateKey: armoredPrivateKey,
|
|
227
|
-
privateKeyPassphrase,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
expect(res.startsWith('-----BEGIN PGP MESSAGE-----')).toBeTruthy();
|
|
231
|
-
|
|
232
|
-
const decryptedMessage = await decrypt({
|
|
233
|
-
content: res,
|
|
234
|
-
type: 'gpgKeys',
|
|
235
|
-
publicKey: armoredPublicKey,
|
|
236
|
-
privateKey: armoredPrivateKey,
|
|
237
|
-
privateKeyPassphrase,
|
|
238
|
-
format: 'utf8',
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
expect(decryptedMessage).toEqual(text);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
test('Should encrypt to binary and decrypt to format armored!', async () => {
|
|
245
|
-
const text = 'Hello world';
|
|
246
|
-
|
|
247
|
-
const res = await encrypt({
|
|
248
|
-
content: text,
|
|
249
|
-
type: 'gpgPassword',
|
|
250
|
-
password: '123',
|
|
251
|
-
format: 'binary',
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
expect(res).toBeInstanceOf(Uint8Array);
|
|
255
|
-
|
|
256
|
-
const decryptedMessage = await decrypt({
|
|
257
|
-
content: res,
|
|
258
|
-
type: 'gpgPassword',
|
|
259
|
-
format: 'utf8',
|
|
260
|
-
password: '123',
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
expect(decryptedMessage).toEqual(text);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test('Should encrypt to binary and decrypt to binary format', async () => {
|
|
267
|
-
const text = 'Hello world';
|
|
268
|
-
|
|
269
|
-
const res = await encrypt({
|
|
270
|
-
content: text,
|
|
271
|
-
type: 'gpgPassword',
|
|
272
|
-
password: '123',
|
|
273
|
-
format: 'binary',
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
expect(res).toBeInstanceOf(Uint8Array);
|
|
277
|
-
|
|
278
|
-
const decryptedMessage = await decrypt({
|
|
279
|
-
content: res,
|
|
280
|
-
type: 'gpgPassword',
|
|
281
|
-
format: 'binary',
|
|
282
|
-
password: '123',
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
expect(decryptedMessage.toString()).toMatchInlineSnapshot(
|
|
286
|
-
`"72,101,108,108,111,32,119,111,114,108,100"`
|
|
287
|
-
);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
test('Should encrypt to armored text and decrypt as binary format', async () => {
|
|
291
|
-
const text = 'Hello world';
|
|
292
|
-
|
|
293
|
-
const res = await encrypt({
|
|
294
|
-
content: text,
|
|
295
|
-
type: 'gpgPassword',
|
|
296
|
-
password: '123',
|
|
297
|
-
format: 'armored',
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
expect(res).toBeTypeOf('string');
|
|
301
|
-
|
|
302
|
-
const decryptedMessage = await decrypt({
|
|
303
|
-
content: res,
|
|
304
|
-
type: 'gpgPassword',
|
|
305
|
-
format: 'binary',
|
|
306
|
-
password: '123',
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
expect(decryptedMessage).toBeInstanceOf(Uint8Array);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test('Should armor and unarmor encrypted file', async () => {
|
|
313
|
-
const content: Uint8Array = new Uint8Array([
|
|
314
|
-
72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100,
|
|
315
|
-
]);
|
|
316
|
-
|
|
317
|
-
const armored = armor(content);
|
|
318
|
-
|
|
319
|
-
expect(armored).toMatchInlineSnapshot(`
|
|
320
|
-
"-----BEGIN PGP MESSAGE-----
|
|
321
|
-
|
|
322
|
-
SGVsbG8gd29ybGQ=
|
|
323
|
-
=7asC
|
|
324
|
-
-----END PGP MESSAGE-----
|
|
325
|
-
"
|
|
326
|
-
`);
|
|
327
|
-
|
|
328
|
-
const { text, data } = await unarmor(armored);
|
|
329
|
-
|
|
330
|
-
expect(data).toEqual(content);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
test('Should decrypt value from provided real world data and passwords', async () => {
|
|
334
|
-
const text = `Hello world!`;
|
|
335
|
-
const password = 'qweqwebebe1';
|
|
336
|
-
|
|
337
|
-
const encryptedContent = await encrypt({
|
|
338
|
-
content: text,
|
|
339
|
-
type: 'gpgPassword',
|
|
340
|
-
password,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
const armoredContent = armor(encryptedContent as unknown as Uint8Array);
|
|
344
|
-
|
|
345
|
-
const decryptedMessage = await decrypt({
|
|
346
|
-
content: armoredContent,
|
|
347
|
-
type: 'gpgPassword',
|
|
348
|
-
password,
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
expect(decryptedMessage).toEqual('Hello world!');
|
|
352
|
-
});
|