@farcaster/frame-sdk 0.0.45 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { AddMiniApp, SignIn, } from '@farcaster/frame-core';
2
+ import { createLightClient } from '@farcaster/quick-auth/light';
2
3
  import { EventEmitter } from 'eventemitter3';
4
+ import * as Siwe from 'ox/Siwe';
3
5
  import { ethereumProvider, getEthereumProvider } from './ethereumProvider';
4
6
  import { frameHost } from './frameHost';
5
7
  import { getSolanaProvider } from './solanaProvider';
@@ -110,6 +112,32 @@ export const sdk = {
110
112
  },
111
113
  experimental: {
112
114
  getSolanaProvider,
115
+ quickAuth: async (options = {}) => {
116
+ const quickAuth = createLightClient({
117
+ origin: options.quickAuthServerOrigin,
118
+ });
119
+ const { nonce } = await quickAuth.generateNonce();
120
+ const response = await frameHost.signIn({
121
+ nonce,
122
+ });
123
+ if (response.result) {
124
+ const parsedSiwe = Siwe.parseMessage(response.result.message);
125
+ // The Farcaster Client rendering the Mini App will set the domain
126
+ // based on the URL it's rendering. It should always be set.
127
+ if (!parsedSiwe.domain) {
128
+ throw new Error('Missing domain on SIWE message');
129
+ }
130
+ return await quickAuth.verifySiwf({
131
+ domain: parsedSiwe.domain,
132
+ message: response.result.message,
133
+ signature: response.result.signature,
134
+ });
135
+ }
136
+ if (response.error.type === 'rejected_by_user') {
137
+ throw new SignIn.RejectedByUser();
138
+ }
139
+ throw new Error('Unreachable');
140
+ },
113
141
  },
114
142
  wallet: {
115
143
  ethProvider: ethereumProvider,