@seams/wallet-server 0.10.2 → 0.11.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/THIRD_PARTY_NOTICES.md +33 -1812
- package/artifact-manifest.json +30 -30
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-a/index.js +2 -2
- 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.js +2 -2
- package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/router/index.js +2 -2
- 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/dist/esm/cloud-host.js +7 -6
- package/dist/esm/hosted-wallet-gateway.js +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/localHostedWalletGatewayHandler.js +17 -11
- package/dist/esm/localIntendedYaoFault.js +34 -3
- package/dist/esm/localIntendedYaoRecoveryFault.js +19 -16
- package/dist/esm/localIntendedYaoSigningFault.js +31 -16
- package/dist/esm/router/auth/routerApiKeyAuth.js +1 -13
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +3 -3
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +19 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +5 -5
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +5 -2
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSetupSupport.js +7 -1
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +29 -4
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationRead.js +6 -3
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +51 -29
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +23 -7
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerFinalizeRecord.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +2 -2
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +3 -3
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +1 -1
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +1 -1
- package/dist/esm/router/cloudflare-adaptor.js +2 -2
- package/dist/esm/router/cloudflare.js +2477 -2438
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +1 -1
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +39 -32
- package/dist/esm/router/framework/registrationSetupDispatch.js +11 -3
- package/dist/esm/router/framework/routeResponses.js +1 -5
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +1 -1
- package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +2 -2
- package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +51 -24
- package/dist/esm/shared-ts/src/utils/validation.js +5 -1
- package/dist/esm/threshold/session/signingSessionSeal/index.js +1 -2
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/esm/wasm/shamir3pass_runtime/pkg/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/types/wallet-server/src/cloud-host.d.ts +1 -0
- package/dist/types/wallet-server/src/localHostedWalletGatewayHandler.d.ts +1 -1
- package/dist/types/wallet-server/src/localIntendedYaoFault.d.ts +13 -3
- package/dist/types/wallet-server/src/localIntendedYaoRecoveryFault.d.ts +4 -2
- package/dist/types/wallet-server/src/localIntendedYaoSigningFault.d.ts +4 -2
- package/dist/types/wallet-server/src/router/auth/routerApiKeyAuth.d.ts +0 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +1 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationSetupSupport.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.d.ts +25 -5
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationRead.d.ts +15 -0
- package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +1 -1
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +2 -0
- package/dist/types/wallet-server/src/router/framework/routeResponses.d.ts +0 -2
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/index.d.ts +1 -2
- package/package.json +2 -9
- package/src/README.md +5 -3
- package/dist/esm/router/express-adaptor.js +0 -84
- package/dist/esm/router/express.js +0 -26400
- package/dist/esm/router/node/nodeHostedWalletGateway.js +0 -64
- package/dist/esm/router/node/nodeHostedWalletGatewayCheck.js +0 -163
- package/dist/esm/router/node/nodeHostedWalletGatewayMain.js +0 -120
- package/dist/esm/router/node/nodeHttp.js +0 -79
- package/dist/esm/router/node/nodeSqlite.js +0 -43
- package/dist/esm/router/node/signerSqlMigrations.js +0 -48
- package/dist/esm/storage/syncSqlite.js +0 -79
- package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +0 -75
- package/dist/types/wallet-server/src/router/express-adaptor.d.ts +0 -22
- package/dist/types/wallet-server/src/router/node/nodeHostedWalletGateway.d.ts +0 -34
- package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayCheck.d.ts +0 -21
- package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayMain.d.ts +0 -2
- package/dist/types/wallet-server/src/router/node/nodeHttp.d.ts +0 -13
- package/dist/types/wallet-server/src/router/node/nodeSqlite.d.ts +0 -22
- package/dist/types/wallet-server/src/router/node/signerSqlMigrations.d.ts +0 -20
- package/dist/types/wallet-server/src/storage/syncSqlite.d.ts +0 -28
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/express.d.ts +0 -12
|
@@ -48,6 +48,8 @@ type RegistrationIntentSignerBranches = {
|
|
|
48
48
|
readonly evmFamilyEcdsa: RegistrationEvmFamilyEcdsaSignerPlan | null;
|
|
49
49
|
};
|
|
50
50
|
export declare function recordRegistrationServerTiming(sink: Array<readonly [string, number]>, name: string, startedAtMs: number): void;
|
|
51
|
+
/** The `Server-Timing` header of a registration route's recorded waits. */
|
|
52
|
+
export declare function registrationServerTimingHeaders(serverTiming: readonly (readonly [string, number])[]): Record<string, string> | undefined;
|
|
51
53
|
export declare function recordRegistrationPromiseTiming<T>(args: {
|
|
52
54
|
readonly sink: Array<readonly [string, number]>;
|
|
53
55
|
readonly name: string;
|
|
@@ -2,6 +2,7 @@ import { type PasskeyCredentialClaims } from '../../../../core/passkeyCredential
|
|
|
2
2
|
import type { ActiveWalletAuthorityV1 } from '../../../../../../shared-ts/src/authorization/walletAuthority';
|
|
3
3
|
import { type ActiveWalletAuthMethodRecordV2 } from '../../../../../../shared-ts/src/utils/walletAuthMethodRecord';
|
|
4
4
|
import { type RegistrationAuthority } from '../../../../../../shared-ts/src/utils/registrationAuthMethodInput';
|
|
5
|
+
import type { Variant } from '../../../../../../shared-ts/src/utils/variant';
|
|
5
6
|
import type { WalletRecord, WalletSignerRecord } from '../../../../core/WalletStore';
|
|
6
7
|
import type { D1DatabaseLike, D1PreparedStatementLike, D1ResultLike } from '../../../../storage/tenantRoute';
|
|
7
8
|
import type { D1EmailOtpRegistrationCommitPlan } from '../emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer';
|
|
@@ -41,11 +42,11 @@ export type HeldRegistrationPasskeyClaim = {
|
|
|
41
42
|
export interface D1WalletRegistrationCommitStore {
|
|
42
43
|
/**
|
|
43
44
|
* Claims the authority's passkey through shared authority, unless `held`
|
|
44
|
-
* records that the same claim was already granted for this ceremony.
|
|
45
|
-
*
|
|
46
|
-
* the claim
|
|
45
|
+
* records that the same claim was already granted for this ceremony. Uses
|
|
46
|
+
* the founding snapshot when supplied; otherwise reads the named records
|
|
47
|
+
* beside the claim. The returned commit performs no additional read.
|
|
47
48
|
*/
|
|
48
|
-
reserveAuthority(authority: RegistrationAuthority, held: HeldRegistrationPasskeyClaim | null, founding:
|
|
49
|
+
reserveAuthority(authority: RegistrationAuthority, held: HeldRegistrationPasskeyClaim | null, founding: RegistrationFoundingRead | null): Promise<ReservedWalletRegistrationCommit>;
|
|
49
50
|
/**
|
|
50
51
|
* Claims a verified passkey before finalization and records a granted
|
|
51
52
|
* claim. A refusal records nothing, so finalization claims again and
|
|
@@ -62,6 +63,25 @@ export interface D1WalletRegistrationCommitStore {
|
|
|
62
63
|
deleteHeldPasskeyClaim(registrationCeremonyId: string): Promise<void>;
|
|
63
64
|
}
|
|
64
65
|
type FoundingRecordIds = Pick<D1WalletRegistrationOperationPreparedV1, 'walletAuthorityId' | 'walletAuthMethodId'>;
|
|
66
|
+
export type RegistrationFoundingRead = {
|
|
67
|
+
readonly kind: 'read';
|
|
68
|
+
readonly ids: FoundingRecordIds;
|
|
69
|
+
readonly records?: never;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'snapshot';
|
|
72
|
+
readonly records: StoredFoundingRecords;
|
|
73
|
+
readonly ids?: never;
|
|
74
|
+
};
|
|
75
|
+
export type RegistrationFoundingSnapshot = Variant<RegistrationFoundingRead, 'kind', 'snapshot'>;
|
|
76
|
+
export declare function parseRegistrationFoundingRead(result: D1ResultLike<Record<string, unknown>>): RegistrationFoundingSnapshot | null;
|
|
77
|
+
/** A registration's founding authority and auth method rows from one database snapshot. */
|
|
78
|
+
type StoredFoundingRecords = FoundingRecordIds & {
|
|
79
|
+
readonly authorityRow: D1RegistrationRecordJsonRow | null;
|
|
80
|
+
readonly authMethodRow: D1RegistrationRecordJsonRow | null;
|
|
81
|
+
};
|
|
82
|
+
type D1RegistrationRecordJsonRow = {
|
|
83
|
+
readonly record_json?: unknown;
|
|
84
|
+
};
|
|
65
85
|
export declare class CloudflareD1WalletRegistrationCommitStore implements D1WalletRegistrationCommitStore {
|
|
66
86
|
private readonly database;
|
|
67
87
|
private readonly scope;
|
|
@@ -74,7 +94,7 @@ export declare class CloudflareD1WalletRegistrationCommitStore implements D1Wall
|
|
|
74
94
|
readonly projectId: string;
|
|
75
95
|
readonly envId: string;
|
|
76
96
|
});
|
|
77
|
-
reserveAuthority(authority: RegistrationAuthority, held: HeldRegistrationPasskeyClaim | null, founding:
|
|
97
|
+
reserveAuthority(authority: RegistrationAuthority, held: HeldRegistrationPasskeyClaim | null, founding: RegistrationFoundingRead | null): Promise<ReservedWalletRegistrationCommit>;
|
|
78
98
|
claimPasskeyAhead(input: {
|
|
79
99
|
readonly registrationCeremonyId: string;
|
|
80
100
|
readonly authority: RegistrationAuthority;
|
package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationRead.d.ts
CHANGED
|
@@ -40,6 +40,21 @@ export declare class D1WalletRegistrationRead {
|
|
|
40
40
|
} | {
|
|
41
41
|
ok: true;
|
|
42
42
|
operation: import("../../../cloudflare-adaptor").VersionedJsonRecordReadResult<D1WalletRegistrationNearProvisioningSideEffectRecord>;
|
|
43
|
+
readFounding: () => {
|
|
44
|
+
readonly kind: "snapshot";
|
|
45
|
+
readonly records: {
|
|
46
|
+
readonly walletAuthMethodId: import("../../../../../../shared-ts/src/utils").WalletAuthMethodId;
|
|
47
|
+
readonly walletAuthorityId: import("../../../../../../shared-ts/src/utils").WalletAuthorityId;
|
|
48
|
+
} & {
|
|
49
|
+
readonly authorityRow: {
|
|
50
|
+
readonly record_json?: unknown;
|
|
51
|
+
} | null;
|
|
52
|
+
readonly authMethodRow: {
|
|
53
|
+
readonly record_json?: unknown;
|
|
54
|
+
} | null;
|
|
55
|
+
};
|
|
56
|
+
readonly ids?: never;
|
|
57
|
+
} | null;
|
|
43
58
|
decision: import("../../../domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoLifecycleDecision").RouterAbEd25519YaoLifecycleDecisionV1 | null;
|
|
44
59
|
heldPasskeyClaim: import("./d1WalletRegistrationCommitStore").HeldRegistrationPasskeyClaim | null;
|
|
45
60
|
readCeremony: () => Promise<import("../../../../core/RegistrationCeremonyStore").StoredWalletRegistrationCeremony | null>;
|
|
@@ -42,7 +42,7 @@ export type { CloudflareTenantStorageRoute, CloudflareTenantTopology, D1BindingN
|
|
|
42
42
|
export { StaticCloudflareTenantStorageRouteResolver, createCloudflareTenantStorageRoute, createSignerD1DoStorageTarget, createStaticCloudflareTenantStorageRouteResolver, createStaticCloudflareTenantStorageRouteResolverFromBindings, } from '../storage/tenantRoute';
|
|
43
43
|
export type { InMemoryRouterApiRuntimeSnapshotConsumer, RouterApiRuntimeSnapshotPublishedUpdate, } from './framework/runtimeSnapshotConsumer';
|
|
44
44
|
export { createInMemoryRouterApiRuntimeSnapshotConsumer, validateRuntimeSnapshotExpectation, } from './framework/runtimeSnapshotConsumer';
|
|
45
|
-
export { extractBearerCredential, extractRouterApiEnvironmentId,
|
|
45
|
+
export { extractBearerCredential, extractRouterApiEnvironmentId, resolveSourceIpFromFetchHeaders, } from './auth/routerApiKeyAuth';
|
|
46
46
|
export { createCloudflareRouter } from './cloudflare/runtime/createCloudflareRouter';
|
|
47
47
|
export type { SelfHostedCloudflareSigningWorkerFactoryInput } from './cloudflare/runtime/createSelfHostedCloudflareSigningWorker';
|
|
48
48
|
export { createSelfHostedCloudflareSigningRouter, createSelfHostedCloudflareSigningWorker, } from './cloudflare/runtime/createSelfHostedCloudflareSigningWorker';
|
package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type WalletRegistrationSetupInput = {
|
|
|
21
21
|
readonly runtimePolicyScope?: ThresholdRuntimePolicyScope;
|
|
22
22
|
readonly signingRootId?: string;
|
|
23
23
|
readonly signingRootVersion?: string;
|
|
24
|
+
/** Collects the `[name, ms]` waits of this setup for its `Server-Timing` header. */
|
|
25
|
+
readonly serverTiming?: Array<readonly [string, number]>;
|
|
24
26
|
};
|
|
25
27
|
export type WalletRegistrationRespondInput = {
|
|
26
28
|
readonly registrationCeremonyId: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Response as ExpressResponse } from 'express';
|
|
2
1
|
import type { RouteResponse } from './routeExecutionContext';
|
|
3
2
|
import type { RoutePolicyFailureCode } from './routeAuthPolicy';
|
|
4
3
|
import type { RouteUsageData } from './routeMeteringPolicy';
|
|
@@ -12,6 +11,5 @@ export declare function routeJson<TBody>(status: number, body: TBody, options?:
|
|
|
12
11
|
usage?: RouteUsageData;
|
|
13
12
|
}): RouteResponse<TBody>;
|
|
14
13
|
export declare function routeError(status: number, code: RouteErrorBody['code'], message: string): RouteResponse<RouteErrorBody>;
|
|
15
|
-
export declare function sendExpressRouteResponse<TBody>(res: ExpressResponse, response: RouteResponse<TBody>): void;
|
|
16
14
|
export declare function toFetchRouteResponse<TBody>(response: RouteResponse<TBody>): Response;
|
|
17
15
|
//# sourceMappingURL=routeResponses.d.ts.map
|
|
@@ -6,7 +6,7 @@ export type { CreateSigningSessionSealOptionsInput } from './options';
|
|
|
6
6
|
export type { CreateSigningSessionSealRateLimitGuardOptions, InMemorySigningSessionSealRateLimiterOptions, SigningSessionSealRateLimitConsumeInput, SigningSessionSealRateLimitConsumeResult, SigningSessionSealRateLimiter, SigningSessionSealRateLimitRejectedEvent, } from './guards';
|
|
7
7
|
export type { CreateSigningSessionSealRateLimitFromEnvInput, CreateRedisTcpSigningSessionSealRateLimiterOptions, CreateUpstashSigningSessionSealRateLimiterOptions, } from './guards/backends';
|
|
8
8
|
export type { CreateSigningSessionSealIdempotencyFromEnvInput, CreateRedisTcpSigningSessionSealIdempotencyStoreOptions, CreateUpstashSigningSessionSealIdempotencyStoreOptions, } from './idempotencyBackends';
|
|
9
|
-
export { signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode } from './transport/shared';
|
|
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';
|
|
12
12
|
export { createSigningSessionSealService } from './service';
|
|
@@ -18,6 +18,5 @@ export { createInMemorySigningSessionSealRateLimiter, createSigningSessionSealRa
|
|
|
18
18
|
export { createRedisTcpSigningSessionSealRateLimiter, createUpstashSigningSessionSealRateLimiter, resolveSigningSessionSealRateLimitFromEnv, } from './guards/backends';
|
|
19
19
|
export { createRedisTcpSigningSessionSealIdempotencyStore, createUpstashSigningSessionSealIdempotencyStore, resolveSigningSessionSealIdempotencyFromEnv, } from './idempotencyBackends';
|
|
20
20
|
export { composeSigningSessionSealGuards } from './guards';
|
|
21
|
-
export { registerSigningSessionSealRoutes } from './transport/express';
|
|
22
21
|
export { handleSigningSessionSealRoutes } from './transport/fetch';
|
|
23
22
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seams/wallet-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Seams server TypeScript SDK for NEAR and EVM-family wallets",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -19,11 +19,6 @@
|
|
|
19
19
|
"import": "./dist/esm/index.js",
|
|
20
20
|
"default": "./dist/esm/index.js"
|
|
21
21
|
},
|
|
22
|
-
"./router/express": {
|
|
23
|
-
"types": "./dist/types/wallet-server/src/router/express-adaptor.d.ts",
|
|
24
|
-
"import": "./dist/esm/router/express.js",
|
|
25
|
-
"default": "./dist/esm/router/express.js"
|
|
26
|
-
},
|
|
27
22
|
"./router/cloudflare": {
|
|
28
23
|
"types": "./dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts",
|
|
29
24
|
"import": "./dist/esm/router/cloudflare.js",
|
|
@@ -120,12 +115,10 @@
|
|
|
120
115
|
"homepage": "https://github.com/seams-tech/seams-wallet#readme",
|
|
121
116
|
"dependencies": {
|
|
122
117
|
"@simplewebauthn/server": "^13.2.2",
|
|
123
|
-
"bs58": "^6.0.0"
|
|
124
|
-
"express": "^4.21.2"
|
|
118
|
+
"bs58": "^6.0.0"
|
|
125
119
|
},
|
|
126
120
|
"devDependencies": {
|
|
127
121
|
"@near-js/types": "^2.4.0",
|
|
128
|
-
"@types/express": "^4.17.21",
|
|
129
122
|
"@types/node": "^20.19.9",
|
|
130
123
|
"rolldown": "^1.0.0-beta.27",
|
|
131
124
|
"typescript": "^5.8.3"
|
package/src/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Use fresh wallets when measuring this change.
|
|
|
76
76
|
It does not authorize wallet ownership.
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
import {
|
|
79
|
+
import { createCloudflareRouter } from '@seams/wallet-server/router/cloudflare';
|
|
80
80
|
import { createSigningSessionSealOptions } from '@seams/wallet-server';
|
|
81
81
|
|
|
82
82
|
const signingSessionSeal = createSigningSessionSealOptions({
|
|
@@ -85,10 +85,12 @@ const signingSessionSeal = createSigningSessionSealOptions({
|
|
|
85
85
|
acceptedWarmKeyVersions: ['signing-session-seal-production-r2'],
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
const fetch = createCloudflareRouter(service, {
|
|
89
89
|
threshold,
|
|
90
90
|
signingSessionSeal,
|
|
91
|
-
})
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export default { fetch };
|
|
92
94
|
```
|
|
93
95
|
|
|
94
96
|
Store the random 32-byte root secret in a secrets manager. Retain accepted old
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ROUTER_AB_PUBLIC_KEYSET_PATH, ROUTER_AB_PUBLIC_KEYSET_VERSION_V2, ROUTER_AB_PUBLIC_KEYSET_WELL_KNOWN_PATH, parseRouterAbPublicKeysetV2 } from "../shared-ts/src/utils/routerAbPublicKeyset.js";
|
|
2
|
-
import { defineRoute } from "./framework/routeDefinitions.js";
|
|
3
|
-
import { InMemoryRouterAbNormalSigningAdmissionStore, createInMemoryRouterAbNormalSigningAdmissionAdapter, createInMemoryRouterAbNormalSigningAdmissionStore, createRouterAbNormalSigningAdmissionAdapter } from "./domains/signingOperations/routerAbNormalSigningAdmissionCore.js";
|
|
4
|
-
import { createRouterApiModule } from "./framework/modules.js";
|
|
5
|
-
import { attachRouterApiRouteSurface, getRouterApiRouteSurface } from "./framework/routerApiRouteSurface.js";
|
|
6
|
-
import { createFetchRouter } from "./transport/fetch/createFetchRouter.js";
|
|
7
|
-
import { createRouterAbEd25519YaoProductRegistrationCompositionFromPortsV1, createRouterAbEd25519YaoProductRegistrationRuntimeV1, createRouterAbEd25519YaoProductRegistrationStateV1 } from "./domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js";
|
|
8
|
-
import { RouterAbEd25519YaoHttpRegistrationBackend, createRouterAbEd25519YaoHttpRegistrationBackendFromEnv } from "./domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js";
|
|
9
|
-
import { createInMemoryRouterApiRuntimeSnapshotConsumer, validateRuntimeSnapshotExpectation } from "./framework/runtimeSnapshotConsumer.js";
|
|
10
|
-
import express from "express";
|
|
11
|
-
//#region src/router/express-adaptor.ts
|
|
12
|
-
function appendExpressRequestHeaders(headers, req) {
|
|
13
|
-
for (const [name, value] of Object.entries(req.headers)) {
|
|
14
|
-
if (Array.isArray(value)) {
|
|
15
|
-
for (const item of value) headers.append(name, item);
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
if (typeof value === "string") headers.set(name, value);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function resolveExpressRequestUrl(req) {
|
|
22
|
-
const host = req.get("host") || "localhost";
|
|
23
|
-
return `${req.protocol || "http"}://${host}${req.originalUrl || req.url}`;
|
|
24
|
-
}
|
|
25
|
-
function encodeExpressRequestBody(req) {
|
|
26
|
-
const method = req.method.toUpperCase();
|
|
27
|
-
if (method === "GET" || method === "HEAD") return void 0;
|
|
28
|
-
if (req.body === void 0 || req.body === null) return void 0;
|
|
29
|
-
if (typeof req.body === "string" || req.body instanceof Uint8Array) return req.body;
|
|
30
|
-
return JSON.stringify(req.body);
|
|
31
|
-
}
|
|
32
|
-
function buildFetchRequestFromExpress(req) {
|
|
33
|
-
const headers = new Headers();
|
|
34
|
-
appendExpressRequestHeaders(headers, req);
|
|
35
|
-
const body = encodeExpressRequestBody(req);
|
|
36
|
-
if (body && !headers.has("content-type")) headers.set("content-type", "application/json; charset=utf-8");
|
|
37
|
-
return new Request(resolveExpressRequestUrl(req), {
|
|
38
|
-
method: req.method,
|
|
39
|
-
headers,
|
|
40
|
-
body
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async function isFetchRouterNotFound(response) {
|
|
44
|
-
if (response.status !== 404) return false;
|
|
45
|
-
return await response.clone().text() === "Not Found";
|
|
46
|
-
}
|
|
47
|
-
async function sendFetchResponseToExpress(fetchResponse, res) {
|
|
48
|
-
fetchResponse.headers.forEach((value, name) => {
|
|
49
|
-
res.setHeader(name, value);
|
|
50
|
-
});
|
|
51
|
-
res.status(fetchResponse.status);
|
|
52
|
-
const body = Buffer.from(await fetchResponse.arrayBuffer());
|
|
53
|
-
if (body.length === 0) {
|
|
54
|
-
res.end();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
res.send(body);
|
|
58
|
-
}
|
|
59
|
-
function createFetchBackedExpressMiddleware(fetchHandler) {
|
|
60
|
-
return async function fetchBackedExpressMiddleware(req, res, next) {
|
|
61
|
-
try {
|
|
62
|
-
const fetchResponse = await fetchHandler(buildFetchRequestFromExpress(req));
|
|
63
|
-
if (await isFetchRouterNotFound(fetchResponse)) {
|
|
64
|
-
next();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
await sendFetchResponseToExpress(fetchResponse, res);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
next(error);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function createRouterApiRouter(service, opts = {}) {
|
|
74
|
-
const fetchHandler = createFetchRouter(service, opts, { kind: "inline" });
|
|
75
|
-
const router = express.Router();
|
|
76
|
-
router.use(createFetchBackedExpressMiddleware(fetchHandler));
|
|
77
|
-
const surface = getRouterApiRouteSurface(fetchHandler);
|
|
78
|
-
if (!surface) return router;
|
|
79
|
-
return attachRouterApiRouteSurface(router, surface);
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { InMemoryRouterAbNormalSigningAdmissionStore, ROUTER_AB_PUBLIC_KEYSET_PATH, ROUTER_AB_PUBLIC_KEYSET_VERSION_V2, ROUTER_AB_PUBLIC_KEYSET_WELL_KNOWN_PATH, RouterAbEd25519YaoHttpRegistrationBackend, createInMemoryRouterAbNormalSigningAdmissionAdapter, createInMemoryRouterAbNormalSigningAdmissionStore, createInMemoryRouterApiRuntimeSnapshotConsumer, createRouterAbEd25519YaoHttpRegistrationBackendFromEnv, createRouterAbEd25519YaoProductRegistrationCompositionFromPortsV1, createRouterAbEd25519YaoProductRegistrationRuntimeV1, createRouterAbEd25519YaoProductRegistrationStateV1, createRouterAbNormalSigningAdmissionAdapter, createRouterApiModule, createRouterApiRouter, defineRoute, parseRouterAbPublicKeysetV2, validateRuntimeSnapshotExpectation };
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=express-adaptor.js.map
|