@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.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 +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactSecrets = redactSecrets;
|
|
4
|
+
exports.redactLogger = redactLogger;
|
|
5
|
+
exports.walkObject = walkObject;
|
|
6
|
+
const errors_js_1 = require("../errors/errors.js");
|
|
7
|
+
const collaborators_js_1 = require("../validation/collaborators.js");
|
|
8
|
+
const option_shape_js_1 = require("../validation/option-shape.js");
|
|
9
|
+
const primitives_js_1 = require("../validation/primitives.js");
|
|
10
|
+
const logger_js_1 = require("./logger.js");
|
|
11
|
+
const secret_patterns_js_1 = require("./secret-patterns.js");
|
|
12
|
+
const UNREDACTABLE = '[UNREDACTABLE]';
|
|
13
|
+
function assertRegExpArray(value, field) {
|
|
14
|
+
if (!Array.isArray(value) || value.some((entry) => !(0, secret_patterns_js_1.isRegExp)(entry))) {
|
|
15
|
+
throw (0, errors_js_1.validationError)(`${field} must be an array of RegExp`, field);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function assertKeyPatterns(value, field) {
|
|
19
|
+
(0, primitives_js_1.assertStringArray)(value, field);
|
|
20
|
+
if (value.some((entry) => (0, secret_patterns_js_1.normaliseKey)(entry) === '')) {
|
|
21
|
+
throw (0, errors_js_1.validationError)(`${field} must name a letter or digit in every entry`, field);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function redactSecrets(value, patterns = secret_patterns_js_1.DEFAULT_SECRET_KEY_PATTERNS, valuePatterns = secret_patterns_js_1.DEFAULT_SECRET_VALUE_PATTERNS) {
|
|
25
|
+
assertKeyPatterns(patterns, 'patterns');
|
|
26
|
+
assertRegExpArray(valuePatterns, 'valuePatterns');
|
|
27
|
+
const keyPatterns = patterns.map(secret_patterns_js_1.normaliseKey);
|
|
28
|
+
const walking = new WeakSet();
|
|
29
|
+
const done = new WeakMap();
|
|
30
|
+
const walk = (current) => {
|
|
31
|
+
if (typeof current === 'string')
|
|
32
|
+
return (0, secret_patterns_js_1.redactText)(current, valuePatterns);
|
|
33
|
+
if (current === null || typeof current !== 'object')
|
|
34
|
+
return current;
|
|
35
|
+
if (done.has(current))
|
|
36
|
+
return done.get(current);
|
|
37
|
+
if (walking.has(current))
|
|
38
|
+
return '[Circular]';
|
|
39
|
+
walking.add(current);
|
|
40
|
+
try {
|
|
41
|
+
const redacted = walkObject(current, { keyPatterns, valuePatterns, walk });
|
|
42
|
+
done.set(current, redacted);
|
|
43
|
+
return redacted;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
walking.delete(current);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
return walk(value);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return UNREDACTABLE;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function assertRedactionOptions(options) {
|
|
57
|
+
(0, option_shape_js_1.assertObjectShape)(options, 'options');
|
|
58
|
+
if (options.extraKeys !== undefined)
|
|
59
|
+
assertKeyPatterns(options.extraKeys, 'extraKeys');
|
|
60
|
+
if (options.extraValuePatterns !== undefined) {
|
|
61
|
+
assertRegExpArray(options.extraValuePatterns, 'extraValuePatterns');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function redactLogger(inner, options = {}) {
|
|
65
|
+
(0, collaborators_js_1.assertMembers)(inner, collaborators_js_1.LOGGER_MEMBERS, 'logger');
|
|
66
|
+
assertRedactionOptions(options);
|
|
67
|
+
const patterns = options.extraKeys
|
|
68
|
+
? [...secret_patterns_js_1.DEFAULT_SECRET_KEY_PATTERNS, ...options.extraKeys.map(secret_patterns_js_1.normaliseKey)]
|
|
69
|
+
: secret_patterns_js_1.DEFAULT_SECRET_KEY_PATTERNS;
|
|
70
|
+
const valuePatterns = options.extraValuePatterns
|
|
71
|
+
? [...secret_patterns_js_1.DEFAULT_SECRET_VALUE_PATTERNS, ...options.extraValuePatterns]
|
|
72
|
+
: secret_patterns_js_1.DEFAULT_SECRET_VALUE_PATTERNS;
|
|
73
|
+
const deliver = (method) => (message, ...args) => (0, logger_js_1.absorbLoggerFailure)(() => inner[method](message, ...args.map((arg) => redactSecrets(arg, patterns, valuePatterns))));
|
|
74
|
+
return {
|
|
75
|
+
info: deliver('info'),
|
|
76
|
+
warn: deliver('warn'),
|
|
77
|
+
error: deliver('error'),
|
|
78
|
+
debug: deliver('debug'),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function isSetValue(value) {
|
|
82
|
+
return Object.prototype.toString.call(value) === '[object Set]';
|
|
83
|
+
}
|
|
84
|
+
function isMapValue(value) {
|
|
85
|
+
return Object.prototype.toString.call(value) === '[object Map]';
|
|
86
|
+
}
|
|
87
|
+
function isErrorValue(value) {
|
|
88
|
+
const tag = Object.prototype.toString.call(value);
|
|
89
|
+
return tag === '[object Error]' || tag === '[object DOMException]';
|
|
90
|
+
}
|
|
91
|
+
function isOpaqueValue(value) {
|
|
92
|
+
const tag = Object.prototype.toString.call(value);
|
|
93
|
+
return tag === '[object Date]' || tag === '[object RegExp]';
|
|
94
|
+
}
|
|
95
|
+
function redactEntries(entries, keyPatterns, walk) {
|
|
96
|
+
const out = {};
|
|
97
|
+
for (const [key, value] of entries) {
|
|
98
|
+
Object.defineProperty(out, key, {
|
|
99
|
+
value: (0, secret_patterns_js_1.isSecretKey)(key, keyPatterns) ? secret_patterns_js_1.REDACTED : walk(value),
|
|
100
|
+
enumerable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
function redactMap(value, deps) {
|
|
108
|
+
const entries = [...value].map(([key, entry]) => {
|
|
109
|
+
const keyText = key;
|
|
110
|
+
return [String(keyText), entry];
|
|
111
|
+
});
|
|
112
|
+
return redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
113
|
+
}
|
|
114
|
+
function redactError(current, entries, deps) {
|
|
115
|
+
const text = (0, secret_patterns_js_1.redactErrorText)(current, deps.valuePatterns);
|
|
116
|
+
const aggregated = current.errors;
|
|
117
|
+
const bare = entries.length === 0 && current.cause === undefined && aggregated === undefined;
|
|
118
|
+
if (bare && !text.changed)
|
|
119
|
+
return current;
|
|
120
|
+
const out = redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
121
|
+
out.name = text.name;
|
|
122
|
+
out.message = text.message;
|
|
123
|
+
out.stack = text.stack;
|
|
124
|
+
if (current.cause !== undefined)
|
|
125
|
+
out.cause = deps.walk(current.cause);
|
|
126
|
+
if (Array.isArray(aggregated))
|
|
127
|
+
out.errors = deps.walk(aggregated);
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
function walkObject(current, deps) {
|
|
131
|
+
if (Array.isArray(current))
|
|
132
|
+
return current.map(deps.walk);
|
|
133
|
+
if (ArrayBuffer.isView(current))
|
|
134
|
+
return (0, secret_patterns_js_1.binaryLabel)(current);
|
|
135
|
+
if (isOpaqueValue(current))
|
|
136
|
+
return current;
|
|
137
|
+
if (isSetValue(current))
|
|
138
|
+
return [...current].map(deps.walk);
|
|
139
|
+
if (isMapValue(current))
|
|
140
|
+
return redactMap(current, deps);
|
|
141
|
+
const entries = Object.entries(current);
|
|
142
|
+
if (isErrorValue(current))
|
|
143
|
+
return redactError(current, entries, deps);
|
|
144
|
+
return redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
145
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides what a secret looks like.
|
|
3
|
+
*
|
|
4
|
+
* Which key names mark their value as a secret, which credential formats are
|
|
5
|
+
* recognised in free text, how a match is replaced while the field's name is
|
|
6
|
+
* kept, and how a caught value's message is redacted before another error
|
|
7
|
+
* quotes it are decided here. The redacting logger and every error that
|
|
8
|
+
* quotes its cause share these rules, so a new credential shape is one edit.
|
|
9
|
+
*/
|
|
10
|
+
/** Marker substituted for anything recognised as secret. */
|
|
11
|
+
export declare const REDACTED = "[REDACTED]";
|
|
12
|
+
/**
|
|
13
|
+
* Key names whose value is a secret. Each entry is a *normalised* name — see
|
|
14
|
+
* {@link normaliseKey} — and matches a key whose normalised form equals it or
|
|
15
|
+
* ends with it. Suffix matching is what catches `secretAccessKey`, `x-api-key`,
|
|
16
|
+
* `client_secret` and `AUTH_TOKEN`; requiring the pattern to be a suffix, not a
|
|
17
|
+
* substring, is what spares `maxTokens`, `total_tokens`, `tokenizer` and
|
|
18
|
+
* `secretary` — a bare substring match would redact all four for merely
|
|
19
|
+
* containing `token` or `secret`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_SECRET_KEY_PATTERNS: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Canonical form of a key name for matching.
|
|
24
|
+
*
|
|
25
|
+
* Accepts: any key name, in any case and with any separators.
|
|
26
|
+
*
|
|
27
|
+
* Returns: it lower-cased with every character that is not a letter or digit
|
|
28
|
+
* removed, so `api_key`, `x-api-key`, `ApiKey` and `API KEY` all become
|
|
29
|
+
* `apikey` and one pattern covers every spelling.
|
|
30
|
+
*
|
|
31
|
+
* Throws: nothing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function normaliseKey(key: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Secret shapes recognisable in free text, where key-name matching cannot
|
|
36
|
+
* reach: an error's `message`/`stack`, or any other string value. Deliberately
|
|
37
|
+
* high-confidence — each pattern describes a credential *format* rather than a
|
|
38
|
+
* word that merely sounds sensitive — so ordinary operational text survives
|
|
39
|
+
* redaction unchanged.
|
|
40
|
+
*
|
|
41
|
+
* The credential-pair pattern (last) tolerates a **closing quote after the
|
|
42
|
+
* keyword**, because that is what `JSON.stringify` produces
|
|
43
|
+
* (`{"password":"…"}`), and a backslash before that quote, because a JSON body
|
|
44
|
+
* quoted inside another JSON string — the shape a logged HTTP error carries —
|
|
45
|
+
* reads `{\"password\":\"…\"}`; requiring the separator to follow the bare
|
|
46
|
+
* keyword would match nothing in either, a silent, complete bypass on the
|
|
47
|
+
* most common shapes a downstream error arrives in. Its keywords include the
|
|
48
|
+
* hyphenated and spaced spellings of an API key (`x-api-key`, `api key`), a
|
|
49
|
+
* secret key and a client secret. Its group 1 is the keyword and separator,
|
|
50
|
+
* preserved by {@link redactText}.
|
|
51
|
+
*
|
|
52
|
+
* Its value side tries four shapes, and their order is load-bearing:
|
|
53
|
+
* 1. a fully-quoted span that consumes escapes, so `{"password":"a\"b"}` is
|
|
54
|
+
* redacted whole. Ending the span at the escaped quote stopped the
|
|
55
|
+
* redaction short and printed the rest of the secret verbatim.
|
|
56
|
+
* 1b. a span quoted with escaped quotes, `\"…\"`, the doubly encoded form of
|
|
57
|
+
* the first; it ends at the next quote, so a quote inside such a secret
|
|
58
|
+
* leaves its tail in the clear, and the sibling fields after it stay
|
|
59
|
+
* intact where the line-end fallback would take them too.
|
|
60
|
+
* 2. an unquoted JSON scalar — number, `true`, `false`, `null` — required to
|
|
61
|
+
* end at a real delimiter — `,`, `}`, `]` or end of input, optionally
|
|
62
|
+
* preceded by whitespace. Without this alternative,
|
|
63
|
+
* `{"apiKey":123,"region":"us-east-1"}` fell through to the fallback below,
|
|
64
|
+
* which then destroyed every sibling field after the secret. The lookahead
|
|
65
|
+
* is what stops the alternative truncating a value it does not fully
|
|
66
|
+
* describe, such as `token=123abc`, and leaking the tail it left behind.
|
|
67
|
+
* Whitespace alone does not end a scalar: treating a space as a delimiter
|
|
68
|
+
* made `api_key: 5 items` redact to `api_key: [REDACTED] items`, which
|
|
69
|
+
* reads as a partial redaction of a value the pattern never described.
|
|
70
|
+
* 3. the rest of the line, so a multi-word secret is redacted whole instead of
|
|
71
|
+
* up to its first space. Trying the two precise shapes first is what keeps
|
|
72
|
+
* this fallback from over-redacting sibling JSON fields.
|
|
73
|
+
*
|
|
74
|
+
* The JWT pattern (third) must scan in linear time, because these patterns
|
|
75
|
+
* run on text a caller controls — anything passed to `redactSecrets` or
|
|
76
|
+
* `redactLogger`, and an error's whole message before `redactedMessage` cuts
|
|
77
|
+
* it. A token's header segment is therefore not allowed to run across a `-`
|
|
78
|
+
* that opens another `eyJ`: written as `eyJ[A-Za-z0-9_-]+`, every `-eyJ` in a
|
|
79
|
+
* long run of token characters started a fresh scan to the end of the run, so
|
|
80
|
+
* 400 KB of `-eyJ` held the event loop for about 13 seconds. The only output
|
|
81
|
+
* this changes is a token whose header segment itself contains `-eyJ`: it is
|
|
82
|
+
* redacted from that point on, which can leave part of the header — never the
|
|
83
|
+
* payload or the signature — in the clear.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DEFAULT_SECRET_VALUE_PATTERNS: readonly RegExp[];
|
|
86
|
+
/**
|
|
87
|
+
* Whether a key name says its value is a secret.
|
|
88
|
+
*
|
|
89
|
+
* Accepts: `key` — any name. `patterns` — already-normalised names; an empty
|
|
90
|
+
* list matches nothing, which is how a caller turns key matching off.
|
|
91
|
+
*
|
|
92
|
+
* Returns: whether the normalised key equals or *ends with* a pattern. Suffix,
|
|
93
|
+
* not substring: that is what catches `secretAccessKey` and `x-api-key` while
|
|
94
|
+
* sparing `maxTokens`, `tokenizer` and `secretary`.
|
|
95
|
+
*
|
|
96
|
+
* Throws: nothing.
|
|
97
|
+
*/
|
|
98
|
+
export declare function isSecretKey(key: string, patterns: readonly string[]): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* An error's message with recognised credential shapes redacted.
|
|
101
|
+
*
|
|
102
|
+
* Accepts: any error — and, since this is what a `catch` block binds, any
|
|
103
|
+
* other value a `throw` can produce: `null`, `undefined`, a string, a number,
|
|
104
|
+
* a symbol, a plain object. Such a value is described through {@link toError}
|
|
105
|
+
* first and the description is what is redacted, so a secret it carries in its
|
|
106
|
+
* own text is still caught.
|
|
107
|
+
*
|
|
108
|
+
* Returns: the message, redacted with the default value patterns and then
|
|
109
|
+
* bounded by `truncateRelayedText` — for embedding in another error's
|
|
110
|
+
* message, since a wrapper that quotes its cause must not leak a `password=`
|
|
111
|
+
* or token the cause happened to carry. That text reaches `err.message`, which
|
|
112
|
+
* an application may print without a redacting logger.
|
|
113
|
+
*
|
|
114
|
+
* The bound is here rather than at the sites that quote the result, so no call
|
|
115
|
+
* site can get it wrong and no future one has to remember: a `RETRY_EXHAUSTED`
|
|
116
|
+
* report, a wrapped AWS failure, a compensation failure and both S3 transfer
|
|
117
|
+
* errors all inherit it from this one line. Redaction runs **before** the cut,
|
|
118
|
+
* because cutting first could split a credential shape past the pattern that
|
|
119
|
+
* would have caught it. Its own cap rather than the identifier cap: this is
|
|
120
|
+
* prose, and `MAX_RELAYED_MESSAGE_CHARS` records what that number is
|
|
121
|
+
* measured against. The value worth bounding is not the AWS SDK's own text but
|
|
122
|
+
* a **caller's** — a `serde` refusal or a `vectorBackend` rejection, whose
|
|
123
|
+
* length the caller controls entirely and which some paths quote once per row.
|
|
124
|
+
*
|
|
125
|
+
* Throws: **nothing**, for any value. Reading `.message` off a thrown
|
|
126
|
+
* primitive yielded `undefined` and the redaction then raised a `TypeError` —
|
|
127
|
+
* from inside the `catch` that was reporting the real failure, and from the
|
|
128
|
+
* one function a static guard funnels every one of this package's `catch`
|
|
129
|
+
* blocks into. Its promise has to hold for what a `catch` actually binds, or
|
|
130
|
+
* the guard concentrates every site into a function that is not safe.
|
|
131
|
+
*/
|
|
132
|
+
export declare function redactedMessage(error: Error): string;
|
|
133
|
+
/**
|
|
134
|
+
* Whether `value` is a regular expression.
|
|
135
|
+
*
|
|
136
|
+
* Accepts: anything, including a `RegExp` from another realm.
|
|
137
|
+
*
|
|
138
|
+
* Returns: whether its tag says so. By tag rather than `instanceof`, which is
|
|
139
|
+
* banned repo-wide because it answers "no" across a realm or a duplicated
|
|
140
|
+
* module.
|
|
141
|
+
*
|
|
142
|
+
* Throws: nothing.
|
|
143
|
+
*/
|
|
144
|
+
export declare function isRegExp(value: RegExp): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Replace every recognised secret shape inside `value` with {@link REDACTED},
|
|
147
|
+
* leaving the surrounding text intact so a redacted message stays readable.
|
|
148
|
+
*
|
|
149
|
+
* Accepts: `value` — any text. `patterns` — applied in order, each against the
|
|
150
|
+
* result of the last; an empty list returns the text unchanged. An entry that
|
|
151
|
+
* is not a `RegExp` is skipped: reading `.source` off one produced
|
|
152
|
+
* `new RegExp(undefined)` — that is `/(?:)/`, which matches the empty string
|
|
153
|
+
* and prefixed the marker to every value while catching no secret at all.
|
|
154
|
+
* Both public entry points — `redactSecrets` and {@link redactLogger} — now
|
|
155
|
+
* refuse such an entry where it is supplied, since a skipped pattern protects
|
|
156
|
+
* nothing while its caller believes it does; skipping remains the last-ditch
|
|
157
|
+
* guard for a list this package assembles internally.
|
|
158
|
+
*
|
|
159
|
+
* Returns: the text with every match replaced. A pattern may capture a leading
|
|
160
|
+
* group it wants **preserved**: only the rest of the match is replaced, which
|
|
161
|
+
* keeps `apiKey=[REDACTED]` saying which field was redacted instead of
|
|
162
|
+
* collapsing to a bare marker. A pattern with no group is replaced whole.
|
|
163
|
+
* `String.prototype.replace` passes the match *offset* — a number — as the
|
|
164
|
+
* second callback argument when the pattern has no group, hence the `typeof`
|
|
165
|
+
* test rather than an `undefined` check.
|
|
166
|
+
*
|
|
167
|
+
* Throws: nothing.
|
|
168
|
+
*
|
|
169
|
+
* Guarantees: every pattern is applied globally and from a fresh copy, so
|
|
170
|
+
* neither a missing `g` flag nor a leftover `lastIndex` can leave a later
|
|
171
|
+
* occurrence in the clear.
|
|
172
|
+
*/
|
|
173
|
+
export declare function redactText(value: string, patterns: readonly RegExp[]): string;
|
|
174
|
+
/**
|
|
175
|
+
* A short label for a binary view.
|
|
176
|
+
*
|
|
177
|
+
* Accepts: any `ArrayBufferView`.
|
|
178
|
+
*
|
|
179
|
+
* Returns: its type and byte length, e.g. `[Uint8Array(4096)]`. Recursing into
|
|
180
|
+
* one would explode it into a per-index numeric map, both unreadable and far
|
|
181
|
+
* larger than the value itself — and a payload is exactly the thing a log must
|
|
182
|
+
* not carry.
|
|
183
|
+
*
|
|
184
|
+
* Throws: nothing.
|
|
185
|
+
*/
|
|
186
|
+
export declare function binaryLabel(value: ArrayBufferView): string;
|
|
187
|
+
/** An Error's redacted non-enumerable text, plus whether redaction changed it. */
|
|
188
|
+
export interface RedactedErrorText {
|
|
189
|
+
name: string;
|
|
190
|
+
message: string;
|
|
191
|
+
stack: string | undefined;
|
|
192
|
+
changed: boolean;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Redact an Error's `name`, `message` and `stack`.
|
|
196
|
+
*
|
|
197
|
+
* Accepts: `error` — any error; a missing `stack` stays missing. Any other
|
|
198
|
+
* value a `throw` can produce is described through {@link toError} first, on
|
|
199
|
+
* the same reasoning as {@link redactedMessage}: the walk that calls this only
|
|
200
|
+
* reaches it for a value whose tag says `Error`, but the promise below is
|
|
201
|
+
* written in this function's own contract and is this function's to keep.
|
|
202
|
+
*
|
|
203
|
+
* Returns: the redacted text, plus `changed`: whether any secret was actually
|
|
204
|
+
* found. That flag is what decides between passing a bare Error through by
|
|
205
|
+
* reference — preserving its identity and stack trace — and rebuilding it so
|
|
206
|
+
* the secret cannot escape. It compares against the described error, so a
|
|
207
|
+
* value that had no text of its own is never reported as changed by the
|
|
208
|
+
* describing.
|
|
209
|
+
*
|
|
210
|
+
* None of the three is cut, and that is a decision rather than an omission.
|
|
211
|
+
* The rule that bounds unchecked text bounds what *this package* writes into
|
|
212
|
+
* its own `err.message` and its own log lines — `redactedMessage` is that
|
|
213
|
+
* funnel. This function is on the other side of the boundary: it rebuilds an
|
|
214
|
+
* Error the **consumer** handed to `redactSecrets`, or to the logger
|
|
215
|
+
* `redactLogger` wrapped, on the way to the consumer's own transport. Cutting
|
|
216
|
+
* there would change what their transport receives, for a value this package
|
|
217
|
+
* neither produced nor quotes, and the caller asked for redaction rather than
|
|
218
|
+
* for truncation. A consumer who wants a bound has their own transport to put
|
|
219
|
+
* one in.
|
|
220
|
+
*
|
|
221
|
+
* Throws: **nothing**, for any value: a `name` or `stack` that cannot be read
|
|
222
|
+
* — a getter of the consumer's own that throws, a `name` whose `toString`
|
|
223
|
+
* throws — is reported as `[unreadable name]` or `[unreadable stack]`, since
|
|
224
|
+
* the one thing this must not do on the way to the consumer's transport is
|
|
225
|
+
* fail.
|
|
226
|
+
*/
|
|
227
|
+
export declare function redactErrorText(error: Error, patterns: readonly RegExp[]): RedactedErrorText;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SECRET_VALUE_PATTERNS = exports.DEFAULT_SECRET_KEY_PATTERNS = exports.REDACTED = void 0;
|
|
4
|
+
exports.normaliseKey = normaliseKey;
|
|
5
|
+
exports.isSecretKey = isSecretKey;
|
|
6
|
+
exports.redactedMessage = redactedMessage;
|
|
7
|
+
exports.isRegExp = isRegExp;
|
|
8
|
+
exports.redactText = redactText;
|
|
9
|
+
exports.binaryLabel = binaryLabel;
|
|
10
|
+
exports.redactErrorText = redactErrorText;
|
|
11
|
+
const base_error_js_1 = require("../errors/base-error.js");
|
|
12
|
+
const truncate_js_1 = require("./truncate.js");
|
|
13
|
+
exports.REDACTED = '[REDACTED]';
|
|
14
|
+
exports.DEFAULT_SECRET_KEY_PATTERNS = [
|
|
15
|
+
'accesskey',
|
|
16
|
+
'accesskeyid',
|
|
17
|
+
'secret',
|
|
18
|
+
'sessiontoken',
|
|
19
|
+
'securitytoken',
|
|
20
|
+
'authorization',
|
|
21
|
+
'password',
|
|
22
|
+
'passwd',
|
|
23
|
+
'passphrase',
|
|
24
|
+
'apikey',
|
|
25
|
+
'bearer',
|
|
26
|
+
'token',
|
|
27
|
+
'privatekey',
|
|
28
|
+
'secretkey',
|
|
29
|
+
];
|
|
30
|
+
function normaliseKey(key) {
|
|
31
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
32
|
+
}
|
|
33
|
+
exports.DEFAULT_SECRET_VALUE_PATTERNS = [
|
|
34
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
35
|
+
/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi,
|
|
36
|
+
/\beyJ(?:[A-Za-z0-9_]|-(?!eyJ))+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,
|
|
37
|
+
/((?:aws_)?(?:secret_access_key|secretaccesskey|secret_?key|client_?secret|password|passwd|api[-_ ]?key|token)(?:\\?["'])?\s*[=:]\s*)(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\\"[^"\r\n]*\\"|\\'[^'\r\n]*\\'|(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)(?=\s*[,}\]]|\s*$)|[^\r\n]+)/gi,
|
|
38
|
+
];
|
|
39
|
+
function isSecretKey(key, patterns) {
|
|
40
|
+
const normalised = normaliseKey(key);
|
|
41
|
+
return patterns.some((pattern) => normalised === pattern || normalised.endsWith(pattern));
|
|
42
|
+
}
|
|
43
|
+
function redactedMessage(error) {
|
|
44
|
+
return (0, truncate_js_1.truncateRelayedText)(redactText((0, base_error_js_1.toError)(error).message, exports.DEFAULT_SECRET_VALUE_PATTERNS));
|
|
45
|
+
}
|
|
46
|
+
function globalCopyOf(pattern) {
|
|
47
|
+
const flags = pattern.flags.includes('g') ? pattern.flags : `${pattern.flags}g`;
|
|
48
|
+
return new RegExp(pattern.source, flags);
|
|
49
|
+
}
|
|
50
|
+
function isRegExp(value) {
|
|
51
|
+
return Object.prototype.toString.call(value) === '[object RegExp]';
|
|
52
|
+
}
|
|
53
|
+
function redactText(value, patterns) {
|
|
54
|
+
return patterns.reduce((text, pattern) => {
|
|
55
|
+
if (!isRegExp(pattern))
|
|
56
|
+
return text;
|
|
57
|
+
return text.replace(globalCopyOf(pattern), (_match, prefix) => typeof prefix === 'string' ? `${prefix}${exports.REDACTED}` : exports.REDACTED);
|
|
58
|
+
}, value);
|
|
59
|
+
}
|
|
60
|
+
function binaryLabel(value) {
|
|
61
|
+
return `[${value.constructor.name}(${value.byteLength})]`;
|
|
62
|
+
}
|
|
63
|
+
function redactErrorText(error, patterns) {
|
|
64
|
+
const described = (0, base_error_js_1.toError)(error);
|
|
65
|
+
const rawName = nameOf(described);
|
|
66
|
+
const rawStack = stackOf(described);
|
|
67
|
+
const name = redactText(rawName, patterns);
|
|
68
|
+
const message = redactText(described.message, patterns);
|
|
69
|
+
const stack = rawStack === undefined ? undefined : redactText(rawStack, patterns);
|
|
70
|
+
return {
|
|
71
|
+
name,
|
|
72
|
+
message,
|
|
73
|
+
stack,
|
|
74
|
+
changed: name !== rawName || message !== described.message || stack !== rawStack,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function nameOf(error) {
|
|
78
|
+
try {
|
|
79
|
+
return String(error.name);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return '[unreadable name]';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function stackOf(error) {
|
|
86
|
+
try {
|
|
87
|
+
const { stack } = error;
|
|
88
|
+
return stack === undefined ? undefined : String(stack);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return '[unreadable stack]';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how much of an unchecked string a line may quote.
|
|
3
|
+
*
|
|
4
|
+
* A log line or public error message that quotes a string this package did
|
|
5
|
+
* not length-check passes it through here. The caps for an identifier, for a
|
|
6
|
+
* relayed cause's prose and for a list of labels, and the mark that states a
|
|
7
|
+
* cut value's real length, are chosen here, so a call site says what kind of
|
|
8
|
+
* value it quotes and never how many characters it keeps.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Characters of an unchecked string one log line or one public error message
|
|
12
|
+
* carries, past which it is cut and marked with its real length.
|
|
13
|
+
*
|
|
14
|
+
* Most of what these lines quote is a row's sort key or an offloaded object's
|
|
15
|
+
* S3 key, so the service already caps each at 1024 bytes — the cost is not one
|
|
16
|
+
* long line but many. `list: skipped a row that is not a checkpoint meta item`
|
|
17
|
+
* and `left a foreign row in place` fire once per row, and those passes walk a
|
|
18
|
+
* whole partition, up to `MAX_TOTAL_ROWS_IN_MEMORY`
|
|
19
|
+
* (`src/shared/dynamodb/paginate.ts`) rows: one call on a shared table could
|
|
20
|
+
* write megabytes of log. A consumer's `VectorBackend` carries no such service
|
|
21
|
+
* cap at all.
|
|
22
|
+
*
|
|
23
|
+
* 256 is `MAX_KEY_SEGMENT_BYTES` (`src/shared/dynamodb/table-schema.ts`), this
|
|
24
|
+
* package's own budget for one identifier inside a key, so any key composed
|
|
25
|
+
* from identifiers it validated is quoted whole in the common case and only a
|
|
26
|
+
* foreign row, a hand-written one or a backend's own answer — exactly the
|
|
27
|
+
* cases these lines report — is cut. Nothing is lost by cutting: the line's
|
|
28
|
+
* job is to say which row to go and look at, and the row holds the rest.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MAX_LOGGED_VALUE_CHARS = 256;
|
|
31
|
+
/**
|
|
32
|
+
* Labels of an unchecked `string[]` one log line or one public error message
|
|
33
|
+
* carries, past which the rest are dropped and the real depth is stated.
|
|
34
|
+
*
|
|
35
|
+
* An array is two unbounded things — how many labels there are and how long
|
|
36
|
+
* each one is — so a bound on the labels alone is not a bound: a backend
|
|
37
|
+
* answering with one label of a megabyte and one answering with a million
|
|
38
|
+
* labels of a character cost the same line. {@link MAX_LOGGED_VALUE_CHARS}
|
|
39
|
+
* covers the first, this covers the second.
|
|
40
|
+
*
|
|
41
|
+
* 8 is a budget rather than a rule about namespaces: a store namespace is a
|
|
42
|
+
* path, what identifies which path is its leading labels, and every namespace
|
|
43
|
+
* this package's own documentation forms is two or three deep. The marker
|
|
44
|
+
* states the depth it really had, so a deeper one is cut without being
|
|
45
|
+
* misreported.
|
|
46
|
+
*
|
|
47
|
+
* A `namespace` and `key` pair that passed `parseStoreAddress` needs none of
|
|
48
|
+
* this and goes in whole: that check measures the sort key they *compose*, so
|
|
49
|
+
* it bounds how many labels there are as well as how long each one is. A
|
|
50
|
+
* search or listing **prefix** passes no such check — nothing composes it into
|
|
51
|
+
* a key — so its depth is unchecked however carefully each label was checked,
|
|
52
|
+
* and a backend's own answer is unchecked in both.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MAX_LOGGED_LABELS = 8;
|
|
55
|
+
/**
|
|
56
|
+
* Characters of a relayed *cause's* text one public error message or one log
|
|
57
|
+
* line carries, past which it is cut and marked with its real length.
|
|
58
|
+
*
|
|
59
|
+
* Its own cap rather than {@link MAX_LOGGED_VALUE_CHARS} because the two bound
|
|
60
|
+
* different things. That one bounds an **identifier** — a sort key, an S3
|
|
61
|
+
* object key, a namespace label — and 256 is this package's own budget for one
|
|
62
|
+
* identifier inside a key, so a value past it is already abnormal and the line
|
|
63
|
+
* only has to say which row to go and look at. This one bounds **prose**: the
|
|
64
|
+
* sentence an AWS SDK error, a consumer's `VectorBackend` or a caller's own
|
|
65
|
+
* `serde` wrote to explain a failure, which `redactedMessage` relays into
|
|
66
|
+
* `err.message`. Cutting that at an identifier's budget would throw away the
|
|
67
|
+
* half of a diagnostic that says what to do about it, and a diagnostic is the
|
|
68
|
+
* entire value of relaying it at all.
|
|
69
|
+
*
|
|
70
|
+
* 1024 is measured against the longest text this package actually relays: an
|
|
71
|
+
* IAM `AccessDenied`, which names the calling principal's ARN, the action and
|
|
72
|
+
* the resource ARN and then says why no policy allows it, runs to the mid
|
|
73
|
+
* hundreds of characters, and a role ARN with a long path and a session name
|
|
74
|
+
* pushes it further. 1024 clears that whole, so the case an operator most
|
|
75
|
+
* needs to read arrives intact.
|
|
76
|
+
*
|
|
77
|
+
* What it is *for* is the other direction. `redactedMessage` also relays a
|
|
78
|
+
* **caller's own** thrown error — a `serde` refusing a value, a `vectorBackend`
|
|
79
|
+
* rejecting a query — whose length the caller controls entirely, and those
|
|
80
|
+
* messages are quoted once per row on paths that walk a whole prefix or table.
|
|
81
|
+
* Unbounded, one such error fills a log; at 1024 a thousand of them are a
|
|
82
|
+
* megabyte rather than an unbounded amount.
|
|
83
|
+
*
|
|
84
|
+
* Its own literal at the same value as `MAX_SORT_KEY_BYTES`
|
|
85
|
+
* (`src/shared/dynamodb/table-schema.ts`) and `MAX_S3_KEY_BYTES`
|
|
86
|
+
* (`src/shared/codec/s3/config.ts`) rather than an alias of either, for the
|
|
87
|
+
* reason `LIST_SCAN_WARN_THRESHOLD` (`src/shared/dynamodb/paginate.ts`)
|
|
88
|
+
* records: aliasing two caps would move one whenever the other is retuned,
|
|
89
|
+
* and these three answer unrelated questions.
|
|
90
|
+
*/
|
|
91
|
+
export declare const MAX_RELAYED_MESSAGE_CHARS = 1024;
|
|
92
|
+
/**
|
|
93
|
+
* Bound a string this package did not length-check.
|
|
94
|
+
*
|
|
95
|
+
* **The rule, in one sentence:** a string goes through here before a log line
|
|
96
|
+
* or a public error message quotes it, unless this package composed it from
|
|
97
|
+
* identifiers it length-checked. Where the string came from does not decide
|
|
98
|
+
* it — a row, a bucket's own configuration, a consumer's `VectorBackend` and
|
|
99
|
+
* an object the caller handed in are the same thing here, which is that
|
|
100
|
+
* nothing bounded them. A caller's `sessionId`, `threadId`, `namespace` and
|
|
101
|
+
* `key`, and every key built from them, are capped by
|
|
102
|
+
* `MAX_PARTITION_ID_BYTES`, `MAX_KEY_SEGMENT_BYTES` and `MAX_SORT_KEY_BYTES`
|
|
103
|
+
* before a request is made, so those go in as they are; a row's own `SK`, an
|
|
104
|
+
* offloaded object's key, a descriptor's `location`, a backend's `namespace`
|
|
105
|
+
* and `key`, a lifecycle rule's scope and a stored message's `type` are
|
|
106
|
+
* bounded by nothing this package ran.
|
|
107
|
+
*
|
|
108
|
+
* **It says "or a public error message" for one reason:** one value must not
|
|
109
|
+
* get two answers. An `s3Key` off a row was cut for the `warn` that reports
|
|
110
|
+
* refusing to delete the object and quoted whole by the error that refuses to
|
|
111
|
+
* read it — one package, one value, two answers. An error's text is not the
|
|
112
|
+
* compatibility surface (the README tells callers to branch on `code`, `name`
|
|
113
|
+
* and the structured fields, never on text) and the `context` those errors
|
|
114
|
+
* carry keeps the value whole, so what reads an error as data loses nothing
|
|
115
|
+
* by this.
|
|
116
|
+
*
|
|
117
|
+
* Accepts: `value` — the string as whatever produced it carried it. Declared
|
|
118
|
+
* `string` because a table's own key attributes always are, and because the
|
|
119
|
+
* interfaces a consumer implements say so; anything else is returned
|
|
120
|
+
* untouched rather than coerced or refused, since a report of a value that is
|
|
121
|
+
* already wrong is the last place to raise a `TypeError` of its own.
|
|
122
|
+
*
|
|
123
|
+
* Returns: the value unchanged at or under {@link MAX_LOGGED_VALUE_CHARS}
|
|
124
|
+
* characters, otherwise that many characters followed by `…(len N)` giving the
|
|
125
|
+
* length it really had. The mark is what keeps a cut value honest: without it
|
|
126
|
+
* a truncated key reads as a key that simply ends there.
|
|
127
|
+
*
|
|
128
|
+
* Throws: nothing.
|
|
129
|
+
*
|
|
130
|
+
* Guarantees: a cut never falls between the halves of a surrogate pair, so a
|
|
131
|
+
* well-formed value stays well-formed. A lone surrogate is what
|
|
132
|
+
* `assertWellFormed` exists to keep out of this package's strings, and a JSON
|
|
133
|
+
* log transport rewrites one to U+FFFD without saying so.
|
|
134
|
+
*/
|
|
135
|
+
export declare function truncateForLog(value: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* Bound the **prose** of a relayed cause, which takes its own cap.
|
|
138
|
+
*
|
|
139
|
+
* {@link truncateForLog} bounds an identifier, where 256 characters is this
|
|
140
|
+
* package's own budget for one and anything past it is already abnormal. The
|
|
141
|
+
* text an AWS SDK error, a consumer's `VectorBackend` or a caller's own
|
|
142
|
+
* `serde` wrote is a sentence rather than a name: cut at an identifier's
|
|
143
|
+
* budget it loses the half that says what to do, which is the only reason to
|
|
144
|
+
* relay it. {@link MAX_RELAYED_MESSAGE_CHARS} records what the larger number
|
|
145
|
+
* is measured against, and why the two differ.
|
|
146
|
+
*
|
|
147
|
+
* It has exactly one caller — `redactedMessage`, the funnel every `catch` in
|
|
148
|
+
* this package goes through — so no call site can get the cap wrong and no
|
|
149
|
+
* future one has to remember it. That also means a site must not cut the
|
|
150
|
+
* result again: a second cut marks the length of the first cut's output rather
|
|
151
|
+
* than of the original, which is the one thing the mark exists to prevent.
|
|
152
|
+
*
|
|
153
|
+
* Accepts: `value` — the redacted text. Redaction runs first, so a credential
|
|
154
|
+
* shape can never be half-cut past the pattern that would have caught it.
|
|
155
|
+
*
|
|
156
|
+
* Returns: the value unchanged at or under the cap, otherwise that many
|
|
157
|
+
* characters followed by `…(len N)`.
|
|
158
|
+
*
|
|
159
|
+
* Throws: nothing.
|
|
160
|
+
*/
|
|
161
|
+
export declare function truncateRelayedText(value: string): string;
|
|
162
|
+
/**
|
|
163
|
+
* Bound a list of labels — a store `namespace`, a list of channel names — the
|
|
164
|
+
* same rule reaches.
|
|
165
|
+
*
|
|
166
|
+
* An array is two unbounded things, how many labels it holds and how long each
|
|
167
|
+
* one is, so a bound on one of them is not a bound. {@link truncateForLog}
|
|
168
|
+
* covers the labels; the count is covered here.
|
|
169
|
+
*
|
|
170
|
+
* A `namespace` and `key` pair that passed `parseStoreAddress` is already
|
|
171
|
+
* bounded in both — that check measures the sort key they compose — and goes
|
|
172
|
+
* in whole. A search or listing prefix is not: nothing composes it into a key,
|
|
173
|
+
* so however carefully each label was checked, how many there are was not.
|
|
174
|
+
*
|
|
175
|
+
* The labels stay a list rather than being joined into one string, for two
|
|
176
|
+
* reasons. A structured transport already carries the field as a list and the
|
|
177
|
+
* README's Logging table documents it as one, so joining would change the
|
|
178
|
+
* shape of a line rather than only its size. And a label nothing validated may
|
|
179
|
+
* hold the `#` a join would put between labels, so a joined line cannot say
|
|
180
|
+
* whether the backend answered with one label or with two — which is the very
|
|
181
|
+
* thing these lines report.
|
|
182
|
+
*
|
|
183
|
+
* Accepts: `labels` — as the row, the backend or the caller gave it. Declared
|
|
184
|
+
* `string[]` because that is what the interfaces say; anything else is
|
|
185
|
+
* returned untouched, for the reason {@link truncateForLog} gives, and that
|
|
186
|
+
* case is reached rather than defensive — a `namespace` that is not an array
|
|
187
|
+
* is one of the things `parseStoreAddress` refuses, and the line reporting the
|
|
188
|
+
* refusal quotes what was refused.
|
|
189
|
+
*
|
|
190
|
+
* Returns: at most {@link MAX_LOGGED_LABELS} labels, each bounded by
|
|
191
|
+
* {@link truncateForLog}, with one further label reading `…(len N)` when some
|
|
192
|
+
* were dropped, giving the depth the list really had. A list within both
|
|
193
|
+
* bounds comes back as an equal list.
|
|
194
|
+
*
|
|
195
|
+
* Throws: nothing.
|
|
196
|
+
*/
|
|
197
|
+
export declare function truncateLabelsForLog(labels: string[]): string[];
|