diff --git a/api-specs/openrpc-user-api.json b/api-specs/openrpc-user-api.json index 130c84f91..4ab3ba3cd 100644 --- a/api-specs/openrpc-user-api.json +++ b/api-specs/openrpc-user-api.json @@ -74,13 +74,93 @@ "title": "networks", "type": "array", "items": { - "$ref": "#/components/schemas/Network" + "$ref": "#/components/schemas/PublicNetwork" } } }, "required": ["networks"] } - } + }, + "description": "Lists configured networks without sensitive authentication details." + }, + { + "name": "getNetwork", + "params": [ + { + "name": "params", + "schema": { + "title": "GetNetworkParams", + "type": "object", + "additionalProperties": false, + "properties": { + "networkId": { + "title": "networkId", + "type": "string", + "description": "Network ID" + } + }, + "required": ["networkId"] + } + } + ], + "result": { + "name": "result", + "schema": { + "title": "GetNetworkResult", + "type": "object", + "additionalProperties": false, + "properties": { + "network": { + "$ref": "#/components/schemas/Network" + } + }, + "required": ["network"] + } + }, + "description": "Returns full network configuration including auth details. Admin only." + }, + { + "name": "selfSignedAccessToken", + "params": [ + { + "name": "params", + "schema": { + "title": "SelfSignedAccessTokenParams", + "type": "object", + "additionalProperties": false, + "properties": { + "networkId": { + "title": "networkId", + "type": "string", + "description": "Network ID" + }, + "clientId": { + "title": "clientId", + "type": "string", + "description": "Client ID used as the JWT subject" + } + }, + "required": ["networkId", "clientId"] + } + } + ], + "result": { + "name": "result", + "schema": { + "title": "SelfSignedAccessTokenResult", + "type": "object", + "additionalProperties": false, + "properties": { + "accessToken": { + "title": "accessToken", + "type": "string", + "description": "Self-signed JWT access token" + } + }, + "required": ["accessToken"] + } + }, + "description": "Mints a self-signed access token using server-side network credentials. Used for login on self-signed networks." }, { "name": "addIdp", @@ -877,6 +957,72 @@ "format": "uuid", "description": "The internal transaction identifier." }, + "PublicNetwork": { + "title": "PublicNetwork", + "type": "object", + "additionalProperties": false, + "description": "Network metadata exposed by listNetworks without sensitive auth configuration", + "properties": { + "id": { + "title": "networkId", + "type": "string", + "description": "Network ID" + }, + "name": { + "title": "name", + "type": "string", + "description": "Name of network" + }, + "description": { + "title": "description", + "type": "string", + "description": "Description of network" + }, + "synchronizerId": { + "title": "synchronizerId", + "type": "string", + "description": "Synchronizer ID" + }, + "identityProviderId": { + "title": "identityProviderId", + "type": "string", + "description": "Identity Provider ID" + }, + "ledgerApi": { + "title": "ledgerApi", + "type": "string", + "description": "Ledger api url" + }, + "authMethod": { + "title": "authMethod", + "type": "string", + "description": "Authentication method configured for this network" + }, + "clientId": { + "title": "clientId", + "type": "string", + "description": "OAuth or self-signed client ID used for user login" + }, + "scope": { + "title": "scope", + "type": "string", + "description": "OAuth scope used for user login" + }, + "audience": { + "title": "audience", + "type": "string", + "description": "OAuth audience used for user login" + } + }, + "required": [ + "id", + "name", + "description", + "identityProviderId", + "ledgerApi", + "authMethod" + ] + }, "Network": { "title": "Network", "type": "object", diff --git a/core/wallet-store-inmemory/src/StoreInternal.ts b/core/wallet-store-inmemory/src/StoreInternal.ts index 7c2d84c85..c5dc52484 100644 --- a/core/wallet-store-inmemory/src/StoreInternal.ts +++ b/core/wallet-store-inmemory/src/StoreInternal.ts @@ -375,7 +375,6 @@ export class StoreInternal implements Store, AuthAware { } async listIdps(): Promise> { - this.assertConnected() return this.systemStorage.idps } diff --git a/core/wallet-ui-components/src/components/login-form.ts b/core/wallet-ui-components/src/components/login-form.ts index 0495a170d..cd6e1e254 100644 --- a/core/wallet-ui-components/src/components/login-form.ts +++ b/core/wallet-ui-components/src/components/login-form.ts @@ -5,14 +5,14 @@ import { css, html, PropertyValues } from 'lit' import { customElement, property, state } from 'lit/decorators.js' import './back-link.js' import { BaseElement } from '../internal/base-element.js' -import { Network, Idp } from '@canton-network/core-wallet-user-rpc-client' +import { PublicNetwork, Idp } from '@canton-network/core-wallet-user-rpc-client' import { chevronDownIcon } from '../icons' import cantonLogo from '../../images/logos/canton-logo.png' /** Emitted when the user clicks the Connect button */ export class LoginConnectEvent extends Event { constructor( - public selectedNetwork: Network, + public selectedNetwork: PublicNetwork, public selectedIdp: Idp, public clientId: string ) { @@ -34,7 +34,7 @@ export class LoginBackEvent extends Event { @customElement('wg-login-form') export class WgLoginForm extends BaseElement { /** Available networks to show in the dropdown */ - @property({ type: Array }) networks: Network[] = [] + @property({ type: Array }) networks: PublicNetwork[] = [] /** Available identity providers */ @property({ type: Array }) idps: Idp[] = [] @@ -42,7 +42,7 @@ export class WgLoginForm extends BaseElement { @property({ type: Boolean }) connecting = false @property({ type: String }) backHref = '/' - @state() accessor selectedNetwork: Network | null = null + @state() accessor selectedNetwork: PublicNetwork | null = null @state() accessor selectedIdp: Idp | null = null @state() accessor message: string | null = null @state() accessor messageType: 'error' | 'info' | null = null @@ -141,7 +141,7 @@ export class WgLoginForm extends BaseElement { if (changedProperties.has('networks') && !this.selectedNetwork) { const index = this.networks.findIndex( - (network) => network.auth.method !== 'client_credentials' + (network) => network.authMethod !== 'client_credentials' ) if (index >= 0) { @@ -211,10 +211,10 @@ export class WgLoginForm extends BaseElement { this.renderRoot.querySelector( '#client-id' ) as HTMLInputElement | null - )?.value || this.selectedNetwork.auth.clientId + )?.value || this.selectedNetwork.clientId this.dispatchEvent( - new LoginConnectEvent(this.selectedNetwork, idp, clientId) + new LoginConnectEvent(this.selectedNetwork, idp, clientId || '') ) } @@ -262,7 +262,7 @@ export class WgLoginForm extends BaseElement { (net, index) => html`