@farcaster/frame-core 0.0.28 → 0.0.29

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/esm/actions/AddFrame.d.ts +27 -23
  3. package/esm/actions/AddFrame.js +9 -9
  4. package/esm/actions/Ready.d.ts +11 -11
  5. package/esm/actions/Ready.js +2 -2
  6. package/esm/actions/SignIn.d.ts +35 -33
  7. package/esm/actions/SignIn.js +5 -5
  8. package/esm/actions/Swap.d.ts +44 -43
  9. package/esm/actions/Swap.js +1 -1
  10. package/esm/actions/ViewProfile.d.ts +3 -3
  11. package/esm/actions/ViewProfile.js +1 -1
  12. package/esm/actions/ViewToken.d.ts +3 -3
  13. package/esm/actions/ViewToken.js +1 -1
  14. package/esm/actions/index.d.ts +6 -6
  15. package/esm/actions/index.js +6 -6
  16. package/esm/context.d.ts +65 -61
  17. package/esm/context.js +1 -1
  18. package/esm/errors.d.ts +9 -7
  19. package/esm/errors.js +6 -6
  20. package/esm/index.d.ts +5 -5
  21. package/esm/index.js +5 -5
  22. package/esm/internal/types.d.ts +18 -7
  23. package/esm/internal/types.js +1 -1
  24. package/esm/schemas/embeds.d.ts +346 -239
  25. package/esm/schemas/embeds.js +31 -23
  26. package/esm/schemas/events.d.ts +225 -129
  27. package/esm/schemas/events.js +17 -17
  28. package/esm/schemas/index.d.ts +5 -5
  29. package/esm/schemas/index.js +5 -5
  30. package/esm/schemas/manifest.d.ts +154 -110
  31. package/esm/schemas/manifest.js +29 -23
  32. package/esm/schemas/notifications.d.ts +86 -58
  33. package/esm/schemas/notifications.js +17 -17
  34. package/esm/schemas/shared.d.ts +53 -35
  35. package/esm/schemas/shared.js +25 -23
  36. package/esm/types.d.ts +70 -51
  37. package/esm/types.js +2 -2
  38. package/esm/wallet/ethereum.d.ts +50 -35
  39. package/esm/wallet/ethereum.js +1 -1
  40. package/esm/wallet/index.d.ts +1 -1
  41. package/esm/wallet/index.js +1 -1
  42. package/package.json +7 -1
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.
@@ -1,36 +1,40 @@
1
- import * as Errors from '../errors';
2
- import type { OneOf } from '../internal/types';
3
- import type { FrameNotificationDetails } from '../schemas';
1
+ import * as Errors from '../errors'
2
+ import type { OneOf } from '../internal/types'
3
+ import type { FrameNotificationDetails } from '../schemas'
4
4
  export type AddFrameResult = {
5
- notificationDetails?: FrameNotificationDetails;
6
- };
7
- export type AddFrame = () => Promise<AddFrameResult>;
5
+ notificationDetails?: FrameNotificationDetails
6
+ }
7
+ export type AddFrame = () => Promise<AddFrameResult>
8
8
  type InvalidDomainManifestJsonError = {
9
- type: 'invalid_domain_manifest';
10
- };
9
+ type: 'invalid_domain_manifest'
10
+ }
11
11
  type RejectedByUserJsonError = {
12
- type: 'rejected_by_user';
13
- };
14
- export type AddFrameJsonError = InvalidDomainManifestJsonError | RejectedByUserJsonError;
15
- export type AddFrameRejectedReason = AddFrameJsonError['type'];
16
- export type AddFrameJsonResult = OneOf<{
17
- result: AddFrameResult;
18
- } | {
19
- error: AddFrameJsonError;
20
- }>;
21
- export type WireAddFrame = () => Promise<AddFrameJsonResult>;
12
+ type: 'rejected_by_user'
13
+ }
14
+ export type AddFrameJsonError =
15
+ | InvalidDomainManifestJsonError
16
+ | RejectedByUserJsonError
17
+ export type AddFrameRejectedReason = AddFrameJsonError['type']
18
+ export type AddFrameJsonResult = OneOf<
19
+ | {
20
+ result: AddFrameResult
21
+ }
22
+ | {
23
+ error: AddFrameJsonError
24
+ }
25
+ >
26
+ export type WireAddFrame = () => Promise<AddFrameJsonResult>
22
27
  /**
23
28
  * Thrown when the frame does not have a valid domain manifest.
24
29
  */
