@canton-network/wallet-gateway-remote 1.11.3 → 1.12.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/dist/auth/jwt-auth-service.d.ts +5 -4
- package/dist/auth/jwt-auth-service.d.ts.map +1 -1
- package/dist/auth/jwt-auth-service.js +76 -8
- package/dist/auth/jwt-auth-service.test.js +193 -0
- package/dist/config/Config.d.ts +58 -7
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.test.js +9 -2
- package/dist/config/ConfigUtils.d.ts +1 -1
- package/dist/config/ConfigUtils.d.ts.map +1 -1
- package/dist/config/ConfigUtils.js +43 -8
- package/dist/dapp-api/controller.d.ts +5 -7
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +31 -21
- package/dist/dapp-api/controller.test.js +12 -16
- package/dist/dapp-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/dapp-api/rpc-gen/schemas.d.ts +3 -0
- package/dist/dapp-api/rpc-gen/schemas.d.ts.map +1 -0
- package/dist/dapp-api/rpc-gen/schemas.js +201 -0
- package/dist/dapp-api/rpc-gen/typings.d.ts +8 -1
- package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/dapp-api/server.d.ts +8 -9
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/server.js +7 -43
- package/dist/dapp-api/server.test.js +41 -2
- package/dist/dapp-api/sse-sink.d.ts +18 -0
- package/dist/dapp-api/sse-sink.d.ts.map +1 -0
- package/dist/dapp-api/sse-sink.js +27 -0
- package/dist/dapp-api/sse-sink.test.d.ts +2 -0
- package/dist/dapp-api/sse-sink.test.d.ts.map +1 -0
- package/dist/dapp-api/sse-sink.test.js +30 -0
- package/dist/env.d.ts +0 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/init.d.ts +2 -2
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +13 -4
- package/dist/ledger/party-allocation-service.d.ts +3 -3
- package/dist/ledger/party-allocation-service.d.ts.map +1 -1
- package/dist/ledger/self-issued-auth-service.d.ts +50 -0
- package/dist/ledger/self-issued-auth-service.d.ts.map +1 -0
- package/dist/ledger/self-issued-auth-service.js +263 -0
- package/dist/ledger/self-issued-auth-service.test.d.ts +2 -0
- package/dist/ledger/self-issued-auth-service.test.d.ts.map +1 -0
- package/dist/ledger/self-issued-auth-service.test.js +454 -0
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.d.ts +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/bitgo-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/blockdaemon-wallet-allocator.d.ts +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/blockdaemon-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/blockdaemon-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/dfns-wallet-allocator.d.ts +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/dfns-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/dfns-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.d.ts +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/kernel-wallet-allocator.d.ts +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/kernel-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/kernel-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/participant-wallet-allocator.d.ts +6 -6
- 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 +7 -7
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/securosys-wallet-allocator.js +1 -1
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts +6 -6
- package/dist/ledger/wallet-allocation/wallet-allocation-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.d.ts +12 -9
- package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.js +49 -15
- package/dist/ledger/wallet-sync-service.test.js +171 -11
- package/dist/middleware/apiKeyAuth.d.ts +3 -3
- package/dist/middleware/apiKeyAuth.d.ts.map +1 -1
- package/dist/middleware/apiKeyAuth.js +2 -2
- package/dist/middleware/errorHandler.d.ts +7 -1
- package/dist/middleware/errorHandler.d.ts.map +1 -1
- package/dist/middleware/errorHandler.js +85 -1
- package/dist/middleware/errorHandler.test.js +39 -1
- package/dist/middleware/jsonRpcHandler.d.ts +6 -4
- package/dist/middleware/jsonRpcHandler.d.ts.map +1 -1
- package/dist/middleware/jsonRpcHandler.js +46 -7
- package/dist/middleware/jsonRpcHandler.test.js +101 -1
- package/dist/middleware/jwtAuth.d.ts +2 -2
- package/dist/middleware/jwtAuth.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.d.ts +6 -4
- package/dist/middleware/sessionHandler.d.ts.map +1 -1
- package/dist/middleware/sessionHandler.js +25 -1
- package/dist/middleware/sessionHandler.test.js +61 -1
- package/dist/signing/service-account-session.d.ts +3 -3
- package/dist/signing/service-account-session.d.ts.map +1 -1
- package/dist/signing/service-account-session.js +2 -2
- package/dist/signing/service-account-session.test.js +1 -2
- package/dist/signing/signing-worker.d.ts +18 -16
- package/dist/signing/signing-worker.d.ts.map +1 -1
- package/dist/signing/signing-worker.js +18 -12
- package/dist/signing/signing-worker.test.js +10 -7
- package/dist/user-api/controller.d.ts +11 -7
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +249 -86
- package/dist/user-api/controller.test.js +145 -17
- package/dist/user-api/rpc-gen/index.d.ts +18 -0
- package/dist/user-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/index.js +6 -0
- package/dist/user-api/rpc-gen/schemas.d.ts +3 -0
- package/dist/user-api/rpc-gen/schemas.d.ts.map +1 -0
- package/dist/user-api/rpc-gen/schemas.js +1035 -0
- package/dist/user-api/rpc-gen/typings.d.ts +202 -28
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/user-api/server.d.ts +7 -8
- package/dist/user-api/server.d.ts.map +1 -1
- package/dist/user-api/server.js +2 -0
- package/dist/user-api/server.test.js +3 -2
- package/dist/user-api/token-network-matching.d.ts +2 -2
- package/dist/user-api/token-network-matching.d.ts.map +1 -1
- package/dist/user-api/token-network-matching.js +9 -7
- package/dist/utils.d.ts +0 -29
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -57
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -5
- 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 +3 -3
- package/dist/web/frontend/assets/404-B1XXXMXN.js +5 -0
- package/dist/web/frontend/assets/{activities-DSP_NZCE.js → activities-HZnPjlMp.js} +2 -2
- package/dist/web/frontend/assets/{addApiKey-Zv2CS3ub.js → addApiKey-BvkCtUF3.js} +3 -3
- package/dist/web/frontend/assets/addIdentityProvider-Dvjma837.js +28 -0
- package/dist/web/frontend/assets/{addNetwork-B620CvC-.js → addNetwork-Cahac0uo.js} +2 -2
- package/dist/web/frontend/assets/addParty-Cdoed_Yx.js +13 -0
- package/dist/web/frontend/assets/{apiKeys-ohQpjexi.js → apiKeys-BwV6ylWL.js} +3 -3
- package/dist/web/frontend/assets/approve-B0nIfe2y.js +26 -0
- package/dist/web/frontend/assets/callback-BieW5Ux2.js +7 -0
- package/dist/web/frontend/assets/{common-BCDg7K0r.js → common-Bv9twGrA.js} +2 -2
- package/dist/web/frontend/assets/editParty-OOjTHFay.js +14 -0
- package/dist/web/frontend/assets/{identityProviders-C26I4FyE.js → identityProviders-BxJAq1Ne.js} +2 -2
- package/dist/web/frontend/assets/index-Bo6MnlYI.js +2 -0
- package/dist/web/frontend/assets/index-CG_aFABR.js +1 -0
- package/dist/web/frontend/assets/index-D1Brmwbg.js +93 -0
- package/dist/web/frontend/assets/index-pMOoiNFq.js +4887 -0
- package/dist/web/frontend/assets/login-BHxgJEz_.js +11 -0
- package/dist/web/frontend/assets/{networks-CtFnklqS.js → networks-CBprjUF5.js} +3 -3
- package/dist/web/frontend/assets/onboarding-ChmWs-TC.js +84 -0
- package/dist/web/frontend/assets/reviewIdentityProvider-CCmKgN8N.js +43 -0
- package/dist/web/frontend/assets/reviewNetwork-CX8Bmuf3.js +43 -0
- package/dist/web/frontend/assets/signMessage-BN_6S5FV.js +79 -0
- 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/onboarding/index.html +23 -0
- package/dist/web/frontend/parties/add/index.html +5 -4
- package/dist/web/frontend/parties/edit/index.html +5 -4
- package/dist/web/frontend/parties/index.html +3 -2
- package/dist/web/frontend/sign-message/index.html +2 -2
- package/dist/web/route-inputs.js +1 -1
- package/dist/web/server.d.ts +1 -1
- package/dist/web/server.d.ts.map +1 -1
- package/package.json +36 -30
- package/dist/ledger/transaction-service.d.ts +0 -27
- package/dist/ledger/transaction-service.d.ts.map +0 -1
- package/dist/ledger/transaction-service.js +0 -297
- package/dist/ledger/transaction-service.test.d.ts +0 -2
- package/dist/ledger/transaction-service.test.d.ts.map +0 -1
- package/dist/ledger/transaction-service.test.js +0 -551
- package/dist/notification/NotificationService.d.ts +0 -18
- package/dist/notification/NotificationService.d.ts.map +0 -1
- package/dist/notification/NotificationService.js +0 -26
- package/dist/notification/NotificationService.test.d.ts +0 -2
- package/dist/notification/NotificationService.test.d.ts.map +0 -1
- package/dist/notification/NotificationService.test.js +0 -110
- package/dist/signing/signing-drivers.d.ts +0 -7
- package/dist/signing/signing-drivers.d.ts.map +0 -1
- package/dist/signing/signing-drivers.js +0 -3
- package/dist/web/frontend/assets/404-Ds_FbOi_.js +0 -5
- package/dist/web/frontend/assets/addIdentityProvider-BqiC9u9A.js +0 -28
- package/dist/web/frontend/assets/addParty-CSMZt930.js +0 -13
- package/dist/web/frontend/assets/approve-D5YmfGHz.js +0 -21
- package/dist/web/frontend/assets/callback-Dk9tIdBj.js +0 -7
- package/dist/web/frontend/assets/editParty-DX9X91dp.js +0 -14
- package/dist/web/frontend/assets/index-BCECRB_Y.js +0 -4943
- package/dist/web/frontend/assets/index-Cvcr2Fng.js +0 -2
- package/dist/web/frontend/assets/index-DrEQVBtC.js +0 -93
- package/dist/web/frontend/assets/login-dmjNaK2x.js +0 -11
- package/dist/web/frontend/assets/reviewIdentityProvider-GBlomu4-.js +0 -43
- package/dist/web/frontend/assets/reviewNetwork-CWEgNcCg.js +0 -43
- package/dist/web/frontend/assets/settings-DSh9rqaO.js +0 -37
- package/dist/web/frontend/assets/signMessage-CT2_Y1LA.js +0 -79
- package/dist/web/frontend/settings/index.html +0 -15
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AuthService } from '@canton-network/core-wallet-auth';
|
|
2
|
-
import { Store } from '@canton-network/core-wallet-store';
|
|
3
|
-
import { Logger } from 'pino';
|
|
1
|
+
import { type AuthService } from '@canton-network/core-wallet-auth';
|
|
2
|
+
import type { Store } from '@canton-network/core-wallet-store';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
4
4
|
/**
|
|
5
5
|
* Creates an AuthService that verifies JWT tokens, using a remote JWK set for
|
|
6
|
-
* oauth identity providers
|
|
6
|
+
* oauth identity providers, the network's secret for self_signed ones, and the
|
|
7
|
+
* party's wallet public key for self-issued ones (iss === sub).
|
|
7
8
|
* @param store - The Store instance to access network configurations.
|
|
8
9
|
* @param logger - Logger instance for logging debug and warning messages.
|
|
9
10
|
* @returns An AuthService implementation that verifies JWT tokens.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-auth-service.d.ts","sourceRoot":"","sources":["../../src/auth/jwt-auth-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,WAAW,
|
|
1
|
+
{"version":3,"file":"jwt-auth-service.d.ts","sourceRoot":"","sources":["../../src/auth/jwt-auth-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,WAAW,EAGnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAU9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAqKlC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,EAAE,QAAQ,MAAM,KAAG,WAiH5D,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
import { resolveUserEmail, } from '@canton-network/core-wallet-auth';
|
|
4
|
-
import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify, } from 'jose';
|
|
4
|
+
import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, importJWK, jwtVerify, base64url, } from 'jose';
|
|
5
5
|
function getEmail(value) {
|
|
6
6
|
if (typeof value !== 'string' || value.length === 0) {
|
|
7
7
|
return undefined;
|
|
@@ -44,9 +44,77 @@ async function verifySelfSignedToken(jwt, idp, store, logger) {
|
|
|
44
44
|
...(email ? { email } : {}),
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
function getSelfIssuedUserId(payload) {
|
|
48
|
+
const daml = payload['daml.com'];
|
|
49
|
+
if (daml === null || typeof daml !== 'object' || Array.isArray(daml)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const usr = daml.usr;
|
|
53
|
+
if (typeof usr !== 'string' || usr.length === 0) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return usr;
|
|
57
|
+
}
|
|
58
|
+
function normalizeAudienceClaim(value) {
|
|
59
|
+
if (typeof value === 'string') {
|
|
60
|
+
return [value];
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
// wallet.publicKey is 32 raw Ed25519 bytes as standard base64. jwtVerify
|
|
68
|
+
// wants a JWK: OKP = octet key pair, crv names Ed25519, x is the same
|
|
69
|
+
// point in base64url (RFC 8037).
|
|
70
|
+
async function ed25519KeyFromWalletPublicKey(publicKey) {
|
|
71
|
+
const raw = Buffer.from(publicKey, 'base64');
|
|
72
|
+
if (raw.length !== 32) {
|
|
73
|
+
throw new Error(`Wallet public key must be 32 raw bytes, got ${raw.length}`);
|
|
74
|
+
}
|
|
75
|
+
return importJWK({
|
|
76
|
+
kty: 'OKP',
|
|
77
|
+
crv: 'Ed25519',
|
|
78
|
+
x: base64url.encode(raw),
|
|
79
|
+
}, 'EdDSA');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Verifies a self-issued token (iss === sub) against the party's wallet
|
|
83
|
+
* public key. The wallet is found via daml.com.usr, sub, and aud
|
|
84
|
+
* (exactly one self_issued network).
|
|
85
|
+
*/
|
|
86
|
+
async function verifySelfIssuedToken(jwt, payload, store, logger) {
|
|
87
|
+
const partyId = payload.sub;
|
|
88
|
+
const userId = getSelfIssuedUserId(payload);
|
|
89
|
+
if (!partyId || !userId) {
|
|
90
|
+
logger.warn('Self-issued JWT is missing sub or daml.com.usr');
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const wallet = await store.getWalletByJwt(userId, partyId, normalizeAudienceClaim(payload.aud));
|
|
94
|
+
if (!wallet) {
|
|
95
|
+
logger.warn({ userId, partyId }, 'No wallet found for self-issued token');
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
if (!wallet.isAuthParty) {
|
|
99
|
+
logger.warn({ userId, partyId }, 'Wallet is not an auth party for self-issued tokens');
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const jwk = await ed25519KeyFromWalletPublicKey(wallet.publicKey);
|
|
103
|
+
await jwtVerify(jwt, jwk, {
|
|
104
|
+
algorithms: ['EdDSA'],
|
|
105
|
+
requiredClaims: ['exp'],
|
|
106
|
+
});
|
|
107
|
+
const email = getEmail(payload.email);
|
|
108
|
+
return {
|
|
109
|
+
userId: wallet.userId,
|
|
110
|
+
accessToken: jwt,
|
|
111
|
+
...(email ? { email } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
47
114
|
/**
|
|
48
115
|
* Creates an AuthService that verifies JWT tokens, using a remote JWK set for
|
|
49
|
-
* oauth identity providers
|
|
116
|
+
* oauth identity providers, the network's secret for self_signed ones, and the
|
|
117
|
+
* party's wallet public key for self-issued ones (iss === sub).
|
|
50
118
|
* @param store - The Store instance to access network configurations.
|
|
51
119
|
* @param logger - Logger instance for logging debug and warning messages.
|
|
52
120
|
* @returns An AuthService implementation that verifies JWT tokens.
|
|
@@ -65,8 +133,11 @@ export const jwtAuthService = (store, logger) => ({
|
|
|
65
133
|
logger.warn('JWT does not contain an issuer');
|
|
66
134
|
return undefined;
|
|
67
135
|
}
|
|
136
|
+
if (iss === decoded.sub) {
|
|
137
|
+
return await verifySelfIssuedToken(jwt, decoded, store, logger);
|
|
138
|
+
}
|
|
68
139
|
const idps = await store.listIdps();
|
|
69
|
-
const idp = idps.find((i) => i.issuer === iss);
|
|
140
|
+
const idp = idps.find((i) => i.type !== 'self_issued' && i.issuer === iss);
|
|
70
141
|
if (!idp) {
|
|
71
142
|
logger.warn(`No identity provider found for issuer: ${iss}`);
|
|
72
143
|
return undefined;
|
|
@@ -97,14 +168,11 @@ export const jwtAuthService = (store, logger) => ({
|
|
|
97
168
|
logger.warn(`No networks configured for IDP ${idp.id}, cannot validate audience`);
|
|
98
169
|
return undefined;
|
|
99
170
|
}
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
171
|
+
const tokenAudiences = normalizeAudienceClaim(payload.aud);
|
|
172
|
+
if (tokenAudiences.length === 0) {
|
|
102
173
|
logger.warn('JWT does not contain an audience claim');
|
|
103
174
|
return undefined;
|
|
104
175
|
}
|
|
105
|
-
const tokenAudiences = Array.isArray(tokenAudience)
|
|
106
|
-
? tokenAudience
|
|
107
|
-
: [tokenAudience];
|
|
108
176
|
const audMatch = tokenAudiences.some((aud) => expectedAudiences.includes(aud));
|
|
109
177
|
if (!audMatch) {
|
|
110
178
|
logger.warn({
|
|
@@ -5,6 +5,7 @@ import { getLogger } from '@logtape/logtape';
|
|
|
5
5
|
import { pino } from 'pino';
|
|
6
6
|
import { sink } from 'pino-test';
|
|
7
7
|
import { createLocalJWKSet, exportJWK, generateKeyPair, SignJWT, } from 'jose';
|
|
8
|
+
import { PartyLevelRight, } from '@canton-network/core-wallet-store';
|
|
8
9
|
import { StoreInternal } from '@canton-network/core-wallet-store-inmemory';
|
|
9
10
|
import { jwtAuthService } from './jwt-auth-service.js';
|
|
10
11
|
const mockFetch = vi.hoisted(() => vi.fn());
|
|
@@ -48,6 +49,58 @@ async function rs256BearerToken(claims, privateKey) {
|
|
|
48
49
|
.sign(privateKey);
|
|
49
50
|
return `Bearer ${jwt}`;
|
|
50
51
|
}
|
|
52
|
+
async function eddsaBearerToken(claims, privateKey) {
|
|
53
|
+
const jwt = await new SignJWT(claims)
|
|
54
|
+
.setProtectedHeader({ alg: 'EdDSA', typ: 'JWT' })
|
|
55
|
+
.sign(privateKey);
|
|
56
|
+
return `Bearer ${jwt}`;
|
|
57
|
+
}
|
|
58
|
+
async function rawEd25519PublicKeyBase64(publicKey) {
|
|
59
|
+
const jwk = await exportJWK(publicKey);
|
|
60
|
+
if (!jwk.x) {
|
|
61
|
+
throw new Error('Ed25519 JWK is missing x');
|
|
62
|
+
}
|
|
63
|
+
return Buffer.from(jwk.x, 'base64url').toString('base64');
|
|
64
|
+
}
|
|
65
|
+
const SELF_ISSUED_USER_ID = 'test-user-id';
|
|
66
|
+
const SELF_ISSUED_PARTY_ID = 'alice::namespace';
|
|
67
|
+
const SELF_ISSUED_NETWORK_ID = 'network-self-issued';
|
|
68
|
+
const SELF_ISSUED_AUDIENCE = 'self-issued-audience';
|
|
69
|
+
const createSelfIssuedNetwork = (id = SELF_ISSUED_NETWORK_ID, audience = SELF_ISSUED_AUDIENCE) => ({
|
|
70
|
+
id,
|
|
71
|
+
name: `Network ${id}`,
|
|
72
|
+
synchronizerId: `${id}-sync`,
|
|
73
|
+
identityProviderId: 'idp-self-issued',
|
|
74
|
+
description: `Test Network ${id}`,
|
|
75
|
+
ledgerApi: { baseUrl: `http://${id}` },
|
|
76
|
+
auth: {
|
|
77
|
+
method: 'self_issued',
|
|
78
|
+
audience,
|
|
79
|
+
scope: 'daml_ledger_api',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const selfIssuedWallet = (publicKey, extras = {}) => ({
|
|
83
|
+
primary: true,
|
|
84
|
+
status: 'allocated',
|
|
85
|
+
partyId: SELF_ISSUED_PARTY_ID,
|
|
86
|
+
hint: 'alice',
|
|
87
|
+
publicKey,
|
|
88
|
+
namespace: 'namespace',
|
|
89
|
+
networkId: SELF_ISSUED_NETWORK_ID,
|
|
90
|
+
signingProviderId: 'WALLET_KERNEL',
|
|
91
|
+
rights: [PartyLevelRight.CanActAs],
|
|
92
|
+
userId: SELF_ISSUED_USER_ID,
|
|
93
|
+
isAuthParty: true,
|
|
94
|
+
...extras,
|
|
95
|
+
});
|
|
96
|
+
const selfIssuedClaims = (extras = {}) => ({
|
|
97
|
+
iss: SELF_ISSUED_PARTY_ID,
|
|
98
|
+
sub: SELF_ISSUED_PARTY_ID,
|
|
99
|
+
aud: SELF_ISSUED_AUDIENCE,
|
|
100
|
+
exp: Math.floor(Date.now() / 1000) + 3600,
|
|
101
|
+
'daml.com': { usr: SELF_ISSUED_USER_ID, syn: 'sync' },
|
|
102
|
+
...extras,
|
|
103
|
+
});
|
|
51
104
|
const createOAuthNetwork = (id, identityProviderId, audience = 'test-audience') => ({
|
|
52
105
|
id,
|
|
53
106
|
name: `Network ${id}`,
|
|
@@ -463,4 +516,144 @@ describe('jwtAuthService', () => {
|
|
|
463
516
|
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
464
517
|
});
|
|
465
518
|
});
|
|
519
|
+
describe('self-issued tokens (iss === sub)', () => {
|
|
520
|
+
let ed25519PrivateKey;
|
|
521
|
+
let walletPublicKey;
|
|
522
|
+
beforeAll(async () => {
|
|
523
|
+
const { publicKey, privateKey } = await generateKeyPair('EdDSA');
|
|
524
|
+
ed25519PrivateKey = privateKey;
|
|
525
|
+
walletPublicKey = await rawEd25519PublicKeyBase64(publicKey);
|
|
526
|
+
});
|
|
527
|
+
beforeEach(async () => {
|
|
528
|
+
await store.addNetwork(createSelfIssuedNetwork());
|
|
529
|
+
await store.addWallet(selfIssuedWallet(walletPublicKey));
|
|
530
|
+
});
|
|
531
|
+
it('returns auth context for a valid self-issued token', async () => {
|
|
532
|
+
const service = jwtAuthService(store, mockLogger);
|
|
533
|
+
const token = await eddsaBearerToken(selfIssuedClaims(), ed25519PrivateKey);
|
|
534
|
+
const result = await service.verifyToken(token);
|
|
535
|
+
expect(result).toEqual({
|
|
536
|
+
userId: SELF_ISSUED_USER_ID,
|
|
537
|
+
accessToken: token.split(' ')[1],
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
it('includes email when present in the token', async () => {
|
|
541
|
+
const service = jwtAuthService(store, mockLogger);
|
|
542
|
+
const token = await eddsaBearerToken(selfIssuedClaims({ email: 'alice@example.com' }), ed25519PrivateKey);
|
|
543
|
+
await expect(service.verifyToken(token)).resolves.toEqual({
|
|
544
|
+
userId: SELF_ISSUED_USER_ID,
|
|
545
|
+
accessToken: token.split(' ')[1],
|
|
546
|
+
email: 'alice@example.com',
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
it('returns undefined when daml.com.usr is missing', async () => {
|
|
550
|
+
const service = jwtAuthService(store, mockLogger);
|
|
551
|
+
const token = await eddsaBearerToken({
|
|
552
|
+
iss: SELF_ISSUED_PARTY_ID,
|
|
553
|
+
sub: SELF_ISSUED_PARTY_ID,
|
|
554
|
+
aud: SELF_ISSUED_AUDIENCE,
|
|
555
|
+
exp: Math.floor(Date.now() / 1000) + 3600,
|
|
556
|
+
}, ed25519PrivateKey);
|
|
557
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
558
|
+
});
|
|
559
|
+
it('returns undefined when no wallet matches user and party', async () => {
|
|
560
|
+
const service = jwtAuthService(store, mockLogger);
|
|
561
|
+
const token = await eddsaBearerToken(selfIssuedClaims({
|
|
562
|
+
iss: 'unknown::namespace',
|
|
563
|
+
sub: 'unknown::namespace',
|
|
564
|
+
}), ed25519PrivateKey);
|
|
565
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
566
|
+
});
|
|
567
|
+
it('returns undefined when the audience does not match the wallet network', async () => {
|
|
568
|
+
const service = jwtAuthService(store, mockLogger);
|
|
569
|
+
const token = await eddsaBearerToken(selfIssuedClaims({ aud: 'other-audience' }), ed25519PrivateKey);
|
|
570
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
571
|
+
});
|
|
572
|
+
it('returns undefined when the JWT has no audience', async () => {
|
|
573
|
+
const service = jwtAuthService(store, mockLogger);
|
|
574
|
+
const claims = selfIssuedClaims();
|
|
575
|
+
delete claims.aud;
|
|
576
|
+
const token = await eddsaBearerToken(claims, ed25519PrivateKey);
|
|
577
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
578
|
+
});
|
|
579
|
+
it('returns undefined when the signature does not match the wallet public key', async () => {
|
|
580
|
+
const { privateKey: otherKey } = await generateKeyPair('EdDSA');
|
|
581
|
+
const service = jwtAuthService(store, mockLogger);
|
|
582
|
+
const token = await eddsaBearerToken(selfIssuedClaims(), otherKey);
|
|
583
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
584
|
+
});
|
|
585
|
+
it('returns undefined when the token is expired', async () => {
|
|
586
|
+
const service = jwtAuthService(store, mockLogger);
|
|
587
|
+
const token = await eddsaBearerToken(selfIssuedClaims({
|
|
588
|
+
exp: Math.floor(Date.now() / 1000) - 60,
|
|
589
|
+
}), ed25519PrivateKey);
|
|
590
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
591
|
+
});
|
|
592
|
+
it('returns undefined when the JWT has no exp', async () => {
|
|
593
|
+
const service = jwtAuthService(store, mockLogger);
|
|
594
|
+
const claims = selfIssuedClaims();
|
|
595
|
+
delete claims.exp;
|
|
596
|
+
const token = await eddsaBearerToken(claims, ed25519PrivateKey);
|
|
597
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
598
|
+
});
|
|
599
|
+
it('returns undefined when isAuthParty is false', async () => {
|
|
600
|
+
const { publicKey, privateKey } = await generateKeyPair('EdDSA');
|
|
601
|
+
const otherParty = 'bob::namespace';
|
|
602
|
+
await store.addWallet(selfIssuedWallet(await rawEd25519PublicKeyBase64(publicKey), {
|
|
603
|
+
partyId: otherParty,
|
|
604
|
+
primary: false,
|
|
605
|
+
isAuthParty: false,
|
|
606
|
+
}));
|
|
607
|
+
const service = jwtAuthService(store, mockLogger);
|
|
608
|
+
const token = await eddsaBearerToken(selfIssuedClaims({
|
|
609
|
+
iss: otherParty,
|
|
610
|
+
sub: otherParty,
|
|
611
|
+
}), privateKey);
|
|
612
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
613
|
+
});
|
|
614
|
+
it('returns undefined when isAuthParty is missing', async () => {
|
|
615
|
+
const { publicKey, privateKey } = await generateKeyPair('EdDSA');
|
|
616
|
+
const otherParty = 'carol::namespace';
|
|
617
|
+
await store.addWallet(selfIssuedWallet(await rawEd25519PublicKeyBase64(publicKey), {
|
|
618
|
+
partyId: otherParty,
|
|
619
|
+
primary: false,
|
|
620
|
+
isAuthParty: undefined,
|
|
621
|
+
}));
|
|
622
|
+
const service = jwtAuthService(store, mockLogger);
|
|
623
|
+
const token = await eddsaBearerToken(selfIssuedClaims({
|
|
624
|
+
iss: otherParty,
|
|
625
|
+
sub: otherParty,
|
|
626
|
+
}), privateKey);
|
|
627
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
628
|
+
});
|
|
629
|
+
it('selects the wallet on the self-issued network matching the token audience', async () => {
|
|
630
|
+
const { publicKey, privateKey } = await generateKeyPair('EdDSA');
|
|
631
|
+
const otherAudience = 'other-self-issued-audience';
|
|
632
|
+
const otherNetworkId = 'network-self-issued-2';
|
|
633
|
+
await store.addNetwork(createSelfIssuedNetwork(otherNetworkId, otherAudience));
|
|
634
|
+
await store.addWallet(selfIssuedWallet(await rawEd25519PublicKeyBase64(publicKey), {
|
|
635
|
+
networkId: otherNetworkId,
|
|
636
|
+
primary: false,
|
|
637
|
+
}));
|
|
638
|
+
const service = jwtAuthService(store, mockLogger);
|
|
639
|
+
const token = await eddsaBearerToken(selfIssuedClaims({ aud: otherAudience }), privateKey);
|
|
640
|
+
await expect(service.verifyToken(token)).resolves.toEqual({
|
|
641
|
+
userId: SELF_ISSUED_USER_ID,
|
|
642
|
+
accessToken: token.split(' ')[1],
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
it('returns undefined when multiple self-issued networks share the token audience', async () => {
|
|
646
|
+
const collidingStore = new StoreInternal({
|
|
647
|
+
idps: [],
|
|
648
|
+
networks: [
|
|
649
|
+
createSelfIssuedNetwork('n1', SELF_ISSUED_AUDIENCE),
|
|
650
|
+
createSelfIssuedNetwork('n2', SELF_ISSUED_AUDIENCE),
|
|
651
|
+
],
|
|
652
|
+
}, getLogger('mock'), authContext);
|
|
653
|
+
await collidingStore.addWallet(selfIssuedWallet(walletPublicKey));
|
|
654
|
+
const service = jwtAuthService(collidingStore, mockLogger);
|
|
655
|
+
const token = await eddsaBearerToken(selfIssuedClaims(), ed25519PrivateKey);
|
|
656
|
+
await expect(service.verifyToken(token)).resolves.toBeUndefined();
|
|
657
|
+
});
|
|
658
|
+
});
|
|
466
659
|
});
|
package/dist/config/Config.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const serverConfigSchema: z.ZodObject<{
|
|
|
17
17
|
admin: z.ZodOptional<z.ZodString>;
|
|
18
18
|
signingWorker: z.ZodPreprocess<z.ZodObject<{
|
|
19
19
|
pollInterval: z.ZodDefault<z.ZodNumber>;
|
|
20
|
-
}, z.core.$strip
|
|
20
|
+
}, z.core.$strip>, unknown>;
|
|
21
21
|
}, z.core.$strip>;
|
|
22
22
|
export declare const rawConfigSchema: z.ZodObject<{
|
|
23
23
|
kernel: z.ZodObject<{
|
|
@@ -38,8 +38,8 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
38
38
|
admin: z.ZodOptional<z.ZodString>;
|
|
39
39
|
signingWorker: z.ZodPreprocess<z.ZodObject<{
|
|
40
40
|
pollInterval: z.ZodDefault<z.ZodNumber>;
|
|
41
|
-
}, z.core.$strip
|
|
42
|
-
}, z.core.$strip
|
|
41
|
+
}, z.core.$strip>, unknown>;
|
|
42
|
+
}, z.core.$strip>, unknown>;
|
|
43
43
|
logging: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
|
|
44
44
|
level: z.ZodOptional<z.ZodEnum<{
|
|
45
45
|
error: "error";
|
|
@@ -53,7 +53,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
53
53
|
json: "json";
|
|
54
54
|
pretty: "pretty";
|
|
55
55
|
}>>;
|
|
56
|
-
}, z.core.$strip
|
|
56
|
+
}, z.core.$strip>, unknown>>;
|
|
57
57
|
store: z.ZodObject<{
|
|
58
58
|
connection: z.ZodUnion<readonly [z.ZodObject<{
|
|
59
59
|
type: z.ZodLiteral<"memory">;
|
|
@@ -104,6 +104,9 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
104
104
|
type: z.ZodLiteral<"self_signed">;
|
|
105
105
|
issuer: z.ZodString;
|
|
106
106
|
}, z.core.$strip>, z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
type: z.ZodLiteral<"self_issued">;
|
|
109
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
107
110
|
id: z.ZodString;
|
|
108
111
|
type: z.ZodLiteral<"oauth">;
|
|
109
112
|
issuer: z.ZodString;
|
|
@@ -125,6 +128,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
125
128
|
clientId: z.ZodString;
|
|
126
129
|
}, z.core.$strip>, z.ZodObject<{
|
|
127
130
|
method: z.ZodLiteral<"client_credentials">;
|
|
131
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
128
132
|
audience: z.ZodString;
|
|
129
133
|
scope: z.ZodString;
|
|
130
134
|
clientId: z.ZodString;
|
|
@@ -136,6 +140,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
136
140
|
scope: z.ZodString;
|
|
137
141
|
clientId: z.ZodString;
|
|
138
142
|
clientSecret: z.ZodString;
|
|
143
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
+
method: z.ZodLiteral<"self_issued">;
|
|
145
|
+
audience: z.ZodString;
|
|
146
|
+
scope: z.ZodString;
|
|
139
147
|
}, z.core.$strip>], "method">, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
140
148
|
method: z.ZodLiteral<"authorization_code">;
|
|
141
149
|
audience: z.ZodString;
|
|
@@ -143,6 +151,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
143
151
|
clientId: z.ZodString;
|
|
144
152
|
}, z.core.$strip>, z.ZodObject<{
|
|
145
153
|
method: z.ZodLiteral<"client_credentials">;
|
|
154
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
146
155
|
audience: z.ZodString;
|
|
147
156
|
scope: z.ZodString;
|
|
148
157
|
clientId: z.ZodString;
|
|
@@ -154,6 +163,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
154
163
|
scope: z.ZodString;
|
|
155
164
|
clientId: z.ZodString;
|
|
156
165
|
clientSecretEnv: z.ZodString;
|
|
166
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
167
|
+
method: z.ZodLiteral<"self_issued">;
|
|
168
|
+
audience: z.ZodString;
|
|
169
|
+
scope: z.ZodString;
|
|
157
170
|
}, z.core.$strip>], "method">]>;
|
|
158
171
|
adminAuth: z.ZodOptional<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
159
172
|
method: z.ZodLiteral<"authorization_code">;
|
|
@@ -162,6 +175,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
162
175
|
clientId: z.ZodString;
|
|
163
176
|
}, z.core.$strip>, z.ZodObject<{
|
|
164
177
|
method: z.ZodLiteral<"client_credentials">;
|
|
178
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
165
179
|
audience: z.ZodString;
|
|
166
180
|
scope: z.ZodString;
|
|
167
181
|
clientId: z.ZodString;
|
|
@@ -173,6 +187,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
173
187
|
scope: z.ZodString;
|
|
174
188
|
clientId: z.ZodString;
|
|
175
189
|
clientSecret: z.ZodString;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
method: z.ZodLiteral<"self_issued">;
|
|
192
|
+
audience: z.ZodString;
|
|
193
|
+
scope: z.ZodString;
|
|
176
194
|
}, z.core.$strip>], "method">, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
177
195
|
method: z.ZodLiteral<"authorization_code">;
|
|
178
196
|
audience: z.ZodString;
|
|
@@ -180,6 +198,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
180
198
|
clientId: z.ZodString;
|
|
181
199
|
}, z.core.$strip>, z.ZodObject<{
|
|
182
200
|
method: z.ZodLiteral<"client_credentials">;
|
|
201
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
183
202
|
audience: z.ZodString;
|
|
184
203
|
scope: z.ZodString;
|
|
185
204
|
clientId: z.ZodString;
|
|
@@ -191,6 +210,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
191
210
|
scope: z.ZodString;
|
|
192
211
|
clientId: z.ZodString;
|
|
193
212
|
clientSecretEnv: z.ZodString;
|
|
213
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
214
|
+
method: z.ZodLiteral<"self_issued">;
|
|
215
|
+
audience: z.ZodString;
|
|
216
|
+
scope: z.ZodString;
|
|
194
217
|
}, z.core.$strip>], "method">]>>;
|
|
195
218
|
serviceAccountAuth: z.ZodOptional<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
196
219
|
method: z.ZodLiteral<"authorization_code">;
|
|
@@ -199,6 +222,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
199
222
|
clientId: z.ZodString;
|
|
200
223
|
}, z.core.$strip>, z.ZodObject<{
|
|
201
224
|
method: z.ZodLiteral<"client_credentials">;
|
|
225
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
202
226
|
audience: z.ZodString;
|
|
203
227
|
scope: z.ZodString;
|
|
204
228
|
clientId: z.ZodString;
|
|
@@ -210,6 +234,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
210
234
|
scope: z.ZodString;
|
|
211
235
|
clientId: z.ZodString;
|
|
212
236
|
clientSecret: z.ZodString;
|
|
237
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
238
|
+
method: z.ZodLiteral<"self_issued">;
|
|
239
|
+
audience: z.ZodString;
|
|
240
|
+
scope: z.ZodString;
|
|
213
241
|
}, z.core.$strip>], "method">, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
214
242
|
method: z.ZodLiteral<"authorization_code">;
|
|
215
243
|
audience: z.ZodString;
|
|
@@ -217,6 +245,7 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
217
245
|
clientId: z.ZodString;
|
|
218
246
|
}, z.core.$strip>, z.ZodObject<{
|
|
219
247
|
method: z.ZodLiteral<"client_credentials">;
|
|
248
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
220
249
|
audience: z.ZodString;
|
|
221
250
|
scope: z.ZodString;
|
|
222
251
|
clientId: z.ZodString;
|
|
@@ -228,6 +257,10 @@ export declare const rawConfigSchema: z.ZodObject<{
|
|
|
228
257
|
scope: z.ZodString;
|
|
229
258
|
clientId: z.ZodString;
|
|
230
259
|
clientSecretEnv: z.ZodString;
|
|
260
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
261
|
+
method: z.ZodLiteral<"self_issued">;
|
|
262
|
+
audience: z.ZodString;
|
|
263
|
+
scope: z.ZodString;
|
|
231
264
|
}, z.core.$strip>], "method">]>>;
|
|
232
265
|
}, z.core.$strip>>;
|
|
233
266
|
}, z.core.$strip>;
|
|
@@ -257,8 +290,8 @@ export declare const configSchema: z.ZodObject<{
|
|
|
257
290
|
admin: z.ZodOptional<z.ZodString>;
|
|
258
291
|
signingWorker: z.ZodPreprocess<z.ZodObject<{
|
|
259
292
|
pollInterval: z.ZodDefault<z.ZodNumber>;
|
|
260
|
-
}, z.core.$strip
|
|
261
|
-
}, z.core.$strip
|
|
293
|
+
}, z.core.$strip>, unknown>;
|
|
294
|
+
}, z.core.$strip>, unknown>;
|
|
262
295
|
logging: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
|
|
263
296
|
level: z.ZodOptional<z.ZodEnum<{
|
|
264
297
|
error: "error";
|
|
@@ -272,7 +305,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
272
305
|
json: "json";
|
|
273
306
|
pretty: "pretty";
|
|
274
307
|
}>>;
|
|
275
|
-
}, z.core.$strip
|
|
308
|
+
}, z.core.$strip>, unknown>>;
|
|
276
309
|
store: z.ZodObject<{
|
|
277
310
|
connection: z.ZodUnion<readonly [z.ZodObject<{
|
|
278
311
|
type: z.ZodLiteral<"memory">;
|
|
@@ -323,6 +356,9 @@ export declare const configSchema: z.ZodObject<{
|
|
|
323
356
|
type: z.ZodLiteral<"self_signed">;
|
|
324
357
|
issuer: z.ZodString;
|
|
325
358
|
}, z.core.$strip>, z.ZodObject<{
|
|
359
|
+
id: z.ZodString;
|
|
360
|
+
type: z.ZodLiteral<"self_issued">;
|
|
361
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
326
362
|
id: z.ZodString;
|
|
327
363
|
type: z.ZodLiteral<"oauth">;
|
|
328
364
|
issuer: z.ZodString;
|
|
@@ -344,6 +380,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
344
380
|
clientId: z.ZodString;
|
|
345
381
|
}, z.core.$strip>, z.ZodObject<{
|
|
346
382
|
method: z.ZodLiteral<"client_credentials">;
|
|
383
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
347
384
|
audience: z.ZodString;
|
|
348
385
|
scope: z.ZodString;
|
|
349
386
|
clientId: z.ZodString;
|
|
@@ -355,6 +392,10 @@ export declare const configSchema: z.ZodObject<{
|
|
|
355
392
|
scope: z.ZodString;
|
|
356
393
|
clientId: z.ZodString;
|
|
357
394
|
clientSecret: z.ZodString;
|
|
395
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
396
|
+
method: z.ZodLiteral<"self_issued">;
|
|
397
|
+
audience: z.ZodString;
|
|
398
|
+
scope: z.ZodString;
|
|
358
399
|
}, z.core.$strip>], "method">;
|
|
359
400
|
adminAuth: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
360
401
|
method: z.ZodLiteral<"authorization_code">;
|
|
@@ -363,6 +404,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
363
404
|
clientId: z.ZodString;
|
|
364
405
|
}, z.core.$strip>, z.ZodObject<{
|
|
365
406
|
method: z.ZodLiteral<"client_credentials">;
|
|
407
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
366
408
|
audience: z.ZodString;
|
|
367
409
|
scope: z.ZodString;
|
|
368
410
|
clientId: z.ZodString;
|
|
@@ -374,6 +416,10 @@ export declare const configSchema: z.ZodObject<{
|
|
|
374
416
|
scope: z.ZodString;
|
|
375
417
|
clientId: z.ZodString;
|
|
376
418
|
clientSecret: z.ZodString;
|
|
419
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
420
|
+
method: z.ZodLiteral<"self_issued">;
|
|
421
|
+
audience: z.ZodString;
|
|
422
|
+
scope: z.ZodString;
|
|
377
423
|
}, z.core.$strip>], "method">>;
|
|
378
424
|
serviceAccountAuth: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
379
425
|
method: z.ZodLiteral<"authorization_code">;
|
|
@@ -382,6 +428,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
382
428
|
clientId: z.ZodString;
|
|
383
429
|
}, z.core.$strip>, z.ZodObject<{
|
|
384
430
|
method: z.ZodLiteral<"client_credentials">;
|
|
431
|
+
identityProviderId: z.ZodOptional<z.ZodString>;
|
|
385
432
|
audience: z.ZodString;
|
|
386
433
|
scope: z.ZodString;
|
|
387
434
|
clientId: z.ZodString;
|
|
@@ -393,6 +440,10 @@ export declare const configSchema: z.ZodObject<{
|
|
|
393
440
|
scope: z.ZodString;
|
|
394
441
|
clientId: z.ZodString;
|
|
395
442
|
clientSecret: z.ZodString;
|
|
443
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
444
|
+
method: z.ZodLiteral<"self_issued">;
|
|
445
|
+
audience: z.ZodString;
|
|
446
|
+
scope: z.ZodString;
|
|
396
447
|
}, z.core.$strip>], "method">>;
|
|
397
448
|
}, z.core.$strip>>;
|
|
398
449
|
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AASvB,eAAO,MAAM,gBAAgB;;;;iBAY3B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBA0D7B,CAAA;AA6CF,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AASvB,eAAO,MAAM,gBAAgB;;;;iBAY3B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBA0D7B,CAAA;AA6CF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ1B,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQvB,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AACvD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
|
@@ -6,9 +6,11 @@ test('config from json file', async () => {
|
|
|
6
6
|
const resp = ConfigUtils.loadConfigFile('../test/config.json');
|
|
7
7
|
expect(resp.bootstrap.networks[0].name).toBe('Local (OAuth IDP)');
|
|
8
8
|
expect(resp.bootstrap.networks[0].ledgerApi.baseUrl).toBe('http://127.0.0.1:5003');
|
|
9
|
-
expect(resp.bootstrap.networks[0].auth.clientId).toBe('operator');
|
|
10
|
-
expect(resp.bootstrap.networks[0].auth.scope).toBe('openid email daml_ledger_api offline_access');
|
|
11
9
|
expect(resp.bootstrap.networks[0].auth.method).toBe('authorization_code');
|
|
10
|
+
if (resp.bootstrap.networks[0].auth.method === 'authorization_code') {
|
|
11
|
+
expect(resp.bootstrap.networks[0].auth.clientId).toBe('operator');
|
|
12
|
+
}
|
|
13
|
+
expect(resp.bootstrap.networks[0].auth.scope).toBe('openid email daml_ledger_api offline_access');
|
|
12
14
|
expect(resp.bootstrap.networks[2].auth.method).toBe('client_credentials');
|
|
13
15
|
if (resp.bootstrap.networks[2].auth.method === 'client_credentials') {
|
|
14
16
|
expect(resp.bootstrap.networks[2].auth.audience).toBe('https://daml.com/jwt/aud/participant/participant1::1220d44fc1c3ba0b5bdf7b956ee71bc94ebe2d23258dc268fdf0824fbaeff2c61424');
|
|
@@ -16,4 +18,9 @@ test('config from json file', async () => {
|
|
|
16
18
|
if (resp.bootstrap.networks[4].adminAuth?.method === 'client_credentials') {
|
|
17
19
|
expect(resp.bootstrap.networks[4].adminAuth.clientSecret).toBe('devnet_secret_testval');
|
|
18
20
|
}
|
|
21
|
+
const selfIssuedNetwork = resp.bootstrap.networks.find((network) => network.id === 'canton:local-self-issued');
|
|
22
|
+
expect(selfIssuedNetwork?.adminAuth).toMatchObject({
|
|
23
|
+
method: 'client_credentials',
|
|
24
|
+
identityProviderId: 'idp-mock-oauth',
|
|
25
|
+
});
|
|
19
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigUtils.d.ts","sourceRoot":"","sources":["../../src/config/ConfigUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ConfigUtils.d.ts","sourceRoot":"","sources":["../../src/config/ConfigUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAmC,MAAM,aAAa,CAAA;AAI1E,qBAAa,WAAW;IACpB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAkElD;AAsKD,UAAU,IAAI;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACrB;AAOD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,IAa1D,CAAA"}
|