-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aegis -> tokenvault tool (#41)
- Loading branch information
1 parent
2443386
commit dd52751
Showing
5 changed files
with
212 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { readFileSync } from 'fs'; | ||
import { readFileSync, statSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { Tools } from './sntools'; | ||
|
||
|
@@ -125,7 +125,7 @@ describe('sn-tools', () => { | |
uuid: expect.stringMatching(uuidFormat), | ||
content_type: 'Note', | ||
content: { | ||
title: 'Imported note 2 from ENote', | ||
title: 'Imported note 2 from Evernote', | ||
text: '<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>', | ||
references: [], | ||
appData: { | ||
|
@@ -142,7 +142,7 @@ describe('sn-tools', () => { | |
uuid: expect.stringMatching(uuidFormat), | ||
content_type: 'Note', | ||
content: { | ||
title: 'Imported note 2 from ENote', | ||
title: 'Imported note 2 from Evernote', | ||
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', | ||
references: [], | ||
appData: { | ||
|
@@ -175,6 +175,67 @@ describe('sn-tools', () => { | |
}); | ||
}); | ||
|
||
describe('convertAegisToSN()', () => { | ||
const filePath = join(__dirname, '../test/data/aegis/backup.json'); | ||
const content = readFileSync(filePath); | ||
const metadata = statSync(filePath); | ||
const parsedFile = tools.convertAegisFile({ | ||
name: 'backup.json', | ||
lastModified: metadata.mtime, | ||
content, | ||
}); | ||
|
||
it('should return 2 valid items', () => { | ||
expect(parsedFile).not.toBe(undefined); | ||
expect(parsedFile.items).toBeDefined(); | ||
expect(parsedFile.items.length).toBe(2); // 1 Note and 1 Tag | ||
|
||
expect(parsedFile).not.toBe(undefined); | ||
expect(parsedFile.items).toBeDefined(); | ||
expect(parsedFile.items.length).toBe(2); // 1 Note and 1 Tag | ||
}); | ||
|
||
const { items } = parsedFile; | ||
|
||
const firstItem = items[0]; | ||
const secondItem = items[1]; | ||
|
||
test("first item should be a Tag", () => { | ||
expect(firstItem).toEqual({ | ||
uuid: expect.stringMatching(uuidFormat), | ||
content_type: 'Tag', | ||
content: { | ||
title: `${new Date('2022-03-13').toLocaleDateString().replace(/\//g, '-')}-import`, | ||
references: [ | ||
{ | ||
content_type: 'Note', | ||
uuid: secondItem.uuid | ||
} | ||
] | ||
} | ||
}); | ||
}); | ||
|
||
test("second item should be a Note", () => { | ||
expect(secondItem).toEqual({ | ||
created_at: new Date(metadata.mtime), | ||
updated_at: new Date(metadata.mtime), | ||
uuid: expect.stringMatching(uuidFormat), | ||
content_type: "Note", | ||
content: { | ||
title: "backup", | ||
text: "[{\"service\":\"TestMail\",\"account\":\"[email protected]\",\"secret\":\"TESTMAILTESTMAILTESTMAILTESTMAIL\",\"notes\":\"Some note\"},{\"service\":\"Some Service\",\"account\":\"[email protected]\",\"secret\":\"SOMESERVICESOMESERVICESOMESERVIC\",\"notes\":\"Some other service\"}]", | ||
references: [], | ||
appData: { | ||
"org.standardnotes.sn": { | ||
client_updated_at: new Date(metadata.mtime), | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('convertGKeepNotes()', () => { | ||
const filesPath = join(__dirname, '../test/data/google-keep'); | ||
const exportFile1 = readFileSync(join(filesPath, 'note-1.json')); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "sntools", | ||
"author": "Standard Notes <[email protected]>", | ||
"license": "AGPL-3.0", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"main": "dist/sntools.js", | ||
"scripts": { | ||
"start": "webpack serve --config webpack.dev.js --progress --hot", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"version": 1, | ||
"header": { | ||
"slots": null, | ||
"params": null | ||
}, | ||
"db": { | ||
"version": 2, | ||
"entries": [ | ||
{ | ||
"type": "totp", | ||
"uuid": "c74a11c4-4f23-417b-818a-e11f6a4d51d7", | ||
"name": "[email protected]", | ||
"issuer": "TestMail", | ||
"note": "Some note", | ||
"icon": null, | ||
"info": { | ||
"secret": "TESTMAILTESTMAILTESTMAILTESTMAIL", | ||
"algo": "SHA1", | ||
"digits": 6, | ||
"period": 30 | ||
} | ||
}, | ||
{ | ||
"type": "totp", | ||
"uuid": "803ed58f-b2c4-386c-9aad-645a47309124", | ||
"name": "[email protected]", | ||
"issuer": "Some Service", | ||
"note": "Some other service", | ||
"icon": null, | ||
"info": { | ||
"secret": "SOMESERVICESOMESERVICESOMESERVIC", | ||
"algo": "SHA1", | ||
"digits": 6, | ||
"period": 30 | ||
} | ||
} | ||
] | ||
} | ||
} |