-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'francisco/complete_2fa' into 'master'
feat(2FA): make 2FA work with phone number See merge request TankerHQ/sdk-react-native!81
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ import { | |
IdentityAlreadyAttached, | ||
} from '@tanker/errors'; | ||
import { createTanker, clearTankerDataDirs } from './tests'; | ||
import base64 from 'react-native-base64'; | ||
|
||
export const tankerTests = () => { | ||
describe('Tanker tests', () => { | ||
|
@@ -262,6 +263,57 @@ export const tankerTests = () => { | |
await secondDevice.stop(); | ||
}); | ||
|
||
it('can request a session token with VerificationOptions', async () => { | ||
await tanker.start(identity); | ||
const token = await tanker.registerIdentity( | ||
{ passphrase: 'foo' }, | ||
{ withSessionToken: true } | ||
); | ||
expect(tanker.status).eq(Tanker.statuses.READY); | ||
expect(token).is.not.empty; | ||
// @ts-ignore is.not.empty checks that the token is not undefined | ||
const tokenData = base64.decode(token); | ||
expect(tokenData).length.greaterThanOrEqual(32); | ||
}); | ||
|
||
it('can use setVerificationMethod with email to get a session token', async () => { | ||
await tanker.start(identity); | ||
await tanker.registerIdentity({ | ||
passphrase: 'Space and time are not what you think', | ||
}); | ||
|
||
const email = '[email protected]'; | ||
const verificationCode = await getVerificationCode(email); | ||
const token = await tanker.setVerificationMethod( | ||
{ email, verificationCode }, | ||
{ withSessionToken: true } | ||
); | ||
|
||
expect(token).is.not.empty; | ||
// @ts-ignore is.not.empty checks that the token is not undefined | ||
const tokenData = base64.decode(token); | ||
expect(tokenData).length.greaterThanOrEqual(32); | ||
}); | ||
|
||
it('can use setVerificationMethod with phone number to get a session token', async () => { | ||
await tanker.start(identity); | ||
await tanker.registerIdentity({ | ||
passphrase: 'Space and time are not what you think', | ||
}); | ||
|
||
const phoneNumber = '+33639982233'; | ||
const verificationCode = await getSMSVerificationCode(phoneNumber); | ||
const token = await tanker.setVerificationMethod( | ||
{ phoneNumber, verificationCode }, | ||
{ withSessionToken: true } | ||
); | ||
|
||
expect(token).is.not.empty; | ||
// @ts-ignore is.not.empty checks that the token is not undefined | ||
const tokenData = base64.decode(token); | ||
expect(tokenData).length.greaterThanOrEqual(32); | ||
}); | ||
|
||
it('can use a verificationKey', async () => { | ||
await tanker.start(identity); | ||
const verifKey = await tanker.generateVerificationKey(); | ||
|