@farcaster/frame-core 0.0.29 → 0.0.31

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.
Files changed (65) hide show
  1. package/README.md +13 -0
  2. package/dist/actions/ComposeCast.d.ts +32 -0
  3. package/dist/actions/ComposeCast.js +2 -0
  4. package/dist/actions/index.d.ts +1 -0
  5. package/dist/actions/index.js +2 -1
  6. package/dist/errors.d.ts +3 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +3 -1
  9. package/dist/manifest.d.ts +101 -0
  10. package/dist/manifest.js +2 -0
  11. package/dist/schemas/shared.js +1 -1
  12. package/dist/types.d.ts +3 -1
  13. package/esm/actions/AddFrame.d.ts +23 -27
  14. package/esm/actions/AddFrame.js +9 -9
  15. package/esm/actions/ComposeCast.d.ts +32 -0
  16. package/esm/actions/ComposeCast.js +1 -0
  17. package/esm/actions/Ready.d.ts +11 -11
  18. package/esm/actions/Ready.js +2 -2
  19. package/esm/actions/SignIn.d.ts +33 -35
  20. package/esm/actions/SignIn.js +5 -5
  21. package/esm/actions/Swap.d.ts +43 -44
  22. package/esm/actions/Swap.js +1 -1
  23. package/esm/actions/ViewProfile.d.ts +3 -3
  24. package/esm/actions/ViewProfile.js +1 -1
  25. package/esm/actions/ViewToken.d.ts +3 -3
  26. package/esm/actions/ViewToken.js +1 -1
  27. package/esm/actions/index.d.ts +7 -6
  28. package/esm/actions/index.js +7 -6
  29. package/esm/context.d.ts +61 -65
  30. package/esm/context.js +1 -1
  31. package/esm/errors.d.ts +10 -9
  32. package/esm/errors.js +6 -6
  33. package/esm/index.d.ts +7 -5
  34. package/esm/index.js +7 -5
  35. package/esm/internal/types.d.ts +7 -18
  36. package/esm/internal/types.js +1 -1
  37. package/esm/manifest.d.ts +101 -0
  38. package/esm/manifest.js +1 -0
  39. package/esm/schemas/embeds.d.ts +239 -346
  40. package/esm/schemas/embeds.js +23 -31
  41. package/esm/schemas/events.d.ts +129 -225
  42. package/esm/schemas/events.js +17 -17
  43. package/esm/schemas/index.d.ts +5 -5
  44. package/esm/schemas/index.js +5 -5
  45. package/esm/schemas/manifest.d.ts +110 -154
  46. package/esm/schemas/manifest.js +23 -29
  47. package/esm/schemas/notifications.d.ts +58 -86
  48. package/esm/schemas/notifications.js +17 -17
  49. package/esm/schemas/shared.d.ts +35 -53
  50. package/esm/schemas/shared.js +23 -25
  51. package/esm/tsconfig.tsbuildinfo +1 -1
  52. package/esm/types.d.ts +53 -70
  53. package/esm/types.js +2 -2
  54. package/esm/wallet/ethereum.d.ts +35 -50
  55. package/esm/wallet/ethereum.js +1 -1
  56. package/esm/wallet/index.d.ts +1 -1
  57. package/esm/wallet/index.js +1 -1
  58. package/package.json +1 -1
  59. package/src/actions/ComposeCast.ts +36 -0
  60. package/src/actions/index.ts +1 -0
  61. package/src/errors.ts +4 -0
  62. package/src/index.ts +2 -0
  63. package/src/manifest.ts +113 -0
  64. package/src/schemas/shared.ts +1 -1
  65. package/src/types.ts +7 -0
