Skip to content

Commit fa17f48

Browse files
Merge pull request #192 from Web3Auth/feat/posboxkey-node-indexes
make postbox key node indexes public
2 parents acfb518 + 82de5d4 commit fa17f48

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export interface JWTLoginParams {
157157
export interface Web3AuthState {
158158
postBoxKey?: string;
159159
signatures?: string[];
160+
postboxKeyNodeIndexes?: number[];
160161
userInfo?: UserInfo;
161162
tssShareIndex?: number;
162163
tssPubKey?: Buffer;
@@ -444,6 +445,7 @@ export interface SessionData {
444445
*/
445446
oAuthKey?: string;
446447
postBoxKey?: string;
448+
postboxKeyNodeIndexes?: number[];
447449
factorKey: string;
448450
tssShareIndex: number;
449451
tssPubKey: string;

src/mpcCoreKit.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ import {
7373
export class Web3AuthMPCCoreKit implements ICoreKit {
7474
public state: Web3AuthState = { accountIndex: 0 };
7575

76-
private options: Web3AuthOptionsWithDefaults;
76+
public torusSp: TSSTorusServiceProvider | null = null;
7777

78-
private torusSp: TSSTorusServiceProvider | null = null;
78+
private options: Web3AuthOptionsWithDefaults;
7979

8080
private storageLayer: TorusStorageLayer | null = null;
8181

@@ -333,6 +333,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
333333

334334
this.updateState({
335335
postBoxKey: this._getPostBoxKey(loginResponse),
336+
postboxKeyNodeIndexes: loginResponse.nodesData?.nodeIndexes,
336337
userInfo: loginResponse.userInfo,
337338
signatures: this._getSignatures(loginResponse.sessionData.sessionTokenData),
338339
});
@@ -347,6 +348,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
347348

348349
this.updateState({
349350
postBoxKey: this._getPostBoxKey(loginResponse),
351+
postboxKeyNodeIndexes: loginResponse.nodesData?.nodeIndexes,
350352
userInfo: loginResponse.userInfo[0],
351353
signatures: this._getSignatures(loginResponse.sessionData.sessionTokenData),
352354
});
@@ -406,6 +408,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
406408

407409
this.updateState({
408410
postBoxKey,
411+
postboxKeyNodeIndexes: loginResponse.nodesData?.nodeIndexes || [],
409412
userInfo: { ...parseToken(idToken), verifier, verifierId },
410413
signatures: this._getSignatures(loginResponse.sessionData.sessionTokenData),
411414
});
@@ -438,6 +441,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
438441
}
439442
this.updateState({
440443
postBoxKey: this._getPostBoxKey(data),
444+
postboxKeyNodeIndexes: data.nodesData?.nodeIndexes || [],
441445
userInfo: data.userInfo,
442446
signatures: this._getSignatures(data.sessionData.sessionTokenData),
443447
});
@@ -450,6 +454,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
450454
}
451455
this.updateState({
452456
postBoxKey: this._getPostBoxKey(data),
457+
postboxKeyNodeIndexes: data.nodesData?.nodeIndexes || [],
453458
userInfo: data.userInfo[0],
454459
signatures: this._getSignatures(data.sessionData.sessionTokenData),
455460
});
@@ -1123,6 +1128,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
11231128
this.updateState({
11241129
factorKey: new BN(result.factorKey, "hex"),
11251130
postBoxKey,
1131+
postboxKeyNodeIndexes: result.postboxKeyNodeIndexes || [],
11261132
tssShareIndex: result.tssShareIndex,
11271133
tssPubKey: this.tkey.getTSSPub().toSEC1(this.tKey.tssCurve, false),
11281134
signatures: result.signatures,
@@ -1134,14 +1140,14 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
11341140
}
11351141

11361142
private async createSession() {
1137-
if (!this.sessionManager) {
1143+
if (!this.options.disableSessionManager && !this.sessionManager) {
11381144
throw new Error("sessionManager is not available");
11391145
}
11401146

11411147
try {
11421148
const sessionId = SessionManager.generateRandomSessionKey();
11431149
this.sessionManager.sessionId = sessionId;
1144-
const { postBoxKey, factorKey, userInfo, tssShareIndex, tssPubKey } = this.state;
1150+
const { postBoxKey, factorKey, userInfo, tssShareIndex, tssPubKey, postboxKeyNodeIndexes } = this.state;
11451151
if (!this.state.factorKey) {
11461152
throw CoreKitError.factorKeyNotPresent("factorKey not present in state when creating session.");
11471153
}
@@ -1153,6 +1159,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
11531159
}
11541160
const payload: SessionData = {
11551161
postBoxKey,
1162+
postboxKeyNodeIndexes: postboxKeyNodeIndexes || [],
11561163
factorKey: factorKey?.toString("hex"),
11571164
tssShareIndex: tssShareIndex as number,
11581165
tssPubKey: Buffer.from(tssPubKey).toString("hex"),

0 commit comments

Comments
 (0)