diff --git a/api-specs/openrpc-dapp-api.json b/api-specs/openrpc-dapp-api.json index b194a202..f5f6c7e1 100644 --- a/api-specs/openrpc-dapp-api.json +++ b/api-specs/openrpc-dapp-api.json @@ -29,13 +29,18 @@ "status": { "$ref": "#/components/schemas/StatusEvent" }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "sessionToken": { "title": "sessionToken", "type": "string", "description": "JWT authentication token (if applicable)." } }, - "required": ["status", "sessionToken"] + "required": ["status", "userId", "sessionToken"] } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId." diff --git a/api-specs/openrpc-dapp-remote-api.json b/api-specs/openrpc-dapp-remote-api.json index 259bc12a..29db86d0 100644 --- a/api-specs/openrpc-dapp-remote-api.json +++ b/api-specs/openrpc-dapp-remote-api.json @@ -189,6 +189,11 @@ "type": "string", "description": "A CAIP-2 compliant network ID, e.g. 'canton:da-mainnet'." }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "sessionToken": { "title": "sessionToken", "type": "string", diff --git a/api-specs/openrpc-user-api.json b/api-specs/openrpc-user-api.json index de62dd13..fe97486a 100644 --- a/api-specs/openrpc-user-api.json +++ b/api-specs/openrpc-user-api.json @@ -611,6 +611,11 @@ "network": { "$ref": "#/components/schemas/Network" }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "accessToken": { "title": "accessToken", "type": "string", diff --git a/core/splice-provider/src/SpliceProviderHttp.ts b/core/splice-provider/src/SpliceProviderHttp.ts index 74104c4b..042abe02 100644 --- a/core/splice-provider/src/SpliceProviderHttp.ts +++ b/core/splice-provider/src/SpliceProviderHttp.ts @@ -13,6 +13,7 @@ import { popupHref } from '@canton-network/core-wallet-ui-components' export class SpliceProviderHttp extends SpliceProviderBase { private sessionToken?: string + private userId?: string private socket: Socket private transport: HttpTransport @@ -42,11 +43,13 @@ export class SpliceProviderHttp extends SpliceProviderBase { constructor( private url: URL, - sessionToken?: string + sessionToken?: string, + userId?: string ) { super() if (sessionToken) this.sessionToken = sessionToken + if (userId) this.userId = userId this.transport = new HttpTransport(url, sessionToken) this.socket = this.openSocket(url) @@ -78,6 +81,7 @@ export class SpliceProviderHttp extends SpliceProviderBase { kernel: statusResult.kernel, networkId: statusResult.networkId, sessionToken: this.sessionToken, + userId: this.userId, }) }) .catch((err) => { diff --git a/core/wallet-dapp-remote-rpc-client/src/index.ts b/core/wallet-dapp-remote-rpc-client/src/index.ts index 9a4b1336..a9499e2c 100644 --- a/core/wallet-dapp-remote-rpc-client/src/index.ts +++ b/core/wallet-dapp-remote-rpc-client/src/index.ts @@ -98,6 +98,12 @@ export interface JsPrepareSubmissionResponse { */ export type UserUrl = string export type Response = string +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * Set as primary wallet for dApp usage. @@ -307,6 +313,7 @@ export interface LedgerApiResult { export interface OnConnectedEvent { kernel: KernelInfo networkId: NetworkId + userId?: UserId sessionToken?: SessionToken [k: string]: any } diff --git a/core/wallet-dapp-remote-rpc-client/src/openrpc.json b/core/wallet-dapp-remote-rpc-client/src/openrpc.json index 259bc12a..29db86d0 100644 --- a/core/wallet-dapp-remote-rpc-client/src/openrpc.json +++ b/core/wallet-dapp-remote-rpc-client/src/openrpc.json @@ -189,6 +189,11 @@ "type": "string", "description": "A CAIP-2 compliant network ID, e.g. 'canton:da-mainnet'." }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "sessionToken": { "title": "sessionToken", "type": "string", diff --git a/core/wallet-dapp-rpc-client/src/index.ts b/core/wallet-dapp-rpc-client/src/index.ts index 195d8944..66007719 100644 --- a/core/wallet-dapp-rpc-client/src/index.ts +++ b/core/wallet-dapp-rpc-client/src/index.ts @@ -68,6 +68,12 @@ export interface StatusEvent { networkId?: NetworkId [k: string]: any } +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * JWT authentication token (if applicable). @@ -278,6 +284,7 @@ export interface LedgerApiParams { } export interface ConnectResult { status: StatusEvent + userId: UserId sessionToken: SessionToken [k: string]: any } diff --git a/core/wallet-dapp-rpc-client/src/openrpc.json b/core/wallet-dapp-rpc-client/src/openrpc.json index b194a202..f5f6c7e1 100644 --- a/core/wallet-dapp-rpc-client/src/openrpc.json +++ b/core/wallet-dapp-rpc-client/src/openrpc.json @@ -29,13 +29,18 @@ "status": { "$ref": "#/components/schemas/StatusEvent" }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "sessionToken": { "title": "sessionToken", "type": "string", "description": "JWT authentication token (if applicable)." } }, - "required": ["status", "sessionToken"] + "required": ["status", "userId", "sessionToken"] } }, "description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId." diff --git a/core/wallet-user-rpc-client/src/index.ts b/core/wallet-user-rpc-client/src/index.ts index c2e9fcf8..cfd03072 100644 --- a/core/wallet-user-rpc-client/src/index.ts +++ b/core/wallet-user-rpc-client/src/index.ts @@ -173,6 +173,12 @@ export interface Wallet { export type Added = Wallet[] export type Removed = Wallet[] export type Networks = Network[] +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * The access token for the session. @@ -187,6 +193,7 @@ export type Status = 'connected' | 'disconnected' */ export interface Session { network: Network + userId?: UserId accessToken: AccessToken status: Status } @@ -285,6 +292,7 @@ export interface ListNetworksResult { */ export interface AddSessionResult { network: Network + userId?: UserId accessToken: AccessToken status: Status } diff --git a/core/wallet-user-rpc-client/src/openrpc.json b/core/wallet-user-rpc-client/src/openrpc.json index de62dd13..fe97486a 100644 --- a/core/wallet-user-rpc-client/src/openrpc.json +++ b/core/wallet-user-rpc-client/src/openrpc.json @@ -611,6 +611,11 @@ "network": { "$ref": "#/components/schemas/Network" }, + "userId": { + "title": "userId", + "type": "string", + "description": "The user ID associated with the session." + }, "accessToken": { "title": "accessToken", "type": "string", diff --git a/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts b/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts index e9567b2e..c8a27e40 100644 --- a/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts +++ b/sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts @@ -68,6 +68,12 @@ export interface StatusEvent { networkId?: NetworkId [k: string]: any } +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * JWT authentication token (if applicable). @@ -278,6 +284,7 @@ export interface LedgerApiParams { } export interface ConnectResult { status: StatusEvent + userId: UserId sessionToken: SessionToken [k: string]: any } diff --git a/sdk/dapp-sdk/src/provider.ts b/sdk/dapp-sdk/src/provider.ts index fb1b42e5..42bc3783 100644 --- a/sdk/dapp-sdk/src/provider.ts +++ b/sdk/dapp-sdk/src/provider.ts @@ -35,7 +35,11 @@ export class Provider implements SpliceProvider { private httpProvider?: SpliceProvider private windowProvider?: SpliceProvider - constructor({ walletType, url }: DiscoverResult, sessionToken?: string) { + constructor( + { walletType, url }: DiscoverResult, + sessionToken?: string, + userId?: string + ) { if (walletType == 'extension') { this.providerType = ProviderType.WINDOW this.windowProvider = new SpliceProviderWindow() @@ -43,7 +47,8 @@ export class Provider implements SpliceProvider { this.providerType = ProviderType.HTTP this.httpProvider = new SpliceProviderHttp( new URL(url), - sessionToken + sessionToken, + userId ) } else { throw new Error(`Unsupported wallet type ${walletType}`) @@ -170,6 +175,7 @@ export const dappController = (provider: SpliceProvider) => (event) => { clearTimeout(timeout) const result: dappAPI.ConnectResult = { + userId: event.userId ?? '', sessionToken: event.sessionToken ?? '', status: { ...event, diff --git a/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts b/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts index e9567b2e..c8a27e40 100644 --- a/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts @@ -68,6 +68,12 @@ export interface StatusEvent { networkId?: NetworkId [k: string]: any } +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * JWT authentication token (if applicable). @@ -278,6 +284,7 @@ export interface LedgerApiParams { } export interface ConnectResult { status: StatusEvent + userId: UserId sessionToken: SessionToken [k: string]: any } diff --git a/wallet-gateway/remote/src/dapp-api/controller.ts b/wallet-gateway/remote/src/dapp-api/controller.ts index 12243777..e314f4d3 100644 --- a/wallet-gateway/remote/src/dapp-api/controller.ts +++ b/wallet-gateway/remote/src/dapp-api/controller.ts @@ -58,6 +58,7 @@ export const dappController = ( const logger = _logger.child({ component: 'dapp-controller' }) return buildController({ connect: async () => ({ + userId: '', sessionToken: '', status: { kernel: kernelInfo, diff --git a/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts b/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts index e0bbac7a..9d39e437 100644 --- a/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts +++ b/wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts @@ -98,6 +98,12 @@ export interface JsPrepareSubmissionResponse { */ export type UserUrl = string export type Response = string +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * Set as primary wallet for dApp usage. @@ -307,6 +313,7 @@ export interface LedgerApiResult { export interface OnConnectedEvent { kernel: KernelInfo networkId: NetworkId + userId?: UserId sessionToken?: SessionToken [k: string]: any } diff --git a/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts b/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts index 073d5f29..ce5345b3 100644 --- a/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts +++ b/wallet-gateway/remote/src/user-api/rpc-gen/typings.ts @@ -173,6 +173,12 @@ export interface Wallet { export type Added = Wallet[] export type Removed = Wallet[] export type Networks = Network[] +/** + * + * The user ID associated with the session. + * + */ +export type UserId = string /** * * The access token for the session. @@ -187,6 +193,7 @@ export type Status = 'connected' | 'disconnected' */ export interface Session { network: Network + userId?: UserId accessToken: AccessToken status: Status } @@ -285,6 +292,7 @@ export interface ListNetworksResult { */ export interface AddSessionResult { network: Network + userId?: UserId accessToken: AccessToken status: Status }