package/esm/types.d.ts CHANGED
@@ -1,75 +1,58 @@
1
- import type {
2
- AddFrame,
3
- Ready,
4
- SignIn,
5
- Swap,
6
- ViewProfile,
7
- ViewToken,
8
- } from './actions'
9
- import type { FrameContext } from './context'
10
- import type {
11
- EventFrameAdded,
12
- EventFrameRemoved,
13
- EventNotificationsDisabled,
14
- EventNotificationsEnabled,
15
- } from './schemas'
16
- import type { Ethereum } from './wallet'
1
+ import type { AddFrame, ComposeCast, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
2
+ import type { FrameContext } from './context';
3
+ import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
4
+ import type { Ethereum } from './wallet';
17
5
  export type SetPrimaryButtonOptions = {
18
- text: string
19
- loading?: boolean
20
- disabled?: boolean
21
- hidden?: boolean
22
- }
23
- export * from './wallet/ethereum'
24
- export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready'
25
- export type SignInOptions = SignIn.SignInOptions
26
- export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
6
+ text: string;
7
+ loading?: boolean;
8
+ disabled?: boolean;
9
+ hidden?: boolean;
10
+ };
11
+ export * from './wallet/ethereum';
12
+ export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready';
13
+ export type SignInOptions = SignIn.SignInOptions;
14
+ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
27
15
  export type WireFrameHost = {
28
- context: FrameContext
29
- close: () => void
30
- ready: Ready.Ready
31
- openUrl: (url: string) => void
32
- signIn: SignIn.WireSignIn
33
- setPrimaryButton: SetPrimaryButton
34
- ethProviderRequest: Ethereum.EthProvideRequest
35
- ethProviderRequestV2: Ethereum.RpcTransport
36
- eip6963RequestProvider: () => void
37
- addFrame: AddFrame.WireAddFrame
38
- viewProfile: ViewProfile.ViewProfile
39
- viewToken: ViewToken.ViewToken
40
- swap: Swap.Swap
41
- }
16
+ context: FrameContext;
17
+ close: () => void;
18
+ ready: Ready.Ready;
19
+ openUrl: (url: string) => void;
20
+ signIn: SignIn.WireSignIn;
21
+ setPrimaryButton: SetPrimaryButton;
22
+ ethProviderRequest: Ethereum.EthProvideRequest;
23
+ ethProviderRequestV2: Ethereum.RpcTransport;
24
+ eip6963RequestProvider: () => void;
25
+ addFrame: AddFrame.WireAddFrame;
26
+ viewProfile: ViewProfile.ViewProfile;
27
+ viewToken: ViewToken.ViewToken;
28
+ swap: Swap.Swap;
29
+ composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
30
+ };
42
31
  export type FrameHost = {
43
- context: FrameContext
44
- close: () => void
45
- ready: Ready.Ready
46
- openUrl: (url: string) => void
47
- signIn: SignIn.SignIn
48
- setPrimaryButton: SetPrimaryButton
49
- ethProviderRequest: Ethereum.EthProvideRequest
50
- ethProviderRequestV2: Ethereum.RpcTransport
51
- /**
52
- * Receive forwarded eip6963:requestProvider events from the frame document.
53
- * Hosts must emit an EventEip6963AnnounceProvider in response.
54
- */
55
- eip6963RequestProvider: () => void
56
- addFrame: AddFrame.AddFrame
57
- viewProfile: ViewProfile.ViewProfile
58
- viewToken: ViewToken.ViewToken
59
- swap: Swap.Swap
60
- }
32
+ context: FrameContext;
33
+ close: () => void;
34
+ ready: Ready.Ready;
35
+ openUrl: (url: string) => void;
36
+ signIn: SignIn.SignIn;
37
+ setPrimaryButton: SetPrimaryButton;
38
+ ethProviderRequest: Ethereum.EthProvideRequest;
39
+ ethProviderRequestV2: Ethereum.RpcTransport;
40
+ /**
41
+ * Receive forwarded eip6963:requestProvider events from the frame document.
42
+ * Hosts must emit an EventEip6963AnnounceProvider in response.
43
+ */
44
+ eip6963RequestProvider: () => void;
45
+ addFrame: AddFrame.AddFrame;
46
+ viewProfile: ViewProfile.ViewProfile;
47
+ viewToken: ViewToken.ViewToken;
48
+ swap: Swap.Swap;
49
+ composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
50
+ };
61
51
  export type EventFrameAddRejected = {
62
- event: 'frame_add_rejected'
63
- reason: AddFrame.AddFrameRejectedReason
64
- }
52
+ event: 'frame_add_rejected';
53
+ reason: AddFrame.AddFrameRejectedReason;
54
+ };
65
55
  export type EventPrimaryButtonClicked = {
66
- event: 'primary_button_clicked'
67
- }
68
- export type FrameClientEvent =
69
- | EventFrameAdded
70
- | EventFrameAddRejected
71
- | EventFrameRemoved
72
- | EventNotificationsEnabled
73
- | EventNotificationsDisabled
74
- | EventPrimaryButtonClicked
75
- | Ethereum.EventEip6963AnnounceProvider
56
+ event: 'primary_button_clicked';
57
+ };
58
+ export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | Ethereum.EventEip6963AnnounceProvider;
package/esm/types.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // start backwards compat, remove in 1.0
2
- export * from './wallet/ethereum'
3
- export { DEFAULT_READY_OPTIONS } from './actions/Ready'
2
+ export * from './wallet/ethereum';
3
+ export { DEFAULT_READY_OPTIONS } from './actions/Ready';
@@ -1,58 +1,43 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
2
- export type EthProvideRequest<
3
- schema extends RpcSchema.Generic = RpcSchema.Default,
4
- > = Provider.RequestFn<schema>
1
+ import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
+ export type EthProvideRequest<schema extends RpcSchema.Generic = RpcSchema.Default> = Provider.RequestFn<schema>;
5
3
  export type FrameEthProviderEventData = {
6
- type: 'frame_eth_provider_event'
7
- } & EthProviderWireEvent
8
- export type RpcTransport = (
9
- request: RpcRequest.RpcRequest,
10
- ) => Promise<RpcResponse.RpcResponse>
4
+ type: 'frame_eth_provider_event';
5
+ } & EthProviderWireEvent;
6
+ export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
11
7
  export type ProviderRpcError = {
12
- code: number
13
- details?: string
14
- message?: string
15
- }
16
- export type EthProviderWireEvent =
17
- | {
18
- event: 'accountsChanged'
19
- params: [readonly Address.Address[]]
20
- }
21
- | {
22
- event: 'chainChanged'
23
- params: [string]
24
- }
25
- | {
26
- event: 'connect'
27
- params: [Provider.ConnectInfo]
28
- }
29
- | {
30
- event: 'disconnect'
31
- params: [ProviderRpcError]
32
- }
33
- | {
34
- event: 'message'
35
- params: [Provider.Message]
36
- }
37
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
38
- event: event,
39
- params: Extract<
40
- EthProviderWireEvent,
41
- {
42
- event: event
43
- }
44
- >['params'],
45
- ) => void
8
+ code: number;
9
+ details?: string;
10
+ message?: string;
11
+ };
12
+ export type EthProviderWireEvent = {
13
+ event: 'accountsChanged';
14
+ params: [readonly Address.Address[]];
15
+ } | {
16
+ event: 'chainChanged';
17
+ params: [string];
18
+ } | {
19
+ event: 'connect';
20
+ params: [Provider.ConnectInfo];
21
+ } | {
22
+ event: 'disconnect';
23
+ params: [ProviderRpcError];
24
+ } | {
25
+ event: 'message';
26
+ params: [Provider.Message];
27
+ };
28
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
29
+ event: event;
30
+ }>['params']) => void;
46
31
  /**
47
32
  * Metadata of the EIP-1193 Provider.
48
33
  */
