@canton-network/wallet-gateway-remote 0.3.0 → 0.5.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.
Files changed (70) hide show
  1. package/README.md +4 -16
  2. package/dist/auth/jwt-auth-service.d.ts +1 -1
  3. package/dist/auth/jwt-auth-service.d.ts.map +1 -1
  4. package/dist/auth/jwt-auth-service.js +11 -1
  5. package/dist/auth/jwt-unsafe-auth-service.d.ts +11 -0
  6. package/dist/auth/jwt-unsafe-auth-service.d.ts.map +1 -0
  7. package/dist/auth/jwt-unsafe-auth-service.js +50 -0
  8. package/dist/config/Config.d.ts +144 -30
  9. package/dist/config/Config.d.ts.map +1 -1
  10. package/dist/dapp-api/controller.d.ts +2 -0
  11. package/dist/dapp-api/controller.d.ts.map +1 -1
  12. package/dist/dapp-api/controller.js +29 -7
  13. package/dist/dapp-api/rpc-gen/index.d.ts +6 -0
  14. package/dist/dapp-api/rpc-gen/index.d.ts.map +1 -1
  15. package/dist/dapp-api/rpc-gen/index.js +2 -0
  16. package/dist/dapp-api/rpc-gen/typings.d.ts +23 -17
  17. package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
  18. package/dist/dapp-api/server.d.ts +4 -1
  19. package/dist/dapp-api/server.d.ts.map +1 -1
  20. package/dist/dapp-api/server.js +12 -16
  21. package/dist/dapp-api/server.test.js +19 -9
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +15 -1
  25. package/dist/init.d.ts +3 -8
  26. package/dist/init.d.ts.map +1 -1
  27. package/dist/init.js +55 -32
  28. package/dist/ledger/party-allocation-service.d.ts +2 -1
  29. package/dist/ledger/party-allocation-service.d.ts.map +1 -1
  30. package/dist/ledger/party-allocation-service.js +4 -4
  31. package/dist/ledger/party-allocation-service.test.js +11 -2
  32. package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
  33. package/dist/ledger/wallet-sync-service.js +1 -1
  34. package/dist/user-api/controller.d.ts.map +1 -1
  35. package/dist/user-api/controller.js +57 -12
  36. package/dist/user-api/rpc-gen/typings.d.ts +10 -0
  37. package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
  38. package/dist/user-api/server.d.ts +6 -4
  39. package/dist/user-api/server.d.ts.map +1 -1
  40. package/dist/user-api/server.js +4 -13
  41. package/dist/user-api/server.test.js +11 -10
  42. package/dist/web/frontend/404/index.html +3 -6
  43. package/dist/web/frontend/approve/index.html +5 -9
  44. package/dist/web/frontend/assets/{404-FxmR286l.js → 404-BJiXCpwg.js} +3 -3
  45. package/dist/web/frontend/assets/approve-hB6irrWF.js +157 -0
  46. package/dist/web/frontend/assets/callback-DHz7ggNR.js +1 -0
  47. package/dist/web/frontend/assets/handle-errors-DT2Go5Ch.js +1 -0
  48. package/dist/web/frontend/assets/{index-BknZMPaI.css → index-HEe9--Xd.css} +1 -1
  49. package/dist/web/frontend/assets/{index-VtAAU1cN.js → index-YpAHEASq.js} +64 -51
  50. package/dist/web/frontend/assets/login-Dw5jymys.js +159 -0
  51. package/dist/web/frontend/assets/{networks-CjofhwC9.js → networks-CaAXx7MG.js} +9 -9
  52. package/dist/web/frontend/assets/{state-DKGJ6EmM.js → state-BTqOtYLt.js} +2 -2
  53. package/dist/web/frontend/assets/{wallets-BPtpBguD.js → wallets-fk9mMhcI.js} +4 -4
  54. package/dist/web/frontend/callback/index.html +3 -3
  55. package/dist/web/frontend/index.html +2 -5
  56. package/dist/web/frontend/login/index.html +5 -8
  57. package/dist/web/frontend/networks/index.html +6 -8
  58. package/dist/web/frontend/wallets/index.html +5 -9
  59. package/dist/web/server.d.ts +3 -1
  60. package/dist/web/server.d.ts.map +1 -1
  61. package/dist/web/server.js +38 -24
  62. package/package.json +17 -17
  63. package/dist/web/frontend/assets/approve-DjrMmUo0.js +0 -157
  64. package/dist/web/frontend/assets/callback-QrXhW3mX.js +0 -1
  65. package/dist/web/frontend/assets/handle-errors-BcwHAkCd.js +0 -1
  66. package/dist/web/frontend/assets/index-BPTkodPz.js +0 -1
  67. package/dist/web/frontend/assets/index-TZrNw7dA.css +0 -1
  68. package/dist/web/frontend/assets/login-kWEHTsIr.js +0 -159
  69. package/dist/web/frontend/assets/rpc-client-CCUlY3sp.js +0 -1
  70. package/dist/web/frontend/assets/state-manager-BNW0y5PZ.js +0 -23
