mirror of https://github.com/dapr/quickstarts.git
				
				
				
			Fixes
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									e0799feeb9
								
							
						
					
					
						commit
						a9c9f3930b
					
				|  | @ -13,7 +13,7 @@ This quickstart includes one application: | |||
| 
 | ||||
| - Node.js application `crypto-quickstart` | ||||
| 
 | ||||
| ### Run Node.js service with Dapr | ||||
| ### Run Node.js app with Dapr | ||||
| 
 | ||||
| 1. Navigate into the folder with the source and install dependencies: | ||||
| 
 | ||||
|  | @ -46,13 +46,22 @@ openssl rand -out keys/symmetric-key-256 32 | |||
| 
 | ||||
| <!-- END_STEP --> | ||||
| 
 | ||||
| 3. Run the Node.js service app with Dapr: | ||||
| 3. Run the Node.js app with Dapr: | ||||
| 
 | ||||
| <!-- STEP | ||||
| name: Run Node publisher | ||||
| name: Run Node.js app | ||||
| expected_stdout_lines: | ||||
|   - "== APP == Saving Order:  { orderId: '1' }" | ||||
|   - "== APP == Getting Order:  { orderId: '1' }" | ||||
|   - "== APP == == Encrypting message using buffers" | ||||
|   - "== APP == Encrypted the message, got 856 bytes" | ||||
|   - "== APP == == Decrypting message using buffers" | ||||
|   - "== APP == Decrypted the message, got 24 bytes" | ||||
|   - '== APP == The secret is "passw0rd"' | ||||
|   - "== APP == == Encrypting message using streams" | ||||
|   - "== APP == Encrypting federico-di-dio-photography-Q4g0Q-eVVEg-unsplash.jpg to encrypted.out" | ||||
|   - "== APP == Encrypted the message to encrypted.out" | ||||
|   - "== APP == == Decrypting message using streams" | ||||
|   - "== APP == Encrypting encrypted.out to decrypted.out" | ||||
|   - "== APP == Decrypted the message to decrypted.out.jpg" | ||||
|   - "Exited App successfully" | ||||
| expected_stderr_lines: | ||||
| working_dir: ./crypto-quickstart | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { createReadStream, createWriteStream } from "node:fs"; | |||
| import { readFile, writeFile } from "node:fs/promises"; | ||||
| import { pipeline } from "node:stream/promises"; | ||||
| 
 | ||||
| import { DaprClient, CommunicationProtocolEnum } from "@dapr/dapr"; | ||||
| import { DaprClient, CommunicationProtocolEnum } from "@dapr/dapr-dev"; | ||||
| 
 | ||||
