@ai-matrx/vault 0.1.5 → 0.1.7

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.cts CHANGED
@@ -122,7 +122,7 @@ declare function locationToParams(loc: VaultLocation): URLSearchParams;
122
122
  /** The one search every list shares: name, type, tags, URLs, then plaintext custom fields. */
123
123
  declare function matchesQuery(item: VaultItem, query: string): boolean;
124
124
  /** An item's website as people read it: `github.com` (no scheme, no `www.`), or "" when it has none. */
125
- declare function siteOf(item: Pick<VaultItem, "loginUrls">): string;
125
+ declare function loginSiteOf(item: Pick<VaultItem, "loginUrls">): string;
126
126
  declare function sortItems(items: readonly VaultItem[], sort: VaultSort): VaultItem[];
127
127
  interface NewSecretField {
128
128
  key: string;
@@ -147,9 +147,6 @@ interface ItemDraft {
147
147
  authenticator: string;
148
148
  }
149
149
 
150
- type NoticeKind = "success" | "error" | "info";
151
- type Notify = (message: string, kind?: NoticeKind) => void;
152
-
153
150
  /** One recorded earlier value of a secret field. Value-free: the value comes only from `revealHistory`. */
154
151
  interface HistoryEntry {
155
152
  fieldId: string;
@@ -1096,7 +1093,8 @@ interface VaultPort {
1096
1093
  * What only some hosts can do. A missing capability hides its control; it never shows a dead one.
1097
1094
  * - Every host with a signed-in person supplies `identity` (confirm it's you before a secret shows).
1098
1095
  * - The browser extension supplies `page` (the tab's address, the logins that match it) and `fill`.
1099
- * - The desktop app supplies `nativeProvider` (the system credential provider's state).
1096
+ * - The desktop app supplies `nativeProvider` (the system credential provider's state), and its own
1097
+ * `lock`, `clipboard` custody and `revealSeconds`.
1100
1098
  */
1101
1099
  interface VaultHostCapabilities {
1102
1100
  identity?: VaultIdentity;
@@ -1114,12 +1112,71 @@ interface VaultHostCapabilities {
1114
1112
  /** Desktop: the native passkey importer (file chooser, parsing and keys stay native). */
1115
1113
  nativeImport?: NativeImportBridge;
1116
1114
  openUrl?: (url: string) => void;
1115
+ /** A lock the host holds (`lock.ts`): while locked the vault shows Unlock and refuses every port call. */
1116
+ lock?: VaultLock;
1117
+ /** The host's clipboard: every copy goes through it; a secret is the host's to clear (`lock.ts`). */
1118
+ clipboard?: VaultClipboard;
1119
+ /** How long a shown value stays shown, in seconds (an organization knob the host reads); default 20. */
1120
+ revealSeconds?: number;
1117
1121
  nativeProvider?: {
1118
1122
  status: "ready" | "needs_setup" | "unavailable";
1119
1123
  openSetup: () => void;
1120
1124
  };
1121
1125
  }
1122
1126
 
1127
+ /**
1128
+ * A HOST-HELD LOCK. Some hosts lock the vault themselves (the desktop app: Touch ID, starts locked,
1129
+ * locks after idle, on sleep and on screen lock). The host owns the lock and enforces it on its own
1130
+ * side; the vault shows a locked screen with Unlock, and while locked refuses every port call — a
1131
+ * value never reaches a screen while the host says locked. Without `lock` nothing changes.
1132
+ */
1133
+ interface VaultLock {
1134
+ /** Locked right now. */
1135
+ locked(): boolean;
1136
+ /** Told on every change; returns the unsubscribe. */
1137
+ subscribe(listener: () => void): () => void;
1138
+ /** Ask the host to unlock (Touch ID, a click…). Rejects with a sentence a person can act on. */
1139
+ unlock(): Promise<void>;
1140
+ /** Lock now. When given, the vault offers "Lock". */
1141
+ lock?: () => void | Promise<void>;
1142
+ /** The unlock button's words ("Unlock with Touch ID"); default "Unlock". */
1143
+ unlockLabel?: string;
1144
+ }
1145
+ /**
1146
+ * HOST CLIPBOARD CUSTODY. When given, every copy in the vault goes through the host. `secret` asks
1147
+ * the host to take custody: clear it after a while if it is still there, and on lock or quit.
1148
+ */
1149
+ interface VaultClipboard {
1150
+ copy(text: string, how: {
1151
+ secret: boolean;
1152
+ }): Promise<void>;
1153
+ }
1154
+ declare const LOCKED_MESSAGE = "The vault is locked. Unlock it first.";
1155
+ declare class VaultLockedError extends Error {
1156
+ readonly code = "vault_locked";
1157
+ constructor();
1158
+ }
1159
+ /**
1160
+ * The port with every method (areas included) refused while `locked()` says so. The check runs at
1161
+ * call time, so a screen still mounted when the lock lands cannot read a value.
1162
+ */
1163
+ declare function guardPort(port: VaultPort, locked: () => boolean): VaultPort;
1164
+
1165
+ type NoticeKind = "success" | "error" | "info";
1166
+ type Notify = (message: string, kind?: NoticeKind) => void;
1167
+ interface CopyOptions {
1168
+ /** A secret (a password, a code, a key): the host's clipboard takes custody. Default true. */
1169
+ secret?: boolean;
1170
+ }
1171
+ /**
1172
+ * Writes `text` and says so (or says why not). Through the host's clipboard when it has one (custody:
1173
+ * the host clears a secret later), else the browser's. Pure over its inputs, so it is tested alone.
1174
+ */
1175
+ declare function copyValue(text: string, label: string, options: CopyOptions, deps: {
1176
+ clipboard?: VaultClipboard | undefined;
1177
+ notify: Notify;
1178
+ }): Promise<boolean>;
1179
+
1123
1180
  type VaultLayout = "auto" | "full" | "split" | "stack";
1124
1181
  interface VaultAppProps {
1125
1182
  port: VaultPort;
@@ -1183,4 +1240,4 @@ declare function GenerateButton({ onUse, label, limits, disabled }: {
1183
1240
  disabled?: boolean;
1184
1241
  }): react.JSX.Element | null;
1185
1242
 
1186
- export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, type IdentityAccount, type IdentityMethod, type ItemDraft, type NoticeKind, type Notify, type SaveResult, type SupabaseAuthLike, type TotpReading, type UriMatchMode, type UrlGuess, VaultApp, type VaultAppProps, type VaultAttachment, type VaultAuthenticator, type VaultCustomField, type VaultDefinition, type VaultField, type VaultHostCapabilities, type VaultIdentity, type VaultItem, type VaultItemCapabilities, type VaultKnobs, type VaultLayout, type VaultLocation, type VaultOrganizationRef, type VaultOwner, type VaultPort, type VaultSelection, type VaultSnapshot, type VaultSort, type VaultUserStateDoor, categoryOf, createApiVaultPort, createSupabaseIdentity, createVaultKnobs, inferFromUrl, locationFromParams, locationToParams, matchesQuery, needsRecentSignIn, parseDefinitions, siteOf, sortItems };
1243
+ export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, type IdentityAccount, type IdentityMethod, type ItemDraft, LOCKED_MESSAGE, type NoticeKind, type Notify, type SaveResult, type SupabaseAuthLike, type TotpReading, type UriMatchMode, type UrlGuess, VaultApp, type VaultAppProps, type VaultAttachment, type VaultAuthenticator, type VaultClipboard, type VaultCustomField, type VaultDefinition, type VaultField, type VaultHostCapabilities, type VaultIdentity, type VaultItem, type VaultItemCapabilities, type VaultKnobs, type VaultLayout, type VaultLocation, type VaultLock, VaultLockedError, type VaultOrganizationRef, type VaultOwner, type VaultPort, type VaultSelection, type VaultSnapshot, type VaultSort, type VaultUserStateDoor, categoryOf, copyValue, createApiVaultPort, createSupabaseIdentity, createVaultKnobs, guardPort, inferFromUrl, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, sortItems };
package/dist/index.d.ts CHANGED
@@ -122,7 +122,7 @@ declare function locationToParams(loc: VaultLocation): URLSearchParams;
122
122
  /** The one search every list shares: name, type, tags, URLs, then plaintext custom fields. */
123
123
  declare function matchesQuery(item: VaultItem, query: string): boolean;
124
124
  /** An item's website as people read it: `github.com` (no scheme, no `www.`), or "" when it has none. */
125
- declare function siteOf(item: Pick<VaultItem, "loginUrls">): string;
125
+ declare function loginSiteOf(item: Pick<VaultItem, "loginUrls">): string;
126
126
  declare function sortItems(items: readonly VaultItem[], sort: VaultSort): VaultItem[];
127
127
  interface NewSecretField {
128
128
  key: string;
@@ -147,9 +147,6 @@ interface ItemDraft {
147
147
  authenticator: string;
148
148
  }
149
149
 
150
- type NoticeKind = "success" | "error" | "info";
151
- type Notify = (message: string, kind?: NoticeKind) => void;
152
-
153
150
  /** One recorded earlier value of a secret field. Value-free: the value comes only from `revealHistory`. */
154
151
  interface HistoryEntry {
155
152
  fieldId: string;
@@ -1096,7 +1093,8 @@ interface VaultPort {
1096
1093
  * What only some hosts can do. A missing capability hides its control; it never shows a dead one.
1097
1094
  * - Every host with a signed-in person supplies `identity` (confirm it's you before a secret shows).
1098
1095
  * - The browser extension supplies `page` (the tab's address, the logins that match it) and `fill`.
1099
- * - The desktop app supplies `nativeProvider` (the system credential provider's state).
1096
+ * - The desktop app supplies `nativeProvider` (the system credential provider's state), and its own
1097
+ * `lock`, `clipboard` custody and `revealSeconds`.
1100
1098
  */
1101
1099
  interface VaultHostCapabilities {
1102
1100
  identity?: VaultIdentity;
@@ -1114,12 +1112,71 @@ interface VaultHostCapabilities {
1114
1112
  /** Desktop: the native passkey importer (file chooser, parsing and keys stay native). */
1115
1113
  nativeImport?: NativeImportBridge;
1116
1114
  openUrl?: (url: string) => void;
1115
+ /** A lock the host holds (`lock.ts`): while locked the vault shows Unlock and refuses every port call. */
1116
+ lock?: VaultLock;
1117
+ /** The host's clipboard: every copy goes through it; a secret is the host's to clear (`lock.ts`). */
1118
+ clipboard?: VaultClipboard;
1119
+ /** How long a shown value stays shown, in seconds (an organization knob the host reads); default 20. */
1120
+ revealSeconds?: number;
1117
1121
  nativeProvider?: {
1118
1122
  status: "ready" | "needs_setup" | "unavailable";
1119
1123
  openSetup: () => void;
1120
1124
  };
1121
1125
  }
1122
1126
 
1127
+ /**
1128
+ * A HOST-HELD LOCK. Some hosts lock the vault themselves (the desktop app: Touch ID, starts locked,
1129
+ * locks after idle, on sleep and on screen lock). The host owns the lock and enforces it on its own
1130
+ * side; the vault shows a locked screen with Unlock, and while locked refuses every port call — a
1131
+ * value never reaches a screen while the host says locked. Without `lock` nothing changes.
1132
+ */
1133
+ interface VaultLock {
1134
+ /** Locked right now. */
1135
+ locked(): boolean;
1136
+ /** Told on every change; returns the unsubscribe. */
1137
+ subscribe(listener: () => void): () => void;
1138
+ /** Ask the host to unlock (Touch ID, a click…). Rejects with a sentence a person can act on. */
1139
+ unlock(): Promise<void>;
1140
+ /** Lock now. When given, the vault offers "Lock". */
1141
+ lock?: () => void | Promise<void>;
1142
+ /** The unlock button's words ("Unlock with Touch ID"); default "Unlock". */
1143
+ unlockLabel?: string;
1144
+ }
1145
+ /**
1146
+ * HOST CLIPBOARD CUSTODY. When given, every copy in the vault goes through the host. `secret` asks
1147
+ * the host to take custody: clear it after a while if it is still there, and on lock or quit.
1148
+ */
1149
+ interface VaultClipboard {
1150
+ copy(text: string, how: {
1151
+ secret: boolean;
1152
+ }): Promise<void>;
1153
+ }
1154
+ declare const LOCKED_MESSAGE = "The vault is locked. Unlock it first.";
1155
+ declare class VaultLockedError extends Error {
1156
+ readonly code = "vault_locked";
1157
+ constructor();
1158
+ }
1159
+ /**
1160
+ * The port with every method (areas included) refused while `locked()` says so. The check runs at
1161
+ * call time, so a screen still mounted when the lock lands cannot read a value.
1162
+ */
1163
+ declare function guardPort(port: VaultPort, locked: () => boolean): VaultPort;
1164
+
1165
+ type NoticeKind = "success" | "error" | "info";
1166
+ type Notify = (message: string, kind?: NoticeKind) => void;
1167
+ interface CopyOptions {
1168
+ /** A secret (a password, a code, a key): the host's clipboard takes custody. Default true. */
1169
+ secret?: boolean;
1170
+ }
1171
+ /**
1172
+ * Writes `text` and says so (or says why not). Through the host's clipboard when it has one (custody:
1173
+ * the host clears a secret later), else the browser's. Pure over its inputs, so it is tested alone.
1174
+ */
1175
+ declare function copyValue(text: string, label: string, options: CopyOptions, deps: {
1176
+ clipboard?: VaultClipboard | undefined;
1177
+ notify: Notify;
1178
+ }): Promise<boolean>;
1179
+
1123
1180
  type VaultLayout = "auto" | "full" | "split" | "stack";
1124
1181
  interface VaultAppProps {
1125
1182
  port: VaultPort;
@@ -1183,4 +1240,4 @@ declare function GenerateButton({ onUse, label, limits, disabled }: {
1183
1240
  disabled?: boolean;
1184
1241
  }): react.JSX.Element | null;
1185
1242
 
1186
- export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, type IdentityAccount, type IdentityMethod, type ItemDraft, type NoticeKind, type Notify, type SaveResult, type SupabaseAuthLike, type TotpReading, type UriMatchMode, type UrlGuess, VaultApp, type VaultAppProps, type VaultAttachment, type VaultAuthenticator, type VaultCustomField, type VaultDefinition, type VaultField, type VaultHostCapabilities, type VaultIdentity, type VaultItem, type VaultItemCapabilities, type VaultKnobs, type VaultLayout, type VaultLocation, type VaultOrganizationRef, type VaultOwner, type VaultPort, type VaultSelection, type VaultSnapshot, type VaultSort, type VaultUserStateDoor, categoryOf, createApiVaultPort, createSupabaseIdentity, createVaultKnobs, inferFromUrl, locationFromParams, locationToParams, matchesQuery, needsRecentSignIn, parseDefinitions, siteOf, sortItems };
1243
+ export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, type IdentityAccount, type IdentityMethod, type ItemDraft, LOCKED_MESSAGE, type NoticeKind, type Notify, type SaveResult, type SupabaseAuthLike, type TotpReading, type UriMatchMode, type UrlGuess, VaultApp, type VaultAppProps, type VaultAttachment, type VaultAuthenticator, type VaultClipboard, type VaultCustomField, type VaultDefinition, type VaultField, type VaultHostCapabilities, type VaultIdentity, type VaultItem, type VaultItemCapabilities, type VaultKnobs, type VaultLayout, type VaultLocation, type VaultLock, VaultLockedError, type VaultOrganizationRef, type VaultOwner, type VaultPort, type VaultSelection, type VaultSnapshot, type VaultSort, type VaultUserStateDoor, categoryOf, copyValue, createApiVaultPort, createSupabaseIdentity, createVaultKnobs, guardPort, inferFromUrl, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, sortItems };