accounts 0.3.0 → 0.4.1
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/core/AccessKey.d.ts +55 -0
- package/dist/core/AccessKey.d.ts.map +1 -0
- package/dist/core/AccessKey.js +69 -0
- package/dist/core/AccessKey.js.map +1 -0
- package/dist/core/Account.d.ts +91 -0
- package/dist/core/Account.d.ts.map +1 -0
- package/dist/core/Account.js +64 -0
- package/dist/core/Account.js.map +1 -0
- package/dist/core/Adapter.d.ts +187 -0
- package/dist/core/Adapter.d.ts.map +1 -0
- package/dist/core/Adapter.js +7 -0
- package/dist/core/Adapter.js.map +1 -0
- package/dist/core/Ceremony.d.ts +109 -0
- package/dist/core/Ceremony.d.ts.map +1 -0
- package/dist/core/Ceremony.js +104 -0
- package/dist/core/Ceremony.js.map +1 -0
- package/dist/core/Client.d.ts +16 -0
- package/dist/core/Client.d.ts.map +1 -0
- package/dist/core/Client.js +18 -0
- package/dist/core/Client.js.map +1 -0
- package/dist/core/Dialog.d.ts +52 -0
- package/dist/core/Dialog.d.ts.map +1 -0
- package/dist/core/Dialog.js +342 -0
- package/dist/core/Dialog.js.map +1 -0
- package/dist/core/Expiry.d.ts +15 -0
- package/dist/core/Expiry.d.ts.map +1 -0
- package/dist/core/Expiry.js +29 -0
- package/dist/core/Expiry.js.map +1 -0
- package/dist/core/Messenger.d.ts +86 -0
- package/dist/core/Messenger.d.ts.map +1 -0
- package/dist/core/Messenger.js +127 -0
- package/dist/core/Messenger.js.map +1 -0
- package/dist/core/Provider.d.ts +69 -0
- package/dist/core/Provider.d.ts.map +1 -0
- package/dist/core/Provider.js +401 -0
- package/dist/core/Provider.js.map +1 -0
- package/dist/core/Remote.d.ts +114 -0
- package/dist/core/Remote.d.ts.map +1 -0
- package/dist/core/Remote.js +116 -0
- package/dist/core/Remote.js.map +1 -0
- package/dist/core/Schema.d.ts +805 -0
- package/dist/core/Schema.d.ts.map +1 -0
- package/dist/core/Schema.js +43 -0
- package/dist/core/Schema.js.map +1 -0
- package/dist/core/Storage.d.ts +42 -0
- package/dist/core/Storage.d.ts.map +1 -0
- package/dist/core/Storage.js +173 -0
- package/dist/core/Storage.js.map +1 -0
- package/dist/core/Store.d.ts +58 -0
- package/dist/core/Store.d.ts.map +1 -0
- package/dist/core/Store.js +58 -0
- package/dist/core/Store.js.map +1 -0
- package/dist/core/adapters/dangerous_secp256k1.d.ts +30 -0
- package/dist/core/adapters/dangerous_secp256k1.d.ts.map +1 -0
- package/dist/core/adapters/dangerous_secp256k1.js +39 -0
- package/dist/core/adapters/dangerous_secp256k1.js.map +1 -0
- package/dist/core/adapters/dialog.d.ts +31 -0
- package/dist/core/adapters/dialog.d.ts.map +1 -0
- package/dist/core/adapters/dialog.js +306 -0
- package/dist/core/adapters/dialog.js.map +1 -0
- package/dist/core/adapters/local.d.ts +33 -0
- package/dist/core/adapters/local.d.ts.map +1 -0
- package/dist/core/adapters/local.js +227 -0
- package/dist/core/adapters/local.js.map +1 -0
- package/dist/core/adapters/webAuthn.d.ts +36 -0
- package/dist/core/adapters/webAuthn.d.ts.map +1 -0
- package/dist/core/adapters/webAuthn.js +93 -0
- package/dist/core/adapters/webAuthn.js.map +1 -0
- package/dist/core/internal/withDedupe.d.ts +12 -0
- package/dist/core/internal/withDedupe.d.ts.map +1 -0
- package/dist/core/internal/withDedupe.js +12 -0
- package/dist/core/internal/withDedupe.js.map +1 -0
- package/dist/core/zod/request.d.ts +31 -0
- package/dist/core/zod/request.d.ts.map +1 -0
- package/dist/core/zod/request.js +41 -0
- package/dist/core/zod/request.js.map +1 -0
- package/dist/core/zod/rpc.d.ts +603 -0
- package/dist/core/zod/rpc.d.ts.map +1 -0
- package/dist/core/zod/rpc.js +293 -0
- package/dist/core/zod/rpc.js.map +1 -0
- package/dist/core/zod/utils.d.ts +18 -0
- package/dist/core/zod/utils.d.ts.map +1 -0
- package/dist/core/zod/utils.js +21 -0
- package/dist/core/zod/utils.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/types.d.ts +284 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +2 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/server/Handler.d.ts +257 -0
- package/dist/server/Handler.d.ts.map +1 -0
- package/dist/server/Handler.js +433 -0
- package/dist/server/Handler.js.map +1 -0
- package/dist/server/Kv.d.ts +16 -0
- package/dist/server/Kv.d.ts.map +1 -0
- package/dist/server/Kv.js +30 -0
- package/dist/server/Kv.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/internal/requestListener.d.ts +124 -0
- package/dist/server/internal/requestListener.d.ts.map +1 -0
- package/dist/server/internal/requestListener.js +173 -0
- package/dist/server/internal/requestListener.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +93 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +238 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/index.d.ts +3 -0
- package/dist/wagmi/index.d.ts.map +1 -0
- package/dist/wagmi/index.js +3 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +56 -2
- package/src/core/AccessKey.test.ts +257 -0
- package/src/core/AccessKey.ts +123 -0
- package/src/core/Account.test.ts +309 -0
- package/src/core/Account.ts +152 -0
- package/src/core/Adapter.ts +238 -0
- package/src/core/Ceremony.browser.test.ts +239 -0
- package/src/core/Ceremony.test.ts +151 -0
- package/src/core/Ceremony.ts +203 -0
- package/src/core/Client.ts +36 -0
- package/src/core/Dialog.browser.test.ts +309 -0
- package/src/core/Dialog.test-d.ts +19 -0
- package/src/core/Dialog.ts +442 -0
- package/src/core/Expiry.ts +34 -0
- package/src/core/Messenger.ts +206 -0
- package/src/core/Provider.browser.test.ts +774 -0
- package/src/core/Provider.connect.browser.test.ts +415 -0
- package/src/core/Provider.test-d.ts +53 -0
- package/src/core/Provider.test.ts +1566 -0
- package/src/core/Provider.ts +559 -0
- package/src/core/Remote.ts +262 -0
- package/src/core/Schema.test-d.ts +211 -0
- package/src/core/Schema.ts +143 -0
- package/src/core/Storage.ts +213 -0
- package/src/core/Store.test.ts +287 -0
- package/src/core/Store.ts +129 -0
- package/src/core/adapters/dangerous_secp256k1.ts +53 -0
- package/src/core/adapters/dialog.ts +379 -0
- package/src/core/adapters/local.test.ts +97 -0
- package/src/core/adapters/local.ts +277 -0
- package/src/core/adapters/webAuthn.ts +129 -0
- package/src/core/internal/withDedupe.test.ts +116 -0
- package/src/core/internal/withDedupe.ts +20 -0
- package/src/core/mppx.test.ts +83 -0
- package/src/core/zod/request.test.ts +121 -0
- package/src/core/zod/request.ts +70 -0
- package/src/core/zod/rpc.ts +374 -0
- package/src/core/zod/utils.test.ts +69 -0
- package/src/core/zod/utils.ts +40 -0
- package/src/index.ts +14 -0
- package/src/internal/types.ts +378 -0
- package/src/server/Handler.test.ts +1014 -0
- package/src/server/Handler.ts +605 -0
- package/src/server/Kv.ts +46 -0
- package/src/server/index.ts +2 -0
- package/src/server/internal/requestListener.ts +273 -0
- package/src/tsconfig.json +9 -0
- package/src/wagmi/Connector.ts +287 -0
- package/src/wagmi/index.ts +2 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/** Combines members of an intersection into a readable type. */
|
|
2
|
+
export type Compute<type> = {
|
|
3
|
+
[key in keyof type]: type[key];
|
|
4
|
+
} & unknown;
|
|
5
|
+
declare const symbol: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a branded type of `T` with the brand `U`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* type Result = Branded<string, 'foo'>
|
|
12
|
+
* // ^? type Result = string & { [symbol]: 'foo' }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type Branded<T, U> = T & {
|
|
16
|
+
[symbol]: U;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Filters out all members of `T` that are not `P`
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* type Result = Filter<['a', 'b', 'c'], 'b'>
|
|
24
|
+
* // ^? type Result = ['a', 'c']
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export type Filter<T extends readonly unknown[], P, Acc extends readonly unknown[] = []> = T extends readonly [infer F, ...infer Rest extends readonly unknown[]] ? [F] extends [P] ? Filter<Rest, P, [...Acc, F]> : Filter<Rest, P, Acc> : readonly [...Acc];
|
|
30
|
+
/**
|
|
31
|
+
* Checks if `T` can be narrowed further than `U`
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* type Result = IsNarrowable<'foo', string>
|
|
36
|
+
* // ^? true
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export type IsNarrowable<T, U> = IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if `T` is `never`
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* type Result = IsNever<never>
|
|
46
|
+
* // ^? type Result = true
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
50
|
+
/**
|
|
51
|
+
* Removes `readonly` from all properties of an object.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export type Mutable<type extends object> = {
|
|
56
|
+
-readonly [key in keyof type]: type[key];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Evaluates boolean "or" condition for `T` properties.
|
|
60
|
+
*
|
|
61
|
+
* * @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* type Result = Or<[false, true, false]>
|
|
64
|
+
* // ^? type Result = true
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* type Result = Or<[false, false, false]>
|
|
70
|
+
* // ^? type Result = false
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export type Or<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Tail] ? Head extends true ? true : Or<Tail> : false;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if `T` is `undefined`
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* type Result = IsUndefined<undefined>
|
|
82
|
+
* // ^? type Result = true
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export type IsUndefined<T> = [undefined] extends [T] ? true : false;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if type `T` is the `unknown` type.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export type IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;
|
|
94
|
+
/** @internal */
|
|
95
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Makes attributes on the type T required if required is true.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* MaybeRequired<{ a: string, b?: number }, true>
|
|
102
|
+
* // { a: string, b: number }
|
|
103
|
+
*
|
|
104
|
+
* MaybeRequired<{ a: string, b?: number }, false>
|
|
105
|
+
* // { a: string, b?: number }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
export type MaybeRequired<T, required extends boolean> = required extends true ? ExactRequired<T> : T;
|
|
111
|
+
/**
|
|
112
|
+
* Assigns the properties of U onto T.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
|
|
117
|
+
* // { a: undefined, b: number, c: boolean }
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export type Assign<T, U> = Assign_inner<T, U> & U;
|
|
123
|
+
/** @internal */
|
|
124
|
+
export type Assign_inner<T, U> = {
|
|
125
|
+
[K in keyof T as K extends keyof U ? (U[K] extends void ? never : K) : K]: K extends keyof U ? U[K] : T[K];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Constructs a type by excluding `undefined` from `T`.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* NoUndefined<string | undefined>
|
|
133
|
+
* // string
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
|
139
|
+
/**
|
|
140
|
+
* Strict version of built-in Omit type
|
|
141
|
+
*
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
export type Omit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a type that is a partial of T, but with the required keys K.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* PartialBy<{ a: string, b: number }, 'a'>
|
|
151
|
+
* // { a?: string, b: number }
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & ExactPartial<Pick<T, K>>;
|
|
157
|
+
export type RecursiveArray<T> = T | readonly RecursiveArray<T>[];
|
|
158
|
+
/**
|
|
159
|
+
* Creates a type that is T with the required keys K.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* RequiredBy<{ a?: string, b: number }, 'a'>
|
|
164
|
+
* // { a: string, b: number }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
export type RequiredBy<T, K extends keyof T> = Omit<T, K> & ExactRequired<Pick<T, K>>;
|
|
170
|
+
/**
|
|
171
|
+
* Returns truthy if `array` contains `value`.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* Some<[1, 2, 3], 2>
|
|
176
|
+
* // true
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
export type Some<array extends readonly unknown[], value> = array extends readonly [
|
|
182
|
+
value,
|
|
183
|
+
...unknown[]
|
|
184
|
+
] ? true : array extends readonly [unknown, ...infer rest] ? Some<rest, value> : false;
|
|
185
|
+
/**
|
|
186
|
+
* Prints custom error message
|
|
187
|
+
*
|
|
188
|
+
* @param messages - Error message
|
|
189
|
+
* @returns Custom error message
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* type Result = TypeErrorMessage<'Custom error message'>
|
|
194
|
+
* // ^? type Result = ['Error: Custom error message']
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export type TypeErrorMessage<messages extends string | string[]> = messages extends string ? [
|
|
198
|
+
`Error: ${messages}`
|
|
199
|
+
] : {
|
|
200
|
+
[key in keyof messages]: messages[key] extends infer message extends string ? `Error: ${message}` : never;
|
|
201
|
+
};
|
|
202
|
+
/** @internal */
|
|
203
|
+
export type UnionToTuple<union, last = LastInUnion<union>> = [union] extends [never] ? [] : [...UnionToTuple<Exclude<union, last>>, last];
|
|
204
|
+
/** @internal */
|
|
205
|
+
export type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer l) => 0 ? l : never;
|
|
206
|
+
/** @internal */
|
|
207
|
+
export type UnionToIntersection<union> = (union extends unknown ? (arg: union) => 0 : never) extends (arg: infer i) => 0 ? i : never;
|
|
208
|
+
/** @internal */
|
|
209
|
+
export type IsUnion<union, union2 = union> = union extends union2 ? ([union2] extends [union] ? false : true) : never;
|
|
210
|
+
/** @internal */
|
|
211
|
+
export type MaybePartial<type, enabled extends boolean | undefined> = enabled extends true ? Compute<ExactPartial<type>> : type;
|
|
212
|
+
export type ExactPartial<type> = {
|
|
213
|
+
[key in keyof type]?: type[key] | undefined;
|
|
214
|
+
};
|
|
215
|
+
/** @internal */
|
|
216
|
+
export type ExactRequired<type> = {
|
|
217
|
+
[key in keyof type]-?: Exclude<type[key], undefined>;
|
|
218
|
+
};
|
|
219
|
+
export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & {
|
|
220
|
+
[key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
|
|
221
|
+
}> : never;
|
|
222
|
+
/** @internal */
|
|
223
|
+
export type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
224
|
+
/** @internal */
|
|
225
|
+
export type Undefined<type> = {
|
|
226
|
+
[key in keyof type]?: undefined;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Loose version of {@link Omit}
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
export type LooseOmit<type, keys extends string> = Pick<type, Exclude<keyof type, keys>>;
|
|
233
|
+
/** @internal */
|
|
234
|
+
export type UnionCompute<type> = type extends object ? Compute<type> : type;
|
|
235
|
+
/** @internal */
|
|
236
|
+
export type UnionLooseOmit<type, keys extends string> = type extends any ? LooseOmit<type, keys> : never;
|
|
237
|
+
/**
|
|
238
|
+
* Construct a type with the properties of union type T except for those in type K.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
242
|
+
* // { b: number } | { b: undefined, c: number }
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
export type UnionOmit<type, keys extends keyof type> = type extends any ? Omit<type, keys> : never;
|
|
248
|
+
/**
|
|
249
|
+
* Construct a type with the properties of union type T except for those in type K.
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
253
|
+
* // { b: number } | { b: undefined, c: number }
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* @internal
|
|
257
|
+
*/
|
|
258
|
+
export type UnionPick<type, keys extends keyof type> = type extends any ? Pick<type, keys> : never;
|
|
259
|
+
/**
|
|
260
|
+
* Creates a type that is a partial of T, but with the required keys K.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* PartialBy<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
265
|
+
* // { a?: string, b: number } | { a?: string, b: undefined, c: number }
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
export type UnionPartialBy<T, K extends keyof T> = T extends any ? PartialBy<T, K> : never;
|
|
271
|
+
/**
|
|
272
|
+
* Creates a type that is T with the required keys K.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* RequiredBy<{ a?: string, b: number } | { a?: string, c?: number }, 'a'>
|
|
277
|
+
* // { a: string, b: number } | { a: string, c?: number }
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @internal
|
|
281
|
+
*/
|
|
282
|
+
export type UnionRequiredBy<T, K extends keyof T> = T extends any ? RequiredBy<T, K> : never;
|
|
283
|
+
export {};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ings":""}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { type Router, type RouterOptions } from '@remix-run/fetch-router';
|
|
2
|
+
import { RpcRequest } from 'ox';
|
|
3
|
+
import { type Chain, type Transport } from 'viem';
|
|
4
|
+
import type { LocalAccount } from 'viem/accounts';
|
|
5
|
+
import type { Kv } from './Kv.js';
|
|
6
|
+
export type Handler = Omit<Router, 'fetch'> & {
|
|
7
|
+
fetch: (input: string | URL | Request, ...args: any[]) => Promise<Response>;
|
|
8
|
+
listener: (req: any, res: any) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function compose(handlers: Handler[], options?: compose.Options): Handler;
|
|
11
|
+
export declare namespace compose {
|
|
12
|
+
type Options = from.Options & {
|
|
13
|
+
/** The path to use for the handler. */
|
|
14
|
+
path?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Instantiates a new request handler.
|
|
19
|
+
*
|
|
20
|
+
* @param options - constructor options
|
|
21
|
+
* @returns Handler instance
|
|
22
|
+
*/
|
|
23
|
+
export declare function from(options?: from.Options): Handler;
|
|
24
|
+
export declare namespace from {
|
|
25
|
+
type Options = RouterOptions & {
|
|
26
|
+
/**
|
|
27
|
+
* CORS configuration.
|
|
28
|
+
* - `true` (default): Allow all origins with default methods/headers
|
|
29
|
+
* - `false`: Disable CORS headers
|
|
30
|
+
* - Object: Custom CORS configuration
|
|
31
|
+
*/
|
|
32
|
+
cors?: boolean | Cors | undefined;
|
|
33
|
+
/** Headers to add to the response. */
|
|
34
|
+
headers?: Headers | Record<string, string> | undefined;
|
|
35
|
+
};
|
|
36
|
+
type Cors = {
|
|
37
|
+
/** Allowed origins. Defaults to `'*'`. */
|
|
38
|
+
origin?: string | string[] | undefined;
|
|
39
|
+
/** Allowed methods. Defaults to `'GET, POST, PUT, DELETE, OPTIONS'`. */
|
|
40
|
+
methods?: string | undefined;
|
|
41
|
+
/** Allowed headers. Defaults to `'Content-Type'`. */
|
|
42
|
+
headers?: string | undefined;
|
|
43
|
+
/** Whether to allow credentials. */
|
|
44
|
+
credentials?: boolean | undefined;
|
|
45
|
+
/** Headers to expose to the browser. */
|
|
46
|
+
exposeHeaders?: string | undefined;
|
|
47
|
+
/** Max age for preflight cache in seconds. */
|
|
48
|
+
maxAge?: number | undefined;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Instantiates a fee payer service request handler that can be used to
|
|
53
|
+
* sponsor the fee for user transactions.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ### Cloudflare Worker
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
60
|
+
* import { Handler } from 'accounts/server'
|
|
61
|
+
*
|
|
62
|
+
* export default {
|
|
63
|
+
* fetch(request) {
|
|
64
|
+
* return Handler.feePayer({
|
|
65
|
+
* account: privateKeyToAccount('0x...'),
|
|
66
|
+
* }).fetch(request)
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ### Next.js
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
76
|
+
* import { Handler } from 'accounts/server'
|
|
77
|
+
*
|
|
78
|
+
* const handler = Handler.feePayer({
|
|
79
|
+
* account: privateKeyToAccount('0x...'),
|
|
80
|
+
* })
|
|
81
|
+
*
|
|
82
|
+
* export GET = handler.fetch
|
|
83
|
+
* export POST = handler.fetch
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ### Hono
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
91
|
+
* import { Handler } from 'accounts/server'
|
|
92
|
+
*
|
|
93
|
+
* const handler = Handler.feePayer({
|
|
94
|
+
* account: privateKeyToAccount('0x...'),
|
|
95
|
+
* })
|
|
96
|
+
*
|
|
97
|
+
* const app = new Hono()
|
|
98
|
+
* app.all('*', handler)
|
|
99
|
+
*
|
|
100
|
+
* export default app
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ### Node.js
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
108
|
+
* import { Handler } from 'accounts/server'
|
|
109
|
+
*
|
|
110
|
+
* const handler = Handler.feePayer({
|
|
111
|
+
* account: privateKeyToAccount('0x...'),
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* const server = createServer(handler.listener)
|
|
115
|
+
* server.listen(3000)
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ### Bun
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
123
|
+
* import { Handler } from 'accounts/server'
|
|
124
|
+
*
|
|
125
|
+
* const handler = Handler.feePayer({
|
|
126
|
+
* account: privateKeyToAccount('0x...'),
|
|
127
|
+
* })
|
|
128
|
+
*
|
|
129
|
+
* Bun.serve(handler)
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ### Deno
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
137
|
+
* import { Handler } from 'accounts/server'
|
|
138
|
+
*
|
|
139
|
+
* const handler = Handler.feePayer({
|
|
140
|
+
* account: privateKeyToAccount('0x...'),
|
|
141
|
+
* })
|
|
142
|
+
*
|
|
143
|
+
* Deno.serve(handler)
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ### Express
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
151
|
+
* import { Handler } from 'accounts/server'
|
|
152
|
+
*
|
|
153
|
+
* const handler = Handler.feePayer({
|
|
154
|
+
* account: privateKeyToAccount('0x...'),
|
|
155
|
+
* })
|
|
156
|
+
*
|
|
157
|
+
* const app = express()
|
|
158
|
+
* app.use(handler.listener)
|
|
159
|
+
* app.listen(3000)
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ### Custom chains & transports
|
|
164
|
+
*
|
|
165
|
+
* ```ts
|
|
166
|
+
* import { http } from 'viem'
|
|
167
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
168
|
+
* import { tempo, tempoModerato } from 'viem/chains'
|
|
169
|
+
* import { Handler } from 'accounts/server'
|
|
170
|
+
*
|
|
171
|
+
* const handler = Handler.feePayer({
|
|
172
|
+
* account: privateKeyToAccount('0x...'),
|
|
173
|
+
* chains: [tempo, tempoModerato],
|
|
174
|
+
* transports: {
|
|
175
|
+
* [tempo.id]: http('https://rpc.tempo.xyz'),
|
|
176
|
+
* [tempoModerato.id]: http('https://rpc.moderato.tempo.xyz'),
|
|
177
|
+
* },
|
|
178
|
+
* })
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @param options - Options.
|
|
182
|
+
* @returns Request handler.
|
|
183
|
+
*/
|
|
184
|
+
export declare function feePayer(options: feePayer.Options): Handler;
|
|
185
|
+
export declare namespace feePayer {
|
|
186
|
+
type Options = from.Options & {
|
|
187
|
+
/** Account to use as the fee payer. */
|
|
188
|
+
account: LocalAccount;
|
|
189
|
+
/**
|
|
190
|
+
* Supported chains. The handler resolves the client based on the
|
|
191
|
+
* `chainId` in the incoming transaction.
|
|
192
|
+
* @default [tempo, tempoModerato]
|
|
193
|
+
*/
|
|
194
|
+
chains?: readonly [Chain, ...Chain[]] | undefined;
|
|
195
|
+
/** Function to call before handling the request. */
|
|
196
|
+
onRequest?: (request: RpcRequest.RpcRequest) => Promise<void>;
|
|
197
|
+
/** Path to use for the handler. */
|
|
198
|
+
path?: string | undefined;
|
|
199
|
+
/** Transports keyed by chain ID. Defaults to `http()` for each chain. */
|
|
200
|
+
transports?: Record<number, Transport> | undefined;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Instantiates a WebAuthn ceremony handler that manages registration and
|
|
205
|
+
* authentication flows server-side.
|
|
206
|
+
*
|
|
207
|
+
* Exposes 4 POST endpoints following the webauthx convention:
|
|
208
|
+
* - `POST /register/options` — generate credential creation options
|
|
209
|
+
* - `POST /register` — verify registration and store credential
|
|
210
|
+
* - `POST /login/options` — generate credential request options
|
|
211
|
+
* - `POST /login` — verify authentication
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { Handler, Kv } from 'accounts/server'
|
|
216
|
+
*
|
|
217
|
+
* const handler = Handler.webauthn({
|
|
218
|
+
* kv: Kv.memory(),
|
|
219
|
+
* origin: 'https://example.com',
|
|
220
|
+
* rpId: 'example.com',
|
|
221
|
+
* })
|
|
222
|
+
*
|
|
223
|
+
* export default handler
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @param options - Options.
|
|
227
|
+
* @returns Request handler.
|
|
228
|
+
*/
|
|
229
|
+
export declare function webauthn(options: webauthn.Options): Handler;
|
|
230
|
+
export declare namespace webauthn {
|
|
231
|
+
type Options = from.Options & {
|
|
232
|
+
/** Maximum age of a challenge in seconds before it expires. @default 300 */
|
|
233
|
+
challengeTtl?: number | undefined;
|
|
234
|
+
/** Key-value store for challenges and credentials. */
|
|
235
|
+
kv: Kv;
|
|
236
|
+
/** Called after a successful registration. The returned response is merged onto the default JSON response. */
|
|
237
|
+
onRegister?: (parameters: {
|
|
238
|
+
credentialId: string;
|
|
239
|
+
publicKey: string;
|
|
240
|
+
request: Request;
|
|
241
|
+
}) => Response | Promise<Response> | void | Promise<void>;
|
|
242
|
+
/** Called after a successful authentication. The returned response is merged onto the default JSON response. */
|
|
243
|
+
onAuthenticate?: (parameters: {
|
|
244
|
+
credentialId: string;
|
|
245
|
+
publicKey: string;
|
|
246
|
+
userId?: string | undefined;
|
|
247
|
+
request: Request;
|
|
248
|
+
}) => Response | Promise<Response> | void | Promise<void>;
|
|
249
|
+
/** Expected origin(s) (e.g. `"https://example.com"` or `["https://a.com", "https://b.com"]`). */
|
|
250
|
+
origin: string | readonly string[];
|
|
251
|
+
/** Path prefix for the WebAuthn endpoints (e.g. `"/webauthn"`). @default "" */
|
|
252
|
+
path?: string | undefined;
|
|
253
|
+
/** Relying Party ID (e.g. `"example.com"`). */
|
|
254
|
+
rpId: string;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=Handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../src/server/Handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAsB,UAAU,EAAe,MAAM,IAAI,CAAA;AAEhE,OAAO,EAAE,KAAK,KAAK,EAAmC,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAWjD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAEjC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC5C,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3E,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CACvC,CAAA;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,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