@farcaster/frame-sdk 0.0.58 → 0.0.60

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/types.d.ts CHANGED
@@ -30,6 +30,17 @@ export type EventMap = {
30
30
  };
31
31
  export type Emitter = Compute<EventEmitter<EventMap>>;
32
32
  type SetPrimaryButton = (options: SetPrimaryButtonOptions) => Promise<void>;
33
+ type QuickAuth = (options?: {
34
+ /**
35
+ * Use a custom Quick Auth server, otherwise defaults to the public
36
+ * instance provided by Farcaster.
37
+ *
38
+ * @default https://auth.farcaster.xyz
39
+ */
40
+ quickAuthServerOrigin?: string;
41
+ }) => Promise<{
42
+ token: string;
43
+ }>;
33
44
  export type FrameSDK = {
34
45
  getCapabilities: GetCapabilities;
35
46
  getChains: GetChains;
@@ -50,20 +61,14 @@ export type FrameSDK = {
50
61
  viewToken: ViewToken.ViewToken;
51
62
  sendToken: SendToken.SendToken;
52
63
  swapToken: SwapToken.SwapToken;
64
+ quickAuth: QuickAuth;
53
65
  };
54
66
  experimental: {
55
67
  getSolanaProvider: () => Promise<SolanaWalletProvider | undefined>;
56
- quickAuth: (options?: {
57
- /**
58
- * Use a custom Quick Auth server, otherwise defaults to the public
59
- * instance provided by Farcaster.
60
- *
61
- * @default https://auth.farcaster.xyz
62
- */
63
- quickAuthServerOrigin?: string;
64
- }) => Promise<{
65
- token: string;
66
- }>;
68
+ /**
69
+ * @deprecated - use `sdk.actions.quickAuth`
70
+ */
71
+ quickAuth: QuickAuth;
67
72
  };
68
73
  wallet: {
69
74
  ethProvider: Provider.Provider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/frame-sdk",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "comlink": "^4.4.2",
24
24
  "eventemitter3": "^5.0.1",
25
25
  "ox": "^0.4.4",
26
- "@farcaster/frame-core": "0.1.7"
26
+ "@farcaster/frame-core": "0.1.8"
27
27
  },
28
28
  "scripts": {
29
29
  "clean": "rm -rf dist",
package/src/sdk.ts CHANGED
@@ -55,6 +55,40 @@ async function isInMiniApp(timeoutMs = 50): Promise<boolean> {
55
55
  return isInMiniApp
56
56
  }
57
57
 
58
+ const quickAuth: FrameSDK['actions']['quickAuth'] = async (options = {}) => {
59
+ const quickAuthClient = createLightClient({
60
+ origin: options.quickAuthServerOrigin,
61
+ })
62
+
63
+ const { nonce } = await quickAuthClient.generateNonce()
64
+ const response = await frameHost.signIn({
65
+ nonce,
66
+ acceptAuthAddress: true,
67
+ })
68
+
69
+ if (response.result) {
70
+ const parsedSiwe = Siwe.parseMessage(response.result.message)
71
+
72
+ // The Farcaster Client rendering the Mini App will set the domain
73
+ // based on the URL it's rendering. It should always be set.
74
+ if (!parsedSiwe.domain) {
75
+ throw new Error('Missing domain on SIWE message')
76
+ }
77
+
78
+ return await quickAuthClient.verifySiwf({
79
+ domain: parsedSiwe.domain,
80
+ message: response.result.message,
81
+ signature: response.result.signature,
82
+ })
83
+ }
84
+
85
+ if (response.error.type === 'rejected_by_user') {
86
+ throw new SignIn.RejectedByUser()
87
+ }
88
+
89
+ throw new Error('Unreachable')
90
+ }
91
+
58
92
  const addMiniApp = async () => {
59
93
  const response = await frameHost.addFrame()
60
94
  if (response.result) {
@@ -111,42 +145,11 @@ export const sdk: FrameSDK = {
111
145
  viewToken: frameHost.viewToken.bind(frameHost),
112
146
  sendToken: frameHost.sendToken.bind(frameHost),
113
147
  swapToken: frameHost.swapToken.bind(frameHost),
148
+ quickAuth,
114
149
  },
115
150
  experimental: {
116
151
  getSolanaProvider,
117
- quickAuth: async (options = {}) => {
118
- const quickAuth = createLightClient({
119
- origin: options.quickAuthServerOrigin,
120
- })
121
-
122
- const { nonce } = await quickAuth.generateNonce()
123
- const response = await frameHost.signIn({
124
- nonce,
125
- acceptAuthAddress: true,
126
- })
127
-
128
- if (response.result) {
129
- const parsedSiwe = Siwe.parseMessage(response.result.message)
130
-
131
- // The Farcaster Client rendering the Mini App will set the domain
132
- // based on the URL it's rendering. It should always be set.
133
- if (!parsedSiwe.domain) {
134
- throw new Error('Missing domain on SIWE message')
135
- }
136
-
137
- return await quickAuth.verifySiwf({
138
- domain: parsedSiwe.domain,
139
- message: response.result.message,
140
- signature: response.result.signature,
141
- })
142
- }
143
-
144
- if (response.error.type === 'rejected_by_user') {
145
- throw new SignIn.RejectedByUser()
146
- }
147
-
148
- throw new Error('Unreachable')
149
- },
152
+ quickAuth,
150
153
  },
151
154
  wallet: {
152
155
  ethProvider: ethereumProvider,
package/src/types.ts CHANGED
@@ -58,6 +58,17 @@ export type EventMap = {
58
58
  export type Emitter = Compute<EventEmitter<EventMap>>
59
59
 
60
60
  type SetPrimaryButton = (options: SetPrimaryButtonOptions) => Promise<void>
61
+ type QuickAuth = (options?: {
62
+ /**
63
+ * Use a custom Quick Auth server, otherwise defaults to the public
64
+ * instance provided by Farcaster.
65
+ *
66
+ * @default https://auth.farcaster.xyz
67
+ */
68
+ quickAuthServerOrigin?: string
69
+ }) => Promise<{
70
+ token: string
71
+ }>
61
72
 
62
73
  export type FrameSDK = {
63
74
  getCapabilities: GetCapabilities
@@ -82,20 +93,15 @@ export type FrameSDK = {
82
93
  viewToken: ViewToken.ViewToken
83
94
  sendToken: SendToken.SendToken
84
95
  swapToken: SwapToken.SwapToken
96
+ quickAuth: QuickAuth
85
97
  }
86
98
  experimental: {
87
99
  getSolanaProvider: () => Promise<SolanaWalletProvider | undefined>
88
- quickAuth: (options?: {
89
- /**
90
- * Use a custom Quick Auth server, otherwise defaults to the public
91
- * instance provided by Farcaster.
92
- *
93
- * @default https://auth.farcaster.xyz
94
- */
95
- quickAuthServerOrigin?: string
96
- }) => Promise<{
97
- token: string
98
- }>
100
+
101
+ /**
102
+ * @deprecated - use `sdk.actions.quickAuth`
103
+ */
104
+ quickAuth: QuickAuth
99
105
  }
100
106
  wallet: {
101
107
  // Deprecated in favor of getEthereumProvider