@novence/sdk 0.2.6 → 0.3.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.
@@ -48,12 +48,18 @@ export interface ChecksResults {
48
48
  passed: boolean | null;
49
49
  skipped?: boolean;
50
50
  reason?: string;
51
+ /** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
52
+ warnings?: string[];
51
53
  [key: string]: unknown;
52
54
  }
53
55
  export interface Deployment {
54
56
  id: string;
55
57
  status: DeploymentStatus;
56
58
  phase?: DeploymentPhase;
59
+ /** 1-based place in the check-runner queue while `status` is `queued`; null otherwise. */
60
+ queuePosition?: number | null;
61
+ /** Suggested delay before the next status poll; null once live or failed. */
62
+ recommendedPollSeconds?: number | null;
57
63
  checksResults?: ChecksResults | null;
58
64
  checksUrl?: string;
59
65
  errorMessage?: string | null;
@@ -127,7 +133,7 @@ export interface ApiKey {
127
133
  id: string;
128
134
  /** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
129
135
  keyPrefix: string;
130
- /** "account", "project", or "member:{email}". */
136
+ /** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
131
137
  name: string;
132
138
  projectId: string | null;
133
139
  /** Account keys have a null projectId. */
@@ -237,10 +243,30 @@ export interface AccountSnapshot {
237
243
  } | null;
238
244
  [key: string]: unknown;
239
245
  }
240
- /** Not schematised in openapi.yaml — known fields only. */
246
+ export interface ManagementSession {
247
+ token: string;
248
+ expiresAt: string;
249
+ ttlMinutes: number;
250
+ scopes: string[];
251
+ }
252
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
253
+ export declare const CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
254
+ /** Known console-kit fields. */
241
255
  export interface ConsoleKit {
256
+ apiBase?: string;
242
257
  htmlTemplate?: string;
243
258
  snapshot?: AccountSnapshot;
259
+ /**
260
+ * Called with nv_: a freshly minted 30-minute session (`token` set, `reused: false`).
261
+ * Called with mgmt_: the caller's own session (`token: null`, `reused: true`).
262
+ */
263
+ session?: {
264
+ token: string | null;
265
+ expiresAt: string;
266
+ scopes: string[];
267
+ reused: boolean;
268
+ [key: string]: unknown;
269
+ };
244
270
  [key: string]: unknown;
245
271
  }
246
272
  export declare class Novence {
@@ -458,11 +484,10 @@ export declare class Novence {
458
484
  account: {
459
485
  get: () => Promise<AccountSnapshot>;
460
486
  consoleKit: () => Promise<ConsoleKit>;
461
- createSession: () => Promise<{
462
- token: string;
463
- expiresAt: string;
464
- scopes: string[];
465
- }>;
487
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
488
+ createSession: (opts?: {
489
+ ttlMinutes?: number;
490
+ }) => Promise<ManagementSession>;
466
491
  revokeSession: () => Promise<{
467
492
  revoked: boolean;
468
493
  }>;
@@ -478,6 +503,18 @@ export declare class Novence {
478
503
  }) => Promise<{
479
504
  keys: ApiKey[];
480
505
  }>;
506
+ /**
507
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
508
+ * returned once. Permissions default to (and cannot exceed) the caller's.
509
+ */
510
+ create: (opts: {
511
+ name: string;
512
+ projectId?: string;
513
+ permissions?: Record<string, boolean>;
514
+ }) => Promise<{
515
+ apiKey: string;
516
+ key: Omit<ApiKey, "current" | "lastUsedAt" | "revokedAt">;
517
+ }>;
481
518
  /**
482
519
  * Revoke a key. Idempotent.
483
520
  *
@@ -541,9 +578,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
541
578
  alreadyVerified?: boolean;
542
579
  verificationCode?: string;
543
580
  }>;
544
- /** Recover a lost account API key with email OTP (after resend-verification). */
545
- export declare function reissueApiKey(email: string, code: string, baseUrl?: string): Promise<{
581
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
582
+ export declare function requestSessionOtp(email: string, baseUrl?: string): Promise<{
583
+ sent: boolean;
584
+ }>;
585
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
586
+ export declare function verifySessionOtp(email: string, code: string, opts?: {
587
+ ttlMinutes?: number;
588
+ baseUrl?: string;
589
+ }): Promise<ManagementSession>;
590
+ export interface ReissuedApiKey {
546
591
  accountId: string;
547
592
  apiKey: string;
548
593
  emailVerified: boolean;
549
- }>;
594
+ revokedCount: number;
595
+ /** Keys still active besides the new one (named keys survive unless `revokeAll`). */
596
+ remainingKeys: Pick<ApiKey, "id" | "keyPrefix" | "name" | "scope" | "projectId">[];
597
+ }
598
+ /**
599
+ * Recover a lost account API key with email OTP (after resend-verification).
600
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
601
+ */
602
+ export declare function reissueApiKey(email: string, code: string, baseUrl?: string, opts?: {
603
+ revokeAll?: boolean;
604
+ }): Promise<ReissuedApiKey>;
package/dist/cjs/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Novence = exports.NovenceError = exports.DEFAULT_BASE_URL = void 0;
3
+ exports.Novence = exports.CONSOLE_INJECT_MARKER = exports.NovenceError = exports.DEFAULT_BASE_URL = void 0;
4
4
  exports.isNovenceClient = isNovenceClient;
5
5
  exports.bootstrapAccount = bootstrapAccount;
6
6
  exports.createDemoAccount = createDemoAccount;
7
7
  exports.claimAccount = claimAccount;
8
8
  exports.verifyEmail = verifyEmail;
9
9
  exports.resendVerification = resendVerification;
10
+ exports.requestSessionOtp = requestSessionOtp;
11
+ exports.verifySessionOtp = verifySessionOtp;
10
12
  exports.reissueApiKey = reissueApiKey;
11
13
  const node_fs_1 = require("node:fs");
12
14
  const node_path_1 = require("node:path");
@@ -50,6 +52,8 @@ class NovenceError extends Error {
50
52
  }
51
53
  }
52
54
  exports.NovenceError = NovenceError;
55
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
56
+ exports.CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
53
57
  const MIME_BY_EXT = {
54
58
  ".html": "text/html; charset=utf-8",
55
59
  ".css": "text/css; charset=utf-8",
@@ -63,6 +67,7 @@ const MIME_BY_EXT = {
63
67
  ".jpeg": "image/jpeg",
64
68
  ".gif": "image/gif",
65
69
  ".webp": "image/webp",
70
+ ".avif": "image/avif",
66
71
  ".ico": "image/x-icon",
67
72
  ".woff": "font/woff",
68
73
  ".woff2": "font/woff2",
@@ -260,7 +265,8 @@ class Novence {
260
265
  account = {
261
266
  get: () => this.request("GET", "/v1/account"),
262
267
  consoleKit: () => this.request("GET", "/v1/account/console-kit"),
263
- createSession: () => this.request("POST", "/v1/account/sessions"),
268
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
269
+ createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
264
270
  revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
265
271
  };
266
272
  apiKeys = {
@@ -277,6 +283,11 @@ class Novence {
277
283
  const qs = q.toString();
278
284
  return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
279
285
  },
286
+ /**
287
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
288
+ * returned once. Permissions default to (and cannot exceed) the caller's.
289
+ */
290
+ create: (opts) => this.request("POST", "/v1/api-keys", opts),
280
291
  /**
281
292
  * Revoke a key. Idempotent.
282
293
  *
@@ -365,12 +376,39 @@ async function resendVerification(email, baseUrl) {
365
376
  throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
366
377
  return data;
367
378
  }
368
- /** Recover a lost account API key with email OTP (after resend-verification). */
369
- async function reissueApiKey(email, code, baseUrl) {
379
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
380
+ async function requestSessionOtp(email, baseUrl) {
381
+ const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/account/sessions/request`, {
382
+ method: "POST",
383
+ headers: { "Content-Type": "application/json" },
384
+ body: JSON.stringify({ email }),
385
+ });
386
+ const data = (await res.json());
387
+ if (!res.ok)
388
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
389
+ return data;
390
+ }
391
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
392
+ async function verifySessionOtp(email, code, opts = {}) {
393
+ const res = await fetch(`${resolveBaseUrl(opts.baseUrl)}/v1/account/sessions/verify`, {
394
+ method: "POST",
395
+ headers: { "Content-Type": "application/json" },
396
+ body: JSON.stringify({ email, code, ttlMinutes: opts.ttlMinutes }),
397
+ });
398
+ const data = (await res.json());
399
+ if (!res.ok)
400
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
401
+ return data;
402
+ }
403
+ /**
404
+ * Recover a lost account API key with email OTP (after resend-verification).
405
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
406
+ */
407
+ async function reissueApiKey(email, code, baseUrl, opts = {}) {
370
408
  const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
371
409
  method: "POST",
372
410
  headers: { "Content-Type": "application/json" },
373
- body: JSON.stringify({ email, code }),
411
+ body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
374
412
  });
375
413
  const data = (await res.json());
376
414
  if (!res.ok)
@@ -48,12 +48,18 @@ export interface ChecksResults {
48
48
  passed: boolean | null;
49
49
  skipped?: boolean;
50
50
  reason?: string;
51
+ /** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
52
+ warnings?: string[];
51
53
  [key: string]: unknown;
52
54
  }
53
55
  export interface Deployment {
54
56
  id: string;
55
57
  status: DeploymentStatus;
56
58
  phase?: DeploymentPhase;
59
+ /** 1-based place in the check-runner queue while `status` is `queued`; null otherwise. */
60
+ queuePosition?: number | null;
61
+ /** Suggested delay before the next status poll; null once live or failed. */
62
+ recommendedPollSeconds?: number | null;
57
63
  checksResults?: ChecksResults | null;
58
64
  checksUrl?: string;
59
65
  errorMessage?: string | null;
@@ -127,7 +133,7 @@ export interface ApiKey {
127
133
  id: string;
128
134
  /** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
129
135
  keyPrefix: string;
130
- /** "account", "project", or "member:{email}". */
136
+ /** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
131
137
  name: string;
132
138
  projectId: string | null;
133
139
  /** Account keys have a null projectId. */
@@ -237,10 +243,30 @@ export interface AccountSnapshot {
237
243
  } | null;
238
244
  [key: string]: unknown;
239
245
  }
240
- /** Not schematised in openapi.yaml — known fields only. */
246
+ export interface ManagementSession {
247
+ token: string;
248
+ expiresAt: string;
249
+ ttlMinutes: number;
250
+ scopes: string[];
251
+ }
252
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
253
+ export declare const CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
254
+ /** Known console-kit fields. */
241
255
  export interface ConsoleKit {
256
+ apiBase?: string;
242
257
  htmlTemplate?: string;
243
258
  snapshot?: AccountSnapshot;
259
+ /**
260
+ * Called with nv_: a freshly minted 30-minute session (`token` set, `reused: false`).
261
+ * Called with mgmt_: the caller's own session (`token: null`, `reused: true`).
262
+ */
263
+ session?: {
264
+ token: string | null;
265
+ expiresAt: string;
266
+ scopes: string[];
267
+ reused: boolean;
268
+ [key: string]: unknown;
269
+ };
244
270
  [key: string]: unknown;
245
271
  }
246
272
  export declare class Novence {
@@ -458,11 +484,10 @@ export declare class Novence {
458
484
  account: {
459
485
  get: () => Promise<AccountSnapshot>;
460
486
  consoleKit: () => Promise<ConsoleKit>;
461
- createSession: () => Promise<{
462
- token: string;
463
- expiresAt: string;
464
- scopes: string[];
465
- }>;
487
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
488
+ createSession: (opts?: {
489
+ ttlMinutes?: number;
490
+ }) => Promise<ManagementSession>;
466
491
  revokeSession: () => Promise<{
467
492
  revoked: boolean;
468
493
  }>;
@@ -478,6 +503,18 @@ export declare class Novence {
478
503
  }) => Promise<{
479
504
  keys: ApiKey[];
480
505
  }>;
506
+ /**
507
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
508
+ * returned once. Permissions default to (and cannot exceed) the caller's.
509
+ */
510
+ create: (opts: {
511
+ name: string;
512
+ projectId?: string;
513
+ permissions?: Record<string, boolean>;
514
+ }) => Promise<{
515
+ apiKey: string;
516
+ key: Omit<ApiKey, "current" | "lastUsedAt" | "revokedAt">;
517
+ }>;
481
518
  /**
482
519
  * Revoke a key. Idempotent.
483
520
  *
@@ -541,9 +578,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
541
578
  alreadyVerified?: boolean;
542
579
  verificationCode?: string;
543
580
  }>;
544
- /** Recover a lost account API key with email OTP (after resend-verification). */
545
- export declare function reissueApiKey(email: string, code: string, baseUrl?: string): Promise<{
581
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
582
+ export declare function requestSessionOtp(email: string, baseUrl?: string): Promise<{
583
+ sent: boolean;
584
+ }>;
585
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
586
+ export declare function verifySessionOtp(email: string, code: string, opts?: {
587
+ ttlMinutes?: number;
588
+ baseUrl?: string;
589
+ }): Promise<ManagementSession>;
590
+ export interface ReissuedApiKey {
546
591
  accountId: string;
547
592
  apiKey: string;
548
593
  emailVerified: boolean;
549
- }>;
594
+ revokedCount: number;
595
+ /** Keys still active besides the new one (named keys survive unless `revokeAll`). */
596
+ remainingKeys: Pick<ApiKey, "id" | "keyPrefix" | "name" | "scope" | "projectId">[];
597
+ }
598
+ /**
599
+ * Recover a lost account API key with email OTP (after resend-verification).
600
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
601
+ */
602
+ export declare function reissueApiKey(email: string, code: string, baseUrl?: string, opts?: {
603
+ revokeAll?: boolean;
604
+ }): Promise<ReissuedApiKey>;
package/dist/esm/index.js CHANGED
@@ -39,6 +39,8 @@ export class NovenceError extends Error {
39
39
  this.status = status;
40
40
  }
41
41
  }
42
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
43
+ export const CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
42
44
  const MIME_BY_EXT = {
43
45
  ".html": "text/html; charset=utf-8",
44
46
  ".css": "text/css; charset=utf-8",
@@ -52,6 +54,7 @@ const MIME_BY_EXT = {
52
54
  ".jpeg": "image/jpeg",
53
55
  ".gif": "image/gif",
54
56
  ".webp": "image/webp",
57
+ ".avif": "image/avif",
55
58
  ".ico": "image/x-icon",
56
59
  ".woff": "font/woff",
57
60
  ".woff2": "font/woff2",
@@ -249,7 +252,8 @@ export class Novence {
249
252
  account = {
250
253
  get: () => this.request("GET", "/v1/account"),
251
254
  consoleKit: () => this.request("GET", "/v1/account/console-kit"),
252
- createSession: () => this.request("POST", "/v1/account/sessions"),
255
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
256
+ createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
253
257
  revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
254
258
  };
255
259
  apiKeys = {
@@ -266,6 +270,11 @@ export class Novence {
266
270
  const qs = q.toString();
267
271
  return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
268
272
  },
273
+ /**
274
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
275
+ * returned once. Permissions default to (and cannot exceed) the caller's.
276
+ */
277
+ create: (opts) => this.request("POST", "/v1/api-keys", opts),
269
278
  /**
270
279
  * Revoke a key. Idempotent.
271
280
  *
@@ -353,12 +362,39 @@ export async function resendVerification(email, baseUrl) {
353
362
  throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
354
363
  return data;
355
364
  }
356
- /** Recover a lost account API key with email OTP (after resend-verification). */
357
- export async function reissueApiKey(email, code, baseUrl) {
365
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
366
+ export async function requestSessionOtp(email, baseUrl) {
367
+ const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/account/sessions/request`, {
368
+ method: "POST",
369
+ headers: { "Content-Type": "application/json" },
370
+ body: JSON.stringify({ email }),
371
+ });
372
+ const data = (await res.json());
373
+ if (!res.ok)
374
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
375
+ return data;
376
+ }
377
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
378
+ export async function verifySessionOtp(email, code, opts = {}) {
379
+ const res = await fetch(`${resolveBaseUrl(opts.baseUrl)}/v1/account/sessions/verify`, {
380
+ method: "POST",
381
+ headers: { "Content-Type": "application/json" },
382
+ body: JSON.stringify({ email, code, ttlMinutes: opts.ttlMinutes }),
383
+ });
384
+ const data = (await res.json());
385
+ if (!res.ok)
386
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
387
+ return data;
388
+ }
389
+ /**
390
+ * Recover a lost account API key with email OTP (after resend-verification).
391
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
392
+ */
393
+ export async function reissueApiKey(email, code, baseUrl, opts = {}) {
358
394
  const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
359
395
  method: "POST",
360
396
  headers: { "Content-Type": "application/json" },
361
- body: JSON.stringify({ email, code }),
397
+ body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
362
398
  });
363
399
  const data = (await res.json());
364
400
  if (!res.ok)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novence/sdk",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "Official TypeScript SDK for Novence — static site hosting for AI agents. Create projects, upload files, run quality checks, deploy to the edge.",
5
5
  "license": "MIT",
6
6
  "type": "module",