Skip to content

Commit

Permalink
chore: bumped @matrixai/rpc to 0.4.1 and updated JSONRPC types …
Browse files Browse the repository at this point in the history
…to be less confusing

chore: bump `@matrixai/rpc` to `0.3.1`

[ci-skip]
  • Loading branch information
amydevs committed Nov 3, 2023
1 parent af8cd4f commit 77d7fd7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@matrixai/mdns": "^1.2.3",
"@matrixai/quic": "^1.1.1",
"@matrixai/resources": "^1.1.5",
"@matrixai/rpc": "^0.2.6",
"@matrixai/rpc": "^0.4.1",
"@matrixai/timer": "^1.1.2",
"@matrixai/workers": "^1.3.7",
"@matrixai/ws": "^1.1.7",
Expand Down
9 changes: 6 additions & 3 deletions src/client/authenticationMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import type { ClientRPCRequestParams, ClientRPCResponseResult } from './types';
import type { Session } from '../sessions';
import type SessionManager from '../sessions/SessionManager';
import type KeyRing from '../keys/KeyRing';
import type { JSONRPCError, JSONRPCResponseError } from '@matrixai/rpc';
import type {
JSONRPCResponseError,
JSONRPCResponseFailed,
} from '@matrixai/rpc';
import { TransformStream } from 'stream/web';
import { authenticate, decodeAuth } from './utils';
import { sysexits } from '../errors';
Expand Down Expand Up @@ -43,12 +46,12 @@ function authenticationMiddlewareServer(
);
} catch (e) {
controller.error(e);
const rpcError: JSONRPCError = {
const rpcError: JSONRPCResponseError = {
code: e.exitCode ?? sysexits.UNKNOWN,
message: e.description ?? '',
data: networkUtils.fromError(e),
};
const rpcErrorMessage: JSONRPCResponseError = {
const rpcErrorMessage: JSONRPCResponseFailed = {
jsonrpc: '2.0',
error: rpcError,
id: null,
Expand Down
39 changes: 16 additions & 23 deletions src/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
JSONObject,
JSONValue,
JSONRPCParams,
JSONRPCResult,
} from '@matrixai/rpc';
import type { JSONObject, JSONRPCResponseResult } from '@matrixai/rpc';
import type {
GestaltIdEncoded,
IdentityId,
Expand All @@ -22,23 +17,21 @@ import type {
import type { Notification } from '../notifications/types';
import type { ProviderToken } from '../identities/types';

// Prevent overwriting the metadata type with `Omit<>`
type ClientRPCRequestParams<T extends JSONObject = JSONObject> = {
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
}>;
} & JSONRPCParams<T>;

// Prevent overwriting the metadata type with `Omit<>`
type ClientRPCResponseResult<T extends JSONObject = JSONObject> = {
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
}>;
} & JSONRPCResult<T>;
type ClientRPCRequestParams<T extends JSONObject = JSONObject> =
JSONRPCResponseResult<
T,
Partial<{
authorization: string;
}>
>;

type ClientRPCResponseResult<T extends JSONObject = JSONObject> =
JSONRPCResponseResult<
T,
Partial<{
authorization: string;
}>
>;

type StatusResultMessage = {
pid: number;
Expand Down
10 changes: 7 additions & 3 deletions src/nodes/agent/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import type { JSONObject, JSONRPCParams, JSONRPCResult } from '@matrixai/rpc';
import type {
JSONObject,
JSONRPCRequestParams,
JSONRPCResponseResult,
} from '@matrixai/rpc';
import type { SignedTokenEncoded } from '../../tokens/types';
import type { ClaimIdEncoded, NodeIdEncoded, VaultIdEncoded } from '../../ids';
import type { VaultAction, VaultName } from '../../vaults/types';
import type { SignedNotification } from '../../notifications/types';

type AgentRPCRequestParams<T extends JSONObject = JSONObject> =
JSONRPCParams<T>;
JSONRPCRequestParams<T>;

type AgentRPCResponseResult<T extends JSONObject = JSONObject> =
JSONRPCResult<T>;
JSONRPCResponseResult<T>;

type ClaimIdMessage = {
claimIdEncoded: ClaimIdEncoded;
Expand Down

0 comments on commit 77d7fd7

Please sign in to comment.