@farcaster/miniapp-core 0.3.7 → 0.3.9

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.
@@ -0,0 +1,77 @@
1
+ import * as Errors from '../errors.ts'
2
+ import type { OneOf } from '../internal/types.ts'
3
+
4
+ export type SignManifestOptions = {
5
+ domain: string
6
+ }
7
+
8
+ export type SignManifestResult = {
9
+ header: string
10
+ payload: string
11
+ signature: string
12
+ }
13
+
14
+ export type SignManifest = (
15
+ options: SignManifestOptions,
16
+ ) => Promise<SignManifestResult>
17
+
18
+ type RejectedByUserJsonError = {
19
+ type: 'rejected_by_user'
20
+ }
21
+
22
+ type InvalidDomainJsonError = {
23
+ type: 'invalid_domain'
24
+ }
25
+
26
+ type GenericErrorJsonError = {
27
+ type: 'generic_error'
28
+ message?: string
29
+ }
30
+
31
+ export type SignManifestJsonError =
32
+ | RejectedByUserJsonError
33
+ | InvalidDomainJsonError
34
+ | GenericErrorJsonError
35
+
36
+ export type SignManifestRejectedReason = SignManifestJsonError['type']
37
+
38
+ export type SignManifestJsonResult = OneOf<
39
+ { result: SignManifestResult } | { error: SignManifestJsonError }
40
+ >
41
+
42
+ export type WireSignManifest = (
43
+ options: SignManifestOptions,
44
+ ) => Promise<SignManifestJsonResult>
45
+
46
+ /**
47
+ * Thrown when sign manifest action was rejected by the user.
48
+ */
49
+ export class RejectedByUser extends Errors.BaseError {
50
+ override readonly name = 'SignManifest.RejectedByUser'
51
+
52
+ constructor() {
53
+ super('Sign manifest rejected by user')
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Thrown when the provided domain is invalid.
59
+ */
60
+ export class InvalidDomain extends Errors.BaseError {
61
+ override readonly name = 'SignManifest.InvalidDomain'
62
+
63
+ constructor() {
64
+ super('Invalid domain provided')
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Thrown when manifest signing fails for generic reasons.
70
+ */
71
+ export class GenericError extends Errors.BaseError {
72
+ override readonly name = 'SignManifest.GenericError'
73
+
74
+ constructor(message = 'Manifest signing failed') {
75
+ super(message)
76
+ }
77
+ }
@@ -6,6 +6,7 @@ export * as Ready from './Ready.ts'
6
6
  export * as RequestCameraAndMicrophoneAccess from './RequestCameraAndMicrophoneAccess.ts'
7
7
  export * as SendToken from './SendToken.ts'
8
8
  export * as SignIn from './SignIn.ts'
9
+ export * as SignManifest from './SignManifest.ts'
9
10
  export * as SwapToken from './SwapToken.ts'
10
11
  export * as ViewCast from './ViewCast.ts'
11
12
  export * as ViewProfile from './ViewProfile.ts'
@@ -8,25 +8,12 @@ export const eventMiniAppAddedSchema = z.object({
8
8
 
9
9
  export type EventMiniAppAdded = z.infer<typeof eventMiniAppAddedSchema>
10
10
 
11
- export const eventFrameAddedSchema = z.object({
12
- event: z.literal('frame_added'),
13
- notificationDetails: notificationDetailsSchema.optional(),
14
- })
15
-
16
- export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>
17
-
18
11
  export const eventMiniAppRemovedSchema = z.object({
19
12
  event: z.literal('miniapp_removed'),
20
13
  })
21
14
 
22
15
  export type EventMiniAppRemoved = z.infer<typeof eventMiniAppRemovedSchema>
23
16
 
24
- export const eventFrameRemovedSchema = z.object({
25
- event: z.literal('frame_removed'),
26
- })
27
-
28
- export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>
29
-
30
17
  export const eventNotificationsEnabledSchema = z.object({
31
18
  event: z.literal('notifications_enabled'),
32
19
  notificationDetails: notificationDetailsSchema.required(),
@@ -49,9 +36,6 @@ export const serverEventSchema = z.discriminatedUnion('event', [
49
36
  eventMiniAppRemovedSchema,
50
37
  eventNotificationsEnabledSchema,
51
38
  notificationsDisabledSchema,
52
- // Remove after compatibility period
53
- eventFrameAddedSchema,
54
- eventFrameRemovedSchema,
55
39
  ])
56
40
 
57
41
  export type MiniAppServerEvent = z.infer<typeof serverEventSchema>
package/src/types.ts CHANGED
@@ -11,6 +11,7 @@ import type {
11
11
  RequestCameraAndMicrophoneAccess,
12
12
  SendToken,
13
13
  SignIn,
14
+ SignManifest,
14
15
  SwapToken,
15
16
  ViewCast,
16
17
  ViewProfile,
@@ -19,8 +20,6 @@ import type {
19
20
  import type { UpdateBackState } from './back.ts'
20
21
  import type { MiniAppContext } from './context.ts'
21
22
  import type {
22
- EventFrameAdded,
23
- EventFrameRemoved,
24
23
  EventMiniAppAdded,
25
24
  EventMiniAppRemoved,
26
25
  EventNotificationsDisabled,
@@ -64,6 +63,7 @@ export const miniAppHostCapabilityList = [
64
63
  'actions.swapToken',
65
64
  'actions.openMiniApp',
66
65
  'actions.requestCameraAndMicrophoneAccess',
66
+ 'experimental.signManifest',
67
67
  'haptics.impactOccurred',
68
68
  'haptics.notificationOccurred',
69
69
  'haptics.selectionChanged',
@@ -83,6 +83,7 @@ export type WireMiniAppHost = {
83
83
  ready: Ready.Ready
84
84
  openUrl: (url: string) => void
85
85
  signIn: SignIn.WireSignIn
86
+ signManifest: SignManifest.WireSignManifest
86
87
  setPrimaryButton: SetPrimaryButton
87
88
  ethProviderRequest: Ethereum.EthProvideRequest
88
89
  ethProviderRequestV2: Ethereum.RpcTransport
@@ -114,6 +115,7 @@ export type MiniAppHost = {
114
115
  ready: Ready.Ready
115
116
  openUrl: (url: string) => void
116
117
  signIn: SignIn.SignIn
118
+ signManifest: SignManifest.SignManifest
117
119
  setPrimaryButton: SetPrimaryButton
118
120
  ethProviderRequest: Ethereum.EthProvideRequest
119
121
  ethProviderRequestV2: Ethereum.RpcTransport
@@ -143,11 +145,6 @@ export type MiniAppHost = {
143
145
  updateBackState: UpdateBackState
144
146
  }
145
147
 
146
- export type EventFrameAddRejected = {
147
- event: 'frame_add_rejected'
148
- reason: AddMiniApp.AddMiniAppRejectedReason
149
- }
150
-
151
148
  export type EventMiniAppAddRejected = {
152
149
  event: 'miniapp_add_rejected'
153
150
  reason: AddMiniApp.AddMiniAppRejectedReason
@@ -170,6 +167,3 @@ export type MiniAppClientEvent =
170
167
  | EventPrimaryButtonClicked
171
168
  | EventBackNavigationTriggered
172
169
  | Ethereum.EventEip6963AnnounceProvider
173
- | EventFrameAdded
174
- | EventFrameAddRejected
175
- | EventFrameRemoved