@seams/wallet-server 0.11.0 → 0.12.0
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/artifact-manifest.json +25 -25
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/signing-worker/index.js +2 -2
- package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/tenant-root-control-plane/index.js +2 -2
- package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
- package/cloudflare-router-ab/scripts/start-local-role-workers.mjs +3 -0
- package/cloudflare-router-ab/scripts/start-local-wallet-system.mjs +3 -0
- package/dist/esm/cloud-host.js +1 -2
- package/dist/esm/core/ThresholdService/kv.js +1 -218
- package/dist/esm/index.js +3 -3
- package/dist/esm/router/cloudflare-adaptor.js +1 -2
- package/dist/esm/router/cloudflare.js +1 -85
- package/dist/esm/threshold/session/signingSessionSeal/guards/backends.js +2 -98
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +2 -69
- package/dist/esm/threshold/session/signingSessionSeal/index.js +3 -3
- package/dist/types/wallet-server/src/core/ThresholdService/kv.d.ts +0 -29
- package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +0 -2
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/guards/backends.d.ts +1 -16
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyBackends.d.ts +1 -16
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/index.d.ts +4 -4
- package/package.json +1 -1
- package/dist/esm/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.js +0 -93
- package/dist/types/wallet-server/src/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.d.ts +0 -23
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { normalizeOptionalTrimmedString } from "../../../shared-ts/src/utils/normalize.js";
|
|
2
|
-
import {
|
|
3
|
-
import { createInMemorySigningSessionSealIdempotencyStore } from "./idempotency.js";
|
|
2
|
+
import { UpstashRedisRestClient } from "../../../core/ThresholdService/kv.js";
|
|
4
3
|
import { parseCurrentSigningSessionSealIdempotencyResultRecord, parseCurrentSigningSessionSealIdempotencyStoredEntry } from "./idempotencyRecords.js";
|
|
5
4
|
//#region src/threshold/session/signingSessionSeal/idempotencyBackends.ts
|
|
6
5
|
const DEFAULT_KEY_PREFIX = "threshold:signing-session-seal:idempotency:";
|
|
@@ -55,76 +54,10 @@ var UpstashSigningSessionSealIdempotencyStore = class {
|
|
|
55
54
|
}, ttlMs);
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
|
-
var RedisTcpSigningSessionSealIdempotencyStore = class {
|
|
59
|
-
constructor(options) {
|
|
60
|
-
this.client = new RedisTcpClient(options.redisUrl);
|
|
61
|
-
this.keyPrefix = normalizeOptionalTrimmedString(options.keyPrefix) || DEFAULT_KEY_PREFIX;
|
|
62
|
-
this.nowMs = options.nowMs || Date.now;
|
|
63
|
-
}
|
|
64
|
-
async get(input) {
|
|
65
|
-
const key = prefixedKey(this.keyPrefix, input.key);
|
|
66
|
-
if (!key) return null;
|
|
67
|
-
const entry = parseCurrentSigningSessionSealIdempotencyStoredEntry(await redisGetJson(this.client, key));
|
|
68
|
-
if (!entry) return null;
|
|
69
|
-
if (entry.expiresAtMs <= input.nowMs) {
|
|
70
|
-
try {
|
|
71
|
-
await redisDel(this.client, key);
|
|
72
|
-
} catch {}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return entry.result;
|
|
76
|
-
}
|
|
77
|
-
async set(input) {
|
|
78
|
-
const key = prefixedKey(this.keyPrefix, input.key);
|
|
79
|
-
if (!key) return;
|
|
80
|
-
const expiresAtMs = toPositiveInt(input.expiresAtMs);
|
|
81
|
-
if (expiresAtMs === void 0) return;
|
|
82
|
-
const normalizedResult = parseCurrentSigningSessionSealIdempotencyResultRecord(input.result);
|
|
83
|
-
if (!normalizedResult) return;
|
|
84
|
-
const ttlMs = ttlMsUntilExpiry(expiresAtMs, this.nowMs());
|
|
85
|
-
if (ttlMs <= 0) return;
|
|
86
|
-
await redisSetJson(this.client, key, {
|
|
87
|
-
result: normalizedResult,
|
|
88
|
-
expiresAtMs
|
|
89
|
-
}, ttlMs);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
57
|
function createUpstashSigningSessionSealIdempotencyStore(options) {
|
|
93
58
|
return new UpstashSigningSessionSealIdempotencyStore(options);
|
|
94
59
|
}
|
|
95
|
-
function createRedisTcpSigningSessionSealIdempotencyStore(options) {
|
|
96
|
-
return new RedisTcpSigningSessionSealIdempotencyStore(options);
|
|
97
|
-
}
|
|
98
|
-
function resolveSigningSessionSealIdempotencyFromEnv(input) {
|
|
99
|
-
const idempotencyKind = normalizeOptionalTrimmedString(input.idempotencyKind || "").toLowerCase();
|
|
100
|
-
const upstashUrl = normalizeOptionalTrimmedString(input.upstashUrl || "");
|
|
101
|
-
const upstashToken = normalizeOptionalTrimmedString(input.upstashToken || "");
|
|
102
|
-
const redisUrl = normalizeOptionalTrimmedString(input.redisUrl || "");
|
|
103
|
-
const keyPrefix = normalizeOptionalTrimmedString(input.keyPrefix || "") || DEFAULT_KEY_PREFIX;
|
|
104
|
-
const ttlMs = toPositiveInt(input.ttlMs);
|
|
105
|
-
const selectedKind = idempotencyKind || (upstashUrl || upstashToken ? "upstash-redis-rest" : redisUrl ? "redis-tcp" : "in-memory");
|
|
106
|
-
let store;
|
|
107
|
-
if (selectedKind === "upstash-redis-rest") {
|
|
108
|
-
if (!upstashUrl || !upstashToken) throw new Error("Upstash signing session-seal idempotency requires both upstashUrl and upstashToken");
|
|
109
|
-
store = createUpstashSigningSessionSealIdempotencyStore({
|
|
110
|
-
url: upstashUrl,
|
|
111
|
-
token: upstashToken,
|
|
112
|
-
keyPrefix
|
|
113
|
-
});
|
|
114
|
-
} else if (selectedKind === "redis-tcp") {
|
|
115
|
-
if (!redisUrl) throw new Error("Redis TCP signing session-seal idempotency requires redisUrl");
|
|
116
|
-
store = createRedisTcpSigningSessionSealIdempotencyStore({
|
|
117
|
-
redisUrl,
|
|
118
|
-
keyPrefix
|
|
119
|
-
});
|
|
120
|
-
} else if (selectedKind === "in-memory") store = createInMemorySigningSessionSealIdempotencyStore();
|
|
121
|
-
else throw new Error(`Unsupported signing session-seal idempotency kind "${selectedKind}". Expected in-memory, upstash-redis-rest, or redis-tcp.`);
|
|
122
|
-
return {
|
|
123
|
-
store,
|
|
124
|
-
...ttlMs ? { ttlMs } : {}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
60
|
//#endregion
|
|
128
|
-
export {
|
|
61
|
+
export { createUpstashSigningSessionSealIdempotencyStore };
|
|
129
62
|
|
|
130
63
|
//# sourceMappingURL=idempotencyBackends.js.map
|
|
@@ -7,6 +7,6 @@ import { createSigningSessionSealService } from "./service.js";
|
|
|
7
7
|
import { createSigningSessionSealRoutesOptions } from "./routesOptions.js";
|
|
8
8
|
import { createSigningSessionSealOptions, parseSigningSessionSealRootConfig } from "./options.js";
|
|
9
9
|
import { createInMemorySigningSessionSealIdempotencyStore } from "./idempotency.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
export { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, composeSigningSessionSealGuards, createInMemorySigningSessionSealIdempotencyStore, createInMemorySigningSessionSealRateLimiter, createPassthroughSigningSessionSealCipherAdapter,
|
|
10
|
+
import { createUpstashSigningSessionSealRateLimiter } from "./guards/backends.js";
|
|
11
|
+
import { createUpstashSigningSessionSealIdempotencyStore } from "./idempotencyBackends.js";
|
|
12
|
+
export { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, composeSigningSessionSealGuards, createInMemorySigningSessionSealIdempotencyStore, createInMemorySigningSessionSealRateLimiter, createPassthroughSigningSessionSealCipherAdapter, createSigningSessionSealAuditLogger, createSigningSessionSealCipherAdapter, createSigningSessionSealOptions, createSigningSessionSealRateLimitGuard, createSigningSessionSealRoutesOptions, createSigningSessionSealService, createSigningSessionSealShamir3PassCipherAdapter, createUpstashSigningSessionSealIdempotencyStore, createUpstashSigningSessionSealRateLimiter, encodeSigningSessionSealServerLockContext, handleSigningSessionSealRoutes, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, parseSigningSessionSealRootConfig, resolveSigningSessionSealBasePath, signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode };
|
|
@@ -13,33 +13,4 @@ export declare class UpstashRedisRestClient {
|
|
|
13
13
|
setJson(key: string, value: unknown, ttlMs?: number): Promise<void>;
|
|
14
14
|
eval(script: string, keys: string[], args: string[]): Promise<unknown | null>;
|
|
15
15
|
}
|
|
16
|
-
export type RedisResp = {
|
|
17
|
-
type: 'simple';
|
|
18
|
-
value: string;
|
|
19
|
-
} | {
|
|
20
|
-
type: 'error';
|
|
21
|
-
value: string;
|
|
22
|
-
} | {
|
|
23
|
-
type: 'integer';
|
|
24
|
-
value: number;
|
|
25
|
-
} | {
|
|
26
|
-
type: 'bulk';
|
|
27
|
-
value: string | null;
|
|
28
|
-
};
|
|
29
|
-
export declare class RedisTcpClient {
|
|
30
|
-
private readonly url;
|
|
31
|
-
private socket;
|
|
32
|
-
private buffer;
|
|
33
|
-
private pending;
|
|
34
|
-
private connecting;
|
|
35
|
-
constructor(redisUrl: string);
|
|
36
|
-
private ensureConnected;
|
|
37
|
-
private connect;
|
|
38
|
-
private drain;
|
|
39
|
-
private failAll;
|
|
40
|
-
send(args: string[]): Promise<RedisResp>;
|
|
41
|
-
}
|
|
42
|
-
export declare function redisGetJson(client: RedisTcpClient, key: string): Promise<unknown | null>;
|
|
43
|
-
export declare function redisDel(client: RedisTcpClient, key: string): Promise<void>;
|
|
44
|
-
export declare function redisSetJson(client: RedisTcpClient, key: string, value: unknown, ttlMs?: number): Promise<void>;
|
|
45
16
|
//# sourceMappingURL=kv.d.ts.map
|
|
@@ -44,8 +44,6 @@ export type { InMemoryRouterApiRuntimeSnapshotConsumer, RouterApiRuntimeSnapshot
|
|
|
44
44
|
export { createInMemoryRouterApiRuntimeSnapshotConsumer, validateRuntimeSnapshotExpectation, } from './framework/runtimeSnapshotConsumer';
|
|
45
45
|
export { extractBearerCredential, extractRouterApiEnvironmentId, resolveSourceIpFromFetchHeaders, } from './auth/routerApiKeyAuth';
|
|
46
46
|
export { createCloudflareRouter } from './cloudflare/runtime/createCloudflareRouter';
|
|
47
|
-
export type { SelfHostedCloudflareSigningWorkerFactoryInput } from './cloudflare/runtime/createSelfHostedCloudflareSigningWorker';
|
|
48
|
-
export { createSelfHostedCloudflareSigningRouter, createSelfHostedCloudflareSigningWorker, } from './cloudflare/runtime/createSelfHostedCloudflareSigningWorker';
|
|
49
47
|
export { CloudflareDurableObjectVersionedJsonRecordStore, CloudflareVersionedJsonRecordStoreError, createCloudflareDurableObjectVersionedJsonRecordStore, } from './cloudflare/durableObjects/versionedJsonRecordStore';
|
|
50
48
|
export type { CloudflareVersionedJsonRecordStoreOptions } from './cloudflare/durableObjects/versionedJsonRecordStore';
|
|
51
49
|
export type { VersionedJsonObject, VersionedJsonRecordPutResult, VersionedJsonRecordReadResult, VersionedJsonValue, } from './framework/versionedJsonRecordStore';
|
package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/guards/backends.d.ts
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SigningSessionSealRateLimiter } from './index';
|
|
2
2
|
export interface CreateUpstashSigningSessionSealRateLimiterOptions {
|
|
3
3
|
url: string;
|
|
4
4
|
token: string;
|
|
5
5
|
keyPrefix?: string;
|
|
6
6
|
}
|
|
7
|
-
export interface CreateRedisTcpSigningSessionSealRateLimiterOptions {
|
|
8
|
-
redisUrl: string;
|
|
9
|
-
keyPrefix?: string;
|
|
10
|
-
}
|
|
11
7
|
export declare function createUpstashSigningSessionSealRateLimiter(options: CreateUpstashSigningSessionSealRateLimiterOptions): SigningSessionSealRateLimiter;
|
|
12
|
-
export declare function createRedisTcpSigningSessionSealRateLimiter(options: CreateRedisTcpSigningSessionSealRateLimiterOptions): SigningSessionSealRateLimiter;
|
|
13
|
-
export interface CreateSigningSessionSealRateLimitFromEnvInput {
|
|
14
|
-
limiterKind?: 'in-memory' | 'upstash-redis-rest' | 'redis-tcp' | null;
|
|
15
|
-
upstashUrl?: string | null;
|
|
16
|
-
upstashToken?: string | null;
|
|
17
|
-
redisUrl?: string | null;
|
|
18
|
-
keyPrefix?: string | null;
|
|
19
|
-
limit: number;
|
|
20
|
-
windowMs: number;
|
|
21
|
-
}
|
|
22
|
-
export declare function resolveSigningSessionSealRateLimitFromEnv(input: CreateSigningSessionSealRateLimitFromEnvInput): Pick<CreateSigningSessionSealRateLimitGuardOptions, 'limiter' | 'limit' | 'windowMs'>;
|
|
23
8
|
//# sourceMappingURL=backends.d.ts.map
|
package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyBackends.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import type { SigningSessionSealIdempotencyStore
|
|
1
|
+
import type { SigningSessionSealIdempotencyStore } from './signingSessionSeal.types';
|
|
2
2
|
export interface CreateUpstashSigningSessionSealIdempotencyStoreOptions {
|
|
3
3
|
url: string;
|
|
4
4
|
token: string;
|
|
5
5
|
keyPrefix?: string;
|
|
6
6
|
nowMs?: () => number;
|
|
7
7
|
}
|
|
8
|
-
export interface CreateRedisTcpSigningSessionSealIdempotencyStoreOptions {
|
|
9
|
-
redisUrl: string;
|
|
10
|
-
keyPrefix?: string;
|
|
11
|
-
nowMs?: () => number;
|
|
12
|
-
}
|
|
13
8
|
export declare function createUpstashSigningSessionSealIdempotencyStore(options: CreateUpstashSigningSessionSealIdempotencyStoreOptions): SigningSessionSealIdempotencyStore;
|
|
14
|
-
export declare function createRedisTcpSigningSessionSealIdempotencyStore(options: CreateRedisTcpSigningSessionSealIdempotencyStoreOptions): SigningSessionSealIdempotencyStore;
|
|
15
|
-
export interface CreateSigningSessionSealIdempotencyFromEnvInput {
|
|
16
|
-
idempotencyKind?: string | null;
|
|
17
|
-
upstashUrl?: string | null;
|
|
18
|
-
upstashToken?: string | null;
|
|
19
|
-
redisUrl?: string | null;
|
|
20
|
-
keyPrefix?: string | null;
|
|
21
|
-
ttlMs?: number | null;
|
|
22
|
-
}
|
|
23
|
-
export declare function resolveSigningSessionSealIdempotencyFromEnv(input: CreateSigningSessionSealIdempotencyFromEnvInput): SigningSessionSealServiceIdempotencyOptions;
|
|
24
9
|
//# sourceMappingURL=idempotencyBackends.d.ts.map
|
|
@@ -4,8 +4,8 @@ export type { CreateSigningSessionSealAuditLoggerOptions } from './observability
|
|
|
4
4
|
export type { CreateSigningSessionSealRoutesOptionsInput } from './routesOptions';
|
|
5
5
|
export type { CreateSigningSessionSealOptionsInput } from './options';
|
|
6
6
|
export type { CreateSigningSessionSealRateLimitGuardOptions, InMemorySigningSessionSealRateLimiterOptions, SigningSessionSealRateLimitConsumeInput, SigningSessionSealRateLimitConsumeResult, SigningSessionSealRateLimiter, SigningSessionSealRateLimitRejectedEvent, } from './guards';
|
|
7
|
-
export type {
|
|
8
|
-
export type {
|
|
7
|
+
export type { CreateUpstashSigningSessionSealRateLimiterOptions, } from './guards/backends';
|
|
8
|
+
export type { CreateUpstashSigningSessionSealIdempotencyStoreOptions, } from './idempotencyBackends';
|
|
9
9
|
export { signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode, } from './transport/shared';
|
|
10
10
|
export { buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, resolveSigningSessionSealBasePath, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, authorizeSigningSessionSealRequest, } from './transport/shared';
|
|
11
11
|
export { createSigningSessionSealCipherAdapter, createPassthroughSigningSessionSealCipherAdapter, createSigningSessionSealShamir3PassCipherAdapter, encodeSigningSessionSealServerLockContext, } from './crypto/cipher';
|
|
@@ -15,8 +15,8 @@ export { createSigningSessionSealAuditLogger } from './observability/audit';
|
|
|
15
15
|
export { createSigningSessionSealRoutesOptions } from './routesOptions';
|
|
16
16
|
export { createSigningSessionSealOptions, parseSigningSessionSealRootConfig } from './options';
|
|
17
17
|
export { createInMemorySigningSessionSealRateLimiter, createSigningSessionSealRateLimitGuard, } from './guards';
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
18
|
+
export { createUpstashSigningSessionSealRateLimiter, } from './guards/backends';
|
|
19
|
+
export { createUpstashSigningSessionSealIdempotencyStore, } from './idempotencyBackends';
|
|
20
20
|
export { composeSigningSessionSealGuards } from './guards';
|
|
21
21
|
export { handleSigningSessionSealRoutes } from './transport/fetch';
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { coerceRouterLogger } from "../../framework/logger.js";
|
|
2
|
-
import { json, withCors } from "../../framework/http.js";
|
|
3
|
-
import { handleThresholdEcdsa } from "../../transport/fetch/routes/thresholdEcdsa.js";
|
|
4
|
-
import { handleThresholdEd25519 } from "../../transport/fetch/routes/thresholdEd25519.js";
|
|
5
|
-
import { validateRouterApiRorOptions } from "../../framework/ror/provider.js";
|
|
6
|
-
import "../../framework/routerApi.js";
|
|
7
|
-
//#region src/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.ts
|
|
8
|
-
function notFound() {
|
|
9
|
-
return new Response("Not Found", { status: 404 });
|
|
10
|
-
}
|
|
11
|
-
function selfHostedHealthResponse(ctx) {
|
|
12
|
-
if (ctx.method !== "GET") return null;
|
|
13
|
-
if (ctx.pathname !== "/healthz" && ctx.pathname !== "/readyz") return null;
|
|
14
|
-
if (ctx.pathname === "/healthz" && !ctx.opts.healthz) return null;
|
|
15
|
-
if (ctx.pathname === "/readyz" && !ctx.opts.readyz) return null;
|
|
16
|
-
return json({
|
|
17
|
-
ok: true,
|
|
18
|
-
selfHosted: true,
|
|
19
|
-
threshold: { configured: Boolean(ctx.opts.routerAbNormalSigningRouterProxy) }
|
|
20
|
-
}, { status: 200 });
|
|
21
|
-
}
|
|
22
|
-
function createSelfHostedContext(input) {
|
|
23
|
-
const url = new URL(input.request.url);
|
|
24
|
-
return {
|
|
25
|
-
request: input.request,
|
|
26
|
-
url,
|
|
27
|
-
pathname: url.pathname,
|
|
28
|
-
method: input.request.method.toUpperCase(),
|
|
29
|
-
runtime: input.cfCtx ? {
|
|
30
|
-
kind: "background",
|
|
31
|
-
waitUntil: (promise) => input.cfCtx?.waitUntil(promise)
|
|
32
|
-
} : { kind: "inline" },
|
|
33
|
-
service: input.service,
|
|
34
|
-
opts: input.opts,
|
|
35
|
-
logger: input.logger,
|
|
36
|
-
routeDefinitions: []
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function createSelfHostedCloudflareSigningRouter(service, opts = {}) {
|
|
40
|
-
const sessionCookieName = String(opts.sessionCookieName || "").trim() || "seams-jwt";
|
|
41
|
-
const effectiveOpts = {
|
|
42
|
-
...opts,
|
|
43
|
-
sessionCookieName
|
|
44
|
-
};
|
|
45
|
-
if (effectiveOpts.ror) validateRouterApiRorOptions(effectiveOpts.ror);
|
|
46
|
-
const logger = coerceRouterLogger(effectiveOpts.logger);
|
|
47
|
-
const handler = async (request, _env, cfCtx) => {
|
|
48
|
-
if (request.method.toUpperCase() === "OPTIONS") {
|
|
49
|
-
const res = new Response(null, { status: 204 });
|
|
50
|
-
withCors(res.headers, effectiveOpts, request);
|
|
51
|
-
return res;
|
|
52
|
-
}
|
|
53
|
-
const ctx = createSelfHostedContext({
|
|
54
|
-
request,
|
|
55
|
-
cfCtx,
|
|
56
|
-
service,
|
|
57
|
-
opts: effectiveOpts,
|
|
58
|
-
logger
|
|
59
|
-
});
|
|
60
|
-
try {
|
|
61
|
-
const response = selfHostedHealthResponse(ctx) || await handleThresholdEd25519(ctx) || await handleThresholdEcdsa(ctx) || notFound();
|
|
62
|
-
withCors(response.headers, effectiveOpts, request);
|
|
63
|
-
return response;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const res = json({
|
|
66
|
-
code: "internal",
|
|
67
|
-
message: error instanceof Error ? error.message : String(error)
|
|
68
|
-
}, { status: 500 });
|
|
69
|
-
withCors(res.headers, effectiveOpts, request);
|
|
70
|
-
return res;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return handler;
|
|
74
|
-
}
|
|
75
|
-
function createSelfHostedCloudflareSigningWorker(input) {
|
|
76
|
-
return { async fetch(request, env, ctx) {
|
|
77
|
-
const service = await input.createAuthService({
|
|
78
|
-
request,
|
|
79
|
-
env,
|
|
80
|
-
ctx
|
|
81
|
-
});
|
|
82
|
-
return createSelfHostedCloudflareSigningRouter(service, typeof input.routerOptions === "function" ? await input.routerOptions({
|
|
83
|
-
request,
|
|
84
|
-
env,
|
|
85
|
-
ctx,
|
|
86
|
-
service
|
|
87
|
-
}) : input.routerOptions || {})(request, env, ctx);
|
|
88
|
-
} };
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
export { createSelfHostedCloudflareSigningRouter, createSelfHostedCloudflareSigningWorker };
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=createSelfHostedCloudflareSigningWorker.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { RouterApiServiceBag } from '../../framework/authServicePort';
|
|
2
|
-
import type { RouterApiOptions } from '../../framework/routerApi';
|
|
3
|
-
import type { CfEnv, CfExecutionContext, FetchHandler } from './cloudflare.types';
|
|
4
|
-
type SelfHostedWorker<Env> = {
|
|
5
|
-
fetch(request: Request, env: Env, ctx: CfExecutionContext): Promise<Response>;
|
|
6
|
-
};
|
|
7
|
-
export type SelfHostedCloudflareSigningWorkerFactoryInput<Env extends CfEnv = CfEnv> = {
|
|
8
|
-
readonly createAuthService: (input: {
|
|
9
|
-
readonly request: Request;
|
|
10
|
-
readonly env: Env;
|
|
11
|
-
readonly ctx: CfExecutionContext;
|
|
12
|
-
}) => RouterApiServiceBag | Promise<RouterApiServiceBag>;
|
|
13
|
-
readonly routerOptions?: RouterApiOptions | ((input: {
|
|
14
|
-
readonly request: Request;
|
|
15
|
-
readonly env: Env;
|
|
16
|
-
readonly ctx: CfExecutionContext;
|
|
17
|
-
readonly service: RouterApiServiceBag;
|
|
18
|
-
}) => RouterApiOptions | Promise<RouterApiOptions>);
|
|
19
|
-
};
|
|
20
|
-
export declare function createSelfHostedCloudflareSigningRouter(service: RouterApiServiceBag, opts?: RouterApiOptions): FetchHandler;
|
|
21
|
-
export declare function createSelfHostedCloudflareSigningWorker<Env extends CfEnv = CfEnv>(input: SelfHostedCloudflareSigningWorkerFactoryInput<Env>): SelfHostedWorker<Env>;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=createSelfHostedCloudflareSigningWorker.d.ts.map
|