@canton-network/wallet-gateway-remote 1.6.0 → 1.7.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 +9 -2
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +27 -12
- package/dist/dapp-api/controller.test.js +23 -6
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/server.js +24 -12
- package/dist/env.d.ts +1 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +4 -1
- package/dist/ledger/transaction-service.d.ts +0 -12
- package/dist/ledger/transaction-service.d.ts.map +1 -1
- package/dist/ledger/transaction-service.js +28 -46
- package/dist/ledger/transaction-service.test.js +70 -26
- package/dist/ledger/wallet-sync-service.test.js +2 -1
- package/dist/middleware/apiKeyAuth.d.ts.map +1 -1
- package/dist/middleware/apiKeyAuth.js +12 -3
- package/dist/middleware/securityHeaders.d.ts +3 -0
- package/dist/middleware/securityHeaders.d.ts.map +1 -0
- package/dist/middleware/securityHeaders.js +10 -0
- package/dist/middleware/securityHeaders.test.d.ts +2 -0
- package/dist/middleware/securityHeaders.test.d.ts.map +1 -0
- package/dist/middleware/securityHeaders.test.js +18 -0
- package/dist/middleware/sessionHandler.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.js +3 -1
- package/dist/signing/signing-worker.d.ts +1 -2
- package/dist/signing/signing-worker.d.ts.map +1 -1
- package/dist/signing/signing-worker.js +7 -3
- package/dist/signing/signing-worker.test.js +2 -0
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +90 -41
- package/dist/user-api/controller.test.js +191 -18
- package/dist/user-api/rpc-gen/typings.d.ts +46 -7
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/user-api/token-network-matching.d.ts +4 -0
- package/dist/user-api/token-network-matching.d.ts.map +1 -0
- package/dist/user-api/token-network-matching.js +56 -0
- package/dist/web/frontend/404/index.html +2 -2
- package/dist/web/frontend/activities/index.html +3 -4
- package/dist/web/frontend/approve/index.html +3 -5
- package/dist/web/frontend/assets/404-C0zn3s5P.js +5 -0
- package/dist/web/frontend/assets/activities-BuOktGvz.js +61 -0
- package/dist/web/frontend/assets/addIdentityProvider-D91uvfNz.js +28 -0
- package/dist/web/frontend/assets/addNetwork-DP0iR59C.js +38 -0
- package/dist/web/frontend/assets/addParty-DUoPRmUF.js +45 -0
- package/dist/web/frontend/assets/approve-BSMrd3FM.js +21 -0
- package/dist/web/frontend/assets/callback-oLJBpxTj.js +3 -0
- package/dist/web/frontend/assets/identityProviders-DQlERLUf.js +71 -0
- package/dist/web/frontend/assets/index-BjhQnXf1.js +2 -0
- package/dist/web/frontend/assets/{index-CFnOucPK.js → index-BoxNLwXf.js} +629 -570
- package/dist/web/frontend/assets/index-D5Xh-WxM.js +91 -0
- package/dist/web/frontend/assets/login-GZTP8nvF.js +10 -0
- package/dist/web/frontend/assets/networks-DHe8V-HP.js +73 -0
- package/dist/web/frontend/assets/reviewIdentityProvider-tg2atORE.js +43 -0
- package/dist/web/frontend/assets/reviewNetwork-ZZv-rrzm.js +43 -0
- package/dist/web/frontend/assets/settings-BC6X9ar3.js +37 -0
- package/dist/web/frontend/callback/index.html +2 -2
- package/dist/web/frontend/identity-providers/add/index.html +2 -3
- package/dist/web/frontend/identity-providers/index.html +2 -3
- package/dist/web/frontend/identity-providers/review/index.html +2 -3
- package/dist/web/frontend/index.html +1 -1
- package/dist/web/frontend/login/index.html +2 -3
- package/dist/web/frontend/networks/add/index.html +2 -3
- package/dist/web/frontend/networks/index.html +2 -3
- package/dist/web/frontend/networks/review/index.html +2 -3
- package/dist/web/frontend/parties/add/index.html +3 -5
- package/dist/web/frontend/parties/index.html +2 -4
- package/dist/web/frontend/settings/index.html +2 -3
- package/dist/web/server.d.ts +1 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +3 -3
- package/package.json +29 -29
- package/dist/web/frontend/assets/404-C4hCL2o8.js +0 -5
- package/dist/web/frontend/assets/activities-Bq7yMMQY.js +0 -61
- package/dist/web/frontend/assets/addIdentityProvider-DRJWLhHF.js +0 -28
- package/dist/web/frontend/assets/addNetwork-CJUaKP1q.js +0 -38
- package/dist/web/frontend/assets/addParty-2ObTLGIL.js +0 -45
- package/dist/web/frontend/assets/approve-BuA5DGC2.js +0 -21
- package/dist/web/frontend/assets/callback-C5vJWFLq.js +0 -1
- package/dist/web/frontend/assets/identityProviders-78FbpzYL.js +0 -71
- package/dist/web/frontend/assets/index-BTH_md6b.js +0 -91
- package/dist/web/frontend/assets/index-CiMGhYb1.js +0 -2
- package/dist/web/frontend/assets/login-Dyn1o6fW.js +0 -10
- package/dist/web/frontend/assets/networks-_el10AWP.js +0 -73
- package/dist/web/frontend/assets/reviewIdentityProvider-DodUZ2mY.js +0 -43
- package/dist/web/frontend/assets/reviewNetwork-BFMtmKEL.js +0 -43
- package/dist/web/frontend/assets/settings-BBmkIfYm.js +0 -37
- package/dist/web/frontend/assets/state-DkxLvywv.js +0 -1
- package/dist/web/frontend/assets/utils-DvJKIYxT.js +0 -1
package/README.md
CHANGED
|
@@ -55,14 +55,21 @@ The JSON-RPC API specs from `api-specs/` are generated into strongly-typed metho
|
|
|
55
55
|
- `DFNS_PRIVATE_KEY` — service account private key (PEM)
|
|
56
56
|
- `DFNS_AUTH_TOKEN` — service account auth token
|
|
57
57
|
|
|
58
|
-
Dfns provisions and activates Canton wallets through its validator integration, so no additional Gateway configuration is required. Only `Canton` and `CantonTestnet` network wallets are supported. See [`@canton-network/core-signing-dfns`](../../core/signing-dfns/README.md) for full driver details.
|
|
59
|
-
|
|
60
58
|
## Fireblocks
|
|
61
59
|
|
|
62
60
|
1. Complete steps 1–3 from the instructions at https://github.com/canton-network/wallet/tree/main/core/signing-fireblocks
|
|
63
61
|
|
|
64
62
|
2. set the environment variable `FIREBLOCKS_API_KEY` (get it from `API User (ID)` column in fireblocks api users table).
|
|
65
63
|
|
|
64
|
+
# Blockdaemon
|
|
65
|
+
|
|
66
|
+
1. Create a system user in the Blockdaemon dashboard and save the API key displayed after successful creation.
|
|
67
|
+
|
|
68
|
+
2. set the environment variables
|
|
69
|
+
|
|
70
|
+
- `BLOCKDAEMON_API_URL` - The base URL for the Blockdaemon API
|
|
71
|
+
- `BLOCKDAEMON_API_KEY` - Your Blockdaemon API key
|
|
72
|
+
|
|
66
73
|
## Postgres connection
|
|
67
74
|
|
|
68
75
|
To create a Postgres database you need to:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAczC,OAAO,EAAE,KAAK,EAAe,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAczC,OAAO,EAAE,KAAK,EAAe,MAAM,mCAAmC,CAAA;AAUtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAK7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAG9D,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,cAAc,CAAA;CACjC;AAED,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,QAAQ,MAAM,GAAG,IAAI,EACrB,MAAM,kBAAkB,EACxB,UAAU,WAAW;;;;;;;;;;;;;;;;CAiexB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { assertConnected, AuthTokenProvider, } from '@canton-network/core-wallet-auth';
|
|
4
4
|
import buildController from './rpc-gen/index.js';
|
|
5
|
-
import { LedgerClient, } from '@canton-network/core-ledger-client';
|
|
5
|
+
import { LedgerClient, isValidGetEndpoint, isValidPostEndpoint, } from '@canton-network/core-ledger-client';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
import { networkStatus, ledgerPrepareParams, logDynamically } from '../utils.js';
|
|
8
8
|
import { TransactionService } from '../ledger/transaction-service.js';
|
|
@@ -18,7 +18,8 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
18
18
|
}
|
|
19
19
|
return buildController({
|
|
20
20
|
connect: async () => {
|
|
21
|
-
|
|
21
|
+
const session = context && (await store.getSession(context.accessToken));
|
|
22
|
+
if (!context || !session) {
|
|
22
23
|
return {
|
|
23
24
|
isConnected: false,
|
|
24
25
|
isNetworkConnected: false,
|
|
@@ -26,7 +27,6 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
26
27
|
userUrl: `${userUrl}/login/`,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
// const session = await store.getSession()
|
|
30
30
|
const network = await store.getCurrentNetwork();
|
|
31
31
|
const ledgerClient = new LedgerClient({
|
|
32
32
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
@@ -34,7 +34,7 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
34
34
|
accessTokenProvider: AuthTokenProvider.fromToken(context.accessToken, logger),
|
|
35
35
|
});
|
|
36
36
|
const status = await networkStatus(ledgerClient);
|
|
37
|
-
const notifier = notificationService.getNotifier(
|
|
37
|
+
const notifier = notificationService.getNotifier(session.id);
|
|
38
38
|
const provider = {
|
|
39
39
|
id: kernelInfo.id,
|
|
40
40
|
version: 'TODO',
|
|
@@ -67,12 +67,15 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
67
67
|
return connection;
|
|
68
68
|
},
|
|
69
69
|
disconnect: async () => {
|
|
70
|
-
if (!context)
|
|
70
|
+
if (!context)
|
|
71
|
+
return null;
|
|
72
|
+
const session = await store.getSession(context.accessToken);
|
|
73
|
+
if (!session?.id) {
|
|
71
74
|
return null;
|
|
72
75
|
}
|
|
73
76
|
else {
|
|
74
|
-
const notifier = notificationService.getNotifier(
|
|
75
|
-
await store.removeSession();
|
|
77
|
+
const notifier = notificationService.getNotifier(session.id);
|
|
78
|
+
await store.removeSession(context.accessToken);
|
|
76
79
|
notifier.emit('statusChanged', {
|
|
77
80
|
provider: {
|
|
78
81
|
id: kernelInfo.id,
|
|
@@ -91,7 +94,7 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
91
94
|
return null;
|
|
92
95
|
},
|
|
93
96
|
isConnected: async () => {
|
|
94
|
-
if (!context || !(await store.getSession())) {
|
|
97
|
+
if (!context || !(await store.getSession(context.accessToken))) {
|
|
95
98
|
return {
|
|
96
99
|
isConnected: false,
|
|
97
100
|
isNetworkConnected: false,
|
|
@@ -124,9 +127,15 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
124
127
|
let result;
|
|
125
128
|
switch (params.requestMethod) {
|
|
126
129
|
case 'get':
|
|
130
|
+
if (!isValidGetEndpoint(params.resource)) {
|
|
131
|
+
throw new Error(`Unsupported get resource: ${params.resource}`);
|
|
132
|
+
}
|
|
127
133
|
result = await ledgerClient.getWithRetry(params.resource, undefined, { path: params.path ?? {}, query: params.query ?? {} });
|
|
128
134
|
break;
|
|
129
135
|
case 'post':
|
|
136
|
+
if (!isValidPostEndpoint(params.resource)) {
|
|
137
|
+
throw new Error(`Unsupported post resource: ${params.resource}`);
|
|
138
|
+
}
|
|
130
139
|
result = await ledgerClient.postWithRetry(params.resource, params.body, undefined, { query: params.query ?? {}, path: params.path ?? {} });
|
|
131
140
|
break;
|
|
132
141
|
default:
|
|
@@ -168,7 +177,11 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
168
177
|
logger,
|
|
169
178
|
accessTokenProvider,
|
|
170
179
|
});
|
|
171
|
-
const
|
|
180
|
+
const session = await store.getSession(context.accessToken);
|
|
181
|
+
if (!session) {
|
|
182
|
+
throw new Error('No active session found');
|
|
183
|
+
}
|
|
184
|
+
const notifier = notificationService.getNotifier(session.id);
|
|
172
185
|
const commandId = params.commandId || v4();
|
|
173
186
|
const transactionId = v4();
|
|
174
187
|
notifier.emit('txChanged', { status: 'pending', commandId });
|
|
@@ -255,7 +268,7 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
255
268
|
url: dappUrl,
|
|
256
269
|
userUrl: `${userUrl}/login/`,
|
|
257
270
|
};
|
|
258
|
-
if (!context || !(await store.getSession())) {
|
|
271
|
+
if (!context || !(await store.getSession(context.accessToken))) {
|
|
259
272
|
return {
|
|
260
273
|
provider: provider,
|
|
261
274
|
connection: {
|
|
@@ -266,7 +279,7 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
266
279
|
},
|
|
267
280
|
};
|
|
268
281
|
}
|
|
269
|
-
const session = await store.getSession();
|
|
282
|
+
const session = await store.getSession(context.accessToken);
|
|
270
283
|
const network = await store.getCurrentNetwork();
|
|
271
284
|
const ledgerClient = new LedgerClient({
|
|
272
285
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
@@ -318,7 +331,9 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
318
331
|
if (wallet === undefined) {
|
|
319
332
|
throw new Error('No primary wallet found');
|
|
320
333
|
}
|
|
321
|
-
const
|
|
334
|
+
const session = await store.getSession(context.accessToken);
|
|
335
|
+
const sessionId = session.id;
|
|
336
|
+
const notifier = notificationService.getNotifier(sessionId);
|
|
322
337
|
const messageId = v4();
|
|
323
338
|
await store.setMessageRaw({
|
|
324
339
|
id: messageId,
|
|
@@ -82,8 +82,9 @@ const auth = {
|
|
|
82
82
|
};
|
|
83
83
|
const session = {
|
|
84
84
|
id: 'session-1',
|
|
85
|
+
origin: 'dapp-1',
|
|
85
86
|
network: 'network1',
|
|
86
|
-
accessToken: '
|
|
87
|
+
accessToken: 'access-token-1',
|
|
87
88
|
};
|
|
88
89
|
const primaryWallet = {
|
|
89
90
|
primary: true,
|
|
@@ -158,7 +159,7 @@ describe('dappController', () => {
|
|
|
158
159
|
});
|
|
159
160
|
it('connects and emits statusChanged and connected', async () => {
|
|
160
161
|
const store = await createStore(logger, auth);
|
|
161
|
-
const notifier = notificationService.getNotifier(
|
|
162
|
+
const notifier = notificationService.getNotifier('session-1');
|
|
162
163
|
const emitSpy = vi.spyOn(notifier, 'emit');
|
|
163
164
|
const controller = createController(store, notificationService, logger, auth);
|
|
164
165
|
const result = await controller.connect();
|
|
@@ -208,11 +209,11 @@ describe('dappController', () => {
|
|
|
208
209
|
});
|
|
209
210
|
it('removes the session and emits statusChanged', async () => {
|
|
210
211
|
const store = await createStore(logger, auth);
|
|
211
|
-
const notifier = notificationService.getNotifier(
|
|
212
|
+
const notifier = notificationService.getNotifier('session-1');
|
|
212
213
|
const emitSpy = vi.spyOn(notifier, 'emit');
|
|
213
214
|
const controller = createController(store, notificationService, logger, auth);
|
|
214
215
|
await controller.disconnect();
|
|
215
|
-
await expect(store.
|
|
216
|
+
await expect(store.listSessions()).resolves.toHaveLength(0);
|
|
216
217
|
expect(emitSpy).toHaveBeenCalledWith('statusChanged', expect.objectContaining({
|
|
217
218
|
connection: expect.objectContaining({
|
|
218
219
|
isConnected: false,
|
|
@@ -331,6 +332,22 @@ describe('dappController', () => {
|
|
|
331
332
|
resource: '/v2/parties',
|
|
332
333
|
})).rejects.toThrow();
|
|
333
334
|
});
|
|
335
|
+
it('throws an error if an incorrect get endpoint is supplied', async () => {
|
|
336
|
+
const store = await createStore(logger, auth);
|
|
337
|
+
const controller = createController(store, notificationService, logger, auth);
|
|
338
|
+
await expect(controller.ledgerApi({
|
|
339
|
+
requestMethod: 'get',
|
|
340
|
+
resource: '/v2/badresource',
|
|
341
|
+
})).rejects.toThrow(`Unsupported get resource: /v2/badresource`);
|
|
342
|
+
});
|
|
343
|
+
it('throws an error if an incorrect post endpoint is supplied', async () => {
|
|
344
|
+
const store = await createStore(logger, auth);
|
|
345
|
+
const controller = createController(store, notificationService, logger, auth);
|
|
346
|
+
await expect(controller.ledgerApi({
|
|
347
|
+
requestMethod: 'post',
|
|
348
|
+
resource: '/v2/state/ledger-end',
|
|
349
|
+
})).rejects.toThrow(`Unsupported post resource: /v2/state/ledger-end`);
|
|
350
|
+
});
|
|
334
351
|
});
|
|
335
352
|
describe('prepareExecute', () => {
|
|
336
353
|
const prepareParams = {
|
|
@@ -362,7 +379,7 @@ describe('dappController', () => {
|
|
|
362
379
|
});
|
|
363
380
|
const store = await createStore(logger, auth);
|
|
364
381
|
const setTransactionSpy = vi.spyOn(store, 'setTransaction');
|
|
365
|
-
const notifier = notificationService.getNotifier(
|
|
382
|
+
const notifier = notificationService.getNotifier('session-1');
|
|
366
383
|
const emitSpy = vi.spyOn(notifier, 'emit');
|
|
367
384
|
const controller = createController(store, notificationService, logger, auth);
|
|
368
385
|
const result = await controller.prepareExecute(prepareParams);
|
|
@@ -437,7 +454,7 @@ describe('dappController', () => {
|
|
|
437
454
|
mockUuidV4.mockReturnValueOnce('message-id');
|
|
438
455
|
const store = await createStore(logger, auth);
|
|
439
456
|
const setMessageSpy = vi.spyOn(store, 'setMessageRaw');
|
|
440
|
-
const notifier = notificationService.getNotifier(
|
|
457
|
+
const notifier = notificationService.getNotifier('session-1');
|
|
441
458
|
const emitSpy = vi.spyOn(notifier, 'emit');
|
|
442
459
|
const controller = createController(store, notificationService, logger, auth);
|
|
443
460
|
const result = await controller.signMessage({ message: 'hello' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dapp-api/server.ts"],"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KAAK,OAAO,CAAC,OAAO,EACpB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,YAAY,UAAU,EACtB,SAAS,MAAM,EACf,SAAS,MAAM,EACf,cAAc,YAAY,EAC1B,qBAAqB,mBAAmB,EACxC,OAAO,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,EAC/B,gBAAgB,kBAAkB,kGAiHrC,CAAA"}
|
package/dist/dapp-api/server.js
CHANGED
|
@@ -19,7 +19,7 @@ export const dapp = (route, app, logger, server, kernelInfo, dappUrl, userUrl, s
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const newStore = store.withAuthContext(context);
|
|
22
|
-
const session = await newStore.getSession();
|
|
22
|
+
const session = await newStore.getSession(context.accessToken);
|
|
23
23
|
const sessionId = session?.id;
|
|
24
24
|
if (!sessionId) {
|
|
25
25
|
res.status(401).json({ error: 'No session' });
|
|
@@ -31,7 +31,12 @@ export const dapp = (route, app, logger, server, kernelInfo, dappUrl, userUrl, s
|
|
|
31
31
|
res.setHeader('Connection', 'keep-alive');
|
|
32
32
|
res.setHeader('X-Accel-Buffering', 'no');
|
|
33
33
|
res.flushHeaders?.();
|
|
34
|
-
|
|
34
|
+
// Events scoped to the user (e.g. wallet/account changes) are broadcast
|
|
35
|
+
// across all of that user's sessions; events scoped to a session (e.g.
|
|
36
|
+
// transaction progress, connection status) are delivered only to the
|
|
37
|
+
// session that originated them.
|
|
38
|
+
const sessionNotifier = notificationService.getNotifier(sessionId);
|
|
39
|
+
const userNotifier = notificationService.getNotifier(context.userId);
|
|
35
40
|
const onAccountsChanged = (...event) => {
|
|
36
41
|
writeSSE(res, 'accountsChanged', event);
|
|
37
42
|
};
|
|
@@ -48,18 +53,25 @@ export const dapp = (route, app, logger, server, kernelInfo, dappUrl, userUrl, s
|
|
|
48
53
|
const onMessageSignature = (...event) => {
|
|
49
54
|
writeSSE(res, 'messageSignature', event);
|
|
50
55
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
const onLogout = () => {
|
|
57
|
+
logger.info({ userId: context.userId }, 'Session terinated by server. Forcing SSE teardown.');
|
|
58
|
+
cleanup();
|
|
59
|
+
res.end();
|
|
60
|
+
};
|
|
61
|
+
userNotifier.on('accountsChanged', onAccountsChanged);
|
|
62
|
+
sessionNotifier.on('connected', onConnected);
|
|
63
|
+
sessionNotifier.on('statusChanged', onStatusChanged);
|
|
64
|
+
sessionNotifier.on('txChanged', onTxChanged);
|
|
65
|
+
sessionNotifier.on('messageSignature', onMessageSignature);
|
|
66
|
+
sessionNotifier.on('logout', onLogout);
|
|
56
67
|
const cleanup = () => {
|
|
57
68
|
logger.debug('SSE client disconnected');
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
userNotifier.removeListener('accountsChanged', onAccountsChanged);
|
|
70
|
+
sessionNotifier.removeListener('connected', onConnected);
|
|
71
|
+
sessionNotifier.removeListener('statusChanged', onStatusChanged);
|
|
72
|
+
sessionNotifier.removeListener('txChanged', onTxChanged);
|
|
73
|
+
sessionNotifier.removeListener('messageSignature', onMessageSignature);
|
|
74
|
+
sessionNotifier.removeListener('logout', onLogout);
|
|
63
75
|
};
|
|
64
76
|
req.on('close', cleanup);
|
|
65
77
|
req.on('error', cleanup);
|
package/dist/env.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare class Env {
|
|
2
2
|
static FIREBLOCKS_API_KEY: () => string | undefined;
|
|
3
3
|
static FIREBLOCKS_SECRET: () => string | undefined;
|
|
4
|
+
static FIREBLOCKS_API_PATH: (fallback: string) => string;
|
|
4
5
|
static BLOCKDAEMON_API_URL: (fallback: string) => string;
|
|
5
6
|
static BLOCKDAEMON_API_KEY: (fallback: string) => string;
|
|
6
7
|
static BLOCKDAEMON_CAIP2: (fallback: string) => string;
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IACZ,MAAM,CAAC,kBAAkB,2BAAsC;IAC/D,MAAM,CAAC,iBAAiB,2BAAqC;IAC7D,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,iBAAiB,GAAI,UAAU,MAAM,YACE;IAC9C,MAAM,CAAC,WAAW,2BAA+B;IACjD,MAAM,CAAC,aAAa,GAAI,UAAU,MAAM,YACE;IAC1C,MAAM,CAAC,YAAY,2BAAgC;IACnD,MAAM,CAAC,gBAAgB,2BAAoC;IAC3D,MAAM,CAAC,eAAe,2BAAmC;IAEzD,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClD,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAChE,MAAM,GAAG,SAAS;CAcxB"}
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IACZ,MAAM,CAAC,kBAAkB,2BAAsC;IAC/D,MAAM,CAAC,iBAAiB,2BAAqC;IAC7D,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,iBAAiB,GAAI,UAAU,MAAM,YACE;IAC9C,MAAM,CAAC,WAAW,2BAA+B;IACjD,MAAM,CAAC,aAAa,GAAI,UAAU,MAAM,YACE;IAC1C,MAAM,CAAC,YAAY,2BAAgC;IACnD,MAAM,CAAC,gBAAgB,2BAAoC;IAC3D,MAAM,CAAC,eAAe,2BAAmC;IAEzD,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClD,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAChE,MAAM,GAAG,SAAS;CAcxB"}
|
package/dist/env.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export class Env {
|
|
4
4
|
static { this.FIREBLOCKS_API_KEY = () => Env.get('FIREBLOCKS_API_KEY'); }
|
|
5
5
|
static { this.FIREBLOCKS_SECRET = () => Env.get('FIREBLOCKS_SECRET'); }
|
|
6
|
+
static { this.FIREBLOCKS_API_PATH = (fallback) => Env.get('FIREBLOCKS_API_PATH', { fallback }); }
|
|
6
7
|
static { this.BLOCKDAEMON_API_URL = (fallback) => Env.get('BLOCKDAEMON_API_URL', { fallback }); }
|
|
7
8
|
static { this.BLOCKDAEMON_API_KEY = (fallback) => Env.get('BLOCKDAEMON_API_KEY', { fallback }); }
|
|
8
9
|
static { this.BLOCKDAEMON_CAIP2 = (fallback) => Env.get('BLOCKDAEMON_CAIP2', { fallback }); }
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAyB7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAyB7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA0MvC,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAqLhE"}
|
package/dist/init.js
CHANGED
|
@@ -25,6 +25,7 @@ import { sql } from 'kysely';
|
|
|
25
25
|
import { Env } from './env.js';
|
|
26
26
|
import { SigningWorker } from './signing/signing-worker.js';
|
|
27
27
|
import { apiKeyAuth } from './middleware/apiKeyAuth.js';
|
|
28
|
+
import { securityHeaders } from './middleware/securityHeaders.js';
|
|
28
29
|
let isReady = false;
|
|
29
30
|
let signingWorker;
|
|
30
31
|
async function initializeDatabase(config, logger) {
|
|
@@ -161,6 +162,7 @@ export async function initialize(opts, logger) {
|
|
|
161
162
|
const { serviceUrl, publicUrl, dappApiUrl, userApiUrl } = deriveUrls(config, port);
|
|
162
163
|
const app = express();
|
|
163
164
|
app.set('trust proxy', config.server.trustProxy);
|
|
165
|
+
app.use(securityHeaders());
|
|
164
166
|
const server = app.listen(port, () => {
|
|
165
167
|
logger.info(`Remote Wallet Gateway starting on ${serviceUrl})`);
|
|
166
168
|
});
|
|
@@ -196,6 +198,7 @@ export async function initialize(opts, logger) {
|
|
|
196
198
|
[SigningProvider.FIREBLOCKS]: new FireblocksSigningProvider({
|
|
197
199
|
defaultKeyInfo: keyInfo,
|
|
198
200
|
userApiKeys,
|
|
201
|
+
apiPath: Env.FIREBLOCKS_API_PATH('https://api.fireblocks.io/v1'),
|
|
199
202
|
}),
|
|
200
203
|
[SigningProvider.BLOCKDAEMON]: new BlockdaemonSigningProvider({
|
|
201
204
|
baseUrl: Env.BLOCKDAEMON_API_URL('http://localhost:5080/api/cwp/canton'),
|
|
@@ -251,7 +254,7 @@ export async function initialize(opts, logger) {
|
|
|
251
254
|
// register user API handlers
|
|
252
255
|
user(config.server.userPath, app, logger, kernelInfo, publicUrl, notificationService, drivers, store, config.server.admin);
|
|
253
256
|
// register web handler
|
|
254
|
-
web(app, server, userApiUrl);
|
|
257
|
+
web(app, server, userApiUrl, dappApiUrl);
|
|
255
258
|
isReady = true;
|
|
256
259
|
logger.info(`Wallet Gateway (version: ${GATEWAY_VERSION}) initialization complete`);
|
|
257
260
|
logger.info(`Wallet Gateway UI available on ${publicUrl}`);
|
|
@@ -22,19 +22,7 @@ export declare class TransactionService {
|
|
|
22
22
|
private signWithWalletKernel;
|
|
23
23
|
private signWithBlockdaemon;
|
|
24
24
|
private signWithFireblocks;
|
|
25
|
-
/**
|
|
26
|
-
* Dfns broadcasts the prepared transaction to Canton itself, so we get back
|
|
27
|
-
* an updateId rather than a raw signature. We persist the updateId as the
|
|
28
|
-
* signature payload (the controller short-circuits Dfns execute) and surface
|
|
29
|
-
* the same SignResult shape the other external providers use.
|
|
30
|
-
*/
|
|
31
25
|
private signWithDfns;
|
|
32
|
-
/**
|
|
33
|
-
* Dfns has already broadcast the transaction at sign-time, so execute is a
|
|
34
|
-
* state reconciliation: mark the stored transaction as executed and return
|
|
35
|
-
* the updateId Dfns gave us. We deliberately don't post to the ledger here.
|
|
36
|
-
*/
|
|
37
|
-
private executeWithDfns;
|
|
38
26
|
private executeWithParticipant;
|
|
39
27
|
private executeWithExternal;
|
|
40
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-service.d.ts","sourceR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YAAY,EAC3B,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC;IAiEZ,cAAc,CACvB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,oBAAoB,CAAC;YAyDlB,iCAAiC;YAsBjC,mBAAmB;YAiCnB,oBAAoB;YAyDpB,mBAAmB;YAiHnB,kBAAkB;YAqHlB,YAAY;YA6GZ,sBAAsB;YAoDtB,mBAAmB;CAiEpC"}
|
|
@@ -25,7 +25,7 @@ export class TransactionService {
|
|
|
25
25
|
}
|
|
26
26
|
switch (signingProvider) {
|
|
27
27
|
case SigningProvider.PARTICIPANT: {
|
|
28
|
-
return this.signWithParticipant(wallet);
|
|
28
|
+
return this.signWithParticipant(wallet, signParams);
|
|
29
29
|
}
|
|
30
30
|
case SigningProvider.WALLET_KERNEL: {
|
|
31
31
|
return this.signWithWalletKernel(authContext.userId, wallet, signParams);
|
|
@@ -47,8 +47,8 @@ export class TransactionService {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
execute(userId, wallet, transaction, executeParams, ledgerClient, network) {
|
|
50
|
-
if (transaction.status
|
|
51
|
-
throw new Error(
|
|
50
|
+
if (transaction.status !== 'signed') {
|
|
51
|
+
throw new Error(`Cannot execute a ${transaction.status} transaction. Expected status: signed.`);
|
|
52
52
|
}
|
|
53
53
|
switch (wallet.signingProviderId) {
|
|
54
54
|
case SigningProvider.PARTICIPANT: {
|
|
@@ -71,7 +71,8 @@ export class TransactionService {
|
|
|
71
71
|
}
|
|
72
72
|
case SigningProvider.WALLET_KERNEL:
|
|
73
73
|
case SigningProvider.BLOCKDAEMON:
|
|
74
|
-
case SigningProvider.FIREBLOCKS:
|
|
74
|
+
case SigningProvider.FIREBLOCKS:
|
|
75
|
+
case SigningProvider.DFNS: {
|
|
75
76
|
if (!executeParams) {
|
|
76
77
|
throw new Error('Execute params are required for external signing');
|
|
77
78
|
}
|
|
@@ -80,9 +81,6 @@ export class TransactionService {
|
|
|
80
81
|
}
|
|
81
82
|
return this.executeWithExternal(userId, executeParams, transaction, ledgerClient);
|
|
82
83
|
}
|
|
83
|
-
case SigningProvider.DFNS: {
|
|
84
|
-
return this.executeWithDfns(transaction);
|
|
85
|
-
}
|
|
86
84
|
default:
|
|
87
85
|
throw new Error(`Unsupported signing provider: ${wallet.signingProviderId}`);
|
|
88
86
|
}
|
|
@@ -117,7 +115,7 @@ export class TransactionService {
|
|
|
117
115
|
const userId = authContext.isApiKey
|
|
118
116
|
? authContext.ledgerUserId
|
|
119
117
|
: authContext.userId;
|
|
120
|
-
return this.execute(userId, wallet, transaction, executeParams, ledgerClient, network);
|
|
118
|
+
return this.execute(userId, wallet, { ...transaction, status: 'signed' }, executeParams, ledgerClient, network);
|
|
121
119
|
}
|
|
122
120
|
async loadPreparedTransactionForSigning(transactionId) {
|
|
123
121
|
const existingTx = await this.store.getTransaction(transactionId);
|
|
@@ -129,7 +127,27 @@ export class TransactionService {
|
|
|
129
127
|
}
|
|
130
128
|
return existingTx;
|
|
131
129
|
}
|
|
132
|
-
|
|
130
|
+
// This doesn't really sign the transaction.
|
|
131
|
+
// For participant both signing and execution are handled by /v2/commands/submit-and-wait using participant keys
|
|
132
|
+
// This behavior is unique to signing provider participant.
|
|
133
|
+
// This step intended for making participant wallets conform to a common API.
|
|
134
|
+
async signWithParticipant(wallet, signParams) {
|
|
135
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
136
|
+
const now = new Date();
|
|
137
|
+
const signedTx = {
|
|
138
|
+
id: tx.id,
|
|
139
|
+
commandId: tx.commandId,
|
|
140
|
+
status: 'signed',
|
|
141
|
+
preparedTransaction: tx.preparedTransaction,
|
|
142
|
+
preparedTransactionHash: tx.preparedTransactionHash,
|
|
143
|
+
origin: tx?.origin ?? null,
|
|
144
|
+
...(tx?.createdAt && {
|
|
145
|
+
createdAt: tx.createdAt,
|
|
146
|
+
}),
|
|
147
|
+
signedAt: now,
|
|
148
|
+
};
|
|
149
|
+
await this.store.setTransactionSigned(tx.id, now);
|
|
150
|
+
this.notifier.emit('txChanged', signedTx);
|
|
133
151
|
return {
|
|
134
152
|
status: 'signed',
|
|
135
153
|
signature: 'none',
|
|
@@ -354,12 +372,6 @@ export class TransactionService {
|
|
|
354
372
|
};
|
|
355
373
|
}
|
|
356
374
|
}
|
|
357
|
-
/**
|
|
358
|
-
* Dfns broadcasts the prepared transaction to Canton itself, so we get back
|
|
359
|
-
* an updateId rather than a raw signature. We persist the updateId as the
|
|
360
|
-
* signature payload (the controller short-circuits Dfns execute) and surface
|
|
361
|
-
* the same SignResult shape the other external providers use.
|
|
362
|
-
*/
|
|
363
375
|
async signWithDfns(userId, wallet, signParams) {
|
|
364
376
|
const signingProvider = this.signingDrivers[SigningProvider.DFNS];
|
|
365
377
|
if (!signingProvider) {
|
|
@@ -394,7 +406,7 @@ export class TransactionService {
|
|
|
394
406
|
});
|
|
395
407
|
if (signingResult.status === 'signed') {
|
|
396
408
|
if (!signingResult.signature) {
|
|
397
|
-
throw new Error('No
|
|
409
|
+
throw new Error('No signature returned from Dfns signing driver');
|
|
398
410
|
}
|
|
399
411
|
const signedTx = {
|
|
400
412
|
id: tx.id,
|
|
@@ -444,36 +456,6 @@ export class TransactionService {
|
|
|
444
456
|
};
|
|
445
457
|
}
|
|
446
458
|
}
|
|
447
|
-
/**
|
|
448
|
-
* Dfns has already broadcast the transaction at sign-time, so execute is a
|
|
449
|
-
* state reconciliation: mark the stored transaction as executed and return
|
|
450
|
-
* the updateId Dfns gave us. We deliberately don't post to the ledger here.
|
|
451
|
-
*/
|
|
452
|
-
async executeWithDfns(transaction) {
|
|
453
|
-
if (!transaction.externalTxId) {
|
|
454
|
-
throw new Error('Cannot execute Dfns transaction without externalTxId from Dfns');
|
|
455
|
-
}
|
|
456
|
-
const executedTx = {
|
|
457
|
-
id: transaction.id,
|
|
458
|
-
commandId: transaction.commandId,
|
|
459
|
-
status: 'executed',
|
|
460
|
-
preparedTransaction: transaction.preparedTransaction,
|
|
461
|
-
preparedTransactionHash: transaction.preparedTransactionHash,
|
|
462
|
-
origin: transaction.origin ?? null,
|
|
463
|
-
...(transaction.createdAt && {
|
|
464
|
-
createdAt: transaction.createdAt,
|
|
465
|
-
}),
|
|
466
|
-
...(transaction.signedAt && {
|
|
467
|
-
signedAt: transaction.signedAt,
|
|
468
|
-
}),
|
|
469
|
-
externalTxId: transaction.externalTxId,
|
|
470
|
-
};
|
|
471
|
-
await this.store.setTransactionStatus(transaction.id, 'executed', {
|
|
472
|
-
externalTxId: transaction.externalTxId,
|
|
473
|
-
});
|
|
474
|
-
this.notifier.emit('txChanged', executedTx);
|
|
475
|
-
return { updateId: transaction.externalTxId };
|
|
476
|
-
}
|
|
477
459
|
async executeWithParticipant(userId, executeParams, transaction, ledgerClient, network) {
|
|
478
460
|
const { partyId } = executeParams;
|
|
479
461
|
const { commandId } = transaction;
|