Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/account/tests/signer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,17 @@ describe('Account signer', () => {

beforeEach(async () => {
class LocalRelayerWithFee extends LocalRelayer {
public feeOptions: FeeOption[]
public quote: FeeQuote

constructor(
options: LocalRelayerOptions | ethers.Signer,
public feeOptions: FeeOption[],
public quote: FeeQuote
feeOptions: FeeOption[],
quote: FeeQuote
) {
super(options)
this.feeOptions = feeOptions
this.quote = quote
}

async getFeeOptions(
Expand Down
81 changes: 73 additions & 8 deletions packages/guard/src/guard.gen.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable */
// sequence-guard v0.4.0 776b307c2145ac7a994eec63240acae042c96067
// sequence-guard v0.5.0 910e01c32ffb24b42386d4ca6be119b0acc55c5f
// --
// Code generated by [email protected] with typescript generator. DO NOT EDIT.
//
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts

export const WebrpcHeader = 'Webrpc'

export const WebrpcHeaderValue = '[email protected];[email protected];sequence-guard@v0.4.0'
export const WebrpcHeaderValue = '[email protected];[email protected];sequence-guard@v0.5.0'

// WebRPC description and code-gen version
export const WebRPCVersion = 'v1'

// Schema version of your RIDL schema
export const WebRPCSchemaVersion = 'v0.4.0'
export const WebRPCSchemaVersion = 'v0.5.0'

// Schema hash generated from your RIDL schema
export const WebRPCSchemaHash = '776b307c2145ac7a994eec63240acae042c96067'
export const WebRPCSchemaHash = '910e01c32ffb24b42386d4ca6be119b0acc55c5f'

type WebrpcGenVersions = {
webrpcGenVersion: string
Expand Down Expand Up @@ -70,6 +70,20 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
// Types
//

export enum PayloadType {
Calls = 'Calls',
Message = 'Message',
ConfigUpdate = 'ConfigUpdate',
SessionImplicitAuthorize = 'SessionImplicitAuthorize'
}

export enum SignatureType {
Hash = 'Hash',
Sapient = 'Sapient',
EthSign = 'EthSign',
Erc1271 = 'Erc1271'
}

export interface Version {
webrpcVersion: string
schemaVersion: string
Expand Down Expand Up @@ -99,26 +113,39 @@ export interface WalletSigner {
export interface SignRequest {
chainId: number
msg: string
auxData: string
auxData?: string
wallet?: string
payloadType?: PayloadType
payloadData?: string
signatures?: Array<Signature>
}

export interface OwnershipProof {
wallet: string
timestamp: number
signer: string
signature: string
chainId: number
}

export interface AuthToken {
id: string
token: string
resetAuth?: boolean
}

export interface RecoveryCode {
code: string
used: boolean
}

export interface Signature {
address: string
type: SignatureType
imageHash?: string
data: string
}

export interface Guard {
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
Expand Down Expand Up @@ -242,18 +269,21 @@ export interface SetPINArgs {
pin: string
timestamp: number
signature: string
chainId: number
}

export interface SetPINReturn {}
export interface ResetPINArgs {
timestamp: number
signature: string
chainId: number
}

export interface ResetPINReturn {}
export interface CreateTOTPArgs {
timestamp: number
signature: string
chainId: number
}

export interface CreateTOTPReturn {
Expand All @@ -269,6 +299,7 @@ export interface CommitTOTPReturn {
export interface ResetTOTPArgs {
timestamp: number
signature: string
chainId: number
}

export interface ResetTOTPReturn {}
Expand All @@ -281,6 +312,7 @@ export interface Reset2FAReturn {}
export interface RecoveryCodesArgs {
timestamp: number
signature: string
chainId: number
}

export interface RecoveryCodesReturn {
Expand All @@ -289,6 +321,7 @@ export interface RecoveryCodesReturn {
export interface ResetRecoveryCodesArgs {
timestamp: number
signature: string
chainId: number
}

export interface ResetRecoveryCodesReturn {
Expand Down Expand Up @@ -931,6 +964,32 @@ export class NotFoundError extends WebrpcError {
}
}

export class RequiresTOTPError extends WebrpcError {
constructor(
name: string = 'RequiresTOTP',
code: number = 6600,
message: string = `TOTP is required`,
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, RequiresTOTPError.prototype)
}
}

export class RequiresPINError extends WebrpcError {
constructor(
name: string = 'RequiresPIN',
code: number = 6601,
message: string = `PIN is required`,
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, RequiresPINError.prototype)
}
}

export enum errors {
WebrpcEndpoint = 'WebrpcEndpoint',
WebrpcRequestFailed = 'WebrpcRequestFailed',
Expand All @@ -955,7 +1014,9 @@ export enum errors {
Unavailable = 'Unavailable',
QueryFailed = 'QueryFailed',
ValidationFailed = 'ValidationFailed',
NotFound = 'NotFound'
NotFound = 'NotFound',
RequiresTOTP = 'RequiresTOTP',
RequiresPIN = 'RequiresPIN'
}

export enum WebrpcErrorCodes {
Expand All @@ -982,7 +1043,9 @@ export enum WebrpcErrorCodes {
Unavailable = 2002,
QueryFailed = 2003,
ValidationFailed = 2004,
NotFound = 3000
NotFound = 3000,
RequiresTOTP = 6600,
RequiresPIN = 6601
}

export const webrpcErrorByCode: { [code: number]: any } = {
Expand All @@ -1009,7 +1072,9 @@ export const webrpcErrorByCode: { [code: number]: any } = {
[2002]: UnavailableError,
[2003]: QueryFailedError,
[2004]: ValidationFailedError,
[3000]: NotFoundError
[3000]: NotFoundError,
[6600]: RequiresTOTPError,
[6601]: RequiresPINError
}

export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
18 changes: 10 additions & 8 deletions packages/guard/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class GuardSigner implements signers.SapientSigner {
wallet: signedProof.walletAddress,
timestamp: signedProof.timestamp.getTime(),
signer: signedProof.signerAddress,
signature: signedProof.signature
signature: signedProof.signature,
chainId: 1
}
})
}
Expand All @@ -104,12 +105,12 @@ export class GuardSigner implements signers.SapientSigner {

if (pin === undefined) {
await this.guard.resetPIN(
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)
} else {
await this.guard.setPIN(
{ pin, timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ pin, timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)
}
Expand All @@ -123,7 +124,7 @@ export class GuardSigner implements signers.SapientSigner {
const signedProof = await signAuthUpdateProof(proof)

const { uri } = await this.guard.createTOTP(
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)

Expand All @@ -139,7 +140,7 @@ export class GuardSigner implements signers.SapientSigner {
const signedProof = await signAuthUpdateProof(proof)

await this.guard.resetTOTP(
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)
}
Expand All @@ -156,7 +157,8 @@ export class GuardSigner implements signers.SapientSigner {
wallet: signedProof.walletAddress,
timestamp: signedProof.timestamp.getTime(),
signer: signedProof.signerAddress,
signature: signedProof.signature
signature: signedProof.signature,
chainId: 1
}
})
}
Expand All @@ -166,7 +168,7 @@ export class GuardSigner implements signers.SapientSigner {
const signedProof = await signAuthUpdateProof(proof)

const { codes } = await this.guard.recoveryCodes(
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)

Expand All @@ -177,7 +179,7 @@ export class GuardSigner implements signers.SapientSigner {
const signedProof = await signAuthUpdateProof(proof)

const { codes } = await this.guard.resetRecoveryCodes(
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
{ Authorization: `BEARER ${proof.jwt}` }
)

Expand Down
Loading