@novence/sdk 0.2.6 → 0.4.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.
@@ -40,6 +40,30 @@ export interface Project {
40
40
  createdAt?: string;
41
41
  updatedAt?: string;
42
42
  }
43
+ /** Result of `projects.delete`. Calling it on an already-deleted project returns `alreadyDeleted: true`. */
44
+ export interface ProjectDeleteResult {
45
+ deleted: true;
46
+ alreadyDeleted: boolean;
47
+ project: {
48
+ id: string;
49
+ name: string;
50
+ suffix: string;
51
+ url: string;
52
+ customDomain: string | null;
53
+ };
54
+ deletedAt: string;
55
+ /** Custom-domain hosts unmapped at the edge by this call. */
56
+ customDomainHostsReleased: string[];
57
+ /** Site files are erased after the response unless the purge already finished. */
58
+ storage: {
59
+ status: "purged";
60
+ objectsDeleted: number;
61
+ } | {
62
+ status: "purging";
63
+ };
64
+ /** Edge cleanup steps that failed. Call `projects.delete` again to retry them. */
65
+ warnings: string[];
66
+ }
43
67
  /**
44
68
  * Quality-gate payload. When `skipped` is true (unverified accounts), `passed`
45
69
  * is null — do not treat that as checks having passed.
@@ -48,12 +72,18 @@ export interface ChecksResults {
48
72
  passed: boolean | null;
49
73
  skipped?: boolean;
50
74
  reason?: string;
75
+ /** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
76
+ warnings?: string[];
51
77
  [key: string]: unknown;
52
78
  }
53
79
  export interface Deployment {
54
80
  id: string;
55
81
  status: DeploymentStatus;
56
82
  phase?: DeploymentPhase;
83
+ /** 1-based place in the check-runner queue while `status` is `queued`; null otherwise. */
84
+ queuePosition?: number | null;
85
+ /** Suggested delay before the next status poll; null once live or failed. */
86
+ recommendedPollSeconds?: number | null;
57
87
  checksResults?: ChecksResults | null;
58
88
  checksUrl?: string;
59
89
  errorMessage?: string | null;
@@ -127,7 +157,7 @@ export interface ApiKey {
127
157
  id: string;
128
158
  /** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
129
159
  keyPrefix: string;
130
- /** "account", "project", or "member:{email}". */
160
+ /** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
131
161
  name: string;
132
162
  projectId: string | null;
133
163
  /** Account keys have a null projectId. */
@@ -237,10 +267,30 @@ export interface AccountSnapshot {
237
267
  } | null;
238
268
  [key: string]: unknown;
239
269
  }
240
- /** Not schematised in openapi.yaml — known fields only. */
270
+ export interface ManagementSession {
271
+ token: string;
272
+ expiresAt: string;
273
+ ttlMinutes: number;
274
+ scopes: string[];
275
+ }
276
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
277
+ export declare const CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
278
+ /** Known console-kit fields. */
241
279
  export interface ConsoleKit {
280
+ apiBase?: string;
242
281
  htmlTemplate?: string;
243
282
  snapshot?: AccountSnapshot;
283
+ /**
284
+ * Called with nv_: a freshly minted 30-minute session (`token` set, `reused: false`).
285
+ * Called with mgmt_: the caller's own session (`token: null`, `reused: true`).
286
+ */
287
+ session?: {
288
+ token: string | null;
289
+ expiresAt: string;
290
+ scopes: string[];
291
+ reused: boolean;
292
+ [key: string]: unknown;
293
+ };
244
294
  [key: string]: unknown;
245
295
  }
246
296
  export declare class Novence {
@@ -276,6 +326,14 @@ export declare class Novence {
276
326
  }) => Promise<{
277
327
  project: Project;
278
328
  }>;
