@farcaster/frame-core 0.0.23 → 0.0.25
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/actions/ViewProfile.d.ts +4 -0
- package/dist/actions/ViewProfile.js +2 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +2 -1
- package/dist/schemas/embeds.d.ts +61 -0
- package/dist/schemas/embeds.js +6 -1
- package/dist/schemas/shared.d.ts +1 -0
- package/dist/schemas/shared.js +5 -1
- package/dist/types.d.ts +3 -1
- package/esm/actions/AddFrame.d.ts +23 -27
- package/esm/actions/AddFrame.js +9 -9
- package/esm/actions/SignIn.d.ts +33 -35
- package/esm/actions/SignIn.js +5 -5
- package/esm/actions/ViewProfile.d.ts +4 -0
- package/esm/actions/ViewProfile.js +1 -0
- package/esm/actions/index.d.ts +3 -2
- package/esm/actions/index.js +3 -2
- package/esm/context.d.ts +61 -65
- package/esm/context.js +1 -1
- package/esm/errors.d.ts +7 -9
- package/esm/errors.js +6 -6
- package/esm/index.d.ts +4 -4
- package/esm/index.js +4 -4
- package/esm/internal/types.d.ts +7 -18
- package/esm/internal/types.js +1 -1
- package/esm/schemas/embeds.d.ts +230 -231
- package/esm/schemas/embeds.js +23 -24
- package/esm/schemas/events.d.ts +129 -225
- package/esm/schemas/events.js +17 -17
- package/esm/schemas/index.d.ts +5 -5
- package/esm/schemas/index.js +5 -5
- package/esm/schemas/manifest.d.ts +110 -154
- package/esm/schemas/manifest.js +23 -29
- package/esm/schemas/notifications.d.ts +58 -86
- package/esm/schemas/notifications.js +17 -17
- package/esm/schemas/shared.d.ts +34 -49
- package/esm/schemas/shared.js +23 -20
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +102 -125
- package/esm/types.js +2 -2
- package/package.json +7 -2
- package/src/actions/ViewProfile.ts +5 -0
- package/src/actions/index.ts +1 -0
- package/src/schemas/embeds.ts +7 -0
- package/src/schemas/shared.ts +7 -0
- package/src/types.ts +3 -1
package/esm/types.d.ts
CHANGED
|
@@ -1,140 +1,117 @@
|
|
|
1
|
-
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
|
|
2
|
-
import type { AddFrame, SignIn } from './actions'
|
|
3
|
-
import type { FrameContext } from './context'
|
|
4
|
-
import type {
|
|
5
|
-
EventFrameAdded,
|
|
6
|
-
EventFrameRemoved,
|
|
7
|
-
EventNotificationsDisabled,
|
|
8
|
-
EventNotificationsEnabled,
|
|
9
|
-
} from './schemas'
|
|
1
|
+
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
|
|
2
|
+
import type { AddFrame, SignIn, ViewProfile } from './actions';
|
|
3
|
+
import type { FrameContext } from './context';
|
|
4
|
+
import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
|
|
10
5
|
export type SetPrimaryButtonOptions = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
|
|
17
|
-
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default
|
|
6
|
+
text: string;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
|
|
12
|
+
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
|
|
18
13
|
export type ReadyOptions = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export declare const DEFAULT_READY_OPTIONS: ReadyOptions
|
|
14
|
+
/**
|
|
15
|
+
* Disable native gestures. Use this option if your frame uses gestures
|
|
16
|
+
* that conflict with native gestures.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue false
|
|
19
|
+
*/
|
|
20
|
+
disableNativeGestures: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare const DEFAULT_READY_OPTIONS: ReadyOptions;
|
|
28
23
|
export type SignInOptions = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* A random string used to prevent replay attacks.
|
|
26
|
+
*/
|
|
27
|
+
nonce: string;
|
|
28
|
+
/**
|
|
29
|
+
* Start time at which the signature becomes valid.
|
|
30
|
+
* ISO 8601 datetime.
|
|
31
|
+
*/
|
|
32
|
+
notBefore?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Expiration time at which the signature is no longer valid.
|
|
35
|
+
* ISO 8601 datetime.
|
|
36
|
+
*/
|
|
37
|
+
expirationTime?: string;
|
|
38
|
+
};
|
|
44
39
|
export type WireFrameHost = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
context: FrameContext;
|
|
41
|
+
close: () => void;
|
|
42
|
+
ready: (options?: Partial<ReadyOptions>) => void;
|
|
43
|
+
openUrl: (url: string) => void;
|
|
44
|
+
signIn: SignIn.WireSignIn;
|
|
45
|
+
setPrimaryButton: SetPrimaryButton;
|
|
46
|
+
ethProviderRequest: EthProviderRequest;
|
|
47
|
+
ethProviderRequestV2: RpcTransport;
|
|
48
|
+
eip6963RequestProvider: () => void;
|
|
49
|
+
addFrame: AddFrame.WireAddFrame;
|
|
50
|
+
viewProfile: ViewProfile.ViewProfile;
|
|
51
|
+
};
|
|
56
52
|
export type FrameHost = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
context: FrameContext;
|
|
54
|
+
close: () => void;
|
|
55
|
+
ready: (options?: Partial<ReadyOptions>) => void;
|
|
56
|
+
openUrl: (url: string) => void;
|
|
57
|
+
signIn: SignIn.SignIn;
|
|
58
|
+
setPrimaryButton: SetPrimaryButton;
|
|
59
|
+
ethProviderRequest: EthProviderRequest;
|
|
60
|
+
ethProviderRequestV2: RpcTransport;
|
|
61
|
+
/**
|
|
62
|
+
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
63
|
+
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
64
|
+
*/
|
|
65
|
+
eip6963RequestProvider: () => void;
|
|
66
|
+
addFrame: AddFrame.AddFrame;
|
|
67
|
+
viewProfile: ViewProfile.ViewProfile;
|
|
68
|
+
};
|
|
72
69
|
export type FrameEthProviderEventData = {
|
|
73
|
-
|
|
74
|
-
} & EthProviderWireEvent
|
|
75
|
-
export type RpcTransport = (
|
|
76
|
-
request: RpcRequest.RpcRequest,
|
|
77
|
-
) => Promise<RpcResponse.RpcResponse>
|
|
70
|
+
type: 'frame_eth_provider_event';
|
|
71
|
+
} & EthProviderWireEvent;
|
|
72
|
+
export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
|
|
78
73
|
export type ProviderRpcError = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
export type EthProviderWireEvent =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
params: [Provider.Message]
|
|
103
|
-
}
|
|
104
|
-
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
|
|
105
|
-
event: event,
|
|
106
|
-
params: Extract<
|
|
107
|
-
EthProviderWireEvent,
|
|
108
|
-
{
|
|
109
|
-
event: event
|
|
110
|
-
}
|
|
111
|
-
>['params'],
|
|
112
|
-
) => void
|
|
74
|
+
code: number;
|
|
75
|
+
details?: string;
|
|
76
|
+
message?: string;
|
|
77
|
+
};
|
|
78
|
+
export type EthProviderWireEvent = {
|
|
79
|
+
event: 'accountsChanged';
|
|
80
|
+
params: [readonly Address.Address[]];
|
|
81
|
+
} | {
|
|
82
|
+
event: 'chainChanged';
|
|
83
|
+
params: [string];
|
|
84
|
+
} | {
|
|
85
|
+
event: 'connect';
|
|
86
|
+
params: [Provider.ConnectInfo];
|
|
87
|
+
} | {
|
|
88
|
+
event: 'disconnect';
|
|
89
|
+
params: [ProviderRpcError];
|
|
90
|
+
} | {
|
|
91
|
+
event: 'message';
|
|
92
|
+
params: [Provider.Message];
|
|
93
|
+
};
|
|
94
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
|
|
95
|
+
event: event;
|
|
96
|
+
}>['params']) => void;
|
|
113
97
|
export type EventFrameAddRejected = {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
98
|
+
event: 'frame_add_rejected';
|
|
99
|
+
reason: AddFrame.AddFrameRejectedReason;
|
|
100
|
+
};
|
|
117
101
|
export type EventPrimaryButtonClicked = {
|
|
118
|
-
|
|
119
|
-
}
|
|
102
|
+
event: 'primary_button_clicked';
|
|
103
|
+
};
|
|
120
104
|
/**
|
|
121
105
|
* Metadata of the EIP-1193 Provider.
|
|
122
106
|
*/
|
|
123
107
|
export interface EIP6963ProviderInfo {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
icon: `data:image/${string}`;
|
|
109
|
+
name: string;
|
|
110
|
+
rdns: string;
|
|
111
|
+
uuid: string;
|
|
128
112
|
}
|
|
129
113
|
export type EventEip6963AnnounceProvider = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
export type FrameClientEvent =
|
|
134
|
-
| EventFrameAdded
|
|
135
|
-
| EventFrameAddRejected
|
|
136
|
-
| EventFrameRemoved
|
|
137
|
-
| EventNotificationsEnabled
|
|
138
|
-
| EventNotificationsDisabled
|
|
139
|
-
| EventPrimaryButtonClicked
|
|
140
|
-
| EventEip6963AnnounceProvider
|
|
114
|
+
event: 'eip6963:announceProvider';
|
|
115
|
+
info: EIP6963ProviderInfo;
|
|
116
|
+
};
|
|
117
|
+
export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventEip6963AnnounceProvider;
|
package/esm/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_READY_OPTIONS = {
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
disableNativeGestures: false,
|
|
3
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farcaster/frame-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
12
13
|
"typescript": "^5.7.2",
|
|
14
|
+
"vitest": "^2.1.8",
|
|
13
15
|
"@farcaster/tsconfig": "0.0.2"
|
|
14
16
|
},
|
|
15
17
|
"dependencies": {
|
|
@@ -25,6 +27,9 @@
|
|
|
25
27
|
"build": "pnpm build:cjs & pnpm build:esm",
|
|
26
28
|
"build:cjs": "tsc -p tsconfig.node.json",
|
|
27
29
|
"build:esm": "tsc -p tsconfig.json",
|
|
28
|
-
"typecheck": "tsc --noEmit"
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:coverage": "vitest --coverage"
|
|
29
34
|
}
|
|
30
35
|
}
|
package/src/actions/index.ts
CHANGED
package/src/schemas/embeds.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import {
|
|
3
3
|
buttonTitleSchema,
|
|
4
|
+
caip19TokenSchema,
|
|
4
5
|
frameNameSchema,
|
|
5
6
|
hexColorSchema,
|
|
6
7
|
secureUrlSchema,
|
|
@@ -14,8 +15,14 @@ export const actionLaunchFrameSchema = z.object({
|
|
|
14
15
|
splashBackgroundColor: hexColorSchema.optional(),
|
|
15
16
|
})
|
|
16
17
|
|
|
18
|
+
export const actionViewTokenSchema = z.object({
|
|
19
|
+
type: z.literal('view_token'),
|
|
20
|
+
token: caip19TokenSchema,
|
|
21
|
+
})
|
|
22
|
+
|
|
17
23
|
export const actionSchema = z.discriminatedUnion('type', [
|
|
18
24
|
actionLaunchFrameSchema,
|
|
25
|
+
actionViewTokenSchema,
|
|
19
26
|
])
|
|
20
27
|
|
|
21
28
|
export const buttonSchema = z.object({
|
package/src/schemas/shared.ts
CHANGED
|
@@ -9,6 +9,13 @@ export const secureUrlSchema = z
|
|
|
9
9
|
export const frameNameSchema = z.string().max(32)
|
|
10
10
|
export const buttonTitleSchema = z.string().max(32)
|
|
11
11
|
|
|
12
|
+
const CAIP_19_REGEX =
|
|
13
|
+
/^[-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)$/
|
|
14
|
+
|
|
15
|
+
export const caip19TokenSchema = z
|
|
16
|
+
.string()
|
|
17
|
+
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' })
|
|
18
|
+
|
|
12
19
|
export const hexColorSchema = z
|
|
13
20
|
.string()
|
|
14
21
|
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
|
|
2
|
-
import type { AddFrame, SignIn } from './actions'
|
|
2
|
+
import type { AddFrame, SignIn, ViewProfile } from './actions'
|
|
3
3
|
import type { FrameContext } from './context'
|
|
4
4
|
import type {
|
|
5
5
|
EventFrameAdded,
|
|
@@ -63,6 +63,7 @@ export type WireFrameHost = {
|
|
|
63
63
|
ethProviderRequestV2: RpcTransport
|
|
64
64
|
eip6963RequestProvider: () => void
|
|
65
65
|
addFrame: AddFrame.WireAddFrame
|
|
66
|
+
viewProfile: ViewProfile.ViewProfile
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export type FrameHost = {
|
|
@@ -80,6 +81,7 @@ export type FrameHost = {
|
|
|
80
81
|
*/
|
|
81
82
|
eip6963RequestProvider: () => void
|
|
82
83
|
addFrame: AddFrame.AddFrame
|
|
84
|
+
viewProfile: ViewProfile.ViewProfile
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
export type FrameEthProviderEventData = {
|