doover-js 0.14.1 → 0.15.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/apis/agents-api.d.ts +108 -0
- package/dist/apis/agents-api.js +64 -6
- package/dist/apis/users-api.d.ts +2 -0
- package/dist/apis/users-api.js +4 -0
- package/dist/client/doover-client.d.ts +3 -0
- package/dist/client/doover-client.js +4 -0
- package/dist/client/local-agent-client.js +7 -0
- package/dist/client/multiplex-client.js +7 -0
- package/dist/esm/apis/agents-api.d.ts +108 -0
- package/dist/esm/apis/agents-api.js +64 -6
- package/dist/esm/apis/users-api.d.ts +2 -0
- package/dist/esm/apis/users-api.js +4 -0
- package/dist/esm/client/doover-client.d.ts +3 -0
- package/dist/esm/client/doover-client.js +4 -0
- package/dist/esm/client/local-agent-client.js +7 -0
- package/dist/esm/client/multiplex-client.js +7 -0
- package/dist/esm/http/errors.d.ts +4 -0
- package/dist/esm/http/errors.js +11 -0
- package/dist/esm/http/index.d.ts +1 -1
- package/dist/esm/http/index.js +1 -1
- package/dist/esm/http/rest-client.d.ts +4 -0
- package/dist/esm/http/rest-client.js +22 -4
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/react/index.d.ts +5 -4
- package/dist/esm/react/index.js +2 -1
- package/dist/esm/react/useAgentCredentials.d.ts +30 -0
- package/dist/esm/react/useAgentCredentials.js +69 -0
- package/dist/esm/types/viewer.d.ts +5 -0
- package/dist/http/errors.d.ts +4 -0
- package/dist/http/errors.js +14 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +3 -1
- package/dist/http/rest-client.d.ts +4 -0
- package/dist/http/rest-client.js +21 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -2
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +10 -1
- package/dist/react/useAgentCredentials.d.ts +30 -0
- package/dist/react/useAgentCredentials.js +79 -0
- package/dist/types/viewer.d.ts +5 -0
- package/package.json +1 -1
package/dist/esm/http/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { RestClient } from "./rest-client.js";
|
|
2
|
-
export { DooverApiError, DooverGatewayError, DooverValidationError } from "./errors.js";
|
|
2
|
+
export { DooverApiError, DooverGatewayError, DooverMfaRequiredError, DooverValidationError, isMfaRequiredBody, } from "./errors.js";
|
|
@@ -3,6 +3,7 @@ import type { NetworkStatusSource } from "../client/network-status.js";
|
|
|
3
3
|
import type { AuthConfig } from "../auth/build-auth.js";
|
|
4
4
|
import type { DooverAuth } from "../auth/doover-auth.js";
|
|
5
5
|
import type { DooverStatsCollector } from "../client/stats.js";
|
|
6
|
+
import { DooverMfaRequiredError } from "./errors.js";
|
|
6
7
|
export interface DooverClientConfig extends AuthConfig {
|
|
7
8
|
networkStatus?: NetworkStatusSource;
|
|
8
9
|
/** Data API reachability checks while reachability is observed. Set false to disable. */
|
|
@@ -47,9 +48,12 @@ export declare class RestClient {
|
|
|
47
48
|
readonly config: Required<Pick<DooverClientConfig, "dataRestUrl" | "controlApiUrl" | "dataWssUrl" | "sharing" | "impersonateUserStorageKey">> & Pick<DooverClientConfig, "organisationId" | "fetchImpl" | "webSocketImpl" | "webSocketFactory">;
|
|
48
49
|
readonly auth: DooverAuth | null;
|
|
49
50
|
private stats;
|
|
51
|
+
private readonly mfaRequiredListeners;
|
|
50
52
|
constructor(config: DooverClientConfig, auth?: DooverAuth, onTransportFailure?: (() => void) | undefined);
|
|
51
53
|
/** Attach a stats collector. Call with `null` to detach. */
|
|
52
54
|
setStats(stats: DooverStatsCollector | null): void;
|
|
55
|
+
/** Called whenever a request is refused because the organisation requires MFA. */
|
|
56
|
+
onMfaRequired(listener: (error: DooverMfaRequiredError) => void): () => void;
|
|
53
57
|
request<T>(options: RequestOptions): Promise<T>;
|
|
54
58
|
private doRequest;
|
|
55
59
|
private prepareAuth;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DooverApiError } from "./errors.js";
|
|
1
|
+
import { DooverApiError, DooverMfaRequiredError, isMfaRequiredBody } from "./errors.js";
|
|
2
2
|
export class RestClient {
|
|
3
3
|
constructor(config, auth, onTransportFailure) {
|
|
4
4
|
this.onTransportFailure = onTransportFailure;
|
|
5
5
|
this.stats = null;
|
|
6
|
+
this.mfaRequiredListeners = new Set();
|
|
6
7
|
this.config = {
|
|
7
8
|
...config,
|
|
8
9
|
sharing: config.sharing ?? "internal",
|
|
@@ -15,6 +16,13 @@ export class RestClient {
|
|
|
15
16
|
setStats(stats) {
|
|
16
17
|
this.stats = stats;
|
|
17
18
|
}
|
|
19
|
+
/** Called whenever a request is refused because the organisation requires MFA. */
|
|
20
|
+
onMfaRequired(listener) {
|
|
21
|
+
this.mfaRequiredListeners.add(listener);
|
|
22
|
+
return () => {
|
|
23
|
+
this.mfaRequiredListeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
18
26
|
async request(options) {
|
|
19
27
|
const startedAt = this.stats?.recordRestStart() ?? null;
|
|
20
28
|
try {
|
|
@@ -42,7 +50,7 @@ export class RestClient {
|
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
if (!response.ok) {
|
|
45
|
-
|
|
53
|
+
const params = {
|
|
46
54
|
status: response.status,
|
|
47
55
|
body: payload,
|
|
48
56
|
url: request.url,
|
|
@@ -53,7 +61,14 @@ export class RestClient {
|
|
|
53
61
|
typeof payload.message === "string"
|
|
54
62
|
? payload.message
|
|
55
63
|
: undefined,
|
|
56
|
-
}
|
|
64
|
+
};
|
|
65
|
+
if (response.status === 403 && isMfaRequiredBody(payload)) {
|
|
66
|
+
const error = new DooverMfaRequiredError(params);
|
|
67
|
+
for (const listener of this.mfaRequiredListeners)
|
|
68
|
+
listener(error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
throw new DooverApiError(params);
|
|
57
72
|
}
|
|
58
73
|
return payload;
|
|
59
74
|
}
|
|
@@ -63,7 +78,10 @@ export class RestClient {
|
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
80
|
prepareRequest(options) {
|
|
66
|
-
|
|
81
|
+
// fetch normalises GET, POST, PUT and DELETE but not PATCH, and a CORS
|
|
82
|
+
// preflight compares methods case-sensitively; refine's custom calls
|
|
83
|
+
// pass them lowercase.
|
|
84
|
+
const method = (options.method ?? "GET").toUpperCase();
|
|
67
85
|
const url = this.buildUrl(options.baseUrl ?? this.config.dataRestUrl, options.path, options.query);
|
|
68
86
|
const headers = new Headers(options.headers);
|
|
69
87
|
const body = this.normalizeBody(options.body, headers);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { getDooverClient, peekDooverClient, resetDooverClient, } from "./client/
|
|
|
7
7
|
export { DooverStatsCollector } from "./client/stats.js";
|
|
8
8
|
export type { DooverStatsSnapshot, RestStatsSnapshot, GatewayStatsSnapshot, } from "./client/stats.js";
|
|
9
9
|
export { AgentsApi } from "./apis/agents-api.js";
|
|
10
|
-
export type { AgentTokenState, AgentTokenPolicy, TokenPolicyField, AdhocTokenResponse, DeviceTokenResponse, ResourcePermission, } from "./apis/agents-api.js";
|
|
10
|
+
export type { AgentTokenState, AgentTokenPolicy, TokenPolicyField, AdhocTokenResponse, DeviceTokenResponse, ResourcePermission, AgentCredential, CreatedCredential, CredentialKind, KeyRestriction, KeyPolicy, } from "./apis/agents-api.js";
|
|
11
11
|
export { AggregatesApi } from "./apis/aggregates-api.js";
|
|
12
12
|
export { AlarmsApi } from "./apis/alarms-api.js";
|
|
13
13
|
export { ChannelsApi } from "./apis/channels-api.js";
|
|
@@ -50,7 +50,7 @@ export { GatewayClient } from "./gateway/gateway-client.js";
|
|
|
50
50
|
export type * from "./gateway/types.js";
|
|
51
51
|
export { RestClient } from "./http/rest-client.js";
|
|
52
52
|
export type { DooverClientConfig } from "./http/rest-client.js";
|
|
53
|
-
export { DooverApiError, DooverGatewayError, DooverValidationError, } from "./http/errors.js";
|
|
53
|
+
export { DooverApiError, DooverGatewayError, DooverMfaRequiredError, DooverValidationError, isMfaRequiredBody, } from "./http/errors.js";
|
|
54
54
|
export { DooverDataProvider } from "./viewer/doover-data-provider.js";
|
|
55
55
|
export { getIdentifierFromPath } from "./viewer/path-parsing.js";
|
|
56
56
|
export type * from "./types/common.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -30,7 +30,7 @@ export { DooverAuthError } from "./auth/errors.js";
|
|
|
30
30
|
export { buildAuth } from "./auth/build-auth.js";
|
|
31
31
|
export { GatewayClient } from "./gateway/gateway-client.js";
|
|
32
32
|
export { RestClient } from "./http/rest-client.js";
|
|
33
|
-
export { DooverApiError, DooverGatewayError, DooverValidationError, } from "./http/errors.js";
|
|
33
|
+
export { DooverApiError, DooverGatewayError, DooverMfaRequiredError, DooverValidationError, isMfaRequiredBody, } from "./http/errors.js";
|
|
34
34
|
export { DooverDataProvider } from "./viewer/doover-data-provider.js";
|
|
35
35
|
export { getIdentifierFromPath } from "./viewer/path-parsing.js";
|
|
36
36
|
export { DV_AUDIT_CHANNEL } from "./types/audit.js";
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"doover-js","version":"0.
|
|
1
|
+
{"name":"doover-js","version":"0.15.0","type":"module","sideEffects":false}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { DooverProvider, useDooverClient } from "./context.js";
|
|
2
2
|
export type { DooverProviderProps } from "./context.js";
|
|
3
|
-
export type { DataClientStatus, DataClientConnectionState, AgentScope } from "../client/data-client.js";
|
|
3
|
+
export type { DataClientStatus, DataClientConnectionState, AgentScope, } from "../client/data-client.js";
|
|
4
4
|
export { useClientStatus } from "./useClientStatus.js";
|
|
5
5
|
export { useOfflineStatus, hasOfflineStatus } from "./useOfflineStatus.js";
|
|
6
|
-
export type { OfflineStatusSnapshot, OfflineStatusClient } from "./useOfflineStatus.js";
|
|
6
|
+
export type { OfflineStatusSnapshot, OfflineStatusClient, } from "./useOfflineStatus.js";
|
|
7
7
|
export { useConnectionState } from "./useConnectionState.js";
|
|
8
|
-
export type { ConnectionState, ConnectionStatus } from "./useConnectionState.js";
|
|
8
|
+
export type { ConnectionState, ConnectionStatus, } from "./useConnectionState.js";
|
|
9
9
|
export { useAgentConnections, agentConnectionsQueryKey, } from "./useAgentConnections.js";
|
|
10
|
-
export { useChannelSubscription
|
|
10
|
+
export { useChannelSubscription } from "./useChannelSubscription.js";
|
|
11
11
|
export type { ChannelSubscriptionHandlers } from "./useChannelSubscription.js";
|
|
12
12
|
export { useChannelAggregate, channelAggregateQueryKey, } from "./useChannelAggregate.js";
|
|
13
13
|
export type { UseChannelAggregateOptions, UseChannelAggregateResult, } from "./useChannelAggregate.js";
|
|
@@ -35,5 +35,6 @@ export type { DeviceMapEntry, UseDeviceMapOptions, UseDeviceMapResult, } from ".
|
|
|
35
35
|
export { useTurnCredentials } from "./useTurnCredentials.js";
|
|
36
36
|
export { useAgentTokenState, useSetAgentTokenPolicy, useSetAgentAuthLock, useRevokeAgentTokens, useSetRevocationFloor, useCreateAdhocToken, useCreateDeviceToken, agentTokenStateQueryKey, } from "./useAgentTokenState.js";
|
|
37
37
|
export type { UseAgentTokenStateOptions } from "./useAgentTokenState.js";
|
|
38
|
+
export { useAgentCredentials, useOrganisationCredentials, organisationCredentialsQueryKey, useCreateApiKey, useAddDeviceKey, useCreateEnrolmentCode, useRevokeCredential, agentCredentialsQueryKey, } from "./useAgentCredentials.js";
|
|
38
39
|
export { getSharedQueryClient, resetSharedQueryClient, } from "./sharedQueryClient.js";
|
|
39
40
|
export { useServiceReachability } from "./useServiceReachability.js";
|
package/dist/esm/react/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { useClientStatus } from "./useClientStatus.js";
|
|
|
3
3
|
export { useOfflineStatus, hasOfflineStatus } from "./useOfflineStatus.js";
|
|
4
4
|
export { useConnectionState } from "./useConnectionState.js";
|
|
5
5
|
export { useAgentConnections, agentConnectionsQueryKey, } from "./useAgentConnections.js";
|
|
6
|
-
export { useChannelSubscription
|
|
6
|
+
export { useChannelSubscription } from "./useChannelSubscription.js";
|
|
7
7
|
export { useChannelAggregate, channelAggregateQueryKey, } from "./useChannelAggregate.js";
|
|
8
8
|
export { useAgentChannel } from "./useAgentChannel.js";
|
|
9
9
|
export { useSendMessage } from "./useSendMessage.js";
|
|
@@ -18,5 +18,6 @@ export { useMultiAgentChannelMessages, multiAgentChannelMessagesQueryKey, MULTI_
|
|
|
18
18
|
export { useDeviceMap } from "./useDeviceMap.js";
|
|
19
19
|
export { useTurnCredentials } from "./useTurnCredentials.js";
|
|
20
20
|
export { useAgentTokenState, useSetAgentTokenPolicy, useSetAgentAuthLock, useRevokeAgentTokens, useSetRevocationFloor, useCreateAdhocToken, useCreateDeviceToken, agentTokenStateQueryKey, } from "./useAgentTokenState.js";
|
|
21
|
+
export { useAgentCredentials, useOrganisationCredentials, organisationCredentialsQueryKey, useCreateApiKey, useAddDeviceKey, useCreateEnrolmentCode, useRevokeCredential, agentCredentialsQueryKey, } from "./useAgentCredentials.js";
|
|
21
22
|
export { getSharedQueryClient, resetSharedQueryClient, } from "./sharedQueryClient.js";
|
|
22
23
|
export { useServiceReachability } from "./useServiceReachability.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { AgentCredential, KeyRestriction } from "../apis/agents-api.js";
|
|
3
|
+
export declare function agentCredentialsQueryKey(agentId: string | undefined): readonly ["doover", "agent", string | null, "credentials"];
|
|
4
|
+
export declare function organisationCredentialsQueryKey(organisationId: string | undefined): readonly ["doover", "organisation", string | null, "credentials"];
|
|
5
|
+
/** Every credential on an organisation's agents, revoked ones included. */
|
|
6
|
+
export declare function useOrganisationCredentials(organisationId: string | undefined, options?: {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}): UseQueryResult<AgentCredential[]>;
|
|
9
|
+
/** An agent's API keys and device keys, revoked ones included. */
|
|
10
|
+
export declare function useAgentCredentials(agentId: string | undefined, options?: {
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}): UseQueryResult<AgentCredential[]>;
|
|
13
|
+
/** Mint an API key. The key is in the result once; hand it straight to the user. */
|
|
14
|
+
export declare function useCreateApiKey(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
15
|
+
name: string;
|
|
16
|
+
restriction?: KeyRestriction;
|
|
17
|
+
expiresMs?: number;
|
|
18
|
+
}, unknown>;
|
|
19
|
+
/** Register a device's P-256 public key (PEM or JWK). */
|
|
20
|
+
export declare function useAddDeviceKey(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
21
|
+
name: string;
|
|
22
|
+
publicKey: string;
|
|
23
|
+
}, unknown>;
|
|
24
|
+
/** Mint a one-time enrolment code for a device. Shown once. */
|
|
25
|
+
export declare function useCreateEnrolmentCode(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
26
|
+
name: string;
|
|
27
|
+
expiresMs?: number;
|
|
28
|
+
}, unknown>;
|
|
29
|
+
/** Revoke an API key or device key. Takes effect at once. */
|
|
30
|
+
export declare function useRevokeCredential(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
|
|
2
|
+
import { useDooverClient } from "./context.js";
|
|
3
|
+
export function agentCredentialsQueryKey(agentId) {
|
|
4
|
+
return ["doover", "agent", agentId ?? null, "credentials"];
|
|
5
|
+
}
|
|
6
|
+
export function organisationCredentialsQueryKey(organisationId) {
|
|
7
|
+
return [
|
|
8
|
+
"doover",
|
|
9
|
+
"organisation",
|
|
10
|
+
organisationId ?? null,
|
|
11
|
+
"credentials",
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
/** Every credential on an organisation's agents, revoked ones included. */
|
|
15
|
+
export function useOrganisationCredentials(organisationId, options) {
|
|
16
|
+
const client = useDooverClient();
|
|
17
|
+
return useQuery({
|
|
18
|
+
queryKey: organisationCredentialsQueryKey(organisationId),
|
|
19
|
+
enabled: (options?.enabled ?? true) && Boolean(organisationId),
|
|
20
|
+
queryFn: () => client.agents.listOrganisationCredentials(organisationId),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** An agent's API keys and device keys, revoked ones included. */
|
|
24
|
+
export function useAgentCredentials(agentId, options) {
|
|
25
|
+
const client = useDooverClient();
|
|
26
|
+
return useQuery({
|
|
27
|
+
queryKey: agentCredentialsQueryKey(agentId),
|
|
28
|
+
enabled: (options?.enabled ?? true) && Boolean(agentId),
|
|
29
|
+
queryFn: () => client.agents.listCredentials(agentId),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function useCredentialMutation(agentId, mutationFn) {
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: (vars) => mutationFn(agentId, vars),
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
void queryClient.invalidateQueries({
|
|
38
|
+
queryKey: agentCredentialsQueryKey(agentId),
|
|
39
|
+
});
|
|
40
|
+
// Org-wide lists include this agent's keys.
|
|
41
|
+
void queryClient.invalidateQueries({
|
|
42
|
+
queryKey: ["doover", "organisation"],
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Mint an API key. The key is in the result once; hand it straight to the user. */
|
|
48
|
+
export function useCreateApiKey(agentId) {
|
|
49
|
+
const client = useDooverClient();
|
|
50
|
+
return useCredentialMutation(agentId, (id, vars) => client.agents.createApiKey(id, vars.name, {
|
|
51
|
+
restriction: vars.restriction,
|
|
52
|
+
expiresMs: vars.expiresMs,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/** Register a device's P-256 public key (PEM or JWK). */
|
|
56
|
+
export function useAddDeviceKey(agentId) {
|
|
57
|
+
const client = useDooverClient();
|
|
58
|
+
return useCredentialMutation(agentId, (id, vars) => client.agents.addDeviceKey(id, vars.name, vars.publicKey));
|
|
59
|
+
}
|
|
60
|
+
/** Mint a one-time enrolment code for a device. Shown once. */
|
|
61
|
+
export function useCreateEnrolmentCode(agentId) {
|
|
62
|
+
const client = useDooverClient();
|
|
63
|
+
return useCredentialMutation(agentId, (id, vars) => client.agents.createEnrolmentCode(id, vars.name, vars.expiresMs));
|
|
64
|
+
}
|
|
65
|
+
/** Revoke an API key or device key. Takes effect at once. */
|
|
66
|
+
export function useRevokeCredential(agentId) {
|
|
67
|
+
const client = useDooverClient();
|
|
68
|
+
return useCredentialMutation(agentId, (id, credentialId) => client.agents.revokeCredential(id, credentialId));
|
|
69
|
+
}
|
|
@@ -20,12 +20,17 @@ export interface Agent {
|
|
|
20
20
|
};
|
|
21
21
|
extra_config: Record<string, unknown>;
|
|
22
22
|
connection_determination?: "Online" | "Offline";
|
|
23
|
+
/** Server-evaluated warning indicator from `/agents`; `null` when unknown. */
|
|
24
|
+
has_warning?: boolean | null;
|
|
23
25
|
__source?: SourceProvenance;
|
|
24
26
|
}
|
|
25
27
|
export interface User {
|
|
26
28
|
id: string;
|
|
27
29
|
email?: string;
|
|
28
30
|
name?: string;
|
|
31
|
+
mfa_enabled?: boolean;
|
|
32
|
+
/** True when the current organisation requires MFA this user hasn't set up. */
|
|
33
|
+
mfa_required?: boolean;
|
|
29
34
|
__source?: SourceProvenance;
|
|
30
35
|
[key: string]: unknown;
|
|
31
36
|
}
|
package/dist/http/errors.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare class DooverApiError extends Error {
|
|
|
11
11
|
message?: string;
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
+
export declare class DooverMfaRequiredError extends DooverApiError {
|
|
15
|
+
constructor(params: ConstructorParameters<typeof DooverApiError>[0]);
|
|
16
|
+
}
|
|
17
|
+
export declare function isMfaRequiredBody(body: unknown): boolean;
|
|
14
18
|
export declare class DooverValidationError extends Error {
|
|
15
19
|
constructor(message: string);
|
|
16
20
|
}
|
package/dist/http/errors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DooverGatewayError = exports.DooverValidationError = exports.DooverApiError = void 0;
|
|
3
|
+
exports.DooverGatewayError = exports.DooverValidationError = exports.DooverMfaRequiredError = exports.DooverApiError = void 0;
|
|
4
|
+
exports.isMfaRequiredBody = isMfaRequiredBody;
|
|
4
5
|
class DooverApiError extends Error {
|
|
5
6
|
constructor(params) {
|
|
6
7
|
super(params.message ?? `Request failed with status ${params.status}`);
|
|
@@ -12,6 +13,18 @@ class DooverApiError extends Error {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.DooverApiError = DooverApiError;
|
|
16
|
+
class DooverMfaRequiredError extends DooverApiError {
|
|
17
|
+
constructor(params) {
|
|
18
|
+
super(params);
|
|
19
|
+
this.name = "DooverMfaRequiredError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DooverMfaRequiredError = DooverMfaRequiredError;
|
|
23
|
+
function isMfaRequiredBody(body) {
|
|
24
|
+
return (typeof body === "object" &&
|
|
25
|
+
body !== null &&
|
|
26
|
+
body.code === "mfa_required");
|
|
27
|
+
}
|
|
15
28
|
class DooverValidationError extends Error {
|
|
16
29
|
constructor(message) {
|
|
17
30
|
super(message);
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { RestClient } from "./rest-client.js";
|
|
2
2
|
export type { DooverClientConfig, RequestOptions } from "./rest-client.js";
|
|
3
|
-
export { DooverApiError, DooverGatewayError, DooverValidationError } from "./errors.js";
|
|
3
|
+
export { DooverApiError, DooverGatewayError, DooverMfaRequiredError, DooverValidationError, isMfaRequiredBody, } from "./errors.js";
|
package/dist/http/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DooverValidationError = exports.DooverGatewayError = exports.DooverApiError = exports.RestClient = void 0;
|
|
3
|
+
exports.isMfaRequiredBody = exports.DooverValidationError = exports.DooverMfaRequiredError = exports.DooverGatewayError = exports.DooverApiError = exports.RestClient = void 0;
|
|
4
4
|
var rest_client_js_1 = require("./rest-client.js");
|
|
5
5
|
Object.defineProperty(exports, "RestClient", { enumerable: true, get: function () { return rest_client_js_1.RestClient; } });
|
|
6
6
|
var errors_js_1 = require("./errors.js");
|
|
7
7
|
Object.defineProperty(exports, "DooverApiError", { enumerable: true, get: function () { return errors_js_1.DooverApiError; } });
|
|
8
8
|
Object.defineProperty(exports, "DooverGatewayError", { enumerable: true, get: function () { return errors_js_1.DooverGatewayError; } });
|
|
9
|
+
Object.defineProperty(exports, "DooverMfaRequiredError", { enumerable: true, get: function () { return errors_js_1.DooverMfaRequiredError; } });
|
|
9
10
|
Object.defineProperty(exports, "DooverValidationError", { enumerable: true, get: function () { return errors_js_1.DooverValidationError; } });
|
|
11
|
+
Object.defineProperty(exports, "isMfaRequiredBody", { enumerable: true, get: function () { return errors_js_1.isMfaRequiredBody; } });
|
|
@@ -3,6 +3,7 @@ import type { NetworkStatusSource } from "../client/network-status.js";
|
|
|
3
3
|
import type { AuthConfig } from "../auth/build-auth.js";
|
|
4
4
|
import type { DooverAuth } from "../auth/doover-auth.js";
|
|
5
5
|
import type { DooverStatsCollector } from "../client/stats.js";
|
|
6
|
+
import { DooverMfaRequiredError } from "./errors.js";
|
|
6
7
|
export interface DooverClientConfig extends AuthConfig {
|
|
7
8
|
networkStatus?: NetworkStatusSource;
|
|
8
9
|
/** Data API reachability checks while reachability is observed. Set false to disable. */
|
|
@@ -47,9 +48,12 @@ export declare class RestClient {
|
|
|
47
48
|
readonly config: Required<Pick<DooverClientConfig, "dataRestUrl" | "controlApiUrl" | "dataWssUrl" | "sharing" | "impersonateUserStorageKey">> & Pick<DooverClientConfig, "organisationId" | "fetchImpl" | "webSocketImpl" | "webSocketFactory">;
|
|
48
49
|
readonly auth: DooverAuth | null;
|
|
49
50
|
private stats;
|
|
51
|
+
private readonly mfaRequiredListeners;
|
|
50
52
|
constructor(config: DooverClientConfig, auth?: DooverAuth, onTransportFailure?: (() => void) | undefined);
|
|
51
53
|
/** Attach a stats collector. Call with `null` to detach. */
|
|
52
54
|
setStats(stats: DooverStatsCollector | null): void;
|
|
55
|
+
/** Called whenever a request is refused because the organisation requires MFA. */
|
|
56
|
+
onMfaRequired(listener: (error: DooverMfaRequiredError) => void): () => void;
|
|
53
57
|
request<T>(options: RequestOptions): Promise<T>;
|
|
54
58
|
private doRequest;
|
|
55
59
|
private prepareAuth;
|
package/dist/http/rest-client.js
CHANGED
|
@@ -6,6 +6,7 @@ class RestClient {
|
|
|
6
6
|
constructor(config, auth, onTransportFailure) {
|
|
7
7
|
this.onTransportFailure = onTransportFailure;
|
|
8
8
|
this.stats = null;
|
|
9
|
+
this.mfaRequiredListeners = new Set();
|
|
9
10
|
this.config = {
|
|
10
11
|
...config,
|
|
11
12
|
sharing: config.sharing ?? "internal",
|
|
@@ -18,6 +19,13 @@ class RestClient {
|
|
|
18
19
|
setStats(stats) {
|
|
19
20
|
this.stats = stats;
|
|
20
21
|
}
|
|
22
|
+
/** Called whenever a request is refused because the organisation requires MFA. */
|
|
23
|
+
onMfaRequired(listener) {
|
|
24
|
+
this.mfaRequiredListeners.add(listener);
|
|
25
|
+
return () => {
|
|
26
|
+
this.mfaRequiredListeners.delete(listener);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
21
29
|
async request(options) {
|
|
22
30
|
const startedAt = this.stats?.recordRestStart() ?? null;
|
|
23
31
|
try {
|
|
@@ -45,7 +53,7 @@ class RestClient {
|
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
if (!response.ok) {
|
|
48
|
-
|
|
56
|
+
const params = {
|
|
49
57
|
status: response.status,
|
|
50
58
|
body: payload,
|
|
51
59
|
url: request.url,
|
|
@@ -56,7 +64,14 @@ class RestClient {
|
|
|
56
64
|
typeof payload.message === "string"
|
|
57
65
|
? payload.message
|
|
58
66
|
: undefined,
|
|
59
|
-
}
|
|
67
|
+
};
|
|
68
|
+
if (response.status === 403 && (0, errors_js_1.isMfaRequiredBody)(payload)) {
|
|
69
|
+
const error = new errors_js_1.DooverMfaRequiredError(params);
|
|
70
|
+
for (const listener of this.mfaRequiredListeners)
|
|
71
|
+
listener(error);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
throw new errors_js_1.DooverApiError(params);
|
|
60
75
|
}
|
|
61
76
|
return payload;
|
|
62
77
|
}
|
|
@@ -66,7 +81,10 @@ class RestClient {
|
|
|
66
81
|
}
|
|
67
82
|
}
|
|
68
83
|
prepareRequest(options) {
|
|
69
|
-
|
|
84
|
+
// fetch normalises GET, POST, PUT and DELETE but not PATCH, and a CORS
|
|
85
|
+
// preflight compares methods case-sensitively; refine's custom calls
|
|
86
|
+
// pass them lowercase.
|
|
87
|
+
const method = (options.method ?? "GET").toUpperCase();
|
|
70
88
|
const url = this.buildUrl(options.baseUrl ?? this.config.dataRestUrl, options.path, options.query);
|
|
71
89
|
const headers = new Headers(options.headers);
|
|
72
90
|
const body = this.normalizeBody(options.body, headers);
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { getDooverClient, peekDooverClient, resetDooverClient, } from "./client/
|
|
|
7
7
|
export { DooverStatsCollector } from "./client/stats.js";
|
|
8
8
|
export type { DooverStatsSnapshot, RestStatsSnapshot, GatewayStatsSnapshot, } from "./client/stats.js";
|
|
9
9
|
export { AgentsApi } from "./apis/agents-api.js";
|
|
10
|
-
export type { AgentTokenState, AgentTokenPolicy, TokenPolicyField, AdhocTokenResponse, DeviceTokenResponse, ResourcePermission, } from "./apis/agents-api.js";
|
|
10
|
+
export type { AgentTokenState, AgentTokenPolicy, TokenPolicyField, AdhocTokenResponse, DeviceTokenResponse, ResourcePermission, AgentCredential, CreatedCredential, CredentialKind, KeyRestriction, KeyPolicy, } from "./apis/agents-api.js";
|
|
11
11
|
export { AggregatesApi } from "./apis/aggregates-api.js";
|
|
12
12
|
export { AlarmsApi } from "./apis/alarms-api.js";
|
|
13
13
|
export { ChannelsApi } from "./apis/channels-api.js";
|
|
@@ -50,7 +50,7 @@ export { GatewayClient } from "./gateway/gateway-client.js";
|
|
|
50
50
|
export type * from "./gateway/types.js";
|
|
51
51
|
export { RestClient } from "./http/rest-client.js";
|
|
52
52
|
export type { DooverClientConfig } from "./http/rest-client.js";
|
|
53
|
-
export { DooverApiError, DooverGatewayError, DooverValidationError, } from "./http/errors.js";
|
|
53
|
+
export { DooverApiError, DooverGatewayError, DooverMfaRequiredError, DooverValidationError, isMfaRequiredBody, } from "./http/errors.js";
|
|
54
54
|
export { DooverDataProvider } from "./viewer/doover-data-provider.js";
|
|
55
55
|
export { getIdentifierFromPath } from "./viewer/path-parsing.js";
|
|
56
56
|
export type * from "./types/common.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.createNetworkStatusStore = exports.browserNetworkStatus = exports.generateSnowflakeIdAtTime = void 0;
|
|
3
|
+
exports.DV_AUDIT_CHANNEL = exports.getIdentifierFromPath = exports.DooverDataProvider = exports.isMfaRequiredBody = exports.DooverValidationError = exports.DooverMfaRequiredError = exports.DooverGatewayError = exports.DooverApiError = exports.RestClient = exports.GatewayClient = exports.buildAuth = exports.DooverAuthError = exports.AuthProfile = exports.DooverTokenAuth = exports.CookieAuth = exports.DooverAuth = exports.mergeBatchResponses = exports.chunkBatchItems = exports.MAX_BATCH_ITEMS = exports.splitRequestOptions = exports.isDooverRequestOptions = exports.requestOptions = exports.DEFAULT_OFFLINE_RETENTION_MS = exports.MemoryOfflineStorageAdapter = exports.OfflineDataClient = exports.DooverOfflineError = exports.AmbiguousWriteError = exports.UnsupportedCapabilityError = exports.ALL_CAPABILITIES = exports.DooverRpcError = exports.RpcDispatcher = exports.UsersApi = exports.TurnApi = exports.ProcessorsApi = exports.PermissionsApi = exports.OrganisationsApi = exports.NotificationsApi = exports.MessagesApi = exports.ConnectionsApi = exports.ChannelsApi = exports.AlarmsApi = exports.AggregatesApi = exports.AgentsApi = exports.DooverStatsCollector = exports.resetDooverClient = exports.peekDooverClient = exports.getDooverClient = exports.MultiplexClient = exports.LocalAgentClient = exports.DooverClient = void 0;
|
|
4
|
+
exports.createNetworkStatusStore = exports.browserNetworkStatus = exports.generateSnowflakeIdAtTime = exports.extractSnowflakeId = exports.addTimestampToMessage = void 0;
|
|
5
5
|
var doover_client_js_1 = require("./client/doover-client.js");
|
|
6
6
|
Object.defineProperty(exports, "DooverClient", { enumerable: true, get: function () { return doover_client_js_1.DooverClient; } });
|
|
7
7
|
var local_agent_client_js_1 = require("./client/local-agent-client.js");
|
|
@@ -79,7 +79,9 @@ Object.defineProperty(exports, "RestClient", { enumerable: true, get: function (
|
|
|
79
79
|
var errors_js_4 = require("./http/errors.js");
|
|
80
80
|
Object.defineProperty(exports, "DooverApiError", { enumerable: true, get: function () { return errors_js_4.DooverApiError; } });
|
|
81
81
|
Object.defineProperty(exports, "DooverGatewayError", { enumerable: true, get: function () { return errors_js_4.DooverGatewayError; } });
|
|
82
|
+
Object.defineProperty(exports, "DooverMfaRequiredError", { enumerable: true, get: function () { return errors_js_4.DooverMfaRequiredError; } });
|
|
82
83
|
Object.defineProperty(exports, "DooverValidationError", { enumerable: true, get: function () { return errors_js_4.DooverValidationError; } });
|
|
84
|
+
Object.defineProperty(exports, "isMfaRequiredBody", { enumerable: true, get: function () { return errors_js_4.isMfaRequiredBody; } });
|
|
83
85
|
var doover_data_provider_js_1 = require("./viewer/doover-data-provider.js");
|
|
84
86
|
Object.defineProperty(exports, "DooverDataProvider", { enumerable: true, get: function () { return doover_data_provider_js_1.DooverDataProvider; } });
|
|
85
87
|
var path_parsing_js_1 = require("./viewer/path-parsing.js");
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { DooverProvider, useDooverClient } from "./context.js";
|
|
2
2
|
export type { DooverProviderProps } from "./context.js";
|
|
3
|
-
export type { DataClientStatus, DataClientConnectionState, AgentScope } from "../client/data-client.js";
|
|
3
|
+
export type { DataClientStatus, DataClientConnectionState, AgentScope, } from "../client/data-client.js";
|
|
4
4
|
export { useClientStatus } from "./useClientStatus.js";
|
|
5
5
|
export { useOfflineStatus, hasOfflineStatus } from "./useOfflineStatus.js";
|
|
6
|
-
export type { OfflineStatusSnapshot, OfflineStatusClient } from "./useOfflineStatus.js";
|
|
6
|
+
export type { OfflineStatusSnapshot, OfflineStatusClient, } from "./useOfflineStatus.js";
|
|
7
7
|
export { useConnectionState } from "./useConnectionState.js";
|
|
8
|
-
export type { ConnectionState, ConnectionStatus } from "./useConnectionState.js";
|
|
8
|
+
export type { ConnectionState, ConnectionStatus, } from "./useConnectionState.js";
|
|
9
9
|
export { useAgentConnections, agentConnectionsQueryKey, } from "./useAgentConnections.js";
|
|
10
|
-
export { useChannelSubscription
|
|
10
|
+
export { useChannelSubscription } from "./useChannelSubscription.js";
|
|
11
11
|
export type { ChannelSubscriptionHandlers } from "./useChannelSubscription.js";
|
|
12
12
|
export { useChannelAggregate, channelAggregateQueryKey, } from "./useChannelAggregate.js";
|
|
13
13
|
export type { UseChannelAggregateOptions, UseChannelAggregateResult, } from "./useChannelAggregate.js";
|
|
@@ -35,5 +35,6 @@ export type { DeviceMapEntry, UseDeviceMapOptions, UseDeviceMapResult, } from ".
|
|
|
35
35
|
export { useTurnCredentials } from "./useTurnCredentials.js";
|
|
36
36
|
export { useAgentTokenState, useSetAgentTokenPolicy, useSetAgentAuthLock, useRevokeAgentTokens, useSetRevocationFloor, useCreateAdhocToken, useCreateDeviceToken, agentTokenStateQueryKey, } from "./useAgentTokenState.js";
|
|
37
37
|
export type { UseAgentTokenStateOptions } from "./useAgentTokenState.js";
|
|
38
|
+
export { useAgentCredentials, useOrganisationCredentials, organisationCredentialsQueryKey, useCreateApiKey, useAddDeviceKey, useCreateEnrolmentCode, useRevokeCredential, agentCredentialsQueryKey, } from "./useAgentCredentials.js";
|
|
38
39
|
export { getSharedQueryClient, resetSharedQueryClient, } from "./sharedQueryClient.js";
|
|
39
40
|
export { useServiceReachability } from "./useServiceReachability.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useServiceReachability = exports.resetSharedQueryClient = exports.getSharedQueryClient = exports.agentTokenStateQueryKey = exports.useCreateDeviceToken = exports.useCreateAdhocToken = exports.useSetRevocationFloor = exports.useRevokeAgentTokens = exports.useSetAgentAuthLock = exports.useSetAgentTokenPolicy = exports.useAgentTokenState = exports.useTurnCredentials = exports.useDeviceMap = exports.MULTI_AGENT_MAX_WINDOW_MS = exports.multiAgentChannelMessagesQueryKey = exports.useMultiAgentChannelMessages = exports.multiAgentAggregatesQueryKey = exports.useMultiAgentAggregates = exports.useSendRpc = exports.invocationLogsQueryKey = exports.useInvocationLogs = exports.channelMessageQueryKey = exports.useChannelMessage = exports.channelMessagesQueryKey = exports.useChannelMessages = exports.useUpdateMessage = exports.useUpdateAggregate = exports.useSendMessage = exports.useAgentChannel = exports.channelAggregateQueryKey = exports.useChannelAggregate = exports.useChannelSubscription = exports.agentConnectionsQueryKey = exports.useAgentConnections = exports.useConnectionState = exports.hasOfflineStatus = exports.useOfflineStatus = exports.useClientStatus = exports.useDooverClient = exports.DooverProvider = void 0;
|
|
3
|
+
exports.useServiceReachability = exports.resetSharedQueryClient = exports.getSharedQueryClient = exports.agentCredentialsQueryKey = exports.useRevokeCredential = exports.useCreateEnrolmentCode = exports.useAddDeviceKey = exports.useCreateApiKey = exports.organisationCredentialsQueryKey = exports.useOrganisationCredentials = exports.useAgentCredentials = exports.agentTokenStateQueryKey = exports.useCreateDeviceToken = exports.useCreateAdhocToken = exports.useSetRevocationFloor = exports.useRevokeAgentTokens = exports.useSetAgentAuthLock = exports.useSetAgentTokenPolicy = exports.useAgentTokenState = exports.useTurnCredentials = exports.useDeviceMap = exports.MULTI_AGENT_MAX_WINDOW_MS = exports.multiAgentChannelMessagesQueryKey = exports.useMultiAgentChannelMessages = exports.multiAgentAggregatesQueryKey = exports.useMultiAgentAggregates = exports.useSendRpc = exports.invocationLogsQueryKey = exports.useInvocationLogs = exports.channelMessageQueryKey = exports.useChannelMessage = exports.channelMessagesQueryKey = exports.useChannelMessages = exports.useUpdateMessage = exports.useUpdateAggregate = exports.useSendMessage = exports.useAgentChannel = exports.channelAggregateQueryKey = exports.useChannelAggregate = exports.useChannelSubscription = exports.agentConnectionsQueryKey = exports.useAgentConnections = exports.useConnectionState = exports.hasOfflineStatus = exports.useOfflineStatus = exports.useClientStatus = exports.useDooverClient = exports.DooverProvider = void 0;
|
|
4
4
|
var context_js_1 = require("./context.js");
|
|
5
5
|
Object.defineProperty(exports, "DooverProvider", { enumerable: true, get: function () { return context_js_1.DooverProvider; } });
|
|
6
6
|
Object.defineProperty(exports, "useDooverClient", { enumerable: true, get: function () { return context_js_1.useDooverClient; } });
|
|
@@ -58,6 +58,15 @@ Object.defineProperty(exports, "useSetRevocationFloor", { enumerable: true, get:
|
|
|
58
58
|
Object.defineProperty(exports, "useCreateAdhocToken", { enumerable: true, get: function () { return useAgentTokenState_js_1.useCreateAdhocToken; } });
|
|
59
59
|
Object.defineProperty(exports, "useCreateDeviceToken", { enumerable: true, get: function () { return useAgentTokenState_js_1.useCreateDeviceToken; } });
|
|
60
60
|
Object.defineProperty(exports, "agentTokenStateQueryKey", { enumerable: true, get: function () { return useAgentTokenState_js_1.agentTokenStateQueryKey; } });
|
|
61
|
+
var useAgentCredentials_js_1 = require("./useAgentCredentials.js");
|
|
62
|
+
Object.defineProperty(exports, "useAgentCredentials", { enumerable: true, get: function () { return useAgentCredentials_js_1.useAgentCredentials; } });
|
|
63
|
+
Object.defineProperty(exports, "useOrganisationCredentials", { enumerable: true, get: function () { return useAgentCredentials_js_1.useOrganisationCredentials; } });
|
|
64
|
+
Object.defineProperty(exports, "organisationCredentialsQueryKey", { enumerable: true, get: function () { return useAgentCredentials_js_1.organisationCredentialsQueryKey; } });
|
|
65
|
+
Object.defineProperty(exports, "useCreateApiKey", { enumerable: true, get: function () { return useAgentCredentials_js_1.useCreateApiKey; } });
|
|
66
|
+
Object.defineProperty(exports, "useAddDeviceKey", { enumerable: true, get: function () { return useAgentCredentials_js_1.useAddDeviceKey; } });
|
|
67
|
+
Object.defineProperty(exports, "useCreateEnrolmentCode", { enumerable: true, get: function () { return useAgentCredentials_js_1.useCreateEnrolmentCode; } });
|
|
68
|
+
Object.defineProperty(exports, "useRevokeCredential", { enumerable: true, get: function () { return useAgentCredentials_js_1.useRevokeCredential; } });
|
|
69
|
+
Object.defineProperty(exports, "agentCredentialsQueryKey", { enumerable: true, get: function () { return useAgentCredentials_js_1.agentCredentialsQueryKey; } });
|
|
61
70
|
var sharedQueryClient_js_1 = require("./sharedQueryClient.js");
|
|
62
71
|
Object.defineProperty(exports, "getSharedQueryClient", { enumerable: true, get: function () { return sharedQueryClient_js_1.getSharedQueryClient; } });
|
|
63
72
|
Object.defineProperty(exports, "resetSharedQueryClient", { enumerable: true, get: function () { return sharedQueryClient_js_1.resetSharedQueryClient; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { AgentCredential, KeyRestriction } from "../apis/agents-api.js";
|
|
3
|
+
export declare function agentCredentialsQueryKey(agentId: string | undefined): readonly ["doover", "agent", string | null, "credentials"];
|
|
4
|
+
export declare function organisationCredentialsQueryKey(organisationId: string | undefined): readonly ["doover", "organisation", string | null, "credentials"];
|
|
5
|
+
/** Every credential on an organisation's agents, revoked ones included. */
|
|
6
|
+
export declare function useOrganisationCredentials(organisationId: string | undefined, options?: {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}): UseQueryResult<AgentCredential[]>;
|
|
9
|
+
/** An agent's API keys and device keys, revoked ones included. */
|
|
10
|
+
export declare function useAgentCredentials(agentId: string | undefined, options?: {
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}): UseQueryResult<AgentCredential[]>;
|
|
13
|
+
/** Mint an API key. The key is in the result once; hand it straight to the user. */
|
|
14
|
+
export declare function useCreateApiKey(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
15
|
+
name: string;
|
|
16
|
+
restriction?: KeyRestriction;
|
|
17
|
+
expiresMs?: number;
|
|
18
|
+
}, unknown>;
|
|
19
|
+
/** Register a device's P-256 public key (PEM or JWK). */
|
|
20
|
+
export declare function useAddDeviceKey(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
21
|
+
name: string;
|
|
22
|
+
publicKey: string;
|
|
23
|
+
}, unknown>;
|
|
24
|
+
/** Mint a one-time enrolment code for a device. Shown once. */
|
|
25
|
+
export declare function useCreateEnrolmentCode(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").CreatedCredential, Error, {
|
|
26
|
+
name: string;
|
|
27
|
+
expiresMs?: number;
|
|
28
|
+
}, unknown>;
|
|
29
|
+
/** Revoke an API key or device key. Takes effect at once. */
|
|
30
|
+
export declare function useRevokeCredential(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|