@canton-network/wallet-gateway-remote 0.2.0 → 0.4.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 +4 -4
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +25 -6
- package/dist/dapp-api/server.d.ts +3 -1
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/server.js +5 -14
- package/dist/dapp-api/server.test.js +12 -5
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/init.d.ts +2 -8
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +17 -17
- package/dist/user-api/controller.js +3 -3
- package/dist/user-api/server.d.ts +3 -2
- package/dist/user-api/server.d.ts.map +1 -1
- package/dist/user-api/server.js +3 -10
- package/dist/user-api/server.test.js +8 -8
- package/dist/web/frontend/approve/index.html +3 -3
- package/dist/web/frontend/assets/{approve-DjrMmUo0.js → approve-BHHuvE3i.js} +1 -1
- package/dist/web/frontend/assets/{callback-QrXhW3mX.js → callback-D9y0DRns.js} +1 -1
- package/dist/web/frontend/assets/{handle-errors-BcwHAkCd.js → handle-errors-BM-xvD4v.js} +1 -1
- package/dist/web/frontend/assets/{login-kWEHTsIr.js → login-DJofeRCg.js} +1 -1
- package/dist/web/frontend/assets/{networks-CjofhwC9.js → networks-CZV8G3N2.js} +1 -1
- package/dist/web/frontend/assets/{rpc-client-CCUlY3sp.js → rpc-client-TGo-LOnR.js} +1 -1
- package/dist/web/frontend/assets/{wallets-BPtpBguD.js → wallets-DwPVJP85.js} +1 -1
- package/dist/web/frontend/callback/index.html +2 -2
- package/dist/web/frontend/login/index.html +2 -2
- package/dist/web/frontend/networks/index.html +3 -3
- package/dist/web/frontend/wallets/index.html +3 -3
- package/dist/web/server.d.ts +3 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +38 -24
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -18,11 +18,11 @@ Alternatively, you can run it directly through npx (tested with NodeJS v24):
|
|
|
18
18
|
|
|
19
19
|
`npx @canton-network/wallet-gateway-remote -c ./config.json`
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
By default, the service runs on port `3030`, but this can be overridden via the `-p, --port` CLI argument.
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
23
|
+
- The User web interface runs on `localhost:3030`
|
|
24
|
+
- The dApp JSON-RPC API is exposed on `localhost:3030/api/v0/dapp`
|
|
25
|
+
- The User JSON-RPC API is exposed on `localhost:3030/api/v0/user`
|
|
26
26
|
|
|
27
27
|
## Configuration
|
|
28
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAO/E,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAQzD,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;AA6B7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,UAAU,WAAW;;;;;;;;;;;CA8IxB,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
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
|
// Disabled unused vars rule to allow for future implementations
|
|
4
|
+
import { assertConnected } from '@canton-network/core-wallet-auth';
|
|
4
5
|
import buildController from './rpc-gen/index.js';
|
|
5
|
-
import { LedgerClient } from '@canton-network/core-ledger-client';
|
|
6
|
+
import { LedgerClient, } from '@canton-network/core-ledger-client';
|
|
6
7
|
import { v4 } from 'uuid';
|
|
7
8
|
async function prepareSubmission(userId, partyId, synchronizerId, commands, ledgerClient, commandId) {
|
|
8
9
|
const prepareParams = {
|
|
@@ -25,12 +26,29 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
|
|
|
25
26
|
connect: async () => ({
|
|
26
27
|
kernel: kernelInfo,
|
|
27
28
|
isConnected: false,
|
|
28
|
-
userUrl: 'http://localhost:
|
|
29
|
+
userUrl: 'http://localhost:3030/login/', // TODO: pull user URL from config
|
|
29
30
|
}),
|
|
30
31
|
darsAvailable: async () => ({ dars: ['default-dar'] }),
|
|
31
|
-
ledgerApi: async (params) =>
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
ledgerApi: async (params) => {
|
|
33
|
+
const network = await store.getCurrentNetwork();
|
|
34
|
+
const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), assertConnected(context).accessToken, logger);
|
|
35
|
+
let result;
|
|
36
|
+
switch (params.requestMethod) {
|
|
37
|
+
case 'GET':
|
|
38
|
+
result = await ledgerClient.getWithRetry(params.resource);
|
|
39
|
+
break;
|
|
40
|
+
case 'POST':
|
|
41
|
+
result = await ledgerClient.postWithRetry(params.resource, params.body
|
|
42
|
+
? JSON.parse(params.body)
|
|
43
|
+
: undefined);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported request method: ${params.requestMethod}`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
response: JSON.stringify(result),
|
|
50
|
+
};
|
|
51
|
+
},
|
|
34
52
|
prepareExecute: async (params) => {
|
|
35
53
|
const wallet = await store.getPrimaryWallet();
|
|
36
54
|
const network = await store.getCurrentNetwork();
|
|
@@ -54,7 +72,8 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
|
|
|
54
72
|
payload: params.commands,
|
|
55
73
|
});
|
|
56
74
|
return {
|
|
57
|
-
|
|
75
|
+
// TODO: pull user base URL / port from config
|
|
76
|
+
userUrl: `http://localhost:3030/approve/index.html?commandId=${commandId}&partyId=${wallet.partyId}&txHash=${encodeURIComponent(preparedTransactionHash)}&tx=${encodeURIComponent(preparedTransaction)}`,
|
|
58
77
|
};
|
|
59
78
|
},
|
|
60
79
|
prepareReturn: async (params) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import express from 'express';
|
|
1
2
|
import { Store } from '@canton-network/core-wallet-store';
|
|
2
3
|
import { AuthService, AuthAware } from '@canton-network/core-wallet-auth';
|
|
4
|
+
import { Server } from 'http';
|
|
3
5
|
import { NotificationService } from '../notification/NotificationService.js';
|
|
4
6
|
import { KernelInfo } from '../config/Config.js';
|
|
5
|
-
export declare const dapp: (kernelInfo: KernelInfo, notificationService: NotificationService, authService: AuthService, store: Store & AuthAware<Store>) =>
|
|
7
|
+
export declare const dapp: (route: string, app: express.Express, server: Server, kernelInfo: KernelInfo, notificationService: NotificationService, authService: AuthService, store: Store & AuthAware<Store>) => Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
6
8
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dapp-api/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dapp-api/server.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,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;AAIhD,eAAO,MAAM,IAAI,GACb,OAAO,MAAM,EACb,KAAK,OAAO,CAAC,OAAO,EACpB,QAAQ,MAAM,EACd,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,aAAa,WAAW,EACxB,OAAO,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,wFAiElC,CAAA"}
|
package/dist/dapp-api/server.js
CHANGED
|
@@ -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';
|
|
4
3
|
import { dappController } from './controller.js';
|
|
5
4
|
import { pino } from 'pino';
|
|
6
5
|
import { jsonRpcHandler } from '../middleware/jsonRpcHandler.js';
|
|
7
|
-
import {
|
|
8
|
-
import { rpcRateLimit } from '../middleware/rateLimit.js';
|
|
9
|
-
import cors from 'cors';
|
|
10
|
-
import { createServer } from 'http';
|
|
11
|
-
import { Server } from 'socket.io';
|
|
6
|
+
import { Server as SocketIoServer } from 'socket.io';
|
|
12
7
|
const logger = pino({ name: 'main', level: 'debug' });
|
|
13
|
-
export const dapp = (kernelInfo, notificationService, authService, store) => {
|
|
14
|
-
|
|
15
|
-
app.use(cors());
|
|
16
|
-
app.use(express.json());
|
|
17
|
-
app.use('/rpc', rpcRateLimit, jwtAuth(authService, logger), (req, res, next) => jsonRpcHandler({
|
|
8
|
+
export const dapp = (route, app, server, kernelInfo, notificationService, authService, store) => {
|
|
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
|
|
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
|
});
|
|
@@ -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
|
|
27
|
-
|
|
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, 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);
|
|
@@ -35,11 +42,11 @@ test('call connect rpc', async () => {
|
|
|
35
42
|
kernel: {
|
|
36
43
|
id: 'remote-da',
|
|
37
44
|
clientType: 'remote',
|
|
38
|
-
url: 'http://localhost:
|
|
39
|
-
userUrl: 'http://localhost:
|
|
45
|
+
url: 'http://localhost:3030/api/v0/dapp',
|
|
46
|
+
userUrl: 'http://localhost:3030',
|
|
40
47
|
},
|
|
41
48
|
isConnected: false,
|
|
42
|
-
userUrl: 'http://localhost:
|
|
49
|
+
userUrl: 'http://localhost:3030/login/',
|
|
43
50
|
},
|
|
44
51
|
});
|
|
45
52
|
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -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":";AA0CA,QAAA,MAAM,OAAO;;;;;CAAiB,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG,OAAO,OAAO,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const program = new Command()
|
|
|
16
16
|
.version(pkg.version)
|
|
17
17
|
.description('Run a remotely hosted Wallet Gateway')
|
|
18
18
|
.option('-c, --config <path>', 'set config path', './config.json')
|
|
19
|
+
.option('-p, --port [port]', 'set port', '3030')
|
|
19
20
|
.addOption(new Option('-f, --log-format <format>', 'set log format')
|
|
20
21
|
.choices(['json', 'pretty'])
|
|
21
22
|
.default('pretty'))
|
package/dist/init.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { CliOptions } from './index.js';
|
|
2
|
+
export declare function initialize(opts: CliOptions): Promise<void>;
|
|
9
3
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA+BvC,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,iBA2DhD"}
|
package/dist/init.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
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 cors from 'cors';
|
|
6
7
|
import { pino } from 'pino';
|
|
7
|
-
import ViteExpress from 'vite-express';
|
|
8
8
|
import { StoreSql, connection } from '@canton-network/core-wallet-store-sql';
|
|
9
9
|
import { ConfigUtils } from './config/ConfigUtils.js';
|
|
10
10
|
import EventEmitter from 'events';
|
|
@@ -12,12 +12,9 @@ import { SigningProvider } from '@canton-network/core-signing-lib';
|
|
|
12
12
|
import { ParticipantSigningDriver } from '@canton-network/core-signing-participant';
|
|
13
13
|
import { InternalSigningDriver } from '@canton-network/core-signing-internal';
|
|
14
14
|
import { jwtAuthService } from './auth/jwt-auth-service.js';
|
|
15
|
-
import path, { dirname } from 'path';
|
|
16
|
-
import { fileURLToPath } from 'url';
|
|
17
15
|
import express from 'express';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const webPort = Number(process.env.WEB_PORT) || 3002;
|
|
16
|
+
import { jwtAuth } from './middleware/jwtAuth.js';
|
|
17
|
+
import { rpcRateLimit } from './middleware/rateLimit.js';
|
|
21
18
|
class NotificationService {
|
|
22
19
|
constructor(logger) {
|
|
23
20
|
this.logger = logger;
|
|
@@ -53,22 +50,25 @@ export async function initialize(opts) {
|
|
|
53
50
|
});
|
|
54
51
|
const notificationService = new NotificationService(logger);
|
|
55
52
|
const config = ConfigUtils.loadConfigFile(opts.config);
|
|
53
|
+
const port = opts.port ? Number(opts.port) : 3030;
|
|
56
54
|
const store = new StoreSql(connection(config.store), logger);
|
|
57
55
|
const authService = jwtAuthService(store, logger);
|
|
58
56
|
const drivers = {
|
|
59
57
|
[SigningProvider.PARTICIPANT]: new ParticipantSigningDriver(),
|
|
60
58
|
[SigningProvider.WALLET_KERNEL]: new InternalSigningDriver(),
|
|
61
59
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
60
|
+
const app = express();
|
|
61
|
+
app.use(cors()); // TODO: read allowedOrigins from config
|
|
62
|
+
app.use('/api/*splat', express.json());
|
|
63
|
+
app.use('/api/*splat', rpcRateLimit);
|
|
64
|
+
app.use('/api/*splat', jwtAuth(authService, logger));
|
|
65
|
+
const server = app.listen(port, () => {
|
|
66
|
+
logger.info(`Remote Wallet Gateway running at http://localhost:${port}`);
|
|
64
67
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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 };
|
|
68
|
+
// register dapp API handlers
|
|
69
|
+
dapp('/api/v0/dapp', app, server, config.kernel, notificationService, authService, store);
|
|
70
|
+
// register user API handlers
|
|
71
|
+
user('/api/v0/user', app, config.kernel, notificationService, drivers, store);
|
|
72
|
+
// register web handler
|
|
73
|
+
web(app, server);
|
|
74
74
|
}
|
|
@@ -65,7 +65,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
|
|
|
65
65
|
},
|
|
66
66
|
createWallet: async (params) => {
|
|
67
67
|
logger.info(`Allocating party with params: ${JSON.stringify(params)}`);
|
|
68
|
-
const userId = assertConnected(authContext);
|
|
68
|
+
const userId = assertConnected(authContext).userId;
|
|
69
69
|
const notifier = notificationService.getNotifier(userId);
|
|
70
70
|
const network = await store.getCurrentNetwork();
|
|
71
71
|
if (network === undefined) {
|
|
@@ -140,7 +140,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
|
|
|
140
140
|
if (wallet === undefined) {
|
|
141
141
|
throw new Error('No primary wallet found');
|
|
142
142
|
}
|
|
143
|
-
const userId = assertConnected(authContext);
|
|
143
|
+
const userId = assertConnected(authContext).userId;
|
|
144
144
|
if (network === undefined) {
|
|
145
145
|
throw new Error('No network session found');
|
|
146
146
|
}
|
|
@@ -196,7 +196,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
|
|
|
196
196
|
if (transaction === undefined) {
|
|
197
197
|
throw new Error('No transaction found');
|
|
198
198
|
}
|
|
199
|
-
const userId = assertConnected(authContext);
|
|
199
|
+
const userId = assertConnected(authContext).userId;
|
|
200
200
|
if (network === undefined) {
|
|
201
201
|
throw new Error('No network session found');
|
|
202
202
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import express from 'express';
|
|
1
2
|
import { Store } from '@canton-network/core-wallet-store';
|
|
2
|
-
import {
|
|
3
|
+
import { AuthAware } from '@canton-network/core-wallet-auth';
|
|
3
4
|
import { NotificationService } from '../notification/NotificationService.js';
|
|
4
5
|
import { KernelInfo } from '../config/Config.js';
|
|
5
6
|
import { SigningDriverInterface, SigningProvider } from '@canton-network/core-signing-lib';
|
|
6
|
-
export declare const user: (kernelInfo: KernelInfo, notificationService: NotificationService,
|
|
7
|
+
export declare const user: (route: string, app: express.Express, kernelInfo: KernelInfo, notificationService: NotificationService, drivers: Partial<Record<SigningProvider, SigningDriverInterface>>, store: Store & AuthAware<Store>) => express.Express;
|
|
7
8
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/user-api/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/user-api/server.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EACH,sBAAsB,EACtB,eAAe,EAClB,MAAM,kCAAkC,CAAA;AAIzC,eAAO,MAAM,IAAI,GACb,OAAO,MAAM,EACb,KAAK,OAAO,CAAC,OAAO,EACpB,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,SAAS,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC,EACjE,OAAO,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,oBAiBlC,CAAA"}
|
package/dist/user-api/server.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
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';
|
|
4
3
|
import { userController } from './controller.js';
|
|
5
4
|
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
6
|
const logger = pino({ name: 'main', level: 'debug' });
|
|
11
|
-
export const user = (kernelInfo, notificationService,
|
|
12
|
-
|
|
13
|
-
user.use(cors());
|
|
14
|
-
user.use(express.json());
|
|
15
|
-
user.use('/rpc', rpcRateLimit, jwtAuth(authService, logger), (req, res, next) => jsonRpcHandler({
|
|
7
|
+
export const user = (route, app, kernelInfo, notificationService, drivers, store) => {
|
|
8
|
+
app.use(route, (req, res, next) => jsonRpcHandler({
|
|
16
9
|
controller: userController(kernelInfo, store.withAuthContext(req.authContext), notificationService, req.authContext, drivers, logger),
|
|
17
10
|
logger,
|
|
18
11
|
})(req, res, next));
|
|
19
|
-
return
|
|
12
|
+
return app;
|
|
20
13
|
};
|
|
@@ -1,17 +1,14 @@
|
|
|
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, jest, test } from '@jest/globals';
|
|
4
|
+
import cors from 'cors';
|
|
5
|
+
import express from 'express';
|
|
4
6
|
import request from 'supertest';
|
|
5
7
|
import { user } 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';
|
|
10
|
-
const authService = {
|
|
11
|
-
verifyToken: async () => {
|
|
12
|
-
return new Promise((resolve) => resolve({ userId: 'user123', accessToken: 'token123' }));
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
12
|
const configPath = '../test/config.json';
|
|
16
13
|
const config = ConfigUtils.loadConfigFile(configPath);
|
|
17
14
|
const store = new StoreInternal(config.store, pino(sink()));
|
|
@@ -22,10 +19,13 @@ const notificationService = {
|
|
|
22
19
|
removeListener: jest.fn(),
|
|
23
20
|
}),
|
|
24
21
|
};
|
|
25
|
-
test('call
|
|
22
|
+
test('call listNetworks rpc', async () => {
|
|
26
23
|
const drivers = {};
|
|
27
|
-
const
|
|
28
|
-
|
|
24
|
+
const app = express();
|
|
25
|
+
app.use(cors());
|
|
26
|
+
app.use(express.json());
|
|
27
|
+
const response = await request(user('/api/v0/user', app, config.kernel, notificationService, drivers, store))
|
|
28
|
+
.post('/api/v0/user')
|
|
29
29
|
.send({ jsonrpc: '2.0', id: 0, method: 'listNetworks', params: [] })
|
|
30
30
|
.set('Accept', 'application/json');
|
|
31
31
|
const json = await response.body.result;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<title>Wallet Kernel - Approve Write Request</title>
|
|
6
|
-
<script type="module" crossorigin src="/assets/approve-
|
|
6
|
+
<script type="module" crossorigin src="/assets/approve-BHHuvE3i.js"></script>
|
|
7
7
|
<link rel="modulepreload" crossorigin href="/assets/state-manager-BNW0y5PZ.js">
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/index-VtAAU1cN.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/index-BPTkodPz.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/state-DKGJ6EmM.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/rpc-client-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/handle-errors-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/rpc-client-TGo-LOnR.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/handle-errors-BM-xvD4v.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-TZrNw7dA.css">
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-BknZMPaI.css">
|
|
15
15
|
</head>
|