Skip to content

Commit

Permalink
fix: note content
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Aug 23, 2024
1 parent 68ed910 commit b1febe0
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 72 deletions.
40 changes: 22 additions & 18 deletions dist/browser/notes/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/browser/notes/index.js.map

Large diffs are not rendered by default.

36 changes: 20 additions & 16 deletions dist/node/notes/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/node/notes/index.js.map

Large diffs are not rendered by default.

46 changes: 38 additions & 8 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ export declare class FilenSDK {
affiliate: () => {
payout: (params_0: {
address: string;
/**
* FilenSDK
* @date 2/1/2024 - 2:45:02 AM
*
* @export
* @class FilenSDK
* @typedef {FilenSDK}
*/
method: string;
}) => Promise<void>;
};
Expand Down Expand Up @@ -390,14 +398,7 @@ export declare class FilenSDK {
authVersion: number;
salt: string;
hasRecoveryKeys: boolean;
newMasterKeys: string; /**
* Creates an instance of FilenSDK.
* @date 2/21/2024 - 8:58:43 AM
*
* @constructor
* @public
* @param {?FilenSDKConfig} [params]
*/
newMasterKeys: string;
}) => Promise<void>;
};
didExportMasterKeys: () => Promise<void>;
Expand Down Expand Up @@ -714,6 +715,14 @@ export declare class FilenSDK {
id: number;
}) => Promise<void>;
participantsRemove: (params_0: {
/**
* FilenSDK
* @date 2/1/2024 - 2:45:02 AM
*
* @export
* @class FilenSDK
* @typedef {FilenSDK}
*/
uuid: string;
userId: number;
}) => Promise<void>;
Expand Down Expand Up @@ -741,6 +750,14 @@ export declare class FilenSDK {
}) => Promise<void>;
tagsFavorite: (params_0: {
uuid: string;
/**
* FilenSDK
* @date 2/1/2024 - 2:45:02 AM
*
* @export
* @class FilenSDK
* @typedef {FilenSDK}
*/
favorite: boolean;
}) => Promise<void>;
tag: (params_0: {
Expand Down Expand Up @@ -869,6 +886,19 @@ export declare class FilenSDK {
sleep: typeof import("./utils").sleep;
convertTimestampToMs: typeof import("./utils").convertTimestampToMs;
normalizePath: typeof import("./utils").normalizePath;
/**
* Set keypair.
* @date 2/20/2024 - 7:48:10 AM
*
* @private
* @async
* @param {{apiKey: string, publicKey: string, privateKey: string, masterKeys: string[]}} param0
* @param {string} param0.apiKey
* @param {string} param0.publicKey
* @param {string} param0.privateKey
* @param {{}} param0.masterKeys
* @returns {Promise<void>}
*/
uuidv4: typeof import("./utils").uuidv4;
Uint8ArrayConcat: typeof import("./utils").Uint8ArrayConcat;
promiseAllChunked: typeof import("./utils").promiseAllChunked;
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@filen/sdk",
"version": "0.1.157",
"version": "0.1.158",
"description": "Filen SDK",
"main": "dist/node/index.js",
"browser": "dist/browser/index.js",
Expand Down
44 changes: 22 additions & 22 deletions src/notes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ export class Notes {

this.crypto
.decrypt()
.noteTitle({ title: note.title, key: decryptedNoteKey })
.noteTitle({
title: note.title,
key: decryptedNoteKey
})
.then(decryptedNoteTitle => {
Promise.all([
note.preview.length === 0
? Promise.resolve(decryptedNoteTitle)
: this.crypto.decrypt().notePreview({ preview: note.preview, key: decryptedNoteKey }),
: this.crypto.decrypt().notePreview({
preview: note.preview,
key: decryptedNoteKey
}),
this.allTags({ tags: note.tags })
])
.then(([decryptedNotePreview, decryptedNoteTags]) => {
notes.push({
...note,
title:
decryptedNoteTitle.length > 0
? decryptedNoteTitle
: `CANNOT_DECRYPT_TITLE_${note.uuid}`,
preview:
decryptedNotePreview.length > 0
? decryptedNotePreview
: `CANNOT_DECRYPT_PREVIEW_${note.uuid}`,
title: decryptedNoteTitle,
preview: decryptedNotePreview,
tags: decryptedNoteTags
})

Expand Down Expand Up @@ -445,15 +445,15 @@ export class Notes {
// eslint-disable-next-line quotes
content = '<ul data-checked="false"><li><br></li></ul>'
} else {
content = contentDecrypted.length > 0 ? contentDecrypted : `CANNOT_DECRYPT_CONTENT_${uuid}`
content = contentDecrypted
}

return {
content,
type: contentEncrypted.type,
editedTimestamp: contentEncrypted.editedTimestamp,
editorId: contentEncrypted.editorId,
preview: previewDecrypted.length > 0 ? previewDecrypted : `CANNOT_DECRYPT_PREVIEW_${uuid}`
preview: previewDecrypted
}
}

Expand Down Expand Up @@ -662,20 +662,20 @@ export class Notes {
promises.push(
new Promise<void>((resolve, reject) => {
Promise.all([
this.crypto.decrypt().noteContent({ content: noteHistory.content, key: decryptedNoteKey }),
this.crypto.decrypt().notePreview({ preview: noteHistory.preview, key: decryptedNoteKey })
this.crypto.decrypt().noteContent({
content: noteHistory.content,
key: decryptedNoteKey
}),
this.crypto.decrypt().notePreview({
preview: noteHistory.preview,
key: decryptedNoteKey
})
])
.then(([noteHistoryContentDecrypted, noteHistoryPreviewDecrypted]) => {
notesHistory.push({
...noteHistory,
content:
noteHistoryContentDecrypted.length > 0
? noteHistoryContentDecrypted
: `CANNOT_DECRYPT_CONTENT_${noteHistory.id}`,
preview:
noteHistoryPreviewDecrypted.length > 0
? noteHistoryPreviewDecrypted
: `CANNOT_DECRYPT_PREVIEW_${noteHistory.id}`
content: noteHistoryContentDecrypted,
preview: noteHistoryPreviewDecrypted
})

resolve()
Expand Down

0 comments on commit b1febe0

Please sign in to comment.