Skip to content

Commit 32e9a61

Browse files
committed
fix: tests
1 parent f64b4b0 commit 32e9a61

2 files changed

Lines changed: 34 additions & 26 deletions

File tree

src/helpers/nodeUtils.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { INodePub, KEY_TYPE, LEGACY_NETWORKS_ROUTE_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants";
1+
import { INodePub, KEY_TYPE, LEGACY_NETWORKS_ROUTE_MAP, SIGNER_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants";
22
import { generatePrivate, getPublic } from "@toruslabs/eccrypto";
3-
import { generateJsonRPCObject, post } from "@toruslabs/http-helpers";
3+
import { generateJsonRPCObject, get, post } from "@toruslabs/http-helpers";
44

55
import { config } from "../config";
66
import { JRPC_METHODS } from "../constants";
@@ -400,19 +400,35 @@ export async function retrieveOrImportShare(params: {
400400
source,
401401
authorizationServerUrl,
402402
} = params;
403-
await post<void>(
404-
authorizationServerUrl,
405-
{
406-
verifier,
407-
verifier_id: verifierParams.verifier_id,
408-
network,
409-
client_id: clientId,
410-
enable_gating: "true",
411-
...(source ? { source } : {}),
412-
},
413-
{},
414-
{ useAPIKey: true }
415-
);
403+
if (authorizationServerUrl) {
404+
await post<void>(
405+
authorizationServerUrl,
406+
{
407+
verifier,
408+
verifier_id: verifierParams.verifier_id,
409+
network,
410+
client_id: clientId,
411+
enable_gating: "true",
412+
...(source ? { source } : {}),
413+
},
414+
{},
415+
{ useAPIKey: true }
416+
);
417+
} else {
418+
await get<void>(
419+
`${SIGNER_MAP[network]}/api/allow`,
420+
{
421+
headers: {
422+
verifier,
423+
verifierid: verifierParams.verifier_id,
424+
network,
425+
clientid: clientId,
426+
enablegating: "true",
427+
},
428+
},
429+
{ useAPIKey: true }
430+
);
431+
}
416432

417433
// generate temporary private and public key that is used to secure receive shares
418434
const sessionAuthKey = generatePrivate();

src/torus.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
INodePub,
3-
KEY_TYPE,
4-
LEGACY_NETWORKS_ROUTE_MAP,
5-
METADATA_MAP,
6-
SIGNER_MAP,
7-
TORUS_LEGACY_NETWORK_TYPE,
8-
TORUS_NETWORK_TYPE,
9-
} from "@toruslabs/constants";
1+
import { INodePub, KEY_TYPE, LEGACY_NETWORKS_ROUTE_MAP, METADATA_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants";
102
import { setAPIKey, setEmbedHost } from "@toruslabs/http-helpers";
113

124
import { config } from "./config";
@@ -61,7 +53,7 @@ class Torus {
6153

6254
private source?: string;
6355

64-
private authorizationServerUrl: string;
56+
private authorizationServerUrl?: string;
6557

6658
constructor({
6759
enableOneKey = false,
@@ -86,7 +78,7 @@ class Torus {
8678
this.enableOneKey = enableOneKey;
8779
this.legacyMetadataHost = legacyMetadataHost || METADATA_MAP[network as TORUS_LEGACY_NETWORK_TYPE];
8880
this.source = source;
89-
this.authorizationServerUrl = authorizationServerUrl || `${SIGNER_MAP[network]}/api/allow`;
81+
this.authorizationServerUrl = authorizationServerUrl;
9082
}
9183

9284
static enableLogging(v = true): void {

0 commit comments

Comments
 (0)