How to use the upad-parse/dist/crypto.encrypt function in upad-parse

To help you get started, we’ve selected a few upad-parse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MicroPad / Web / app / src / react-web / DifferenceEngine.ts View on Github external
export const uploadNotepad = (username: string, token: string, syncId: string, notepad: ISyncedNotepad, passkey?: string): Observable =>
			from(!!notepad.crypto && !!passkey ? encrypt(notepad, passkey) : of(notepad)).pipe(
				concatMap(np =>
					call<{ assetsToUpload: AssetList }>('upload', syncId, {
						notepadV2: JSON.stringify(np, (k, v) => (k === 'parent') ? undefined : v) // Remove parent links here, unneeded content
							.replace(
								/[\u007f-\uffff]/g,
								char => '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4)
							), // Fix unicode encoding
						username,
						token
					})
				),
				map(res => res.assetsToUpload)
			);