25
30
  export declare class InvalidDomainManifest extends Errors.BaseError {
26
- readonly name = "AddFrame.InvalidDomainManifest";
27
- constructor();
31
+ readonly name = 'AddFrame.InvalidDomainManifest'
32
+ constructor()
28
33
  }
29
34
  /**
30
35
  * Thrown when add frame action was rejected by the user.
31
36
  */
32
37
  export declare class RejectedByUser extends Errors.BaseError {
33
- readonly name = "AddFrame.RejectedByUser";
34
- constructor();
38
+ readonly name = 'AddFrame.RejectedByUser'
39
+ constructor()
35
40
  }
36
- export {};
@@ -1,19 +1,19 @@
1
- import * as Errors from '../errors';
1
+ import * as Errors from '../errors'
2
2
  /**
3
3
  * Thrown when the frame does not have a valid domain manifest.
4
4
  */
5
5
  export class InvalidDomainManifest extends Errors.BaseError {
6
- name = 'AddFrame.InvalidDomainManifest';
7
- constructor() {
8
- super('Invalid domain manifest');
9
- }
6
+ name = 'AddFrame.InvalidDomainManifest'
7
+ constructor() {
8
+ super('Invalid domain manifest')
9
+ }
10
10
  }
11
11
  /**
12
12
  * Thrown when add frame action was rejected by the user.
13
13
  */
14
14
  export class RejectedByUser extends Errors.BaseError {
15
- name = 'AddFrame.RejectedByUser';
16
- constructor() {
17
- super('Add frame rejected by user');
18
- }
15
+ name = 'AddFrame.RejectedByUser'
16
+ constructor() {
17
+ super('Add frame rejected by user')
18
+ }
19
19
  }
@@ -1,13 +1,13 @@
1
1
  export type ReadyOptions = {
2
- /**
3
- * Disable native gestures. Use this option if your frame uses gestures
4
- * that conflict with native gestures.
5
- *
6
- * @defaultValue false
7
- */
8
- disableNativeGestures: boolean;
9
- };
2
+ /**
3
+ * Disable native gestures. Use this option if your frame uses gestures
4
+ * that conflict with native gestures.
5
+ *
6
+ * @defaultValue false
7
+ */
8
+ disableNativeGestures: boolean
9
+ }
10
10
  export declare const DEFAULT_READY_OPTIONS: {
11
- disableNativeGestures: false;
12
- };
13
- export type Ready = (options?: Partial<ReadyOptions>) => void;
11
+ disableNativeGestures: false
12
+ }
13
+ export type Ready = (options?: Partial<ReadyOptions>) => void
@@ -1,3 +1,3 @@
1
1
  export const DEFAULT_READY_OPTIONS = {
2
- disableNativeGestures: false,
3
- };
2
+ disableNativeGestures: false,
3
+ }
@@ -1,41 +1,43 @@
1
- import * as Errors from '../errors';
2
- import type { OneOf } from '../internal/types';
1
+ import * as Errors from '../errors'
2
+ import type { OneOf } from '../internal/types'
3
3
  export type SignInOptions = {
4
- /**
5
- * A random string used to prevent replay attacks.
6
- */
7
- nonce: string;
8
- /**
9
- * Start time at which the signature becomes valid.
10
- * ISO 8601 datetime.
11
- */
12
- notBefore?: string;
13
- /**
14
- * Expiration time at which the signature is no longer valid.
15
- * ISO 8601 datetime.
16
- */
17
- expirationTime?: string;
18
- };
4
+ /**
5
+ * A random string used to prevent replay attacks.
6
+ */
7
+ nonce: string
8
+ /**
9
+ * Start time at which the signature becomes valid.
10
+ * ISO 8601 datetime.
11
+ */
12
+ notBefore?: string
13
+ /**
14
+ * Expiration time at which the signature is no longer valid.
15
+ * ISO 8601 datetime.
16
+ */
17
+ expirationTime?: string
18
+ }
19
19
  export type SignInResult = {
20
- signature: string;
21
- message: string;
22
- };
23
- export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
20
+ signature: string
21
+ message: string
22
+ }
23
+ export type SignIn = (options: SignInOptions) => Promise<SignInResult>
24
24
  type RejectedByUserJsonError = {
25
- type: 'rejected_by_user';
26
- };
27
- export type SignInJsonError = RejectedByUserJsonError;
28
- export type SignInJsonResult = OneOf<{
29
- result: SignInResult;
30
- } | {
31
- error: SignInJsonError;
32
- }>;
33
- export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>;
25
+ type: 'rejected_by_user'
26
+ }
27
+ export type SignInJsonError = RejectedByUserJsonError
28
+ export type SignInJsonResult = OneOf<
29
+ | {
30
+ result: SignInResult
31
+ }
32
+ | {
33
+ error: SignInJsonError
34
+ }
35
+ >
36
+ export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>
34
37
  /**
35
38
  * Thrown when a sign in action was rejected.
36
39
  */
