@atcute/xrpc-server 1.0.0 → 2.0.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.
Files changed (106) hide show
  1. package/dist/auth/index.d.ts +0 -1
  2. package/dist/auth/index.js +0 -1
  3. package/dist/auth/jwt-creator.d.ts +0 -1
  4. package/dist/auth/jwt-creator.js +0 -1
  5. package/dist/auth/jwt-verifier.d.ts +24 -33
  6. package/dist/auth/jwt-verifier.js +8 -10
  7. package/dist/auth/jwt.d.ts +0 -1
  8. package/dist/auth/jwt.js +22 -26
  9. package/dist/auth/types.d.ts +0 -1
  10. package/dist/auth/types.js +0 -1
  11. package/dist/main/index.d.ts +0 -1
  12. package/dist/main/index.js +0 -1
  13. package/dist/main/response.d.ts +0 -1
  14. package/dist/main/response.js +0 -1
  15. package/dist/main/router.d.ts +7 -14
  16. package/dist/main/router.js +3 -12
  17. package/dist/main/types/operation.d.ts +3 -5
  18. package/dist/main/types/operation.js +1 -1
  19. package/dist/main/types/websocket.d.ts +3 -5
  20. package/dist/main/types/websocket.js +0 -1
  21. package/dist/main/utils/frames.d.ts +0 -1
  22. package/dist/main/utils/frames.js +0 -1
  23. package/dist/main/utils/middlewares.d.ts +0 -1
  24. package/dist/main/utils/middlewares.js +1 -1
  25. package/dist/main/utils/namespaced.d.ts +0 -1
  26. package/dist/main/utils/namespaced.js +0 -1
  27. package/dist/main/utils/request-input.d.ts +3 -5
  28. package/dist/main/utils/request-input.js +3 -5
  29. package/dist/main/utils/request-params.d.ts +0 -1
  30. package/dist/main/utils/request-params.js +4 -3
  31. package/dist/main/utils/response.d.ts +0 -1
  32. package/dist/main/utils/response.js +0 -1
  33. package/dist/main/utils/websocket-mock.d.ts +0 -1
  34. package/dist/main/utils/websocket-mock.js +0 -1
  35. package/dist/main/xrpc-error.d.ts +16 -18
  36. package/dist/main/xrpc-error.js +9 -10
  37. package/dist/main/xrpc-handler.d.ts +1 -3
  38. package/dist/main/xrpc-handler.js +0 -1
  39. package/dist/middlewares/cors.d.ts +0 -1
  40. package/dist/middlewares/cors.js +0 -1
  41. package/dist/types/misc.d.ts +0 -1
  42. package/dist/types/misc.js +0 -1
  43. package/package.json +17 -20
  44. package/dist/auth/index.d.ts.map +0 -1
  45. package/dist/auth/index.js.map +0 -1
  46. package/dist/auth/jwt-creator.d.ts.map +0 -1
  47. package/dist/auth/jwt-creator.js.map +0 -1
  48. package/dist/auth/jwt-verifier.d.ts.map +0 -1
  49. package/dist/auth/jwt-verifier.js.map +0 -1
  50. package/dist/auth/jwt.d.ts.map +0 -1
  51. package/dist/auth/jwt.js.map +0 -1
  52. package/dist/auth/types.d.ts.map +0 -1
  53. package/dist/auth/types.js.map +0 -1
  54. package/dist/main/index.d.ts.map +0 -1
  55. package/dist/main/index.js.map +0 -1
  56. package/dist/main/response.d.ts.map +0 -1
  57. package/dist/main/response.js.map +0 -1
  58. package/dist/main/router.d.ts.map +0 -1
  59. package/dist/main/router.js.map +0 -1
  60. package/dist/main/types/operation.d.ts.map +0 -1
  61. package/dist/main/types/operation.js.map +0 -1
  62. package/dist/main/types/websocket.d.ts.map +0 -1
  63. package/dist/main/types/websocket.js.map +0 -1
  64. package/dist/main/utils/frames.d.ts.map +0 -1
  65. package/dist/main/utils/frames.js.map +0 -1
  66. package/dist/main/utils/middlewares.d.ts.map +0 -1
  67. package/dist/main/utils/middlewares.js.map +0 -1
  68. package/dist/main/utils/namespaced.d.ts.map +0 -1
  69. package/dist/main/utils/namespaced.js.map +0 -1
  70. package/dist/main/utils/request-input.d.ts.map +0 -1
  71. package/dist/main/utils/request-input.js.map +0 -1
  72. package/dist/main/utils/request-params.d.ts.map +0 -1
  73. package/dist/main/utils/request-params.js.map +0 -1
  74. package/dist/main/utils/response.d.ts.map +0 -1
  75. package/dist/main/utils/response.js.map +0 -1
  76. package/dist/main/utils/websocket-mock.d.ts.map +0 -1
  77. package/dist/main/utils/websocket-mock.js.map +0 -1
  78. package/dist/main/xrpc-error.d.ts.map +0 -1
  79. package/dist/main/xrpc-error.js.map +0 -1
  80. package/dist/main/xrpc-handler.d.ts.map +0 -1
  81. package/dist/main/xrpc-handler.js.map +0 -1
  82. package/dist/middlewares/cors.d.ts.map +0 -1
  83. package/dist/middlewares/cors.js.map +0 -1
  84. package/dist/types/misc.d.ts.map +0 -1
  85. package/dist/types/misc.js.map +0 -1
  86. package/lib/auth/index.ts +0 -2
  87. package/lib/auth/jwt-creator.ts +0 -53
  88. package/lib/auth/jwt-verifier.ts +0 -395
  89. package/lib/auth/jwt.ts +0 -146
  90. package/lib/auth/types.ts +0 -4
  91. package/lib/main/index.ts +0 -17
  92. package/lib/main/response.ts +0 -9
  93. package/lib/main/router.ts +0 -464
  94. package/lib/main/types/operation.ts +0 -130
  95. package/lib/main/types/websocket.ts +0 -22
  96. package/lib/main/utils/frames.ts +0 -71
  97. package/lib/main/utils/middlewares.ts +0 -13
  98. package/lib/main/utils/namespaced.ts +0 -5
  99. package/lib/main/utils/request-input.ts +0 -89
  100. package/lib/main/utils/request-params.ts +0 -108
  101. package/lib/main/utils/response.ts +0 -14
  102. package/lib/main/utils/websocket-mock.ts +0 -118
  103. package/lib/main/xrpc-error.ts +0 -201
  104. package/lib/main/xrpc-handler.ts +0 -53
  105. package/lib/middlewares/cors.ts +0 -104
  106. package/lib/types/misc.ts +0 -4
