Device Connection Payload Builder (gateway/auth.ts)

clawwork · packages/pwa/src/gateway/auth.ts · typescript · Apache-2.0
auth, security, lang:typescript, tag:crypto

Generates a cryptographically signed payload for secure device authentication and pairing. Use this when implementing secure handshake protocols between client devices and backend services.

// Source: https://github.com/clawwork-ai/clawwork | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import type { DeviceIdentity } from './device-identity.js';
import { publicKeyRawBase64Url, signPayload } from './device-identity.js';

interface DeviceConnectPayload {
  id: string;
  publicKey: string;
  signature: string;
  signedAt: number;
  nonce: string;
}

export async function buildDeviceConnectPayload(
  identity: DeviceIdentity,
  nonce: string,
  token?: string,
  params?: {
    clientId?: string;
    clientMode?: string;
    role?: string;
    scopes?: string[];
    platform?: string;
    deviceFamily?: string;
  },
): Promise<DeviceConnectPayload> {
  const signedAtMs =

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key