@novence/sdk 0.2.5 → 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.
- package/README.md +1 -1
- package/dist/cjs/index.d.ts +139 -13
- package/dist/cjs/index.js +85 -12
- package/dist/esm/index.d.ts +139 -13
- package/dist/esm/index.js +82 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ call at a different control plane — useful when running the API locally.
|
|
|
118
118
|
|
|
119
119
|
| Namespace | Methods |
|
|
120
120
|
| --- | --- |
|
|
121
|
-
| `client.projects` | `create` · `list` · `get` · `update` · `usage` · `analytics` |
|
|
121
|
+
| `client.projects` | `create` · `list` · `get` · `update` · `usage` · `analytics` · `brief` · `putBrief` · `events` |
|
|
122
122
|
| `client.files` | `uploadDir` · `uploadBuffer` · `getUploadUrl` · `getUploadUrlsBatch` · `confirm` · `confirmBatch` |
|
|
123
123
|
| `client.deployments` | `create` · `latest` |
|
|
124
124
|
| `client.domains` | `configure` · `status` |
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface Project {
|
|
|
32
32
|
customDomain?: string | null;
|
|
33
33
|
customDomainStatus?: string;
|
|
34
34
|
analyticsEnabled?: boolean;
|
|
35
|
+
shareGateEmails?: string[];
|
|
36
|
+
siteMcp?: "off" | "read" | "forms";
|
|
37
|
+
dataEditEmails?: string[];
|
|
38
|
+
dataEditNames?: string[];
|
|
39
|
+
dataEditPath?: string;
|
|
35
40
|
createdAt?: string;
|
|
36
41
|
updatedAt?: string;
|
|
37
42
|
}
|
|
@@ -43,12 +48,18 @@ export interface ChecksResults {
|
|
|
43
48
|
passed: boolean | null;
|
|
44
49
|
skipped?: boolean;
|
|
45
50
|
reason?: string;
|
|
51
|
+
/** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
|
|
52
|
+
warnings?: string[];
|
|
46
53
|
[key: string]: unknown;
|
|
47
54
|
}
|
|
48
55
|
export interface Deployment {
|
|
49
56
|
id: string;
|
|
50
57
|
status: DeploymentStatus;
|
|
51
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;
|
|
52
63
|
checksResults?: ChecksResults | null;
|
|
53
64
|
checksUrl?: string;
|
|
54
65
|
errorMessage?: string | null;
|
|
@@ -122,7 +133,7 @@ export interface ApiKey {
|
|
|
122
133
|
id: string;
|
|
123
134
|
/** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
|
|
124
135
|
keyPrefix: string;
|
|
125
|
-
/** "account", "project",
|
|
136
|
+
/** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
|
|
126
137
|
name: string;
|
|
127
138
|
projectId: string | null;
|
|
128
139
|
/** Account keys have a null projectId. */
|
|
@@ -180,6 +191,14 @@ export interface Analytics {
|
|
|
180
191
|
pageviews: number;
|
|
181
192
|
}>;
|
|
182
193
|
}
|
|
194
|
+
export interface SiteDataResult {
|
|
195
|
+
name: string;
|
|
196
|
+
path: string;
|
|
197
|
+
bytes: number;
|
|
198
|
+
json?: unknown;
|
|
199
|
+
url: string;
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
}
|
|
183
202
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
184
203
|
export interface DomainConfigureResult {
|
|
185
204
|
hosts?: string[];
|
|
@@ -191,6 +210,7 @@ export interface DomainConfigureResult {
|
|
|
191
210
|
maxRecords?: number;
|
|
192
211
|
cnameTarget?: string;
|
|
193
212
|
records?: Array<Record<string, unknown>>;
|
|
213
|
+
apexOptions?: Array<Record<string, unknown>>;
|
|
194
214
|
[key: string]: unknown;
|
|
195
215
|
};
|
|
196
216
|
[key: string]: unknown;
|
|
@@ -198,7 +218,14 @@ export interface DomainConfigureResult {
|
|
|
198
218
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
199
219
|
export interface DomainStatus {
|
|
200
220
|
hostname?: string | null;
|
|
221
|
+
customDomain?: string | null;
|
|
222
|
+
customDomainStatus?: string;
|
|
201
223
|
status?: string;
|
|
224
|
+
dns?: {
|
|
225
|
+
www?: "ok" | "missing" | "skipped";
|
|
226
|
+
apex?: "present" | "missing" | "skipped";
|
|
227
|
+
next?: string | null;
|
|
228
|
+
};
|
|
202
229
|
[key: string]: unknown;
|
|
203
230
|
}
|
|
204
231
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
@@ -216,10 +243,30 @@ export interface AccountSnapshot {
|
|
|
216
243
|
} | null;
|
|
217
244
|
[key: string]: unknown;
|
|
218
245
|
}
|
|
219
|
-
|
|
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. */
|
|
220
255
|
export interface ConsoleKit {
|
|
256
|
+
apiBase?: string;
|
|
221
257
|
htmlTemplate?: string;
|
|
222
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
|
+
};
|
|
223
270
|
[key: string]: unknown;
|
|
224
271
|
}
|
|
225
272
|
export declare class Novence {
|
|
@@ -247,6 +294,11 @@ export declare class Novence {
|
|
|
247
294
|
description?: string;
|
|
248
295
|
checkThresholds?: Record<string, unknown>;
|
|
249
296
|
analyticsEnabled?: boolean;
|
|
297
|
+
shareGateEmails?: string[];
|
|
298
|
+
siteMcp?: "off" | "read" | "forms";
|
|
299
|
+
dataEditEmails?: string[];
|
|
300
|
+
dataEditNames?: string[];
|
|
301
|
+
dataEditPath?: string;
|
|
250
302
|
}) => Promise<{
|
|
251
303
|
project: Project;
|
|
252
304
|
}>;
|
|
@@ -263,6 +315,30 @@ export declare class Novence {
|
|
|
263
315
|
from?: string;
|
|
264
316
|
to?: string;
|
|
265
317
|
}) => Promise<Analytics>;
|
|
318
|
+
brief: (id: string) => Promise<{
|
|
319
|
+
projectId: string;
|
|
320
|
+
brief: string | null;
|
|
321
|
+
updatedAt: string | null;
|
|
322
|
+
}>;
|
|
323
|
+
putBrief: (id: string, brief: string) => Promise<{
|
|
324
|
+
projectId: string;
|
|
325
|
+
brief: string | null;
|
|
326
|
+
updatedAt: string | null;
|
|
327
|
+
}>;
|
|
328
|
+
events: (id: string, opts?: {
|
|
329
|
+
since?: string;
|
|
330
|
+
limit?: number;
|
|
331
|
+
}) => Promise<{
|
|
332
|
+
projectId: string;
|
|
333
|
+
since: string;
|
|
334
|
+
limit: number;
|
|
335
|
+
events: Array<{
|
|
336
|
+
id: string;
|
|
337
|
+
type: string;
|
|
338
|
+
payload: Record<string, unknown>;
|
|
339
|
+
createdAt: string;
|
|
340
|
+
}>;
|
|
341
|
+
}>;
|
|
266
342
|
};
|
|
267
343
|
files: {
|
|
268
344
|
getUploadUrl: (projectId: string, path: string, contentType?: string) => Promise<UploadPresign>;
|
|
@@ -313,9 +389,16 @@ export declare class Novence {
|
|
|
313
389
|
force?: boolean;
|
|
314
390
|
}): Promise<PublishHtmlResult>;
|
|
315
391
|
domains: {
|
|
316
|
-
configure: (projectId: string, hostname: string
|
|
392
|
+
configure: (projectId: string, hostname: string, input?: {
|
|
393
|
+
primary?: "www" | "apex";
|
|
394
|
+
redirect?: boolean;
|
|
395
|
+
}) => Promise<DomainConfigureResult>;
|
|
317
396
|
status: (projectId: string) => Promise<DomainStatus>;
|
|
318
397
|
};
|
|
398
|
+
data: {
|
|
399
|
+
put: (projectId: string, name: string, json: unknown) => Promise<SiteDataResult>;
|
|
400
|
+
get: (projectId: string, name: string) => Promise<SiteDataResult>;
|
|
401
|
+
};
|
|
319
402
|
forms: {
|
|
320
403
|
create: (projectId: string, input: {
|
|
321
404
|
name: string;
|
|
@@ -401,11 +484,10 @@ export declare class Novence {
|
|
|
401
484
|
account: {
|
|
402
485
|
get: () => Promise<AccountSnapshot>;
|
|
403
486
|
consoleKit: () => Promise<ConsoleKit>;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}>;
|
|
487
|
+
/** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
|
|
488
|
+
createSession: (opts?: {
|
|
489
|
+
ttlMinutes?: number;
|
|
490
|
+
}) => Promise<ManagementSession>;
|
|
409
491
|
revokeSession: () => Promise<{
|
|
410
492
|
revoked: boolean;
|
|
411
493
|
}>;
|
|
@@ -421,6 +503,18 @@ export declare class Novence {
|
|
|
421
503
|
}) => Promise<{
|
|
422
504
|
keys: ApiKey[];
|
|
423
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
|
+
}>;
|
|
424
518
|
/**
|
|
425
519
|
* Revoke a key. Idempotent.
|
|
426
520
|
*
|
|
@@ -436,14 +530,28 @@ export declare class Novence {
|
|
|
436
530
|
}>;
|
|
437
531
|
};
|
|
438
532
|
}
|
|
439
|
-
export
|
|
533
|
+
export interface SignupAttributionInput {
|
|
534
|
+
method?: "web" | "mcp" | "cli" | "sdk" | "api";
|
|
535
|
+
client?: string;
|
|
536
|
+
source?: string;
|
|
537
|
+
medium?: string;
|
|
538
|
+
campaign?: string;
|
|
539
|
+
content?: string;
|
|
540
|
+
term?: string;
|
|
541
|
+
gclid?: string;
|
|
542
|
+
referrer?: string;
|
|
543
|
+
landing?: string;
|
|
544
|
+
gaClientId?: string;
|
|
545
|
+
gaSessionId?: string;
|
|
546
|
+
}
|
|
547
|
+
export declare function bootstrapAccount(email: string, baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
440
548
|
accountId: string;
|
|
441
549
|
apiKey: string;
|
|
442
550
|
plan: string;
|
|
443
551
|
emailVerificationRequired?: boolean;
|
|
444
552
|
verificationCode?: string;
|
|
445
553
|
}>;
|
|
446
|
-
export declare function createDemoAccount(baseUrl?: string): Promise<{
|
|
554
|
+
export declare function createDemoAccount(baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
447
555
|
accountId: string;
|
|
448
556
|
apiKey: string;
|
|
449
557
|
plan: string;
|
|
@@ -470,9 +578,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
|
|
|
470
578
|
alreadyVerified?: boolean;
|
|
471
579
|
verificationCode?: string;
|
|
472
580
|
}>;
|
|
473
|
-
/**
|
|
474
|
-
export declare function
|
|
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 {
|
|
475
591
|
accountId: string;
|
|
476
592
|
apiKey: string;
|
|
477
593
|
emailVerified: boolean;
|
|
478
|
-
|
|
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",
|
|
@@ -116,6 +121,17 @@ class Novence {
|
|
|
116
121
|
const qs = q.toString();
|
|
117
122
|
return this.request("GET", `/v1/projects/${id}/analytics${qs ? `?${qs}` : ""}`);
|
|
118
123
|
},
|
|
124
|
+
brief: (id) => this.request("GET", `/v1/projects/${id}/brief`),
|
|
125
|
+
putBrief: (id, brief) => this.request("PUT", `/v1/projects/${id}/brief`, { brief }),
|
|
126
|
+
events: (id, opts) => {
|
|
127
|
+
const q = new URLSearchParams();
|
|
128
|
+
if (opts?.since)
|
|
129
|
+
q.set("since", opts.since);
|
|
130
|
+
if (opts?.limit !== undefined)
|
|
131
|
+
q.set("limit", String(opts.limit));
|
|
132
|
+
const qs = q.toString();
|
|
133
|
+
return this.request("GET", `/v1/projects/${id}/events${qs ? `?${qs}` : ""}`);
|
|
134
|
+
},
|
|
119
135
|
};
|
|
120
136
|
files = {
|
|
121
137
|
getUploadUrl: (projectId, path, contentType) => this.request("POST", `/v1/projects/${projectId}/uploads`, {
|
|
@@ -192,11 +208,16 @@ class Novence {
|
|
|
192
208
|
});
|
|
193
209
|
}
|
|
194
210
|
domains = {
|
|
195
|
-
configure: (projectId, hostname) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
211
|
+
configure: (projectId, hostname, input) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
196
212
|
hostname,
|
|
213
|
+
...input,
|
|
197
214
|
}),
|
|
198
215
|
status: (projectId) => this.request("GET", `/v1/projects/${projectId}/domains`),
|
|
199
216
|
};
|
|
217
|
+
data = {
|
|
218
|
+
put: (projectId, name, json) => this.request("PUT", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`, json),
|
|
219
|
+
get: (projectId, name) => this.request("GET", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`),
|
|
220
|
+
};
|
|
200
221
|
forms = {
|
|
201
222
|
create: (projectId, input) => this.request("POST", `/v1/projects/${projectId}/forms`, input),
|
|
202
223
|
list: (projectId) => this.request("GET", `/v1/projects/${projectId}/forms`),
|
|
@@ -244,7 +265,8 @@ class Novence {
|
|
|
244
265
|
account = {
|
|
245
266
|
get: () => this.request("GET", "/v1/account"),
|
|
246
267
|
consoleKit: () => this.request("GET", "/v1/account/console-kit"),
|
|
247
|
-
|
|
268
|
+
/** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
|
|
269
|
+
createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
|
|
248
270
|
revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
|
|
249
271
|
};
|
|
250
272
|
apiKeys = {
|
|
@@ -261,6 +283,11 @@ class Novence {
|
|
|
261
283
|
const qs = q.toString();
|
|
262
284
|
return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
|
|
263
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),
|
|
264
291
|
/**
|
|
265
292
|
* Revoke a key. Idempotent.
|
|
266
293
|
*
|
|
@@ -272,24 +299,43 @@ class Novence {
|
|
|
272
299
|
};
|
|
273
300
|
}
|
|
274
301
|
exports.Novence = Novence;
|
|
275
|
-
|
|
302
|
+
function withMethod(attribution, method) {
|
|
303
|
+
return { ...attribution, method: attribution?.method ?? method };
|
|
304
|
+
}
|
|
305
|
+
/** Gateway 502s are HTML. Parsing them as JSON hides the status. */
|
|
306
|
+
async function readErrorBody(res) {
|
|
307
|
+
const text = await res.text();
|
|
308
|
+
if (!text)
|
|
309
|
+
return {};
|
|
310
|
+
try {
|
|
311
|
+
const parsed = JSON.parse(text);
|
|
312
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
313
|
+
return parsed;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return {};
|
|
318
|
+
}
|
|
319
|
+
return {};
|
|
320
|
+
}
|
|
321
|
+
async function bootstrapAccount(email, baseUrl, attribution) {
|
|
276
322
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/bootstrap`, {
|
|
277
323
|
method: "POST",
|
|
278
324
|
headers: { "Content-Type": "application/json" },
|
|
279
|
-
body: JSON.stringify({ email }),
|
|
325
|
+
body: JSON.stringify({ email, attribution: withMethod(attribution, "sdk") }),
|
|
280
326
|
});
|
|
281
|
-
const data = (await res
|
|
327
|
+
const data = (await readErrorBody(res));
|
|
282
328
|
if (!res.ok)
|
|
283
329
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
284
330
|
return data;
|
|
285
331
|
}
|
|
286
|
-
async function createDemoAccount(baseUrl) {
|
|
332
|
+
async function createDemoAccount(baseUrl, attribution) {
|
|
287
333
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/demo`, {
|
|
288
334
|
method: "POST",
|
|
289
335
|
headers: { "Content-Type": "application/json" },
|
|
290
|
-
body: JSON.stringify({}),
|
|
336
|
+
body: JSON.stringify({ attribution: withMethod(attribution, "sdk") }),
|
|
291
337
|
});
|
|
292
|
-
const data = (await res
|
|
338
|
+
const data = (await readErrorBody(res));
|
|
293
339
|
if (!res.ok)
|
|
294
340
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
295
341
|
return data;
|
|
@@ -330,12 +376,39 @@ async function resendVerification(email, baseUrl) {
|
|
|
330
376
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
331
377
|
return data;
|
|
332
378
|
}
|
|
333
|
-
/**
|
|
334
|
-
async function
|
|
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 = {}) {
|
|
335
408
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
|
|
336
409
|
method: "POST",
|
|
337
410
|
headers: { "Content-Type": "application/json" },
|
|
338
|
-
body: JSON.stringify({ email, code }),
|
|
411
|
+
body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
|
|
339
412
|
});
|
|
340
413
|
const data = (await res.json());
|
|
341
414
|
if (!res.ok)
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface Project {
|
|
|
32
32
|
customDomain?: string | null;
|
|
33
33
|
customDomainStatus?: string;
|
|
34
34
|
analyticsEnabled?: boolean;
|
|
35
|
+
shareGateEmails?: string[];
|
|
36
|
+
siteMcp?: "off" | "read" | "forms";
|
|
37
|
+
dataEditEmails?: string[];
|
|
38
|
+
dataEditNames?: string[];
|
|
39
|
+
dataEditPath?: string;
|
|
35
40
|
createdAt?: string;
|
|
36
41
|
updatedAt?: string;
|
|
37
42
|
}
|
|
@@ -43,12 +48,18 @@ export interface ChecksResults {
|
|
|
43
48
|
passed: boolean | null;
|
|
44
49
|
skipped?: boolean;
|
|
45
50
|
reason?: string;
|
|
51
|
+
/** Non-blocking findings, e.g. low Lighthouse performance while `enforcePerformance` is off. */
|
|
52
|
+
warnings?: string[];
|
|
46
53
|
[key: string]: unknown;
|
|
47
54
|
}
|
|
48
55
|
export interface Deployment {
|
|
49
56
|
id: string;
|
|
50
57
|
status: DeploymentStatus;
|
|
51
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;
|
|
52
63
|
checksResults?: ChecksResults | null;
|
|
53
64
|
checksUrl?: string;
|
|
54
65
|
errorMessage?: string | null;
|
|
@@ -122,7 +133,7 @@ export interface ApiKey {
|
|
|
122
133
|
id: string;
|
|
123
134
|
/** First 12 chars, e.g. nv_live_ab12. The key itself is never returned. */
|
|
124
135
|
keyPrefix: string;
|
|
125
|
-
/** "account", "project",
|
|
136
|
+
/** "account" (primary), "project", "member:{email}", or a label from `apiKeys.create`. */
|
|
126
137
|
name: string;
|
|
127
138
|
projectId: string | null;
|
|
128
139
|
/** Account keys have a null projectId. */
|
|
@@ -180,6 +191,14 @@ export interface Analytics {
|
|
|
180
191
|
pageviews: number;
|
|
181
192
|
}>;
|
|
182
193
|
}
|
|
194
|
+
export interface SiteDataResult {
|
|
195
|
+
name: string;
|
|
196
|
+
path: string;
|
|
197
|
+
bytes: number;
|
|
198
|
+
json?: unknown;
|
|
199
|
+
url: string;
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
}
|
|
183
202
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
184
203
|
export interface DomainConfigureResult {
|
|
185
204
|
hosts?: string[];
|
|
@@ -191,6 +210,7 @@ export interface DomainConfigureResult {
|
|
|
191
210
|
maxRecords?: number;
|
|
192
211
|
cnameTarget?: string;
|
|
193
212
|
records?: Array<Record<string, unknown>>;
|
|
213
|
+
apexOptions?: Array<Record<string, unknown>>;
|
|
194
214
|
[key: string]: unknown;
|
|
195
215
|
};
|
|
196
216
|
[key: string]: unknown;
|
|
@@ -198,7 +218,14 @@ export interface DomainConfigureResult {
|
|
|
198
218
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
199
219
|
export interface DomainStatus {
|
|
200
220
|
hostname?: string | null;
|
|
221
|
+
customDomain?: string | null;
|
|
222
|
+
customDomainStatus?: string;
|
|
201
223
|
status?: string;
|
|
224
|
+
dns?: {
|
|
225
|
+
www?: "ok" | "missing" | "skipped";
|
|
226
|
+
apex?: "present" | "missing" | "skipped";
|
|
227
|
+
next?: string | null;
|
|
228
|
+
};
|
|
202
229
|
[key: string]: unknown;
|
|
203
230
|
}
|
|
204
231
|
/** Not schematised in openapi.yaml — known fields only. */
|
|
@@ -216,10 +243,30 @@ export interface AccountSnapshot {
|
|
|
216
243
|
} | null;
|
|
217
244
|
[key: string]: unknown;
|
|
218
245
|
}
|
|
219
|
-
|
|
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. */
|
|
220
255
|
export interface ConsoleKit {
|
|
256
|
+
apiBase?: string;
|
|
221
257
|
htmlTemplate?: string;
|
|
222
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
|
+
};
|
|
223
270
|
[key: string]: unknown;
|
|
224
271
|
}
|
|
225
272
|
export declare class Novence {
|
|
@@ -247,6 +294,11 @@ export declare class Novence {
|
|
|
247
294
|
description?: string;
|
|
248
295
|
checkThresholds?: Record<string, unknown>;
|
|
249
296
|
analyticsEnabled?: boolean;
|
|
297
|
+
shareGateEmails?: string[];
|
|
298
|
+
siteMcp?: "off" | "read" | "forms";
|
|
299
|
+
dataEditEmails?: string[];
|
|
300
|
+
dataEditNames?: string[];
|
|
301
|
+
dataEditPath?: string;
|
|
250
302
|
}) => Promise<{
|
|
251
303
|
project: Project;
|
|
252
304
|
}>;
|
|
@@ -263,6 +315,30 @@ export declare class Novence {
|
|
|
263
315
|
from?: string;
|
|
264
316
|
to?: string;
|
|
265
317
|
}) => Promise<Analytics>;
|
|
318
|
+
brief: (id: string) => Promise<{
|
|
319
|
+
projectId: string;
|
|
320
|
+
brief: string | null;
|
|
321
|
+
updatedAt: string | null;
|
|
322
|
+
}>;
|
|
323
|
+
putBrief: (id: string, brief: string) => Promise<{
|
|
324
|
+
projectId: string;
|
|
325
|
+
brief: string | null;
|
|
326
|
+
updatedAt: string | null;
|
|
327
|
+
}>;
|
|
328
|
+
events: (id: string, opts?: {
|
|
329
|
+
since?: string;
|
|
330
|
+
limit?: number;
|
|
331
|
+
}) => Promise<{
|
|
332
|
+
projectId: string;
|
|
333
|
+
since: string;
|
|
334
|
+
limit: number;
|
|
335
|
+
events: Array<{
|
|
336
|
+
id: string;
|
|
337
|
+
type: string;
|
|
338
|
+
payload: Record<string, unknown>;
|
|
339
|
+
createdAt: string;
|
|
340
|
+
}>;
|
|
341
|
+
}>;
|
|
266
342
|
};
|
|
267
343
|
files: {
|
|
268
344
|
getUploadUrl: (projectId: string, path: string, contentType?: string) => Promise<UploadPresign>;
|
|
@@ -313,9 +389,16 @@ export declare class Novence {
|
|
|
313
389
|
force?: boolean;
|
|
314
390
|
}): Promise<PublishHtmlResult>;
|
|
315
391
|
domains: {
|
|
316
|
-
configure: (projectId: string, hostname: string
|
|
392
|
+
configure: (projectId: string, hostname: string, input?: {
|
|
393
|
+
primary?: "www" | "apex";
|
|
394
|
+
redirect?: boolean;
|
|
395
|
+
}) => Promise<DomainConfigureResult>;
|
|
317
396
|
status: (projectId: string) => Promise<DomainStatus>;
|
|
318
397
|
};
|
|
398
|
+
data: {
|
|
399
|
+
put: (projectId: string, name: string, json: unknown) => Promise<SiteDataResult>;
|
|
400
|
+
get: (projectId: string, name: string) => Promise<SiteDataResult>;
|
|
401
|
+
};
|
|
319
402
|
forms: {
|
|
320
403
|
create: (projectId: string, input: {
|
|
321
404
|
name: string;
|
|
@@ -401,11 +484,10 @@ export declare class Novence {
|
|
|
401
484
|
account: {
|
|
402
485
|
get: () => Promise<AccountSnapshot>;
|
|
403
486
|
consoleKit: () => Promise<ConsoleKit>;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}>;
|
|
487
|
+
/** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
|
|
488
|
+
createSession: (opts?: {
|
|
489
|
+
ttlMinutes?: number;
|
|
490
|
+
}) => Promise<ManagementSession>;
|
|
409
491
|
revokeSession: () => Promise<{
|
|
410
492
|
revoked: boolean;
|
|
411
493
|
}>;
|
|
@@ -421,6 +503,18 @@ export declare class Novence {
|
|
|
421
503
|
}) => Promise<{
|
|
422
504
|
keys: ApiKey[];
|
|
423
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
|
+
}>;
|
|
424
518
|
/**
|
|
425
519
|
* Revoke a key. Idempotent.
|
|
426
520
|
*
|
|
@@ -436,14 +530,28 @@ export declare class Novence {
|
|
|
436
530
|
}>;
|
|
437
531
|
};
|
|
438
532
|
}
|
|
439
|
-
export
|
|
533
|
+
export interface SignupAttributionInput {
|
|
534
|
+
method?: "web" | "mcp" | "cli" | "sdk" | "api";
|
|
535
|
+
client?: string;
|
|
536
|
+
source?: string;
|
|
537
|
+
medium?: string;
|
|
538
|
+
campaign?: string;
|
|
539
|
+
content?: string;
|
|
540
|
+
term?: string;
|
|
541
|
+
gclid?: string;
|
|
542
|
+
referrer?: string;
|
|
543
|
+
landing?: string;
|
|
544
|
+
gaClientId?: string;
|
|
545
|
+
gaSessionId?: string;
|
|
546
|
+
}
|
|
547
|
+
export declare function bootstrapAccount(email: string, baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
440
548
|
accountId: string;
|
|
441
549
|
apiKey: string;
|
|
442
550
|
plan: string;
|
|
443
551
|
emailVerificationRequired?: boolean;
|
|
444
552
|
verificationCode?: string;
|
|
445
553
|
}>;
|
|
446
|
-
export declare function createDemoAccount(baseUrl?: string): Promise<{
|
|
554
|
+
export declare function createDemoAccount(baseUrl?: string, attribution?: SignupAttributionInput): Promise<{
|
|
447
555
|
accountId: string;
|
|
448
556
|
apiKey: string;
|
|
449
557
|
plan: string;
|
|
@@ -470,9 +578,27 @@ export declare function resendVerification(email: string, baseUrl?: string): Pro
|
|
|
470
578
|
alreadyVerified?: boolean;
|
|
471
579
|
verificationCode?: string;
|
|
472
580
|
}>;
|
|
473
|
-
/**
|
|
474
|
-
export declare function
|
|
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 {
|
|
475
591
|
accountId: string;
|
|
476
592
|
apiKey: string;
|
|
477
593
|
emailVerified: boolean;
|
|
478
|
-
|
|
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",
|
|
@@ -105,6 +108,17 @@ export class Novence {
|
|
|
105
108
|
const qs = q.toString();
|
|
106
109
|
return this.request("GET", `/v1/projects/${id}/analytics${qs ? `?${qs}` : ""}`);
|
|
107
110
|
},
|
|
111
|
+
brief: (id) => this.request("GET", `/v1/projects/${id}/brief`),
|
|
112
|
+
putBrief: (id, brief) => this.request("PUT", `/v1/projects/${id}/brief`, { brief }),
|
|
113
|
+
events: (id, opts) => {
|
|
114
|
+
const q = new URLSearchParams();
|
|
115
|
+
if (opts?.since)
|
|
116
|
+
q.set("since", opts.since);
|
|
117
|
+
if (opts?.limit !== undefined)
|
|
118
|
+
q.set("limit", String(opts.limit));
|
|
119
|
+
const qs = q.toString();
|
|
120
|
+
return this.request("GET", `/v1/projects/${id}/events${qs ? `?${qs}` : ""}`);
|
|
121
|
+
},
|
|
108
122
|
};
|
|
109
123
|
files = {
|
|
110
124
|
getUploadUrl: (projectId, path, contentType) => this.request("POST", `/v1/projects/${projectId}/uploads`, {
|
|
@@ -181,11 +195,16 @@ export class Novence {
|
|
|
181
195
|
});
|
|
182
196
|
}
|
|
183
197
|
domains = {
|
|
184
|
-
configure: (projectId, hostname) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
198
|
+
configure: (projectId, hostname, input) => this.request("POST", `/v1/projects/${projectId}/domains`, {
|
|
185
199
|
hostname,
|
|
200
|
+
...input,
|
|
186
201
|
}),
|
|
187
202
|
status: (projectId) => this.request("GET", `/v1/projects/${projectId}/domains`),
|
|
188
203
|
};
|
|
204
|
+
data = {
|
|
205
|
+
put: (projectId, name, json) => this.request("PUT", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`, json),
|
|
206
|
+
get: (projectId, name) => this.request("GET", `/v1/projects/${projectId}/data/${encodeURIComponent(name)}`),
|
|
207
|
+
};
|
|
189
208
|
forms = {
|
|
190
209
|
create: (projectId, input) => this.request("POST", `/v1/projects/${projectId}/forms`, input),
|
|
191
210
|
list: (projectId) => this.request("GET", `/v1/projects/${projectId}/forms`),
|
|
@@ -233,7 +252,8 @@ export class Novence {
|
|
|
233
252
|
account = {
|
|
234
253
|
get: () => this.request("GET", "/v1/account"),
|
|
235
254
|
consoleKit: () => this.request("GET", "/v1/account/console-kit"),
|
|
236
|
-
|
|
255
|
+
/** `ttlMinutes` 5–480 (default 30). Sessions over 30 minutes omit `project:members`. */
|
|
256
|
+
createSession: (opts = {}) => this.request("POST", "/v1/account/sessions", opts),
|
|
237
257
|
revokeSession: () => this.request("DELETE", "/v1/account/sessions/current"),
|
|
238
258
|
};
|
|
239
259
|
apiKeys = {
|
|
@@ -250,6 +270,11 @@ export class Novence {
|
|
|
250
270
|
const qs = q.toString();
|
|
251
271
|
return this.request("GET", `/v1/api-keys${qs ? `?${qs}` : ""}`);
|
|
252
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),
|
|
253
278
|
/**
|
|
254
279
|
* Revoke a key. Idempotent.
|
|
255
280
|
*
|
|
@@ -260,24 +285,43 @@ export class Novence {
|
|
|
260
285
|
revoke: (id, opts = {}) => this.request("DELETE", `/v1/api-keys/${id}${opts.force ? "?force=true" : ""}`),
|
|
261
286
|
};
|
|
262
287
|
}
|
|
263
|
-
|
|
288
|
+
function withMethod(attribution, method) {
|
|
289
|
+
return { ...attribution, method: attribution?.method ?? method };
|
|
290
|
+
}
|
|
291
|
+
/** Gateway 502s are HTML. Parsing them as JSON hides the status. */
|
|
292
|
+
async function readErrorBody(res) {
|
|
293
|
+
const text = await res.text();
|
|
294
|
+
if (!text)
|
|
295
|
+
return {};
|
|
296
|
+
try {
|
|
297
|
+
const parsed = JSON.parse(text);
|
|
298
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
299
|
+
return parsed;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return {};
|
|
304
|
+
}
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
export async function bootstrapAccount(email, baseUrl, attribution) {
|
|
264
308
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/bootstrap`, {
|
|
265
309
|
method: "POST",
|
|
266
310
|
headers: { "Content-Type": "application/json" },
|
|
267
|
-
body: JSON.stringify({ email }),
|
|
311
|
+
body: JSON.stringify({ email, attribution: withMethod(attribution, "sdk") }),
|
|
268
312
|
});
|
|
269
|
-
const data = (await res
|
|
313
|
+
const data = (await readErrorBody(res));
|
|
270
314
|
if (!res.ok)
|
|
271
315
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
272
316
|
return data;
|
|
273
317
|
}
|
|
274
|
-
export async function createDemoAccount(baseUrl) {
|
|
318
|
+
export async function createDemoAccount(baseUrl, attribution) {
|
|
275
319
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/demo`, {
|
|
276
320
|
method: "POST",
|
|
277
321
|
headers: { "Content-Type": "application/json" },
|
|
278
|
-
body: JSON.stringify({}),
|
|
322
|
+
body: JSON.stringify({ attribution: withMethod(attribution, "sdk") }),
|
|
279
323
|
});
|
|
280
|
-
const data = (await res
|
|
324
|
+
const data = (await readErrorBody(res));
|
|
281
325
|
if (!res.ok)
|
|
282
326
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
283
327
|
return data;
|
|
@@ -318,12 +362,39 @@ export async function resendVerification(email, baseUrl) {
|
|
|
318
362
|
throw new NovenceError(data.error ?? `HTTP ${res.status}`, res.status);
|
|
319
363
|
return data;
|
|
320
364
|
}
|
|
321
|
-
/**
|
|
322
|
-
export async function
|
|
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 = {}) {
|
|
323
394
|
const res = await fetch(`${resolveBaseUrl(baseUrl)}/v1/auth/reissue-key`, {
|
|
324
395
|
method: "POST",
|
|
325
396
|
headers: { "Content-Type": "application/json" },
|
|
326
|
-
body: JSON.stringify({ email, code }),
|
|
397
|
+
body: JSON.stringify({ email, code, revokeAll: opts.revokeAll }),
|
|
327
398
|
});
|
|
328
399
|
const data = (await res.json());
|
|
329
400
|
if (!res.ok)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novence/sdk",
|
|
3
|
-
"version": "0.
|
|
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",
|