@0xpass/passport
Advanced tools
Comparing version 0.1.10 to 0.1.11
# @0xpass/passport | ||
## 0.1.11 | ||
### Patch Changes | ||
- 2cac52c: Split registration into initiate and complete | ||
## 0.1.10 | ||
@@ -4,0 +10,0 @@ |
@@ -62,2 +62,4 @@ import { AuthenticationParams, AuthenticationResponse, DelegatedRegisterAccountParams, DelegatedRegisterAccountResponse, LambaCallParams, LambdaListParams, LambdaNewParams, Method, NewScopeParams, NewScopeResponse, RegistrationParams, RegistrationResponse, RpcHeaders, RpcMethodParams, SignMessageParams, SignMessageResponse, SignTransactionParams, SignTransactionResponse, UpdateScopeParams, UpdateScopeResponse } from "./types"; | ||
register: (params: RegistrationParams) => Promise<RegistrationResponse>; | ||
initiateRegistration(params: RegistrationParams): Promise<any>; | ||
completeRegistration(encrypted_user: any, challenge_id: any, cco_json: any): Promise<RegistrationResponse>; | ||
authenticate: (params: AuthenticationParams, regenerate_seed?: boolean) => Promise<AuthenticationResponse>; | ||
@@ -64,0 +66,0 @@ uncompressPublicKey: (compressedPubKeyHex: any) => string; |
@@ -380,2 +380,37 @@ import axios from 'axios'; | ||
} | ||
async initiateRegistration(params) { | ||
if (!this.isCredentialCreator(this.signer)) { | ||
throw new Error("Signer does not support registration."); | ||
} | ||
const encrypted_user = await aesEncrypt(JSON.stringify(params), this.aesKey); | ||
const initRegResponse = await this.call("initiateRegistration", { | ||
encrypted_user, | ||
}); | ||
if (initRegResponse.error) { | ||
throw new Error(`error message: ${initRegResponse.error.message}, error data: ${initRegResponse.error.data}`); | ||
} | ||
const challenge_id = initRegResponse.result.challenge_id; | ||
const cco_str = await aesDecrypt(initRegResponse.result.encrypted_creation_challenge, this.aesKey); | ||
const cco_json = JSON.parse(cco_str); | ||
return { | ||
challenge_id, | ||
cco_json, | ||
}; | ||
} | ||
async completeRegistration(encrypted_user, challenge_id, cco_json) { | ||
if (!this.isCredentialCreator(this.signer)) { | ||
throw new Error("Signer does not support registration."); | ||
} | ||
const attestation = await this.signer.create(cco_json); | ||
const encrypted_attestation = await aesEncrypt(JSON.stringify(attestation), this.aesKey); | ||
const finishRegResult = await this.call("completeRegistration", { | ||
challenge_id, | ||
encrypted_attestation, | ||
encrypted_user, | ||
}); | ||
if (finishRegResult.error) { | ||
throw new Error(`error message: ${finishRegResult.error.message}, error data: ${finishRegResult.error.data}`); | ||
} | ||
return finishRegResult; | ||
} | ||
} | ||
@@ -382,0 +417,0 @@ |
{ | ||
"name": "@0xpass/passport", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -231,2 +231,57 @@ import axios from "axios"; | ||
public async initiateRegistration(params: RegistrationParams): Promise<any> { | ||
if (!this.isCredentialCreator(this.signer)) { | ||
throw new Error("Signer does not support registration."); | ||
} | ||
const encrypted_user = await aesEncrypt(JSON.stringify(params), this.aesKey); | ||
const initRegResponse = await this.call("initiateRegistration", { | ||
encrypted_user, | ||
}); | ||
if (initRegResponse.error) { | ||
throw new Error( | ||
`error message: ${initRegResponse.error.message}, error data: ${initRegResponse.error.data}` | ||
); | ||
} | ||
const challenge_id = initRegResponse.result.challenge_id; | ||
const cco_str = await aesDecrypt( | ||
initRegResponse.result.encrypted_creation_challenge, | ||
this.aesKey | ||
); | ||
const cco_json = JSON.parse(cco_str) as CredentialCreationOptions; | ||
return { | ||
challenge_id, | ||
cco_json, | ||
}; | ||
} | ||
public async completeRegistration( | ||
encrypted_user: any, | ||
challenge_id: any, | ||
cco_json: any | ||
): Promise<RegistrationResponse> { | ||
if (!this.isCredentialCreator(this.signer)) { | ||
throw new Error("Signer does not support registration."); | ||
} | ||
const attestation = await this.signer.create(cco_json); | ||
const encrypted_attestation = await aesEncrypt(JSON.stringify(attestation), this.aesKey); | ||
const finishRegResult = await this.call("completeRegistration", { | ||
challenge_id, | ||
encrypted_attestation, | ||
encrypted_user, | ||
}); | ||
if (finishRegResult.error) { | ||
throw new Error( | ||
`error message: ${finishRegResult.error.message}, error data: ${finishRegResult.error.data}` | ||
); | ||
} | ||
return finishRegResult; | ||
} | ||
public authenticate = async ( | ||
@@ -233,0 +288,0 @@ params: AuthenticationParams, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63472
1451