| const daprHost = process.env.DAPR_HOST ?? "127.0.0.1"; | ||||
| const daprPort = process.env.DAPR_GRPC_PORT ?? "50001"; | ||||
|  | @ -30,18 +30,18 @@ async function encryptDecryptBuffer(client) { | |||
|   // First, encrypt the message
 | ||||
|   console.log("== Encrypting message using buffers"); | ||||
| 
 | ||||
|   const ciphertext = await client.crypto.encrypt(plaintext, { | ||||
|     componentName: "crypto-local", | ||||
|     keyName: "my-rsa-key", | ||||
|   const encrypted = await client.crypto.encrypt(plaintext, { | ||||
|     componentName: "localstorage", | ||||
|     keyName: "rsa-private-key.pem", | ||||
|     keyWrapAlgorithm: "RSA", | ||||
|   }); | ||||
| 
 | ||||
|   console.log("Encrypted the message, got", ciphertext.length, "bytes"); | ||||
|   console.log("Encrypted the message, got", encrypted.length, "bytes"); | ||||
| 
 | ||||
|   // Decrypt the message
 | ||||
|   console.log("== Decrypting message using buffers"); | ||||
|   const decrypted = await client.crypto.decrypt(ciphertext, { | ||||
|     componentName: "crypto-local", | ||||
|   const decrypted = await client.crypto.decrypt(encrypted, { | ||||
|     componentName: "localstorage", | ||||
|   }); | ||||
| 
 | ||||
|   console.log("Decrypted the message, got", decrypted.length, "bytes"); | ||||
|  | @ -56,32 +56,32 @@ async function encryptDecryptBuffer(client) { | |||
| async function encryptDecryptStream(client) { | ||||
|   // First, encrypt the message
 | ||||
|   console.log("== Encrypting message using streams"); | ||||
|   console.log("Encrypting", testFileName, "to ciphertext.out"); | ||||
|   console.log("Encrypting", testFileName, "to encrypted.out"); | ||||
| 
 | ||||
|   await pipeline( | ||||
|     createReadStream(testFileName), | ||||
|     await client.crypto.encrypt({ | ||||
|       componentName: "crypto-local", | ||||
|       keyName: "symmetric256", | ||||
|       componentName: "localstorage", | ||||
|       keyName: "symmetric-key-256", | ||||
|       keyWrapAlgorithm: "A256KW", | ||||
|     }), | ||||
|     createWriteStream("ciphertext.out"), | ||||
|     createWriteStream("encrypted.out"), | ||||
|   ); | ||||
| 
 | ||||
|   console.log("Encrypted the message to ciphertext.out"); | ||||
|   console.log("Encrypted the message to encrypted.out"); | ||||
| 
 | ||||
|   // Decrypt the message
 | ||||
|   console.log("== Decrypting message using streams"); | ||||
|   console.log("Encrypting ciphertext.out to plaintext.out"); | ||||
|   console.log("Encrypting encrypted.out to decrypted.out"); | ||||
|   await pipeline( | ||||
|     createReadStream("ciphertext.out"), | ||||
|     createReadStream("encrypted.out"), | ||||
|     await client.crypto.decrypt({ | ||||
|       componentName: "crypto-local", | ||||
|       componentName: "localstorage", | ||||
|     }), | ||||
|     createWriteStream("plaintext.out.jpg"), | ||||
|     createWriteStream("decrypted.out.jpg"), | ||||
|   ); | ||||
| 
 | ||||
|   console.log("Decrypted the message to plaintext.out.jpg"); | ||||
|   console.log("Decrypted the message to decrypted.out.jpg"); | ||||
| } | ||||
| 
 | ||||
| await start(); | ||||
|  |  | |||
|  | @ -9,16 +9,16 @@ | |||
|             "version": "1.0.0", | ||||
|             "license": "MIT", | ||||
|             "dependencies": { | ||||
|                 "@dapr/dapr": "^3.0.0" | ||||
|                 "@dapr/dapr-dev": "3.0.0-20230608164322-af71496" | ||||
|             }, | ||||
|             "devDependencies": { | ||||
|                 "eslint": "^8.42.0" | ||||
|             } | ||||
|         }, | ||||
|         "node_modules/@dapr/dapr": { | ||||
|             "version": "3.0.0", | ||||
|             "resolved": "git+ssh://git@github.com/dapr/js-sdk.git#af71496618d5d2d640defdcb7d94fb165a2e8794", | ||||
|             "license": "ISC", | ||||
|         "node_modules/@dapr/dapr-dev": { | ||||
|             "version": "3.0.0-20230608164322-af71496", | ||||
|             "resolved": "https://registry.npmjs.org/@dapr/dapr-dev/-/dapr-dev-3.0.0-20230608164322-af71496.tgz", | ||||
|             "integrity": "sha512-0olN5kwcOVA1Fm2BD9Rzk8yi04/Zst5qH/HvccPuhvVbZoOkU3zH2v7ievLcN7mLmjscsNkudSWUhcUxL9+w+w==", | ||||
|             "dependencies": { | ||||
|                 "@grpc/grpc-js": "^1.3.7", | ||||
|                 "@js-temporal/polyfill": "^0.3.0", | ||||
|  | @ -2269,9 +2269,10 @@ | |||
|         } | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@dapr/dapr": { | ||||
|             "version": "git+ssh://git@github.com/dapr/js-sdk.git#af71496618d5d2d640defdcb7d94fb165a2e8794", | ||||
|             "from": "@dapr/dapr@^3.0.0", | ||||
|         "@dapr/dapr-dev": { | ||||
|             "version": "3.0.0-20230608164322-af71496", | ||||
|             "resolved": "https://registry.npmjs.org/@dapr/dapr-dev/-/dapr-dev-3.0.0-20230608164322-af71496.tgz", | ||||
|             "integrity": "sha512-0olN5kwcOVA1Fm2BD9Rzk8yi04/Zst5qH/HvccPuhvVbZoOkU3zH2v7ievLcN7mLmjscsNkudSWUhcUxL9+w+w==", | ||||
|             "requires": { | ||||
|                 "@grpc/grpc-js": "^1.3.7", | ||||
|                 "@js-temporal/polyfill": "^0.3.0", | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ | |||
|     "author": "", | ||||
|     "license": "MIT", | ||||
|     "dependencies": { | ||||
|         "@dapr/dapr": "^3.0.0" | ||||
|         "@dapr/dapr-dev": "3.0.0-20230608164322-af71496" | ||||
|     }, | ||||
|     "devDependencies": { | ||||
|         "eslint": "^8.42.0" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue