@canton-network/wallet-gateway-remote 1.12.0 → 1.14.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/README.md +107 -31
- package/dist/auth/jwt-auth-service.d.ts.map +1 -1
- package/dist/auth/jwt-auth-service.js +164 -77
- package/dist/config/Config.d.ts +407 -24
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.js +146 -11
- package/dist/config/ConfigUtils.d.ts +16 -1
- package/dist/config/ConfigUtils.d.ts.map +1 -1
- package/dist/config/ConfigUtils.js +150 -60
- package/dist/dapp-api/controller.d.ts +13 -1
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +16 -20
- package/dist/dapp-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/dapp-api/rpc-gen/typings.d.ts +33 -3
- package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/dapp-api/server.d.ts +10 -5
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/server.js +10 -3
- package/dist/dapp-api/sse-sink.d.ts.map +1 -1
- package/dist/env.d.ts +1 -24
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +0 -23
- package/dist/example-config.d.ts +94 -62
- package/dist/example-config.d.ts.map +1 -1
- package/dist/example-config.js +95 -61
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -32
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +86 -127
- package/dist/ledger/party-allocation-service.d.ts +1 -4
- package/dist/ledger/party-allocation-service.d.ts.map +1 -1
- package/dist/ledger/party-allocation-service.js +1 -3
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/blockdaemon-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/dfns-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/kernel-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/participant-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts +2 -2
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.js +2 -2
- package/dist/ledger/wallet-sync-service.d.ts +14 -1
- package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.js +240 -72
- package/dist/middleware/apiKeyAuth.d.ts.map +1 -1
- package/dist/middleware/apiKeyAuth.js +4 -8
- package/dist/middleware/errorHandler.d.ts +1 -1
- package/dist/middleware/errorHandler.d.ts.map +1 -1
- package/dist/middleware/jsonRpcHandler.d.ts.map +1 -1
- package/dist/middleware/jsonRpcHandler.js +3 -3
- package/dist/middleware/jwtAuth.d.ts +1 -1
- package/dist/middleware/jwtAuth.d.ts.map +1 -1
- package/dist/middleware/jwtAuth.js +17 -2
- package/dist/middleware/rateLimit.d.ts.map +1 -1
- package/dist/middleware/rateLimit.js +3 -9
- package/dist/middleware/securityHeaders.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.d.ts +3 -3
- package/dist/middleware/sessionHandler.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.js +8 -8
- package/dist/notices/server-notices.d.ts +24 -0
- package/dist/notices/server-notices.d.ts.map +1 -0
- package/dist/notices/server-notices.js +40 -0
- package/dist/notices/server-status-service.d.ts +11 -0
- package/dist/notices/server-status-service.d.ts.map +1 -0
- package/dist/notices/server-status-service.js +17 -0
- package/dist/signing/service-account-session.d.ts +16 -2
- package/dist/signing/service-account-session.d.ts.map +1 -1
- package/dist/signing/service-account-session.js +32 -1
- package/dist/signing-providers-registration.d.ts +7 -0
- package/dist/signing-providers-registration.d.ts.map +1 -0
- package/dist/signing-providers-registration.js +276 -0
- package/dist/user-api/controller.d.ts +25 -4
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +218 -235
- package/dist/user-api/rpc-gen/index.d.ts +27 -9
- package/dist/user-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/index.js +9 -3
- package/dist/user-api/rpc-gen/schemas.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/schemas.js +86 -11
- package/dist/user-api/rpc-gen/typings.d.ts +158 -58
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/user-api/server.d.ts +7 -5
- package/dist/user-api/server.d.ts.map +1 -1
- package/dist/user-api/server.js +7 -2
- package/dist/web/frontend/404/index.html +3 -2
- package/dist/web/frontend/activities/index.html +4 -3
- package/dist/web/frontend/admin/index.html +16 -0
- package/dist/web/frontend/api-keys/add/index.html +3 -2
- package/dist/web/frontend/api-keys/index.html +3 -2
- package/dist/web/frontend/approve/index.html +4 -3
- package/dist/web/frontend/assets/404-N2p-H94F.js +5 -0
- package/dist/web/frontend/assets/activities-CIyMcvMq.js +71 -0
- package/dist/web/frontend/assets/addApiKey-DD_HxolC.js +92 -0
- package/dist/web/frontend/assets/addIdentityProvider-DNaST3bz.js +28 -0
- package/dist/web/frontend/assets/addNetwork-BwV-qK9L.js +38 -0
- package/dist/web/frontend/assets/addParty-DtBW1rpV.js +14 -0
- package/dist/web/frontend/assets/admin-CKAkdJym.js +53 -0
- package/dist/web/frontend/assets/apiKeys-CcnbBkNH.js +68 -0
- package/dist/web/frontend/assets/approve-33mo5eC8.js +27 -0
- package/dist/web/frontend/assets/callback-lKGXXz-1.js +7 -0
- package/dist/web/frontend/assets/common-DaUa4tUM.js +15 -0
- package/dist/web/frontend/assets/dist-BW5ACUmw.js +2 -0
- package/dist/web/frontend/assets/dist-CVv1nHd6.js +1 -0
- package/dist/web/frontend/assets/editParty-ZifjLzYx.js +15 -0
- package/dist/web/frontend/assets/frontend-Bs6UVmG1.js +4968 -0
- package/dist/web/frontend/assets/identityProviders-D5s7N-Ec.js +76 -0
- package/dist/web/frontend/assets/login-BAJsIB9G.js +11 -0
- package/dist/web/frontend/assets/networks-Do-zoG5E.js +78 -0
- package/dist/web/frontend/assets/parties-DFcN190b.js +51 -0
- package/dist/web/frontend/assets/reviewIdentityProvider-C2tsrpKc.js +43 -0
- package/dist/web/frontend/assets/reviewNetwork-BEGzls61.js +43 -0
- package/dist/web/frontend/assets/rolldown-runtime-pP25SEvz.js +1 -0
- package/dist/web/frontend/assets/selfIssuedLogin-a2KenO2P.js +112 -0
- package/dist/web/frontend/assets/signMessage-CQF0sCMe.js +23 -0
- package/dist/web/frontend/callback/index.html +3 -2
- package/dist/web/frontend/identity-providers/add/index.html +3 -2
- package/dist/web/frontend/identity-providers/index.html +3 -2
- package/dist/web/frontend/identity-providers/review/index.html +3 -2
- package/dist/web/frontend/index.html +2 -1
- package/dist/web/frontend/login/index.html +4 -11
- package/dist/web/frontend/networks/add/index.html +3 -2
- package/dist/web/frontend/networks/index.html +3 -2
- package/dist/web/frontend/networks/review/index.html +3 -2
- package/dist/web/frontend/parties/add/index.html +5 -5
- package/dist/web/frontend/parties/edit/index.html +5 -5
- package/dist/web/frontend/parties/index.html +4 -3
- package/dist/web/frontend/self-issued-login/index.html +16 -0
- package/dist/web/frontend/sign-message/index.html +3 -2
- package/dist/web/route-inputs.d.ts.map +1 -1
- package/dist/web/route-inputs.js +2 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +1 -1
- package/package.json +53 -51
- package/dist/auth/jwt-auth-service.test.d.ts +0 -2
- package/dist/auth/jwt-auth-service.test.d.ts.map +0 -1
- package/dist/auth/jwt-auth-service.test.js +0 -659
- package/dist/config/Config.test.d.ts +0 -2
- package/dist/config/Config.test.d.ts.map +0 -1
- package/dist/config/Config.test.js +0 -26
- package/dist/dapp-api/controller.test.d.ts +0 -2
- package/dist/dapp-api/controller.test.d.ts.map +0 -1
- package/dist/dapp-api/controller.test.js +0 -531
- package/dist/dapp-api/server.test.d.ts +0 -2
- package/dist/dapp-api/server.test.d.ts.map +0 -1
- package/dist/dapp-api/server.test.js +0 -79
- package/dist/dapp-api/sse-sink.test.d.ts +0 -2
- package/dist/dapp-api/sse-sink.test.d.ts.map +0 -1
- package/dist/dapp-api/sse-sink.test.js +0 -30
- package/dist/ledger/party-allocation-service.test.d.ts +0 -2
- package/dist/ledger/party-allocation-service.test.d.ts.map +0 -1
- package/dist/ledger/party-allocation-service.test.js +0 -105
- package/dist/ledger/self-issued-auth-service.d.ts +0 -50
- package/dist/ledger/self-issued-auth-service.d.ts.map +0 -1
- package/dist/ledger/self-issued-auth-service.js +0 -263
- package/dist/ledger/self-issued-auth-service.test.d.ts +0 -2
- package/dist/ledger/self-issued-auth-service.test.d.ts.map +0 -1
- package/dist/ledger/self-issued-auth-service.test.js +0 -454
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.d.ts +0 -2
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.d.ts.map +0 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.js +0 -1005
- package/dist/ledger/wallet-sync-service.test.d.ts +0 -2
- package/dist/ledger/wallet-sync-service.test.d.ts.map +0 -1
- package/dist/ledger/wallet-sync-service.test.js +0 -1017
- package/dist/middleware/apiKeyAuth.test.d.ts +0 -2
- package/dist/middleware/apiKeyAuth.test.d.ts.map +0 -1
- package/dist/middleware/apiKeyAuth.test.js +0 -126
- package/dist/middleware/errorHandler.test.d.ts +0 -2
- package/dist/middleware/errorHandler.test.d.ts.map +0 -1
- package/dist/middleware/errorHandler.test.js +0 -138
- package/dist/middleware/jsonRpcHandler.test.d.ts +0 -2
- package/dist/middleware/jsonRpcHandler.test.d.ts.map +0 -1
- package/dist/middleware/jsonRpcHandler.test.js +0 -377
- package/dist/middleware/jwtAuth.test.d.ts +0 -2
- package/dist/middleware/jwtAuth.test.d.ts.map +0 -1
- package/dist/middleware/jwtAuth.test.js +0 -100
- package/dist/middleware/rateLimit.test.d.ts +0 -2
- package/dist/middleware/rateLimit.test.d.ts.map +0 -1
- package/dist/middleware/rateLimit.test.js +0 -56
- package/dist/middleware/securityHeaders.test.d.ts +0 -2
- package/dist/middleware/securityHeaders.test.d.ts.map +0 -1
- package/dist/middleware/securityHeaders.test.js +0 -18
- package/dist/middleware/sessionHandler.test.d.ts +0 -2
- package/dist/middleware/sessionHandler.test.d.ts.map +0 -1
- package/dist/middleware/sessionHandler.test.js +0 -215
- package/dist/signing/service-account-session.test.d.ts +0 -2
- package/dist/signing/service-account-session.test.d.ts.map +0 -1
- package/dist/signing/service-account-session.test.js +0 -88
- package/dist/signing/signing-worker.d.ts +0 -86
- package/dist/signing/signing-worker.d.ts.map +0 -1
- package/dist/signing/signing-worker.js +0 -216
- package/dist/signing/signing-worker.test.d.ts +0 -2
- package/dist/signing/signing-worker.test.d.ts.map +0 -1
- package/dist/signing/signing-worker.test.js +0 -158
- package/dist/user-api/controller.test.d.ts +0 -2
- package/dist/user-api/controller.test.d.ts.map +0 -1
- package/dist/user-api/controller.test.js +0 -1228
- package/dist/user-api/server.test.d.ts +0 -2
- package/dist/user-api/server.test.d.ts.map +0 -1
- package/dist/user-api/server.test.js +0 -117
- package/dist/user-api/token-network-matching.test.d.ts +0 -2
- package/dist/user-api/token-network-matching.test.d.ts.map +0 -1
- package/dist/user-api/token-network-matching.test.js +0 -66
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -24
- package/dist/web/frontend/assets/404-B1XXXMXN.js +0 -5
- package/dist/web/frontend/assets/activities-HZnPjlMp.js +0 -61
- package/dist/web/frontend/assets/addApiKey-BvkCtUF3.js +0 -92
- package/dist/web/frontend/assets/addIdentityProvider-Dvjma837.js +0 -28
- package/dist/web/frontend/assets/addNetwork-Cahac0uo.js +0 -38
- package/dist/web/frontend/assets/addParty-Cdoed_Yx.js +0 -13
- package/dist/web/frontend/assets/apiKeys-BwV6ylWL.js +0 -68
- package/dist/web/frontend/assets/approve-B0nIfe2y.js +0 -26
- package/dist/web/frontend/assets/callback-BieW5Ux2.js +0 -7
- package/dist/web/frontend/assets/common-Bv9twGrA.js +0 -31
- package/dist/web/frontend/assets/editParty-OOjTHFay.js +0 -14
- package/dist/web/frontend/assets/identityProviders-BxJAq1Ne.js +0 -71
- package/dist/web/frontend/assets/index-Bo6MnlYI.js +0 -2
- package/dist/web/frontend/assets/index-CG_aFABR.js +0 -1
- package/dist/web/frontend/assets/index-D1Brmwbg.js +0 -93
- package/dist/web/frontend/assets/index-pMOoiNFq.js +0 -4887
- package/dist/web/frontend/assets/login-BHxgJEz_.js +0 -11
- package/dist/web/frontend/assets/networks-CBprjUF5.js +0 -73
- package/dist/web/frontend/assets/onboarding-ChmWs-TC.js +0 -84
- package/dist/web/frontend/assets/reviewIdentityProvider-CCmKgN8N.js +0 -43
- package/dist/web/frontend/assets/reviewNetwork-CX8Bmuf3.js +0 -43
- package/dist/web/frontend/assets/signMessage-BN_6S5FV.js +0 -79
- package/dist/web/frontend/onboarding/index.html +0 -23
- package/dist/web/route-inputs.test.d.ts +0 -2
- package/dist/web/route-inputs.test.d.ts.map +0 -1
- package/dist/web/route-inputs.test.js +0 -30
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
4
|
-
import { jwtAuth } from './jwtAuth.js';
|
|
5
|
-
import { providerErrors } from '@canton-network/core-rpc-errors';
|
|
6
|
-
import { pino } from 'pino';
|
|
7
|
-
import { sink } from 'pino-test';
|
|
8
|
-
describe('jwtAuth', () => {
|
|
9
|
-
const verifyToken = vi.fn();
|
|
10
|
-
const authService = { verifyToken };
|
|
11
|
-
const logger = pino({ level: 'silent' }, sink());
|
|
12
|
-
let next;
|
|
13
|
-
let status;
|
|
14
|
-
let json;
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
verifyToken.mockReset();
|
|
17
|
-
next = vi.fn();
|
|
18
|
-
status = vi.fn().mockReturnThis();
|
|
19
|
-
json = vi.fn();
|
|
20
|
-
});
|
|
21
|
-
function makeReq(partial) {
|
|
22
|
-
return {
|
|
23
|
-
headers: {},
|
|
24
|
-
query: {},
|
|
25
|
-
...partial,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function makeRes() {
|
|
29
|
-
return { status, json };
|
|
30
|
-
}
|
|
31
|
-
it('sets authContext and calls next when verification succeeds', async () => {
|
|
32
|
-
const ctx = { userId: 'alice', accessToken: 'tok' };
|
|
33
|
-
verifyToken.mockResolvedValue(ctx);
|
|
34
|
-
const req = makeReq({
|
|
35
|
-
headers: { authorization: 'Bearer abc' },
|
|
36
|
-
});
|
|
37
|
-
const res = makeRes();
|
|
38
|
-
const middleware = jwtAuth(authService, logger);
|
|
39
|
-
await middleware(req, res, next);
|
|
40
|
-
expect(verifyToken).toHaveBeenCalledWith('Bearer abc');
|
|
41
|
-
expect(req.authContext).toEqual(ctx);
|
|
42
|
-
expect(next).toHaveBeenCalledOnce();
|
|
43
|
-
expect(status).not.toHaveBeenCalled();
|
|
44
|
-
});
|
|
45
|
-
it('uses Bearer token from query when Authorization header is absent', async () => {
|
|
46
|
-
const ctx = { userId: 'bob', accessToken: 'tok' };
|
|
47
|
-
verifyToken.mockResolvedValue(ctx);
|
|
48
|
-
const req = makeReq({
|
|
49
|
-
query: { token: 'query-jwt' },
|
|
50
|
-
});
|
|
51
|
-
const res = makeRes();
|
|
52
|
-
const middleware = jwtAuth(authService, logger);
|
|
53
|
-
await middleware(req, res, next);
|
|
54
|
-
expect(verifyToken).toHaveBeenCalledWith('Bearer query-jwt');
|
|
55
|
-
expect(req.authContext).toEqual(ctx);
|
|
56
|
-
expect(next).toHaveBeenCalledOnce();
|
|
57
|
-
});
|
|
58
|
-
it('passes undefined to verifyToken when no credentials are present', async () => {
|
|
59
|
-
verifyToken.mockResolvedValue(undefined);
|
|
60
|
-
const req = makeReq({});
|
|
61
|
-
const res = makeRes();
|
|
62
|
-
const middleware = jwtAuth(authService, logger);
|
|
63
|
-
await middleware(req, res, next);
|
|
64
|
-
expect(verifyToken).toHaveBeenCalledWith(undefined);
|
|
65
|
-
expect(req.authContext).toBeUndefined();
|
|
66
|
-
expect(next).toHaveBeenCalledOnce();
|
|
67
|
-
});
|
|
68
|
-
it('returns a JSON-RPC 401 when verification throws', async () => {
|
|
69
|
-
verifyToken.mockRejectedValue(new Error('bad sig'));
|
|
70
|
-
const req = makeReq({
|
|
71
|
-
headers: { authorization: 'Bearer x' },
|
|
72
|
-
body: { id: 7 },
|
|
73
|
-
});
|
|
74
|
-
const res = makeRes();
|
|
75
|
-
const middleware = jwtAuth(authService, logger);
|
|
76
|
-
await middleware(req, res, next);
|
|
77
|
-
expect(next).not.toHaveBeenCalled();
|
|
78
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
79
|
-
expect(json).toHaveBeenCalledWith({
|
|
80
|
-
jsonrpc: '2.0',
|
|
81
|
-
id: 7,
|
|
82
|
-
error: {
|
|
83
|
-
code: providerErrors.unauthorized().code,
|
|
84
|
-
message: 'Invalid or expired token',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
it('does not leak the underlying verification failure to the client', async () => {
|
|
89
|
-
verifyToken.mockRejectedValue(new Error('signature doesnt match the secret which is leaked-secret-123'));
|
|
90
|
-
const req = makeReq({
|
|
91
|
-
headers: { authorization: 'Bearer x' },
|
|
92
|
-
});
|
|
93
|
-
const res = makeRes();
|
|
94
|
-
const middleware = jwtAuth(authService, logger);
|
|
95
|
-
await middleware(req, res, next);
|
|
96
|
-
const body = JSON.stringify(json.mock.calls[0][0]);
|
|
97
|
-
expect(body).not.toContain('leaked-secret-123');
|
|
98
|
-
expect(body).toContain('Invalid or expired token');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimit.test.d.ts","sourceRoot":"","sources":["../../src/middleware/rateLimit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { describe, expect, test } from 'vitest';
|
|
4
|
-
import { ipRateLimitKeyGenerator, rateLimitKeyGenerator } from './rateLimit.js';
|
|
5
|
-
describe('ipRateLimitKeyGenerator', () => {
|
|
6
|
-
test('uses request ip address', () => {
|
|
7
|
-
const req = {
|
|
8
|
-
ip: '198.51.100.42',
|
|
9
|
-
socket: { remoteAddress: '10.0.0.1' },
|
|
10
|
-
};
|
|
11
|
-
expect(ipRateLimitKeyGenerator(req)).toBe('ip:198.51.100.42');
|
|
12
|
-
});
|
|
13
|
-
test('leaves IPv4 request ip address unchanged', () => {
|
|
14
|
-
const req = {
|
|
15
|
-
ip: '198.51.100.42',
|
|
16
|
-
socket: { remoteAddress: '10.0.0.1' },
|
|
17
|
-
};
|
|
18
|
-
expect(ipRateLimitKeyGenerator(req)).toBe('ip:198.51.100.42');
|
|
19
|
-
});
|
|
20
|
-
test('normalizes IPv6 request ip address to a subnet key', () => {
|
|
21
|
-
const req = {
|
|
22
|
-
ip: '2001:db8:abcd:0012:1111:2222:3333:4444',
|
|
23
|
-
socket: { remoteAddress: '10.0.0.1' },
|
|
24
|
-
};
|
|
25
|
-
expect(ipRateLimitKeyGenerator(req)).toBe('ip:2001:db8:abcd::/56');
|
|
26
|
-
});
|
|
27
|
-
test('falls back to socket.remoteAddress when ip is unset', () => {
|
|
28
|
-
const req = {
|
|
29
|
-
socket: { remoteAddress: '10.0.0.2' },
|
|
30
|
-
};
|
|
31
|
-
expect(ipRateLimitKeyGenerator(req)).toBe('ip:10.0.0.2');
|
|
32
|
-
});
|
|
33
|
-
test('uses unknown when neither ip nor remoteAddress is set', () => {
|
|
34
|
-
const req = {
|
|
35
|
-
socket: {},
|
|
36
|
-
};
|
|
37
|
-
expect(ipRateLimitKeyGenerator(req)).toBe('ip:unknown');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('rateLimitKeyGenerator', () => {
|
|
41
|
-
test('uses authenticated user id when available', () => {
|
|
42
|
-
const req = {
|
|
43
|
-
authContext: { userId: 'alice' },
|
|
44
|
-
ip: '203.0.113.10',
|
|
45
|
-
socket: { remoteAddress: '10.0.0.1' },
|
|
46
|
-
};
|
|
47
|
-
expect(rateLimitKeyGenerator(req)).toBe('user:alice');
|
|
48
|
-
});
|
|
49
|
-
test('falls back to request ip when user is not authenticated', () => {
|
|
50
|
-
const req = {
|
|
51
|
-
ip: '198.51.100.42',
|
|
52
|
-
socket: { remoteAddress: '10.0.0.1' },
|
|
53
|
-
};
|
|
54
|
-
expect(rateLimitKeyGenerator(req)).toBe('ip:198.51.100.42');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"securityHeaders.test.d.ts","sourceRoot":"","sources":["../../src/middleware/securityHeaders.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import { securityHeaders } from './securityHeaders.js';
|
|
5
|
-
describe('securityHeaders', () => {
|
|
6
|
-
it('sets the expected security response headers', () => {
|
|
7
|
-
const setHeader = vi.fn();
|
|
8
|
-
const next = vi.fn();
|
|
9
|
-
const middleware = securityHeaders();
|
|
10
|
-
const req = {};
|
|
11
|
-
const res = { setHeader };
|
|
12
|
-
middleware(req, res, next);
|
|
13
|
-
expect(setHeader).toHaveBeenCalledWith('X-Frame-Options', 'DENY');
|
|
14
|
-
expect(setHeader).toHaveBeenCalledWith('Content-Security-Policy', "frame-ancestors 'none';");
|
|
15
|
-
expect(setHeader).toHaveBeenCalledWith('X-Content-Type-Options', 'nosniff');
|
|
16
|
-
expect(next).toHaveBeenCalledOnce();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionHandler.test.d.ts","sourceRoot":"","sources":["../../src/middleware/sessionHandler.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import { pino } from 'pino';
|
|
5
|
-
import { sink } from 'pino-test';
|
|
6
|
-
import { sessionHandler } from './sessionHandler.js';
|
|
7
|
-
import { providerErrors } from '@canton-network/core-rpc-errors';
|
|
8
|
-
describe('sessionHandler', () => {
|
|
9
|
-
const getSession = vi.fn();
|
|
10
|
-
const getOnboardingSession = vi.fn();
|
|
11
|
-
const withAuthContext = vi.fn(() => ({ getSession }));
|
|
12
|
-
const store = {
|
|
13
|
-
withAuthContext,
|
|
14
|
-
getOnboardingSession,
|
|
15
|
-
};
|
|
16
|
-
const logger = pino({ level: 'silent' }, sink());
|
|
17
|
-
const allowedPaths = {
|
|
18
|
-
'/api/v0/user': ['addSession', 'listNetworks', 'getUser'],
|
|
19
|
-
'/api/v0/dapp': ['*'],
|
|
20
|
-
};
|
|
21
|
-
let next;
|
|
22
|
-
let status;
|
|
23
|
-
let json;
|
|
24
|
-
const authContext = {
|
|
25
|
-
userId: 'user-1',
|
|
26
|
-
accessToken: 'access-token',
|
|
27
|
-
};
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
getSession.mockReset();
|
|
30
|
-
getOnboardingSession.mockReset();
|
|
31
|
-
withAuthContext.mockClear();
|
|
32
|
-
withAuthContext.mockReturnValue({ getSession });
|
|
33
|
-
next = vi.fn();
|
|
34
|
-
status = vi.fn().mockReturnThis();
|
|
35
|
-
json = vi.fn();
|
|
36
|
-
});
|
|
37
|
-
function makeReq(partial) {
|
|
38
|
-
return {
|
|
39
|
-
method: 'POST',
|
|
40
|
-
baseUrl: '/api/v0/user',
|
|
41
|
-
body: { method: 'listWallets' },
|
|
42
|
-
authContext,
|
|
43
|
-
...partial,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function makeRes() {
|
|
47
|
-
return { status, json };
|
|
48
|
-
}
|
|
49
|
-
it('skips session check for non-POST requests', async () => {
|
|
50
|
-
const req = makeReq({ method: 'GET' });
|
|
51
|
-
const res = makeRes();
|
|
52
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
53
|
-
await middleware(req, res, next);
|
|
54
|
-
expect(withAuthContext).not.toHaveBeenCalled();
|
|
55
|
-
expect(next).toHaveBeenCalledOnce();
|
|
56
|
-
expect(status).not.toHaveBeenCalled();
|
|
57
|
-
});
|
|
58
|
-
it('allows unauthenticated POST when the RPC method is on the allow list', async () => {
|
|
59
|
-
const req = makeReq({ body: { method: 'addSession' } });
|
|
60
|
-
const res = makeRes();
|
|
61
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
62
|
-
await middleware(req, res, next);
|
|
63
|
-
expect(withAuthContext).not.toHaveBeenCalled();
|
|
64
|
-
expect(next).toHaveBeenCalledOnce();
|
|
65
|
-
expect(status).not.toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
it('allows unauthenticated POST when the path uses a wildcard allow list', async () => {
|
|
68
|
-
const req = makeReq({
|
|
69
|
-
baseUrl: '/api/v0/dapp',
|
|
70
|
-
body: { method: 'connect' },
|
|
71
|
-
});
|
|
72
|
-
const res = makeRes();
|
|
73
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
74
|
-
await middleware(req, res, next);
|
|
75
|
-
expect(withAuthContext).not.toHaveBeenCalled();
|
|
76
|
-
expect(next).toHaveBeenCalledOnce();
|
|
77
|
-
});
|
|
78
|
-
it('calls next when an active session exists for a protected method', async () => {
|
|
79
|
-
getSession.mockResolvedValue({
|
|
80
|
-
id: 'session-1',
|
|
81
|
-
network: 'network1',
|
|
82
|
-
accessToken: 'session-token',
|
|
83
|
-
});
|
|
84
|
-
const req = makeReq({ body: { method: 'listWallets' } });
|
|
85
|
-
const res = makeRes();
|
|
86
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
87
|
-
await middleware(req, res, next);
|
|
88
|
-
expect(withAuthContext).toHaveBeenCalledWith(authContext);
|
|
89
|
-
expect(getSession).toHaveBeenCalled();
|
|
90
|
-
expect(next).toHaveBeenCalledOnce();
|
|
91
|
-
expect(status).not.toHaveBeenCalled();
|
|
92
|
-
});
|
|
93
|
-
it('returns 401 when no session exists for a protected method', async () => {
|
|
94
|
-
getSession.mockResolvedValue(undefined);
|
|
95
|
-
const req = makeReq({ body: { method: 'listWallets' } });
|
|
96
|
-
const res = makeRes();
|
|
97
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
98
|
-
await middleware(req, res, next);
|
|
99
|
-
expect(withAuthContext).toHaveBeenCalledWith(authContext);
|
|
100
|
-
expect(next).not.toHaveBeenCalled();
|
|
101
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
102
|
-
expect(json).toHaveBeenCalledWith({
|
|
103
|
-
jsonrpc: '2.0',
|
|
104
|
-
id: null,
|
|
105
|
-
error: {
|
|
106
|
-
code: providerErrors.unauthorized().code,
|
|
107
|
-
message: 'No active session found',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
it('returns 401 without calling getSession when no access token is present', async () => {
|
|
112
|
-
const req = makeReq({
|
|
113
|
-
body: { method: 'listWallets' },
|
|
114
|
-
authContext: undefined,
|
|
115
|
-
});
|
|
116
|
-
const res = makeRes();
|
|
117
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
118
|
-
await middleware(req, res, next);
|
|
119
|
-
expect(getSession).not.toHaveBeenCalled();
|
|
120
|
-
expect(next).not.toHaveBeenCalled();
|
|
121
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
122
|
-
expect(json).toHaveBeenCalledWith({
|
|
123
|
-
jsonrpc: '2.0',
|
|
124
|
-
id: null,
|
|
125
|
-
error: {
|
|
126
|
-
code: providerErrors.unauthorized().code,
|
|
127
|
-
message: 'No active session found',
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
it('keeps the JSON-RPC request id in the 401 response', async () => {
|
|
132
|
-
getSession.mockResolvedValue(undefined);
|
|
133
|
-
const req = makeReq({ body: { method: 'listWallets', id: 42 } });
|
|
134
|
-
const res = makeRes();
|
|
135
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
136
|
-
await middleware(req, res, next);
|
|
137
|
-
expect(json).toHaveBeenCalledWith(expect.objectContaining({ id: 42 }));
|
|
138
|
-
});
|
|
139
|
-
it('requires a session when the path is not in the allow list config', async () => {
|
|
140
|
-
getSession.mockResolvedValue(undefined);
|
|
141
|
-
const req = makeReq({
|
|
142
|
-
baseUrl: '/api/v0/other',
|
|
143
|
-
body: { method: 'addSession' },
|
|
144
|
-
});
|
|
145
|
-
const res = makeRes();
|
|
146
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
147
|
-
await middleware(req, res, next);
|
|
148
|
-
expect(withAuthContext).toHaveBeenCalledWith(authContext);
|
|
149
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
150
|
-
});
|
|
151
|
-
describe('onboarding methods', () => {
|
|
152
|
-
const onboardingPaths = {
|
|
153
|
-
'/api/v0/user': ['createSelfIssuedWallet'],
|
|
154
|
-
};
|
|
155
|
-
it('sets a tokenless auth context from the onboarding session', async () => {
|
|
156
|
-
getOnboardingSession.mockResolvedValue({
|
|
157
|
-
id: 'onboarding-1',
|
|
158
|
-
network: 'network1',
|
|
159
|
-
origin: 'https://app.example',
|
|
160
|
-
userId: 'alice',
|
|
161
|
-
});
|
|
162
|
-
const req = makeReq({
|
|
163
|
-
authContext: undefined,
|
|
164
|
-
body: {
|
|
165
|
-
method: 'createSelfIssuedWallet',
|
|
166
|
-
params: { sessionId: 'onboarding-1' },
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
const middleware = sessionHandler(store, allowedPaths, logger, onboardingPaths);
|
|
170
|
-
await middleware(req, makeRes(), next);
|
|
171
|
-
expect(getOnboardingSession).toHaveBeenCalledWith('onboarding-1');
|
|
172
|
-
expect(req.authContext).toEqual({
|
|
173
|
-
userId: 'alice',
|
|
174
|
-
accessToken: '',
|
|
175
|
-
sessionId: 'onboarding-1',
|
|
176
|
-
});
|
|
177
|
-
expect(next).toHaveBeenCalledOnce();
|
|
178
|
-
expect(status).not.toHaveBeenCalled();
|
|
179
|
-
});
|
|
180
|
-
it.each([
|
|
181
|
-
['is missing', undefined],
|
|
182
|
-
['is unknown or already has a token', 'onboarding-1'],
|
|
183
|
-
])('returns 401 when the session id %s', async (_, sessionId) => {
|
|
184
|
-
getOnboardingSession.mockResolvedValue(undefined);
|
|
185
|
-
const req = makeReq({
|
|
186
|
-
authContext: undefined,
|
|
187
|
-
body: {
|
|
188
|
-
method: 'createSelfIssuedWallet',
|
|
189
|
-
params: sessionId ? { sessionId } : {},
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
const middleware = sessionHandler(store, allowedPaths, logger, onboardingPaths);
|
|
193
|
-
await middleware(req, makeRes(), next);
|
|
194
|
-
expect(next).not.toHaveBeenCalled();
|
|
195
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
196
|
-
expect(json).toHaveBeenCalledWith({
|
|
197
|
-
jsonrpc: '2.0',
|
|
198
|
-
id: null,
|
|
199
|
-
error: {
|
|
200
|
-
code: providerErrors.unauthorized().code,
|
|
201
|
-
message: 'No onboarding session found',
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
it('requires a session when the RPC method is not on the path allow list', async () => {
|
|
207
|
-
getSession.mockResolvedValue(undefined);
|
|
208
|
-
const req = makeReq({ body: { method: 'removeSession' } });
|
|
209
|
-
const res = makeRes();
|
|
210
|
-
const middleware = sessionHandler(store, allowedPaths, logger);
|
|
211
|
-
await middleware(req, res, next);
|
|
212
|
-
expect(withAuthContext).toHaveBeenCalledWith(authContext);
|
|
213
|
-
expect(status).toHaveBeenCalledWith(401);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-account-session.test.d.ts","sourceRoot":"","sources":["../../src/signing/service-account-session.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
vi.mock('uuid', () => ({ v4: vi.fn(() => 'session-new') }));
|
|
5
|
-
import { pino } from 'pino';
|
|
6
|
-
import { sink } from 'pino-test';
|
|
7
|
-
import { resolveAutomationRunContext } from './service-account-session.js';
|
|
8
|
-
vi.mock('@canton-network/core-wallet-auth', async () => {
|
|
9
|
-
const actual = await vi.importActual('@canton-network/core-wallet-auth');
|
|
10
|
-
return {
|
|
11
|
-
...actual,
|
|
12
|
-
AuthTokenProvider: {
|
|
13
|
-
fromGatewayConfig: vi.fn().mockReturnValue({
|
|
14
|
-
getAuthContext: vi.fn().mockResolvedValue({
|
|
15
|
-
userId: 'service_account',
|
|
16
|
-
accessToken: 'abc',
|
|
17
|
-
}),
|
|
18
|
-
}),
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
const idp = {
|
|
23
|
-
id: 'idp1',
|
|
24
|
-
type: 'oauth',
|
|
25
|
-
issuer: 'https://issuer.example',
|
|
26
|
-
configUrl: 'https://issuer.example/.well-known/openid-configuration',
|
|
27
|
-
};
|
|
28
|
-
const m2mNetwork = {
|
|
29
|
-
id: 'net-m2m',
|
|
30
|
-
name: 'm2m',
|
|
31
|
-
description: '',
|
|
32
|
-
synchronizerId: 'sync::fp',
|
|
33
|
-
identityProviderId: 'idp1',
|
|
34
|
-
ledgerApi: { baseUrl: 'http://ledger' },
|
|
35
|
-
auth: {
|
|
36
|
-
method: 'authorization_code',
|
|
37
|
-
clientId: 'svc',
|
|
38
|
-
audience: 'aud',
|
|
39
|
-
scope: 'scope',
|
|
40
|
-
},
|
|
41
|
-
serviceAccountAuth: {
|
|
42
|
-
method: 'client_credentials',
|
|
43
|
-
clientId: 'svc',
|
|
44
|
-
clientSecret: 'secret',
|
|
45
|
-
audience: 'aud',
|
|
46
|
-
scope: 'scope',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
const logger = pino({ level: 'silent' }, sink());
|
|
50
|
-
describe('resolveAutomationRunContext', () => {
|
|
51
|
-
it('reuses a valid client-credentials session', async () => {
|
|
52
|
-
const session = {
|
|
53
|
-
id: 'session-1',
|
|
54
|
-
network: 'net-m2m',
|
|
55
|
-
accessToken: 'abc',
|
|
56
|
-
};
|
|
57
|
-
const scopedStore = { setSession: vi.fn() };
|
|
58
|
-
const store = {
|
|
59
|
-
getIdp: vi.fn().mockResolvedValue(idp),
|
|
60
|
-
getNetwork: vi.fn().mockResolvedValue(m2mNetwork),
|
|
61
|
-
withAuthContext: vi.fn().mockReturnValue(scopedStore),
|
|
62
|
-
};
|
|
63
|
-
const result = await resolveAutomationRunContext(store, 'service_account', 'net-m2m', logger);
|
|
64
|
-
expect(result?.authContext).toEqual({
|
|
65
|
-
userId: 'service_account',
|
|
66
|
-
accessToken: session.accessToken,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it('mints a token when no usable session exists', async () => {
|
|
70
|
-
const scopedStore = { setSession: vi.fn() };
|
|
71
|
-
const store = {
|
|
72
|
-
getIdp: vi.fn().mockResolvedValue(idp),
|
|
73
|
-
getNetwork: vi.fn().mockResolvedValue(m2mNetwork),
|
|
74
|
-
withAuthContext: vi.fn().mockReturnValue(scopedStore),
|
|
75
|
-
};
|
|
76
|
-
const result = await resolveAutomationRunContext(store, 'service_account', 'net-m2m', logger);
|
|
77
|
-
expect(result?.authContext.userId).toBe('service_account');
|
|
78
|
-
});
|
|
79
|
-
it('mints when the stored session is not a client-credentials token', async () => {
|
|
80
|
-
const scopedStore = { setSession: vi.fn() };
|
|
81
|
-
const store = {
|
|
82
|
-
getIdp: vi.fn().mockResolvedValue(idp),
|
|
83
|
-
getNetwork: vi.fn().mockResolvedValue(m2mNetwork),
|
|
84
|
-
withAuthContext: vi.fn().mockReturnValue(scopedStore),
|
|
85
|
-
};
|
|
86
|
-
await resolveAutomationRunContext(store, 'service_account', 'net-m2m', logger);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { Logger } from 'pino';
|
|
2
|
-
import type { AuthAware } from '@canton-network/core-wallet-auth';
|
|
3
|
-
import type { Store } from '@canton-network/core-wallet-store';
|
|
4
|
-
import { type HASHING_SCHEME_VERSION, type NotificationService, type SigningDrivers } from '@canton-network/core-wallet-services';
|
|
5
|
-
export type { AccessTokenProviderFactory } from './service-account-session.js';
|
|
6
|
-
/** Configuration for {@link SigningWorker}. */
|
|
7
|
-
export interface SigningWorkerOptions {
|
|
8
|
-
/** Poll interval in ms (`server.signingWorker.pollInterval`, default 5000). */
|
|
9
|
-
intervalMs: number;
|
|
10
|
-
signingDrivers: SigningDrivers;
|
|
11
|
-
store: Store & AuthAware<Store>;
|
|
12
|
-
notificationService: NotificationService;
|
|
13
|
-
logger: Logger;
|
|
14
|
-
hashingSchemeVersion: HASHING_SCHEME_VERSION;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Background poller that completes service-account transactions stuck in external
|
|
18
|
-
* custody approval.
|
|
19
|
-
*
|
|
20
|
-
* ## When this runs
|
|
21
|
-
*
|
|
22
|
-
* During M2M automation (`prepareExecute` → `signAndExecute`), external signing
|
|
23
|
-
* providers (Fireblocks, Blockdaemon, Dfns) may return `pending` instead of a
|
|
24
|
-
* signature. The gateway persists the transaction with `status: 'pending'` and `status: 'awaiting-signature'` and
|
|
25
|
-
* an `externalTxId` from the provider. This worker picks up those rows on each
|
|
26
|
-
* tick via {@link Store.listAllPendingTransactions} (rows with an
|
|
27
|
-
* `externalTxId` are processed; others are skipped).
|
|
28
|
-
*
|
|
29
|
-
* Participant and wallet-kernel sign synchronously and never appear here.
|
|
30
|
-
*
|
|
31
|
-
* ## What happens on each tick
|
|
32
|
-
*
|
|
33
|
-
* For every pending row the worker resolves an M2M auth context
|
|
34
|
-
* ({@link resolveAutomationRunContext}), loads the user's primary wallet, and
|
|
35
|
-
* calls {@link TransactionService.signAndExecute}.
|
|
36
|
-
*
|
|
37
|
-
* Although the worker always invokes `signAndExecute`, **retries do not submit a
|
|
38
|
-
* new sign request**. `signAndExecute`branches on the stored transaction's status
|
|
39
|
-
*
|
|
40
|
-
* - **First pass** ( `pending`, no `externalTxId`): calls `sign()` which submits to singing provider
|
|
41
|
-
* via `driver.signTransaction()` and stores the returned `externalTxId` with status `awaiting-signature`
|
|
42
|
-
* - **Subsequent ticks** (`awaiting-signature` with `externalTxId` present): `refreshTransaction()`
|
|
43
|
-
* which polls the existing requst via `driver.getTransaction()` and updated the stored status
|
|
44
|
-
*
|
|
45
|
-
* `sign()` initiates only and will throw for a transaction that already has an `externalTxId`
|
|
46
|
-
*
|
|
47
|
-
* `signAndExecute` then:
|
|
48
|
-
*
|
|
49
|
-
* - returns `{status: pending}` while provider still reports the request as awaiting approval
|
|
50
|
-
* (worker logs and waits for the next tick), or
|
|
51
|
-
* - calls `execute()` once provider reports `signed`. The signature is re-fetched from provider at
|
|
52
|
-
* execution time rather than carried from the signing step.
|
|
53
|
-
*
|
|
54
|
-
* A transaction is re-read before processing so a concurrent DApp call or an
|
|
55
|
-
* earlier tick that already completed it is skipped.
|
|
56
|
-
*
|
|
57
|
-
* Rows that reach `failed` (rejected by provider or by the ledger) are not retried and `failureReason` records why
|
|
58
|
-
*
|
|
59
|
-
* ## Lifecycle
|
|
60
|
-
*
|
|
61
|
-
* Started once at gateway init (`start()`). Ticks are serialized: if a tick is
|
|
62
|
-
* still running, the next interval callback is a no-op. Use `stop()` on shutdown.
|
|
63
|
-
*/
|
|
64
|
-
export declare class SigningWorker {
|
|
65
|
-
private readonly options;
|
|
66
|
-
private timer;
|
|
67
|
-
private running;
|
|
68
|
-
constructor(options: SigningWorkerOptions);
|
|
69
|
-
/** Starts the interval timer. Idempotent if already started. */
|
|
70
|
-
start(): void;
|
|
71
|
-
/** Clears the interval timer. */
|
|
72
|
-
stop(): void;
|
|
73
|
-
/**
|
|
74
|
-
* One poll cycle: list all pending transactions and attempt to complete
|
|
75
|
-
* external-custody rows via {@link processPending}. Safe to call directly in
|
|
76
|
-
* tests.
|
|
77
|
-
*/
|
|
78
|
-
tick(): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Drives a single pending transaction through `signAndExecute`. Skips when
|
|
81
|
-
* automation context, submitting wallet, or refreshed `pending` status is missing.
|
|
82
|
-
* Errors are logged per transaction; other rows in the same tick still run.
|
|
83
|
-
*/
|
|
84
|
-
private processPending;
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=signing-worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signing-worker.d.ts","sourceRoot":"","sources":["../../src/signing/signing-worker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EACR,KAAK,EAGR,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACtB,MAAM,sCAAsC,CAAA;AAE7C,YAAY,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAE9E,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACjC,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,cAAc,CAAA;IAC9B,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC/B,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,oBAAoB,EAAE,sBAAsB,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,aAAa;IAIV,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO,CAAC,OAAO,CAAQ;gBAEM,OAAO,EAAE,oBAAoB;IAE1D,gEAAgE;IAChE,KAAK,IAAI,IAAI;IAcb,iCAAiC;IACjC,IAAI,IAAI,IAAI;IAOZ;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B3B;;;;OAIG;YACW,cAAc;CA0I/B"}
|