@lifesi/genesis 0.1.1 → 0.1.2

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/beacons.d.ts CHANGED
@@ -2,7 +2,53 @@ import type { GenesisClient } from './client.js';
2
2
  import type { OperationInput, OperationOutput } from './types.js';
3
3
  /** Beacons uses the authenticated Genesis organization; never supply an org header. */
4
4
  export declare function beaconsModule(client: GenesisClient): {
5
+ fleets: {
6
+ /** Reuse the same request ID and body after an interrupted response. Creates metadata only. */
7
+ provision: (requestId: string, body?: {
8
+ name?: string;
9
+ }) => Promise<{
10
+ data: {
11
+ fleet_id: string;
12
+ organization_id: string;
13
+ workspace_id: string;
14
+ project_id: string;
15
+ environment_id: string;
16
+ metadata_only: true;
17
+ };
18
+ }>;
19
+ };
5
20
  devices: {
21
+ revocations: (id: string) => Promise<{
22
+ data: import("./index.js").components["schemas"]["Beacons.DeviceRevocation"][];
23
+ }>;
24
+ acknowledge: (id: string, version: number, body: OperationInput<"beacons_acknowledgeBridgeDeviceRevocation">["body"]) => Promise<{
25
+ data: import("./index.js").components["schemas"]["Beacons.DeviceRevocation"];
26
+ }>;
27
+ challenge: (body: OperationInput<"beacons_issueBridgeDeviceChallenge">["body"]) => Promise<{
28
+ version: 1;
29
+ id: string;
30
+ nonce: string;
31
+ issuer: string;
32
+ organization: string;
33
+ principal: string;
34
+ workspace: string;
35
+ project: string;
36
+ environment: string;
37
+ binding_revision: string;
38
+ transport: string;
39
+ fleet_id: string;
40
+ proof_key: string;
41
+ tunnel_key: string;
42
+ issued_at: number;
43
+ expires_at: number;
44
+ }>;
45
+ enroll: (body: OperationInput<"beacons_enrollBridgeDevice">["body"]) => Promise<{
46
+ device_id: string;
47
+ fleet_id: string;
48
+ mesh: {
49
+ [key: string]: unknown;
50
+ };
51
+ }>;
6
52
  list: () => Promise<{
7
53
  data?: import("./index.js").components["schemas"]["Beacons.BridgeDevice"][];
8
54
  }>;
package/dist/beacons.js CHANGED
@@ -1,7 +1,27 @@
1
+ import { GenesisError } from './errors.js';
2
+ function provisioningInput(requestId, body) {
3
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(requestId)
4
+ || requestId === '00000000-0000-0000-0000-000000000000'
5
+ || !body || typeof body !== 'object' || Array.isArray(body)
6
+ || Object.keys(body).some(key => key !== 'name')
7
+ || (body.name !== undefined && (typeof body.name !== 'string' || !body.name.trim()
8
+ || new TextEncoder().encode(body.name).length > 256 || /[\u0000-\u001f\u007f-\u009f]/.test(body.name)))) {
9
+ throw new GenesisError({ status: 0, type: 'invalid_request', operationId: 'beacons_provisionBridgeFleet', message: 'Provide a nonzero UUID request ID and an optional fleet name of up to 256 UTF-8 bytes.' });
10
+ }
11
+ return body.name === undefined ? {} : { name: body.name };
12
+ }
1
13
  /** Beacons uses the authenticated Genesis organization; never supply an org header. */
2
14
  export function beaconsModule(client) {
3
15
  return {
16
+ fleets: {
17
+ /** Reuse the same request ID and body after an interrupted response. Creates metadata only. */
18
+ provision: (requestId, body = {}) => client.request('beacons_provisionBridgeFleet', { body: provisioningInput(requestId, body) }, { headers: { 'idempotency-key': requestId } }),
19
+ },
4
20
  devices: {
21
+ revocations: (id) => client.request('beacons_listBridgeDeviceRevocations', { id }),
22
+ acknowledge: (id, version, body) => client.request('beacons_acknowledgeBridgeDeviceRevocation', { id, version, body }),
23
+ challenge: (body) => client.request('beacons_issueBridgeDeviceChallenge', { body }),
24
+ enroll: (body) => client.request('beacons_enrollBridgeDevice', { body }),
5
25
  list: () => client.request('beacons_listBridgeDevices'),
6
26
  update: (id, body) => client.request('beacons_updateBridgeDevice', { id, body }),
7
27
  revoke: (id) => client.request('beacons_revokeBridgeDevice', { id }),