diff --git a/packages/auth-provider-automerge-repo/src/AuthProvider.ts b/packages/auth-provider-automerge-repo/src/AuthProvider.ts index 188cfc1a..2036403c 100644 --- a/packages/auth-provider-automerge-repo/src/AuthProvider.ts +++ b/packages/auth-provider-automerge-repo/src/AuthProvider.ts @@ -211,9 +211,7 @@ export class AuthProvider extends EventEmitter { * Creates a team and registers it with all of our sync servers. */ public async createTeam(teamName: string) { - if (!this.#user) { - throw new Error('Cannot create team as user is missing on AuthProvider') - } + assert(this.#user, 'Cannot create team as user is missing on AuthProvider') const team = Auth.createTeam(teamName, { device: this.#device, diff --git a/packages/auth/src/connection/getDeviceUserFromGraph.ts b/packages/auth/src/connection/getDeviceUserFromGraph.ts index 7dbf1267..4b6dfcf0 100644 --- a/packages/auth/src/connection/getDeviceUserFromGraph.ts +++ b/packages/auth/src/connection/getDeviceUserFromGraph.ts @@ -43,9 +43,7 @@ export const getDeviceUserFromGraph = ({ const userKeyring = select.keyring(state, { type: USER, name: userId }, starterKeys) const keys = getLatestGeneration(userKeyring) - if (!keys) { - throw new Error('Failed to get device user from graph as there are no keys for user keyring') - } + assert(keys, 'Failed to get device user from graph as there are no keys for user keyring') const user: UserWithSecrets = { userName, userId, keys }