Skip to content

Commit

Permalink
feat: fixing snap connect issues (#4560)
Browse files Browse the repository at this point in the history
## Explanation

Profile sync SDK was not exporting any method for connecting to snap.
This PR exports a method to connect to snap after initializing the SDK
  • Loading branch information
dovydas55 authored Jul 26, 2024
1 parent c2f0b5c commit 9c4791c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/profile-sync-controller/src/sdk/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import type { UserProfile, Pair } from './authentication-jwt-bearer/types';
import { AuthType } from './authentication-jwt-bearer/types';
import type { Env } from './env';
import { PairError, UnsupportedAuthTypeError } from './errors';
import { getMetaMaskProviderEIP6963 } from './utils/eip-6963-metamask-provider';
import { connectSnap } from './utils/messaging-signing-snap-requests';

// Computing the Classes, so we only get back the public methods for the interface.
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
Expand Down Expand Up @@ -48,6 +50,15 @@ export class JwtBearerAuth implements SIWEInterface, SRPInterface {
return await this.#sdk.getAccessToken();
}

async connectSnap(): Promise<string> {
const provider = await getMetaMaskProviderEIP6963();
if (!provider) {
throw new Error('failed to get MetaMaskProviderEIP6963 provider');
}
const res = await connectSnap(provider);
return res;
}

async getUserProfile(): Promise<UserProfile> {
return await this.#sdk.getUserProfile();
}
Expand Down

0 comments on commit 9c4791c

Please sign in to comment.