@canton-network/wallet-gateway-remote 1.12.0 → 1.13.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 +105 -29
- package/dist/auth/jwt-auth-service.d.ts.map +1 -1
- package/dist/auth/jwt-auth-service.js +150 -77
- package/dist/config/Config.d.ts +146 -22
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.js +120 -6
- package/dist/config/ConfigUtils.d.ts.map +1 -1
- package/dist/config/ConfigUtils.js +3 -1
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +14 -19
- package/dist/dapp-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/dapp-api/rpc-gen/typings.d.ts +3 -3
- package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/sse-sink.d.ts.map +1 -1
- package/dist/env.d.ts +1 -24
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +0 -23
- package/dist/example-config.d.ts +40 -4
- package/dist/example-config.d.ts.map +1 -1
- package/dist/example-config.js +44 -8
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +75 -28
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +24 -110
- package/dist/ledger/party-allocation-service.d.ts +1 -4
- package/dist/ledger/party-allocation-service.d.ts.map +1 -1
- package/dist/ledger/party-allocation-service.js +1 -3
- package/dist/ledger/self-issued-auth-service.d.ts +15 -15
- package/dist/ledger/self-issued-auth-service.d.ts.map +1 -1
- package/dist/ledger/self-issued-auth-service.js +44 -43
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/blockdaemon-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/dfns-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/kernel-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/participant-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts +2 -2
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.js +2 -2
- package/dist/ledger/wallet-sync-service.d.ts +3 -0
- package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.js +143 -28
- package/dist/middleware/apiKeyAuth.d.ts.map +1 -1
- package/dist/middleware/apiKeyAuth.js +4 -8
- package/dist/middleware/errorHandler.d.ts +1 -1
- package/dist/middleware/errorHandler.d.ts.map +1 -1
- package/dist/middleware/jsonRpcHandler.d.ts.map +1 -1
- package/dist/middleware/jsonRpcHandler.js +3 -3
- package/dist/middleware/jwtAuth.d.ts +1 -1
- package/dist/middleware/jwtAuth.d.ts.map +1 -1
- package/dist/middleware/jwtAuth.js +17 -2
- package/dist/middleware/securityHeaders.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.d.ts +3 -3
- package/dist/middleware/sessionHandler.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.js +8 -8
- package/dist/signing/service-account-session.d.ts.map +1 -1
- package/dist/signing/service-account-session.js +1 -1
- package/dist/signing/signing-worker.d.ts +1 -1
- package/dist/signing/signing-worker.d.ts.map +1 -1
- package/dist/signing/signing-worker.js +2 -5
- package/dist/signing-providers-registration.d.ts +6 -0
- package/dist/signing-providers-registration.d.ts.map +1 -0
- package/dist/signing-providers-registration.js +216 -0
- package/dist/user-api/controller.d.ts +6 -3
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +218 -94
- package/dist/user-api/rpc-gen/index.d.ts +18 -9
- package/dist/user-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/index.js +6 -3
- package/dist/user-api/rpc-gen/schemas.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/schemas.js +42 -10
- package/dist/user-api/rpc-gen/typings.d.ts +67 -45
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/user-api/server.d.ts.map +1 -1
- package/dist/web/frontend/404/index.html +2 -2
- package/dist/web/frontend/activities/index.html +3 -3
- package/dist/web/frontend/api-keys/add/index.html +2 -2
- package/dist/web/frontend/api-keys/index.html +2 -2
- package/dist/web/frontend/approve/index.html +4 -3
- package/dist/web/frontend/assets/404-D6hNG1H8.js +5 -0
- package/dist/web/frontend/assets/{activities-HZnPjlMp.js → activities-CSaNJ4Bw.js} +2 -2
- package/dist/web/frontend/assets/{addApiKey-BvkCtUF3.js → addApiKey-IKOYP6lC.js} +3 -3
- package/dist/web/frontend/assets/addIdentityProvider-CnRS1C3U.js +28 -0
- package/dist/web/frontend/assets/addNetwork-Wq0K3t5Z.js +38 -0
- package/dist/web/frontend/assets/{addParty-Cdoed_Yx.js → addParty-B0GaqKvG.js} +3 -2
- package/dist/web/frontend/assets/{apiKeys-BwV6ylWL.js → apiKeys-BgJyxg5r.js} +2 -2
- package/dist/web/frontend/assets/approve-kKlT_54l.js +27 -0
- package/dist/web/frontend/assets/callback-83Lr1QFW.js +7 -0
- package/dist/web/frontend/assets/common-BkYw_tO_.js +31 -0
- package/dist/web/frontend/assets/{editParty-OOjTHFay.js → editParty-DU9eMclk.js} +3 -2
- package/dist/web/frontend/assets/{identityProviders-BxJAq1Ne.js → identityProviders-sWmbKlSu.js} +2 -2
- package/dist/web/frontend/assets/{index-D1Brmwbg.js → index-AvzB2hln.js} +3 -3
- package/dist/web/frontend/assets/index-BF3EIXoM.js +2 -0
- package/dist/web/frontend/assets/{index-CG_aFABR.js → index-CGK8ht7_.js} +1 -1
- package/dist/web/frontend/assets/index-DRQ0oWml.js +4814 -0
- package/dist/web/frontend/assets/index-NgSpx7q_.js +3 -0
- package/dist/web/frontend/assets/login-BqK1nbQm.js +11 -0
- package/dist/web/frontend/assets/{networks-CBprjUF5.js → networks-C62lWsP4.js} +3 -3
- package/dist/web/frontend/assets/{reviewIdentityProvider-CCmKgN8N.js → reviewIdentityProvider-pILqo6EV.js} +4 -4
- package/dist/web/frontend/assets/{reviewNetwork-CX8Bmuf3.js → reviewNetwork-DZOWqkuG.js} +3 -3
- package/dist/web/frontend/assets/selfIssuedLogin-DarXIpvS.js +81 -0
- package/dist/web/frontend/assets/signMessage-k9b_lLxh.js +23 -0
- package/dist/web/frontend/callback/index.html +3 -2
- package/dist/web/frontend/identity-providers/add/index.html +2 -2
- package/dist/web/frontend/identity-providers/index.html +2 -2
- package/dist/web/frontend/identity-providers/review/index.html +2 -2
- package/dist/web/frontend/index.html +1 -1
- package/dist/web/frontend/login/index.html +3 -2
- package/dist/web/frontend/networks/add/index.html +2 -2
- package/dist/web/frontend/networks/index.html +2 -2
- package/dist/web/frontend/networks/review/index.html +2 -2
- package/dist/web/frontend/parties/add/index.html +5 -5
- package/dist/web/frontend/parties/edit/index.html +5 -5
- package/dist/web/frontend/parties/index.html +3 -3
- package/dist/web/frontend/{onboarding → self-issued-login}/index.html +6 -5
- package/dist/web/frontend/sign-message/index.html +2 -2
- package/dist/web/route-inputs.js +1 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +1 -1
- package/package.json +49 -51
- package/dist/auth/jwt-auth-service.test.d.ts +0 -2
- package/dist/auth/jwt-auth-service.test.d.ts.map +0 -1
- package/dist/auth/jwt-auth-service.test.js +0 -659
- package/dist/config/Config.test.d.ts +0 -2
- package/dist/config/Config.test.d.ts.map +0 -1
- package/dist/config/Config.test.js +0 -26
- package/dist/dapp-api/controller.test.d.ts +0 -2
- package/dist/dapp-api/controller.test.d.ts.map +0 -1
- package/dist/dapp-api/controller.test.js +0 -531
- package/dist/dapp-api/server.test.d.ts +0 -2
- package/dist/dapp-api/server.test.d.ts.map +0 -1
- package/dist/dapp-api/server.test.js +0 -79
- package/dist/dapp-api/sse-sink.test.d.ts +0 -2
- package/dist/dapp-api/sse-sink.test.d.ts.map +0 -1
- package/dist/dapp-api/sse-sink.test.js +0 -30
- package/dist/ledger/party-allocation-service.test.d.ts +0 -2
- package/dist/ledger/party-allocation-service.test.d.ts.map +0 -1
- package/dist/ledger/party-allocation-service.test.js +0 -105
- package/dist/ledger/self-issued-auth-service.test.d.ts +0 -2
- package/dist/ledger/self-issued-auth-service.test.d.ts.map +0 -1
- package/dist/ledger/self-issued-auth-service.test.js +0 -454
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.d.ts +0 -2
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.d.ts.map +0 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.js +0 -1005
- package/dist/ledger/wallet-sync-service.test.d.ts +0 -2
- package/dist/ledger/wallet-sync-service.test.d.ts.map +0 -1
- package/dist/ledger/wallet-sync-service.test.js +0 -1017
- package/dist/middleware/apiKeyAuth.test.d.ts +0 -2
- package/dist/middleware/apiKeyAuth.test.d.ts.map +0 -1
- package/dist/middleware/apiKeyAuth.test.js +0 -126
- package/dist/middleware/errorHandler.test.d.ts +0 -2
- package/dist/middleware/errorHandler.test.d.ts.map +0 -1
- package/dist/middleware/errorHandler.test.js +0 -138
- package/dist/middleware/jsonRpcHandler.test.d.ts +0 -2
- package/dist/middleware/jsonRpcHandler.test.d.ts.map +0 -1
- package/dist/middleware/jsonRpcHandler.test.js +0 -377
- package/dist/middleware/jwtAuth.test.d.ts +0 -2
- package/dist/middleware/jwtAuth.test.d.ts.map +0 -1
- package/dist/middleware/jwtAuth.test.js +0 -100
- package/dist/middleware/rateLimit.test.d.ts +0 -2
- package/dist/middleware/rateLimit.test.d.ts.map +0 -1
- package/dist/middleware/rateLimit.test.js +0 -56
- package/dist/middleware/securityHeaders.test.d.ts +0 -2
- package/dist/middleware/securityHeaders.test.d.ts.map +0 -1
- package/dist/middleware/securityHeaders.test.js +0 -18
- package/dist/middleware/sessionHandler.test.d.ts +0 -2
- package/dist/middleware/sessionHandler.test.d.ts.map +0 -1
- package/dist/middleware/sessionHandler.test.js +0 -215
- package/dist/signing/service-account-session.test.d.ts +0 -2
- package/dist/signing/service-account-session.test.d.ts.map +0 -1
- package/dist/signing/service-account-session.test.js +0 -88
- package/dist/signing/signing-worker.test.d.ts +0 -2
- package/dist/signing/signing-worker.test.d.ts.map +0 -1
- package/dist/signing/signing-worker.test.js +0 -158
- package/dist/user-api/controller.test.d.ts +0 -2
- package/dist/user-api/controller.test.d.ts.map +0 -1
- package/dist/user-api/controller.test.js +0 -1228
- package/dist/user-api/server.test.d.ts +0 -2
- package/dist/user-api/server.test.d.ts.map +0 -1
- package/dist/user-api/server.test.js +0 -117
- package/dist/user-api/token-network-matching.test.d.ts +0 -2
- package/dist/user-api/token-network-matching.test.d.ts.map +0 -1
- package/dist/user-api/token-network-matching.test.js +0 -66
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -24
- package/dist/web/frontend/assets/404-B1XXXMXN.js +0 -5
- package/dist/web/frontend/assets/addIdentityProvider-Dvjma837.js +0 -28
- package/dist/web/frontend/assets/addNetwork-Cahac0uo.js +0 -38
- package/dist/web/frontend/assets/approve-B0nIfe2y.js +0 -26
- package/dist/web/frontend/assets/callback-BieW5Ux2.js +0 -7
- package/dist/web/frontend/assets/common-Bv9twGrA.js +0 -31
- package/dist/web/frontend/assets/index-Bo6MnlYI.js +0 -2
- package/dist/web/frontend/assets/index-pMOoiNFq.js +0 -4887
- package/dist/web/frontend/assets/login-BHxgJEz_.js +0 -11
- package/dist/web/frontend/assets/onboarding-ChmWs-TC.js +0 -84
- package/dist/web/frontend/assets/signMessage-BN_6S5FV.js +0 -79
- package/dist/web/route-inputs.test.d.ts +0 -2
- package/dist/web/route-inputs.test.d.ts.map +0 -1
- package/dist/web/route-inputs.test.js +0 -30
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
// Copyright (c) 2025-2026 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
|
-
/*
|
|
4
|
+
/* oxlint-disable no-unused-vars */
|
|
5
5
|
import { LedgerClient } from '@canton-network/core-ledger-client';
|
|
6
6
|
import buildController from './rpc-gen/index.js';
|
|
7
7
|
import { assertConnected, authSchema, AuthTokenProvider, idpSchema, resolveAuthIdentityProviderId, assertIsConnected, } from '@canton-network/core-wallet-auth';
|
|
8
|
-
import { isRpcError, SigningProvider } from '@canton-network/core-signing-lib';
|
|
8
|
+
import { isRpcError, SIGN_MESSAGE_CAPABLE_SIGNING_PROVIDERS, SigningProvider, } from '@canton-network/core-signing-lib';
|
|
9
9
|
import { PartyAllocationService } from '../ledger/party-allocation-service.js';
|
|
10
10
|
import { WalletAllocationService } from '../ledger/wallet-allocation/wallet-allocation-service.js';
|
|
11
11
|
import { WalletSyncService } from '../ledger/wallet-sync-service.js';
|
|
12
|
-
import {
|
|
13
|
-
import { assertSelfIssuedOnboardingAllowed, createSelfIssuedAuthService, } from '../ledger/self-issued-auth-service.js';
|
|
12
|
+
import { assertLoginAllowed, createSelfIssuedAuthService, } from '../ledger/self-issued-auth-service.js';
|
|
14
13
|
import { providerErrors, rpcErrors } from '@canton-network/core-rpc-errors';
|
|
15
|
-
import
|
|
14
|
+
import { randomBytes, createHash, timingSafeEqual } from 'crypto';
|
|
16
15
|
import { assertTokenClaimsMatchNetwork } from './token-network-matching.js';
|
|
17
16
|
import { TransactionService, logDynamically, networkStatus, } from '@canton-network/core-wallet-services';
|
|
18
17
|
export const userController = (kernelInfo, userUrl, store, notificationService, authContext, drivers, _logger, hashingSchemeVersion, adminUserId) => {
|
|
@@ -33,9 +32,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
33
32
|
throw new Error('Unauthorized: only the admin user can perform this operation');
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
function
|
|
35
|
+
function requireSelfIssuedLoginSession() {
|
|
37
36
|
if (!authContext || authContext.isApiKey || !authContext.sessionId) {
|
|
38
|
-
throw new Error('No
|
|
37
|
+
throw new Error('No self-issued login session found');
|
|
39
38
|
}
|
|
40
39
|
return {
|
|
41
40
|
userId: authContext.userId,
|
|
@@ -89,12 +88,11 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
89
88
|
throw new Error('No admin auth configured');
|
|
90
89
|
}
|
|
91
90
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
92
|
-
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
91
|
+
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
93
92
|
const partyAllocator = new PartyAllocationService({
|
|
94
93
|
synchronizerId: network.synchronizerId,
|
|
95
94
|
accessTokenProvider: adminAccessTokenProvider,
|
|
96
95
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
97
|
-
logger,
|
|
98
96
|
});
|
|
99
97
|
const walletAllocationService = new WalletAllocationService(store, logger, partyAllocator, drivers);
|
|
100
98
|
if (!drivers[params.signingProviderId])
|
|
@@ -191,13 +189,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
191
189
|
if (auth.method !== 'self_signed') {
|
|
192
190
|
throw new Error('Network does not use self_signed authentication');
|
|
193
191
|
}
|
|
194
|
-
const clientSecretMatch =
|
|
195
|
-
.createHash('sha256')
|
|
192
|
+
const clientSecretMatch = timingSafeEqual(createHash('sha256')
|
|
196
193
|
.update(params.clientSecret, 'utf8')
|
|
197
|
-
.digest(),
|
|
198
|
-
.createHash('sha256')
|
|
199
|
-
.update(auth.clientSecret, 'utf8')
|
|
200
|
-
.digest());
|
|
194
|
+
.digest(), createHash('sha256').update(auth.clientSecret, 'utf8').digest());
|
|
201
195
|
if (!clientSecretMatch) {
|
|
202
196
|
throw providerErrors.unauthorized({
|
|
203
197
|
message: 'Invalid client secret',
|
|
@@ -220,7 +214,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
220
214
|
scope: auth.scope,
|
|
221
215
|
audience: auth.audience,
|
|
222
216
|
},
|
|
223
|
-
}
|
|
217
|
+
}).getAccessToken();
|
|
224
218
|
return { accessToken };
|
|
225
219
|
},
|
|
226
220
|
addIdp: async (params) => {
|
|
@@ -256,12 +250,11 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
256
250
|
throw new Error('No admin auth configured');
|
|
257
251
|
}
|
|
258
252
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
259
|
-
const adminTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
253
|
+
const adminTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
260
254
|
const partyAllocator = new PartyAllocationService({
|
|
261
255
|
synchronizerId: network.synchronizerId,
|
|
262
256
|
accessTokenProvider: adminTokenProvider,
|
|
263
257
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
264
|
-
logger,
|
|
265
258
|
});
|
|
266
259
|
const walletAllocationService = new WalletAllocationService(store, logger, partyAllocator, drivers);
|
|
267
260
|
if (!drivers[signingProviderId]) {
|
|
@@ -270,8 +263,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
270
263
|
const wallet = await walletAllocationService.createWallet(authContext, partyHint, primary ?? false, signingProviderId, params.keyName);
|
|
271
264
|
const ledgerClient = new LedgerClient({
|
|
272
265
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
273
|
-
|
|
274
|
-
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken, logger),
|
|
266
|
+
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken),
|
|
275
267
|
});
|
|
276
268
|
const service = new WalletSyncService(store, ledgerClient, authContext, logger);
|
|
277
269
|
await service.syncRights();
|
|
@@ -283,7 +275,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
283
275
|
const walletWithUpdatedRights = wallets.find((w) => w.partyId === wallet.partyId && w.networkId === network.id);
|
|
284
276
|
return { wallet: walletWithUpdatedRights ?? wallet };
|
|
285
277
|
},
|
|
286
|
-
|
|
278
|
+
startSelfIssuedLoginSession: async (params) => {
|
|
287
279
|
const username = params.username.trim();
|
|
288
280
|
if (!username) {
|
|
289
281
|
throw new Error('username is required');
|
|
@@ -296,8 +288,8 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
296
288
|
userId: username,
|
|
297
289
|
accessToken: '',
|
|
298
290
|
});
|
|
299
|
-
await
|
|
300
|
-
const sessionId =
|
|
291
|
+
await assertLoginAllowed(authAwareStore, network, username);
|
|
292
|
+
const sessionId = crypto.randomUUID();
|
|
301
293
|
await onboardingStore.setSession({
|
|
302
294
|
id: sessionId,
|
|
303
295
|
origin: params.origin,
|
|
@@ -305,16 +297,16 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
305
297
|
});
|
|
306
298
|
return { sessionId };
|
|
307
299
|
},
|
|
308
|
-
|
|
309
|
-
const service = await createSelfIssuedAuthService(authAwareStore,
|
|
310
|
-
return service.
|
|
300
|
+
getSelfIssuedLoginMode: async (_params) => {
|
|
301
|
+
const service = await createSelfIssuedAuthService(authAwareStore, requireSelfIssuedLoginSession(), drivers, logger);
|
|
302
|
+
return service.getLoginMode();
|
|
311
303
|
},
|
|
312
304
|
createSelfIssuedWallet: async (params) => {
|
|
313
305
|
const { signingProviderId } = params;
|
|
314
306
|
if (!drivers[signingProviderId]) {
|
|
315
307
|
throw new Error(`Signing provider ${signingProviderId} not supported`);
|
|
316
308
|
}
|
|
317
|
-
const service = await createSelfIssuedAuthService(authAwareStore,
|
|
309
|
+
const service = await createSelfIssuedAuthService(authAwareStore, requireSelfIssuedLoginSession(), drivers, logger);
|
|
318
310
|
const wallet = await service.createWallet({
|
|
319
311
|
partyHint: params.partyHint,
|
|
320
312
|
signingProviderId: signingProviderId,
|
|
@@ -322,32 +314,38 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
322
314
|
return { wallet };
|
|
323
315
|
},
|
|
324
316
|
allocateSelfIssuedWallet: async (params) => {
|
|
325
|
-
const service = await createSelfIssuedAuthService(authAwareStore,
|
|
326
|
-
const allocated = await service.allocateParty(
|
|
327
|
-
partyId: params.partyId,
|
|
328
|
-
});
|
|
317
|
+
const service = await createSelfIssuedAuthService(authAwareStore, requireSelfIssuedLoginSession(), drivers, logger);
|
|
318
|
+
const allocated = await service.allocateParty(params.partyId);
|
|
329
319
|
return { wallet: allocated };
|
|
330
320
|
},
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
const service = await createSelfIssuedAuthService(authAwareStore,
|
|
334
|
-
const { wallet, accessToken, session } = await service.
|
|
335
|
-
partyId: params.partyId,
|
|
336
|
-
});
|
|
321
|
+
completeSelfIssuedLogin: async (params) => {
|
|
322
|
+
const selfIssuedLoginSession = requireSelfIssuedLoginSession();
|
|
323
|
+
const service = await createSelfIssuedAuthService(authAwareStore, selfIssuedLoginSession, drivers, logger);
|
|
324
|
+
const { wallet, accessToken, session } = await service.completeLogin(params.partyId);
|
|
337
325
|
const connectedContext = {
|
|
338
|
-
userId:
|
|
326
|
+
userId: selfIssuedLoginSession.userId,
|
|
339
327
|
accessToken,
|
|
340
328
|
};
|
|
341
329
|
const scopedStore = authAwareStore.withAuthContext(connectedContext);
|
|
342
330
|
const network = await scopedStore.getCurrentNetwork();
|
|
343
331
|
const ledgerClient = new LedgerClient({
|
|
344
332
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
345
|
-
|
|
346
|
-
accessTokenProvider: AuthTokenProvider.fromToken(accessToken, logger),
|
|
333
|
+
accessTokenProvider: AuthTokenProvider.fromToken(accessToken),
|
|
347
334
|
});
|
|
348
335
|
await emitSessionConnected(session.id, network, connectedContext, ledgerClient);
|
|
349
336
|
return { wallet, accessToken, sessionId: session.id };
|
|
350
337
|
},
|
|
338
|
+
removeSelfIssuedLoginSession: async (_params) => {
|
|
339
|
+
const session = requireSelfIssuedLoginSession();
|
|
340
|
+
await authAwareStore
|
|
341
|
+
.withAuthContext({
|
|
342
|
+
userId: session.userId,
|
|
343
|
+
accessToken: '',
|
|
344
|
+
sessionId: session.sessionId,
|
|
345
|
+
})
|
|
346
|
+
.removeSelfIssuedLoginSession(session.sessionId);
|
|
347
|
+
return null;
|
|
348
|
+
},
|
|
351
349
|
allocatePartyForWallet: async (params) => {
|
|
352
350
|
assertIsConnected(authContext);
|
|
353
351
|
const network = await store.getCurrentNetwork();
|
|
@@ -363,12 +361,11 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
363
361
|
throw new Error(`Wallet not found for party ${params.partyId}`);
|
|
364
362
|
}
|
|
365
363
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
366
|
-
const accessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
364
|
+
const accessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
367
365
|
const partyAllocator = new PartyAllocationService({
|
|
368
366
|
synchronizerId: network.synchronizerId,
|
|
369
367
|
accessTokenProvider,
|
|
370
368
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
371
|
-
logger,
|
|
372
369
|
});
|
|
373
370
|
const walletAllocationService = new WalletAllocationService(store, logger, partyAllocator, drivers);
|
|
374
371
|
const signingProviderId = existingWallet.signingProviderId;
|
|
@@ -378,8 +375,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
378
375
|
await walletAllocationService.allocateParty(authContext, existingWallet, signingProviderId);
|
|
379
376
|
const ledgerClient = new LedgerClient({
|
|
380
377
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
381
|
-
|
|
382
|
-
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken, logger),
|
|
378
|
+
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken),
|
|
383
379
|
});
|
|
384
380
|
const service = new WalletSyncService(store, ledgerClient, authContext, logger);
|
|
385
381
|
await service.syncRights();
|
|
@@ -422,7 +418,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
422
418
|
throw new Error('No active session found');
|
|
423
419
|
}
|
|
424
420
|
const notifier = notificationService.getNotifier(session.id);
|
|
425
|
-
const transactionService = new TransactionService(store,
|
|
421
|
+
const transactionService = new TransactionService(store, drivers, notifier, hashingSchemeVersion);
|
|
426
422
|
logDynamically(logger, 'signing transaction with params', {
|
|
427
423
|
info: { transactionId: signParams.transactionId },
|
|
428
424
|
debug: { signParams, wallet, authContext },
|
|
@@ -455,7 +451,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
455
451
|
const emitFailedAndPersist = async (details) => {
|
|
456
452
|
// Best-effort: make sure listeners see a terminal state.
|
|
457
453
|
try {
|
|
458
|
-
await store.setMessageRawStatus(pending.id, 'failed'
|
|
454
|
+
await store.setMessageRawStatus(pending.id, 'failed', {
|
|
455
|
+
failureReason: details,
|
|
456
|
+
});
|
|
459
457
|
}
|
|
460
458
|
catch {
|
|
461
459
|
// ignore (e.g. record removed concurrently)
|
|
@@ -467,6 +465,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
467
465
|
// Preserve the original error message for the caller/UI.
|
|
468
466
|
throw new Error(details);
|
|
469
467
|
};
|
|
468
|
+
if (!pending.message) {
|
|
469
|
+
return await emitFailedAndPersist(`Message request ${pending.id} has an empty message.`);
|
|
470
|
+
}
|
|
470
471
|
const wallet = (await store.getWallets()).find((w) => w.partyId === pending.partyId);
|
|
471
472
|
if (!wallet) {
|
|
472
473
|
return await emitFailedAndPersist(`No wallet found for partyId ${pending.partyId} (from message request ${pending.id})`);
|
|
@@ -474,46 +475,157 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
474
475
|
if (wallet.publicKey !== pending.publicKey) {
|
|
475
476
|
return await emitFailedAndPersist(`Wallet public key changed for partyId ${pending.partyId}; refusing to sign message request ${pending.id}`);
|
|
476
477
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
return await emitFailedAndPersist(`signMessage is only supported for ${SigningProvider.WALLET_KERNEL} wallets, got ${wallet.signingProviderId}`);
|
|
478
|
+
if (!SIGN_MESSAGE_CAPABLE_SIGNING_PROVIDERS.includes(wallet.signingProviderId)) {
|
|
479
|
+
return await emitFailedAndPersist(`signMessage is only supported for ${SIGN_MESSAGE_CAPABLE_SIGNING_PROVIDERS.join(', ')} wallets, got ${wallet.signingProviderId}`);
|
|
480
480
|
}
|
|
481
|
-
const driver = drivers[
|
|
481
|
+
const driver = drivers[wallet.signingProviderId]?.controller(userId);
|
|
482
482
|
if (!driver) {
|
|
483
|
-
return await emitFailedAndPersist(
|
|
483
|
+
return await emitFailedAndPersist(`${wallet.signingProviderId} signing driver not available`);
|
|
484
484
|
}
|
|
485
485
|
const result = await driver.signMessage({
|
|
486
486
|
message: pending.message,
|
|
487
487
|
keyIdentifier: { publicKey: wallet.publicKey },
|
|
488
|
+
internalTxId: pending.id,
|
|
488
489
|
});
|
|
489
490
|
if (isRpcError(result)) {
|
|
490
|
-
await
|
|
491
|
+
return await emitFailedAndPersist(result.error_description);
|
|
492
|
+
}
|
|
493
|
+
if (result.status === 'signed') {
|
|
494
|
+
if (!result.signature) {
|
|
495
|
+
return await emitFailedAndPersist('No signature returned from signing driver');
|
|
496
|
+
}
|
|
497
|
+
await store.setMessageRawStatus(pending.id, 'signed', {
|
|
498
|
+
signedAt: new Date(),
|
|
499
|
+
signature: result.signature,
|
|
500
|
+
externalTxId: result.txId,
|
|
501
|
+
});
|
|
491
502
|
notifier.emit('messageSignature', {
|
|
492
|
-
status: '
|
|
503
|
+
status: 'signed',
|
|
493
504
|
messageId: pending.id,
|
|
505
|
+
signature: result.signature,
|
|
494
506
|
});
|
|
495
|
-
|
|
507
|
+
return {
|
|
508
|
+
status: result.status,
|
|
509
|
+
signature: result.signature,
|
|
510
|
+
publicKey: wallet.publicKey,
|
|
511
|
+
...(result.txId && { externalTxId: result.txId }),
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
if (result.status === 'pending' && result.txId) {
|
|
515
|
+
await store.setMessageRawStatus(pending.id, 'awaiting-signature', { externalTxId: result.txId });
|
|
516
|
+
return {
|
|
517
|
+
publicKey: wallet.publicKey,
|
|
518
|
+
status: 'awaiting-signature',
|
|
519
|
+
externalTxId: result.txId,
|
|
520
|
+
};
|
|
496
521
|
}
|
|
497
|
-
if (
|
|
498
|
-
|
|
522
|
+
if (result.status === 'failed' || result.status === 'rejected') {
|
|
523
|
+
const failureReason = `Signing provider returned status: ${result.status}`;
|
|
524
|
+
await store.setMessageRawStatus(pending.id, 'failed', {
|
|
525
|
+
failureReason,
|
|
526
|
+
...(result.txId && { externalTxId: result.txId }),
|
|
527
|
+
});
|
|
499
528
|
notifier.emit('messageSignature', {
|
|
500
529
|
status: 'failed',
|
|
501
530
|
messageId: pending.id,
|
|
502
531
|
});
|
|
503
|
-
|
|
532
|
+
return {
|
|
533
|
+
publicKey: wallet.publicKey,
|
|
534
|
+
status: 'failed',
|
|
535
|
+
failureReason,
|
|
536
|
+
...(result.txId && { externalTxId: result.txId }),
|
|
537
|
+
};
|
|
504
538
|
}
|
|
505
|
-
await
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
539
|
+
return await emitFailedAndPersist(`Signing provider returned status: ${result.status} without a txId`);
|
|
540
|
+
},
|
|
541
|
+
getSignMessageStatus: async (params) => {
|
|
542
|
+
const message = await store.getMessageRaw(params.messageId);
|
|
543
|
+
if (!message) {
|
|
544
|
+
throw new Error(`Message signing request not found with id: ${params.messageId}`);
|
|
545
|
+
}
|
|
546
|
+
if (!message.externalTxId ||
|
|
547
|
+
message.status !== 'awaiting-signature') {
|
|
548
|
+
return {
|
|
549
|
+
status: message.status,
|
|
550
|
+
...(message.externalTxId && {
|
|
551
|
+
externalTxId: message.externalTxId,
|
|
552
|
+
}),
|
|
553
|
+
...(message.signature && { signature: message.signature }),
|
|
554
|
+
...(message.failureReason && {
|
|
555
|
+
failureReason: message.failureReason,
|
|
556
|
+
}),
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const wallet = (await store.getWallets()).find((w) => w.partyId === message.partyId);
|
|
560
|
+
if (!wallet) {
|
|
561
|
+
throw new Error(`No wallet found for partyId ${message.partyId}`);
|
|
562
|
+
}
|
|
563
|
+
assertIsConnected(authContext);
|
|
564
|
+
const provider = wallet.signingProviderId;
|
|
565
|
+
const signingProvider = drivers[provider];
|
|
566
|
+
if (!signingProvider) {
|
|
567
|
+
throw new Error(`No driver found for provider ${provider}`);
|
|
568
|
+
}
|
|
569
|
+
if (provider === SigningProvider.BLOCKDAEMON &&
|
|
570
|
+
!authContext.email) {
|
|
571
|
+
throw new Error('Invalid auth context (missing email) for SigningProvider BlockDaemon');
|
|
572
|
+
}
|
|
573
|
+
const session = await store.getSession(authContext.accessToken);
|
|
574
|
+
if (!session) {
|
|
575
|
+
throw new Error('No active session found');
|
|
576
|
+
}
|
|
577
|
+
const notifier = notificationService.getNotifier(session.id);
|
|
578
|
+
const controllerId = provider === SigningProvider.BLOCKDAEMON
|
|
579
|
+
? authContext.email
|
|
580
|
+
: authContext.userId;
|
|
581
|
+
const signingDriver = signingProvider.controller(controllerId);
|
|
582
|
+
const signingResult = await signingDriver.getTransaction({
|
|
583
|
+
userId: controllerId,
|
|
584
|
+
txId: message.externalTxId,
|
|
513
585
|
});
|
|
586
|
+
if (isRpcError(signingResult)) {
|
|
587
|
+
throw new Error(signingResult.error_description);
|
|
588
|
+
}
|
|
589
|
+
if (signingResult.status === 'signed') {
|
|
590
|
+
if (!signingResult.signature) {
|
|
591
|
+
throw new Error('No signature returned from signing driver');
|
|
592
|
+
}
|
|
593
|
+
await store.setMessageRawStatus(message.id, 'signed', {
|
|
594
|
+
signedAt: new Date(),
|
|
595
|
+
signature: signingResult.signature,
|
|
596
|
+
externalTxId: message.externalTxId,
|
|
597
|
+
});
|
|
598
|
+
notifier.emit('messageSignature', {
|
|
599
|
+
status: 'signed',
|
|
600
|
+
messageId: message.id,
|
|
601
|
+
signature: signingResult.signature,
|
|
602
|
+
});
|
|
603
|
+
return {
|
|
604
|
+
status: 'signed',
|
|
605
|
+
externalTxId: message.externalTxId,
|
|
606
|
+
signature: signingResult.signature,
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (signingResult.status === 'failed' ||
|
|
610
|
+
signingResult.status === 'rejected') {
|
|
611
|
+
const failureReason = `Signing provider returned status: ${signingResult.status}`;
|
|
612
|
+
await store.setMessageRawStatus(message.id, 'failed', {
|
|
613
|
+
externalTxId: message.externalTxId,
|
|
614
|
+
failureReason,
|
|
615
|
+
});
|
|
616
|
+
notifier.emit('messageSignature', {
|
|
617
|
+
status: 'failed',
|
|
618
|
+
messageId: message.id,
|
|
619
|
+
});
|
|
620
|
+
return {
|
|
621
|
+
status: 'failed',
|
|
622
|
+
externalTxId: message.externalTxId,
|
|
623
|
+
failureReason,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
514
626
|
return {
|
|
515
|
-
|
|
516
|
-
|
|
627
|
+
status: 'awaiting-signature',
|
|
628
|
+
externalTxId: message.externalTxId,
|
|
517
629
|
};
|
|
518
630
|
},
|
|
519
631
|
getMessageToSign: async (params) => {
|
|
@@ -536,6 +648,12 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
536
648
|
signedAt: message.signedAt.toISOString(),
|
|
537
649
|
}),
|
|
538
650
|
...(message.signature && { signature: message.signature }),
|
|
651
|
+
...(message.externalTxId && {
|
|
652
|
+
externalTxId: message.externalTxId,
|
|
653
|
+
}),
|
|
654
|
+
...(message.failureReason && {
|
|
655
|
+
failureReason: message.failureReason,
|
|
656
|
+
}),
|
|
539
657
|
},
|
|
540
658
|
};
|
|
541
659
|
},
|
|
@@ -556,6 +674,12 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
556
674
|
signedAt: message.signedAt.toISOString(),
|
|
557
675
|
}),
|
|
558
676
|
...(message.signature && { signature: message.signature }),
|
|
677
|
+
...(message.externalTxId && {
|
|
678
|
+
externalTxId: message.externalTxId,
|
|
679
|
+
}),
|
|
680
|
+
...(message.failureReason && {
|
|
681
|
+
failureReason: message.failureReason,
|
|
682
|
+
}),
|
|
559
683
|
})),
|
|
560
684
|
};
|
|
561
685
|
},
|
|
@@ -564,8 +688,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
564
688
|
if (!message) {
|
|
565
689
|
throw new Error(`Message signing request not found with id: ${params.messageId}`);
|
|
566
690
|
}
|
|
567
|
-
if (message.status !== 'pending'
|
|
568
|
-
|
|
691
|
+
if (message.status !== 'pending' &&
|
|
692
|
+
message.status !== 'awaiting-signature') {
|
|
693
|
+
throw new Error(`Cannot delete message with status '${message.status}'. Only pending or awaiting-signature messages can be deleted.`);
|
|
569
694
|
}
|
|
570
695
|
assertIsConnected(authContext);
|
|
571
696
|
const userId = authContext.userId;
|
|
@@ -596,7 +721,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
596
721
|
throw new Error('No transaction found');
|
|
597
722
|
}
|
|
598
723
|
assertIsConnected(authContext);
|
|
599
|
-
const accessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken
|
|
724
|
+
const accessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken);
|
|
600
725
|
if (network === undefined) {
|
|
601
726
|
throw new Error('No network session found');
|
|
602
727
|
}
|
|
@@ -607,10 +732,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
607
732
|
const notifier = notificationService.getNotifier(session.id);
|
|
608
733
|
const ledgerClient = new LedgerClient({
|
|
609
734
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
610
|
-
logger,
|
|
611
735
|
accessTokenProvider,
|
|
612
736
|
});
|
|
613
|
-
const transactionService = new TransactionService(store,
|
|
737
|
+
const transactionService = new TransactionService(store, drivers, notifier, hashingSchemeVersion);
|
|
614
738
|
logDynamically(logger, 'executing transaction with params', {
|
|
615
739
|
info: { transactionId: executeParams.transactionId },
|
|
616
740
|
debug: {
|
|
@@ -631,7 +755,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
631
755
|
try {
|
|
632
756
|
assertIsConnected(authContext);
|
|
633
757
|
const { accessToken } = authContext;
|
|
634
|
-
const newSessionId =
|
|
758
|
+
const newSessionId = crypto.randomUUID();
|
|
635
759
|
logger.info(`Adding session with ID ${newSessionId} for network ${params.networkId}`);
|
|
636
760
|
const network = await store.getNetwork(params.networkId);
|
|
637
761
|
const idp = await store.getIdp(network.identityProviderId);
|
|
@@ -644,8 +768,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
644
768
|
});
|
|
645
769
|
const ledgerClient = new LedgerClient({
|
|
646
770
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
647
|
-
|
|
648
|
-
accessTokenProvider: AuthTokenProvider.fromToken(accessToken, logger),
|
|
771
|
+
accessTokenProvider: AuthTokenProvider.fromToken(accessToken),
|
|
649
772
|
});
|
|
650
773
|
const status = await emitSessionConnected(newSessionId, network, authContext, ledgerClient);
|
|
651
774
|
// Only bootstrap wallets the first time a session is created.
|
|
@@ -665,12 +788,11 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
665
788
|
throw new Error('No admin auth configured');
|
|
666
789
|
}
|
|
667
790
|
const adminIdp = await getIdpForAuth(network, network.adminAuth);
|
|
668
|
-
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(adminIdp, network.adminAuth
|
|
791
|
+
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(adminIdp, network.adminAuth);
|
|
669
792
|
const partyAllocator = new PartyAllocationService({
|
|
670
793
|
synchronizerId: network.synchronizerId,
|
|
671
794
|
accessTokenProvider: adminAccessTokenProvider,
|
|
672
795
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
673
|
-
logger,
|
|
674
796
|
});
|
|
675
797
|
const service = new WalletSyncService(store, ledgerClient, authContext, logger, drivers, partyAllocator);
|
|
676
798
|
await service.syncWallets();
|
|
@@ -732,8 +854,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
732
854
|
const network = await store.getNetwork(session.network);
|
|
733
855
|
const ledgerClient = new LedgerClient({
|
|
734
856
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
735
|
-
|
|
736
|
-
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken, logger),
|
|
857
|
+
accessTokenProvider: AuthTokenProvider.fromToken(authContext.accessToken),
|
|
737
858
|
});
|
|
738
859
|
const idp = await store.getIdp(network.identityProviderId);
|
|
739
860
|
const status = await networkStatus(ledgerClient);
|
|
@@ -758,21 +879,19 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
758
879
|
syncWallets: async function () {
|
|
759
880
|
const network = await store.getCurrentNetwork();
|
|
760
881
|
const { userId } = assertConnected(authContext);
|
|
761
|
-
const userAccessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken
|
|
882
|
+
const userAccessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken);
|
|
762
883
|
if (!network.adminAuth) {
|
|
763
884
|
throw new Error('No admin auth configured');
|
|
764
885
|
}
|
|
765
886
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
766
|
-
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
887
|
+
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
767
888
|
const partyAllocator = new PartyAllocationService({
|
|
768
889
|
synchronizerId: network.synchronizerId,
|
|
769
890
|
accessTokenProvider: adminAccessTokenProvider,
|
|
770
891
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
771
|
-
logger,
|
|
772
892
|
});
|
|
773
893
|
const userLedger = new LedgerClient({
|
|
774
894
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
775
|
-
logger,
|
|
776
895
|
accessTokenProvider: userAccessTokenProvider,
|
|
777
896
|
});
|
|
778
897
|
const service = new WalletSyncService(store, userLedger, authContext, logger, drivers, partyAllocator);
|
|
@@ -790,21 +909,19 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
790
909
|
isWalletSyncNeeded: async () => {
|
|
791
910
|
const network = await store.getCurrentNetwork();
|
|
792
911
|
assertConnected(authContext);
|
|
793
|
-
const userAccessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken
|
|
912
|
+
const userAccessTokenProvider = AuthTokenProvider.fromToken(authContext.accessToken);
|
|
794
913
|
if (!network.adminAuth) {
|
|
795
914
|
throw new Error('No admin auth configured');
|
|
796
915
|
}
|
|
797
916
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
798
|
-
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
917
|
+
const adminAccessTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
799
918
|
const partyAllocator = new PartyAllocationService({
|
|
800
919
|
synchronizerId: network.synchronizerId,
|
|
801
920
|
accessTokenProvider: adminAccessTokenProvider,
|
|
802
921
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
803
|
-
logger,
|
|
804
922
|
});
|
|
805
923
|
const userLedger = new LedgerClient({
|
|
806
924
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
807
|
-
logger,
|
|
808
925
|
accessTokenProvider: userAccessTokenProvider,
|
|
809
926
|
});
|
|
810
927
|
const service = new WalletSyncService(store, userLedger, authContext, logger, drivers, partyAllocator);
|
|
@@ -837,6 +954,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
837
954
|
...(transaction.externalTxId && {
|
|
838
955
|
externalTxId: transaction.externalTxId,
|
|
839
956
|
}),
|
|
957
|
+
...(transaction.failureReason && {
|
|
958
|
+
failureReason: transaction.failureReason,
|
|
959
|
+
}),
|
|
840
960
|
};
|
|
841
961
|
},
|
|
842
962
|
listTransactions: async function (params) {
|
|
@@ -864,6 +984,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
864
984
|
...(transaction.externalTxId && {
|
|
865
985
|
externalTxId: transaction.externalTxId,
|
|
866
986
|
}),
|
|
987
|
+
...(transaction.failureReason && {
|
|
988
|
+
failureReason: transaction.failureReason,
|
|
989
|
+
}),
|
|
867
990
|
}));
|
|
868
991
|
if (page.nextCursor === null) {
|
|
869
992
|
return { transactions: txs, count: txCount };
|
|
@@ -899,10 +1022,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
899
1022
|
generateApiKey: async (params) => {
|
|
900
1023
|
const userId = assertConnected(authContext).userId;
|
|
901
1024
|
const network = await store.getCurrentNetwork();
|
|
902
|
-
const apiKeyId =
|
|
903
|
-
const generatedApiKey =
|
|
904
|
-
const hashedApiKey =
|
|
905
|
-
.createHash('sha256')
|
|
1025
|
+
const apiKeyId = crypto.randomUUID();
|
|
1026
|
+
const generatedApiKey = randomBytes(32).toString('hex');
|
|
1027
|
+
const hashedApiKey = createHash('sha256')
|
|
906
1028
|
.update(generatedApiKey)
|
|
907
1029
|
.digest('hex');
|
|
908
1030
|
const storedApiKey = {
|
|
@@ -941,6 +1063,9 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
941
1063
|
await store.removeApiKey(params.id);
|
|
942
1064
|
return null;
|
|
943
1065
|
},
|
|
1066
|
+
listSigningProviders: async () => ({
|
|
1067
|
+
signingProviders: Object.keys(drivers),
|
|
1068
|
+
}),
|
|
944
1069
|
listSigningProviderKeys: async (params) => {
|
|
945
1070
|
return await getSigningProviderKeys(params);
|
|
946
1071
|
},
|
|
@@ -959,12 +1084,11 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
959
1084
|
throw new Error('No admin auth configured');
|
|
960
1085
|
}
|
|
961
1086
|
const idp = await getIdpForAuth(network, network.adminAuth);
|
|
962
|
-
const adminTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth
|
|
1087
|
+
const adminTokenProvider = AuthTokenProvider.fromGatewayConfig(idp, network.adminAuth);
|
|
963
1088
|
const partyAllocator = new PartyAllocationService({
|
|
964
1089
|
synchronizerId: network.synchronizerId,
|
|
965
1090
|
accessTokenProvider: adminTokenProvider,
|
|
966
1091
|
httpLedgerUrl: network.ledgerApi.baseUrl,
|
|
967
|
-
logger,
|
|
968
1092
|
});
|
|
969
1093
|
const normalizedKey = partyAllocator.normalizePublicKeyToBase64(publicKey);
|
|
970
1094
|
if (!normalizedKey) {
|
|
@@ -1012,7 +1136,7 @@ export const userController = (kernelInfo, userUrl, store, notificationService,
|
|
|
1012
1136
|
throw new Error('No active session found');
|
|
1013
1137
|
}
|
|
1014
1138
|
const notifier = notificationService.getNotifier(session.id);
|
|
1015
|
-
const transactionService = new TransactionService(store,
|
|
1139
|
+
const transactionService = new TransactionService(store, drivers, notifier, hashingSchemeVersion);
|
|
1016
1140
|
const result = await transactionService.refreshTransaction(authContext, wallet, tx.id);
|
|
1017
1141
|
logDynamically(logger, `refreshed transaction status`, {
|
|
1018
1142
|
info: { transactionId: tx.id, status: result.status },
|