@onkernel/sdk 0.79.0 → 0.81.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 +19 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/lib/audit-log-download.d.mts +28 -0
- package/lib/audit-log-download.d.mts.map +1 -0
- package/lib/audit-log-download.d.ts +28 -0
- package/lib/audit-log-download.d.ts.map +1 -0
- package/lib/audit-log-download.js +176 -0
- package/lib/audit-log-download.js.map +1 -0
- package/lib/audit-log-download.mjs +171 -0
- package/lib/audit-log-download.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/audit-logs.d.mts +11 -1
- package/resources/audit-logs.d.mts.map +1 -1
- package/resources/audit-logs.d.ts +11 -1
- package/resources/audit-logs.d.ts.map +1 -1
- package/resources/audit-logs.js +11 -0
- package/resources/audit-logs.js.map +1 -1
- package/resources/audit-logs.mjs +11 -0
- package/resources/audit-logs.mjs.map +1 -1
- package/resources/auth/connections.d.mts +156 -2
- package/resources/auth/connections.d.mts.map +1 -1
- package/resources/auth/connections.d.ts +156 -2
- package/resources/auth/connections.d.ts.map +1 -1
- package/src/index.ts +9 -0
- package/src/lib/audit-log-download.ts +234 -0
- package/src/resources/audit-logs.ts +42 -0
- package/src/resources/auth/connections.ts +197 -2
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.81.0 (2026-07-21)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.80.0...v0.81.0](https://github.com/kernel/kernel-node-sdk/compare/v0.80.0...v0.81.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add complete audit log downloads ([6cb8e9e](https://github.com/kernel/kernel-node-sdk/commit/6cb8e9e38540b5e2954a6304b61b848fca70909e))
|
|
10
|
+
|
|
11
|
+
## 0.80.0 (2026-07-19)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.79.0...v0.80.0](https://github.com/kernel/kernel-node-sdk/compare/v0.79.0...v0.80.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Add example to ProxyCheckRequest.url so API reference sample shows it ([bd1c0ca](https://github.com/kernel/kernel-node-sdk/commit/bd1c0ca24864a06051c2deb0ef97d46a5d822caa))
|
|
18
|
+
* Expose browser sessions on auth timeline events ([9250344](https://github.com/kernel/kernel-node-sdk/commit/925034471eabbf215130abd829265d4c8e9a059a))
|
|
19
|
+
* **managed-auth:** add TS CUA worker contract (KERNEL-1456) ([0a5405f](https://github.com/kernel/kernel-node-sdk/commit/0a5405f257c7fd6138f1a25adba598b672f30b06))
|
|
20
|
+
* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([868a6e1](https://github.com/kernel/kernel-node-sdk/commit/868a6e1318fd09b9c54bab3f64c15d1682668c54))
|
|
21
|
+
|
|
3
22
|
## 0.79.0 (2026-07-15)
|
|
4
23
|
|
|
5
24
|
Full Changelog: [v0.78.1...v0.79.0](https://github.com/kernel/kernel-node-sdk/compare/v0.78.1...v0.79.0)
|
package/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ export { type Uploadable, toFile } from "./core/uploads.mjs";
|
|
|
3
3
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
4
4
|
export { Kernel, type ClientOptions } from "./client.mjs";
|
|
5
5
|
export { type BrowserFetchInit } from "./lib/browser-fetch.mjs";
|
|
6
|
+
export { AuditLogDownloadError, type AuditLogDownloadDestination, type AuditLogDownloadOptions, type AuditLogDownloadParams, type AuditLogDownloadProgress, type AuditLogDownloadResult, type AuditLogDownloadWriteResult, } from "./lib/audit-log-download.mjs";
|
|
6
7
|
export { BrowserRouteCache, type BrowserRoute } from "./lib/browser-routing.mjs";
|
|
7
8
|
export { PagePromise } from "./core/pagination.mjs";
|
|
8
9
|
export { KernelError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
package/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,qBAAiB;AAE7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,qBAAiB;AACtD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gCAA4B;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,kCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AAEtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,iCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,qBAAiB;AAE7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,qBAAiB;AACtD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gCAA4B;AAC5D,OAAO,EACL,qBAAqB,EACrB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,GACjC,qCAAiC;AAClC,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,kCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AAEtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,iCAA6B"}
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { type Uploadable, toFile } from "./core/uploads.js";
|
|
|
3
3
|
export { APIPromise } from "./core/api-promise.js";
|
|
4
4
|
export { Kernel, type ClientOptions } from "./client.js";
|
|
5
5
|
export { type BrowserFetchInit } from "./lib/browser-fetch.js";
|
|
6
|
+
export { AuditLogDownloadError, type AuditLogDownloadDestination, type AuditLogDownloadOptions, type AuditLogDownloadParams, type AuditLogDownloadProgress, type AuditLogDownloadResult, type AuditLogDownloadWriteResult, } from "./lib/audit-log-download.js";
|
|
6
7
|
export { BrowserRouteCache, type BrowserRoute } from "./lib/browser-routing.js";
|
|
7
8
|
export { PagePromise } from "./core/pagination.js";
|
|
8
9
|
export { KernelError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,oBAAiB;AAE7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,0BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,8BAA2B;AAChD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,oBAAiB;AACtD,OAAO,EAAE,KAAK,gBAAgB,EAAE,+BAA4B;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,iCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,6BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,wBAAqB;AAEtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,gCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,oBAAiB;AAE7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,0BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,8BAA2B;AAChD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,oBAAiB;AACtD,OAAO,EAAE,KAAK,gBAAgB,EAAE,+BAA4B;AAC5D,OAAO,EACL,qBAAqB,EACrB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,GACjC,oCAAiC;AAClC,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,iCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,6BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,wBAAqB;AAEtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,gCAA6B"}
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports = module.exports = function (...args) {
|
|
|
4
4
|
return new exports.default(...args)
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.appRegistry = exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.KernelError = exports.PagePromise = exports.BrowserRouteCache = exports.Kernel = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
7
|
+
exports.appRegistry = exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.KernelError = exports.PagePromise = exports.BrowserRouteCache = exports.AuditLogDownloadError = exports.Kernel = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
8
8
|
var client_1 = require("./client.js");
|
|
9
9
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.Kernel; } });
|
|
10
10
|
var uploads_1 = require("./core/uploads.js");
|
|
@@ -13,6 +13,8 @@ var api_promise_1 = require("./core/api-promise.js");
|
|
|
13
13
|
Object.defineProperty(exports, "APIPromise", { enumerable: true, get: function () { return api_promise_1.APIPromise; } });
|
|
14
14
|
var client_2 = require("./client.js");
|
|
15
15
|
Object.defineProperty(exports, "Kernel", { enumerable: true, get: function () { return client_2.Kernel; } });
|
|
16
|
+
var audit_log_download_1 = require("./lib/audit-log-download.js");
|
|
17
|
+
Object.defineProperty(exports, "AuditLogDownloadError", { enumerable: true, get: function () { return audit_log_download_1.AuditLogDownloadError; } });
|
|
16
18
|
var browser_routing_1 = require("./lib/browser-routing.js");
|
|
17
19
|
Object.defineProperty(exports, "BrowserRouteCache", { enumerable: true, get: function () { return browser_routing_1.BrowserRouteCache; } });
|
|
18
20
|
var pagination_1 = require("./core/pagination.js");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAA6C;AAApC,iGAAA,MAAM,OAAW;AAE1B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAsD;AAA7C,gGAAA,MAAM,OAAA;AAEf,4DAA6E;AAApE,oHAAA,iBAAiB,OAAA;AAC1B,mDAAgD;AAAvC,yGAAA,WAAW,OAAA;AACpB,yCAcsB;AAbpB,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AAG1B,yDAA4F;AAA1C,4GAAA,WAAW,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAA6C;AAApC,iGAAA,MAAM,OAAW;AAE1B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAsD;AAA7C,gGAAA,MAAM,OAAA;AAEf,kEAQkC;AAPhC,2HAAA,qBAAqB,OAAA;AAQvB,4DAA6E;AAApE,oHAAA,iBAAiB,OAAA;AAC1B,mDAAgD;AAAvC,yGAAA,WAAW,OAAA;AACpB,yCAcsB;AAbpB,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AAG1B,yDAA4F;AAA1C,4GAAA,WAAW,OAAA"}
|
package/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ export { Kernel as default } from "./client.mjs";
|
|
|
3
3
|
export { toFile } from "./core/uploads.mjs";
|
|
4
4
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
5
5
|
export { Kernel } from "./client.mjs";
|
|
6
|
+
export { AuditLogDownloadError, } from "./lib/audit-log-download.mjs";
|
|
6
7
|
export { BrowserRouteCache } from "./lib/browser-routing.mjs";
|
|
7
8
|
export { PagePromise } from "./core/pagination.mjs";
|
|
8
9
|
export { KernelError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,qBAAiB;AAE7C,OAAO,EAAmB,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,MAAM,EAAsB,qBAAiB;AAEtD,OAAO,EAAE,iBAAiB,EAAqB,kCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AAEtB,OAAO,EAA2C,WAAW,EAAE,iCAA6B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,qBAAiB;AAE7C,OAAO,EAAmB,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,MAAM,EAAsB,qBAAiB;AAEtD,OAAO,EACL,qBAAqB,GAOtB,qCAAiC;AAClC,OAAO,EAAE,iBAAiB,EAAqB,kCAA8B;AAC7E,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AAEtB,OAAO,EAA2C,WAAW,EAAE,iCAA6B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KernelError } from "../core/error.mjs";
|
|
2
|
+
import type { RequestOptions } from "../internal/request-options.mjs";
|
|
3
|
+
import type { AuditLogExportChunkParams } from "../resources/audit-logs.mjs";
|
|
4
|
+
export declare class AuditLogDownloadError extends KernelError {
|
|
5
|
+
}
|
|
6
|
+
export type AuditLogDownloadParams = Omit<AuditLogExportChunkParams, 'cursor' | 'format'>;
|
|
7
|
+
export interface AuditLogDownloadResult {
|
|
8
|
+
bytesWritten: number;
|
|
9
|
+
chunks: number;
|
|
10
|
+
rows: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AuditLogDownloadProgress extends AuditLogDownloadResult {
|
|
13
|
+
chunkRows: number;
|
|
14
|
+
}
|
|
15
|
+
export type AuditLogDownloadWriteResult = void | number | {
|
|
16
|
+
bytesWritten: number;
|
|
17
|
+
};
|
|
18
|
+
export interface AuditLogDownloadDestination {
|
|
19
|
+
write(chunk: Uint8Array): AuditLogDownloadWriteResult | Promise<AuditLogDownloadWriteResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface AuditLogDownloadOptions extends Omit<RequestOptions, 'method' | 'path' | 'query' | 'body' | 'stream' | '__binaryResponse' | '__streamClass'> {
|
|
22
|
+
onProgress?(progress: AuditLogDownloadProgress): void | Promise<void>;
|
|
23
|
+
maxTransferRetries?: number;
|
|
24
|
+
}
|
|
25
|
+
type FetchChunk = (query: AuditLogExportChunkParams, options?: RequestOptions) => Promise<Response>;
|
|
26
|
+
export declare function downloadAuditLogs(fetchChunk: FetchChunk, query: AuditLogDownloadParams, destination: AuditLogDownloadDestination, defaultTimeout: number, options?: AuditLogDownloadOptions): Promise<AuditLogDownloadResult>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=audit-log-download.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-download.d.mts","sourceRoot":"","sources":["../src/lib/audit-log-download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,W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C,sBAAsB,CAAC,CA0CjC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KernelError } from "../core/error.js";
|
|
2
|
+
import type { RequestOptions } from "../internal/request-options.js";
|
|
3
|
+
import type { AuditLogExportChunkParams } from "../resources/audit-logs.js";
|
|
4
|
+
export declare class AuditLogDownloadError extends KernelError {
|
|
5
|
+
}
|
|
6
|
+
export type AuditLogDownloadParams = Omit<AuditLogExportChunkParams, 'cursor' | 'format'>;
|
|
7
|
+
export interface AuditLogDownloadResult {
|
|
8
|
+
bytesWritten: number;
|
|
9
|
+
chunks: number;
|
|
10
|
+
rows: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AuditLogDownloadProgress extends AuditLogDownloadResult {
|
|
13
|
+
chunkRows: number;
|
|
14
|
+
}
|
|
15
|
+
export type AuditLogDownloadWriteResult = void | number | {
|
|
16
|
+
bytesWritten: number;
|
|
17
|
+
};
|
|
18
|
+
export interface AuditLogDownloadDestination {
|
|
19
|
+
write(chunk: Uint8Array): AuditLogDownloadWriteResult | Promise<AuditLogDownloadWriteResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface AuditLogDownloadOptions extends Omit<RequestOptions, 'method' | 'path' | 'query' | 'body' | 'stream' | '__binaryResponse' | '__streamClass'> {
|
|
22
|
+
onProgress?(progress: AuditLogDownloadProgress): void | Promise<void>;
|
|
23
|
+
maxTransferRetries?: number;
|
|
24
|
+
}
|
|
25
|
+
type FetchChunk = (query: AuditLogExportChunkParams, options?: RequestOptions) => Promise<Response>;
|
|
26
|
+
export declare function downloadAuditLogs(fetchChunk: FetchChunk, query: AuditLogDownloadParams, destination: AuditLogDownloadDestination, defaultTimeout: number, options?: AuditLogDownloadOptions): Promise<AuditLogDownloadResult>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=audit-log-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-download.d.ts","sourceRoot":"","sources":["../src/lib/audit-log-download.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B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CA0CjC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditLogDownloadError = void 0;
|
|
4
|
+
exports.downloadAuditLogs = downloadAuditLogs;
|
|
5
|
+
const error_1 = require("../core/error.js");
|
|
6
|
+
const DEFAULT_MAX_TRANSFER_RETRIES = 6;
|
|
7
|
+
const MAX_CHUNK_ROWS = 50000;
|
|
8
|
+
const MAX_RETRY_DELAY_MS = 8000;
|
|
9
|
+
class AuditLogDownloadError extends error_1.KernelError {
|
|
10
|
+
}
|
|
11
|
+
exports.AuditLogDownloadError = AuditLogDownloadError;
|
|
12
|
+
async function downloadAuditLogs(fetchChunk, query, destination, defaultTimeout, options = {}) {
|
|
13
|
+
if (!destination || typeof destination.write !== 'function') {
|
|
14
|
+
throw new TypeError('audit log download destination must provide write()');
|
|
15
|
+
}
|
|
16
|
+
const { onProgress, maxTransferRetries = DEFAULT_MAX_TRANSFER_RETRIES, ...requestOptions } = options;
|
|
17
|
+
if (!Number.isInteger(maxTransferRetries) || maxTransferRetries < 0) {
|
|
18
|
+
throw new TypeError('maxTransferRetries must be a non-negative integer');
|
|
19
|
+
}
|
|
20
|
+
const timeout = requestOptions.timeout ?? defaultTimeout;
|
|
21
|
+
let cursor;
|
|
22
|
+
const result = { bytesWritten: 0, chunks: 0, rows: 0 };
|
|
23
|
+
const seenCursors = new Set();
|
|
24
|
+
while (true) {
|
|
25
|
+
const chunk = await fetchVerifiedChunk(fetchChunk, cursor ? { ...query, cursor } : query, requestOptions, maxTransferRetries, timeout);
|
|
26
|
+
const { nextCursor, hasMore, rows } = parseChunkHeaders(chunk.headers, cursor);
|
|
27
|
+
if (hasMore && nextCursor) {
|
|
28
|
+
if (seenCursors.has(nextCursor)) {
|
|
29
|
+
throw new AuditLogDownloadError('response repeated X-Next-Cursor header');
|
|
30
|
+
}
|
|
31
|
+
seenCursors.add(nextCursor);
|
|
32
|
+
}
|
|
33
|
+
await writeChunk(destination, chunk.body);
|
|
34
|
+
cursor = nextCursor;
|
|
35
|
+
result.bytesWritten += chunk.body.byteLength;
|
|
36
|
+
result.chunks += 1;
|
|
37
|
+
result.rows += rows;
|
|
38
|
+
if (onProgress) {
|
|
39
|
+
await onProgress({ ...result, chunkRows: rows });
|
|
40
|
+
}
|
|
41
|
+
if (!hasMore) {
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function fetchVerifiedChunk(fetchChunk, query, options, maxTransferRetries, timeout) {
|
|
47
|
+
for (let retries = 0;; retries += 1) {
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const onAbort = () => controller.abort();
|
|
50
|
+
if (options.signal?.aborted) {
|
|
51
|
+
controller.abort();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
55
|
+
}
|
|
56
|
+
let response;
|
|
57
|
+
try {
|
|
58
|
+
response = await fetchChunk(query, { ...options, signal: controller.signal });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
let bodyTimedOut = false;
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
bodyTimedOut = true;
|
|
67
|
+
controller.abort();
|
|
68
|
+
}, timeout);
|
|
69
|
+
try {
|
|
70
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
if (options.signal?.aborted) {
|
|
73
|
+
throw new error_1.APIUserAbortError();
|
|
74
|
+
}
|
|
75
|
+
if (bodyTimedOut) {
|
|
76
|
+
throw new error_1.APIConnectionTimeoutError();
|
|
77
|
+
}
|
|
78
|
+
const expected = response.headers.get('x-content-sha256');
|
|
79
|
+
if (!expected) {
|
|
80
|
+
throw new AuditLogDownloadError('response missing X-Content-Sha256 header');
|
|
81
|
+
}
|
|
82
|
+
const actual = await sha256Hex(body);
|
|
83
|
+
if (options.signal?.aborted) {
|
|
84
|
+
throw new error_1.APIUserAbortError();
|
|
85
|
+
}
|
|
86
|
+
if (actual !== expected) {
|
|
87
|
+
throw new AuditLogDownloadError(`audit log chunk checksum mismatch (got ${actual}, want ${expected})`);
|
|
88
|
+
}
|
|
89
|
+
return { body, headers: response.headers };
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (options.signal?.aborted && !(error instanceof error_1.APIUserAbortError)) {
|
|
93
|
+
error = new error_1.APIUserAbortError();
|
|
94
|
+
}
|
|
95
|
+
else if (bodyTimedOut) {
|
|
96
|
+
error = new error_1.APIConnectionTimeoutError();
|
|
97
|
+
}
|
|
98
|
+
if (retries === maxTransferRetries || error instanceof error_1.APIUserAbortError) {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
await retryDelay(retries + 1, options.signal);
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function parseChunkHeaders(headers, currentCursor) {
|
|
110
|
+
const hasMoreValue = headers.get('x-has-more');
|
|
111
|
+
if (hasMoreValue !== 'true' && hasMoreValue !== 'false') {
|
|
112
|
+
throw new AuditLogDownloadError('response missing or invalid X-Has-More header');
|
|
113
|
+
}
|
|
114
|
+
const hasMore = hasMoreValue === 'true';
|
|
115
|
+
const rowCount = headers.get('x-row-count');
|
|
116
|
+
if (rowCount === null || !/^[0-9]+$/.test(rowCount)) {
|
|
117
|
+
throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
|
|
118
|
+
}
|
|
119
|
+
const rows = Number(rowCount);
|
|
120
|
+
if (!Number.isSafeInteger(rows) || rows > MAX_CHUNK_ROWS) {
|
|
121
|
+
throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
|
|
122
|
+
}
|
|
123
|
+
const nextCursor = headers.get('x-next-cursor') || undefined;
|
|
124
|
+
if (hasMore && (!nextCursor || nextCursor === currentCursor)) {
|
|
125
|
+
throw new AuditLogDownloadError('response has invalid X-Next-Cursor header');
|
|
126
|
+
}
|
|
127
|
+
if (!hasMore && nextCursor) {
|
|
128
|
+
throw new AuditLogDownloadError('response returned a cursor after the final chunk');
|
|
129
|
+
}
|
|
130
|
+
return { rows, nextCursor, hasMore };
|
|
131
|
+
}
|
|
132
|
+
async function sha256Hex(body) {
|
|
133
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', body);
|
|
134
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
135
|
+
}
|
|
136
|
+
async function retryDelay(attempt, signal) {
|
|
137
|
+
const delay = Math.min(1000 * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
138
|
+
await new Promise((resolve, reject) => {
|
|
139
|
+
if (signal?.aborted) {
|
|
140
|
+
reject(new error_1.APIUserAbortError());
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const onAbort = () => {
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
reject(new error_1.APIUserAbortError());
|
|
146
|
+
};
|
|
147
|
+
const timer = setTimeout(() => {
|
|
148
|
+
signal?.removeEventListener('abort', onAbort);
|
|
149
|
+
resolve();
|
|
150
|
+
}, delay);
|
|
151
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async function writeChunk(destination, body) {
|
|
155
|
+
let offset = 0;
|
|
156
|
+
while (offset < body.byteLength) {
|
|
157
|
+
const result = await destination.write(offset === 0 ? body : body.subarray(offset));
|
|
158
|
+
if (typeof result === 'number') {
|
|
159
|
+
offset += validateWriteCount(result, body.byteLength - offset);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (result && typeof result === 'object' && 'bytesWritten' in result) {
|
|
163
|
+
const bytesWritten = result.bytesWritten;
|
|
164
|
+
offset += validateWriteCount(bytesWritten, body.byteLength - offset);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function validateWriteCount(value, remaining) {
|
|
171
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > remaining) {
|
|
172
|
+
throw new AuditLogDownloadError('audit log download destination performed a short write');
|
|
173
|
+
}
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=audit-log-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-download.js","sourceRoot":"","sources":["../src/lib/audit-log-download.ts"],"names":[],"mappings":";;;AAuCA,8CAgDC;AAvFD,4CAA0F;AAI1F,MAAM,4BAA4B,GAAG,CAAC,CAAC;AACvC,MAAM,cAAc,GAAG,KAAM,CAAC;AAC9B,MAAM,kBAAkB,GAAG,IAAK,CAAC;AAEjC,MAAa,qBAAsB,SAAQ,mBAAW;CAAG;AAAzD,sDAAyD;AA+BlD,KAAK,UAAU,iBAAiB,CACrC,UAAsB,EACtB,KAA6B,EAC7B,WAAwC,EACxC,cAAsB,EACtB,UAAmC,EAAE;IAErC,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC5D,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,4BAA4B,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IACrG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,GAAG,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC3E,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;AAED,KAAK,UAAU,UAAU,CAAC,WAAwC,EAAE,IAAgB;IAClF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACpF,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;YAC/D,SAAS;QACX,CAAC;QACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,cAAc,IAAI,MAAM,EAAE,CAAC;YACrE,MAAM,YAAY,GAAI,MAAmC,CAAC,YAAY,CAAC;YACvE,MAAM,IAAI,kBAAkB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;YACrE,SAAS;QACX,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;IAC1D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,qBAAqB,CAAC,wDAAwD,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { APIConnectionTimeoutError, APIUserAbortError, KernelError } from "../core/error.mjs";
|
|
2
|
+
const DEFAULT_MAX_TRANSFER_RETRIES = 6;
|
|
3
|
+
const MAX_CHUNK_ROWS = 50000;
|
|
4
|
+
const MAX_RETRY_DELAY_MS = 8000;
|
|
5
|
+
export class AuditLogDownloadError extends KernelError {
|
|
6
|
+
}
|
|
7
|
+
export async function downloadAuditLogs(fetchChunk, query, destination, defaultTimeout, options = {}) {
|
|
8
|
+
if (!destination || typeof destination.write !== 'function') {
|
|
9
|
+
throw new TypeError('audit log download destination must provide write()');
|
|
10
|
+
}
|
|
11
|
+
const { onProgress, maxTransferRetries = DEFAULT_MAX_TRANSFER_RETRIES, ...requestOptions } = options;
|
|
12
|
+
if (!Number.isInteger(maxTransferRetries) || maxTransferRetries < 0) {
|
|
13
|
+
throw new TypeError('maxTransferRetries must be a non-negative integer');
|
|
14
|
+
}
|
|
15
|
+
const timeout = requestOptions.timeout ?? defaultTimeout;
|
|
16
|
+
let cursor;
|
|
17
|
+
const result = { bytesWritten: 0, chunks: 0, rows: 0 };
|
|
18
|
+
const seenCursors = new Set();
|
|
19
|
+
while (true) {
|
|
20
|
+
const chunk = await fetchVerifiedChunk(fetchChunk, cursor ? { ...query, cursor } : query, requestOptions, maxTransferRetries, timeout);
|
|
21
|
+
const { nextCursor, hasMore, rows } = parseChunkHeaders(chunk.headers, cursor);
|
|
22
|
+
if (hasMore && nextCursor) {
|
|
23
|
+
if (seenCursors.has(nextCursor)) {
|
|
24
|
+
throw new AuditLogDownloadError('response repeated X-Next-Cursor header');
|
|
25
|
+
}
|
|
26
|
+
seenCursors.add(nextCursor);
|
|
27
|
+
}
|
|
28
|
+
await writeChunk(destination, chunk.body);
|
|
29
|
+
cursor = nextCursor;
|
|
30
|
+
result.bytesWritten += chunk.body.byteLength;
|
|
31
|
+
result.chunks += 1;
|
|
32
|
+
result.rows += rows;
|
|
33
|
+
if (onProgress) {
|
|
34
|
+
await onProgress({ ...result, chunkRows: rows });
|
|
35
|
+
}
|
|
36
|
+
if (!hasMore) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function fetchVerifiedChunk(fetchChunk, query, options, maxTransferRetries, timeout) {
|
|
42
|
+
for (let retries = 0;; retries += 1) {
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
const onAbort = () => controller.abort();
|
|
45
|
+
if (options.signal?.aborted) {
|
|
46
|
+
controller.abort();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
50
|
+
}
|
|
51
|
+
let response;
|
|
52
|
+
try {
|
|
53
|
+
response = await fetchChunk(query, { ...options, signal: controller.signal });
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
let bodyTimedOut = false;
|
|
60
|
+
const timer = setTimeout(() => {
|
|
61
|
+
bodyTimedOut = true;
|
|
62
|
+
controller.abort();
|
|
63
|
+
}, timeout);
|
|
64
|
+
try {
|
|
65
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
if (options.signal?.aborted) {
|
|
68
|
+
throw new APIUserAbortError();
|
|
69
|
+
}
|
|
70
|
+
if (bodyTimedOut) {
|
|
71
|
+
throw new APIConnectionTimeoutError();
|
|
72
|
+
}
|
|
73
|
+
const expected = response.headers.get('x-content-sha256');
|
|
74
|
+
if (!expected) {
|
|
75
|
+
throw new AuditLogDownloadError('response missing X-Content-Sha256 header');
|
|
76
|
+
}
|
|
77
|
+
const actual = await sha256Hex(body);
|
|
78
|
+
if (options.signal?.aborted) {
|
|
79
|
+
throw new APIUserAbortError();
|
|
80
|
+
}
|
|
81
|
+
if (actual !== expected) {
|
|
82
|
+
throw new AuditLogDownloadError(`audit log chunk checksum mismatch (got ${actual}, want ${expected})`);
|
|
83
|
+
}
|
|
84
|
+
return { body, headers: response.headers };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (options.signal?.aborted && !(error instanceof APIUserAbortError)) {
|
|
88
|
+
error = new APIUserAbortError();
|
|
89
|
+
}
|
|
90
|
+
else if (bodyTimedOut) {
|
|
91
|
+
error = new APIConnectionTimeoutError();
|
|
92
|
+
}
|
|
93
|
+
if (retries === maxTransferRetries || error instanceof APIUserAbortError) {
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
await retryDelay(retries + 1, options.signal);
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function parseChunkHeaders(headers, currentCursor) {
|
|
105
|
+
const hasMoreValue = headers.get('x-has-more');
|
|
106
|
+
if (hasMoreValue !== 'true' && hasMoreValue !== 'false') {
|
|
107
|
+
throw new AuditLogDownloadError('response missing or invalid X-Has-More header');
|
|
108
|
+
}
|
|
109
|
+
const hasMore = hasMoreValue === 'true';
|
|
110
|
+
const rowCount = headers.get('x-row-count');
|
|
111
|
+
if (rowCount === null || !/^[0-9]+$/.test(rowCount)) {
|
|
112
|
+
throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
|
|
113
|
+
}
|
|
114
|
+
const rows = Number(rowCount);
|
|
115
|
+
if (!Number.isSafeInteger(rows) || rows > MAX_CHUNK_ROWS) {
|
|
116
|
+
throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
|
|
117
|
+
}
|
|
118
|
+
const nextCursor = headers.get('x-next-cursor') || undefined;
|
|
119
|
+
if (hasMore && (!nextCursor || nextCursor === currentCursor)) {
|
|
120
|
+
throw new AuditLogDownloadError('response has invalid X-Next-Cursor header');
|
|
121
|
+
}
|
|
122
|
+
if (!hasMore && nextCursor) {
|
|
123
|
+
throw new AuditLogDownloadError('response returned a cursor after the final chunk');
|
|
124
|
+
}
|
|
125
|
+
return { rows, nextCursor, hasMore };
|
|
126
|
+
}
|
|
127
|
+
async function sha256Hex(body) {
|
|
128
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', body);
|
|
129
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
130
|
+
}
|
|
131
|
+
async function retryDelay(attempt, signal) {
|
|
132
|
+
const delay = Math.min(1000 * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
133
|
+
await new Promise((resolve, reject) => {
|
|
134
|
+
if (signal?.aborted) {
|
|
135
|
+
reject(new APIUserAbortError());
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const onAbort = () => {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
reject(new APIUserAbortError());
|
|
141
|
+
};
|
|
142
|
+
const timer = setTimeout(() => {
|
|
143
|
+
signal?.removeEventListener('abort', onAbort);
|
|
144
|
+
resolve();
|
|
145
|
+
}, delay);
|
|
146
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async function writeChunk(destination, body) {
|
|
150
|
+
let offset = 0;
|
|
151
|
+
while (offset < body.byteLength) {
|
|
152
|
+
const result = await destination.write(offset === 0 ? body : body.subarray(offset));
|
|
153
|
+
if (typeof result === 'number') {
|
|
154
|
+
offset += validateWriteCount(result, body.byteLength - offset);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (result && typeof result === 'object' && 'bytesWritten' in result) {
|
|
158
|
+
const bytesWritten = result.bytesWritten;
|
|
159
|
+
offset += validateWriteCount(bytesWritten, body.byteLength - offset);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function validateWriteCount(value, remaining) {
|
|
166
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > remaining) {
|
|
167
|
+
throw new AuditLogDownloadError('audit log download destination performed a short write');
|
|
168
|
+
}
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=audit-log-download.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log-download.mjs","sour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S;QACX,CAAC;QACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,cAAc,IAAI,MAAM,EAAE,CAAC;YACrE,MAAM,YAAY,GAAI,MAAmC,CAAC,YAAY,CAAC;YACvE,MAAM,IAAI,kBAAkB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;YACrE,SAAS;QACX,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;IAC1D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,qBAAqB,CAAC,wDAAwD,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,6 +2,8 @@ import { APIResource } from "../core/resource.mjs";
|
|
|
2
2
|
import { APIPromise } from "../core/api-promise.mjs";
|
|
3
3
|
import { PagePromise, PageTokenPagination, type PageTokenPaginationParams } from "../core/pagination.mjs";
|
|
4
4
|
import { RequestOptions } from "../internal/request-options.mjs";
|
|
5
|
+
import { type AuditLogDownloadDestination, type AuditLogDownloadOptions, type AuditLogDownloadParams, type AuditLogDownloadProgress, type AuditLogDownloadResult } from "../lib/audit-log-download.mjs";
|
|
6
|
+
export type { AuditLogDownloadDestination, AuditLogDownloadOptions, AuditLogDownloadParams, AuditLogDownloadProgress, AuditLogDownloadResult, } from "../lib/audit-log-download.mjs";
|
|
5
7
|
/**
|
|
6
8
|
* Read audit log records for the authenticated organization.
|
|
7
9
|
*/
|
|
@@ -17,6 +19,14 @@ export declare class AuditLogs extends APIResource {
|
|
|
17
19
|
* /audit-logs.
|
|
18
20
|
*/
|
|
19
21
|
exportChunk(query: AuditLogExportChunkParams, options?: RequestOptions): APIPromise<Response>;
|
|
22
|
+
/**
|
|
23
|
+
* Download a complete gzip-compressed JSON Lines audit log export to a writable
|
|
24
|
+
* destination. The SDK verifies every chunk and retries transient transfer
|
|
25
|
+
* failures. It does not close the destination. If the download fails, the
|
|
26
|
+
* destination may contain a partial export; use a temporary file and atomic
|
|
27
|
+
* rename when the completed export must be published atomically.
|
|
28
|
+
*/
|
|
29
|
+
download(query: AuditLogDownloadParams, destination: AuditLogDownloadDestination, options?: AuditLogDownloadOptions): Promise<AuditLogDownloadResult>;
|
|
20
30
|
}
|
|
21
31
|
export type AuditLogEntriesPageTokenPagination = PageTokenPagination<AuditLogEntry>;
|
|
22
32
|
export interface AuditLogEntry {
|
|
@@ -150,6 +160,6 @@ export interface AuditLogExportChunkParams {
|
|
|
150
160
|
service?: string;
|
|
151
161
|
}
|
|
152
162
|
export declare namespace AuditLogs {
|
|
153
|
-
export { type AuditLogEntry as AuditLogEntry, type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination, type AuditLogListParams as AuditLogListParams, type AuditLogExportChunkParams as AuditLogExportChunkParams, };
|
|
163
|
+
export { type AuditLogEntry as AuditLogEntry, type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination, type AuditLogListParams as AuditLogListParams, type AuditLogExportChunkParams as AuditLogExportChunkParams, type AuditLogDownloadDestination as AuditLogDownloadDestination, type AuditLogDownloadOptions as AuditLogDownloadOptions, type AuditLogDownloadParams as AuditLogDownloadParams, type AuditLogDownloadProgress as AuditLogDownloadProgress, type AuditLogDownloadResult as AuditLogDownloadResult, };
|
|
154
164
|
}
|
|
155
165
|
//# sourceMappingURL=audit-logs.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-logs.d.mts","sourceRoot":"","sources":["../src/resources/audit-logs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,KAAK,yB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AAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,OAAO,EACL,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
|
@@ -2,6 +2,8 @@ import { APIResource } from "../core/resource.js";
|
|
|
2
2
|
import { APIPromise } from "../core/api-promise.js";
|
|
3
3
|
import { PagePromise, PageTokenPagination, type PageTokenPaginationParams } from "../core/pagination.js";
|
|
4
4
|
import { RequestOptions } from "../internal/request-options.js";
|
|
5
|
+
import { type AuditLogDownloadDestination, type AuditLogDownloadOptions, type AuditLogDownloadParams, type AuditLogDownloadProgress, type AuditLogDownloadResult } from "../lib/audit-log-download.js";
|
|
6
|
+
export type { AuditLogDownloadDestination, AuditLogDownloadOptions, AuditLogDownloadParams, AuditLogDownloadProgress, AuditLogDownloadResult, } from "../lib/audit-log-download.js";
|
|
5
7
|
/**
|
|
6
8
|
* Read audit log records for the authenticated organization.
|
|
7
9
|
*/
|
|
@@ -17,6 +19,14 @@ export declare class AuditLogs extends APIResource {
|
|
|
17
19
|
* /audit-logs.
|
|
18
20
|
*/
|
|
19
21
|
exportChunk(query: AuditLogExportChunkParams, options?: RequestOptions): APIPromise<Response>;
|
|
22
|
+
/**
|
|
23
|
+
* Download a complete gzip-compressed JSON Lines audit log export to a writable
|
|
24
|
+
* destination. The SDK verifies every chunk and retries transient transfer
|
|
25
|
+
* failures. It does not close the destination. If the download fails, the
|
|
26
|
+
* destination may contain a partial export; use a temporary file and atomic
|
|
27
|
+
* rename when the completed export must be published atomically.
|
|
28
|
+
*/
|
|
29
|
+
download(query: AuditLogDownloadParams, destination: AuditLogDownloadDestination, options?: AuditLogDownloadOptions): Promise<AuditLogDownloadResult>;
|
|
20
30
|
}
|
|
21
31
|
export type AuditLogEntriesPageTokenPagination = PageTokenPagination<AuditLogEntry>;
|
|
22
32
|
export interface AuditLogEntry {
|
|
@@ -150,6 +160,6 @@ export interface AuditLogExportChunkParams {
|
|
|
150
160
|
service?: string;
|
|
151
161
|
}
|
|
152
162
|
export declare namespace AuditLogs {
|
|
153
|
-
export { type AuditLogEntry as AuditLogEntry, type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination, type AuditLogListParams as AuditLogListParams, type AuditLogExportChunkParams as AuditLogExportChunkParams, };
|
|
163
|
+
export { type AuditLogEntry as AuditLogEntry, type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination, type AuditLogListParams as AuditLogListParams, type AuditLogExportChunkParams as AuditLogExportChunkParams, type AuditLogDownloadDestination as AuditLogDownloadDestination, type AuditLogDownloadOptions as AuditLogDownloadOptions, type AuditLogDownloadParams as AuditLogDownloadParams, type AuditLogDownloadProgress as AuditLogDownloadProgress, type AuditLogDownloadResult as AuditLogDownloadResult, };
|
|
154
164
|
}
|
|
155
165
|
//# sourceMappingURL=audit-logs.d.ts.map
|