@@ -24,14 +24,32 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
24
24
  const logger = _logger.child({ component: 'dapp-controller' });
25
25
  return buildController({
26
26
  connect: async () => ({
27
- kernel: kernelInfo,
28
- isConnected: false,
29
- userUrl: 'http://localhost:3002/login/',
27
+ sessionToken: '',
28
+ status: {
29
+ kernel: kernelInfo,
30
+ isConnected: false,
31
+ userUrl: 'http://localhost:3030/login/', // TODO: pull user URL from config
32
+ },
30
33
  }),
34
+ disconnect: async () => {
35
+ if (!context) {
36
+ return null;
37
+ }
38
+ else {
39
+ const notifier = notificationService.getNotifier(context.userId);
40
+ await store.removeSession();
41
+ notifier.emit('statusChanged', {
42
+ kernel: kernelInfo,
43
+ isConnected: false,
44
+ userUrl: 'http://localhost:3030/login/', // TODO: pull user URL from config
45
+ });
46
+ }
47
+ return null;
48
+ },
31
49
  darsAvailable: async () => ({ dars: ['default-dar'] }),
32
50
  ledgerApi: async (params) => {
33
51
  const network = await store.getCurrentNetwork();
34
- const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), assertConnected(context).accessToken, logger);
52
+ const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), logger, false, assertConnected(context).accessToken);
35
53
  let result;
36
54
  switch (params.requestMethod) {
37
55
  case 'GET':
@@ -58,7 +76,7 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
58
76
  if (wallet === undefined) {
59
77
  throw new Error('No primary wallet found');
60
78
  }
61
- const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), context.accessToken, logger);
79
+ const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), logger, false, context.accessToken);
62
80
  const userId = context.userId;
63
81
  const notifier = notificationService.getNotifier(userId);
64
82
  const commandId = v4();
@@ -72,7 +90,8 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
72
90
  payload: params.commands,
73
91
  });
74
92
  return {
75
- userUrl: `http://localhost:3002/approve/index.html?commandId=${commandId}&partyId=${wallet.partyId}&txHash=${encodeURIComponent(preparedTransactionHash)}&tx=${encodeURIComponent(preparedTransaction)}`,
93
+ // TODO: pull user base URL / port from config
94
+ userUrl: `http://localhost:3030/approve/index.html?commandId=${commandId}&partyId=${wallet.partyId}&txHash=${encodeURIComponent(preparedTransactionHash)}&tx=${encodeURIComponent(preparedTransaction)}`,
76
95
  };
77
96
  },
78
97
  prepareReturn: async (params) => {
@@ -84,7 +103,7 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
84
103
  if (wallet === undefined) {
85
104
  throw new Error('No primary wallet found');
86
105
  }
87
- const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), context.accessToken, logger);
106
+ const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), logger, false, context.accessToken);
88
107
  return prepareSubmission(context.userId, wallet.partyId, network.synchronizerId, params.commands, ledgerClient);
89
108
  },
90
109
  status: async () => {
@@ -105,6 +124,9 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
105
124
  onConnected: async () => {
106
125
  throw new Error('Only for events.');
107
126
  },
127
+ onStatusChanged: async () => {
128
+ throw new Error('Only for events.');
129
+ },
108
130
  onAccountsChanged: async () => {
109
131
  throw new Error('Only for events.');
110
132
  },
@@ -1,21 +1,25 @@
1
1
  import { Status } from './typings.js';
2
2
  import { Connect } from './typings.js';
3
+ import { Disconnect } from './typings.js';
3
4
  import { DarsAvailable } from './typings.js';
4
5
  import { PrepareReturn } from './typings.js';
5
6
  import { PrepareExecute } from './typings.js';
6
7
  import { LedgerApi } from './typings.js';
7
8
  import { OnConnected } from './typings.js';
9
+ import { OnStatusChanged } from './typings.js';
8
10
  import { OnAccountsChanged } from './typings.js';
9
11
  import { RequestAccounts } from './typings.js';
10
12
  import { OnTxChanged } from './typings.js';
11
13
  export type Methods = {
12
14
  status: Status;
13
15
  connect: Connect;
16
+ disconnect: Disconnect;
14
17
  darsAvailable: DarsAvailable;
15
18
  prepareReturn: PrepareReturn;
16
19
  prepareExecute: PrepareExecute;
17
20
  ledgerApi: LedgerApi;
18
21
  onConnected: OnConnected;
22
+ onStatusChanged: OnStatusChanged;
19
23
  onAccountsChanged: OnAccountsChanged;
20
24
  requestAccounts: RequestAccounts;
21
25
  onTxChanged: OnTxChanged;
@@ -23,11 +27,13 @@ export type Methods = {
23
27
  declare function buildController(methods: Methods): {
24
28
  status: Status;
25
29
  connect: Connect;
30
+ disconnect: Disconnect;
26
31
  darsAvailable: DarsAvailable;
27
32
  prepareReturn: PrepareReturn;
28
33
  prepareExecute: PrepareExecute;
29
34
  ledgerApi: LedgerApi;
30
35
  onConnected: OnConnected;
36
+ onStatusChanged: OnStatusChanged;
31
37
  onAccountsChanged: OnAccountsChanged;
32
38
  requestAccounts: RequestAccounts;
33
39
  onTxChanged: OnTxChanged;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dapp-api/rpc-gen/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO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AAA;IAChB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,cAAc,CAAA;IAC9B,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE,WAAW,CAAA;IACxB,eAAe,EAAE,eAAe,CAAA;IAChC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,eAAe,EAAE,eAAe,CAAA;IAChC,WAAW,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,iBAAS,eAAe,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;EAexC;AAED,eAAe,eAAe,CAAA"}
@@ -4,11 +4,13 @@ function buildController(methods) {
4
4
  return {
5
5
  status: methods.status,
6
6
  connect: methods.connect,
7
+ disconnect: methods.disconnect,
7
8
  darsAvailable: methods.darsAvailable,
8
9
  prepareReturn: methods.prepareReturn,
9
10
  prepareExecute: methods.prepareExecute,
10
11
  ledgerApi: methods.ledgerApi,
11
12
  onConnected: methods.onConnected,
13
+ onStatusChanged: methods.onStatusChanged,
12
14
  onAccountsChanged: methods.onAccountsChanged,
13
15
  requestAccounts: methods.requestAccounts,
14
16
  onTxChanged: methods.onTxChanged,
@@ -40,7 +40,7 @@ export interface KernelInfo {
40
40
  }
41
41
  /**
42
42
  *
43
- * Whether or not a connection to a network is esablished.
43
+ * Whether or not a connection to a network is established.
44
44
  *
45
45
  */
46
46
  export type IsConnected = boolean;
@@ -50,12 +50,18 @@ export type IsConnected = boolean;
50
50
  *
51
51
  */
52
52
  export type ChainId = string;
53
+ export interface StatusEvent {
54
+ kernel: KernelInfo;
55
+ isConnected: IsConnected;
56
+ chainId?: ChainId;
57
+ [k: string]: any;
58
+ }
53
59
  /**
54
60
  *
55
- * A URL that points to a user interface.
61
+ * JWT authentication token (if applicable).
56
62
  *
57
63
  */
58
- export type UserUrl = string;
64
+ export type SessionToken = string;
59
65
  export type Dar = string;
60
66
  export type Dars = Dar[];
61
67
  /**
@@ -80,13 +86,13 @@ export interface JsPrepareSubmissionResponse {
80
86
  preparedTransactionHash?: PreparedTransactionHash;
81
87
  [k: string]: any;
82
88
  }
83
- export type Response = string;
84
89
  /**
85
90
  *
86
- * JWT authentication token (if applicable).
91
+ * A URL that points to a user interface.
87
92
  *
88
93
  */
89
- export type SessionToken = string;
94
+ export type UserUrl = string;
95
+ export type Response = string;
90
96
  /**
91
97
  *
92
98
  * Set as primary wallet for dApp usage.
@@ -264,19 +270,17 @@ export interface LedgerApiParams {
264
270
  body?: Body;
265
271
  [k: string]: any;
266
272
  }
267
- export interface StatusResult {
268
- kernel: KernelInfo;
269
- isConnected: IsConnected;
270
- chainId?: ChainId;
271
- [k: string]: any;
272
- }
273
273
  export interface ConnectResult {
274
- kernel: KernelInfo;
275
- isConnected: IsConnected;
276
- chainId?: ChainId;
277
- userUrl: UserUrl;
274
+ status: StatusEvent;
275
+ sessionToken: SessionToken;
278
276
  [k: string]: any;
279
277
  }
278
+ /**
279
+ *
280
+ * Represents a null value, used in responses where no data is returned.
281
+ *
282
+ */
283
+ export type Null = null;
280
284
  export interface DarsAvailableResult {
281
285
  dars: Dars;
282
286
  [k: string]: any;
@@ -324,13 +328,15 @@ export type TxChangedEvent = TxChangedPendingEvent | TxChangedSignedEvent | TxCh
324
328
  * Generated! Represents an alias to any of the provided schemas
325
329
  *
326
330
  */
327
- export type Status = () => Promise<StatusResult>;
331
+ export type Status = () => Promise<StatusEvent>;
328
332
  export type Connect = () => Promise<ConnectResult>;
333
+ export type Disconnect = () => Promise<Null>;
329
334
  export type DarsAvailable = () => Promise<DarsAvailableResult>;
330
335
  export type PrepareReturn = (params: PrepareReturnParams) => Promise<PrepareReturnResult>;
331
336
  export type PrepareExecute = (params: PrepareExecuteParams) => Promise<PrepareExecuteResult>;
332
337
  export type LedgerApi = (params: LedgerApiParams) => Promise<LedgerApiResult>;
333
338
  export type OnConnected = () => Promise<OnConnectedEvent>;
339
+ export type OnStatusChanged = () => Promise<StatusEvent>;
334
340
  export type OnAccountsChanged = () => Promise<AccountsChangedEvent>;
335
341
  export type RequestAccounts = () => Promise<RequestAccountsResult>;
336
342
  export type OnTxChanged = () => Promise<TxChangedEvent>;
@@ -1 +1 @@
1
- {"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../../../src/dapp-api/rpc-gen/typings.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB;AACD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAC7D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC7B,MAAM,MAAM,IAAI,GAAG,MAAM,CAAA;AACzB;;;;GAIG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,CAAA;AACvB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AACpE;;;;GAIG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAA;AACxB;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,EAAE,CAAA;IACN,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AACD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAA;AACjC;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAC5B;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAC5B,MAAM,MAAM,GAAG,GAAG,MAAM,CAAA;AACxB,MAAM,MAAM,IAAI,GAAG,GAAG,EAAE,CAAA;AACxB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAA;AACxC;;;;GAIG;AACH,MAAM,MAAM,u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MAAM,EAAE,mBAAmB,KAC1B,OAAO,CAAC,mBAAmB,CAAC,CAAA;AACjC,MAAM,MAAM,cAAc,GAAG,CACzB,MAAM,EAAE,oBAAoB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAClC,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;AAC7E,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;AACxD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAA;AACnE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAClE,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAA"}
@@ -1,6 +1,9 @@
1
+ import express from 'express';
2
+ import { Logger } from 'pino';
1
3
  import { Store } from '@canton-network/core-wallet-store';
2
4
  import { AuthService, AuthAware } from '@canton-network/core-wallet-auth';
5
+ import { Server } from 'http';
3
6
  import { NotificationService } from '../notification/NotificationService.js';
4
7
  import { KernelInfo } from '../config/Config.js';
5
- export declare const dapp: (kernelInfo: KernelInfo, notificationService: NotificationService, authService: AuthService, store: Store & AuthAware<Store>) => import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
8
+ export declare const dapp: (route: string, app: express.Express, logger: Logger, server: Server, kernelInfo: KernelInfo, notificationService: NotificationService, authService: AuthService, store: Store & AuthAware<Store>) => Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
6
9
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dapp-api/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAEzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAKzE,OAAO,EACH,mBAAmB,EAEtB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAIhD,eAAO,MAAM,IAAI,GACb,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,aAAa,WAAW,EACxB,OAAO,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,uGAyElC,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dapp-api/server.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAG7B,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,OAAO,EACH,mBAAmB,EAEtB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,eAAO,MAAM,IAAI,GACb,OAAO,MAAM,EACb,KAAK,OAAO,CAAC,OAAO,EACpB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,aAAa,WAAW,EACxB,OAAO,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,wFAuElC,CAAA"}
@@ -1,27 +1,18 @@
1
1
  // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import express from 'express';
3
+ import cors from 'cors';
4
4
  import { dappController } from './controller.js';
5
- import { pino } from 'pino';
6
5
  import { jsonRpcHandler } from '../middleware/jsonRpcHandler.js';
7
- import { jwtAuth } from '../middleware/jwtAuth.js';
8
- import { rpcRateLimit } from '../middleware/rateLimit.js';
9
- import cors from 'cors';
10
- import { createServer } from 'http';
11
- import { Server } from 'socket.io';
12
- const logger = pino({ name: 'main', level: 'debug' });
13
- export const dapp = (kernelInfo, notificationService, authService, store) => {
14
- const app = express();
15
- app.use(cors());
16
- app.use(express.json());
17
- app.use('/rpc', rpcRateLimit, jwtAuth(authService, logger), (req, res, next) => jsonRpcHandler({
6
+ import { Server as SocketIoServer } from 'socket.io';
7
+ export const dapp = (route, app, logger, server, kernelInfo, notificationService, authService, store) => {
8
+ app.use(cors()); // TODO: read allowedOrigins from config
9
+ app.use(route, (req, res, next) => jsonRpcHandler({
18
10
  controller: dappController(kernelInfo, store.withAuthContext(req.authContext), notificationService, logger, req.authContext),
19
11
  logger,
20
12
  })(req, res, next));
21
- const server = createServer(app);
22
- const io = new Server(server, {
13
+ const io = new SocketIoServer(server, {
23
14
  cors: {
24
- origin: '*',
15
+ origin: '*', // TODO: read allowedOrigins from config
25
16
  methods: ['GET', 'POST'],
26
17
  },
27
18
  });
@@ -31,6 +22,9 @@ export const dapp = (kernelInfo, notificationService, authService, store) => {
31
22
  const onAccountsChanged = (...event) => {
32
23
  io.emit('accountsChanged', ...event);
33
24
  };
25
+ const onStatusChanged = (...event) => {
26
+ io.emit('statusChanged', ...event);
27
+ };
34
28
  const onConnected = (...event) => {
35
29
  io.emit('onConnected', ...event);
36
30
  };
@@ -47,6 +41,7 @@ export const dapp = (kernelInfo, notificationService, authService, store) => {
47
41
  notifier = notificationService.getNotifier(userId);
48
42
  notifier.on('accountsChanged', onAccountsChanged);
49
43
  notifier.on('onConnected', onConnected);
44
+ notifier.on('statusChanged', onStatusChanged);
50
45
  notifier.on('txChanged', onTxChanged);
51
46
  });
52
47
  socket.on('disconnect', () => {
@@ -54,6 +49,7 @@ export const dapp = (kernelInfo, notificationService, authService, store) => {
54
49
  if (notifier) {
55
50
  notifier.removeListener('accountsChanged', onAccountsChanged);
56
51
  notifier.removeListener('onConnected', onConnected);
52
+ notifier.removeListener('statusChanged', onStatusChanged);
57
53
  notifier.removeListener('txChanged', onTxChanged);
58
54
  }
59
55
  });
@@ -1,12 +1,15 @@
1
1
  // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { expect, test, jest } from '@jest/globals';
4
+ import cors from 'cors';
4
5
  import request from 'supertest';
6
+ import express from 'express';
5
7
  import { dapp } from './server.js';
6
8
  import { StoreInternal } from '@canton-network/core-wallet-store-inmemory';
7
9
  import { ConfigUtils } from '../config/ConfigUtils.js';
8
10
  import { pino } from 'pino';
9
11
  import { sink } from 'pino-test';
12
+ import { createServer } from 'http';
10
13
  const authService = {
11
14
  verifyToken: async () => {
12
15
  return new Promise((resolve) => resolve({ userId: 'user123', accessToken: 'token123' }));
@@ -23,8 +26,12 @@ const notificationService = {
23
26
  }),
24
27
  };
25
28
  test('call connect rpc', async () => {
26
- const response = await request(dapp(config.kernel, notificationService, authService, store))
27
- .post('/rpc')
29
+ const app = express();
30
+ app.use(cors());
31
+ app.use(express.json());
32
+ const server = createServer(app);
33
+ const response = await request(dapp('/api/v0/dapp', app, pino(sink()), server, config.kernel, notificationService, authService, store))
34
+ .post('/api/v0/dapp')
28
35
  .send({ jsonrpc: '2.0', id: 0, method: 'connect', params: [] })
29
36
  .set('Accept', 'application/json');
30
37
  expect(response.statusCode).toBe(200);
@@ -32,14 +39,17 @@ test('call connect rpc', async () => {
32
39
  id: 0,
33
40
  jsonrpc: '2.0',
34
41
  result: {
35
- kernel: {
36
- id: 'remote-da',
37
- clientType: 'remote',
38
- url: 'http://localhost:3008/rpc',
39
- userUrl: 'http://localhost:3002',
42
+ sessionToken: '',
43
+ status: {
44
+ kernel: {
45
+ id: 'remote-da',
46
+ clientType: 'remote',
47
+ url: 'http://localhost:3030/api/v0/dapp',
48
+ userUrl: 'http://localhost:3030',
49
+ },
50
+ isConnected: false,
51
+ userUrl: 'http://localhost:3030/login/',
40
52
  },
41
- isConnected: false,
42
- userUrl: 'http://localhost:3002/login/',
43
53
  },
44
54
  });
45
55
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ declare const options: {
3
+ config: string;
4
+ port: string | true;
5
+ logFormat: "json" | "pretty";
6
+ storeType: "sqlite" | "postgres";
7
+ };
8
+ export type CliOptions = typeof options;
2
9
  export {};
3
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAuDA,QAAA,MAAM,OAAO;;;;;CAAiB,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG,OAAO,OAAO,CAAA"}
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import { ConfigUtils } from './config/ConfigUtils.js';
8
8
  import { readFileSync } from 'fs';
9
9
  import { join, dirname } from 'path';
10
10
  import { fileURLToPath } from 'url';
11
+ import pino from 'pino';
11
12
  const __filename = fileURLToPath(import.meta.url);
12
13
  const __dirname = dirname(__filename);
13
14
  const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
@@ -16,6 +17,7 @@ const program = new Command()
16
17
  .version(pkg.version)
17
18
  .description('Run a remotely hosted Wallet Gateway')
18
19
  .option('-c, --config <path>', 'set config path', './config.json')
20
+ .option('-p, --port [port]', 'set port', '3030')
19
21
  .addOption(new Option('-f, --log-format <format>', 'set log format')
20
22
  .choices(['json', 'pretty'])
21
23
  .default('pretty'))
@@ -23,8 +25,20 @@ const program = new Command()
23
25
  .choices(['sqlite', 'postgres'])
24
26
  .default('sqlite'))
25
27
  .action((opts) => {
28
+ // Define project-global logger
29
+ const logger = pino({
30
+ name: 'main',
31
+ level: 'debug',
32
+ ...(opts.logFormat === 'pretty'
33
+ ? {
34
+ transport: {
35
+ target: 'pino-pretty',
36
+ },
37
+ }
38
+ : {}),
39
+ });
26
40
  // Initialize the database with the provided config
27
- initialize(opts);
41
+ initialize(opts, logger);
28
42
  });
29
43
  // Parse only the options (without executing commands) to get config path
30
44
  program.parseOptions(process.argv);
package/dist/init.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- export declare function initialize(opts: {
2
- config: string;
3
- logFormat: 'pretty' | 'json';
4
- }): Promise<{
5
- dAppServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
6
- userServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
7
- webServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
8
- }>;
1
+ import { Logger } from 'pino';
2
+ import { CliOptions } from './index.js';
3
+ export declare function initialize(opts: CliOptions, logger: Logger): Promise<void>;
9
4
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAmDA,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC/B;;;;GAkEA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAe7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAsEvC,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBA+DhE"}
package/dist/init.js CHANGED
@@ -3,21 +3,18 @@
3
3
  import { dapp } from './dapp-api/server.js';
4
4
  import { user } from './user-api/server.js';
5
5
  import { web } from './web/server.js';
6
- import { pino } from 'pino';
7
- import ViteExpress from 'vite-express';
8
- import { StoreSql, connection } from '@canton-network/core-wallet-store-sql';
6
+ import { StoreSql, bootstrap, connection, migrator, } from '@canton-network/core-wallet-store-sql';
9
7
  import { ConfigUtils } from './config/ConfigUtils.js';
10
8
  import EventEmitter from 'events';
11
9
  import { SigningProvider } from '@canton-network/core-signing-lib';
12
10
  import { ParticipantSigningDriver } from '@canton-network/core-signing-participant';
13
11
  import { InternalSigningDriver } from '@canton-network/core-signing-internal';
14
12
  import { jwtAuthService } from './auth/jwt-auth-service.js';
15
- import path, { dirname } from 'path';
16
- import { fileURLToPath } from 'url';
17
13
  import express from 'express';
18
- const dAppPort = Number(process.env.DAPP_API_PORT) || 3008;
19
- const userPort = Number(process.env.USER_API_PORT) || 3001;
20
- const webPort = Number(process.env.WEB_PORT) || 3002;
14
+ import { jwtAuth } from './middleware/jwtAuth.js';
15
+ import { rpcRateLimit } from './middleware/rateLimit.js';
16
+ import { existsSync } from 'fs';
17
+ let isReady = false;
21
18
  class NotificationService {
22
19
  constructor(logger) {
23
20
  this.logger = logger;
@@ -39,36 +36,62 @@ class NotificationService {
39
36
  return notifier;
40
37
  }
41
38
  }
42
- export async function initialize(opts) {
43
- const logger = pino({
44
- name: 'main',
45
- level: 'debug',
46
- ...(opts.logFormat === 'pretty'
47
- ? {
48
- transport: {
49
- target: 'pino-pretty',
50
- },
51
- }
52
- : {}),
39
+ async function initializeDatabase(config, logger) {
40
+ logger.info('Checking for database migrations...');
41
+ let exists = true;
42
+ if (config.store.connection.type === 'sqlite') {
43
+ exists = existsSync(config.store.connection.database);
44
+ }
45
+ const db = connection(config.store);
46
+ const umzug = migrator(db);
47
+ const pending = await umzug.pending();
48
+ if (pending.length > 0) {
49
+ logger.info({ pendingMigrations: pending.map((m) => m.name) }, 'Applying database migrations...');
50
+ await umzug.up();
51
+ logger.info('Database migrations applied successfully.');
52
+ }
53
+ else {
54
+ logger.info('No pending database migrations found.');
55
+ }
56
+ // bootstrap database from config file if it did not exist before
57
+ if (!exists) {
58
+ logger.info('Bootstrapping database from config...');
59
+ await bootstrap(db, config.store, logger);
60
+ }
61
+ return new StoreSql(db, logger);
62
+ }
63
+ export async function initialize(opts, logger) {
64
+ const port = opts.port ? Number(opts.port) : 3030;
65
+ const app = express();
66
+ const server = app.listen(port, () => {
67
+ logger.info(`Remote Wallet Gateway starting on http://localhost:${port}`);
68
+ });
69
+ app.use('/healthz', rpcRateLimit, (_req, res) => res.status(200).send('OK'));
70
+ app.use('/readyz', rpcRateLimit, (_req, res) => {
71
+ if (isReady) {
72
+ res.status(200).send('OK');
73
+ }
74
+ else {
75
+ res.status(503).send('UNAVAILABLE');
76
+ }
53
77
  });
54
78
  const notificationService = new NotificationService(logger);
55
79
  const config = ConfigUtils.loadConfigFile(opts.config);
56
- const store = new StoreSql(connection(config.store), logger);
80
+ const store = await initializeDatabase(config, logger);
57
81
  const authService = jwtAuthService(store, logger);
58
82
  const drivers = {
59
83
  [SigningProvider.PARTICIPANT]: new ParticipantSigningDriver(),
60
84
  [SigningProvider.WALLET_KERNEL]: new InternalSigningDriver(),
61
85
  };
62
- const dAppServer = dapp(config.kernel, notificationService, authService, store).listen(dAppPort, () => {
63
- logger.info(`dApp Server running at http://localhost:${dAppPort}`);
64
- });
65
- const userServer = user(config.kernel, notificationService, authService, drivers, store).listen(userPort, () => {
66
- logger.info(`User Server running at http://localhost:${userPort}`);
67
- });
68
- const webServer = process.env.NODE_ENV === 'development'
69
- ? ViteExpress.listen(web, webPort, () => logger.info(`Web server running at http://localhost:${webPort}`))
70
- : web
71
- .use(express.static(path.resolve(dirname(fileURLToPath(import.meta.url)), '../dist/web/frontend')))
72
- .listen(webPort, () => logger.info(`Web server running at http://localhost:${webPort}`));
73
- return { dAppServer, userServer, webServer };
86
+ app.use('/api/*splat', express.json());
87
+ app.use('/api/*splat', rpcRateLimit);
88
+ app.use('/api/*splat', jwtAuth(authService, logger));
89
+ // register dapp API handlers
90
+ dapp('/api/v0/dapp', app, logger, server, config.kernel, notificationService, authService, store);
91
+ // register user API handlers
92
+ user('/api/v0/user', app, logger, config.kernel, notificationService, drivers, store);
93
+ // register web handler
94
+ web(app, server);
95
+ isReady = true;
96
+ logger.info('Wallet Gateway initialization complete');
74
97
  }
@@ -1,3 +1,4 @@
1
+ import { AccessTokenProvider } from '@canton-network/core-wallet-auth';
1
2
  import { Logger } from 'pino';
2
3
  export type AllocatedParty = {
3
4
  partyId: string;
@@ -12,7 +13,7 @@ export declare class PartyAllocationService {
12
13
  private synchronizerId;
13
14
  private logger;
14
15
  private ledgerClient;
15
- constructor(synchronizerId: string, adminToken: string, httpLedgerUrl: string, logger: Logger);
16
+ constructor(synchronizerId: string, accessTokenProvider: AccessTokenProvider, httpLedgerUrl: string, logger: Logger, accessToken?: string);
16
17
  /**
17
18
  * Allocates an internal participant party for a user.
18
19
  * @param userId The ID of the user.
@@ -1 +1 @@
1
- {"version":3,"file":"party-allocation-service.d.ts","sourceRoot":"","sources":["../../src/ledger/party-allocation-service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAEpD;;GAEG;AACH,qBAAa,sBAAsB;IAI3B,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,MAAM;IANlB,OAAO,CAAC,YAAY,CAAc;gBAGtB,cAAc,EAAE,MAAM,EAC9B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;IAS1B;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAE1E;;;;;;OAMG;IACG,aAAa,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,WAAW,GAC7B,OAAO,CAAC,cAAc,CAAC;YAoBZ,qBAAqB;YAoBrB,qBAAqB;CAmCtC"}
1
+ {"version":3,"file":"party-allocation-service.d.ts","sourceRoot":"","sources":["../../src/ledger/party-allocation-service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAEpD;;GAEG;AACH,qBAAa,sBAAsB;IAI3B,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,MAAM;IANlB,OAAO,CAAC,YAAY,CAAc;gBAGtB,cAAc,EAAE,MAAM,EAC9B,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACtB,WAAW,GAAE,MAAW;IAW5B;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAE1E;;;;;;OAMG;IACG,aAAa,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,WAAW,GAC7B,OAAO,CAAC,cAAc,CAAC;YAoBZ,qBAAqB;YAuBrB,qBAAqB;CAsCtC"}
@@ -5,10 +5,10 @@ import { LedgerClient, TopologyWriteService, } from '@canton-network/core-ledger
5
5
  * This service provides an abstraction for Canton party allocation that seamlessly handles both internal and external parties.
6
6
  */
7
7
  export class PartyAllocationService {
8
- constructor(synchronizerId, adminToken, httpLedgerUrl, logger) {
8
+ constructor(synchronizerId, accessTokenProvider, httpLedgerUrl, logger, accessToken = '') {
9
9
  this.synchronizerId = synchronizerId;
10
10
  this.logger = logger;
11
- this.ledgerClient = new LedgerClient(new URL(httpLedgerUrl), adminToken, this.logger);
11
+ this.ledgerClient = new LedgerClient(new URL(httpLedgerUrl), this.logger, true, accessToken, accessTokenProvider);
12
12
  }
13
13
  async allocateParty(userId, hint, publicKey, signingCallback) {
14
14
  if (publicKey !== undefined && signingCallback !== undefined) {
@@ -27,7 +27,7 @@ export class PartyAllocationService {
27
27
  if (!res.partyDetails?.party) {
28
28
  throw new Error('Failed to allocate party');
29
29
  }
30
- await this.ledgerClient.grantUserRights(userId, res.partyDetails.party);
30
+ await this.ledgerClient.waitForPartyAndGrantUserRights(userId, res.partyDetails.party);
31
31
  return { hint, namespace, partyId: res.partyDetails.party };
32
32
  }
33
33
  async allocateExternalParty(userId, hint, publicKey, signingCallback) {
@@ -44,7 +44,7 @@ export class PartyAllocationService {
44
44
  signingAlgorithmSpec: 'SIGNING_ALGORITHM_SPEC_ED25519',
45
45
  },
46
46
  ]);
47
- await this.ledgerClient.grantUserRights(userId, res.partyId);
47
+ await this.ledgerClient.waitForPartyAndGrantUserRights(userId, res.partyId);
48
48
  return { hint, partyId: res.partyId, namespace };
49
49
  }
50
50
  }