329
+ /**
330
+ * Permanently delete a project (owner only, account key). Irreversible: the site goes
331
+ * offline on every host and its files are erased. `confirm` must equal the project's
332
+ * exact name or suffix.
333
+ */
334
+ delete: (id: string, input: {
335
+ confirm: string;
336
+ }) => Promise<ProjectDeleteResult>;
279
337
  usage: (id: string) => Promise<{
280
338
  projectId: string;
281
339
  period: {
@@ -458,11 +516,10 @@ export declare class Novence {
458
516
  account: {
459
517
  get: () => Promise<AccountSnapshot>;
460
518
  consoleKit: () => Promise<ConsoleKit>;
461
- createSession: () => Promise<{
462
- token: string;
463
- expiresAt: string;
464
- scopes: string[];
465
- }>;
519
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
520
+ createSession: (opts?: {
521
+ ttlMinutes?: number;
522
+ }) => Promise<ManagementSession>;
466
523
  revokeSession: () => Promise<{
467
524
  revoked: boolean;
468
525
  }>;
@@ -478,6 +535,18 @@ export declare class Novence {
478
535
  }) => Promise<{
479
536
  keys: ApiKey[];
480
537
  }>;
538
+ /**
539
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
540
+ * returned once. Permissions default to (and cannot exceed) the caller's.
541
+ */
542
+ create: (opts: {
543
+ name: string;
544
+ projectId?: string;
545
+ permissions?: Record<string, boolean>;
546
+ }) => Promise<{
547
+ apiKey: string;
548
+ key: Omit<ApiKey, "current" | "lastUsedAt" | "revokedAt">;
549
+ }>;
481
550
  /**
482
551
  * Revoke a key. Idempotent.
483
552
  *
@@ -541,9 +610,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
541
610
  alreadyVerified?: boolean;
542
611
  verificationCode?: string;
543
612
  }>;
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<{
613
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
614
+ export declare function requestSessionOtp(email: string, baseUrl?: string): Promise<{
615
+ sent: boolean;
616
+ }>;
617
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
618
+ export declare function verifySessionOtp(email: string, code: string, opts?: {
619
+ ttlMinutes?: number;
620
+ baseUrl?: string;
621
+ }): Promise<ManagementSession>;
622
+ export interface ReissuedApiKey {
546
623
  accountId: string;
547
624
  apiKey: string;
548
625
  emailVerified: boolean;
549
- }>;
626
+ revokedCount: number;
627
+ /** Keys still active besides the new one (named keys survive unless `revokeAll`). */
628
+ remainingKeys: Pick<ApiKey, "id" | "keyPrefix" | "name" | "scope" | "projectId">[];
629
+ }
630
+ /**
631
+ * Recover a lost account API key with email OTP (after resend-verification).
632
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
633
+ */
634
+ export declare function reissueApiKey(email: string, code: string, baseUrl?: string, opts?: {
635
+ revokeAll?: boolean;
636
+ }): 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",
@@ -106,6 +111,12 @@ class Novence {
106
111
  list: () => this.request("GET", "/v1/projects"),
107
112
  get: (id) => this.request("GET", `/v1/projects/${id}`),
108
113
  update: (id, input) => this.request("PATCH", `/v1/projects/${id}`, input),
114
+ /**
115
+ * Permanently delete a project (owner only, account key). Irreversible: the site goes
116
+ * offline on every host and its files are erased. `confirm` must equal the project's
117
+ * exact name or suffix.
118
+ */
119
+ delete: (id, input) => this.request("DELETE", `/v1/projects/${id}`, { confirm: input.confirm }),
109
120
  usage: (id) => this.request("GET", `/v1/projects/${id}/usage`),
110
121
  analytics: (id, range) => {
111
122
  const q = new URLSearchParams();
@@ -260,7 +271,8 @@ class Novence {
260
271
  account = {
261
272
  get: () => this.request("GET", "/v1/account"),
262
273
  consoleKit: () => this.request("GET", "/v1/account/console-kit"),
263
- createSession: () => this.request("POST", "/v1/account/sessions"),
274
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
275
+ createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
264
276
  revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
265
277
  };
266
278
  apiKeys = {
@@ -277,6 +289,11 @@ class Novence {
277
289
  const qs = q.toString();
278
290
  return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
279
291
  },
292
+ /**
293
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
294
+ * returned once. Permissions default to (and cannot exceed) the caller's.
295
+ */
296
+ create: (opts) => this.request("POST", "/v1/api-keys", opts),
280
297
  /**
281
298
  * Revoke a key. Idempotent.
282
299
  *
@@ -365,12 +382,39 @@ async function resendVerification(email, baseUrl) {
365
382
  throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
366
383
  return data;
367
384
  }
368
- /** Recover a lost account API key with email OTP (after resend-verification). */
369
- async function reissueApiKey(email, code, baseUrl) {
385
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
386
+ async function requestSessionOtp(email, baseUrl) {
387
+ const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/account/sessions/request`, {
388
+ method: "POST",
389
+ headers: { "Content-Type": "application/json" },
390
+ body: JSON.stringify({ email }),
391
+ });
392
+ const data = (await res.json());
393
+ if (!res.ok)
394
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
395
+ return data;
396
+ }
397
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
398
+ async function verifySessionOtp(email, code, opts = {}) {
399
+ const res = await fetch(`${resolveBaseUrl(opts.baseUrl)}/v1/account/sessions/verify`, {
400
+ method: "POST",
401
+ headers: { "Content-Type": "application/json" },
402
+ body: JSON.stringify({ email, code, ttlMinutes: opts.ttlMinutes }),
403
+ });
404
+ const data = (await res.json());
405
+ if (!res.ok)
406
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
407
+ return data;
408
+ }
409
+ /**
410
+ * Recover a lost account API key with email OTP (after resend-verification).
411
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
412
+ */
413
+ async function reissueApiKey(email, code, baseUrl, opts = {}) {
370
414
  const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
371
415
  method: "POST",
372
416
  headers: { "Content-Type": "application/json" },
373
- body: JSON.stringify({ email, code }),
417
+ body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
374
418
  });
375
419
  const data = (await res.json());
376
420
  if (!res.ok)
@@ -40,6 +40,30 @@ export interface Project {
40
40
  createdAt?: string;
41
41
  updatedAt?: string;
42
42
  }
43
+ /** Result of `projects.delete`. Calling it on an already-deleted project returns `alreadyDeleted: true`. */
44
+ export interface ProjectDeleteResult {
45
+ deleted: true;
46
+ alreadyDeleted: boolean;
47
+ project: {
48
+ id: string;
49
+ name: string;
50
+ suffix: string;
51
+ url: string;
52
+ customDomain: string | null;
53
+ };
54
+ deletedAt: string;
55
+ /** Custom-domain hosts unmapped at the edge by this call. */
56
+ customDomainHostsReleased: string[];
57
+ /** Site files are erased after the response unless the purge already finished. */
58
+ storage: {
59
+ status: "purged";
60
+ objectsDeleted: number;
61
+ } | {
62
+ status: "purging";
63
+ };
64
+ /** Edge cleanup steps that failed. Call `projects.delete` again to retry them. */
65
+ warnings: string[];
66
+ }
43
67
  /**
44
68
  * Quality-gate payload. When `skipped` is true (unverified accounts), `passed`
45
69
  * is null — do not treat that as checks having passed.
@@ -48,12 +72,18 @@ export interface ChecksResults {
48
72
  passed: boolean | null;
49
73
  skipped?: boolean;
50
74
  reason?: string;
75
+ /** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
76
+ warnings?: string[];
51
77
  [key: string]: unknown;
52
78
  }
53
79
  export interface Deployment {
54
80
  id: string;
55
81
  status: DeploymentStatus;
56
82
  phase?: DeploymentPhase;
83
+ /** 1-based place in the check-runner queue while `status` is `queued`; null otherwise. */
84
+ queuePosition?: number | null;
85
+ /** Suggested delay before the next status poll; null once live or failed. */
86
+ recommendedPollSeconds?: number | null;
57
87
  checksResults?: ChecksResults | null;
58
88
  checksUrl?: string;
59
89
  errorMessage?: string | null;
@@ -127,7 +157,7 @@ export interface ApiKey {
127
157
  id: string;
128
158
  /** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
129
159
  keyPrefix: string;
130
- /** "account", "project", or "member:{email}". */
160
+ /** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
131
161
  name: string;
132
162
  projectId: string | null;
133
163
  /** Account keys have a null projectId. */
@@ -237,10 +267,30 @@ export interface AccountSnapshot {
237
267
  } | null;
238
268
  [key: string]: unknown;
239
269
  }
240
- /** Not schematised in openapi.yaml — known fields only. */
270
+ export interface ManagementSession {
271
+ token: string;
272
+ expiresAt: string;
273
+ ttlMinutes: number;
274
+ scopes: string[];
275
+ }
276
+ /** Marker in `ConsoleKit.htmlTemplate` to replace with the snapshot + token globals. */
277
+ export declare const CONSOLE_INJECT_MARKER = "/*NOVENCE_INJECT*/";
278
+ /** Known console-kit fields. */
241
279
  export interface ConsoleKit {
280
+ apiBase?: string;
242
281
  htmlTemplate?: string;
243
282
  snapshot?: AccountSnapshot;
283
+ /**
284
+ * Called with nv_: a freshly minted 30-minute session (`token` set, `reused: false`).
285
+ * Called with mgmt_: the caller's own session (`token: null`, `reused: true`).
286
+ */
287
+ session?: {
288
+ token: string | null;
289
+ expiresAt: string;
290
+ scopes: string[];
291
+ reused: boolean;
292
+ [key: string]: unknown;
293
+ };
244
294
  [key: string]: unknown;
245
295
  }
246
296
  export declare class Novence {
@@ -276,6 +326,14 @@ export declare class Novence {
276
326
  }) => Promise<{
277
327
  project: Project;
278
328
  }>;
329
+ /**
330
+ * Permanently delete a project (owner only, account key). Irreversible: the site goes
331
+ * offline on every host and its files are erased. `confirm` must equal the project's
332
+ * exact name or suffix.
333
+ */
334
+ delete: (id: string, input: {
335
+ confirm: string;
336
+ }) => Promise<ProjectDeleteResult>;
279
337
  usage: (id: string) => Promise<{
280
338
  projectId: string;
281
339
  period: {
@@ -458,11 +516,10 @@ export declare class Novence {
458
516
  account: {
459
517
  get: () => Promise<AccountSnapshot>;
460
518
  consoleKit: () => Promise<ConsoleKit>;
461
- createSession: () => Promise<{
462
- token: string;
463
- expiresAt: string;
464
- scopes: string[];
465
- }>;
519
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
520
+ createSession: (opts?: {
521
+ ttlMinutes?: number;
522
+ }) => Promise<ManagementSession>;
466
523
  revokeSession: () => Promise<{
467
524
  revoked: boolean;
468
525
  }>;
@@ -478,6 +535,18 @@ export declare class Novence {
478
535
  }) => Promise<{
479
536
  keys: ApiKey[];
480
537
  }>;
538
+ /**
539
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
540
+ * returned once. Permissions default to (and cannot exceed) the caller's.
541
+ */
542
+ create: (opts: {
543
+ name: string;
544
+ projectId?: string;
545
+ permissions?: Record<string, boolean>;
546
+ }) => Promise<{
547
+ apiKey: string;
548
+ key: Omit<ApiKey, "current" | "lastUsedAt" | "revokedAt">;
549
+ }>;
481
550
  /**
482
551
  * Revoke a key. Idempotent.
483
552
  *
@@ -541,9 +610,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
541
610
  alreadyVerified?: boolean;
542
611
  verificationCode?: string;
543
612
  }>;
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<{
613
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
614
+ export declare function requestSessionOtp(email: string, baseUrl?: string): Promise<{
615
+ sent: boolean;
616
+ }>;
617
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
618
+ export declare function verifySessionOtp(email: string, code: string, opts?: {
619
+ ttlMinutes?: number;
620
+ baseUrl?: string;
621
+ }): Promise<ManagementSession>;
622
+ export interface ReissuedApiKey {
546
623
  accountId: string;
547
624
  apiKey: string;
548
625
  emailVerified: boolean;
549
- }>;
626
+ revokedCount: number;
627
+ /** Keys still active besides the new one (named keys survive unless `revokeAll`). */
628
+ remainingKeys: Pick<ApiKey, "id" | "keyPrefix" | "name" | "scope" | "projectId">[];
629
+ }
630
+ /**
631
+ * Recover a lost account API key with email OTP (after resend-verification).
632
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
633
+ */
634
+ export declare function reissueApiKey(email: string, code: string, baseUrl?: string, opts?: {
635
+ revokeAll?: boolean;
636
+ }): 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",
@@ -95,6 +98,12 @@ export class Novence {
95
98
  list: () => this.request("GET", "/v1/projects"),
96
99
  get: (id) => this.request("GET", `/v1/projects/${id}`),
97
100
  update: (id, input) => this.request("PATCH", `/v1/projects/${id}`, input),
101
+ /**
102
+ * Permanently delete a project (owner only, account key). Irreversible: the site goes
103
+ * offline on every host and its files are erased. `confirm` must equal the project's
104
+ * exact name or suffix.
105
+ */
106
+ delete: (id, input) => this.request("DELETE", `/v1/projects/${id}`, { confirm: input.confirm }),
98
107
  usage: (id) => this.request("GET", `/v1/projects/${id}/usage`),
99
108
  analytics: (id, range) => {
100
109
  const q = new URLSearchParams();
@@ -249,7 +258,8 @@ export class Novence {
249
258
  account = {
250
259
  get: () => this.request("GET", "/v1/account"),
251
260
  consoleKit: () => this.request("GET", "/v1/account/console-kit"),
252
- createSession: () => this.request("POST", "/v1/account/sessions"),
261
+ /** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
262
+ createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
253
263
  revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
254
264
  };
255
265
  apiKeys = {
@@ -266,6 +276,11 @@ export class Novence {
266
276
  const qs = q.toString();
267
277
  return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
268
278
  },
279
+ /**
280
+ * Mint a labelled key (e.g. "ci") that survives `reissueApiKey`. `apiKey` is
281
+ * returned once. Permissions default to (and cannot exceed) the caller's.
282
+ */
283
+ create: (opts) => this.request("POST", "/v1/api-keys", opts),
269
284
  /**
270
285
  * Revoke a key. Idempotent.
271
286
  *
@@ -353,12 +368,39 @@ export async function resendVerification(email, baseUrl) {
353
368
  throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
354
369
  return data;
355
370
  }
356
- /** Recover a lost account API key with email OTP (after resend-verification). */
357
- export async function reissueApiKey(email, code, baseUrl) {
371
+ /** Email a sign-in code for a management session. Always `{ sent: true }` (no account enumeration). */
372
+ export async function requestSessionOtp(email, baseUrl) {
373
+ const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/account/sessions/request`, {
374
+ method: "POST",
375
+ headers: { "Content-Type": "application/json" },
376
+ body: JSON.stringify({ email }),
377
+ });
378
+ const data = (await res.json());
379
+ if (!res.ok)
380
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
381
+ return data;
382
+ }
383
+ /** Exchange an emailed code for a mgmt_ token (read + billing portal; no deploys). */
384
+ export async function verifySessionOtp(email, code, opts = {}) {
385
+ const res = await fetch(`${resolveBaseUrl(opts.baseUrl)}/v1/account/sessions/verify`, {
386
+ method: "POST",
387
+ headers: { "Content-Type": "application/json" },
388
+ body: JSON.stringify({ email, code, ttlMinutes: opts.ttlMinutes }),
389
+ });
390
+ const data = (await res.json());
391
+ if (!res.ok)
392
+ throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
393
+ return data;
394
+ }
395
+ /**
396
+ * Recover a lost account API key with email OTP (after resend-verification).
397
+ * Revokes only the previous primary key unless `revokeAll` (use if a key leaked).
398
+ */
399
+ export async function reissueApiKey(email, code, baseUrl, opts = {}) {
358
400
  const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
359
401
  method: "POST",
360
402
  headers: { "Content-Type": "application/json" },
361
- body: JSON.stringify({ email, code }),
403
+ body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
362
404
  });
363
405
  const data = (await res.json());
364
406
  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.4.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",