Skip to content

Commit

Permalink
waas: replace tenant / secret with AccessKey
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Jan 16, 2024
1 parent ab77f5d commit 749b19c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/waas/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ import { SignMessageArgs } from './payloads/packets/messages'
import { SimpleNetwork, WithSimpleNetwork } from './networks'
import { TEMPLATE_LOCAL } from './defaults'
import { EmailAuth } from './email'
import { base64 } from "ethers/lib/utils";
import { BigNumber } from "ethers";

export type Sessions = (Session & { isThis: boolean })[]

export type SequenceExplicitConfig = {
secret: string
tenant: number
accessKey: string

emailClientId?: string
identityPoolId: string
Expand Down Expand Up @@ -109,12 +110,8 @@ export function defaultArgsOrFail(
preconfig.network = 1
}

if (preconfig.tenant === undefined) {
throw new Error('Missing tenant')
}

if (preconfig.secret === undefined) {
throw new Error('Missing secret')
if (preconfig.accessKey === undefined) {
throw new Error('Missing access key')
}

if (preconfig.identityPoolId === undefined) {
Expand Down Expand Up @@ -255,8 +252,7 @@ export class Sequence {

return {
headers: {
'X-Sequence-Tenant': this.config.tenant
// 'X-Sequence-Secret': this.config.secret,
'X-Access-Key': this.config.accessKey
},
args: { encryptedPayloadKey, payloadCiphertext, payloadSig }
}
Expand Down Expand Up @@ -294,8 +290,12 @@ export class Sequence {

await this.saveCypherKey(kmsClient)

const projectId = BigNumber.from(
base64.decode(this.config.accessKey).slice(-8)
)

const payload: RegisterSessionPayload = {
projectId: this.config.tenant,
projectId: projectId.toNumber(),
idToken: creds.idToken,
sessionAddress: waaspayload.packet.session,
friendlyName: name,
Expand Down

0 comments on commit 749b19c

Please sign in to comment.