Skip to content

Commit

Permalink
[Wallet] Add support for 8 digits verification codes
Browse files Browse the repository at this point in the history
  • Loading branch information
i1skn committed Nov 20, 2020
1 parent 51095df commit 8fb1277
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 112 deletions.
45 changes: 25 additions & 20 deletions packages/contractkit/src/wrappers/Attestations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export interface AttesationServiceRevealRequest {
salt?: string
smsRetrieverAppSig?: string
language?: string
securityCodePrefix?: string
}

export interface AttesationServiceCodeForSecurityRequest {
account: Address
phoneNumber: string
issuer: string
// TODO rename to pepper here and in Attesation Service
salt: string
securityCode: string
}

export interface UnselectedRequest {
Expand Down Expand Up @@ -525,28 +535,10 @@ export class AttestationsWrapper extends BaseWrapper<Attestations> {

/**
* Reveal phone number to issuer
* @param phoneNumber: attestation's phone number
* @param account: attestation's account
* @param issuer: validator's address
* @param serviceURL: validator's attestation service URL
* @param pepper: phone number privacy pepper
* @param smsRetrieverAppSig?: Android app's hash
* @param body: AttesationServiceRevealRequest
*/
revealPhoneNumberToIssuer(
phoneNumber: string,
account: Address,
issuer: Address,
serviceURL: string,
pepper?: string,
smsRetrieverAppSig?: string
) {
const body: AttesationServiceRevealRequest = {
account,
phoneNumber,
issuer,
salt: pepper,
smsRetrieverAppSig,
}
revealPhoneNumberToIssuer(serviceURL: string, body: AttesationServiceRevealRequest) {
return fetch(appendPath(serviceURL, 'attestations'), {
method: 'POST',
headers: {
Expand Down Expand Up @@ -583,6 +575,19 @@ export class AttestationsWrapper extends BaseWrapper<Attestations> {
})
}

/**
* Returns attestation code for provided security code from validator's attestation service
* @param serviceURL: validator's attestation service URL
* @param body: onServiceCodeForSecurityRequest
*/
getAttestationForSecurityCode(serviceURL: string, body: AttesationServiceCodeForSecurityRequest) {
const urlParams = new URLSearchParams({ ...body })
return fetch(appendPath(serviceURL, 'get_attestations') + '?' + urlParams, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
}

/**
* Validates a given code by the issuer on-chain
* @param identifier Attestation identifier (e.g. phone hash)
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
- [AttestationState](developer-resources/contractkit/reference/enums/_wrappers_attestations_.attestationstate.md)
- [AttestationsWrapper](developer-resources/contractkit/reference/classes/_wrappers_attestations_.attestationswrapper.md)
- [ActionableAttestation](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.actionableattestation.md)
- [AttesationServiceCodeForSecurityRequest](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attesationservicecodeforsecurityrequest.md)
- [AttesationServiceRevealRequest](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attesationservicerevealrequest.md)
- [AttestationServiceStatusResponse](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attestationservicestatusresponse.md)
- [AttestationStat](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attestationstat.md)
Expand Down Expand Up @@ -485,6 +486,7 @@
- [UnlockableWallet](developer-resources/contractkit/reference/interfaces/_wallets_wallet_.unlockablewallet.md)
- [Wallet](developer-resources/contractkit/reference/interfaces/_wallets_wallet_.wallet.md)
- [ActionableAttestation](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.actionableattestation.md)
- [AttesationServiceCodeForSecurityRequest](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attesationservicecodeforsecurityrequest.md)
- [AttesationServiceRevealRequest](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attesationservicerevealrequest.md)
- [AttestationServiceStatusResponse](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attestationservicestatusresponse.md)
- [AttestationStat](developer-resources/contractkit/reference/interfaces/_wrappers_attestations_.attestationstat.md)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8fb1277

Please sign in to comment.