@protobase/schema 0.12.3 → 0.12.5

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/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ import { layout } from "./layout.js";
23
23
  import { KeyType, decodeKey, encodeKey, keyTypes } from "./keys.js";
24
24
  import { addressWords, appPath, readAppPath } from "./app-address.js";
25
25
  import { PluginHost, PluginRequirement, inRange, pluginProblem } from "./plugin-version.js";
26
+ import { redactSecrets } from "./redact-secrets.js";
26
27
  import { addressPlaceholders, appHrefError, fillAddress, hrefPlaceholders, leavesApp } from "./address-template.js";
27
28
  import { AddressCheck, addressErrors } from "./address-errors.js";
28
29
  import { FilterLimits, FilterParse, parseFilter } from "./filter/parse.js";
@@ -42,4 +43,4 @@ import "./access/index.js";
42
43
  import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
43
44
  import { applyAssistantEvent, emptyAssistantState } from "./assistant/apply-event.js";
44
45
  import { readEventStream } from "./assistant/event-stream.js";
45
- export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FieldWidgetModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PluginHost, type PluginRequirement, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
46
+ export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FieldWidgetModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PluginHost, type PluginRequirement, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, redactSecrets, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ import { bottomBarErrors } from "./bottom-bar-errors.js";
25
25
  import { decodeKey, encodeKey, keyTypes } from "./keys.js";
26
26
  import { addressWords, appPath, readAppPath } from "./app-address.js";
27
27
  import { inRange, pluginProblem } from "./plugin-version.js";
28
+ import { redactSecrets } from "./redact-secrets.js";
28
29
  import { addressErrors } from "./address-errors.js";
29
30
  import { rule } from "./access/rule.js";
30
31
  import { defineRoles } from "./access/roles.js";
@@ -32,4 +33,4 @@ import { pickView } from "./access/pick-view.js";
32
33
  import { restrictModel } from "./access/restrict.js";
33
34
  import { applyAssistantEvent, emptyAssistantState } from "./assistant/apply-event.js";
34
35
  import { readEventStream } from "./assistant/event-stream.js";
35
- export { accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
36
+ export { accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, redactSecrets, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
@@ -0,0 +1,7 @@
1
+ //#region src/redact-secrets.d.ts
2
+ /**
3
+ * A copy of an error event, or any plain value, without the credentials it carries: the value of every key that names
4
+ * one (authorization headers, cookies, passwords, tokens, API keys) and of every such query parameter in a URL.
5
+ */
6
+ export declare const redactSecrets: <T>(value: T) => T;
7
+ //#endregion
@@ -0,0 +1,35 @@
1
+ //#region src/redact-secrets.ts
2
+ const redacted = "[Filtered]";
3
+ const secretName = /authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i;
4
+ const urlKeys = /* @__PURE__ */ new Set([
5
+ "url",
6
+ "query_string",
7
+ "from",
8
+ "to"
9
+ ]);
10
+ const maxDepth = 12;
11
+ const redactQuery = (query) => query.replace(/(^|&)([^=&]*)=([^&]*)/g, (pair, separator, name) => secretName.test(name) ? `${separator}${name}=${redacted}` : pair);
12
+ const redactUrl = (url) => {
13
+ const start = url.indexOf("?");
14
+ if (start === -1) return url;
15
+ const end = url.indexOf("#", start);
16
+ const query = end === -1 ? url.slice(start + 1) : url.slice(start + 1, end);
17
+ return `${url.slice(0, start + 1)}${redactQuery(query)}${end === -1 ? "" : url.slice(end)}`;
18
+ };
19
+ const redactValue = (key, value, depth) => {
20
+ if (secretName.test(key)) return redacted;
21
+ if (typeof value === "string" && urlKeys.has(key)) return key === "query_string" ? redactQuery(value) : redactUrl(value);
22
+ return redactWithin(value, depth + 1);
23
+ };
24
+ const redactWithin = (value, depth) => {
25
+ if (depth > maxDepth || typeof value !== "object" || value === null) return value;
26
+ if (Array.isArray(value)) return value.map((item) => Array.isArray(item) && item.length === 2 && typeof item[0] === "string" ? [item[0], redactValue(item[0], item[1], depth)] : redactWithin(item, depth + 1));
27
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(key, item, depth)]));
28
+ };
29
+ /**
30
+ * A copy of an error event, or any plain value, without the credentials it carries: the value of every key that names
31
+ * one (authorization headers, cookies, passwords, tokens, API keys) and of every such query parameter in a URL.
32
+ */
33
+ const redactSecrets = (value) => redactWithin(value, 0);
34
+ //#endregion
35
+ export { redactSecrets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {