@atcute/xrpc-server 0.1.8 → 0.1.10
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/auth/index.d.ts +2 -2
- package/dist/auth/jwt-verifier.d.ts +2 -2
- package/dist/auth/jwt.d.ts +2 -2
- package/dist/auth/jwt.d.ts.map +1 -1
- package/dist/auth/jwt.js +2 -2
- package/dist/auth/jwt.js.map +1 -1
- package/dist/main/index.d.ts +6 -5
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +1 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/router.d.ts +5 -5
- package/dist/main/types/operation.d.ts +2 -2
- package/dist/main/types/operation.d.ts.map +1 -1
- package/dist/main/types/websocket.d.ts +1 -1
- package/dist/main/utils/request-input.d.ts +1 -1
- package/dist/main/utils/request-params.d.ts +1 -1
- package/dist/main/utils/websocket-mock.d.ts +4 -4
- package/dist/main/utils/websocket-mock.d.ts.map +1 -1
- package/dist/main/utils/websocket-mock.js.map +1 -1
- package/dist/main/xrpc-handler.d.ts +3 -3
- package/dist/middlewares/cors.d.ts +1 -1
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/cors.js +4 -1
- package/dist/middlewares/cors.js.map +1 -1
- package/lib/auth/index.ts +2 -2
- package/lib/auth/jwt-creator.ts +1 -1
- package/lib/auth/jwt-verifier.ts +3 -3
- package/lib/auth/jwt.ts +5 -5
- package/lib/main/index.ts +16 -5
- package/lib/main/router.ts +10 -10
- package/lib/main/types/operation.ts +16 -17
- package/lib/main/types/websocket.ts +1 -1
- package/lib/main/utils/request-input.ts +1 -1
- package/lib/main/utils/request-params.ts +1 -1
- package/lib/main/utils/websocket-mock.ts +5 -4
- package/lib/main/xrpc-handler.ts +3 -3
- package/lib/middlewares/cors.ts +5 -2
- package/package.json +14 -14
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './jwt-creator.
|
|
2
|
-
export * from './jwt-verifier.
|
|
1
|
+
export * from './jwt-creator.ts';
|
|
2
|
+
export * from './jwt-verifier.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DidDocumentResolver } from '@atcute/identity-resolver';
|
|
2
2
|
import type { Did, Nsid } from '@atcute/lexicons';
|
|
3
|
-
import type { Result } from '../types/misc.
|
|
4
|
-
import type { AuthError } from './types.
|
|
3
|
+
import type { Result } from '../types/misc.ts';
|
|
4
|
+
import type { AuthError } from './types.ts';
|
|
5
5
|
export interface ServiceJwtVerifierOptions {
|
|
6
6
|
serviceDid: Did | null;
|
|
7
7
|
resolver: DidDocumentResolver;
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Did, Nsid } from '@atcute/lexicons';
|
|
2
|
-
import type { Result } from '../types/misc.
|
|
3
|
-
import type { AuthError } from './types.
|
|
2
|
+
import type { Result } from '../types/misc.ts';
|
|
3
|
+
import type { AuthError } from './types.ts';
|
|
4
4
|
export interface JwtHeader {
|
|
5
5
|
typ?: string;
|
|
6
6
|
alg: string;
|
package/dist/auth/jwt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../lib/auth/jwt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../lib/auth/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,MAAM,WAAW,SAAS;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACZ;AAOD,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAsBD,MAAM,WAAW,SAAS;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACjC,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACnC;AAoCD,eAAO,MAAM,QAAQ,qDAsCpB,CAAC"}
|
package/dist/auth/jwt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as v from '@badrap/valita';
|
|
2
1
|
import { isDid, isNsid } from '@atcute/lexicons/syntax';
|
|
3
2
|
import { fromBase64Url } from '@atcute/multibase';
|
|
4
3
|
import { decodeUtf8From, encodeUtf8 } from '@atcute/uint8array';
|
|
4
|
+
import * as v from '@badrap/valita';
|
|
5
5
|
const didString = v.string().assert(isDid, `must be a did`);
|
|
6
6
|
const nsidString = v.string().assert(isNsid, `must be an nsid`);
|
|
7
7
|
const integer = v.number().assert((input) => input >= 0 && Number.isSafeInteger(input), `must be an integer`);
|
|
@@ -32,7 +32,7 @@ const readJwtPortion = (schema, input) => {
|
|
|
32
32
|
try {
|
|
33
33
|
const raw = decodeUtf8From(fromBase64Url(input));
|
|
34
34
|
const json = JSON.parse(raw);
|
|
35
|
-
const result = schema.try(json);
|
|
35
|
+
const result = schema.try(json, { mode: 'passthrough' });
|
|
36
36
|
if (result.ok) {
|
|
37
37
|
return result;
|
|
38
38
|
}
|
package/dist/auth/jwt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../lib/auth/jwt.ts"],"names":[],"mappings":"
|
|
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AC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACN,EAAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACN,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,kBAAkB;aAC/B;SACD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC;IAE7D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO;QACN,EAAE,EAAE,IAAI;QACR,KAAK,EAAE;YACN,MAAM,EAAE,MAAM,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,KAAK;YACtB,OAAO,EAAE,UAAU,CAAC,GAAG,YAAY,IAAI,aAAa,EAAE,CAAC;YACvD,SAAS,EAAE,SAAS,CAAC,KAAK;SAC1B;KACD,CAAC;AAAA,CACF,CAAC"}
|
package/dist/main/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './response.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './xrpc-
|
|
5
|
-
export
|
|
1
|
+
export * from './response.ts';
|
|
2
|
+
export * from './router.ts';
|
|
3
|
+
export * from './xrpc-error.ts';
|
|
4
|
+
export * from './xrpc-handler.ts';
|
|
5
|
+
export type { ProcedureConfig, ProcedureContext, ProcedureHandler, QueryConfig, QueryContext, QueryHandler, SubscriptionConfig, SubscriptionContext, SubscriptionHandler, } from './types/operation.ts';
|
|
6
|
+
export * from './types/websocket.ts';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAElC,YAAY,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
package/dist/main/index.js
CHANGED
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAalC,cAAc,sBAAsB,CAAC"}
|
package/dist/main/router.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type XRPCProcedureMetadata, type XRPCQueryMetadata, type XRPCSubscriptionMetadata } from '@atcute/lexicons/validations';
|
|
2
|
-
import type { Promisable } from '../types/misc.
|
|
3
|
-
import type { ProcedureConfig, QueryConfig, SubscriptionConfig } from './types/operation.
|
|
4
|
-
import type { WebSocketAdapter } from './types/websocket.
|
|
5
|
-
import { type Middleware } from './utils/middlewares.
|
|
6
|
-
import { type Namespaced } from './utils/namespaced.
|
|
2
|
+
import type { Promisable } from '../types/misc.ts';
|
|
3
|
+
import type { ProcedureConfig, QueryConfig, SubscriptionConfig } from './types/operation.ts';
|
|
4
|
+
import type { WebSocketAdapter } from './types/websocket.ts';
|
|
5
|
+
import { type Middleware } from './utils/middlewares.ts';
|
|
6
|
+
import { type Namespaced } from './utils/namespaced.ts';
|
|
7
7
|
export type FetchMiddleware = Middleware<[request: Request], Promise<Response>>;
|
|
8
8
|
export type NotFoundHandler = (request: Request) => Promisable<Response>;
|
|
9
9
|
export type ExceptionHandler = (error: unknown, request: Request) => Promisable<Response>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InferOutput, ObjectSchema, VariantSchema, XRPCBlobBodyParam, XRPCLexBodyParam, XRPCProcedureMetadata, XRPCQueryMetadata, XRPCSubscriptionMetadata } from '@atcute/lexicons/validations';
|
|
2
|
-
import type { Literal, Promisable } from '../../types/misc.
|
|
3
|
-
import type { JSONResponse } from '../response.
|
|
2
|
+
import type { Literal, Promisable } from '../../types/misc.ts';
|
|
3
|
+
import type { JSONResponse } from '../response.ts';
|
|
4
4
|
export type UnknownOperationContext = {
|
|
5
5
|
request: Request;
|
|
6
6
|
signal: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../lib/main/types/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE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AC,CAAC,QAAQ,CAAC,CAAC,CAAC,GACpE,QAAQ,CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,UAAU,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IAC/F,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;CACtC,CAAC;AAIF,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,mBAAmB,CAAC,aAAa,SAAS,wBAAwB,IAAI;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;CACpB,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,YAAY,GAC9C;IACA,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC7C,GACA,EAEA,CAAC,CAAC;AAEL,MAAM,MAAM,mBAAmB,CAAC,aAAa,SAAS,wBAAwB,IAAI,CACjF,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,KACvC,aAAa,CACjB,aAAa,CAAC,SAAS,CAAC,SAAS,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,GAC/D,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GACrC,KAAK,CACR,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,aAAa,SAAS,wBAAwB,GAAG,wBAAwB,IAAI;IAC3G,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAC5C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { XRPCBlobBodyParam, XRPCLexBodyParam } from '@atcute/lexicons/validations';
|
|
2
|
-
import type { Result } from '../../types/misc.
|
|
2
|
+
import type { Result } from '../../types/misc.ts';
|
|
3
3
|
export declare const constructMimeValidator: (param: XRPCBlobBodyParam | XRPCLexBodyParam<import("@atcute/lexicons/validations").ObjectSchema<import("@atcute/lexicons/validations").LooseObjectShape> | import("@atcute/lexicons/validations").VariantSchema<readonly import("@atcute/lexicons/validations").ObjectSchema<any>[], boolean>>) => ((request: Request) => Result<void, string>) | null;
|
|
4
4
|
//# sourceMappingURL=request-input.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ObjectSchema, type ValidationResult } from '@atcute/lexicons/validations';
|
|
2
|
-
import type { Literal } from '../../types/misc.
|
|
2
|
+
import type { Literal } from '../../types/misc.ts';
|
|
3
3
|
type MaybeArray<T> = T | T[];
|
|
4
4
|
export declare const constructParamsHandler: <TSchema extends ObjectSchema<import("@atcute/lexicons/validations").LooseObjectShape>>(schema: TSchema) => (searchParams: URLSearchParams) => ValidationResult<Record<string, MaybeArray<Literal>>>;
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Promisable } from '../../types/misc.
|
|
2
|
-
import type { XRPCRouter } from '../router.
|
|
3
|
-
import type { WebSocketAdapter, WebSocketConnection } from '../types/websocket.
|
|
4
|
-
import { EventEmitter } from './event-emitter.
|
|
1
|
+
import type { Promisable } from '../../types/misc.ts';
|
|
2
|
+
import type { XRPCRouter } from '../router.ts';
|
|
3
|
+
import type { WebSocketAdapter, WebSocketConnection } from '../types/websocket.ts';
|
|
4
|
+
import { EventEmitter } from './event-emitter.ts';
|
|
5
5
|
export interface SubscriptionClient extends Disposable {
|
|
6
6
|
events: EventEmitter<{
|
|
7
7
|
message: [data: Uint8Array];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-mock.d.ts","sourceRoot":"","sources":["../../../lib/main/utils/websocket-mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"websocket-mock.d.ts","sourceRoot":"","sources":["../../../lib/main/utils/websocket-mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACrD,MAAM,EAAE,YAAY,CAAC;QACpB,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5B,KAAK,EAAE,CAAC,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KACpE,CAAC,CAAC;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACpD;AAED,qBAAa,oBAAqB,YAAW,gBAAgB;;IAG5D,OAAO,CACN,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,UAAU,CAAC,IAAI,CAAC,GACpD,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC,CASlC;IAED,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAqE3C;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-mock.js","sourceRoot":"","sources":["../../../lib/main/utils/websocket-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAA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AAC;oBAAA,CACf;iBACD,CAAC;gBAEF,OAAO,MAAM,CAAC;YAAA,CACd;SACD,CAAC;IAAA,CACF;CACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XRPCProcedureMetadata, XRPCQueryMetadata } from '@atcute/lexicons/validations';
|
|
2
|
-
import { type XRPCRouterOptions } from './router.
|
|
3
|
-
import type { ProcedureConfig, QueryConfig } from './types/operation.
|
|
4
|
-
import { type Namespaced } from './utils/namespaced.
|
|
2
|
+
import { type XRPCRouterOptions } from './router.ts';
|
|
3
|
+
import type { ProcedureConfig, QueryConfig } from './types/operation.ts';
|
|
4
|
+
import { type Namespaced } from './utils/namespaced.ts';
|
|
5
5
|
type XrpcHandlerRouterOptions = Pick<XRPCRouterOptions, 'middlewares' | 'handleNotFound' | 'handleException'>;
|
|
6
6
|
export type XrpcQueryHandlerOptions<TQuery extends XRPCQueryMetadata> = {
|
|
7
7
|
lxm: TQuery | Namespaced<TQuery>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../lib/middlewares/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC3B,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAwBD,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../lib/middlewares/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC3B,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAwBD,eAAO,MAAM,IAAI,4CAoEhB,CAAC"}
|
package/dist/middlewares/cors.js
CHANGED
|
@@ -15,8 +15,11 @@ const DEFAULT_ALLOWED_HEADERS = [
|
|
|
15
15
|
];
|
|
16
16
|
const RE_XRPC_NSID = /^\/xrpc\/([^?]*)/;
|
|
17
17
|
export const cors = (options = {}) => {
|
|
18
|
-
const exposedHeaders = Array.from(new Set([...DEFAULT_EXPOSED_HEADERS, ...(options.exposedHeaders?.map((h) => h.toLowerCase()) || [])]))
|
|
18
|
+
const exposedHeaders = Array.from(new Set([...DEFAULT_EXPOSED_HEADERS, ...(options.exposedHeaders?.map((h) => h.toLowerCase()) || [])]))
|
|
19
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- Array.from already clones
|
|
20
|
+
.sort();
|
|
19
21
|
const allowedHeaders = Array.from(new Set([...DEFAULT_ALLOWED_HEADERS, ...(options.allowedHeaders?.map((h) => h.toLowerCase()) || [])]))
|
|
22
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- Array.from already clones
|
|
20
23
|
.sort()
|
|
21
24
|
.join(',');
|
|
22
25
|
const exclude = options.exclude;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../lib/middlewares/cors.ts"],"names":[],"mappings":"AAaA,MAAM,uBAAuB,GAAG;IAC/B,YAAY;IACZ,kBAAkB;IAElB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,iBAAiB;CACjB,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC/B,cAAc;IAEd,eAAe;IACf,MAAM;IAEN,yBAAyB;IACzB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;YAC9B,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;YAEnD,IAAI,cAAc,EAAE,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,cAAc,CAAC,CAAC;YAC7D,CAAC;YAED,IAAI,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,KAAK,MAAM,EAAE,CAAC;gBACrG,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,MAAM,CAAC,CAAC;YAC7D,CAAC;YAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE/E,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,QAAQ,CAAC;IAAA,CAChB,CAAC;AAAA,CACF,CAAC"}
|
package/lib/auth/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './jwt-creator.
|
|
2
|
-
export * from './jwt-verifier.
|
|
1
|
+
export * from './jwt-creator.ts';
|
|
2
|
+
export * from './jwt-verifier.ts';
|
package/lib/auth/jwt-creator.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { encodeUtf8 } from '@atcute/uint8array';
|
|
|
5
5
|
|
|
6
6
|
import { nanoid } from 'nanoid';
|
|
7
7
|
|
|
8
|
-
import type { JwtHeader, JwtPayload } from './jwt.
|
|
8
|
+
import type { JwtHeader, JwtPayload } from './jwt.ts';
|
|
9
9
|
|
|
10
10
|
export interface CreateServiceJwtOptions {
|
|
11
11
|
keypair: PrivateKey;
|
package/lib/auth/jwt-verifier.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { type DidDocumentResolver } from '@atcute/identity-resolver';
|
|
|
4
4
|
import type { Did, Nsid } from '@atcute/lexicons';
|
|
5
5
|
import * as uint8arrays from '@atcute/uint8array';
|
|
6
6
|
|
|
7
|
-
import type { Result } from '../types/misc.
|
|
7
|
+
import type { Result } from '../types/misc.ts';
|
|
8
8
|
|
|
9
|
-
import { parseJwt, type ParsedJwt } from './jwt.
|
|
10
|
-
import type { AuthError } from './types.
|
|
9
|
+
import { parseJwt, type ParsedJwt } from './jwt.ts';
|
|
10
|
+
import type { AuthError } from './types.ts';
|
|
11
11
|
|
|
12
12
|
export interface ServiceJwtVerifierOptions {
|
|
13
13
|
serviceDid: Did | null;
|
package/lib/auth/jwt.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as v from '@badrap/valita';
|
|
2
|
-
|
|
3
1
|
import type { Did, Nsid } from '@atcute/lexicons';
|
|
4
2
|
import { isDid, isNsid } from '@atcute/lexicons/syntax';
|
|
5
3
|
import { fromBase64Url } from '@atcute/multibase';
|
|
6
4
|
import { decodeUtf8From, encodeUtf8 } from '@atcute/uint8array';
|
|
7
5
|
|
|
8
|
-
import
|
|
6
|
+
import * as v from '@badrap/valita';
|
|
7
|
+
|
|
8
|
+
import type { Result } from '../types/misc.ts';
|
|
9
9
|
|
|
10
|
-
import type { AuthError } from './types.
|
|
10
|
+
import type { AuthError } from './types.ts';
|
|
11
11
|
|
|
12
12
|
const didString = v.string().assert(isDid, `must be a did`);
|
|
13
13
|
const nsidString = v.string().assert(isNsid, `must be an nsid`);
|
|
@@ -65,7 +65,7 @@ const readJwtPortion = <T>(schema: v.Type<T>, input: string): Result<T, AuthErro
|
|
|
65
65
|
const raw = decodeUtf8From(fromBase64Url(input));
|
|
66
66
|
const json = JSON.parse(raw);
|
|
67
67
|
|
|
68
|
-
const result = schema.try(json);
|
|
68
|
+
const result = schema.try(json, { mode: 'passthrough' });
|
|
69
69
|
if (result.ok) {
|
|
70
70
|
return result;
|
|
71
71
|
}
|
package/lib/main/index.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
export * from './response.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './xrpc-
|
|
1
|
+
export * from './response.ts';
|
|
2
|
+
export * from './router.ts';
|
|
3
|
+
export * from './xrpc-error.ts';
|
|
4
|
+
export * from './xrpc-handler.ts';
|
|
5
5
|
|
|
6
|
-
export
|
|
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';
|
package/lib/main/router.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type XRPCSubscriptionMetadata,
|
|
6
6
|
} from '@atcute/lexicons/validations';
|
|
7
7
|
|
|
8
|
-
import type { Literal, Promisable } from '../types/misc.
|
|
8
|
+
import type { Literal, Promisable } from '../types/misc.ts';
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
11
|
ProcedureConfig,
|
|
@@ -13,15 +13,15 @@ import type {
|
|
|
13
13
|
SubscriptionConfig,
|
|
14
14
|
UnknownOperationContext,
|
|
15
15
|
UnknownSubscriptionContext,
|
|
16
|
-
} from './types/operation.
|
|
17
|
-
import type { WebSocketAdapter } from './types/websocket.
|
|
18
|
-
import { encodeErrorFrame, encodeMessageFrame, extractMessageType, omitMessageType } from './utils/frames.
|
|
19
|
-
import { createAsyncMiddlewareRunner, type Middleware } from './utils/middlewares.
|
|
20
|
-
import { unwrapLxm, type Namespaced } from './utils/namespaced.
|
|
21
|
-
import { constructMimeValidator } from './utils/request-input.
|
|
22
|
-
import { constructParamsHandler } from './utils/request-params.
|
|
23
|
-
import { invalidRequest, validationError } from './utils/response.
|
|
24
|
-
import { XRPCError, XRPCSubscriptionError } from './xrpc-error.
|
|
16
|
+
} from './types/operation.ts';
|
|
17
|
+
import type { WebSocketAdapter } from './types/websocket.ts';
|
|
18
|
+
import { encodeErrorFrame, encodeMessageFrame, extractMessageType, omitMessageType } from './utils/frames.ts';
|
|
19
|
+
import { createAsyncMiddlewareRunner, type Middleware } from './utils/middlewares.ts';
|
|
20
|
+
import { unwrapLxm, type Namespaced } from './utils/namespaced.ts';
|
|
21
|
+
import { constructMimeValidator } from './utils/request-input.ts';
|
|
22
|
+
import { constructParamsHandler } from './utils/request-params.ts';
|
|
23
|
+
import { invalidRequest, validationError } from './utils/response.ts';
|
|
24
|
+
import { XRPCError, XRPCSubscriptionError } from './xrpc-error.ts';
|
|
25
25
|
|
|
26
26
|
type InternalRequestContext = {
|
|
27
27
|
url: URL;
|
|
@@ -9,9 +9,8 @@ import type {
|
|
|
9
9
|
XRPCSubscriptionMetadata,
|
|
10
10
|
} from '@atcute/lexicons/validations';
|
|
11
11
|
|
|
12
|
-
import type { Literal, Promisable } from '../../types/misc.
|
|
13
|
-
|
|
14
|
-
import type { JSONResponse } from '../response.js';
|
|
12
|
+
import type { Literal, Promisable } from '../../types/misc.ts';
|
|
13
|
+
import type { JSONResponse } from '../response.ts';
|
|
15
14
|
|
|
16
15
|
export type UnknownOperationContext = {
|
|
17
16
|
request: Request;
|
|
@@ -62,20 +61,20 @@ export type ProcedureContext<TProcedure extends XRPCProcedureMetadata> = {
|
|
|
62
61
|
: {
|
|
63
62
|
request: Request;
|
|
64
63
|
}) &
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
(TProcedure['params'] extends ObjectSchema
|
|
65
|
+
? {
|
|
66
|
+
params: InferOutput<TProcedure['params']>;
|
|
67
|
+
}
|
|
68
|
+
: {
|
|
69
|
+
// params
|
|
70
|
+
}) &
|
|
71
|
+
(TProcedure['input'] extends XRPCLexBodyParam
|
|
72
|
+
? {
|
|
73
|
+
input: InferOutput<TProcedure['input']['schema']>;
|
|
74
|
+
}
|
|
75
|
+
: {
|
|
76
|
+
// input
|
|
77
|
+
});
|
|
79
78
|
|
|
80
79
|
export type ProcedureHandler<TProcedure extends XRPCProcedureMetadata> = (
|
|
81
80
|
context: ProcedureContext<TProcedure>,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { XRPCBlobBodyParam, XRPCLexBodyParam } from '@atcute/lexicons/validations';
|
|
2
2
|
|
|
3
|
-
import type { Result } from '../../types/misc.
|
|
3
|
+
import type { Result } from '../../types/misc.ts';
|
|
4
4
|
|
|
5
5
|
const jsonMimeValidator = (() => {
|
|
6
6
|
const JSON_RE = /^\s*application\/json\s*(?:$|;)/;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
|
|
3
|
-
import type { Promisable } from '../../types/misc.
|
|
4
|
-
import type { XRPCRouter } from '../router.
|
|
5
|
-
import type { WebSocketAdapter, WebSocketConnection } from '../types/websocket.
|
|
6
|
-
|
|
3
|
+
import type { Promisable } from '../../types/misc.ts';
|
|
4
|
+
import type { XRPCRouter } from '../router.ts';
|
|
5
|
+
import type { WebSocketAdapter, WebSocketConnection } from '../types/websocket.ts';
|
|
6
|
+
|
|
7
|
+
import { EventEmitter } from './event-emitter.ts';
|
|
7
8
|
|
|
8
9
|
interface WebSocketHandlerContext {
|
|
9
10
|
handler: ((ws: WebSocketConnection) => Promisable<void>) | null;
|
package/lib/main/xrpc-handler.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { XRPCProcedureMetadata, XRPCQueryMetadata } from '@atcute/lexicons/validations';
|
|
2
2
|
|
|
3
|
-
import { XRPCRouter, type XRPCRouterOptions } from './router.
|
|
4
|
-
import type { ProcedureConfig, QueryConfig } from './types/operation.
|
|
5
|
-
import { unwrapLxm, type Namespaced } from './utils/namespaced.
|
|
3
|
+
import { XRPCRouter, type XRPCRouterOptions } from './router.ts';
|
|
4
|
+
import type { ProcedureConfig, QueryConfig } from './types/operation.ts';
|
|
5
|
+
import { unwrapLxm, type Namespaced } from './utils/namespaced.ts';
|
|
6
6
|
|
|
7
7
|
type XrpcHandlerRouterOptions = Pick<XRPCRouterOptions, 'middlewares' | 'handleNotFound' | 'handleException'>;
|
|
8
8
|
|
package/lib/middlewares/cors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchMiddleware } from '../main/router.
|
|
1
|
+
import type { FetchMiddleware } from '../main/router.ts';
|
|
2
2
|
|
|
3
3
|
export interface CORSOptions {
|
|
4
4
|
/** Additional headers to expose to the client */
|
|
@@ -36,11 +36,14 @@ const RE_XRPC_NSID = /^\/xrpc\/([^?]*)/;
|
|
|
36
36
|
export const cors = (options: CORSOptions = {}): FetchMiddleware => {
|
|
37
37
|
const exposedHeaders = Array.from(
|
|
38
38
|
new Set([...DEFAULT_EXPOSED_HEADERS, ...(options.exposedHeaders?.map((h) => h.toLowerCase()) || [])]),
|
|
39
|
-
)
|
|
39
|
+
)
|
|
40
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- Array.from already clones
|
|
41
|
+
.sort();
|
|
40
42
|
|
|
41
43
|
const allowedHeaders = Array.from(
|
|
42
44
|
new Set([...DEFAULT_ALLOWED_HEADERS, ...(options.allowedHeaders?.map((h) => h.toLowerCase()) || [])]),
|
|
43
45
|
)
|
|
46
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- Array.from already clones
|
|
44
47
|
.sort()
|
|
45
48
|
.join(',');
|
|
46
49
|
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"type": "module",
|
|
3
2
|
"name": "@atcute/xrpc-server",
|
|
4
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
5
4
|
"description": "a small web framework for handling XRPC operations",
|
|
6
5
|
"license": "0BSD",
|
|
7
6
|
"repository": {
|
|
8
7
|
"url": "https://github.com/mary-ext/atcute",
|
|
9
8
|
"directory": "packages/servers/xrpc-server"
|
|
10
9
|
},
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
10
|
"files": [
|
|
15
11
|
"dist/",
|
|
16
12
|
"lib/",
|
|
17
13
|
"!lib/**/*.bench.ts",
|
|
18
14
|
"!lib/**/*.test.ts"
|
|
19
15
|
],
|
|
16
|
+
"type": "module",
|
|
20
17
|
"exports": {
|
|
21
18
|
".": "./dist/main/index.js",
|
|
22
19
|
"./auth": "./dist/auth/index.js",
|
|
23
20
|
"./middlewares/cors": "./dist/middlewares/cors.js"
|
|
24
21
|
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@badrap/valita": "^0.4.6",
|
|
27
27
|
"nanoid": "^5.1.6",
|
|
28
|
+
"@atcute/cbor": "^2.3.2",
|
|
28
29
|
"@atcute/crypto": "^2.3.0",
|
|
29
|
-
"@atcute/cbor": "^2.2.8",
|
|
30
30
|
"@atcute/identity": "^1.1.3",
|
|
31
|
-
"@atcute/
|
|
32
|
-
"@atcute/
|
|
33
|
-
"@atcute/uint8array": "^1.
|
|
34
|
-
"@atcute/
|
|
31
|
+
"@atcute/lexicons": "^1.2.9",
|
|
32
|
+
"@atcute/multibase": "^1.1.8",
|
|
33
|
+
"@atcute/uint8array": "^1.1.1",
|
|
34
|
+
"@atcute/identity-resolver": "^1.2.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@atcute/xrpc-server": "file:",
|
|
38
|
-
"@types/node": "^
|
|
39
|
-
"@vitest/coverage-v8": "^4.0.
|
|
40
|
-
"vitest": "^4.0.
|
|
38
|
+
"@types/node": "^25.2.3",
|
|
39
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
40
|
+
"vitest": "^4.0.18",
|
|
41
41
|
"@atcute/atproto": "^3.1.10",
|
|
42
|
-
"@atcute/bluesky": "^3.2.
|
|
42
|
+
"@atcute/bluesky": "^3.2.18"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsgo --project tsconfig.build.json",
|