11import { Signers as CoreSigners , Relayer , State } from '@0xsequence/wallet-core'
2+
23import {
34 Attestation ,
45 Config ,
@@ -10,6 +11,7 @@ import {
1011 SessionConfig ,
1112 Signature as SequenceSignature ,
1213} from '@0xsequence/wallet-primitives'
14+ import { createAttestationVerifyingFetch } from '@0xsequence/tee-verifier'
1315import { Address } from 'ox'
1416import * as Db from '../dbs/index.js'
1517import * as Identity from '../identity/index.js'
@@ -63,6 +65,8 @@ export type ManagerOptions = {
6365 identity ?: {
6466 url ?: string
6567 fetch ?: typeof window . fetch
68+ verifyAttestation ?: boolean
69+ expectedPcr0 ?: string [ ]
6670 email ?: {
6771 enabled : boolean
6872 }
@@ -121,6 +125,7 @@ export const ManagerOptionsDefaults = {
121125 // TODO: change to prod url once deployed
122126 url : 'https://dev-identity.sequence-dev.app' ,
123127 fetch : window . fetch ,
128+ verifyAttestation : true ,
124129 email : {
125130 enabled : false ,
126131 } ,
@@ -272,12 +277,19 @@ export class Manager {
272277
273278 this . mnemonicHandler = new MnemonicHandler ( modules . signatures )
274279 shared . handlers . set ( Kinds . LoginMnemonic , this . mnemonicHandler )
275-
280+
276281 this . recoveryHandler = new RecoveryHandler ( modules . signatures , modules . recovery )
277282 shared . handlers . set ( Kinds . Recovery , this . recoveryHandler )
278283
279- // TODO: configurable nitro rpc
280- const nitro = new Identity . IdentityInstrument ( ops . identity . url , ops . identity . fetch )
284+ const verifyingFetch = ops . identity . verifyAttestation
285+ ? createAttestationVerifyingFetch ( {
286+ fetch : ops . identity . fetch ,
287+ expectedPCRs : ops . identity . expectedPcr0 ? new Map ( [ [ 0 , ops . identity . expectedPcr0 ] ] ) : undefined ,
288+ logTiming : true ,
289+ } )
290+ : ops . identity . fetch
291+ const nitro = new Identity . IdentityInstrument ( ops . identity . url , verifyingFetch )
292+
281293 if ( ops . identity . email ?. enabled ) {
282294 this . otpHandler = new OtpHandler ( nitro , modules . signatures , shared . databases . authKeys )
283295 shared . handlers . set ( Kinds . LoginEmailOtp , this . otpHandler )
0 commit comments