@farcaster/frame-core 0.0.28 → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Merkle Manufactory Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @farcaster/frame-core
2
+
3
+ Build onchain social apps
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @farcaster/core
9
+ ```
10
+
11
+ ## Documentation
12
+
13
+ For documentation and guides, visit [miniapps.farcaster.xyz](https://miniapps.farcaster.xyz).
@@ -0,0 +1,32 @@
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
+ /** Suggested embeds. Max two. */
9
+ embeds?: [] | [string] | [string, string];
10
+ /** Suggested parent. */
11
+ parent?: {
12
+ type: 'cast';
13
+ hash: string;
14
+ };
15
+ /** Whether the app should be closed when this action is called. */
16
+ close?: close;
17
+ };
18
+ export type Result<close extends boolean | undefined = undefined> = close extends true ? undefined : {
19
+ cast: {
20
+ /** Cast of the created cast */
21
+ hash: string;
22
+ /** Text of the created cast */
23
+ text?: string;
24
+ /** Embeds of the created cast */
25
+ embeds?: [] | [string] | [string, string];
26
+ /** Parent of the created cast */
27
+ parent?: {
28
+ type: 'cast';
29
+ hash: string;
30
+ };
31
+ };
32
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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';
@@ -33,8 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ViewToken = exports.ViewProfile = exports.Swap = exports.SignIn = exports.Ready = exports.AddFrame = void 0;
36
+ exports.ViewToken = exports.ViewProfile = exports.Swap = exports.SignIn = exports.Ready = exports.ComposeCast = exports.AddFrame = void 0;
37
37
  exports.AddFrame = __importStar(require("./AddFrame"));
38
+ exports.ComposeCast = __importStar(require("./ComposeCast"));
38
39
  exports.Ready = __importStar(require("./Ready"));
39
40
  exports.SignIn = __importStar(require("./SignIn"));
40
41
  exports.Swap = __importStar(require("./Swap"));
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export type GlobalErrorType<name extends string = 'Error'> = Error & {
2
+ name: name;
3
+ };
1
4
  export declare class BaseError<cause extends Error | undefined = undefined> extends Error {
2
5
  name: string;
3
6
  cause: cause;
package/dist/index.d.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';
package/dist/index.js CHANGED
@@ -36,9 +36,11 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Context = void 0;
39
+ exports.Manifest = exports.Context = exports.Errors = void 0;
40
40
  __exportStar(require("./actions"), exports);
41
41
  __exportStar(require("./wallet"), exports);
42
+ exports.Errors = __importStar(require("./errors"));
42
43
  exports.Context = __importStar(require("./context"));
44
+ exports.Manifest = __importStar(require("./manifest"));
43
45
  __exportStar(require("./types"), exports);
44
46
  __exportStar(require("./schemas"), exports);
@@ -0,0 +1,101 @@
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
+ * Signed domain association linking this frame to a Farcaster account
10
+ *
11
+ * A DomainAssociation can be generated using the {@link https://warpcast.com/~/developers/domains | Warpcast
12
+ * Domains Developer} tool.
13
+ */
14
+ export type AccountAssociation = {
15
+ /**
16
+ * Base64URL encoded JFS signature
17
+ */
18
+ header: string;
19
+ /**
20
+ * Base64URL encoded payload signature
21
+ */
22
+ payload: string;
23
+ /**
24
+ * Base64URL encoded signature
25
+ */
26
+ signature: string;
27
+ };
28
+ /**
29
+ * Frame configuration
30
+ *
31
+ * @example
32
+ * ``ts
33
+ * const frame: FrameConfig = {
34
+ * version: '1',
35
+ * name: 'Yoink!',
36
+ * homeUrl: 'https://yoink.party',
37
+ * iconUrl: 'https://yoink.party/img/icon.png',
38
+ * imageUrl: 'https://yoink.party/framesV2/opengraph-image',
39
+ * buttonTitle: '🚩 Start',
40
+ * splashImageUrl: 'https://yoink.party/img/splash.png',
41
+ * splashImageBackgroundColor: '#eeeee4',
42
+ * webhookUrl: 'https://yoink.party/webhook'
43
+ * };
44
+ * ``
45
+ */
46
+ export type FrameConfig = {
47
+ /**
48
+ * Manifest version
49
+ *
50
+ * Must be the literal '1'.
51
+ */
52
+ version: '1';
53
+ /**
54
+ * App name that will be displayed to users
55
+ *
56
+ * Max length of 32 characters.
57
+ */
58
+ name: string;
59
+ /**
60
+ * Default launch URL
61
+ *
62
+ * Max length of 1024 characters.
63
+ */
64
+ homeUrl: string;
65
+ /**
66
+ * Icon URL
67
+ *
68
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
69
+ */
70
+ iconUrl: string;
71
+ /**
72
+ * Image URL
73
+ *
74
+ * Max length of 1024 characters. Image must have a 3:2 ratio.
75
+ */
76
+ imageUrl: string;
77
+ /**
78
+ * Default button title to use when frame is rendered.
79
+ *
80
+ * Max length of 32 characters.
81
+ */
82
+ buttonTitle: string;
83
+ /**
84
+ * Splash image URL
85
+ *
86
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
87
+ */
88
+ splashImageUrl?: string;
89
+ /**
90
+ * Splash background color
91
+ *
92
+ * Must be a hex color code.
93
+ */
94
+ splashBackgroundColor?: string;
95
+ /**
96
+ * URL to which clients will POST server events.
97
+ * Max length of 1024 characters.
98
+ * Required if the frame application uses notifications.
99
+ */
100
+ webhookUrl?: string;
101
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,7 +6,7 @@ exports.secureUrlSchema = zod_1.z
6
6
  .string()
7
7
  .url()
8
8
  .startsWith('https://', { message: 'Must be an https url' })
9
- .max(512);
9
+ .max(1024);
10
10
  exports.frameNameSchema = zod_1.z.string().max(32);
11
11
  exports.buttonTitleSchema = zod_1.z.string().max(32);
12
12
  const CAIP_19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AddFrame, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
1
+ import type { AddFrame, ComposeCast, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
2
2
  import type { FrameContext } from './context';
3
3
  import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
4
4
  import type { Ethereum } from './wallet';
@@ -26,6 +26,7 @@ export type WireFrameHost = {
26
26
  viewProfile: ViewProfile.ViewProfile;
27
27
  viewToken: ViewToken.ViewToken;
28
28
  swap: Swap.Swap;
29
+ composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
29
30
  };
30
31
  export type FrameHost = {
31
32
  context: FrameContext;
@@ -45,6 +46,7 @@ export type FrameHost = {
45
46
  viewProfile: ViewProfile.ViewProfile;
46
47
  viewToken: ViewToken.ViewToken;
47
48
  swap: Swap.Swap;
49
+ composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
48
50
  };
49
51
  export type EventFrameAddRejected = {
50
52
  event: 'frame_add_rejected';
@@ -0,0 +1,32 @@
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
+ /** Suggested embeds. Max two. */
9
+ embeds?: [] | [string] | [string, string];
10
+ /** Suggested parent. */
11
+ parent?: {
12
+ type: 'cast';
13
+ hash: string;
14
+ };
15
+ /** Whether the app should be closed when this action is called. */
16
+ close?: close;
17
+ };
18
+ export type Result<close extends boolean | undefined = undefined> = close extends true ? undefined : {
19
+ cast: {
20
+ /** Cast of the created cast */
21
+ hash: string;
22
+ /** Text of the created cast */
23
+ text?: string;
24
+ /** Embeds of the created cast */
25
+ embeds?: [] | [string] | [string, string];
26
+ /** Parent of the created cast */
27
+ parent?: {
28
+ type: 'cast';
29
+ hash: string;
30
+ };
31
+ };
32
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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';
@@ -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/esm/errors.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export type GlobalErrorType<name extends string = 'Error'> = Error & {
2
+ name: name;
3
+ };
1
4
  export declare class BaseError<cause extends Error | undefined = undefined> extends Error {
2
5
  name: string;
3
6
  cause: cause;
package/esm/index.d.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';
package/esm/index.js 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,101 @@
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
+ * Signed domain association linking this frame to a Farcaster account
10
+ *
11
+ * A DomainAssociation can be generated using the {@link https://warpcast.com/~/developers/domains | Warpcast
12
+ * Domains Developer} tool.
13
+ */
14
+ export type AccountAssociation = {
15
+ /**
16
+ * Base64URL encoded JFS signature
17
+ */
18
+ header: string;
19
+ /**
20
+ * Base64URL encoded payload signature
21
+ */
22
+ payload: string;
23
+ /**
24
+ * Base64URL encoded signature
25
+ */
26
+ signature: string;
27
+ };
28
+ /**
29
+ * Frame configuration
30
+ *
31
+ * @example
32
+ * ``ts
33
+ * const frame: FrameConfig = {
34
+ * version: '1',
35
+ * name: 'Yoink!',
36
+ * homeUrl: 'https://yoink.party',
37
+ * iconUrl: 'https://yoink.party/img/icon.png',
38
+ * imageUrl: 'https://yoink.party/framesV2/opengraph-image',
39
+ * buttonTitle: '🚩 Start',
40
+ * splashImageUrl: 'https://yoink.party/img/splash.png',
41
+ * splashImageBackgroundColor: '#eeeee4',
42
+ * webhookUrl: 'https://yoink.party/webhook'
43
+ * };
44
+ * ``
45
+ */
46
+ export type FrameConfig = {
47
+ /**
48
+ * Manifest version
49
+ *
50
+ * Must be the literal '1'.
51
+ */
52
+ version: '1';
53
+ /**
54
+ * App name that will be displayed to users
55
+ *
56
+ * Max length of 32 characters.
57
+ */
58
+ name: string;
59
+ /**
60
+ * Default launch URL
61
+ *
62
+ * Max length of 1024 characters.
63
+ */
64
+ homeUrl: string;
65
+ /**
66
+ * Icon URL
67
+ *
68
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
69
+ */
70
+ iconUrl: string;
71
+ /**
72
+ * Image URL
73
+ *
74
+ * Max length of 1024 characters. Image must have a 3:2 ratio.
75
+ */
76
+ imageUrl: string;
77
+ /**
78
+ * Default button title to use when frame is rendered.
79
+ *
80
+ * Max length of 32 characters.
81
+ */
82
+ buttonTitle: string;
83
+ /**
84
+ * Splash image URL
85
+ *
86
+ * Max length of 1024 characters. Image must be 200x200px and less than 1MB.
87
+ */
88
+ splashImageUrl?: string;
89
+ /**
90
+ * Splash background color
91
+ *
92
+ * Must be a hex color code.
93
+ */
94
+ splashBackgroundColor?: string;
95
+ /**
96
+ * URL to which clients will POST server events.
97
+ * Max length of 1024 characters.
98
+ * Required if the frame application uses notifications.
99
+ */
100
+ webhookUrl?: string;
101
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -3,7 +3,7 @@ export const secureUrlSchema = z
3
3
  .string()
4
4
  .url()
5
5
  .startsWith('https://', { message: 'Must be an https url' })
6
- .max(512);
6
+ .max(1024);
7
7
  export const frameNameSchema = z.string().max(32);
8
8
  export const buttonTitleSchema = z.string().max(32);
9
9
  const CAIP_19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/;