@@ -1,395 +0,0 @@
1
- import { getPublicKeyFromDidController, verifySig, type FoundPublicKey } from '@atcute/crypto';
2
- import { getVerificationMaterial, type DidDocument } from '@atcute/identity';
3
- import { type DidDocumentResolver } from '@atcute/identity-resolver';
4
- import type { Did, Nsid } from '@atcute/lexicons';
5
- import type { AtprotoAudience } from '@atcute/lexicons/syntax';
6
- import * as uint8arrays from '@atcute/uint8array';
7
-
8
- import { AuthRequiredError } from '../main/xrpc-error.ts';
9
- import type { Result } from '../types/misc.ts';
10
-
11
- import { parseJwt, type ParsedJwt } from './jwt.ts';
12
- import type { AuthError } from './types.ts';
13
-
14
- type SupportedKid = `#${string}`;
15
- /** only `#atproto` is accepted as a signing key identifier for now */
16
- const DEFAULT_KID: SupportedKid = '#atproto';
17
-
18
- /**
19
- * replay-protection store for service JWTs. when configured on a verifier,
20
- * tokens must carry a `jti` claim and the verifier consults this store to
21
- * reject duplicates.
22
- */
23
- export interface ReplayStore {
24
- /**
25
- * record a `(iss, jti)` pair seen now.
26
- *
27
- * @param key issuer + token identifier; implementations decide how to
28
- * encode this into a storage key.
29
- * @param ttlSeconds how long the entry must be retained. implementations
30
- * are free to retain it for longer.
31
- * @returns `true` if the pair was previously unseen (token is unique),
32
- * `false` if the pair has been recorded before (replay).
33
- */
34
- check(key: { iss: Did; jti: string }, ttlSeconds: number): Promise<boolean>;
35
- }
36
-
37
- export interface ServiceJwtVerifierOptions {
38
- /**
39
- * list of `aud` values accepted by this service; each entry is a bare DID or a DID with
40
- * service fragment (e.g. `did:web:x.example#svc`), and incoming tokens must exact-match any entry.
41
- *
42
- * pass `null` to skip audience validation (accept any audience). an empty array rejects every
43
- * audience, which is useful when a service wants to fail closed until configured.
44
- */
45
- acceptAudiences: (Did | AtprotoAudience)[] | null;
46
- resolver: DidDocumentResolver;
47
- /**
48
- * maximum token lifetime window in seconds. rejects tokens whose `exp` is
49
- * more than this far in the future or whose `iat` is more than this far in
50
- * the past. defaults to 300 (5 minutes), matching atproto convention.
51
- */
52
- maxAge?: number;
53
- /**
54
- * clock-skew leeway in seconds applied to `exp` and `nbf` comparisons.
55
- * defaults to 5 seconds.
56
- */
57
- clockLeeway?: number;
58
- /**
59
- * optional replay-protection store. when provided, tokens must carry a
60
- * `jti` claim and the verifier rejects any `(iss, jti)` the store reports
61
- * as previously seen.
62
- */
63
- replayStore?: ReplayStore;
64
- }
65
-
66
- export interface VerifyJwtOptions {
67
- lxm: Nsid | Nsid[];
68
- /** abort signal forwarded to DID resolution; falls back to `request.signal` in `verifyRequest`. */
69
- signal?: AbortSignal;
70
- }
71
-
72
- export interface VerifiedJwt {
73
- issuer: Did;
74
- audience: Did | AtprotoAudience;
75
- lxm: Nsid;
76
- }
77
-
78
- const BEARER_PREFIX = 'Bearer ';
79
-
80
- export class ServiceJwtVerifier {
81
- didDocResolver: DidDocumentResolver;
82
- acceptAudiences: (Did | AtprotoAudience)[] | null;
83
- maxAge: number;
84
- clockLeeway: number;
85
- replayStore?: ReplayStore;
86
-
87
- constructor(options: ServiceJwtVerifierOptions) {
88
- this.didDocResolver = options.resolver;
89
- this.acceptAudiences = options.acceptAudiences;
90
- this.maxAge = options.maxAge ?? 5 * 60;
91
- this.clockLeeway = options.clockLeeway ?? 5;
92
- this.replayStore = options.replayStore;
93
- }
94
-
95
- /**
96
- * parse the Authorization header, verify the bearer token, and return the
97
- * validated claims. throws {@link AuthRequiredError} with a populated
98
- * `WWW-Authenticate: Bearer` challenge on every failure path.
99
- *
100
- * @param request incoming request; `request.signal` is forwarded to DID
101
- * resolution unless `options.signal` overrides it.
102
- * @param options verification options; `lxm` restricts which lexicon
103
- * methods the token is allowed to invoke.
104
- * @throws {AuthRequiredError} on missing header, malformed token,
105
- * signature mismatch, audience/lxm rejection, replay, or expiry.
106
- */
107
- async verifyRequest(request: Request, options: VerifyJwtOptions): Promise<VerifiedJwt> {
108
- const authorization = request.headers.get('authorization');
109
- if (authorization === null) {
110
- throw new AuthRequiredError({
111
- message: 'authorization header required',
112
- wwwAuthenticate: { scheme: 'Bearer' },
113
- });
114
- }
115
-
116
- if (!authorization.startsWith(BEARER_PREFIX)) {
117
- throw authError({ error: 'MissingBearer', description: 'expected a bearer token' });
118
- }
119
-
120
- const token = authorization.slice(BEARER_PREFIX.length).trim();
121
- const signal = options.signal ?? request.signal;
122
-
123
- const result = await this.#verifyToken(token, { lxm: options.lxm, signal });
124
- if (!result.ok) {
125
- throw authError(result.error);
126
- }
127
-
128
- return result.value;
129
- }
130
-
131
- async #getSigningKey(
132
- issuer: Did,
133
- kid: SupportedKid,
134
- noCache: boolean,
135
- signal: AbortSignal,
136
- ): Promise<Result<FoundPublicKey, AuthError>> {
137
- let didDocument: DidDocument;
138
- let key: FoundPublicKey;
139
-
140
- try {
141
- didDocument = await this.didDocResolver.resolve(issuer, { noCache, signal });
142
- } catch {
143
- return {
144
- ok: false,
145
- error: {
146
- error: 'DidResolutionFailed',
147
- description: `failed to retrieve did document for ${issuer}`,
148
- },
149
- };
150
- }
151
-
152
- const controller = getVerificationMaterial(didDocument, kid);
153
- if (!controller) {
154
- return {
155
- ok: false,
156
- error: {
157
- error: 'BadJwtIssuer',
158
- description: `${issuer} does not have a ${kid} verification material`,
159
- },
160
- };
161
- }
162
-
163
- try {
164
- key = getPublicKeyFromDidController(controller);
165
- } catch {
166
- return {
167
- ok: false,
168
- error: {
169
- error: 'BadJwtIssuer',
170
- description: `${issuer} has invalid ${kid} verification material`,
171
- },
172
- };
173
- }
174
-
175
- return { ok: true, value: key };
176
- }
177
-
178
- async #verifySignature(key: FoundPublicKey, jwt: ParsedJwt): Promise<Result<boolean, AuthError>> {
179
- try {
180
- return {
181
- ok: true,
182
- value: await verifySig(key, jwt.signature, jwt.message, { allowMalleableSig: true }),
183
- };
184
- } catch {
185
- return {
186
- ok: false,
187
- error: {
188
- error: 'BadJwtSignature',
189
- description: `could not verify jwt signature`,
190
- },
191
- };
192
- }
193
- }
194
-
195
- async #verifyToken(
196
- token: string,
197
- options: { lxm: Nsid | Nsid[]; signal: AbortSignal },
198
- ): Promise<Result<VerifiedJwt, AuthError>> {
199
- const parsed = parseJwt(token);
200
- if (!parsed.ok) {
201
- return parsed;
202
- }
203
-
204
- const { header, payload } = parsed.value;
205
-
206
- switch (header.typ) {
207
- case 'at+jwt':
208
- case 'refresh+jwt':
209
- case 'dpop+jwt': {
210
- return {
211
- ok: false,
212
- error: {
213
- error: 'BadJwtType',
214
- description: `invalid jwt type`,
215
- },
216
- };
217
- }
218
- }
219
-
220
- // resolve the `kid` header (defaulting to `#atproto`) and restrict to the set of
221
- // identifiers this verifier knows how to look up in the issuer's DID document.
222
- // matches proposal 0014's "safe default" for SDKs.
223
- const kid: string = header.kid ?? DEFAULT_KID;
224
- if (kid !== DEFAULT_KID) {
225
- return {
226
- ok: false,
227
- error: {
228
- error: 'BadJwtIssuer',
229
- description: `unsupported signing key identifier (${kid})`,
230
- },
231
- };
232
- }
233
-
234
- const now = Math.floor(Date.now() / 1_000);
235
-
236
- if (payload.nbf !== undefined && now < payload.nbf - this.clockLeeway) {
237
- return {
238
- ok: false,
239
- error: {
240
- error: 'JwtNotYetValid',
241
- description: `jwt is not yet valid`,
242
- },
243
- };
244
- }
245
-
246
- if (now > payload.exp + this.clockLeeway) {
247
- return {
248
- ok: false,
249
- error: {
250
- error: 'JwtExpired',
251
- description: `jwt is expired`,
252
- },
253
- };
254
- }
255
-
256
- // prevent issuers from minting very long-lived tokens: the configured max-age
257
- // window bounds how far `exp` can be in the future and how far `iat` can be in
258
- // the past.
259
- if (payload.exp - now > this.maxAge || (payload.iat !== undefined && now - payload.iat > this.maxAge)) {
260
- return {
261
- ok: false,
262
- error: {
263
- error: 'JwtTooOld',
264
- description: `jwt exceeds maximum age (${this.maxAge}s)`,
265
- },
266
- };
267
- }
268
-
269
- if (this.acceptAudiences !== null && !this.acceptAudiences.includes(payload.aud)) {
270
- return {
271
- ok: false,
272
- error: {
273
- error: 'InvalidAudience',
274
- description:
275
- this.acceptAudiences.length === 0
276
- ? `jwt audience does not match (no audiences accepted)`
277
- : `jwt audience does not match (expected one of: ${this.acceptAudiences.join(', ')})`,
278
- },
279
- };
280
- }
281
-
282
- if (typeof options.lxm === 'string' ? options.lxm !== payload.lxm : !options.lxm.includes(payload.lxm)) {
283
- return {
284
- ok: false,
285
- error: {
286
- error: `BadJwtLexiconMethod`,
287
- description: `jwt lexicon method does not match (expected ${options.lxm})`,
288
- },
289
- };
290
- }
291
-
292
- let jti: string | undefined;
293
- if (this.replayStore !== undefined) {
294
- if (payload.jti === undefined) {
295
- return {
296
- ok: false,
297
- error: {
298
- error: 'BadJwt',
299
- description: `jwt is missing the jti claim (required for replay protection)`,
300
- },
301
- };
302
- }
303
-
304
- jti = payload.jti;
305
- }
306
-
307
- const key = await this.#getSigningKey(payload.iss, kid, false, options.signal);
308
- if (!key.ok) {
309
- return key;
310
- }
311
-
312
- let isValid = false;
313
-
314
- if (key.value.jwtAlg === header.alg) {
315
- const result = await this.#verifySignature(key.value, parsed.value);
316
- if (!result.ok) {
317
- return result;
318
- }
319
-
320
- isValid = result.value;
321
- }
322
-
323
- if (!isValid) {
324
- // try again, uncached
325
- const freshKey = await this.#getSigningKey(payload.iss, kid, true, options.signal);
326
- if (!freshKey.ok) {
327
- return freshKey;
328
- }
329
-
330
- // at this point we can't ignore the jwt alg difference
331
- if (freshKey.value.jwtAlg !== header.alg) {
332
- return {
333
- ok: false,
334
- error: {
335
- error: 'BadJwtIssuer',
336
- description: `mismatching cryptographic key format (jwt is ${header.alg})`,
337
- },
338
- };
339
- }
340
-
341
- // only revalidate if it's a different key
342
- if (!uint8arrays.equals(freshKey.value.publicKeyBytes, key.value.publicKeyBytes)) {
343
- const result = await this.#verifySignature(freshKey.value, parsed.value);
344
- if (!result.ok) {
345
- return result;
346
- }
347
-
348
- isValid = result.value;
349
- }
350
- }
351
-
352
- if (!isValid) {
353
- // too bad
354
- return {
355
- ok: false,
356
- error: {
357
- error: 'BadJwtSignature',
358
- description: `invalid jwt signature`,
359
- },
360
- };
361
- }
362
-
363
- // replay-store check runs after signature verification so forged tokens
364
- // can't burn entries (memory dos) or evict legitimate `(iss, jti)` pairs
365
- // before the real request lands.
366
- if (this.replayStore !== undefined && jti !== undefined) {
367
- const unique = await this.replayStore.check({ iss: payload.iss, jti }, this.maxAge);
368
- if (!unique) {
369
- return {
370
- ok: false,
371
- error: {
372
- error: 'NonceNotUnique',
373
- description: `jwt has been used before`,
374
- },
375
- };
376
- }
377
- }
378
-
379
- return {
380
- ok: true,
381
- value: {
382
- issuer: payload.iss,
383
- audience: payload.aud,
384
- lxm: payload.lxm,
385
- },
386
- };
387
- }
388
- }
389
-
390
- const authError = (err: AuthError): AuthRequiredError => {
391
- return new AuthRequiredError({
392
- message: err.description,
393
- wwwAuthenticate: { scheme: 'Bearer', params: { error: err.error } },
394
- });
395
- };
package/lib/auth/jwt.ts DELETED
@@ -1,146 +0,0 @@
1
- import { isAtprotoAudience } from '@atcute/identity';
2
- import type { Did, Nsid } from '@atcute/lexicons';
3
- import { isDid, isNsid, type AtprotoAudience } from '@atcute/lexicons/syntax';
4
- import { fromBase64Url } from '@atcute/multibase';
5
- import { decodeUtf8From, encodeUtf8 } from '@atcute/uint8array';
6
-
7
- import * as v from '@badrap/valita';
8
-
9
- import type { Result } from '../types/misc.ts';
10
-
11
- import type { AuthError } from './types.ts';
12
-
13
- const didString = v.string().assert(isDid, `must be a did`);
14
- const audienceString = v
15
- .string()
16
- .assert((input) => isAtprotoAudience(input) || isDid(input), `must be a did or atproto audience`);
17
- const nsidString = v.string().assert(isNsid, `must be an nsid`);
18
-
19
- const integer = v.number().assert((input) => input >= 0 && Number.isSafeInteger(input), `must be an integer`);
20
-
21
- export interface JwtHeader {
22
- typ?: string;
23
- alg: string;
24
- /** signing key identifier; a DID fragment, defaults to `#atproto` when absent */
25
- kid?: string;
26
- }
27
-
28
- const jwtHeader: v.Type<JwtHeader> = v.object({
29
- typ: v.string().optional(),
30
- alg: v.string(),
31
- kid: v.string().optional(),
32
- });
33
-
34
- export interface JwtPayload {
35
- iss: Did;
36
- aud: Did | AtprotoAudience;
37
- exp: number;
38
- iat?: number;
39
- /** not-before time; token is invalid before this unix timestamp */
40
- nbf?: number;
41
- lxm: Nsid;
42
- jti?: string;
43
- }
44
-
45
- const jwtPayload: v.Type<JwtPayload> = v
46
- .object({
47
- /** issuer */
48
- iss: didString,
49
- /** target audience; a bare DID or a DID with service fragment (e.g. `did:web:x.example#svc`) */
50
- aud: audienceString,
51
- /** expiration time */
52
- exp: integer,
53
- /** creation time */
54
- iat: integer.optional(),
55
- /** not-before time */
56
- nbf: integer.optional(),
57
- /** xrpc operation being invoked; required per atproto service auth spec */
58
- lxm: nsidString,
59
- /** unique identifier */
60
- jti: v.string().optional(),
61
- })
62
- .assert(({ iat, exp }) => iat === undefined || exp > iat, {
63
- message: `expiry time must be greater than issued time`,
64
- path: ['exp'],
65
- });
66
-
67
- export interface ParsedJwt {
68
- header: JwtHeader;
69
- payload: JwtPayload;
70
- message: Uint8Array<ArrayBuffer>;
71
- signature: Uint8Array<ArrayBuffer>;
72
- }
73
-
74
- const readJwtPortion = <T>(schema: v.Type<T>, input: string): Result<T, AuthError> => {
75
- try {
76
- const raw = decodeUtf8From(fromBase64Url(input));
77
- const json = JSON.parse(raw);
78
-
79
- const result = schema.try(json, { mode: 'passthrough' });
80
- if (result.ok) {
81
- return result;
82
- }
83
- } catch {}
84
-
85
- return {
86
- ok: false,
87
- error: {
88
- error: `BadJwt`,
89
- description: `jwt is malformed`,
90
- },
91
- };
92
- };
93
-
94
- const readJwtSignature = (input: string): Result<Uint8Array<ArrayBuffer>, AuthError> => {
95
- try {
96
- return { ok: true, value: fromBase64Url(input) };
97
- } catch {}
98
-
99
- return {
100
- ok: false,
101
- error: {
102
- error: `BadJwt`,
103
- description: `jwt is malformed`,
104
- },
105
- };
106
- };
107
-
108
- export const parseJwt = (jwtString: string): Result<ParsedJwt, AuthError> => {
109
- const parts = jwtString.split('.');
110
- if (parts.length !== 3) {
111
- return {
112
- ok: false,
113
- error: {
114
- error: `BadJwt`,
115
- description: `jwt is malformed`,
116
- },
117
- };
118
- }
119
-
120
- const [headerString, payloadString, signatureString] = parts;
121
-
122
- const header = readJwtPortion(jwtHeader, headerString);
123
- if (!header.ok) {
124
- return header;
125
- }
126
-
127
- const payload = readJwtPortion(jwtPayload, payloadString);
128
- if (!payload.ok) {
129
- return payload;
130
- }
131
-
132
- const signature = readJwtSignature(signatureString);
133
- if (!signature.ok) {
134
- return signature;
135
- }
136
-
137
- return {
138
- ok: true,
139
- value: {
140
- header: header.value,
141
- payload: payload.value,
142
- message: encodeUtf8(`${headerString}.${payloadString}`),
143
- signature: signature.value,
144
- },
145
- };
146
- };
package/lib/auth/types.ts DELETED
@@ -1,4 +0,0 @@
1
- export type AuthError = {
2
- error: string;
3
- description: string;
4
- };
package/lib/main/index.ts DELETED
@@ -1,17 +0,0 @@
1
- export * from './response.ts';
2
- export * from './router.ts';
3
- export * from './xrpc-error.ts';
4
- export * from './xrpc-handler.ts';
5
-
6
- export type {
7
- ProcedureConfig,
8
- ProcedureContext,
9
- ProcedureHandler,
10
- QueryConfig,
11
- QueryContext,
12
- QueryHandler,
13
- SubscriptionConfig,
14
- SubscriptionContext,
15
- SubscriptionHandler,
16
- } from './types/operation.ts';
17
- export * from './types/websocket.ts';
@@ -1,9 +0,0 @@
1
- declare const kJson: unique symbol;
2
-
3
- export type JSONResponse<TData> = Response & { [kJson]: TData };
4
-
5
- export const json: {
6
- <TData>(data: NoInfer<TData>, init?: ResponseInit): JSONResponse<TData>;
7
- } = (data: any, init?: ResponseInit): any => {
8
- return Response.json(data, init);
9
- };