-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
353 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopify/shopify-api": minor | ||
--- | ||
|
||
Added the ability to encrypt Session access tokens using AES-GCM with a 128-bit tag and a 12-byte random IV. |
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,3 +1,4 @@ | ||
import '../crypto/__tests__/encrypt.test'; | ||
import '../crypto/__tests__/hmac.test'; | ||
import '../http/__tests__/http.test'; | ||
import '../platform/__tests__/platform.test'; |
22 changes: 22 additions & 0 deletions
22
packages/apps/shopify-api/runtime/crypto/__tests__/encrypt.test.ts
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,22 @@ | ||
import {decryptString, encryptString} from '../encrypt'; | ||
import {getCryptoLib} from '../utils'; | ||
|
||
it('can encrypt and decrypt a string with a random key and IV', async () => { | ||
// GIVEN | ||
const cryptoLib = getCryptoLib(); | ||
|
||
const iv = cryptoLib.getRandomValues(new Uint8Array(12)); | ||
const key = await cryptoLib.subtle.generateKey( | ||
{name: 'AES-GCM', length: 256}, | ||
true, | ||
['encrypt', 'decrypt'], | ||
); | ||
|
||
// WHEN | ||
const encryptedValue = await encryptString('Test encrypted value', {key, iv}); | ||
const result = await decryptString(encryptedValue, {key, iv}); | ||
|
||
// THEN | ||
expect(encryptedValue).not.toEqual('Test encrypted value'); | ||
expect(result).toEqual('Test encrypted value'); | ||
}); |
Oops, something went wrong.