49
34
  export interface EIP6963ProviderInfo {
50
- icon: `data:image/${string}`
51
- name: string
52
- rdns: string
53
- uuid: string
35
+ icon: `data:image/${string}`;
36
+ name: string;
37
+ rdns: string;
38
+ uuid: string;
54
39
  }
55
40
  export type EventEip6963AnnounceProvider = {
56
- event: 'eip6963:announceProvider'
57
- info: EIP6963ProviderInfo
58
- }
41
+ event: 'eip6963:announceProvider';
42
+ info: EIP6963ProviderInfo;
43
+ };
@@ -1 +1 @@
1
- export {}
1
+ export {};
@@ -1 +1 @@
1
- export * as Ethereum from './ethereum'
1
+ export * as Ethereum from './ethereum';
@@ -1 +1 @@
1
- export * as Ethereum from './ethereum'
1
+ export * as Ethereum from './ethereum';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/frame-core",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,36 @@
1
+ export type Options<close extends boolean | undefined = undefined> = {
2
+ /**
3
+ * Suggested text for the body of the cast.
4
+ *
5
+ * Mentions can be included using the human-writeable form (e.g. @farcaster).
6
+ **/
7
+ text?: string
8
+
9
+ /** Suggested embeds. Max two. */
10
+ embeds?: [] | [string] | [string, string]
11
+
12
+ /** Suggested parent. */
13
+ parent?: { type: 'cast'; hash: string }
14
+
15
+ /** Whether the app should be closed when this action is called. */
16
+ close?: close
17
+ }
18
+
19
+ export type Result<close extends boolean | undefined = undefined> =
20
+ close extends true
21
+ ? undefined
22
+ : {
23
+ cast: {
24
+ /** Cast of the created cast */
25
+ hash: string
26
+
27
+ /** Text of the created cast */
28
+ text?: string
29
+
30
+ /** Embeds of the created cast */
31
+ embeds?: [] | [string] | [string, string]
32
+
33
+ /** Parent of the created cast */
34
+ parent?: { type: 'cast'; hash: string }
35
+ }
36
+ }
@@ -1,4 +1,5 @@
1
1
  export * as AddFrame from './AddFrame'
2
+ export * as ComposeCast from './ComposeCast'
2
3
  export * as Ready from './Ready'
3
4
  export * as SignIn from './SignIn'
4
5
  export * as Swap from './Swap'
package/src/errors.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export type GlobalErrorType<name extends string = 'Error'> = Error & {
2
+ name: name
3
+ }
4
+
1
5
  export class BaseError<
2
6
  cause extends Error | undefined = undefined,
