@farcaster/frame-sdk 0.0.58 → 0.0.59
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/index.min.js +7 -7
- package/dist/index.min.js.map +3 -3
- package/dist/sdk.js +29 -27
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +16 -11
- package/package.json +1 -1
- package/src/sdk.ts +36 -33
- package/src/types.ts +17 -11
package/dist/sdk.js
CHANGED
|
@@ -42,6 +42,33 @@ async function isInMiniApp(timeoutMs = 50) {
|
|
|
42
42
|
}
|
|
43
43
|
return isInMiniApp;
|
|
44
44
|
}
|
|
45
|
+
const quickAuth = async (options = {}) => {
|
|
46
|
+
const quickAuthClient = createLightClient({
|
|
47
|
+
origin: options.quickAuthServerOrigin,
|
|
48
|
+
});
|
|
49
|
+
const { nonce } = await quickAuthClient.generateNonce();
|
|
50
|
+
const response = await frameHost.signIn({
|
|
51
|
+
nonce,
|
|
52
|
+
acceptAuthAddress: true,
|
|
53
|
+
});
|
|
54
|
+
if (response.result) {
|
|
55
|
+
const parsedSiwe = Siwe.parseMessage(response.result.message);
|
|
56
|
+
// The Farcaster Client rendering the Mini App will set the domain
|
|
57
|
+
// based on the URL it's rendering. It should always be set.
|
|
58
|
+
if (!parsedSiwe.domain) {
|
|
59
|
+
throw new Error('Missing domain on SIWE message');
|
|
60
|
+
}
|
|
61
|
+
return await quickAuthClient.verifySiwf({
|
|
62
|
+
domain: parsedSiwe.domain,
|
|
63
|
+
message: response.result.message,
|
|
64
|
+
signature: response.result.signature,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (response.error.type === 'rejected_by_user') {
|
|
68
|
+
throw new SignIn.RejectedByUser();
|
|
69
|
+
}
|
|
70
|
+
throw new Error('Unreachable');
|
|
71
|
+
};
|
|
45
72
|
const addMiniApp = async () => {
|
|
46
73
|
const response = await frameHost.addFrame();
|
|
47
74
|
if (response.result) {
|
|
@@ -92,36 +119,11 @@ export const sdk = {
|
|
|
92
119
|
viewToken: frameHost.viewToken.bind(frameHost),
|
|
93
120
|
sendToken: frameHost.sendToken.bind(frameHost),
|
|
94
121
|
swapToken: frameHost.swapToken.bind(frameHost),
|
|
122
|
+
quickAuth,
|
|
95
123
|
},
|
|
96
124
|
experimental: {
|
|
97
125
|
getSolanaProvider,
|
|
98
|
-
quickAuth
|
|
99
|
-
const quickAuth = createLightClient({
|
|
100
|
-
origin: options.quickAuthServerOrigin,
|
|
101
|
-
});
|
|
102
|
-
const { nonce } = await quickAuth.generateNonce();
|
|
103
|
-
const response = await frameHost.signIn({
|
|
104
|
-
nonce,
|
|
105
|
-
acceptAuthAddress: true,
|
|
106
|
-
});
|
|
107
|
-
if (response.result) {
|
|
108
|
-
const parsedSiwe = Siwe.parseMessage(response.result.message);
|
|
109
|
-
// The Farcaster Client rendering the Mini App will set the domain
|
|
110
|
-
// based on the URL it's rendering. It should always be set.
|
|
111
|
-
if (!parsedSiwe.domain) {
|
|
112
|
-
throw new Error('Missing domain on SIWE message');
|
|
113
|
-
}
|
|
114
|
-
return await quickAuth.verifySiwf({
|
|
115
|
-
domain: parsedSiwe.domain,
|
|
116
|
-
message: response.result.message,
|
|
117
|
-
signature: response.result.signature,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (response.error.type === 'rejected_by_user') {
|
|
121
|
-
throw new SignIn.RejectedByUser();
|
|
122
|
-
}
|
|
123
|
-
throw new Error('Unreachable');
|
|
124
|
-
},
|
|
126
|
+
quickAuth,
|
|
125
127
|
},
|
|
126
128
|
wallet: {
|
|
127
129
|
ethProvider: ethereumProvider,
|