37
40
  export declare class RejectedByUser extends Errors.BaseError {
38
- readonly name = "SignIn.RejectedByUser";
39
- constructor();
41
+ readonly name = 'SignIn.RejectedByUser'
42
+ constructor()
40
43
  }
41
- export {};
@@ -1,10 +1,10 @@
1
- import * as Errors from '../errors';
1
+ import * as Errors from '../errors'
2
2
  /**
3
3
  * Thrown when a sign in action was rejected.
4
4
  */
5
5
  export class RejectedByUser extends Errors.BaseError {
6
- name = 'SignIn.RejectedByUser';
7
- constructor() {
8
- super('Sign in rejected by user');
9
- }
6
+ name = 'SignIn.RejectedByUser'
7
+ constructor() {
8
+ super('Sign in rejected by user')
9
+ }
10
10
  }
@@ -1,46 +1,47 @@
1
1
  export type SwapOptions = {
2
- /**
3
- * CAIP-19 asset ID
4
- * For example, Base USDC:
5
- * eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
6
- */
7
- sellToken?: string;
8
- /**
9
- * CAIP-19 token ID. For example, OP ETH:
10
- * eip155:10/native
11
- */
12
- buyToken?: string;
13
- /**
14
- * Sell token amount, as numeric string.
15
- * For example, 10 USDC: 1000000
16
- */
17
- sellAmount?: string;
18
- };
2
+ /**
3
+ * CAIP-19 asset ID
4
+ * For example, Base USDC:
5
+ * eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
6
+ */
7
+ sellToken?: string
8
+ /**
9
+ * CAIP-19 token ID. For example, OP ETH:
10
+ * eip155:10/native
11
+ */
12
+ buyToken?: string
13
+ /**
14
+ * Sell token amount, as numeric string.
15
+ * For example, 10 USDC: 1000000
16
+ */
17
+ sellAmount?: string
18
+ }
19
19
  type SwapDetails = {
20
- /**
21
- * Array of tx identifiers in order of execution.
22
- * Some swaps will have both an approval and swap tx.
23
- */
24
- transactions: `0x${string}`[];
25
- };
20
+ /**
21
+ * Array of tx identifiers in order of execution.
22
+ * Some swaps will have both an approval and swap tx.
23
+ */
24
+ transactions: `0x${string}`[]
25
+ }
26
26
  type SwapErrorDetails = {
27
- /**
28
- * Error code.
29
- */
30
- error: string;
31
- /**
32
- * Error message.
33
- */
34
- message?: string;
35
- };
36
- export type SwapErrorReason = 'rejected_by_user' | 'swap_failed';
37
- export type SwapResult = {
38
- success: true;
39
- swap: SwapDetails;
40
- } | {
41
- success: false;
42
- reason: SwapErrorReason;
43
- error?: SwapErrorDetails;
44
- };
45
- export type Swap = (options: SwapOptions) => Promise<SwapResult>;
46
- export {};
27
+ /**
28
+ * Error code.
29
+ */
30
+ error: string
31
+ /**
32
+ * Error message.
33
+ */
34
+ message?: string
35
+ }
36
+ export type SwapErrorReason = 'rejected_by_user' | 'swap_failed'
37
+ export type SwapResult =
38
+ | {
39
+ success: true
40
+ swap: SwapDetails
41
+ }
42
+ | {
43
+ success: false
44
+ reason: SwapErrorReason
45
+ error?: SwapErrorDetails
46
+ }
47
+ export type Swap = (options: SwapOptions) => Promise<SwapResult>
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,4 +1,4 @@
1
1
  export type ViewProfileOptions = {
2
- fid: number;
3
- };
4
- export type ViewProfile = (options: ViewProfileOptions) => Promise<void>;
2
+ fid: number
3
+ }
4
+ export type ViewProfile = (options: ViewProfileOptions) => Promise<void>
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,4 +1,4 @@
1
1
  export type ViewTokenOptions = {
2
- token: string;
3
- };
4
- export type ViewToken = (options: ViewTokenOptions) => Promise<void>;
2
+ token: string
3
+ }
4
+ export type ViewToken = (options: ViewTokenOptions) => Promise<void>
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,6 +1,6 @@
1
- export * as AddFrame from './AddFrame';
2
- export * as Ready from './Ready';
3
- export * as SignIn from './SignIn';
4
- export * as Swap from './Swap';
5
- export * as ViewProfile from './ViewProfile';
6
- export * as ViewToken from './ViewToken';
1
+ export * as AddFrame from './AddFrame'
2
+ export * as Ready from './Ready'
3
+ export * as SignIn from './SignIn'
4
+ export * as Swap from './Swap'
5
+ export * as ViewProfile from './ViewProfile'
6
+ export * as ViewToken from './ViewToken'
@@ -1,6 +1,6 @@
1
- export * as AddFrame from './AddFrame';
2
- export * as Ready from './Ready';
3
- export * as SignIn from './SignIn';
4
- export * as Swap from './Swap';
5
- export * as ViewProfile from './ViewProfile';
6
- export * as ViewToken from './ViewToken';
1
+ export * as AddFrame from './AddFrame'
2
+ export * as Ready from './Ready'
3
+ export * as SignIn from './SignIn'
4
+ export * as Swap from './Swap'
5
+ export * as ViewProfile from './ViewProfile'
6
+ export * as ViewToken from './ViewToken'
package/esm/context.d.ts CHANGED
@@ -1,72 +1,76 @@
1
- import type { FrameNotificationDetails } from './schemas';
1
+ import type { FrameNotificationDetails } from './schemas'
2
2
  export type CastEmbedLocationContext = {
3
- type: 'cast_embed';
4
- embed: string;
5
- cast: {
6
- fid: number;
7
- hash: string;
8
- };
9
- };
3
+ type: 'cast_embed'
4
+ embed: string
5
+ cast: {
6
+ fid: number
7
+ hash: string
8
+ }
9
+ }
10
10
  export type NotificationLocationContext = {
11
- type: 'notification';
12
- notification: {
13
- notificationId: string;
14
- title: string;
15
- body: string;
16
- };
17
- };
11
+ type: 'notification'
12
+ notification: {
13
+ notificationId: string
14
+ title: string
15
+ body: string
16
+ }
17
+ }
18
18
  export type LauncherLocationContext = {
19
- type: 'launcher';
20
- };
19
+ type: 'launcher'
20
+ }
21
21
  export type ChannelLocationContext = {
22
- type: 'channel';
23
- channel: {
24
- /**
25
- * Channel key identifier
26
- */
27
- key: string;
28
- /**
29
- * Channel name
30
- */
31
- name: string;
32
- /**
33
- * Channel profile image URL
34
- */
35
- imageUrl?: string;
36
- };
37
- };
38
- export type LocationContext = CastEmbedLocationContext | NotificationLocationContext | LauncherLocationContext | ChannelLocationContext;
39
- export type AccountLocation = {
40
- placeId: string;
22
+ type: 'channel'
23
+ channel: {
41
24
  /**
42
- * Human-readable string describing the location
25
+ * Channel key identifier
43
26
  */
44
- description: string;
45
- };
46
- export type UserContext = {
47
- fid: number;
48
- username?: string;
49
- displayName?: string;
27
+ key: string
28
+ /**
29
+ * Channel name
30
+ */
31
+ name: string
50
32
  /**
51
- * Profile image URL
33
+ * Channel profile image URL
52
34
  */
53
- pfpUrl?: string;
54
- location?: AccountLocation;
55
- };
35
+ imageUrl?: string
36
+ }
37
+ }
38
+ export type LocationContext =
39
+ | CastEmbedLocationContext
40
+ | NotificationLocationContext
41
+ | LauncherLocationContext
42
+ | ChannelLocationContext
43
+ export type AccountLocation = {
44
+ placeId: string
45
+ /**
46
+ * Human-readable string describing the location
47
+ */
48
+ description: string
49
+ }
50
+ export type UserContext = {
51
+ fid: number
52
+ username?: string
53
+ displayName?: string
54
+ /**
55
+ * Profile image URL
56
+ */
57
+ pfpUrl?: string
58
+ location?: AccountLocation
59
+ }
56
60
  export type SafeAreaInsets = {
57
- top: number;
58
- bottom: number;
59
- left: number;
60
- right: number;
61
- };
61
+ top: number
62
+ bottom: number
63
+ left: number
64
+ right: number
65
+ }
62
66
  export type ClientContext = {
63
- clientFid: number;
64
- added: boolean;
65
- notificationDetails?: FrameNotificationDetails;
66
- safeAreaInsets?: SafeAreaInsets;
67
- };
67
+ clientFid: number
68
+ added: boolean
69
+ notificationDetails?: FrameNotificationDetails
70
+ safeAreaInsets?: SafeAreaInsets
71
+ }
68
72
  export type FrameContext = {
69
- client: ClientContext;
70
- user: UserContext;
71
- location?: LocationContext;
72
- };
73
+ client: ClientContext
74
+ user: UserContext
75
+ location?: LocationContext
76
+ }
package/esm/context.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {}
package/esm/errors.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- export declare class BaseError<cause extends Error | undefined = undefined> extends Error {
2
- name: string;
3
- cause: cause;
4
- constructor(message: string, options?: BaseError.Options<cause>);
1
+ export declare class BaseError<
2
+ cause extends Error | undefined = undefined,
3
+ > extends Error {
4
+ name: string
5
+ cause: cause
6
+ constructor(message: string, options?: BaseError.Options<cause>)
5
7
  }
6
8
  export declare namespace BaseError {
7
- type Options<cause extends Error | undefined = Error | undefined> = {
8
- cause?: cause | undefined;
9
- };
9
+ type Options<cause extends Error | undefined = Error | undefined> = {
10
+ cause?: cause | undefined
11
+ }
10
12
  }
package/esm/errors.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export class BaseError extends Error {
2
- name = 'BaseError';
3
- cause;
4
- constructor(message, options = {}) {
5
- super(message, options.cause ? { cause: options.cause } : undefined);
6
- this.cause = options.cause;
7
- }
2
+ name = 'BaseError'
3
+ cause
4
+ constructor(message, options = {}) {
5
+ super(message, options.cause ? { cause: options.cause } : undefined)
6
+ this.cause = options.cause
7
+ }
8
8
  }
package/esm/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './actions';
2
- export * from './wallet';
3
- export * as Context from './context';
4
- export * from './types';
5
- export * from './schemas';
1
+ export * from './actions'
2
+ export * from './wallet'
3
+ export * as Context from './context'
4
+ export * from './types'
5
+ export * from './schemas'
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './actions';
2
- export * from './wallet';
3
- export * as Context from './context';
4
- export * from './types';
5
- export * from './schemas';
1
+ export * from './actions'
2
+ export * from './wallet'
3
+ export * as Context from './context'
4
+ export * from './types'
5
+ export * from './schemas'
@@ -1,8 +1,19 @@
1
1
  type Compute<type> = {
2
- [key in keyof type]: type[key];
3
- } & unknown;
4
- type KeyofUnion<type> = type extends type ? keyof type : never;
5
- export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & {
6
- [key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
7
- }> : never;
8
- export {};
2
+ [key in keyof type]: type[key]
3
+ } & unknown
4
+ type KeyofUnion<type> = type extends type ? keyof type : never
5
+ export type OneOf<
6
+ union extends object,
7
+ fallback extends object | undefined = undefined,
8
+ keys extends KeyofUnion<union> = KeyofUnion<union>,
9
+ > = union extends infer item
10
+ ? Compute<
11
+ item & {
12
+ [key in Exclude<keys, keyof item>]?: fallback extends object
13
+ ? key extends keyof fallback
14
+ ? fallback[key]
15
+ : undefined
16
+ : undefined
17
+ }
18
+ >
19
+ : never
@@ -1 +1 @@
1
- export {};
1
+ export {}