@atlasauth/backend 0.16.0 → 0.18.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/CHANGELOG.md +16 -0
- package/dist/better-auth.d.ts +157 -0
- package/dist/better-auth.js +245 -0
- package/dist/better-auth.js.map +1 -0
- package/dist/client/better-auth-imports.d.ts +205 -0
- package/dist/client/better-auth-imports.js +107 -0
- package/dist/client/better-auth-imports.js.map +1 -0
- package/dist/client/index.d.ts +116 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/policies.d.ts +316 -0
- package/dist/client/policies.js +103 -0
- package/dist/client/policies.js.map +1 -0
- package/dist/client/users.d.ts +15 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy-issuers.d.ts +65 -0
- package/dist/legacy-issuers.js +140 -0
- package/dist/legacy-issuers.js.map +1 -0
- package/dist/policy-source.d.ts +104 -0
- package/dist/policy-source.js +99 -0
- package/dist/policy-source.js.map +1 -0
- package/dist/verify.d.ts +22 -0
- package/dist/verify.js +32 -0
- package/dist/verify.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BETTER_AUTH_IMPORT_PART_BYTES = void 0;
|
|
4
|
+
exports.splitBundleParts = splitBundleParts;
|
|
5
|
+
exports.betterAuthImportsResource = betterAuthImportsResource;
|
|
6
|
+
const request_1 = require("./request");
|
|
7
|
+
/** Bytes per uploaded part (the API takes at most 10 MiB). Parts end on a line boundary. */
|
|
8
|
+
exports.BETTER_AUTH_IMPORT_PART_BYTES = 8 * 1024 * 1024;
|
|
9
|
+
/** Split a sealed bundle's text into upload parts on line boundaries. */
|
|
10
|
+
function splitBundleParts(text, maxBytes = exports.BETTER_AUTH_IMPORT_PART_BYTES) {
|
|
11
|
+
const enc8 = new TextEncoder();
|
|
12
|
+
const parts = [];
|
|
13
|
+
let current = [];
|
|
14
|
+
let size = 0;
|
|
15
|
+
for (const line of text.split('\n')) {
|
|
16
|
+
if (!line)
|
|
17
|
+
continue;
|
|
18
|
+
const n = enc8.encode(line).length + 1;
|
|
19
|
+
if (size > 0 && size + n > maxBytes) {
|
|
20
|
+
parts.push(`${current.join('\n')}\n`);
|
|
21
|
+
current = [];
|
|
22
|
+
size = 0;
|
|
23
|
+
}
|
|
24
|
+
current.push(line);
|
|
25
|
+
size += n;
|
|
26
|
+
}
|
|
27
|
+
if (current.length)
|
|
28
|
+
parts.push(`${current.join('\n')}\n`);
|
|
29
|
+
return parts;
|
|
30
|
+
}
|
|
31
|
+
const TERMINAL = ['ready', 'invalid', 'completed', 'failed'];
|
|
32
|
+
function betterAuthImportsResource(request) {
|
|
33
|
+
const base = '/v1/better_auth_imports';
|
|
34
|
+
const self = {
|
|
35
|
+
/** The import public key (created on first read). */
|
|
36
|
+
getPublicKey() {
|
|
37
|
+
return request({ method: 'GET', path: `${base}/public_key` });
|
|
38
|
+
},
|
|
39
|
+
/** Replace the import key; bundles sealed to the old one no longer finalize. */
|
|
40
|
+
rotatePublicKey() {
|
|
41
|
+
return request({ method: 'POST', path: `${base}/public_key/rotate` });
|
|
42
|
+
},
|
|
43
|
+
create(body = {}, idempotencyKey) {
|
|
44
|
+
return request({ method: 'POST', path: base, body, idempotencyKey });
|
|
45
|
+
},
|
|
46
|
+
list(params = {}) {
|
|
47
|
+
return request({ method: 'GET', path: base, query: { ...params } });
|
|
48
|
+
},
|
|
49
|
+
get(id) {
|
|
50
|
+
return request({ method: 'GET', path: `${base}/${(0, request_1.enc)(id)}` });
|
|
51
|
+
},
|
|
52
|
+
/** Upload part `part` (1-based) of the sealed bundle text. */
|
|
53
|
+
uploadPart(id, part, data) {
|
|
54
|
+
return request({ method: 'PUT', path: `${base}/${(0, request_1.enc)(id)}/parts/${part}`, body: { data } });
|
|
55
|
+
},
|
|
56
|
+
/** Close the upload; Atlas checks the key and runs the dry run. */
|
|
57
|
+
finalize(id) {
|
|
58
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/finalize` });
|
|
59
|
+
},
|
|
60
|
+
/** Run the dry run again, optionally with new options. */
|
|
61
|
+
dryRun(id, body = {}) {
|
|
62
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/dry_run`, body });
|
|
63
|
+
},
|
|
64
|
+
/** Import (or resume). Pass confirm_conflicts when the dry run reported conflicts. */
|
|
65
|
+
apply(id, body = {}) {
|
|
66
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/apply`, body });
|
|
67
|
+
},
|
|
68
|
+
delete(id) {
|
|
69
|
+
return request({ method: 'DELETE', path: `${base}/${(0, request_1.enc)(id)}` });
|
|
70
|
+
},
|
|
71
|
+
/** Better Auth JWT keys published in the instance JWKS for the cutover. */
|
|
72
|
+
listJwks() {
|
|
73
|
+
return request({ method: 'GET', path: `${base}/jwks` });
|
|
74
|
+
},
|
|
75
|
+
deleteJwk(kid) {
|
|
76
|
+
return request({ method: 'DELETE', path: `${base}/jwks/${(0, request_1.enc)(kid)}` });
|
|
77
|
+
},
|
|
78
|
+
/** Create an import, upload the sealed bundle text in parts and finalize it. */
|
|
79
|
+
async upload(bundleText, opts = {}) {
|
|
80
|
+
const parts = splitBundleParts(bundleText, opts.partBytes);
|
|
81
|
+
if (parts.length === 0)
|
|
82
|
+
throw new Error('The bundle is empty.');
|
|
83
|
+
const created = await self.create(opts.options ? { options: opts.options } : {});
|
|
84
|
+
for (let i = 0; i < parts.length; i++) {
|
|
85
|
+
await self.uploadPart(created.id, i + 1, parts[i]);
|
|
86
|
+
opts.onPart?.(i + 1, parts.length);
|
|
87
|
+
}
|
|
88
|
+
return self.finalize(created.id);
|
|
89
|
+
},
|
|
90
|
+
/** Poll until the import leaves analyzing / queued / applying. */
|
|
91
|
+
async waitFor(id, opts = {}) {
|
|
92
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
93
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 6 * 3600_000);
|
|
94
|
+
for (;;) {
|
|
95
|
+
const imp = await self.get(id);
|
|
96
|
+
opts.onProgress?.(imp);
|
|
97
|
+
if (TERMINAL.includes(imp.status) || imp.status === 'uploading')
|
|
98
|
+
return imp;
|
|
99
|
+
if (Date.now() > deadline)
|
|
100
|
+
throw new Error(`Timed out waiting for Better Auth import ${id} (status ${imp.status}).`);
|
|
101
|
+
await sleep(opts.intervalMs ?? 2000);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
return self;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=better-auth-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth-imports.js","sourceRoot":"","sources":["../../src/client/better-auth-imports.ts"],"names":[],"mappings":";;;AAgIA,4CAkBC;AAID,8DA6EC;AAnOD,uCAAgD;AA4HhD,4FAA4F;AAC/E,QAAA,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7D,yEAAyE;AACzE,SAAgB,gBAAgB,CAAC,IAAY,EAAE,QAAQ,GAAG,qCAA6B;IACrF,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACvC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,QAAQ,EAAE,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AI,CAAC,KAAK,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;YAC/D,SAAS,CAAC;gBACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/B,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;gBACvB,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,WAAW;oBAAE,OAAO,GAAG,CAAC;gBAC5E,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,EAAE,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;gBACrH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -973,6 +973,51 @@ declare function buildNamespaces(request: RequestFn): {
|
|
|
973
973
|
getJob(id: string): Promise<import("./import-export").Job>;
|
|
974
974
|
getJobErrors(id: string): Promise<import("./types").ListPage<import("./import-export").JobError>>;
|
|
975
975
|
};
|
|
976
|
+
betterAuthImports: {
|
|
977
|
+
getPublicKey(): Promise<import("./better-auth-imports").BetterAuthImportKey>;
|
|
978
|
+
rotatePublicKey(): Promise<import("./better-auth-imports").BetterAuthImportKey>;
|
|
979
|
+
create(body?: {
|
|
980
|
+
options?: import("./better-auth-imports").BetterAuthImportOptions;
|
|
981
|
+
}, idempotencyKey?: string): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
982
|
+
list(params?: import("./types").CursorParams): Promise<import("./types").CursorPage<import("./better-auth-imports").BetterAuthImport>>;
|
|
983
|
+
get(id: string): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
984
|
+
uploadPart(id: string, part: number, data: string): Promise<{
|
|
985
|
+
object: "better_auth_import_part";
|
|
986
|
+
import_id: string;
|
|
987
|
+
part: number;
|
|
988
|
+
bytes: number;
|
|
989
|
+
sha256: string;
|
|
990
|
+
}>;
|
|
991
|
+
finalize(id: string): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
992
|
+
dryRun(id: string, body?: {
|
|
993
|
+
options?: import("./better-auth-imports").BetterAuthImportOptions;
|
|
994
|
+
}): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
995
|
+
apply(id: string, body?: {
|
|
996
|
+
confirm_conflicts?: boolean;
|
|
997
|
+
}): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
998
|
+
delete(id: string): Promise<{
|
|
999
|
+
object: "better_auth_import";
|
|
1000
|
+
id: string;
|
|
1001
|
+
deleted: true;
|
|
1002
|
+
}>;
|
|
1003
|
+
listJwks(): Promise<import("./types").CursorPage<import("./better-auth-imports").ImportedJwk>>;
|
|
1004
|
+
deleteJwk(kid: string): Promise<{
|
|
1005
|
+
object: "imported_jwk";
|
|
1006
|
+
kid: string;
|
|
1007
|
+
deleted: true;
|
|
1008
|
+
}>;
|
|
1009
|
+
upload(bundleText: string, opts?: {
|
|
1010
|
+
options?: import("./better-auth-imports").BetterAuthImportOptions;
|
|
1011
|
+
partBytes?: number;
|
|
1012
|
+
onPart?: (n: number, of: number) => void;
|
|
1013
|
+
}): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
1014
|
+
waitFor(id: string, opts?: {
|
|
1015
|
+
intervalMs?: number;
|
|
1016
|
+
timeoutMs?: number;
|
|
1017
|
+
onProgress?: (imp: import("./better-auth-imports").BetterAuthImport) => void;
|
|
1018
|
+
sleep?: (ms: number) => Promise<void>;
|
|
1019
|
+
}): Promise<import("./better-auth-imports").BetterAuthImport>;
|
|
1020
|
+
};
|
|
976
1021
|
dataSubjectRequests: {
|
|
977
1022
|
create(body: import("./data-subject-requests").CreateDataSubjectRequestBody, idempotencyKey?: string): Promise<import("./data-subject-requests").DataSubjectRequest>;
|
|
978
1023
|
cancel(id: string): Promise<import("./data-subject-requests").DataSubjectRequest>;
|
|
@@ -1114,6 +1159,75 @@ declare function buildNamespaces(request: RequestFn): {
|
|
|
1114
1159
|
getBackfill(id: string): Promise<import("./referrals").ReferralBackfillJob>;
|
|
1115
1160
|
getForUser(userId: string): Promise<import("./users").UserReferralResult>;
|
|
1116
1161
|
};
|
|
1162
|
+
policies: {
|
|
1163
|
+
list(params?: {
|
|
1164
|
+
include_retired?: boolean;
|
|
1165
|
+
}): Promise<{
|
|
1166
|
+
object: "list";
|
|
1167
|
+
data: import("./policies").Policy[];
|
|
1168
|
+
}>;
|
|
1169
|
+
create(body: import("./policies").CreatePolicyBody): Promise<import("./policies").Policy>;
|
|
1170
|
+
get(idOrKey: string): Promise<import("./policies").Policy>;
|
|
1171
|
+
update(idOrKey: string, body: import("./policies").UpdatePolicyBody): Promise<import("./policies").Policy>;
|
|
1172
|
+
delete(idOrKey: string): Promise<{
|
|
1173
|
+
object: "policy";
|
|
1174
|
+
id: string;
|
|
1175
|
+
key: string;
|
|
1176
|
+
deleted: boolean;
|
|
1177
|
+
retired: boolean;
|
|
1178
|
+
policy?: import("./policies").Policy;
|
|
1179
|
+
}>;
|
|
1180
|
+
versions: {
|
|
1181
|
+
list(idOrKey: string): Promise<{
|
|
1182
|
+
object: "list";
|
|
1183
|
+
data: import("./policies").PolicyVersion[];
|
|
1184
|
+
}>;
|
|
1185
|
+
create(idOrKey: string, body: import("./policies").CreatePolicyVersionBody): Promise<import("./policies").PolicyVersion>;
|
|
1186
|
+
get(idOrKey: string, versionIdOrLabel: string): Promise<import("./policies").PolicyVersion>;
|
|
1187
|
+
update(idOrKey: string, versionIdOrLabel: string, body: import("./policies").UpdatePolicyVersionBody): Promise<import("./policies").PolicyVersion>;
|
|
1188
|
+
delete(idOrKey: string, versionIdOrLabel: string): Promise<{
|
|
1189
|
+
object: "policy_version";
|
|
1190
|
+
id: string;
|
|
1191
|
+
deleted: true;
|
|
1192
|
+
}>;
|
|
1193
|
+
publish(idOrKey: string, versionIdOrLabel: string, body?: {
|
|
1194
|
+
effective_at?: number | string;
|
|
1195
|
+
}): Promise<import("./policies").PolicyVersion>;
|
|
1196
|
+
retire(idOrKey: string, versionIdOrLabel: string): Promise<import("./policies").PolicyVersion>;
|
|
1197
|
+
};
|
|
1198
|
+
listAcceptances(idOrKey: string, params?: import("./policies").ListPolicyAcceptancesParams): Promise<import("./policies").PolicyAcceptancePage>;
|
|
1199
|
+
exportAcceptancesCsv(idOrKey: string, params?: Omit<import("./policies").ListPolicyAcceptancesParams, "limit" | "starting_after">): Promise<string>;
|
|
1200
|
+
forUser(userId: string): Promise<{
|
|
1201
|
+
object: "list";
|
|
1202
|
+
user_id: string;
|
|
1203
|
+
data: import("./policies").PolicyStanding[];
|
|
1204
|
+
needs_acceptance: boolean;
|
|
1205
|
+
}>;
|
|
1206
|
+
settings: {
|
|
1207
|
+
get(): Promise<import("./policies").PolicySettings>;
|
|
1208
|
+
update(body: {
|
|
1209
|
+
session_claim?: boolean;
|
|
1210
|
+
}): Promise<import("./policies").PolicySettings>;
|
|
1211
|
+
};
|
|
1212
|
+
};
|
|
1213
|
+
policySource: {
|
|
1214
|
+
get(): Promise<import("./policies").PolicySource>;
|
|
1215
|
+
update(body: import("./policies").UpdatePolicySourceBody): Promise<import("./policies").PolicySource>;
|
|
1216
|
+
delete(): Promise<import("./policies").PolicySource>;
|
|
1217
|
+
test(): Promise<import("./policies").PolicySourceTest>;
|
|
1218
|
+
sync(): Promise<import("./policies").PolicySourceSync>;
|
|
1219
|
+
listDeliveries(params?: {
|
|
1220
|
+
limit?: number;
|
|
1221
|
+
starting_after?: string;
|
|
1222
|
+
kind?: string;
|
|
1223
|
+
status?: string;
|
|
1224
|
+
}): Promise<{
|
|
1225
|
+
object: "list";
|
|
1226
|
+
data: import("./policies").PolicySourceDelivery[];
|
|
1227
|
+
has_more: boolean;
|
|
1228
|
+
next_cursor: string | null;
|
|
1229
|
+
}>;
|
|
1230
|
+
};
|
|
1117
1231
|
userHooks: {
|
|
1118
1232
|
getBeforeUserCreate(): Promise<import("./user-hooks").BeforeUserCreateHook>;
|
|
1119
1233
|
updateBeforeUserCreate(body: import("./user-hooks").UpdateBeforeUserCreateHookBody): Promise<import("./user-hooks").BeforeUserCreateHook>;
|
|
@@ -1494,12 +1608,14 @@ export * from './action-gallery';
|
|
|
1494
1608
|
export * from './billing-plans';
|
|
1495
1609
|
export * from './messaging';
|
|
1496
1610
|
export * from './import-export';
|
|
1611
|
+
export * from './better-auth-imports';
|
|
1497
1612
|
export * from './data-subject-requests';
|
|
1498
1613
|
export * from './radius-clients';
|
|
1499
1614
|
export * from './lti-platforms';
|
|
1500
1615
|
export * from './instance';
|
|
1501
1616
|
export * from './instance-security';
|
|
1502
1617
|
export * from './referrals';
|
|
1618
|
+
export * from './policies';
|
|
1503
1619
|
export * from './user-hooks';
|
|
1504
1620
|
export * from './tokens';
|
|
1505
1621
|
export * from './captcha';
|
package/dist/client/index.js
CHANGED
|
@@ -57,12 +57,14 @@ const action_gallery_1 = require("./action-gallery");
|
|
|
57
57
|
const billing_plans_1 = require("./billing-plans");
|
|
58
58
|
const messaging_1 = require("./messaging");
|
|
59
59
|
const import_export_1 = require("./import-export");
|
|
60
|
+
const better_auth_imports_1 = require("./better-auth-imports");
|
|
60
61
|
const data_subject_requests_1 = require("./data-subject-requests");
|
|
61
62
|
const radius_clients_1 = require("./radius-clients");
|
|
62
63
|
const lti_platforms_1 = require("./lti-platforms");
|
|
63
64
|
const instance_1 = require("./instance");
|
|
64
65
|
const instance_security_1 = require("./instance-security");
|
|
65
66
|
const referrals_1 = require("./referrals");
|
|
67
|
+
const policies_1 = require("./policies");
|
|
66
68
|
const user_hooks_1 = require("./user-hooks");
|
|
67
69
|
const tokens_1 = require("./tokens");
|
|
68
70
|
const captcha_1 = require("./captcha");
|
|
@@ -151,6 +153,8 @@ function buildNamespaces(request) {
|
|
|
151
153
|
billing: (0, billing_plans_1.billingResource)(request),
|
|
152
154
|
messaging: (0, messaging_1.messagingResource)(request),
|
|
153
155
|
importExport: (0, import_export_1.importExportResource)(request),
|
|
156
|
+
// Migrate from Better Auth: sealed-bundle upload, dry run and resumable apply.
|
|
157
|
+
betterAuthImports: (0, better_auth_imports_1.betterAuthImportsResource)(request),
|
|
154
158
|
dataSubjectRequests: (0, data_subject_requests_1.dataSubjectRequestsResource)(request),
|
|
155
159
|
radiusClients: (0, radius_clients_1.radiusClientsResource)(request),
|
|
156
160
|
ltiPlatforms: (0, lti_platforms_1.ltiPlatformsResource)(request),
|
|
@@ -158,6 +162,9 @@ function buildNamespaces(request) {
|
|
|
158
162
|
instanceSecurity: (0, instance_security_1.instanceSecurityResource)(request),
|
|
159
163
|
// Referral attribution: the instance's referral platform connection and call log.
|
|
160
164
|
referrals: (0, referrals_1.referralsResource)(request),
|
|
165
|
+
// Policy acceptance: policies, versions, acceptances, settings, and the external policy source.
|
|
166
|
+
policies: (0, policies_1.policiesResource)(request),
|
|
167
|
+
policySource: (0, policies_1.policySourceResource)(request),
|
|
161
168
|
// The before_user_create hook (sets external_id before the user exists).
|
|
162
169
|
userHooks: (0, user_hooks_1.userHooksResource)(request),
|
|
163
170
|
tokens: (0, tokens_1.tokensResource)(request),
|
|
@@ -247,12 +254,14 @@ __exportStar(require("./action-gallery"), exports);
|
|
|
247
254
|
__exportStar(require("./billing-plans"), exports);
|
|
248
255
|
__exportStar(require("./messaging"), exports);
|
|
249
256
|
__exportStar(require("./import-export"), exports);
|
|
257
|
+
__exportStar(require("./better-auth-imports"), exports);
|
|
250
258
|
__exportStar(require("./data-subject-requests"), exports);
|
|
251
259
|
__exportStar(require("./radius-clients"), exports);
|
|
252
260
|
__exportStar(require("./lti-platforms"), exports);
|
|
253
261
|
__exportStar(require("./instance"), exports);
|
|
254
262
|
__exportStar(require("./instance-security"), exports);
|
|
255
263
|
__exportStar(require("./referrals"), exports);
|
|
264
|
+
__exportStar(require("./policies"), exports);
|
|
256
265
|
__exportStar(require("./user-hooks"), exports);
|
|
257
266
|
__exportStar(require("./tokens"), exports);
|
|
258
267
|
__exportStar(require("./captcha"), exports);
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmFA,8CAQC;AA3FD,uCAA6F;AAC7F,mCAAwC;AACxC,yCAA8C;AAC9C,mDAAwD;AACxD,mCAA6D;AAC7D,mDAAuD;AACvD,yDAA6D;AAC7D,uDAA2D;AAC3D,+CAAmD;AACnD,uCAA4C;AAC5C,yCAA8C;AAC9C,iDAAsE;AACtE,2DAA+D;AAC/D,iDAAqD;AACrD,+CAAoD;AACpD,yCAA8C;AAC9C,qDAAwD;AACxD,6CAAiD;AACjD,mDAAuD;AACvD,yCAA6C;AAC7C,2CAA+C;AAC/C,yCAA8C;AAC9C,uDAA2D;AAC3D,qDAAyD;AACzD,2DAA+D;AAC/D,+BAAoC;AACpC,6CAAuD;AACvD,qDAAwD;AACxD,+CAAmD;AACnD,iDAAqD;AACrD,+CAAmD;AACnD,+CAAmD;AACnD,yCAA8C;AAC9C,uDAA2D;AAC3D,mDAAuD;AACvD,mDAAwD;AACxD,uCAA4C;AAC5C,qDAAkF;AAClF,mDAAkD;AAClD,2CAAgD;AAChD,mDAAuD;AACvD,+DAAkE;AAClE,mEAAsE;AACtE,qDAAyD;AACzD,mDAAuD;AACvD,yCAA8C;AA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AACtB,wCAAsB;AACtB,gDAA8B;AAC9B,kDAAgC;AAChC,0DAAwC;AACxC,4CAA0B;AAC1B,8CAA4B;AAC5B,gDAA8B;AAC9B,4DAA0C;AAC1C,6CAA2B"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { type RequestFn } from './request';
|
|
2
|
+
/**
|
|
3
|
+
* Policy acceptance: the policies (Terms of Service, privacy policy, any key)
|
|
4
|
+
* your users accept at sign-up — and, per policy, again at sign-in when a new
|
|
5
|
+
* version takes effect. A policy's versions go draft → published (with an
|
|
6
|
+
* `effective_at`) → retired; a published version is immutable, and its
|
|
7
|
+
* `content_sha256` is the SHA-256 of the sanitised HTML users are shown.
|
|
8
|
+
* Acceptances are consent records carrying that hash and the reading evidence.
|
|
9
|
+
*
|
|
10
|
+
* Content can also come from any external system through the Atlas policy
|
|
11
|
+
* source protocol (`policySource`): Atlas fetches `GET {endpoint_url}/policies`
|
|
12
|
+
* signed like an Atlas webhook, and your system tells Atlas about a new
|
|
13
|
+
* version with a signed `policy.published` event.
|
|
14
|
+
*/
|
|
15
|
+
export type PolicyDisplay = 'checkbox' | 'scroll' | 'link';
|
|
16
|
+
export type PolicyAppliesTo = 'sign_up' | 'sign_in_and_sign_up';
|
|
17
|
+
export type PolicyReaccept = 'none' | 'next_sign_in' | 'grace';
|
|
18
|
+
export interface PolicyVersionRef {
|
|
19
|
+
id: string;
|
|
20
|
+
version: string;
|
|
21
|
+
status: 'draft' | 'published' | 'retired' | (string & {});
|
|
22
|
+
content_sha256: string;
|
|
23
|
+
published_at: number | null;
|
|
24
|
+
effective_at: number | null;
|
|
25
|
+
}
|
|
26
|
+
export interface Policy {
|
|
27
|
+
object: 'policy';
|
|
28
|
+
id: string;
|
|
29
|
+
key: string;
|
|
30
|
+
title: string;
|
|
31
|
+
display: PolicyDisplay;
|
|
32
|
+
required: boolean;
|
|
33
|
+
applies_to: PolicyAppliesTo;
|
|
34
|
+
reaccept: PolicyReaccept;
|
|
35
|
+
grace_days: number | null;
|
|
36
|
+
source: 'atlas' | 'external';
|
|
37
|
+
position: number;
|
|
38
|
+
status: 'active' | 'retired';
|
|
39
|
+
/** External policies: fields changed in Atlas that a sync keeps. */
|
|
40
|
+
overrides: string[];
|
|
41
|
+
/** The version in effect now. */
|
|
42
|
+
current_version: PolicyVersionRef | null;
|
|
43
|
+
/** A newer published version that is not in effect yet. */
|
|
44
|
+
upcoming_version: PolicyVersionRef | null;
|
|
45
|
+
/** The newest version of any status (drafts included). */
|
|
46
|
+
latest_version: PolicyVersionRef | null;
|
|
47
|
+
retired_at: number | null;
|
|
48
|
+
created_at: number;
|
|
49
|
+
updated_at: number;
|
|
50
|
+
}
|
|
51
|
+
export interface PolicyVersion {
|
|
52
|
+
object: 'policy_version';
|
|
53
|
+
id: string;
|
|
54
|
+
policy_id: string;
|
|
55
|
+
policy: string;
|
|
56
|
+
version: string;
|
|
57
|
+
status: 'draft' | 'published' | 'retired';
|
|
58
|
+
content_markdown: string | null;
|
|
59
|
+
/** The sanitised HTML clients render. */
|
|
60
|
+
content_html: string;
|
|
61
|
+
content_url: string | null;
|
|
62
|
+
/** Hex SHA-256 of `content_html`. */
|
|
63
|
+
content_sha256: string;
|
|
64
|
+
summary_of_changes: string | null;
|
|
65
|
+
locale: string | null;
|
|
66
|
+
published_at: number | null;
|
|
67
|
+
effective_at: number | null;
|
|
68
|
+
retired_at: number | null;
|
|
69
|
+
created_at: number;
|
|
70
|
+
updated_at: number;
|
|
71
|
+
/** On list: how many users accepted this version. */
|
|
72
|
+
acceptance_count?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface PolicyAcceptance {
|
|
75
|
+
object: 'policy_acceptance';
|
|
76
|
+
id: string;
|
|
77
|
+
user_id: string;
|
|
78
|
+
policy: string;
|
|
79
|
+
version: string;
|
|
80
|
+
policy_version_id: string | null;
|
|
81
|
+
status: 'accepted' | 'withdrawn';
|
|
82
|
+
source: 'signup' | 'signin' | 'reaccept' | 'api' | 'import' | (string & {}) | null;
|
|
83
|
+
content_sha256: string | null;
|
|
84
|
+
display: PolicyDisplay | null;
|
|
85
|
+
scrolled_to_end: boolean | null;
|
|
86
|
+
view_ms: number | null;
|
|
87
|
+
locale: string | null;
|
|
88
|
+
ip: string | null;
|
|
89
|
+
user_agent: string | null;
|
|
90
|
+
accepted_at: number;
|
|
91
|
+
}
|
|
92
|
+
export interface PolicyStanding {
|
|
93
|
+
object: 'policy_standing';
|
|
94
|
+
policy: string;
|
|
95
|
+
policy_id: string;
|
|
96
|
+
title: string;
|
|
97
|
+
display: PolicyDisplay;
|
|
98
|
+
required: boolean;
|
|
99
|
+
applies_to: PolicyAppliesTo;
|
|
100
|
+
reaccept: PolicyReaccept;
|
|
101
|
+
current_version_id: string | null;
|
|
102
|
+
current_version: string | null;
|
|
103
|
+
content_sha256: string | null;
|
|
104
|
+
summary_of_changes: string | null;
|
|
105
|
+
accepted_version_id: string | null;
|
|
106
|
+
accepted_version: string | null;
|
|
107
|
+
accepted_at: number | null;
|
|
108
|
+
needs_reaccept: boolean;
|
|
109
|
+
/** Accepting is required before the user's next sign-in completes. */
|
|
110
|
+
blocking: boolean;
|
|
111
|
+
grace_ends_at: number | null;
|
|
112
|
+
}
|
|
113
|
+
export interface CreatePolicyBody {
|
|
114
|
+
/** Slug, unique per instance (e.g. `tos`, `privacy`). Becomes the consent record's `policy`. */
|
|
115
|
+
key: string;
|
|
116
|
+
title: string;
|
|
117
|
+
display?: PolicyDisplay;
|
|
118
|
+
required?: boolean;
|
|
119
|
+
applies_to?: PolicyAppliesTo;
|
|
120
|
+
reaccept?: PolicyReaccept;
|
|
121
|
+
/** Required with `reaccept: 'grace'` (1–365). */
|
|
122
|
+
grace_days?: number | null;
|
|
123
|
+
position?: number;
|
|
124
|
+
}
|
|
125
|
+
export type UpdatePolicyBody = Partial<Omit<CreatePolicyBody, 'key'>> & {
|
|
126
|
+
status?: 'active' | 'retired';
|
|
127
|
+
};
|
|
128
|
+
export interface CreatePolicyVersionBody {
|
|
129
|
+
/** A label such as `2026-10-24` or `1.2.0`, unique per policy. */
|
|
130
|
+
version: string;
|
|
131
|
+
/** Markdown (rendered and sanitised by Atlas) — or `content_html`. */
|
|
132
|
+
content_markdown?: string;
|
|
133
|
+
content_html?: string;
|
|
134
|
+
content_url?: string | null;
|
|
135
|
+
summary_of_changes?: string | null;
|
|
136
|
+
locale?: string | null;
|
|
137
|
+
/** Publish immediately instead of saving a draft. */
|
|
138
|
+
publish?: boolean;
|
|
139
|
+
/** With `publish`: when the gate starts asking for it (epoch ms or ISO; default now). */
|
|
140
|
+
effective_at?: number | string;
|
|
141
|
+
}
|
|
142
|
+
export type UpdatePolicyVersionBody = Partial<Omit<CreatePolicyVersionBody, 'publish' | 'effective_at'>>;
|
|
143
|
+
export interface ListPolicyAcceptancesParams {
|
|
144
|
+
/** A version id or label. */
|
|
145
|
+
version?: string;
|
|
146
|
+
/** `accepted` (default), `withdrawn` or `all`. */
|
|
147
|
+
status?: 'accepted' | 'withdrawn' | 'all';
|
|
148
|
+
limit?: number;
|
|
149
|
+
starting_after?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface PolicyAcceptancePage {
|
|
152
|
+
object: 'list';
|
|
153
|
+
data: PolicyAcceptance[];
|
|
154
|
+
has_more: boolean;
|
|
155
|
+
next_cursor: string | null;
|
|
156
|
+
}
|
|
157
|
+
export interface PolicySettings {
|
|
158
|
+
object: 'policy_settings';
|
|
159
|
+
/** Put `pol` (accepted versions of required policies) on session tokens. */
|
|
160
|
+
session_claim: boolean;
|
|
161
|
+
}
|
|
162
|
+
export interface PolicySource {
|
|
163
|
+
object: 'policy_source';
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
endpoint_url: string | null;
|
|
166
|
+
signing_secret_set: boolean;
|
|
167
|
+
sync: 'webhook' | 'poll';
|
|
168
|
+
poll_interval_minutes: number;
|
|
169
|
+
/** Where your source sends `policy.published` / `policy.retired` events. */
|
|
170
|
+
webhook_url: string | null;
|
|
171
|
+
protocol_version: string;
|
|
172
|
+
last_synced_at: number | null;
|
|
173
|
+
last_sync_ok: boolean | null;
|
|
174
|
+
last_sync_error: string | null;
|
|
175
|
+
next_poll_at: number | null;
|
|
176
|
+
}
|
|
177
|
+
export interface UpdatePolicySourceBody {
|
|
178
|
+
enabled?: boolean;
|
|
179
|
+
/** Base URL; Atlas calls `GET {endpoint_url}/policies`. */
|
|
180
|
+
endpoint_url?: string | null;
|
|
181
|
+
/** Write-only (a `whsec_` secret works). */
|
|
182
|
+
signing_secret?: string | null;
|
|
183
|
+
sync?: 'webhook' | 'poll';
|
|
184
|
+
/** Poll mode: 5–1440. */
|
|
185
|
+
poll_interval_minutes?: number;
|
|
186
|
+
}
|
|
187
|
+
export interface PolicySourceDelivery {
|
|
188
|
+
object: 'policy_source_delivery';
|
|
189
|
+
id: string;
|
|
190
|
+
direction: 'outbound' | 'inbound';
|
|
191
|
+
kind: 'fetch' | 'test' | 'poll' | 'webhook';
|
|
192
|
+
status: 'ok' | 'failed' | 'rejected';
|
|
193
|
+
http_status: number | null;
|
|
194
|
+
error: string | null;
|
|
195
|
+
event_type: string | null;
|
|
196
|
+
policy: string | null;
|
|
197
|
+
version: string | null;
|
|
198
|
+
url: string | null;
|
|
199
|
+
changes: Record<string, unknown> | null;
|
|
200
|
+
latency_ms: number | null;
|
|
201
|
+
created_at: number;
|
|
202
|
+
}
|
|
203
|
+
export interface PolicySourceTest {
|
|
204
|
+
object: 'policy_source_test';
|
|
205
|
+
ok: boolean;
|
|
206
|
+
http_status: number | null;
|
|
207
|
+
latency_ms: number | null;
|
|
208
|
+
error: string | null;
|
|
209
|
+
warnings: string[];
|
|
210
|
+
policies: Array<{
|
|
211
|
+
key: string;
|
|
212
|
+
title: string;
|
|
213
|
+
versions: string[];
|
|
214
|
+
}>;
|
|
215
|
+
delivery: PolicySourceDelivery;
|
|
216
|
+
}
|
|
217
|
+
export interface PolicySourceSync {
|
|
218
|
+
object: 'policy_source_sync';
|
|
219
|
+
ok: boolean;
|
|
220
|
+
error: string | null;
|
|
221
|
+
warnings: string[];
|
|
222
|
+
changes: {
|
|
223
|
+
created: string[];
|
|
224
|
+
updated: string[];
|
|
225
|
+
published: string[];
|
|
226
|
+
unchanged: string[];
|
|
227
|
+
rejected: string[];
|
|
228
|
+
retired: string[];
|
|
229
|
+
} | null;
|
|
230
|
+
delivery: PolicySourceDelivery;
|
|
231
|
+
}
|
|
232
|
+
export declare function policiesResource(request: RequestFn): {
|
|
233
|
+
/** `GET /v1/policies` — active policies (`include_retired` for all). */
|
|
234
|
+
list(params?: {
|
|
235
|
+
include_retired?: boolean;
|
|
236
|
+
}): Promise<{
|
|
237
|
+
object: "list";
|
|
238
|
+
data: Policy[];
|
|
239
|
+
}>;
|
|
240
|
+
/** `POST /v1/policies`. */
|
|
241
|
+
create(body: CreatePolicyBody): Promise<Policy>;
|
|
242
|
+
/** `GET /v1/policies/:id` — by id or key. */
|
|
243
|
+
get(idOrKey: string): Promise<Policy>;
|
|
244
|
+
/** `PATCH /v1/policies/:id`. */
|
|
245
|
+
update(idOrKey: string, body: UpdatePolicyBody): Promise<Policy>;
|
|
246
|
+
/** `DELETE /v1/policies/:id` — deletes a never-published policy, retires one with history. */
|
|
247
|
+
delete(idOrKey: string): Promise<{
|
|
248
|
+
object: "policy";
|
|
249
|
+
id: string;
|
|
250
|
+
key: string;
|
|
251
|
+
deleted: boolean;
|
|
252
|
+
retired: boolean;
|
|
253
|
+
policy?: Policy;
|
|
254
|
+
}>;
|
|
255
|
+
versions: {
|
|
256
|
+
list(idOrKey: string): Promise<{
|
|
257
|
+
object: "list";
|
|
258
|
+
data: PolicyVersion[];
|
|
259
|
+
}>;
|
|
260
|
+
/** `POST /v1/policies/:id/versions` — a draft (or published at once with `publish: true`). */
|
|
261
|
+
create(idOrKey: string, body: CreatePolicyVersionBody): Promise<PolicyVersion>;
|
|
262
|
+
get(idOrKey: string, versionIdOrLabel: string): Promise<PolicyVersion>;
|
|
263
|
+
/** Drafts only. */
|
|
264
|
+
update(idOrKey: string, versionIdOrLabel: string, body: UpdatePolicyVersionBody): Promise<PolicyVersion>;
|
|
265
|
+
/** Drafts only. */
|
|
266
|
+
delete(idOrKey: string, versionIdOrLabel: string): Promise<{
|
|
267
|
+
object: "policy_version";
|
|
268
|
+
id: string;
|
|
269
|
+
deleted: true;
|
|
270
|
+
}>;
|
|
271
|
+
/** `POST …/publish` — `effective_at` (epoch ms or ISO; default now) is when the gate starts asking for it. */
|
|
272
|
+
publish(idOrKey: string, versionIdOrLabel: string, body?: {
|
|
273
|
+
effective_at?: number | string;
|
|
274
|
+
}): Promise<PolicyVersion>;
|
|
275
|
+
retire(idOrKey: string, versionIdOrLabel: string): Promise<PolicyVersion>;
|
|
276
|
+
};
|
|
277
|
+
/** `GET /v1/policies/:id/acceptances` — who accepted, newest first. */
|
|
278
|
+
listAcceptances(idOrKey: string, params?: ListPolicyAcceptancesParams): Promise<PolicyAcceptancePage>;
|
|
279
|
+
/** The same as CSV (`format=csv`, up to 100,000 rows). */
|
|
280
|
+
exportAcceptancesCsv(idOrKey: string, params?: Omit<ListPolicyAcceptancesParams, "limit" | "starting_after">): Promise<string>;
|
|
281
|
+
/** `GET /v1/users/:id/policies` — a user's standing on every policy. */
|
|
282
|
+
forUser(userId: string): Promise<{
|
|
283
|
+
object: "list";
|
|
284
|
+
user_id: string;
|
|
285
|
+
data: PolicyStanding[];
|
|
286
|
+
needs_acceptance: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
settings: {
|
|
289
|
+
get(): Promise<PolicySettings>;
|
|
290
|
+
update(body: {
|
|
291
|
+
session_claim?: boolean;
|
|
292
|
+
}): Promise<PolicySettings>;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
export declare function policySourceResource(request: RequestFn): {
|
|
296
|
+
get(): Promise<PolicySource>;
|
|
297
|
+
/** `PUT /v1/instance/policy_source` — partial; `signing_secret` is write-only. */
|
|
298
|
+
update(body: UpdatePolicySourceBody): Promise<PolicySource>;
|
|
299
|
+
/** Disconnect the source (its policies and history stay). */
|
|
300
|
+
delete(): Promise<PolicySource>;
|
|
301
|
+
/** A signed fetch of the feed, validated but not stored. */
|
|
302
|
+
test(): Promise<PolicySourceTest>;
|
|
303
|
+
/** Fetch and store now. */
|
|
304
|
+
sync(): Promise<PolicySourceSync>;
|
|
305
|
+
listDeliveries(params?: {
|
|
306
|
+
limit?: number;
|
|
307
|
+
starting_after?: string;
|
|
308
|
+
kind?: string;
|
|
309
|
+
status?: string;
|
|
310
|
+
}): Promise<{
|
|
311
|
+
object: "list";
|
|
312
|
+
data: PolicySourceDelivery[];
|
|
313
|
+
has_more: boolean;
|
|
314
|
+
next_cursor: string | null;
|
|
315
|
+
}>;
|
|
316
|
+
};
|