@canton-network/wallet-gateway-remote 1.7.0 → 1.8.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 +18 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +8 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +29 -0
- package/dist/ledger/transaction-service.d.ts +1 -0
- package/dist/ledger/transaction-service.d.ts.map +1 -1
- package/dist/ledger/transaction-service.js +90 -1
- package/dist/ledger/transaction-service.test.js +35 -0
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.d.ts +18 -0
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.d.ts.map +1 -0
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.js +130 -0
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts +1 -0
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.js +15 -0
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.js +88 -0
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +19 -9
- package/dist/user-api/controller.test.js +39 -4
- package/dist/user-api/rpc-gen/typings.d.ts +1 -1
- package/dist/web/frontend/404/index.html +2 -2
- package/dist/web/frontend/activities/index.html +2 -2
- package/dist/web/frontend/approve/index.html +2 -2
- package/dist/web/frontend/assets/{404-C0zn3s5P.js → 404-DAyFyvuw.js} +1 -1
- package/dist/web/frontend/assets/{activities-BuOktGvz.js → activities-BQSNQCP2.js} +1 -1
- package/dist/web/frontend/assets/{addIdentityProvider-D91uvfNz.js → addIdentityProvider-Djya4QfT.js} +1 -1
- package/dist/web/frontend/assets/{addNetwork-DP0iR59C.js → addNetwork-83_QwE58.js} +1 -1
- package/dist/web/frontend/assets/{addParty-DUoPRmUF.js → addParty-CdxWCt0U.js} +3 -3
- package/dist/web/frontend/assets/{approve-BSMrd3FM.js → approve-NcV61aZJ.js} +1 -1
- package/dist/web/frontend/assets/{callback-oLJBpxTj.js → callback-U_3ypVos.js} +1 -1
- package/dist/web/frontend/assets/{identityProviders-DQlERLUf.js → identityProviders-CIk5SJX_.js} +1 -1
- package/dist/web/frontend/assets/{index-D5Xh-WxM.js → index-jHlzHNRR.js} +1 -1
- package/dist/web/frontend/assets/{index-BoxNLwXf.js → index-uxv_f8PV.js} +112 -112
- package/dist/web/frontend/assets/{login-GZTP8nvF.js → login-C_JAX4Df.js} +1 -1
- package/dist/web/frontend/assets/{networks-DHe8V-HP.js → networks-C1kpJNtZ.js} +2 -2
- package/dist/web/frontend/assets/{reviewIdentityProvider-tg2atORE.js → reviewIdentityProvider-BZv-CbZZ.js} +1 -1
- package/dist/web/frontend/assets/{reviewNetwork-ZZv-rrzm.js → reviewNetwork-CnoSJz4N.js} +1 -1
- package/dist/web/frontend/assets/{settings-BC6X9ar3.js → settings-Dt0_RW30.js} +1 -1
- package/dist/web/frontend/callback/index.html +2 -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 +2 -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 +3 -3
- package/dist/web/frontend/parties/index.html +2 -2
- package/dist/web/frontend/settings/index.html +2 -2
- package/package.json +21 -20
package/README.md
CHANGED
|
@@ -70,6 +70,24 @@ The JSON-RPC API specs from `api-specs/` are generated into strongly-typed metho
|
|
|
70
70
|
- `BLOCKDAEMON_API_URL` - The base URL for the Blockdaemon API
|
|
71
71
|
- `BLOCKDAEMON_API_KEY` - Your Blockdaemon API key
|
|
72
72
|
|
|
73
|
+
## Securosys
|
|
74
|
+
|
|
75
|
+
The Securosys TSB signing driver is registered at startup as `securosys` when
|
|
76
|
+
`SECUROSYS_TSB_BASE_URL` is set. Set these environment variables before starting
|
|
77
|
+
the Gateway:
|
|
78
|
+
|
|
79
|
+
- `SECUROSYS_TSB_BASE_URL` — TSB base URL
|
|
80
|
+
- `SECUROSYS_TSB_KEY_MANAGEMENT_API_KEY` — `X-API-KEY` optional for key-management endpoints
|
|
81
|
+
- `SECUROSYS_TSB_KEY_OPERATION_API_KEY` — `X-API-KEY` optional for signing/request endpoints
|
|
82
|
+
- `SECUROSYS_TSB_BEARER_TOKEN` — optional bearer token for access-token mode
|
|
83
|
+
- `SECUROSYS_TSB_MTLS_P12_PATH` — optional client PKCS#12/P12 file for mTLS
|
|
84
|
+
- `SECUROSYS_TSB_MTLS_P12_PASSWORD` — optional PKCS#12/P12 password
|
|
85
|
+
- `SECUROSYS_TSB_KEY_PASSWORD` — optional TSB key password
|
|
86
|
+
- `SECUROSYS_TSB_SIGNATURE_ALGORITHM` — TSB signature algorithm, defaults to `EDDSA`
|
|
87
|
+
|
|
88
|
+
See [`@canton-network/core-signing-securosys`](../../core/signing-securosys/README.md)
|
|
89
|
+
for key creation, public-key, and signature format details.
|
|
90
|
+
|
|
73
91
|
## Postgres connection
|
|
74
92
|
|
|
75
93
|
To create a Postgres database you need to:
|
package/dist/env.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export declare class Env {
|
|
|
5
5
|
static BLOCKDAEMON_API_URL: (fallback: string) => string;
|
|
6
6
|
static BLOCKDAEMON_API_KEY: (fallback: string) => string;
|
|
7
7
|
static BLOCKDAEMON_CAIP2: (fallback: string) => string;
|
|
8
|
+
static SECUROSYS_TSB_BASE_URL: () => string | undefined;
|
|
9
|
+
static SECUROSYS_TSB_KEY_MANAGEMENT_API_KEY: () => string | undefined;
|
|
10
|
+
static SECUROSYS_TSB_KEY_OPERATION_API_KEY: () => string | undefined;
|
|
11
|
+
static SECUROSYS_TSB_BEARER_TOKEN: () => string | undefined;
|
|
12
|
+
static SECUROSYS_TSB_MTLS_P12_PATH: () => string | undefined;
|
|
13
|
+
static SECUROSYS_TSB_MTLS_P12_PASSWORD: () => string | undefined;
|
|
14
|
+
static SECUROSYS_TSB_KEY_PASSWORD: () => string | undefined;
|
|
15
|
+
static SECUROSYS_TSB_SIGNATURE_ALGORITHM: (fallback: string) => string;
|
|
8
16
|
static DFNS_ORG_ID: () => string | undefined;
|
|
9
17
|
static DFNS_BASE_URL: (fallback: string) => string;
|
|
10
18
|
static DFNS_CRED_ID: () => string | undefined;
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IACZ,MAAM,CAAC,kBAAkB,2BAAsC;IAC/D,MAAM,CAAC,iBAAiB,2BAAqC;IAC7D,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,iBAAiB,GAAI,UAAU,MAAM,YACE;IAC9C,MAAM,CAAC,WAAW,2BAA+B;IACjD,MAAM,CAAC,aAAa,GAAI,UAAU,MAAM,YACE;IAC1C,MAAM,CAAC,YAAY,2BAAgC;IACnD,MAAM,CAAC,gBAAgB,2BAAoC;IAC3D,MAAM,CAAC,eAAe,2BAAmC;IAEzD,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClD,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAChE,MAAM,GAAG,SAAS;CAcxB"}
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,qBAAa,GAAG;IACZ,MAAM,CAAC,kBAAkB,2BAAsC;IAC/D,MAAM,CAAC,iBAAiB,2BAAqC;IAC7D,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,mBAAmB,GAAI,UAAU,MAAM,YACE;IAChD,MAAM,CAAC,iBAAiB,GAAI,UAAU,MAAM,YACE;IAC9C,MAAM,CAAC,sBAAsB,2BAA0C;IACvE,MAAM,CAAC,oCAAoC,2BACQ;IACnD,MAAM,CAAC,mCAAmC,2BACQ;IAClD,MAAM,CAAC,0BAA0B,2BACQ;IACzC,MAAM,CAAC,2BAA2B,2BACQ;IAC1C,MAAM,CAAC,+BAA+B,2BACQ;IAC9C,MAAM,CAAC,0BAA0B,2BACQ;IACzC,MAAM,CAAC,iCAAiC,GAAI,UAAU,MAAM,YACE;IAC9D,MAAM,CAAC,WAAW,2BAA+B;IACjD,MAAM,CAAC,aAAa,GAAI,UAAU,MAAM,YACE;IAC1C,MAAM,CAAC,YAAY,2BAAgC;IACnD,MAAM,CAAC,gBAAgB,2BAAoC;IAC3D,MAAM,CAAC,eAAe,2BAAmC;IAEzD,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClD,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,MAAM;IACT,MAAM,CAAC,GAAG,CACN,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAChE,MAAM,GAAG,SAAS;CAcxB"}
|
package/dist/env.js
CHANGED
|
@@ -7,6 +7,14 @@ export class Env {
|
|
|
7
7
|
static { this.BLOCKDAEMON_API_URL = (fallback) => Env.get('BLOCKDAEMON_API_URL', { fallback }); }
|
|
8
8
|
static { this.BLOCKDAEMON_API_KEY = (fallback) => Env.get('BLOCKDAEMON_API_KEY', { fallback }); }
|
|
9
9
|
static { this.BLOCKDAEMON_CAIP2 = (fallback) => Env.get('BLOCKDAEMON_CAIP2', { fallback }); }
|
|
10
|
+
static { this.SECUROSYS_TSB_BASE_URL = () => Env.get('SECUROSYS_TSB_BASE_URL'); }
|
|
11
|
+
static { this.SECUROSYS_TSB_KEY_MANAGEMENT_API_KEY = () => Env.get('SECUROSYS_TSB_KEY_MANAGEMENT_API_KEY'); }
|
|
12
|
+
static { this.SECUROSYS_TSB_KEY_OPERATION_API_KEY = () => Env.get('SECUROSYS_TSB_KEY_OPERATION_API_KEY'); }
|
|
13
|
+
static { this.SECUROSYS_TSB_BEARER_TOKEN = () => Env.get('SECUROSYS_TSB_BEARER_TOKEN'); }
|
|
14
|
+
static { this.SECUROSYS_TSB_MTLS_P12_PATH = () => Env.get('SECUROSYS_TSB_MTLS_P12_PATH'); }
|
|
15
|
+
static { this.SECUROSYS_TSB_MTLS_P12_PASSWORD = () => Env.get('SECUROSYS_TSB_MTLS_P12_PASSWORD'); }
|
|
16
|
+
static { this.SECUROSYS_TSB_KEY_PASSWORD = () => Env.get('SECUROSYS_TSB_KEY_PASSWORD'); }
|
|
17
|
+
static { this.SECUROSYS_TSB_SIGNATURE_ALGORITHM = (fallback) => Env.get('SECUROSYS_TSB_SIGNATURE_ALGORITHM', { fallback }); }
|
|
10
18
|
static { this.DFNS_ORG_ID = () => Env.get('DFNS_ORG_ID'); }
|
|
11
19
|
static { this.DFNS_BASE_URL = (fallback) => Env.get('DFNS_BASE_URL', { fallback }); }
|
|
12
20
|
static { this.DFNS_CRED_ID = () => Env.get('DFNS_CRED_ID'); }
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA4B7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA0MvC,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAuNhE"}
|
package/dist/init.js
CHANGED
|
@@ -12,6 +12,7 @@ import { InternalSigningDriver } from '@canton-network/core-signing-internal';
|
|
|
12
12
|
import DfnsSigningProvider from '@canton-network/core-signing-dfns';
|
|
13
13
|
import FireblocksSigningProvider from '@canton-network/core-signing-fireblocks';
|
|
14
14
|
import BlockdaemonSigningProvider from '@canton-network/core-signing-blockdaemon';
|
|
15
|
+
import SecurosysSigningProvider from '@canton-network/core-signing-securosys';
|
|
15
16
|
import { jwtAuthService } from './auth/jwt-auth-service.js';
|
|
16
17
|
import express from 'express';
|
|
17
18
|
import { jwtAuth } from './middleware/jwtAuth.js';
|
|
@@ -192,6 +193,13 @@ export async function initialize(opts, logger) {
|
|
|
192
193
|
}
|
|
193
194
|
const keyInfo = { apiKey, apiSecret };
|
|
194
195
|
const userApiKeys = new Map([['user', keyInfo]]);
|
|
196
|
+
const securosysKeyManagementApiKey = Env.SECUROSYS_TSB_KEY_MANAGEMENT_API_KEY();
|
|
197
|
+
const securosysKeyOperationApiKey = Env.SECUROSYS_TSB_KEY_OPERATION_API_KEY();
|
|
198
|
+
const securosysBearerToken = Env.SECUROSYS_TSB_BEARER_TOKEN();
|
|
199
|
+
const securosysMtlsP12Path = Env.SECUROSYS_TSB_MTLS_P12_PATH();
|
|
200
|
+
const securosysMtlsP12Password = Env.SECUROSYS_TSB_MTLS_P12_PASSWORD();
|
|
201
|
+
const securosysKeyPassword = Env.SECUROSYS_TSB_KEY_PASSWORD();
|
|
202
|
+
const securosysBaseUrl = Env.SECUROSYS_TSB_BASE_URL();
|
|
195
203
|
const drivers = {
|
|
196
204
|
[SigningProvider.PARTICIPANT]: new ParticipantSigningDriver(),
|
|
197
205
|
[SigningProvider.WALLET_KERNEL]: new InternalSigningDriver(signingStore),
|
|
@@ -206,6 +214,27 @@ export async function initialize(opts, logger) {
|
|
|
206
214
|
caip2: Env.BLOCKDAEMON_CAIP2('canton:testnet'),
|
|
207
215
|
}),
|
|
208
216
|
};
|
|
217
|
+
if (securosysBaseUrl) {
|
|
218
|
+
drivers[SigningProvider.SECUROSYS] = new SecurosysSigningProvider({
|
|
219
|
+
baseUrl: securosysBaseUrl,
|
|
220
|
+
...(securosysKeyManagementApiKey && {
|
|
221
|
+
keyManagementApiKey: securosysKeyManagementApiKey,
|
|
222
|
+
}),
|
|
223
|
+
...(securosysKeyOperationApiKey && {
|
|
224
|
+
keyOperationApiKey: securosysKeyOperationApiKey,
|
|
225
|
+
}),
|
|
226
|
+
...(securosysBearerToken && { bearerToken: securosysBearerToken }),
|
|
227
|
+
...(securosysMtlsP12Path && { mtlsP12Path: securosysMtlsP12Path }),
|
|
228
|
+
...(securosysMtlsP12Password && {
|
|
229
|
+
mtlsP12Password: securosysMtlsP12Password,
|
|
230
|
+
}),
|
|
231
|
+
...(securosysKeyPassword && { keyPassword: securosysKeyPassword }),
|
|
232
|
+
signatureAlgorithm: Env.SECUROSYS_TSB_SIGNATURE_ALGORITHM('EDDSA'),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
logger.warn('Securosys TSB base URL not set — Securosys signing provider will be unavailable');
|
|
237
|
+
}
|
|
209
238
|
if (Env.DFNS_ORG_ID() &&
|
|
210
239
|
Env.DFNS_CRED_ID() &&
|
|
211
240
|
Env.DFNS_PRIVATE_KEY() &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-service.d.ts","sourceRoot":"","sources":["../../src/ledger/transaction-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAOhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EACH,aAAa,EACb,aAAa,EACb,UAAU,EAEb,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AAMjE,OAAO,EACH,WAAW,EAEd,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"transaction-service.d.ts","sourceRoot":"","sources":["../../src/ledger/transaction-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAOhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EACH,aAAa,EACb,aAAa,EACb,UAAU,EAEb,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AAMjE,OAAO,EACH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAGzC,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,aAAa,CAAA;AAW7D,qBAAa,kBAAkB;IAEvB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,QAAQ;gBAHR,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,YAAK,EACnC,QAAQ,EAAE,QAAQ;IAGjB,IAAI,CACb,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACvB,OAAO,CAAC,UAAU,CAAC;IAwDf,OAAO,CACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,aAAa,EAC7B,YAAY,CAAC,EAAE,YAAY,EAC3B,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC;IAkEZ,cAAc,CACvB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,oBAAoB,CAAC;YAyDlB,iCAAiC;YAsBjC,mBAAmB;YAiCnB,oBAAoB;YAyDpB,mBAAmB;YAiHnB,kBAAkB;YAqHlB,YAAY;YA6GZ,iBAAiB;YA4GjB,sBAAsB;YAoDtB,mBAAmB;CAiEpC"}
|
|
@@ -4,6 +4,7 @@ import { LedgerClient } from '@canton-network/core-ledger-client';
|
|
|
4
4
|
import { SigningProvider, } from '@canton-network/core-signing-lib';
|
|
5
5
|
import { ledgerPrepareParams, logDynamically, } from '../utils.js';
|
|
6
6
|
import { AuthTokenProvider, } from '@canton-network/core-wallet-auth';
|
|
7
|
+
import { keyLabelFromPublicKey } from '@canton-network/core-signing-securosys';
|
|
7
8
|
function handleSigningError(result) {
|
|
8
9
|
if ('error' in result) {
|
|
9
10
|
throw new Error(`Error from signing driver: ${result.error_description}`);
|
|
@@ -42,6 +43,9 @@ export class TransactionService {
|
|
|
42
43
|
case SigningProvider.DFNS: {
|
|
43
44
|
return this.signWithDfns(authContext.userId, wallet, signParams);
|
|
44
45
|
}
|
|
46
|
+
case SigningProvider.SECUROSYS: {
|
|
47
|
+
return this.signWithSecurosys(authContext.userId, wallet, signParams);
|
|
48
|
+
}
|
|
45
49
|
default:
|
|
46
50
|
throw new Error(`Unsupported signing provider: ${wallet.signingProviderId}`);
|
|
47
51
|
}
|
|
@@ -72,7 +76,8 @@ export class TransactionService {
|
|
|
72
76
|
case SigningProvider.WALLET_KERNEL:
|
|
73
77
|
case SigningProvider.BLOCKDAEMON:
|
|
74
78
|
case SigningProvider.FIREBLOCKS:
|
|
75
|
-
case SigningProvider.DFNS:
|
|
79
|
+
case SigningProvider.DFNS:
|
|
80
|
+
case SigningProvider.SECUROSYS: {
|
|
76
81
|
if (!executeParams) {
|
|
77
82
|
throw new Error('Execute params are required for external signing');
|
|
78
83
|
}
|
|
@@ -456,6 +461,90 @@ export class TransactionService {
|
|
|
456
461
|
};
|
|
457
462
|
}
|
|
458
463
|
}
|
|
464
|
+
async signWithSecurosys(userId, wallet, signParams) {
|
|
465
|
+
const signingProvider = this.signingDrivers[SigningProvider.SECUROSYS];
|
|
466
|
+
if (!signingProvider) {
|
|
467
|
+
throw new Error('Securosys signing driver not available');
|
|
468
|
+
}
|
|
469
|
+
const driver = signingProvider.controller(userId);
|
|
470
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
471
|
+
let signingResult;
|
|
472
|
+
if (tx.externalTxId) {
|
|
473
|
+
signingResult = await driver
|
|
474
|
+
.getTransaction({
|
|
475
|
+
txId: tx.externalTxId,
|
|
476
|
+
})
|
|
477
|
+
.then(handleSigningError);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
signingResult = await driver
|
|
481
|
+
.signTransaction({
|
|
482
|
+
tx: tx.preparedTransaction,
|
|
483
|
+
txHash: tx.preparedTransactionHash,
|
|
484
|
+
keyIdentifier: {
|
|
485
|
+
id: keyLabelFromPublicKey(wallet.publicKey),
|
|
486
|
+
publicKey: wallet.publicKey,
|
|
487
|
+
},
|
|
488
|
+
})
|
|
489
|
+
.then(handleSigningError);
|
|
490
|
+
}
|
|
491
|
+
const now = new Date();
|
|
492
|
+
logDynamically(this.logger, 'Securosys signing result', {
|
|
493
|
+
info: { transactionId: tx.id, status: signingResult.status },
|
|
494
|
+
debug: { signingResult, tx },
|
|
495
|
+
});
|
|
496
|
+
if (signingResult.status === 'signed') {
|
|
497
|
+
if (!signingResult.signature) {
|
|
498
|
+
throw new Error('No signature returned from signing driver');
|
|
499
|
+
}
|
|
500
|
+
const signedTx = {
|
|
501
|
+
id: tx.id,
|
|
502
|
+
commandId: tx.commandId,
|
|
503
|
+
status: signingResult.status,
|
|
504
|
+
preparedTransaction: tx.preparedTransaction,
|
|
505
|
+
preparedTransactionHash: tx.preparedTransactionHash,
|
|
506
|
+
origin: tx?.origin ?? null,
|
|
507
|
+
...(tx?.createdAt && {
|
|
508
|
+
createdAt: tx.createdAt,
|
|
509
|
+
}),
|
|
510
|
+
signedAt: now,
|
|
511
|
+
externalTxId: signingResult.txId,
|
|
512
|
+
};
|
|
513
|
+
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
514
|
+
this.notifier.emit('txChanged', signedTx);
|
|
515
|
+
return {
|
|
516
|
+
status: signingResult.status,
|
|
517
|
+
signature: signingResult.signature,
|
|
518
|
+
signedBy: wallet.namespace,
|
|
519
|
+
partyId: wallet.partyId,
|
|
520
|
+
externalTxId: signingResult.txId,
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
525
|
+
const pendingTx = {
|
|
526
|
+
id: tx.id,
|
|
527
|
+
commandId: tx.commandId,
|
|
528
|
+
status,
|
|
529
|
+
preparedTransaction: tx.preparedTransaction,
|
|
530
|
+
preparedTransactionHash: tx.preparedTransactionHash,
|
|
531
|
+
externalTxId: signingResult.txId,
|
|
532
|
+
origin: tx?.origin ?? null,
|
|
533
|
+
...(tx?.createdAt && {
|
|
534
|
+
createdAt: tx.createdAt,
|
|
535
|
+
}),
|
|
536
|
+
};
|
|
537
|
+
await this.store.setTransactionStatus(tx.id, status, {
|
|
538
|
+
externalTxId: signingResult.txId,
|
|
539
|
+
});
|
|
540
|
+
this.notifier.emit('txChanged', pendingTx);
|
|
541
|
+
return {
|
|
542
|
+
status: signingResult.status,
|
|
543
|
+
externalTxId: signingResult.txId,
|
|
544
|
+
partyId: wallet.partyId,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
}
|
|
459
548
|
async executeWithParticipant(userId, executeParams, transaction, ledgerClient, network) {
|
|
460
549
|
const { partyId } = executeParams;
|
|
461
550
|
const { commandId } = transaction;
|
|
@@ -285,6 +285,35 @@ describe('TransactionService', () => {
|
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
287
|
});
|
|
288
|
+
describe('securosys', () => {
|
|
289
|
+
it('starts signing and persists the TSB request id when signing is pending', async () => {
|
|
290
|
+
const signTransaction = vi.fn().mockResolvedValue({
|
|
291
|
+
status: 'pending',
|
|
292
|
+
txId: 'tsb-request-1',
|
|
293
|
+
});
|
|
294
|
+
const store = createStore();
|
|
295
|
+
const service = createService(store, {
|
|
296
|
+
[SigningProvider.SECUROSYS]: createDriver({
|
|
297
|
+
signTransaction,
|
|
298
|
+
}),
|
|
299
|
+
}, notifier, logger);
|
|
300
|
+
const result = await service.sign(authContext, walletWithProvider(SigningProvider.SECUROSYS), signParams);
|
|
301
|
+
expect(signTransaction).toHaveBeenCalledWith({
|
|
302
|
+
tx: pendingTransaction.preparedTransaction,
|
|
303
|
+
txHash: pendingTransaction.preparedTransactionHash,
|
|
304
|
+
keyIdentifier: {
|
|
305
|
+
id: wallet.publicKey,
|
|
306
|
+
publicKey: wallet.publicKey,
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
expect(store.setTransactionStatus).toHaveBeenCalledWith(pendingTransaction.id, 'pending', { externalTxId: 'tsb-request-1' });
|
|
310
|
+
expect(result).toEqual({
|
|
311
|
+
status: 'pending',
|
|
312
|
+
externalTxId: 'tsb-request-1',
|
|
313
|
+
partyId: wallet.partyId,
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
});
|
|
288
317
|
it.each([
|
|
289
318
|
{
|
|
290
319
|
name: 'participant',
|
|
@@ -311,6 +340,11 @@ describe('TransactionService', () => {
|
|
|
311
340
|
provider: SigningProvider.DFNS,
|
|
312
341
|
auth: authContext,
|
|
313
342
|
},
|
|
343
|
+
{
|
|
344
|
+
name: 'securosys',
|
|
345
|
+
provider: SigningProvider.SECUROSYS,
|
|
346
|
+
auth: authContext,
|
|
347
|
+
},
|
|
314
348
|
])('rejects signing an already executed transaction for $name', async ({ provider, auth }) => {
|
|
315
349
|
const store = createStore(executedTransaction);
|
|
316
350
|
const service = createService(store, {
|
|
@@ -366,6 +400,7 @@ describe('TransactionService', () => {
|
|
|
366
400
|
SigningProvider.BLOCKDAEMON,
|
|
367
401
|
SigningProvider.FIREBLOCKS,
|
|
368
402
|
SigningProvider.DFNS,
|
|
403
|
+
SigningProvider.SECUROSYS,
|
|
369
404
|
])('executes with the provided signature for %s', async (signingProviderId) => {
|
|
370
405
|
const signedTransaction = {
|
|
371
406
|
...pendingTransaction,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { UserId } from '@canton-network/core-wallet-auth';
|
|
2
|
+
import { Store, Wallet } from '@canton-network/core-wallet-store';
|
|
3
|
+
import { SigningDriverInterface } from '@canton-network/core-signing-lib';
|
|
4
|
+
import { Logger } from 'pino';
|
|
5
|
+
import { PartyAllocationService } from '../../party-allocation-service.js';
|
|
6
|
+
import { PartyHint, Primary } from '../../../user-api/rpc-gen/typings.js';
|
|
7
|
+
import type { WalletAllocator } from '../wallet-allocation-service.js';
|
|
8
|
+
export declare class SecurosysWalletAllocator implements WalletAllocator {
|
|
9
|
+
private store;
|
|
10
|
+
private logger;
|
|
11
|
+
private partyAllocator;
|
|
12
|
+
private signingDriver;
|
|
13
|
+
constructor(store: Store, logger: Logger, partyAllocator: PartyAllocationService, signingDriver: SigningDriverInterface);
|
|
14
|
+
createWallet(userId: UserId, _email: string | undefined, partyHint: PartyHint, primary?: Primary): Promise<Wallet>;
|
|
15
|
+
allocateParty(userId: UserId, _email: string | undefined, existingWallet: Wallet): Promise<void>;
|
|
16
|
+
private finalizeWallet;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=securosys-wallet-allocator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securosys-wallet-allocator.d.ts","sourceRoot":"","sources":["../../../../src/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAEH,sBAAsB,EAEzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAYtE,qBAAa,wBAAyB,YAAW,eAAe;IAExD,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,aAAa;gBAHb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,sBAAsB,EACtC,aAAa,EAAE,sBAAsB;IAG3C,YAAY,CACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,OAAe,GACzB,OAAO,CAAC,MAAM,CAAC;IA4DZ,aAAa,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;YA+DF,cAAc;CA+C/B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { SigningProvider, } from '@canton-network/core-signing-lib';
|
|
4
|
+
import { WALLET_DISABLED_REASON } from '@canton-network/core-types';
|
|
5
|
+
function handleSigningError(result) {
|
|
6
|
+
if ('error' in result) {
|
|
7
|
+
throw new Error(`Error from signing driver: ${result.error_description}`);
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
export class SecurosysWalletAllocator {
|
|
12
|
+
constructor(store, logger, partyAllocator, signingDriver) {
|
|
13
|
+
this.store = store;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.partyAllocator = partyAllocator;
|
|
16
|
+
this.signingDriver = signingDriver;
|
|
17
|
+
}
|
|
18
|
+
async createWallet(userId, _email, partyHint, primary = false) {
|
|
19
|
+
const driver = this.signingDriver.controller(userId);
|
|
20
|
+
const key = await driver
|
|
21
|
+
.createKey({ name: partyHint })
|
|
22
|
+
.then(handleSigningError);
|
|
23
|
+
const namespace = this.partyAllocator.createFingerprintFromKey(key.publicKey);
|
|
24
|
+
const transactions = await this.partyAllocator.generateTopologyTransactions(partyHint, key.publicKey);
|
|
25
|
+
const topologyTransactions = transactions.topologyTransactions ?? [];
|
|
26
|
+
const internalTxId = crypto
|
|
27
|
+
.randomUUID()
|
|
28
|
+
.replace(/-/g, '')
|
|
29
|
+
.substring(0, 16);
|
|
30
|
+
const txPayload = JSON.stringify(topologyTransactions);
|
|
31
|
+
const { status, txId } = await driver
|
|
32
|
+
.signTransaction({
|
|
33
|
+
tx: Buffer.from(txPayload).toString('base64'),
|
|
34
|
+
txHash: transactions.multiHash,
|
|
35
|
+
keyIdentifier: { id: key.id, publicKey: key.publicKey },
|
|
36
|
+
internalTxId,
|
|
37
|
+
})
|
|
38
|
+
.then(handleSigningError);
|
|
39
|
+
const network = await this.store.getCurrentNetwork();
|
|
40
|
+
const walletBase = {
|
|
41
|
+
partyId: `${partyHint}::${namespace}`,
|
|
42
|
+
hint: partyHint,
|
|
43
|
+
namespace,
|
|
44
|
+
signingProviderId: SigningProvider.SECUROSYS,
|
|
45
|
+
networkId: network.id,
|
|
46
|
+
primary,
|
|
47
|
+
publicKey: key.publicKey,
|
|
48
|
+
externalTxId: txId,
|
|
49
|
+
topologyTransactions: topologyTransactions.join(', '),
|
|
50
|
+
rights: [],
|
|
51
|
+
};
|
|
52
|
+
const wallet = await this.finalizeWallet(walletBase, userId, status, txId, topologyTransactions, namespace, driver);
|
|
53
|
+
await this.store.addWallet(wallet);
|
|
54
|
+
return wallet;
|
|
55
|
+
}
|
|
56
|
+
async allocateParty(userId, _email, existingWallet) {
|
|
57
|
+
if (!existingWallet.externalTxId ||
|
|
58
|
+
!existingWallet.topologyTransactions) {
|
|
59
|
+
throw new Error('Existing wallet is missing field externalTxId or topologyTransactions');
|
|
60
|
+
}
|
|
61
|
+
const driver = this.signingDriver.controller(userId);
|
|
62
|
+
const { signature, status, metadata } = await driver
|
|
63
|
+
.getTransaction({ txId: existingWallet.externalTxId })
|
|
64
|
+
.then(handleSigningError);
|
|
65
|
+
let walletUpdate = {
|
|
66
|
+
partyId: existingWallet.partyId,
|
|
67
|
+
networkId: existingWallet.networkId,
|
|
68
|
+
};
|
|
69
|
+
if (status === 'signed') {
|
|
70
|
+
if (!signature) {
|
|
71
|
+
throw new Error('Transaction signed but no signature found in result');
|
|
72
|
+
}
|
|
73
|
+
const partyId = await this.partyAllocator.allocatePartyWithExistingWallet(existingWallet.namespace, existingWallet.topologyTransactions.split(', '), signature, userId);
|
|
74
|
+
walletUpdate = {
|
|
75
|
+
...walletUpdate,
|
|
76
|
+
partyId,
|
|
77
|
+
status: 'allocated',
|
|
78
|
+
reason: '',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else if (status === 'pending') {
|
|
82
|
+
walletUpdate = {
|
|
83
|
+
...walletUpdate,
|
|
84
|
+
status: 'initialized',
|
|
85
|
+
reason: WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_PENDING,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.logger.warn(`Topology transaction for wallet ${existingWallet.partyId} was ${status} with ${JSON.stringify(metadata)}`);
|
|
90
|
+
const reason = status === 'rejected'
|
|
91
|
+
? WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_REJECTED
|
|
92
|
+
: WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_FAILED;
|
|
93
|
+
walletUpdate = {
|
|
94
|
+
...walletUpdate,
|
|
95
|
+
status: 'removed',
|
|
96
|
+
disabled: true,
|
|
97
|
+
reason,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return this.store.updateWallet(walletUpdate);
|
|
101
|
+
}
|
|
102
|
+
async finalizeWallet(walletBase, userId, status, txId, topologyTransactions, namespace, driver) {
|
|
103
|
+
if (status === 'signed') {
|
|
104
|
+
const { signature } = await driver
|
|
105
|
+
.getTransaction({ txId })
|
|
106
|
+
.then(handleSigningError);
|
|
107
|
+
if (!signature) {
|
|
108
|
+
throw new Error('Transaction signed but no signature found in result');
|
|
109
|
+
}
|
|
110
|
+
const partyId = await this.partyAllocator.allocatePartyWithExistingWallet(namespace, topologyTransactions, signature, userId);
|
|
111
|
+
return { ...walletBase, partyId, status: 'allocated' };
|
|
112
|
+
}
|
|
113
|
+
if (status === 'pending') {
|
|
114
|
+
return {
|
|
115
|
+
...walletBase,
|
|
116
|
+
status: 'initialized',
|
|
117
|
+
reason: WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_PENDING,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const reason = status === 'rejected'
|
|
121
|
+
? WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_REJECTED
|
|
122
|
+
: WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_FAILED;
|
|
123
|
+
return {
|
|
124
|
+
...walletBase,
|
|
125
|
+
status: 'removed',
|
|
126
|
+
disabled: true,
|
|
127
|
+
reason,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -17,6 +17,7 @@ export declare class WalletAllocationService {
|
|
|
17
17
|
private readonly fireblocksAllocator?;
|
|
18
18
|
private readonly blockdaemonAllocator?;
|
|
19
19
|
private readonly dfnsAllocator?;
|
|
20
|
+
private readonly securosysAllocator?;
|
|
20
21
|
constructor(store: Store, logger: Logger, partyAllocator: PartyAllocationService, signingDrivers?: Partial<Record<SigningProvider, SigningDriverInterface>>);
|
|
21
22
|
createWallet(authContext: AuthContext, partyHint: PartyHint, primary: Primary, signingProviderId: SigningProvider, vaultName?: VaultName | undefined): Promise<Wallet>;
|
|
22
23
|
allocateParty(authContext: AuthContext, existingWallet: Wallet, signingProviderId: SigningProvider): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-allocation-service.d.ts","sourceRoot":"","sources":["../../../src/ledger/wallet-allocation/wallet-allocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EACH,sBAAsB,EACtB,eAAe,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EACH,SAAS,EACT,OAAO,EACP,SAAS,EACZ,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"wallet-allocation-service.d.ts","sourceRoot":"","sources":["../../../src/ledger/wallet-allocation/wallet-allocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EACH,sBAAsB,EACtB,eAAe,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EACH,SAAS,EACT,OAAO,EACP,SAAS,EACZ,MAAM,mCAAmC,CAAA;AAQ1C,MAAM,WAAW,eAAe;IAC5B,YAAY,CACR,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAClC,OAAO,CAAC,MAAM,CAAC,CAAA;IAClB,aAAa,CACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAAA;IAChB,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAC5D;AAED,qBAAa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA4B;IACjE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAA2B;IAChE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAA4B;IAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAqB;IACpD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAA0B;gBAG1D,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,sBAAsB,EACtC,cAAc,GAAE,OAAO,CACnB,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAC7C;IA2DG,YAAY,CACrB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,eAAe,EAClC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAClC,OAAO,CAAC,MAAM,CAAC;IA+EL,aAAa,CACtB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,eAAe,GACnC,OAAO,CAAC,IAAI,CAAC;IAmEH,SAAS,CAClB,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,eAAe,GACnC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAanC"}
|
|
@@ -6,6 +6,7 @@ import { KernelWalletAllocator } from './signing-providers/kernel-wallet-allocat
|
|
|
6
6
|
import { FireblocksWalletAllocator } from './signing-providers/fireblocks-wallet-allocator.js';
|
|
7
7
|
import { BlockdaemonWalletAllocator } from './signing-providers/blockdaemon-wallet-allocator.js';
|
|
8
8
|
import { DfnsWalletAllocator } from './signing-providers/dfns-wallet-allocator.js';
|
|
9
|
+
import { SecurosysWalletAllocator } from './signing-providers/securosys-wallet-allocator.js';
|
|
9
10
|
export class WalletAllocationService {
|
|
10
11
|
constructor(store, logger, partyAllocator, signingDrivers = {}) {
|
|
11
12
|
this.participantAllocator = new ParticipantWalletAllocator(store, logger, partyAllocator);
|
|
@@ -25,6 +26,10 @@ export class WalletAllocationService {
|
|
|
25
26
|
if (dfnsDriver) {
|
|
26
27
|
this.dfnsAllocator = new DfnsWalletAllocator(store, logger, partyAllocator, dfnsDriver);
|
|
27
28
|
}
|
|
29
|
+
const securosysDriver = signingDrivers[SigningProvider.SECUROSYS];
|
|
30
|
+
if (securosysDriver) {
|
|
31
|
+
this.securosysAllocator = new SecurosysWalletAllocator(store, logger, partyAllocator, securosysDriver);
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
async createWallet(authContext, partyHint, primary, signingProviderId, vaultName) {
|
|
30
35
|
switch (signingProviderId) {
|
|
@@ -56,6 +61,11 @@ export class WalletAllocationService {
|
|
|
56
61
|
throw new Error('Dfns signing driver not available');
|
|
57
62
|
}
|
|
58
63
|
return this.dfnsAllocator.createWallet(authContext.userId, authContext.email, partyHint, primary);
|
|
64
|
+
case SigningProvider.SECUROSYS:
|
|
65
|
+
if (!this.securosysAllocator) {
|
|
66
|
+
throw new Error('Securosys signing driver not available');
|
|
67
|
+
}
|
|
68
|
+
return this.securosysAllocator.createWallet(authContext.userId, authContext.email, partyHint, primary);
|
|
59
69
|
default:
|
|
60
70
|
throw new Error(`Unsupported signing provider: ${signingProviderId}`);
|
|
61
71
|
}
|
|
@@ -87,6 +97,11 @@ export class WalletAllocationService {
|
|
|
87
97
|
throw new Error('Dfns signing driver not available');
|
|
88
98
|
}
|
|
89
99
|
return this.dfnsAllocator.allocateParty(authContext.userId, authContext.email, existingWallet);
|
|
100
|
+
case SigningProvider.SECUROSYS:
|
|
101
|
+
if (!this.securosysAllocator) {
|
|
102
|
+
throw new Error('Securosys signing driver not available');
|
|
103
|
+
}
|
|
104
|
+
return this.securosysAllocator.allocateParty(authContext.userId, authContext.email, existingWallet);
|
|
90
105
|
default:
|
|
91
106
|
throw new Error(`Unsupported signing provider: ${signingProviderId}`);
|
|
92
107
|
}
|
|
@@ -100,6 +100,30 @@ function createDfnsDriver(options) {
|
|
|
100
100
|
}),
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
+
function createSecurosysDriver(options) {
|
|
104
|
+
const createKeyResult = options.createKeyResult ?? {
|
|
105
|
+
id: 'key-1',
|
|
106
|
+
publicKey: 'securosys-pk',
|
|
107
|
+
};
|
|
108
|
+
const signTransactionResult = options.signTransactionResult ?? {
|
|
109
|
+
status: 'pending',
|
|
110
|
+
txId: 'tx-1',
|
|
111
|
+
};
|
|
112
|
+
const getTransactionResult = options.getTransactionResult ?? signTransactionResult;
|
|
113
|
+
return {
|
|
114
|
+
controller: vi.fn().mockReturnValue({
|
|
115
|
+
createKey: vi
|
|
116
|
+
.fn()
|
|
117
|
+
.mockResolvedValue(createKeyResult),
|
|
118
|
+
signTransaction: vi
|
|
119
|
+
.fn()
|
|
120
|
+
.mockResolvedValue(signTransactionResult),
|
|
121
|
+
getTransaction: vi
|
|
122
|
+
.fn()
|
|
123
|
+
.mockResolvedValue(getTransactionResult),
|
|
124
|
+
}),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
103
127
|
describe('WalletAllocationService', () => {
|
|
104
128
|
let mockLogger;
|
|
105
129
|
let mockStore;
|
|
@@ -830,4 +854,68 @@ describe('WalletAllocationService', () => {
|
|
|
830
854
|
});
|
|
831
855
|
});
|
|
832
856
|
});
|
|
857
|
+
describe('Securosys', () => {
|
|
858
|
+
it('throws when Securosys signing driver not available', async () => {
|
|
859
|
+
const serviceWithoutSecurosys = createService({});
|
|
860
|
+
await expect(serviceWithoutSecurosys.createWallet(authContext, 'alice', false, SigningProvider.SECUROSYS)).rejects.toThrow('Securosys signing driver not available');
|
|
861
|
+
});
|
|
862
|
+
it('createWallet returns initialized when signTransaction returns pending', async () => {
|
|
863
|
+
const driver = createSecurosysDriver({
|
|
864
|
+
createKeyResult: {
|
|
865
|
+
id: 'alice-key',
|
|
866
|
+
publicKey: 'securosys-pk',
|
|
867
|
+
},
|
|
868
|
+
signTransactionResult: {
|
|
869
|
+
status: 'pending',
|
|
870
|
+
txId: 'tsb-request-1',
|
|
871
|
+
},
|
|
872
|
+
});
|
|
873
|
+
const serviceWithSecurosys = createService({
|
|
874
|
+
[SigningProvider.SECUROSYS]: driver,
|
|
875
|
+
});
|
|
876
|
+
const result = await serviceWithSecurosys.createWallet(authContext, 'alice', false, SigningProvider.SECUROSYS);
|
|
877
|
+
const controller = vi.mocked(driver.controller).mock.results[0]
|
|
878
|
+
?.value;
|
|
879
|
+
expect(controller.createKey).toHaveBeenCalledWith({
|
|
880
|
+
name: 'alice',
|
|
881
|
+
});
|
|
882
|
+
expect(controller.signTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
883
|
+
txHash: 'hash',
|
|
884
|
+
keyIdentifier: {
|
|
885
|
+
id: 'alice-key',
|
|
886
|
+
publicKey: 'securosys-pk',
|
|
887
|
+
},
|
|
888
|
+
}));
|
|
889
|
+
expect(result.status).toBe('initialized');
|
|
890
|
+
expect(result.reason).toBe(WALLET_DISABLED_REASON.TOPOLOGY_TRANSACTION_PENDING);
|
|
891
|
+
expect(result.signingProviderId).toBe(SigningProvider.SECUROSYS);
|
|
892
|
+
expect(result.externalTxId).toBe('tsb-request-1');
|
|
893
|
+
expect(mockStore.addWallet).toHaveBeenCalled();
|
|
894
|
+
});
|
|
895
|
+
it('allocateParty updates wallet to allocated when transaction is signed', async () => {
|
|
896
|
+
const serviceWithSecurosys = createService({
|
|
897
|
+
[SigningProvider.SECUROSYS]: createSecurosysDriver({
|
|
898
|
+
getTransactionResult: {
|
|
899
|
+
txId: 'tsb-request-1',
|
|
900
|
+
status: 'signed',
|
|
901
|
+
signature: 'sig-base64',
|
|
902
|
+
},
|
|
903
|
+
}),
|
|
904
|
+
});
|
|
905
|
+
mockPartyAllocator.allocatePartyWithExistingWallet.mockResolvedValue('alice::namespace');
|
|
906
|
+
await serviceWithSecurosys.allocateParty(authContext, createWallet('alice::fingerprint', {
|
|
907
|
+
signingProviderId: SigningProvider.SECUROSYS,
|
|
908
|
+
namespace: 'fingerprint',
|
|
909
|
+
topologyTransactions: 'tx1',
|
|
910
|
+
externalTxId: 'tsb-request-1',
|
|
911
|
+
}), SigningProvider.SECUROSYS);
|
|
912
|
+
expect(mockPartyAllocator.allocatePartyWithExistingWallet).toHaveBeenCalledWith('fingerprint', ['tx1'], 'sig-base64', authContext.userId);
|
|
913
|
+
expect(mockStore.updateWallet).toHaveBeenCalledWith({
|
|
914
|
+
networkId: 'network1',
|
|
915
|
+
partyId: 'alice::namespace',
|
|
916
|
+
status: 'allocated',
|
|
917
|
+
reason: '',
|
|
918
|
+
});
|
|
919
|
+
});
|
|
920
|
+
});
|
|
833
921
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/user-api/controller.ts"],"names":[],"mappings":"AAgDA,OAAO,EAAE,KAAK,EAAW,MAAM,mCAAmC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAEH,WAAW,EAKd,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAanE,eAAO,MAAM,cAAc,GACvB,YAAY,UAAU,EACtB,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,aAAa,WAAW,GAAG,SAAS,EACpC,SAAS,cAAc,EACvB,SAAS,MAAM,EACf,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/user-api/controller.ts"],"names":[],"mappings":"AAgDA,OAAO,EAAE,KAAK,EAAW,MAAM,mCAAmC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAEH,WAAW,EAKd,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAanE,eAAO,MAAM,cAAc,GACvB,YAAY,UAAU,EACtB,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,aAAa,WAAW,GAAG,SAAS,EACpC,SAAS,cAAc,EACvB,SAAS,MAAM,EACf,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4mCvB,CAAA"}
|