@farcaster/miniapp-sdk 0.1.8 → 0.1.10
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 +11 -11
- package/dist/index.min.js.map +4 -4
- package/dist/sdk.js +19 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +2 -2
- package/src/sdk.ts +23 -2
- package/src/types.ts +2 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddMiniApp, ComposeCast, Context, GetCapabilities, GetChains, ImpactOccurred, MiniAppNotificationDetails, NotificationOccurred, OpenMiniApp, Ready, RequestCameraAndMicrophoneAccess, SelectionChanged, SendToken, SetPrimaryButtonOptions, SignIn, SolanaWalletProvider, SwapToken, ViewCast, ViewProfile, ViewToken } from '@farcaster/miniapp-core';
|
|
1
|
+
import type { AddMiniApp, ComposeCast, Context, GetCapabilities, GetChains, ImpactOccurred, MiniAppNotificationDetails, NotificationOccurred, OpenMiniApp, Ready, RequestCameraAndMicrophoneAccess, SelectionChanged, SendToken, SetPrimaryButtonOptions, SignIn, SignManifest, SolanaWalletProvider, SwapToken, ViewCast, ViewProfile, ViewToken } from '@farcaster/miniapp-core';
|
|
2
2
|
import type { EventEmitter } from 'eventemitter3';
|
|
3
3
|
import type * as Provider from 'ox/Provider';
|
|
4
4
|
import type { Back } from './back.ts';
|
|
@@ -59,6 +59,7 @@ export type MiniAppSDK = {
|
|
|
59
59
|
};
|
|
60
60
|
experimental: {
|
|
61
61
|
getSolanaProvider: () => Promise<SolanaWalletProvider | undefined>;
|
|
62
|
+
signManifest: SignManifest.SignManifest;
|
|
62
63
|
/**
|
|
63
64
|
* @deprecated - use `sdk.quickAuth.getToken`
|
|
64
65
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farcaster/miniapp-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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/miniapp-core": "0.3.
|
|
26
|
+
"@farcaster/miniapp-core": "0.3.9"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"clean": "rm -rf dist",
|
package/src/sdk.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
AddMiniApp,
|
|
3
3
|
type MiniAppClientEvent,
|
|
4
4
|
SignIn,
|
|
5
|
+
SignManifest,
|
|
5
6
|
} from '@farcaster/miniapp-core'
|
|
6
7
|
import { createBack } from './back.ts'
|
|
7
8
|
import { ethereumProvider, getEthereumProvider } from './ethereumProvider.ts'
|
|
@@ -16,10 +17,10 @@ let cachedIsInMiniAppResult: boolean | null = null
|
|
|
16
17
|
/**
|
|
17
18
|
* Determines if the current environment is a MiniApp context.
|
|
18
19
|
*
|
|
19
|
-
* @param timeoutMs - Optional timeout in milliseconds (default:
|
|
20
|
+
* @param timeoutMs - Optional timeout in milliseconds (default: 1000)
|
|
20
21
|
* @returns Promise resolving to boolean indicating if in MiniApp context
|
|
21
22
|
*/
|
|
22
|
-
async function isInMiniApp(timeoutMs =
|
|
23
|
+
async function isInMiniApp(timeoutMs = 1000): Promise<boolean> {
|
|
23
24
|
// Return cached result if we've already determined we are in a MiniApp
|
|
24
25
|
if (cachedIsInMiniAppResult === true) {
|
|
25
26
|
return true
|
|
@@ -119,6 +120,26 @@ export const sdk: MiniAppSDK = {
|
|
|
119
120
|
},
|
|
120
121
|
experimental: {
|
|
121
122
|
getSolanaProvider,
|
|
123
|
+
signManifest: async (options) => {
|
|
124
|
+
const response = await miniAppHost.signManifest(options)
|
|
125
|
+
if (response.result) {
|
|
126
|
+
return response.result
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (response.error.type === 'rejected_by_user') {
|
|
130
|
+
throw new SignManifest.RejectedByUser()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (response.error.type === 'invalid_domain') {
|
|
134
|
+
throw new SignManifest.InvalidDomain()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (response.error.type === 'generic_error') {
|
|
138
|
+
throw new SignManifest.GenericError(response.error.message)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
throw new Error('Unreachable')
|
|
142
|
+
},
|
|
122
143
|
quickAuth(options) {
|
|
123
144
|
return quickAuth.getToken(options)
|
|
124
145
|
},
|
package/src/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
SendToken,
|
|
15
15
|
SetPrimaryButtonOptions,
|
|
16
16
|
SignIn,
|
|
17
|
+
SignManifest,
|
|
17
18
|
SolanaWalletProvider,
|
|
18
19
|
SwapToken,
|
|
19
20
|
ViewCast,
|
|
@@ -93,6 +94,7 @@ export type MiniAppSDK = {
|
|
|
93
94
|
}
|
|
94
95
|
experimental: {
|
|
95
96
|
getSolanaProvider: () => Promise<SolanaWalletProvider | undefined>
|
|
97
|
+
signManifest: SignManifest.SignManifest
|
|
96
98
|
|
|
97
99
|
/**
|
|
98
100
|
* @deprecated - use `sdk.quickAuth.getToken`
|