Skip to content

Commit

Permalink
feat: adds preAuthenticateToInboxCallback before signature request
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Aug 1, 2024
1 parent 8b97ffe commit ad77903
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 2 additions & 5 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ test('can make a MLS V3 client', async () => {
return true
})


test('calls preAuthenticateToInboxCallback when supplied', async () => {
let isCallbackCalled = 0
let isPreAuthCalled = false
const preAuthenticateToInboxCallback = () => {
isCallbackCalled++;
isCallbackCalled++
isPreAuthCalled = true
}
const preEnableIdentityCallback = () => {
Expand All @@ -65,11 +64,9 @@ test('calls preAuthenticateToInboxCallback when supplied', async () => {
}
const keyBytes = new Uint8Array([
233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64,
166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135,
145,
166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145,
])


await Client.createRandom({
env: 'local',
enableV3: true,
Expand Down
19 changes: 12 additions & 7 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ export class Client<
enableSubscription?: Subscription,
authInboxSubscription?: Subscription
): void {
[createSubscription, enableSubscription, authInboxSubscription, this.signSubscription, this.authSubscription]
.forEach(subscription => subscription?.remove());

this.signSubscription = null;
this.authSubscription = null;
;[
createSubscription,
enableSubscription,
authInboxSubscription,
this.signSubscription,
this.authSubscription,
].forEach((subscription) => subscription?.remove())

this.signSubscription = null
this.authSubscription = null
}

/**
Expand Down Expand Up @@ -328,10 +333,10 @@ export class Client<

/**
* Static method to determine the inboxId for the address.
*
*
* @param {string} peerAddress - The address of the peer to check for messaging eligibility.
* @param {Partial<ClientOptions>} opts - Optional configuration options for the Client.
* @returns {Promise<InboxId>}
* @returns {Promise<InboxId>}
*/
static async getOrCreateInboxId(
address: string,
Expand Down

0 comments on commit ad77903

Please sign in to comment.