@ai-matrx/vault 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -3
- package/dist/index.cjs +222 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -4
- package/dist/index.d.ts +62 -4
- package/dist/index.js +285 -114
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { Look } from '@ai-matrx/design-system';
|
|
3
4
|
import { KnobClient } from '@ai-matrx/data/knobs';
|
|
4
5
|
import * as account from '@ai-matrx/api/account';
|
|
@@ -85,6 +86,8 @@ interface VaultItem {
|
|
|
85
86
|
accessMode: string | null;
|
|
86
87
|
/** The person who owns the item (`user_id`). For the person's own items this is them. */
|
|
87
88
|
ownerUserId: string | null;
|
|
89
|
+
/** The whole item is turned off (an item restored from Trash comes back off): nothing can use it until it is turned on. */
|
|
90
|
+
turnedOff?: boolean;
|
|
88
91
|
/** Set when the item is in the trash: what restoring it needs. */
|
|
89
92
|
deletion: {
|
|
90
93
|
deletionId: string | null;
|
|
@@ -137,6 +140,11 @@ declare const isHiddenItem: (item: {
|
|
|
137
140
|
}) => boolean;
|
|
138
141
|
/** An item's website as people read it: `github.com` (no scheme, no `www.`), or "" when it has none. */
|
|
139
142
|
declare function loginSiteOf(item: Pick<VaultItem, "loginUrls">): string;
|
|
143
|
+
/**
|
|
144
|
+
* The site a host belongs to, its registrable domain: `accounts.google.com` → `google.com`,
|
|
145
|
+
* `shop.example.co.uk` → `example.co.uk`. An address or a one-label host is returned as it is.
|
|
146
|
+
*/
|
|
147
|
+
declare function siteDomainOf(host: string): string;
|
|
140
148
|
declare function sortItems(items: readonly VaultItem[], sort: VaultSort): VaultItem[];
|
|
141
149
|
interface NewSecretField {
|
|
142
150
|
key: string;
|
|
@@ -253,6 +261,12 @@ interface VaultIdentity {
|
|
|
253
261
|
withEmailCode(code: string): Promise<void>;
|
|
254
262
|
/** A host-only path with no human step (the playground's dev server). */
|
|
255
263
|
dev?: () => Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Run once when the page loads. After a provider confirmation left the page and came back, it
|
|
266
|
+
* checks the SAME person is signed in. A different account is signed out of this device and the
|
|
267
|
+
* sentence to show is returned; otherwise null.
|
|
268
|
+
*/
|
|
269
|
+
checkReturn?: () => Promise<string | null>;
|
|
256
270
|
}
|
|
257
271
|
/** The slice of supabase-js `auth` this needs, so the package never depends on supabase-js itself. */
|
|
258
272
|
interface SupabaseAuthLike {
|
|
@@ -318,12 +332,38 @@ interface SupabaseAuthLike {
|
|
|
318
332
|
message: string;
|
|
319
333
|
} | null;
|
|
320
334
|
}>;
|
|
335
|
+
/** Used only when the host gives no `onDifferentPerson`: ends THIS device's session, never others. */
|
|
336
|
+
signOut?(o: {
|
|
337
|
+
scope: "local";
|
|
338
|
+
}): Promise<{
|
|
339
|
+
error: unknown;
|
|
340
|
+
}>;
|
|
321
341
|
}
|
|
322
|
-
/**
|
|
323
|
-
|
|
342
|
+
/** Where the person confirming is remembered while the page is away at the provider. */
|
|
343
|
+
interface ReturnStore {
|
|
344
|
+
getItem(key: string): string | null;
|
|
345
|
+
setItem(key: string, value: string): void;
|
|
346
|
+
removeItem(key: string): void;
|
|
347
|
+
}
|
|
348
|
+
interface SupabaseIdentityOptions {
|
|
349
|
+
/** The host's accepted OAuth return address carrying this page. */
|
|
324
350
|
redirectTo?: () => string;
|
|
325
351
|
dev?: () => Promise<void>;
|
|
326
|
-
|
|
352
|
+
/**
|
|
353
|
+
* A provider confirmation came back signed in as someone else. The host ends that session on THIS
|
|
354
|
+
* device only (its own device-scoped sign-out) and tells the person; `message` says what happened.
|
|
355
|
+
* Without it the package signs out locally through `auth.signOut({ scope: "local" })`.
|
|
356
|
+
*/
|
|
357
|
+
onDifferentPerson?: (message: string) => Promise<void> | void;
|
|
358
|
+
/** Default: the tab's `sessionStorage`. */
|
|
359
|
+
store?: ReturnStore;
|
|
360
|
+
/** Default `Date.now`. */
|
|
361
|
+
now?: () => number;
|
|
362
|
+
}
|
|
363
|
+
/** The key the expected person is kept under across the provider's redirect. */
|
|
364
|
+
declare const CONFIRM_RETURN_KEY = "matrx-vault:confirming-as";
|
|
365
|
+
/** THE identity confirmation for every host: give it the host's `supabase.auth`. */
|
|
366
|
+
declare function createSupabaseIdentity(auth: SupabaseAuthLike, options?: SupabaseIdentityOptions): VaultIdentity;
|
|
327
367
|
/** True when the server refused because the sign-in is not recent enough. */
|
|
328
368
|
declare function needsRecentSignIn(e: unknown): boolean;
|
|
329
369
|
|
|
@@ -704,6 +744,8 @@ interface ItemSettingsPatch {
|
|
|
704
744
|
browserFillEnabled?: boolean;
|
|
705
745
|
/** The complete list of websites (used to add a promoted address). */
|
|
706
746
|
loginUrls?: string[];
|
|
747
|
+
/** Turn the whole item on (true) or off (false). */
|
|
748
|
+
active?: boolean;
|
|
707
749
|
}
|
|
708
750
|
interface NewFieldInput {
|
|
709
751
|
key: string;
|
|
@@ -1131,6 +1173,8 @@ interface VaultHostCapabilities {
|
|
|
1131
1173
|
/** Desktop: the native passkey importer (file chooser, parsing and keys stay native). */
|
|
1132
1174
|
nativeImport?: NativeImportBridge;
|
|
1133
1175
|
openUrl?: (url: string) => void;
|
|
1176
|
+
/** The host's own sign-in, offered when the session has ended (the web app: its login page, back here after). */
|
|
1177
|
+
signIn?: () => void;
|
|
1134
1178
|
/** A lock the host holds (`lock.ts`): while locked the vault shows Unlock and refuses every port call. */
|
|
1135
1179
|
lock?: VaultLock;
|
|
1136
1180
|
/** The host's clipboard: every copy goes through it; a secret is the host's to clear (`lock.ts`). */
|
|
@@ -1249,6 +1293,20 @@ interface ApiVaultPortOptions {
|
|
|
1249
1293
|
}
|
|
1250
1294
|
declare function createApiVaultPort(api: Api, options?: ApiVaultPortOptions): VaultPort;
|
|
1251
1295
|
|
|
1296
|
+
/**
|
|
1297
|
+
* Wrap any call that shows, copies or exports a secret. When the server answers "sign in again",
|
|
1298
|
+
* the person confirms it is them (Google, password, or an emailed code) and the call runs again —
|
|
1299
|
+
* they never see a dead "Authentication required" in the row.
|
|
1300
|
+
*/
|
|
1301
|
+
type Confirmed = <T>(run: () => Promise<T>) => Promise<T>;
|
|
1302
|
+
declare function useConfirmed(): Confirmed;
|
|
1303
|
+
declare function IdentityGate({ identity, children }: {
|
|
1304
|
+
identity: VaultIdentity | undefined;
|
|
1305
|
+
children: ReactNode;
|
|
1306
|
+
}): react.JSX.Element;
|
|
1307
|
+
/** True for the rejection a cancelled confirmation produces (callers stay quiet about it). */
|
|
1308
|
+
declare const wasCancelled: (e: unknown) => boolean;
|
|
1309
|
+
|
|
1252
1310
|
/** Reads the organization's ceilings. Raw knob values are fine: they are validated here. */
|
|
1253
1311
|
type GeneratorLimitsSource = () => Promise<{
|
|
1254
1312
|
maxPasswordLength?: unknown;
|
|
@@ -1265,4 +1323,4 @@ declare function GenerateButton({ onUse, label, limits, disabled }: {
|
|
|
1265
1323
|
disabled?: boolean;
|
|
1266
1324
|
}): react.JSX.Element | null;
|
|
1267
1325
|
|
|
1268
|
-
export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, HIDDEN_ITEM_TAG, 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, isHiddenItem, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, sortItems };
|
|
1326
|
+
export { type ApiVaultPortOptions, CATEGORIES, CONFIRM_RETURN_KEY, type CategoryId, type Confirmed, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, HIDDEN_ITEM_TAG, type IdentityAccount, IdentityGate, type IdentityMethod, type ItemDraft, LOCKED_MESSAGE, type NoticeKind, type Notify, type ReturnStore, type SaveResult, type SupabaseAuthLike, type SupabaseIdentityOptions, 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, isHiddenItem, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, siteDomainOf, sortItems, useConfirmed, wasCancelled };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { Look } from '@ai-matrx/design-system';
|
|
3
4
|
import { KnobClient } from '@ai-matrx/data/knobs';
|
|
4
5
|
import * as account from '@ai-matrx/api/account';
|
|
@@ -85,6 +86,8 @@ interface VaultItem {
|
|
|
85
86
|
accessMode: string | null;
|
|
86
87
|
/** The person who owns the item (`user_id`). For the person's own items this is them. */
|
|
87
88
|
ownerUserId: string | null;
|
|
89
|
+
/** The whole item is turned off (an item restored from Trash comes back off): nothing can use it until it is turned on. */
|
|
90
|
+
turnedOff?: boolean;
|
|
88
91
|
/** Set when the item is in the trash: what restoring it needs. */
|
|
89
92
|
deletion: {
|
|
90
93
|
deletionId: string | null;
|
|
@@ -137,6 +140,11 @@ declare const isHiddenItem: (item: {
|
|
|
137
140
|
}) => boolean;
|
|
138
141
|
/** An item's website as people read it: `github.com` (no scheme, no `www.`), or "" when it has none. */
|
|
139
142
|
declare function loginSiteOf(item: Pick<VaultItem, "loginUrls">): string;
|
|
143
|
+
/**
|
|
144
|
+
* The site a host belongs to, its registrable domain: `accounts.google.com` → `google.com`,
|
|
145
|
+
* `shop.example.co.uk` → `example.co.uk`. An address or a one-label host is returned as it is.
|
|
146
|
+
*/
|
|
147
|
+
declare function siteDomainOf(host: string): string;
|
|
140
148
|
declare function sortItems(items: readonly VaultItem[], sort: VaultSort): VaultItem[];
|
|
141
149
|
interface NewSecretField {
|
|
142
150
|
key: string;
|
|
@@ -253,6 +261,12 @@ interface VaultIdentity {
|
|
|
253
261
|
withEmailCode(code: string): Promise<void>;
|
|
254
262
|
/** A host-only path with no human step (the playground's dev server). */
|
|
255
263
|
dev?: () => Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Run once when the page loads. After a provider confirmation left the page and came back, it
|
|
266
|
+
* checks the SAME person is signed in. A different account is signed out of this device and the
|
|
267
|
+
* sentence to show is returned; otherwise null.
|
|
268
|
+
*/
|
|
269
|
+
checkReturn?: () => Promise<string | null>;
|
|
256
270
|
}
|
|
257
271
|
/** The slice of supabase-js `auth` this needs, so the package never depends on supabase-js itself. */
|
|
258
272
|
interface SupabaseAuthLike {
|
|
@@ -318,12 +332,38 @@ interface SupabaseAuthLike {
|
|
|
318
332
|
message: string;
|
|
319
333
|
} | null;
|
|
320
334
|
}>;
|
|
335
|
+
/** Used only when the host gives no `onDifferentPerson`: ends THIS device's session, never others. */
|
|
336
|
+
signOut?(o: {
|
|
337
|
+
scope: "local";
|
|
338
|
+
}): Promise<{
|
|
339
|
+
error: unknown;
|
|
340
|
+
}>;
|
|
321
341
|
}
|
|
322
|
-
/**
|
|
323
|
-
|
|
342
|
+
/** Where the person confirming is remembered while the page is away at the provider. */
|
|
343
|
+
interface ReturnStore {
|
|
344
|
+
getItem(key: string): string | null;
|
|
345
|
+
setItem(key: string, value: string): void;
|
|
346
|
+
removeItem(key: string): void;
|
|
347
|
+
}
|
|
348
|
+
interface SupabaseIdentityOptions {
|
|
349
|
+
/** The host's accepted OAuth return address carrying this page. */
|
|
324
350
|
redirectTo?: () => string;
|
|
325
351
|
dev?: () => Promise<void>;
|
|
326
|
-
|
|
352
|
+
/**
|
|
353
|
+
* A provider confirmation came back signed in as someone else. The host ends that session on THIS
|
|
354
|
+
* device only (its own device-scoped sign-out) and tells the person; `message` says what happened.
|
|
355
|
+
* Without it the package signs out locally through `auth.signOut({ scope: "local" })`.
|
|
356
|
+
*/
|
|
357
|
+
onDifferentPerson?: (message: string) => Promise<void> | void;
|
|
358
|
+
/** Default: the tab's `sessionStorage`. */
|
|
359
|
+
store?: ReturnStore;
|
|
360
|
+
/** Default `Date.now`. */
|
|
361
|
+
now?: () => number;
|
|
362
|
+
}
|
|
363
|
+
/** The key the expected person is kept under across the provider's redirect. */
|
|
364
|
+
declare const CONFIRM_RETURN_KEY = "matrx-vault:confirming-as";
|
|
365
|
+
/** THE identity confirmation for every host: give it the host's `supabase.auth`. */
|
|
366
|
+
declare function createSupabaseIdentity(auth: SupabaseAuthLike, options?: SupabaseIdentityOptions): VaultIdentity;
|
|
327
367
|
/** True when the server refused because the sign-in is not recent enough. */
|
|
328
368
|
declare function needsRecentSignIn(e: unknown): boolean;
|
|
329
369
|
|
|
@@ -704,6 +744,8 @@ interface ItemSettingsPatch {
|
|
|
704
744
|
browserFillEnabled?: boolean;
|
|
705
745
|
/** The complete list of websites (used to add a promoted address). */
|
|
706
746
|
loginUrls?: string[];
|
|
747
|
+
/** Turn the whole item on (true) or off (false). */
|
|
748
|
+
active?: boolean;
|
|
707
749
|
}
|
|
708
750
|
interface NewFieldInput {
|
|
709
751
|
key: string;
|
|
@@ -1131,6 +1173,8 @@ interface VaultHostCapabilities {
|
|
|
1131
1173
|
/** Desktop: the native passkey importer (file chooser, parsing and keys stay native). */
|
|
1132
1174
|
nativeImport?: NativeImportBridge;
|
|
1133
1175
|
openUrl?: (url: string) => void;
|
|
1176
|
+
/** The host's own sign-in, offered when the session has ended (the web app: its login page, back here after). */
|
|
1177
|
+
signIn?: () => void;
|
|
1134
1178
|
/** A lock the host holds (`lock.ts`): while locked the vault shows Unlock and refuses every port call. */
|
|
1135
1179
|
lock?: VaultLock;
|
|
1136
1180
|
/** The host's clipboard: every copy goes through it; a secret is the host's to clear (`lock.ts`). */
|
|
@@ -1249,6 +1293,20 @@ interface ApiVaultPortOptions {
|
|
|
1249
1293
|
}
|
|
1250
1294
|
declare function createApiVaultPort(api: Api, options?: ApiVaultPortOptions): VaultPort;
|
|
1251
1295
|
|
|
1296
|
+
/**
|
|
1297
|
+
* Wrap any call that shows, copies or exports a secret. When the server answers "sign in again",
|
|
1298
|
+
* the person confirms it is them (Google, password, or an emailed code) and the call runs again —
|
|
1299
|
+
* they never see a dead "Authentication required" in the row.
|
|
1300
|
+
*/
|
|
1301
|
+
type Confirmed = <T>(run: () => Promise<T>) => Promise<T>;
|
|
1302
|
+
declare function useConfirmed(): Confirmed;
|
|
1303
|
+
declare function IdentityGate({ identity, children }: {
|
|
1304
|
+
identity: VaultIdentity | undefined;
|
|
1305
|
+
children: ReactNode;
|
|
1306
|
+
}): react.JSX.Element;
|
|
1307
|
+
/** True for the rejection a cancelled confirmation produces (callers stay quiet about it). */
|
|
1308
|
+
declare const wasCancelled: (e: unknown) => boolean;
|
|
1309
|
+
|
|
1252
1310
|
/** Reads the organization's ceilings. Raw knob values are fine: they are validated here. */
|
|
1253
1311
|
type GeneratorLimitsSource = () => Promise<{
|
|
1254
1312
|
maxPasswordLength?: unknown;
|
|
@@ -1265,4 +1323,4 @@ declare function GenerateButton({ onUse, label, limits, disabled }: {
|
|
|
1265
1323
|
disabled?: boolean;
|
|
1266
1324
|
}): react.JSX.Element | null;
|
|
1267
1325
|
|
|
1268
|
-
export { type ApiVaultPortOptions, CATEGORIES, type CategoryId, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, HIDDEN_ITEM_TAG, 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, isHiddenItem, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, sortItems };
|
|
1326
|
+
export { type ApiVaultPortOptions, CATEGORIES, CONFIRM_RETURN_KEY, type CategoryId, type Confirmed, type CopyOptions, DEFAULT_LOCATION, type DefinitionField, type FieldHandling, type FieldKind, GenerateButton, HIDDEN_ITEM_TAG, type IdentityAccount, IdentityGate, type IdentityMethod, type ItemDraft, LOCKED_MESSAGE, type NoticeKind, type Notify, type ReturnStore, type SaveResult, type SupabaseAuthLike, type SupabaseIdentityOptions, 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, isHiddenItem, locationFromParams, locationToParams, loginSiteOf, matchesQuery, needsRecentSignIn, parseDefinitions, siteDomainOf, sortItems, useConfirmed, wasCancelled };
|