-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from magiclabs/jerryliu-sc-78190-gdkms-v1-sym…
…metric-encryption Add symmetric encryption api
- Loading branch information
Showing
4 changed files
with
89 additions
and
44 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
33 changes: 33 additions & 0 deletions
33
packages/@magic-sdk/provider/test/spec/modules/user/gdkms.spec.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,33 @@ | ||
import browserEnv from '@ikscodes/browser-env'; | ||
import { MagicPayloadMethod } from '@magic-sdk/types'; | ||
import { createMagicSDK } from '../../../factories'; | ||
|
||
beforeEach(() => { | ||
browserEnv.restore(); | ||
}); | ||
|
||
test('Construct Encrypt Request with `magic_auth_encrypt_v1`', async () => { | ||
const magic = createMagicSDK(); | ||
magic.user.request = jest.fn(); | ||
|
||
const message = 'hello world'; | ||
|
||
magic.user.encryptWithPrivateKey(message); | ||
|
||
const requestPayload = magic.user.request.mock.calls[0][0]; | ||
expect(requestPayload.method).toBe(MagicPayloadMethod.EncryptV1); | ||
expect(requestPayload.params).toEqual([{ message }]); | ||
}); | ||
|
||
test('Construct Decrypt Request with `magic_auth_decrypt_v1`', async () => { | ||
const magic = createMagicSDK(); | ||
magic.user.request = jest.fn(); | ||
|
||
const cipherText = 'XJD/1238t'; | ||
|
||
magic.user.decryptWithPrivateKey(cipherText); | ||
|
||
const requestPayload = magic.user.request.mock.calls[0][0]; | ||
expect(requestPayload.method).toBe(MagicPayloadMethod.DecryptV1); | ||
expect(requestPayload.params).toEqual([{ cipherText }]); | ||
}); |
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