Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: merge staging to master #860

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/acl/ACL.ts
Original file line number Diff line number Diff line change
@@ -144,11 +144,7 @@ class ACL {
if (permId in permIds) {
nodePerm = permIds[permId];
// Get the first existing perm object
let perm: Permission;
for (const nodeId_ in nodePerm) {
perm = nodePerm[nodeId_];
break;
}
const perm = Object.values(nodePerm)[0];
// All perm objects are shared
nodePerm[nodeId] = perm!;
} else {
@@ -614,8 +610,8 @@ class ACL {
[...this.aclNodesDbPath, nodeId.toBuffer()],
true,
);
// Skip if the nodeId doesn't exist
// this means that it previously been removed
// Skip if the nodeId doesn't exist. This means that it has previously
// been removed.
if (permId == null) {
continue;
}
4 changes: 2 additions & 2 deletions src/client/callers/vaultsSecretsGet.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { HandlerTypes } from '@matrixai/rpc';
import type VaultsSecretsGet from '../handlers/VaultsSecretsGet';
import { ServerCaller } from '@matrixai/rpc';
import { UnaryCaller } from '@matrixai/rpc';

type CallerTypes = HandlerTypes<VaultsSecretsGet>;

const vaultsSecretsGet = new ServerCaller<
const vaultsSecretsGet = new UnaryCaller<
CallerTypes['input'],
CallerTypes['output']
>();
2 changes: 1 addition & 1 deletion src/client/handlers/AgentStatus.ts
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import type {
} from '../types';
import type PolykeyAgent from '../../PolykeyAgent';
import { UnaryHandler } from '@matrixai/rpc';
import * as nodesUtils from '../../nodes/utils';
import config from '../../config';
import * as nodesUtils from '../../nodes/utils';

class AgentStatus extends UnaryHandler<
{
5 changes: 3 additions & 2 deletions src/client/handlers/AuditEventsGet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type { ClientRPCRequestParams, ClientRPCResponseResult } from '../types';
import type {
AuditEvent,
@@ -42,8 +43,8 @@ class AuditEventsGet extends ServerHandler<
}> & {
paths: Array<TopicSubPath>;
},
_cancel,
_meta,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<AuditEventSerialized>> {
const { audit }: { audit: Audit } = this.container;
2 changes: 1 addition & 1 deletion src/client/handlers/GestaltsActionsGetByIdentity.ts
Original file line number Diff line number Diff line change
@@ -8,9 +8,9 @@ import type GestaltGraph from '../../gestalts/GestaltGraph';
import type { GestaltAction } from '../../gestalts/types';
import type { IdentityId, ProviderId } from '../../ids';
import { UnaryHandler } from '@matrixai/rpc';
import * as ids from '../../ids';
import { validateSync } from '../../validation';
import { matchSync } from '../../utils';
import * as ids from '../../ids';

class GestaltsActionsGetByIdentity extends UnaryHandler<
{
13 changes: 7 additions & 6 deletions src/client/handlers/IdentitiesAuthenticate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type {
AuthProcessMessage,
ClientRPCRequestParams,
@@ -21,11 +23,10 @@ class IdentitiesAuthenticate extends ServerHandler<
public timeout = 120000; // 2 Minutes
public handle = async function* (
input: ClientRPCRequestParams<{ providerId: string }>,
_cancel,
_meta,
ctx,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<AuthProcessMessage>> {
if (ctx.signal.aborted) throw ctx.signal.reason;
const { identitiesManager }: { identitiesManager: IdentitiesManager } =
this.container;
const {
@@ -52,7 +53,7 @@ class IdentitiesAuthenticate extends ServerHandler<
if (authFlowResult.done) {
never('authFlow signalled done too soon');
}
if (ctx.signal.aborted) throw ctx.signal.reason;
ctx.signal.throwIfAborted();
yield {
request: {
url: authFlowResult.value.url,
@@ -63,7 +64,7 @@ class IdentitiesAuthenticate extends ServerHandler<
if (!authFlowResult.done) {
never('authFlow did not signal done when expected');
}
if (ctx.signal.aborted) throw ctx.signal.reason;
ctx.signal.throwIfAborted();
yield {
response: {
identityId: authFlowResult.value,
15 changes: 7 additions & 8 deletions src/client/handlers/IdentitiesAuthenticatedGet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
@@ -19,11 +21,10 @@ class IdentitiesAuthenticatedGet extends ServerHandler<
> {
public handle = async function* (
input: ClientRPCRequestParams<{ providerId?: string }>,
_cancel,
_meta,
ctx,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<IdentityMessage>> {
if (ctx.signal.aborted) throw ctx.signal.reason;
const { identitiesManager }: { identitiesManager: IdentitiesManager } =
this.container;
let providerId: ProviderId | undefined;
@@ -46,12 +47,10 @@ class IdentitiesAuthenticatedGet extends ServerHandler<
: [providerId];
for (const providerId of providerIds) {
const provider = identitiesManager.getProvider(providerId);
if (provider == null) {
continue;
}
if (provider == null) continue;
const identities = await provider.getAuthIdentityIds();
for (const identityId of identities) {
if (ctx.signal.aborted) throw ctx.signal.reason;
ctx.signal.throwIfAborted();
yield {
providerId: provider.id,
identityId: identityId,
12 changes: 7 additions & 5 deletions src/client/handlers/IdentitiesInfoConnectedGet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
@@ -22,11 +24,10 @@ class IdentitiesInfoConnectedGet extends ServerHandler<
> {
public handle = async function* (
input: ClientRPCRequestParams<ProviderSearchMessage>,
_cancel,
_meta,
ctx,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<IdentityInfoMessage>> {
if (ctx.signal.aborted) throw ctx.signal.reason;
const { identitiesManager }: { identitiesManager: IdentitiesManager } =
this.container;
const {
@@ -71,6 +72,7 @@ class IdentitiesInfoConnectedGet extends ServerHandler<
}
const identities: Array<AsyncGenerator<IdentityData>> = [];
for (const providerId of providerIds) {
ctx.signal.throwIfAborted();
// Get provider from id
const provider = identitiesManager.getProvider(providerId);
if (provider === undefined) {
@@ -94,7 +96,7 @@ class IdentitiesInfoConnectedGet extends ServerHandler<
let count = 0;
for (const gen of identities) {
for await (const identity of gen) {
if (ctx.signal.aborted) throw ctx.signal.reason;
ctx.signal.throwIfAborted();
if (input.limit !== undefined && count >= input.limit) break;
yield {
providerId: identity.providerId,
14 changes: 8 additions & 6 deletions src/client/handlers/IdentitiesInfoGet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
@@ -8,11 +10,11 @@ import type { IdentityId, ProviderId } from '../../ids';
import type IdentitiesManager from '../../identities/IdentitiesManager';
import type { IdentityData } from '../../identities/types';
import { ServerHandler } from '@matrixai/rpc';
import { validateSync } from '../../validation';
import { matchSync } from '../../utils';
import * as ids from '../../ids';
import * as identitiesErrors from '../../identities/errors';
import * as identitiesUtils from '../../identities/utils';
import { validateSync } from '../../validation';
import { matchSync } from '../../utils';

class IdentitiesInfoGet extends ServerHandler<
{
@@ -23,9 +25,9 @@ class IdentitiesInfoGet extends ServerHandler<
> {
public handle = async function* (
input: ClientRPCRequestParams<ProviderSearchMessage>,
_cancel,
_meta,
ctx,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<IdentityInfoMessage>> {
if (ctx.signal.aborted) throw ctx.signal.reason;
const { identitiesManager }: { identitiesManager: IdentitiesManager } =
@@ -86,7 +88,7 @@ class IdentitiesInfoGet extends ServerHandler<
input.limit = identities.length;
}
for (let i = 0; i < input.limit; i++) {
if (ctx.signal.aborted) throw ctx.signal.reason;
ctx.signal.throwIfAborted();
const identity = identities[i];
if (identity !== undefined) {
if (identitiesUtils.matchIdentityData(identity, searchTerms)) {
16 changes: 8 additions & 8 deletions src/client/handlers/KeysCertsChainGet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { JSONValue } from '@matrixai/rpc';
import type {
CertMessage,
ClientRPCRequestParams,
@@ -14,17 +16,15 @@ class KeysCertsChainGet extends ServerHandler<
ClientRPCResponseResult<CertMessage>
> {
public handle = async function* (
_input,
_cancel,
_meta,
ctx,
_input: ClientRPCRequestParams,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): AsyncGenerator<ClientRPCResponseResult<CertMessage>> {
const { certManager }: { certManager: CertManager } = this.container;
for (const certPEM of await certManager.getCertPEMsChain()) {
if (ctx.signal.aborted) throw ctx.signal.reason;
yield {
cert: certPEM,
};
ctx.signal.throwIfAborted();
yield { cert: certPEM };
}
};
}
4 changes: 1 addition & 3 deletions src/client/handlers/KeysCertsGet.ts
Original file line number Diff line number Diff line change
@@ -16,9 +16,7 @@ class KeysCertsGet extends UnaryHandler<
public handle = async (): Promise<ClientRPCResponseResult<CertMessage>> => {
const { certManager }: { certManager: CertManager } = this.container;
const cert = await certManager.getCurrentCertPEM();
return {
cert,
};
return { cert };
};
}

2 changes: 0 additions & 2 deletions src/client/handlers/KeysKeyPairRenew.ts
Original file line number Diff line number Diff line change
@@ -17,11 +17,9 @@ class KeysKeyPairRenew extends UnaryHandler<
input: ClientRPCRequestParams<PasswordMessage>,
): Promise<ClientRPCResponseResult> => {
const { certManager }: { certManager: CertManager } = this.container;

// Other domains will be updated accordingly via the `EventBus` so we
// only need to modify the KeyManager
await certManager.renewCertWithNewKeyPair(input.password);

return {};
};
}
2 changes: 1 addition & 1 deletion src/client/handlers/KeysVerify.ts
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ class KeysVerify extends UnaryHandler<
Buffer.from(input.data, 'binary'),
Buffer.from(input.signature, 'binary') as Signature,
);
return { type: 'success', success: success };
return { success: success };
};
}

11 changes: 8 additions & 3 deletions src/client/handlers/NodesAdd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { ContextTimed } from '@matrixai/contexts';
import type { DB } from '@matrixai/db';
import type { JSONValue } from '@matrixai/rpc';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
@@ -8,11 +10,11 @@ import type { NodeId } from '../../ids';
import type { Host, Port } from '../../network/types';
import type NodeManager from '../../nodes/NodeManager';
import { UnaryHandler } from '@matrixai/rpc';
import { matchSync } from '../../utils';
import { validateSync } from '../../validation';
import * as ids from '../../ids';
import * as networkUtils from '../../network/utils';
import * as nodeErrors from '../../nodes/errors';
import { matchSync } from '../../utils';
import { validateSync } from '../../validation';

class NodesAdd extends UnaryHandler<
{
@@ -24,6 +26,9 @@ class NodesAdd extends UnaryHandler<
> {
public handle = async (
input: ClientRPCRequestParams<NodesAddMessage>,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): Promise<ClientRPCResponseResult> => {
const { db, nodeManager }: { db: DB; nodeManager: NodeManager } =
this.container;
@@ -72,8 +77,8 @@ class NodesAdd extends UnaryHandler<
true,
input.force ?? false,
1500,
undefined,
tran,
ctx,
),
);
return {};
6 changes: 3 additions & 3 deletions src/client/handlers/NodesClaim.ts
Original file line number Diff line number Diff line change
@@ -41,11 +41,11 @@ class NodesClaim extends UnaryHandler<
},
);
await db.withTransactionF(async (tran) => {
// Attempt to claim the node,
// if there is no permission then we get an error
// Attempt to claim the node. If there is no permission then we get an
// error.
await nodeManager.claimNode(nodeId, tran);
});
return { type: 'success', success: true };
return { success: true };
};
}

18 changes: 7 additions & 11 deletions src/client/handlers/NodesFind.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { JSONValue } from '@matrixai/rpc';
import type { ContextTimed } from '@matrixai/contexts';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
@@ -6,12 +8,11 @@ import type {
} from '../types';
import type { NodeId } from '../../ids';
import type NodeManager from '../../nodes/NodeManager';
import type { ContextTimed } from '@matrixai/contexts';
import { UnaryHandler } from '@matrixai/rpc';
import * as ids from '../../ids';
import * as nodesErrors from '../../nodes/errors';
import { validateSync } from '../../validation';
import { matchSync } from '../../utils';
import * as ids from '../../ids';
import * as nodesErrors from '../../nodes/errors';

class NodesFind extends UnaryHandler<
{
@@ -22,8 +23,8 @@ class NodesFind extends UnaryHandler<
> {
public handle = async (
input: ClientRPCRequestParams<NodeIdMessage>,
_cancel,
_meta,
_cancel: (reason?: any) => void,
_meta: Record<string, JSONValue>,
ctx: ContextTimed,
): Promise<ClientRPCResponseResult<NodesFindMessage>> => {
const { nodeManager }: { nodeManager: NodeManager } = this.container;
@@ -42,12 +43,7 @@ class NodesFind extends UnaryHandler<
nodeId: input.nodeIdEncoded,
},
);
const result = await nodeManager.findNode(
{
nodeId: nodeId,
},
ctx,
);
const result = await nodeManager.findNode({ nodeId: nodeId }, ctx);
if (result == null) {
throw new nodesErrors.ErrorNodeGraphNodeIdNotFound();
}
Loading