@farcaster/frame-core 0.0.21 → 0.0.23
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/AddFrame.d.ts +36 -0
- package/dist/actions/AddFrame.js +57 -0
- package/dist/actions/{signIn.d.ts → SignIn.d.ts} +7 -6
- package/dist/actions/{signIn.js → SignIn.js} +1 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +38 -0
- package/dist/context.d.ts +72 -0
- package/dist/context.js +2 -0
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +6 -5
- package/dist/internal/types.d.ts +3 -2
- package/dist/schemas/embeds.d.ts +1 -1
- package/dist/schemas/embeds.js +3 -3
- package/dist/schemas/events.d.ts +1 -1
- package/dist/schemas/events.js +5 -5
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/manifest.d.ts +1 -1
- package/dist/schemas/manifest.js +4 -4
- package/dist/schemas/notifications.d.ts +1 -1
- package/dist/schemas/shared.d.ts +1 -1
- package/dist/schemas/shared.js +4 -4
- package/dist/types.d.ts +40 -80
- package/esm/actions/AddFrame.d.ts +40 -0
- package/esm/actions/AddFrame.js +19 -0
- package/esm/actions/SignIn.d.ts +43 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/index.d.ts +2 -0
- package/esm/actions/index.js +2 -0
- package/esm/context.d.ts +76 -0
- package/esm/context.js +1 -0
- package/esm/errors.d.ts +9 -7
- package/esm/errors.js +6 -6
- package/esm/index.d.ts +4 -3
- package/esm/index.js +4 -3
- package/esm/internal/types.d.ts +19 -7
- package/esm/internal/types.js +1 -1
- package/esm/schemas/embeds.d.ts +231 -169
- package/esm/schemas/embeds.js +25 -19
- package/esm/schemas/events.d.ts +225 -129
- package/esm/schemas/events.js +18 -18
- package/esm/schemas/index.d.ts +5 -5
- package/esm/schemas/index.js +5 -5
- package/esm/schemas/manifest.d.ts +154 -110
- package/esm/schemas/manifest.js +29 -23
- package/esm/schemas/notifications.d.ts +86 -58
- package/esm/schemas/notifications.js +17 -17
- package/esm/schemas/shared.d.ts +49 -33
- package/esm/schemas/shared.js +20 -19
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +132 -147
- package/esm/types.js +2 -2
- package/package.json +4 -5
- package/src/actions/AddFrame.ts +51 -0
- package/src/actions/SignIn.ts +51 -0
- package/src/actions/index.ts +2 -0
- package/src/context.ts +90 -0
- package/src/errors.ts +4 -4
- package/src/index.ts +4 -3
- package/src/internal/types.ts +3 -4
- package/src/schemas/embeds.ts +13 -13
- package/src/schemas/events.ts +17 -17
- package/src/schemas/index.ts +5 -5
- package/src/schemas/manifest.ts +11 -11
- package/src/schemas/notifications.ts +8 -10
- package/src/schemas/shared.ts +13 -13
- package/src/types.ts +88 -149
- package/esm/actions/signIn.d.ts +0 -40
- package/esm/actions/signIn.js +0 -10
- package/src/actions/signIn.ts +0 -50
package/src/schemas/manifest.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
buttonTitleSchema,
|
|
4
|
+
encodedJsonFarcasterSignatureSchema,
|
|
4
5
|
frameNameSchema,
|
|
5
6
|
hexColorSchema,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./shared";
|
|
7
|
+
secureUrlSchema,
|
|
8
|
+
} from './shared'
|
|
9
9
|
|
|
10
10
|
export const domainFrameConfigSchema = z.object({
|
|
11
11
|
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for
|
|
12
12
|
// backwards compatibilty. next should always resolve to the most recent
|
|
13
13
|
// schema version.
|
|
14
14
|
version: z.union([
|
|
15
|
-
z.literal(
|
|
16
|
-
z.literal(
|
|
17
|
-
z.literal(
|
|
18
|
-
z.literal('next')
|
|
15
|
+
z.literal('0.0.0'),
|
|
16
|
+
z.literal('0.0.1'),
|
|
17
|
+
z.literal('1'),
|
|
18
|
+
z.literal('next'),
|
|
19
19
|
]),
|
|
20
20
|
name: frameNameSchema,
|
|
21
21
|
iconUrl: secureUrlSchema,
|
|
@@ -25,9 +25,9 @@ export const domainFrameConfigSchema = z.object({
|
|
|
25
25
|
splashImageUrl: secureUrlSchema.optional(),
|
|
26
26
|
splashBackgroundColor: hexColorSchema.optional(),
|
|
27
27
|
webhookUrl: secureUrlSchema.optional(),
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
29
|
|
|
30
30
|
export const domainManifestSchema = z.object({
|
|
31
31
|
accountAssociation: encodedJsonFarcasterSignatureSchema,
|
|
32
32
|
frame: domainFrameConfigSchema.optional(),
|
|
33
|
-
})
|
|
33
|
+
})
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { secureUrlSchema } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { secureUrlSchema } from './shared'
|
|
3
3
|
|
|
4
4
|
export const notificationDetailsSchema = z.object({
|
|
5
5
|
url: z.string(),
|
|
6
6
|
token: z.string(),
|
|
7
|
-
})
|
|
7
|
+
})
|
|
8
8
|
|
|
9
|
-
export type FrameNotificationDetails = z.infer<
|
|
10
|
-
typeof notificationDetailsSchema
|
|
11
|
-
>;
|
|
9
|
+
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>
|
|
12
10
|
|
|
13
11
|
export const sendNotificationRequestSchema = z.object({
|
|
14
12
|
notificationId: z.string().max(128),
|
|
@@ -16,11 +14,11 @@ export const sendNotificationRequestSchema = z.object({
|
|
|
16
14
|
body: z.string().max(128),
|
|
17
15
|
targetUrl: secureUrlSchema,
|
|
18
16
|
tokens: z.string().array().max(100),
|
|
19
|
-
})
|
|
17
|
+
})
|
|
20
18
|
|
|
21
19
|
export type SendNotificationRequest = z.infer<
|
|
22
20
|
typeof sendNotificationRequestSchema
|
|
23
|
-
|
|
21
|
+
>
|
|
24
22
|
|
|
25
23
|
export const sendNotificationResponseSchema = z.object({
|
|
26
24
|
result: z.object({
|
|
@@ -28,8 +26,8 @@ export const sendNotificationResponseSchema = z.object({
|
|
|
28
26
|
invalidTokens: z.array(z.string()),
|
|
29
27
|
rateLimitedTokens: z.array(z.string()),
|
|
30
28
|
}),
|
|
31
|
-
})
|
|
29
|
+
})
|
|
32
30
|
|
|
33
31
|
export type SendNotificationResponse = z.infer<
|
|
34
32
|
typeof sendNotificationResponseSchema
|
|
35
|
-
|
|
33
|
+
>
|
package/src/schemas/shared.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
3
|
export const secureUrlSchema = z
|
|
4
4
|
.string()
|
|
5
5
|
.url()
|
|
6
|
-
.startsWith(
|
|
7
|
-
.max(512)
|
|
6
|
+
.startsWith('https://', { message: 'Must be an https url' })
|
|
7
|
+
.max(512)
|
|
8
8
|
|
|
9
|
-
export const frameNameSchema = z.string().max(32)
|
|
10
|
-
export const buttonTitleSchema = z.string().max(32)
|
|
9
|
+
export const frameNameSchema = z.string().max(32)
|
|
10
|
+
export const buttonTitleSchema = z.string().max(32)
|
|
11
11
|
|
|
12
12
|
export const hexColorSchema = z
|
|
13
13
|
.string()
|
|
14
14
|
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
|
15
15
|
message:
|
|
16
|
-
|
|
17
|
-
})
|
|
16
|
+
'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
|
|
17
|
+
})
|
|
18
18
|
|
|
19
19
|
export const encodedJsonFarcasterSignatureSchema = z.object({
|
|
20
20
|
header: z.string(),
|
|
21
21
|
payload: z.string(),
|
|
22
22
|
signature: z.string(),
|
|
23
|
-
})
|
|
23
|
+
})
|
|
24
24
|
|
|
25
25
|
export type EncodedJsonFarcasterSignatureSchema = z.infer<
|
|
26
26
|
typeof encodedJsonFarcasterSignatureSchema
|
|
27
|
-
|
|
27
|
+
>
|
|
28
28
|
|
|
29
29
|
export const jsonFarcasterSignatureHeaderSchema = z.object({
|
|
30
30
|
fid: z.number(),
|
|
31
|
-
type: z.literal(
|
|
32
|
-
key: z.string().startsWith(
|
|
33
|
-
})
|
|
31
|
+
type: z.literal('app_key'),
|
|
32
|
+
key: z.string().startsWith('0x'),
|
|
33
|
+
})
|
|
34
34
|
|
|
35
35
|
export type JsonFarcasterSignatureHeaderSchema = z.infer<
|
|
36
36
|
typeof jsonFarcasterSignatureHeaderSchema
|
|
37
|
-
|
|
37
|
+
>
|
package/src/types.ts
CHANGED
|
@@ -1,106 +1,23 @@
|
|
|
1
|
+
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
|
|
2
|
+
import type { AddFrame, SignIn } from './actions'
|
|
3
|
+
import type { FrameContext } from './context'
|
|
1
4
|
import type {
|
|
2
|
-
Address,
|
|
3
|
-
Provider,
|
|
4
|
-
RpcRequest,
|
|
5
|
-
RpcResponse,
|
|
6
|
-
RpcSchema,
|
|
7
|
-
} from "ox";
|
|
8
|
-
import {
|
|
9
|
-
FrameNotificationDetails,
|
|
10
5
|
EventFrameAdded,
|
|
11
6
|
EventFrameRemoved,
|
|
12
|
-
EventNotificationsEnabled,
|
|
13
7
|
EventNotificationsDisabled,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type SetPrimaryButton = (options: {
|
|
18
|
-
text: string;
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
hidden?: boolean;
|
|
22
|
-
}) => void;
|
|
23
|
-
|
|
24
|
-
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
|
|
8
|
+
EventNotificationsEnabled,
|
|
9
|
+
} from './schemas'
|
|
25
10
|
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type FrameLocationContextCastEmbed = {
|
|
35
|
-
type: "cast_embed";
|
|
36
|
-
embed: string;
|
|
37
|
-
cast: {
|
|
38
|
-
fid: number;
|
|
39
|
-
hash: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type FrameLocationContextNotification = {
|
|
44
|
-
type: "notification";
|
|
45
|
-
notification: {
|
|
46
|
-
notificationId: string;
|
|
47
|
-
title: string;
|
|
48
|
-
body: string;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type FrameLocationContextLauncher = {
|
|
53
|
-
type: "launcher";
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type FrameLocationContext =
|
|
57
|
-
| FrameLocationContextCastEmbed
|
|
58
|
-
| FrameLocationContextNotification
|
|
59
|
-
| FrameLocationContextLauncher;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export type SafeAreaInsets = {
|
|
63
|
-
top: number;
|
|
64
|
-
bottom: number;
|
|
65
|
-
left: number;
|
|
66
|
-
right: number;
|
|
11
|
+
export type SetPrimaryButtonOptions = {
|
|
12
|
+
text: string
|
|
13
|
+
loading?: boolean
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
hidden?: boolean
|
|
67
16
|
}
|
|
68
17
|
|
|
69
|
-
export type
|
|
70
|
-
user: {
|
|
71
|
-
fid: number;
|
|
72
|
-
username?: string;
|
|
73
|
-
displayName?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Profile image URL
|
|
76
|
-
*/
|
|
77
|
-
pfpUrl?: string;
|
|
78
|
-
location?: AccountLocation;
|
|
79
|
-
};
|
|
80
|
-
location?: FrameLocationContext;
|
|
81
|
-
client: {
|
|
82
|
-
clientFid: number;
|
|
83
|
-
added: boolean;
|
|
84
|
-
notificationDetails?: FrameNotificationDetails;
|
|
85
|
-
safeAreaInsets?: SafeAreaInsets;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type AddFrameRejectedReason =
|
|
90
|
-
| "invalid_domain_manifest"
|
|
91
|
-
| "rejected_by_user";
|
|
92
|
-
|
|
93
|
-
export type AddFrameResult =
|
|
94
|
-
| {
|
|
95
|
-
added: true;
|
|
96
|
-
notificationDetails?: FrameNotificationDetails;
|
|
97
|
-
}
|
|
98
|
-
| {
|
|
99
|
-
added: false;
|
|
100
|
-
reason: AddFrameRejectedReason;
|
|
101
|
-
};
|
|
18
|
+
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
|
|
102
19
|
|
|
103
|
-
export type
|
|
20
|
+
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>
|
|
104
21
|
|
|
105
22
|
export type ReadyOptions = {
|
|
106
23
|
/**
|
|
@@ -109,105 +26,126 @@ export type ReadyOptions = {
|
|
|
109
26
|
*
|
|
110
27
|
* @defaultValue false
|
|
111
28
|
*/
|
|
112
|
-
disableNativeGestures: boolean
|
|
113
|
-
}
|
|
29
|
+
disableNativeGestures: boolean
|
|
30
|
+
}
|
|
114
31
|
|
|
115
32
|
export const DEFAULT_READY_OPTIONS: ReadyOptions = {
|
|
116
33
|
disableNativeGestures: false,
|
|
117
|
-
}
|
|
34
|
+
}
|
|
118
35
|
|
|
119
36
|
export type SignInOptions = {
|
|
120
37
|
/**
|
|
121
38
|
* A random string used to prevent replay attacks.
|
|
122
39
|
*/
|
|
123
|
-
nonce: string
|
|
40
|
+
nonce: string
|
|
124
41
|
|
|
125
42
|
/**
|
|
126
43
|
* Start time at which the signature becomes valid.
|
|
127
44
|
* ISO 8601 datetime.
|
|
128
45
|
*/
|
|
129
|
-
notBefore?: string
|
|
46
|
+
notBefore?: string
|
|
130
47
|
|
|
131
48
|
/**
|
|
132
49
|
* Expiration time at which the signature is no longer valid.
|
|
133
50
|
* ISO 8601 datetime.
|
|
134
51
|
*/
|
|
135
|
-
expirationTime?: string
|
|
136
|
-
}
|
|
52
|
+
expirationTime?: string
|
|
53
|
+
}
|
|
137
54
|
|
|
138
55
|
export type WireFrameHost = {
|
|
139
|
-
context: FrameContext
|
|
140
|
-
close: () => void
|
|
141
|
-
ready: (options?: Partial<ReadyOptions>) => void
|
|
142
|
-
openUrl: (url: string) => void
|
|
143
|
-
signIn: SignIn.WireSignIn
|
|
144
|
-
setPrimaryButton: SetPrimaryButton
|
|
145
|
-
ethProviderRequest: EthProviderRequest
|
|
146
|
-
ethProviderRequestV2: RpcTransport
|
|
147
|
-
|
|
148
|
-
|
|
56
|
+
context: FrameContext
|
|
57
|
+
close: () => void
|
|
58
|
+
ready: (options?: Partial<ReadyOptions>) => void
|
|
59
|
+
openUrl: (url: string) => void
|
|
60
|
+
signIn: SignIn.WireSignIn
|
|
61
|
+
setPrimaryButton: SetPrimaryButton
|
|
62
|
+
ethProviderRequest: EthProviderRequest
|
|
63
|
+
ethProviderRequestV2: RpcTransport
|
|
64
|
+
eip6963RequestProvider: () => void
|
|
65
|
+
addFrame: AddFrame.WireAddFrame
|
|
66
|
+
}
|
|
149
67
|
|
|
150
68
|
export type FrameHost = {
|
|
151
|
-
context: FrameContext
|
|
152
|
-
close: () => void
|
|
153
|
-
ready: (options?: Partial<ReadyOptions>) => void
|
|
154
|
-
openUrl: (url: string) => void
|
|
155
|
-
signIn: SignIn.SignIn
|
|
156
|
-
setPrimaryButton: SetPrimaryButton
|
|
157
|
-
ethProviderRequest: EthProviderRequest
|
|
158
|
-
ethProviderRequestV2: RpcTransport
|
|
159
|
-
|
|
160
|
-
|
|
69
|
+
context: FrameContext
|
|
70
|
+
close: () => void
|
|
71
|
+
ready: (options?: Partial<ReadyOptions>) => void
|
|
72
|
+
openUrl: (url: string) => void
|
|
73
|
+
signIn: SignIn.SignIn
|
|
74
|
+
setPrimaryButton: SetPrimaryButton
|
|
75
|
+
ethProviderRequest: EthProviderRequest
|
|
76
|
+
ethProviderRequestV2: RpcTransport
|
|
77
|
+
/**
|
|
78
|
+
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
79
|
+
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
80
|
+
*/
|
|
81
|
+
eip6963RequestProvider: () => void
|
|
82
|
+
addFrame: AddFrame.AddFrame
|
|
83
|
+
}
|
|
161
84
|
|
|
162
85
|
export type FrameEthProviderEventData = {
|
|
163
|
-
type:
|
|
164
|
-
} & EthProviderWireEvent
|
|
86
|
+
type: 'frame_eth_provider_event'
|
|
87
|
+
} & EthProviderWireEvent
|
|
165
88
|
|
|
166
89
|
export type RpcTransport = (
|
|
167
90
|
request: RpcRequest.RpcRequest,
|
|
168
|
-
) => Promise<RpcResponse.RpcResponse
|
|
91
|
+
) => Promise<RpcResponse.RpcResponse>
|
|
169
92
|
|
|
170
93
|
export type ProviderRpcError = {
|
|
171
|
-
code: number
|
|
172
|
-
details?: string
|
|
173
|
-
message?: string
|
|
174
|
-
}
|
|
94
|
+
code: number
|
|
95
|
+
details?: string
|
|
96
|
+
message?: string
|
|
97
|
+
}
|
|
175
98
|
|
|
176
99
|
export type EthProviderWireEvent =
|
|
177
100
|
| {
|
|
178
|
-
event:
|
|
179
|
-
params: [readonly Address.Address[]]
|
|
101
|
+
event: 'accountsChanged'
|
|
102
|
+
params: [readonly Address.Address[]]
|
|
180
103
|
}
|
|
181
104
|
| {
|
|
182
|
-
event:
|
|
183
|
-
params: [string]
|
|
105
|
+
event: 'chainChanged'
|
|
106
|
+
params: [string]
|
|
184
107
|
}
|
|
185
108
|
| {
|
|
186
|
-
event:
|
|
187
|
-
params: [Provider.ConnectInfo]
|
|
109
|
+
event: 'connect'
|
|
110
|
+
params: [Provider.ConnectInfo]
|
|
188
111
|
}
|
|
189
112
|
| {
|
|
190
|
-
event:
|
|
191
|
-
params: [ProviderRpcError]
|
|
113
|
+
event: 'disconnect'
|
|
114
|
+
params: [ProviderRpcError]
|
|
192
115
|
}
|
|
193
116
|
| {
|
|
194
|
-
event:
|
|
195
|
-
params: [Provider.Message]
|
|
196
|
-
}
|
|
117
|
+
event: 'message'
|
|
118
|
+
params: [Provider.Message]
|
|
119
|
+
}
|
|
197
120
|
|
|
198
|
-
export type EmitEthProvider = <event extends EthProviderWireEvent[
|
|
121
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
|
|
199
122
|
event: event,
|
|
200
|
-
params: Extract<EthProviderWireEvent, { event: event }>[
|
|
201
|
-
) => void
|
|
123
|
+
params: Extract<EthProviderWireEvent, { event: event }>['params'],
|
|
124
|
+
) => void
|
|
202
125
|
|
|
203
126
|
export type EventFrameAddRejected = {
|
|
204
|
-
event:
|
|
205
|
-
reason: AddFrameRejectedReason
|
|
206
|
-
}
|
|
127
|
+
event: 'frame_add_rejected'
|
|
128
|
+
reason: AddFrame.AddFrameRejectedReason
|
|
129
|
+
}
|
|
207
130
|
|
|
208
131
|
export type EventPrimaryButtonClicked = {
|
|
209
|
-
event:
|
|
210
|
-
}
|
|
132
|
+
event: 'primary_button_clicked'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Metadata of the EIP-1193 Provider.
|
|
137
|
+
*/
|
|
138
|
+
export interface EIP6963ProviderInfo {
|
|
139
|
+
icon: `data:image/${string}` // RFC-2397
|
|
140
|
+
name: string
|
|
141
|
+
rdns: string
|
|
142
|
+
uuid: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type EventEip6963AnnounceProvider = {
|
|
146
|
+
event: 'eip6963:announceProvider'
|
|
147
|
+
info: EIP6963ProviderInfo
|
|
148
|
+
}
|
|
211
149
|
|
|
212
150
|
export type FrameClientEvent =
|
|
213
151
|
| EventFrameAdded
|
|
@@ -215,4 +153,5 @@ export type FrameClientEvent =
|
|
|
215
153
|
| EventFrameRemoved
|
|
216
154
|
| EventNotificationsEnabled
|
|
217
155
|
| EventNotificationsDisabled
|
|
218
|
-
| EventPrimaryButtonClicked
|
|
156
|
+
| EventPrimaryButtonClicked
|
|
157
|
+
| EventEip6963AnnounceProvider
|
package/esm/actions/signIn.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as Errors from '../errors';
|
|
2
|
-
import { OneOf } from '../internal/types';
|
|
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
|
-
};
|
|
19
|
-
export type SignInResult = {
|
|
20
|
-
signature: string;
|
|
21
|
-
message: string;
|
|
22
|
-
};
|
|
23
|
-
export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
|
|
24
|
-
export type RejectedByUserError = {
|
|
25
|
-
type: 'rejected_by_user';
|
|
26
|
-
};
|
|
27
|
-
export type JsonSignInError = RejectedByUserError;
|
|
28
|
-
export type WireSignInResponse = OneOf<{
|
|
29
|
-
result: SignInResult;
|
|
30
|
-
} | {
|
|
31
|
-
error: JsonSignInError;
|
|
32
|
-
}>;
|
|
33
|
-
export type WireSignIn = (options: SignInOptions) => Promise<WireSignInResponse>;
|
|
34
|
-
/**
|
|
35
|
-
* Thrown when a sign in action was rejected.
|
|
36
|
-
*/
|
|
37
|
-
export declare class RejectedByUser extends Errors.BaseError {
|
|
38
|
-
readonly name = "SignIn.RejectedByUser";
|
|
39
|
-
constructor();
|
|
40
|
-
}
|
package/esm/actions/signIn.js
DELETED
package/src/actions/signIn.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Address } from 'ox';
|
|
2
|
-
import * as Errors from '../errors'
|
|
3
|
-
import { OneOf } from '../internal/types';
|
|
4
|
-
|
|
5
|
-
export type SignInOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* A random string used to prevent replay attacks.
|
|
8
|
-
*/
|
|
9
|
-
nonce: string;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Start time at which the signature becomes valid.
|
|
13
|
-
* ISO 8601 datetime.
|
|
14
|
-
*/
|
|
15
|
-
notBefore?: string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Expiration time at which the signature is no longer valid.
|
|
19
|
-
* ISO 8601 datetime.
|
|
20
|
-
*/
|
|
21
|
-
expirationTime?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type SignInResult = {
|
|
25
|
-
signature: string;
|
|
26
|
-
message: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
|
|
30
|
-
|
|
31
|
-
export type RejectedByUserError = {
|
|
32
|
-
type: 'rejected_by_user'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type JsonSignInError = RejectedByUserError;
|
|
36
|
-
|
|
37
|
-
export type WireSignInResponse = OneOf<{ result: SignInResult } | { error: JsonSignInError }>
|
|
38
|
-
|
|
39
|
-
export type WireSignIn = (options: SignInOptions) => Promise<WireSignInResponse>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Thrown when a sign in action was rejected.
|
|
43
|
-
*/
|
|
44
|
-
export class RejectedByUser extends Errors.BaseError {
|
|
45
|
-
override readonly name = 'SignIn.RejectedByUser'
|
|
46
|
-
|
|
47
|
-
constructor() {
|
|
48
|
-
super("Sign in rejected by user")
|
|
49
|
-
}
|
|
50
|
-
}
|