@seams/wallet-server 0.11.0 → 0.13.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 +32 -27
- 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 +2 -3
- package/dist/esm/core/ThresholdService/kv.js +1 -218
- package/dist/esm/index.js +3 -3
- package/dist/esm/local-hosted-wallet-gateway-worker.js +4 -2
- package/dist/esm/localHostedWalletGatewayHandler.js +20 -7
- package/dist/esm/router/cloudflare/d1/registration/d1WalletExecutionAuthority.js +109 -14
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +16 -2
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +7 -12
- package/dist/esm/router/cloudflare-adaptor.js +1 -2
- package/dist/esm/router/cloudflare.js +2 -86
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +1 -1
- 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/cloud-host.d.ts +1 -1
- package/dist/types/wallet-server/src/core/ThresholdService/kv.d.ts +0 -29
- package/dist/types/wallet-server/src/localHostedWalletGatewayHandler.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletExecutionAuthority.d.ts +22 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +0 -2
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationReservation.d.ts +13 -18
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +1 -1
- 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/migrations/d1-signer/0081_registration_directory_publications.sql +26 -0
- 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
|
@@ -1033,7 +1033,7 @@ export interface RouterApiWalletRegistrationService {
|
|
|
1033
1033
|
setupWalletRegistration(input: WalletRegistrationSetupInput): Promise<RouteResponse>;
|
|
1034
1034
|
respondWalletRegistration(input: WalletRegistrationRespondInput, traceContext?: RouterAbTraceContextV1, serverTiming?: Array<readonly [string, number]>, waitUntil?: (promise: Promise<unknown>) => void): Promise<WalletRegistrationRespondResponseV2>;
|
|
1035
1035
|
authorizeWalletRegistrationNearAdmission(input: WalletRegistrationNearAdmissionInput): Promise<WalletRegistrationNearAdmissionResponseV2>;
|
|
1036
|
-
activateWalletRegistration(input: WalletRegistrationActivateInput, traceContext?: RouterAbTraceContextV1, serverTiming?: Array<readonly [string, number]>): Promise<WalletRegistrationActivateResponseV2>;
|
|
1036
|
+
activateWalletRegistration(input: WalletRegistrationActivateInput, traceContext?: RouterAbTraceContextV1, serverTiming?: Array<readonly [string, number]>, waitUntil?: (promise: Promise<unknown>) => void): Promise<WalletRegistrationActivateResponseV2>;
|
|
1037
1037
|
completeWalletRegistrationNearProvisioning(input: WalletRegistrationNearProvisioningInput, serverTiming?: Array<readonly [string, number]>, waitUntil?: (promise: Promise<unknown>) => void): Promise<WalletRegistrationNearProvisioningResponseV2>;
|
|
1038
1038
|
refreshEd25519YaoWalletSession(input: RouterAbEd25519YaoBudgetRefreshRequestV1): Promise<RouterAbEd25519YaoBudgetRefreshResponseV1>;
|
|
1039
1039
|
provisionEd25519YaoWalletSession(input: RouterAbEd25519YaoVerifiedWalletUnlockRequestV1): Promise<RouterAbEd25519YaoVerifiedWalletUnlockResponseV1>;
|
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
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- An active registration home whose directory write has no acknowledgement yet.
|
|
2
|
+
-- The batch that completes the registration operation and activates the home
|
|
3
|
+
-- inserts the row; the acknowledgement deletes it. A refused row stays for an operator.
|
|
4
|
+
CREATE TABLE wallet_registration_directory_publications (
|
|
5
|
+
namespace TEXT NOT NULL, org_id TEXT NOT NULL, project_id TEXT NOT NULL, env_id TEXT NOT NULL,
|
|
6
|
+
wallet_id TEXT NOT NULL,
|
|
7
|
+
ceremony_id TEXT NOT NULL CHECK(length(ceremony_id) > 0),
|
|
8
|
+
session_digest TEXT NOT NULL CHECK(length(session_digest) > 0),
|
|
9
|
+
session_expires_at_ms INTEGER NOT NULL
|
|
10
|
+
CHECK(session_expires_at_ms > 0 AND session_expires_at_ms <= 9007199254740991),
|
|
11
|
+
state TEXT NOT NULL DEFAULT 'pending' CHECK(state IN ('pending', 'refused')),
|
|
12
|
+
attempts INTEGER NOT NULL DEFAULT 0 CHECK(attempts >= 0),
|
|
13
|
+
next_attempt_at_ms INTEGER NOT NULL CHECK(next_attempt_at_ms > 0),
|
|
14
|
+
PRIMARY KEY(namespace, org_id, project_id, env_id, wallet_id)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX wallet_registration_directory_publications_due
|
|
18
|
+
ON wallet_registration_directory_publications(namespace, org_id, project_id, env_id, state, next_attempt_at_ms);
|
|
19
|
+
|
|
20
|
+
CREATE TRIGGER wallet_registration_directory_publication_identity
|
|
21
|
+
BEFORE UPDATE ON wallet_registration_directory_publications
|
|
22
|
+
WHEN NEW.wallet_id IS NOT OLD.wallet_id OR NEW.ceremony_id IS NOT OLD.ceremony_id
|
|
23
|
+
OR NEW.session_digest IS NOT OLD.session_digest
|
|
24
|
+
OR NEW.session_expires_at_ms IS NOT OLD.session_expires_at_ms
|
|
25
|
+
OR (OLD.state = 'refused' AND NEW.state != 'refused')
|
|
26
|
+
BEGIN SELECT RAISE(ABORT, 'wallet_registration_directory_publication_conflicts'); END;
|
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
|