Skip to content

Commit

Permalink
Merge pull request #31 from torusresearch/update
Browse files Browse the repository at this point in the history
fix: jitpack
  • Loading branch information
grvgoel81 authored Sep 2, 2024
2 parents b8c2691 + 9eda59b commit b3c4c2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
jdk:
- openjdk11
install:
- ./gradlew :sdk:build :sdk:publishToMavenLocal
30 changes: 18 additions & 12 deletions sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,27 @@ public CompletableFuture<TorusAggregateLoginResponse> triggerAggregateLogin(Aggr
// All promises would have been resolved correctly by here
userInfoArray.add(userInfoPromise.join());
}
AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams();
aggregateVerifierParams.setVerify_params(new VerifyParams[subVerifierDetailsArray.length]);
aggregateVerifierParams.setSub_verifier_ids(new String[subVerifierDetailsArray.length]);

VerifyParams[] params = new VerifyParams[subVerifierDetailsArray.length];
String[] subVerifierDetails = new String[subVerifierDetailsArray.length];

List<String> aggregateIdTokenSeeds = new ArrayList<>();
String aggregateVerifierId = "";
for (int i = 0; i < subVerifierDetailsArray.length; i++) {
LoginWindowResponse loginParams = loginParamsArray.get(i);
TorusVerifierResponse userInfo = userInfoArray.get(i);
String finalToken = !Helpers.isEmpty(loginParams.getIdToken()) ? loginParams.getIdToken() : loginParams.getAccessToken();
aggregateVerifierParams.setVerifyParamItem(new VerifyParams(userInfo.getVerifierId(), finalToken), i);
aggregateVerifierParams.setSubVerifierIdItem(userInfo.getVerifier(), i);
params[i] =new VerifyParams(userInfo.getVerifierId(), finalToken);
subVerifierDetails[i] = userInfo.getVerifier();
aggregateIdTokenSeeds.add(finalToken);
aggregateVerifierId = userInfo.getVerifierId();
}
Collections.sort(aggregateIdTokenSeeds);
String aggregateTokenString = TextUtils.join(Character.toString((char) 29), aggregateIdTokenSeeds);
String aggregateIdToken = Hash.sha3String(aggregateTokenString).substring(2);
aggregateVerifierParams.setVerifier_id(aggregateVerifierId);

AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(params, subVerifierDetails, aggregateVerifierId);

VerifierParams verifierParams = new VerifierParams(aggregateVerifierParams.getVerifier_id(), null,
aggregateVerifierParams.getSub_verifier_ids(), aggregateVerifierParams.getVerify_params());
try {
Expand Down Expand Up @@ -192,23 +195,26 @@ public TorusKey getTorusKey(String verifier, String verifierId, VerifierParams v
}

public TorusKey getAggregateTorusKey(String verifier, String verifierId, TorusSubVerifierInfo[] subVerifierInfoArray) throws Exception {
AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams();
aggregateVerifierParams.setVerify_params(new VerifyParams[subVerifierInfoArray.length]);
aggregateVerifierParams.setSub_verifier_ids(new String[subVerifierInfoArray.length]);
List<String> aggregateIdTokenSeeds = new ArrayList<>();
String aggregateVerifierId = "";

VerifyParams[] params = new VerifyParams[subVerifierInfoArray.length];
String[] subVerifierDetails = new String[subVerifierInfoArray.length];

for (int i = 0; i < subVerifierInfoArray.length; i++) {
TorusSubVerifierInfo userInfo = subVerifierInfoArray[i];
String finalToken = userInfo.getIdToken();
aggregateVerifierParams.setVerifyParamItem(new VerifyParams(verifierId, finalToken), i);
aggregateVerifierParams.setSubVerifierIdItem(userInfo.getVerifier(), i);
params[i] = new VerifyParams(verifierId, finalToken);
subVerifierDetails[i] = userInfo.getVerifier();
aggregateIdTokenSeeds.add(finalToken);
aggregateVerifierId = verifierId;
}

Collections.sort(aggregateIdTokenSeeds);
String aggregateTokenString = TextUtils.join(Character.toString((char) 29), aggregateIdTokenSeeds);
String aggregateIdToken = Hash.sha3String(aggregateTokenString).substring(2);
aggregateVerifierParams.setVerifier_id(aggregateVerifierId);

AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(params, subVerifierDetails, verifierId);
VerifierParams verifierParams = new VerifierParams(aggregateVerifierParams.getVerifier_id(), null,
aggregateVerifierParams.getSub_verifier_ids(), aggregateVerifierParams.getVerify_params());
return this.getTorusKey(verifier, aggregateVerifierId, verifierParams, aggregateIdToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
package org.torusresearch.customauth.types;

import org.jetbrains.annotations.NotNull;
import org.torusresearch.torusutils.types.VerifyParams;

public class AggregateVerifierParams {
private VerifyParams[] verify_params;
private String[] sub_verifier_ids;
private String verifier_id;

public VerifyParams[] getVerify_params() {
return verify_params;
public AggregateVerifierParams(@NotNull VerifyParams[] verifyParams, @NotNull String[] subVerifierIds, @NotNull String verifierId) {
this.verify_params = verifyParams;
this.sub_verifier_ids = subVerifierIds;
this.verifier_id = verifierId;
}

public void setVerify_params(VerifyParams[] verify_params) {
this.verify_params = verify_params;
}

public void setVerifyParamItem(VerifyParams verify_param, int index) {
this.verify_params[index] = verify_param;
public VerifyParams[] getVerify_params() {
return verify_params;
}

public String[] getSub_verifier_ids() {
return sub_verifier_ids;
}

public void setSub_verifier_ids(String[] sub_verifier_ids) {
this.sub_verifier_ids = sub_verifier_ids;
}

public void setSubVerifierIdItem(String sub_verifier_id, int index) {
this.sub_verifier_ids[index] = sub_verifier_id;
}

public String getVerifier_id() {
return verifier_id;
}

public void setVerifier_id(String verifier_id) {
this.verifier_id = verifier_id;
}
}

0 comments on commit b3c4c2a

Please sign in to comment.