3
7
  > extends Error {
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from './actions'
2
2
  export * from './wallet'
3
+ export * as Errors from './errors'
3
4
  export * as Context from './context'
5
+ export * as Manifest from './manifest'
4
6
  export * from './types'
5
7
  export * from './schemas'
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Farcaster manifest for a domain hosted at `/.well-known/farcaster.json`
3
+ */
4
+ export type Manifest = {
5
+ accountAssociation: AccountAssociation
6
+ frame: FrameConfig
7
+ }
8
+
9
+ /**
10
+ * Signed domain association linking this frame to a Farcaster account
11
+ *
12
+ * A DomainAssociation can be generated using the {@link https://warpcast.com/~/developers/domains | Warpcast
13
+ * Domains Developer} tool.
14
+ */
15
+ export type AccountAssociation = {
16
+ /**
17
+ * Base64URL encoded JFS signature
18
+ */
19
+ header: string
20
+
21
+ /**
22
+ * Base64URL encoded payload signature
23
+ */
24
+ payload: string
25
+
26
+ /**
27
+ * Base64URL encoded signature
28
+ */
29
+ signature: string
30
+ }
31
+
32
+ /**
33
+ * Frame configuration
34
+ *
35
+ * @example
36
+ * ``ts
37
+ * const frame: FrameConfig = {
38
+ * version: '1',
39
+ * name: 'Yoink!',
40
+ * homeUrl: 'https://yoink.party',
41
+ * iconUrl: 'https://yoink.party/img/icon.png',
42
+ * imageUrl: 'https://yoink.party/framesV2/opengraph-image',
43
+ * buttonTitle: '🚩 Start',
44
+ * splashImageUrl: 'https://yoink.party/img/splash.png',
45
+ * splashImageBackgroundColor: '#eeeee4',
46
+ * webhookUrl: 'https://yoink.party/webhook'
47
+ * };
48
+ * ``
49
+ */
50
+ export type FrameConfig = {
51
+ /**
52
+ * Manifest version
53
+ *
54
+ * Must be the literal '1'.
55
+ */
56
+ version: '1'
57
+
58
+ /**
59
+ * App name that will be displayed to users
60
+ *
61
+ * Max length of 32 characters.
62
+ */
63
+ name: string
64
+
65
+ /**
66
+ * Default launch URL
67
+ *
68
+ * Max length of 1024 characters.
69
+ */
70
+ homeUrl: string
71
+
72
+ /**
73
+ * Icon URL
74
+ *
75
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
76
+ */
77
+ iconUrl: string
78
+
79
+ /**
80
+ * Image URL
81
+ *
82
+ * Max length of 1024 characters. Image must have a 3:2 ratio.
83
+ */
84
+ imageUrl: string
85
+
86
+ /**
87
+ * Default button title to use when frame is rendered.
88
+ *
89
+ * Max length of 32 characters.
90
+ */
91
+ buttonTitle: string
92
+
93
+ /**
94
+ * Splash image URL
95
+ *
96
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
97
+ */
98
+ splashImageUrl?: string
99
+
100
+ /**
101
+ * Splash background color
102
+ *
103
+ * Must be a hex color code.
104
+ */
105
+ splashBackgroundColor?: string
106
+
107
+ /**
108
+ * URL to which clients will POST server events.
109
+ * Max length of 1024 characters.
110
+ * Required if the frame application uses notifications.
111
+ */
112
+ webhookUrl?: string
113
+ }
@@ -4,7 +4,7 @@ export const secureUrlSchema = z
4
4
  .string()
5
5
  .url()
6
6
  .startsWith('https://', { message: 'Must be an https url' })
7
- .max(512)
7
+ .max(1024)
8
8
 
9
9
  export const frameNameSchema = z.string().max(32)
10
10
  export const buttonTitleSchema = z.string().max(32)
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AddFrame,
3
+ ComposeCast,
3
4
  Ready,
4
5
  SignIn,
5
6
  Swap,
@@ -44,6 +45,9 @@ export type WireFrameHost = {
44
45
  viewProfile: ViewProfile.ViewProfile
45
46
  viewToken: ViewToken.ViewToken
46
47
  swap: Swap.Swap
48
+ composeCast: <close extends boolean | undefined = undefined>(
49
+ options: ComposeCast.Options<close>,
50
+ ) => Promise<ComposeCast.Result<close>>
47
51
  }
48
52
 
49
53
  export type FrameHost = {
@@ -64,6 +68,9 @@ export type FrameHost = {
64
68
  viewProfile: ViewProfile.ViewProfile
65
69
  viewToken: ViewToken.ViewToken
66
70
  swap: Swap.Swap
71
+ composeCast: <close extends boolean | undefined = undefined>(
72
+ options: ComposeCast.Options<close>,
73
+ ) => Promise<ComposeCast.Result<close>>
67
74
  }
68
75
 
69
76
  export type EventFrameAddRejected = {