Skip to content

Commit

Permalink
Minor enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
yashovardhan committed Jun 12, 2024
1 parent be39fa4 commit 3bd7214
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/service-provider-sfa/src/SfaServiceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SfaServiceProvider extends ServiceProviderBase {

public torusKey: TorusKey;

public migratableKey: BN | null = null;
public migratableKey: BN | null = null; // Migration of key from SFA to tKey

private nodeDetailManagerInstance: NodeDetailManager;

Expand Down Expand Up @@ -79,10 +79,10 @@ class SfaServiceProvider extends ServiceProviderBase {

const torusKey = await this.authInstance.retrieveShares(torusNodeEndpoints, torusIndexes, verifier, finalVerifierParams, finalIdToken);
this.torusKey = torusKey;
const { finalKeyData, oAuthKeyData } = torusKey;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;

if (!torusKey.metadata.upgraded) {
const { finalKeyData, oAuthKeyData } = torusKey;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;
this.migratableKey = new BN(privKey, "hex");
}
const postboxKey = Torus.getPostboxKey(torusKey);
Expand Down
10 changes: 5 additions & 5 deletions packages/service-provider-torus/src/TorusServiceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class TorusServiceProvider extends ServiceProviderBase {
if (obj) {
const localPrivKey = Torus.getPostboxKey(obj);
this.torusKey = obj;
const { finalKeyData, oAuthKeyData } = obj;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;

if (!obj.metadata.upgraded) {
const { finalKeyData, oAuthKeyData } = obj;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;
this.migratableKey = new BN(privKey, "hex");
}

Expand All @@ -78,10 +78,10 @@ class TorusServiceProvider extends ServiceProviderBase {
if (obj) {
const localPrivKey = Torus.getPostboxKey(obj);
this.torusKey = obj;
const { finalKeyData, oAuthKeyData } = obj;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;

if (!obj.metadata.upgraded) {
const { finalKeyData, oAuthKeyData } = obj;
const privKey = finalKeyData.privKey || oAuthKeyData.privKey;
this.migratableKey = new BN(privKey, "hex");
}

Expand All @@ -95,12 +95,12 @@ class TorusServiceProvider extends ServiceProviderBase {
*/
async triggerHybridAggregateLogin(params: HybridAggregateLoginParams): Promise<TorusHybridAggregateLoginResponse> {
const obj = await this.customAuthInstance.triggerHybridAggregateLogin(params);
this.torusKey = null; // Since there are multiple keys, we don't set the torusKey here.

// `obj` maybe `null` in redirect mode.
if (obj) {
const aggregateLoginKey = Torus.getPostboxKey(obj.aggregateLogins[0]);
const singleLoginKey = Torus.getPostboxKey(obj.singleLogin);
this.torusKey = null;
this.postboxKey = new BN(aggregateLoginKey, "hex");
this.singleLoginKey = new BN(singleLoginKey, "hex");
}
Expand Down

0 comments on commit 3bd7214

Please sign in to comment.