@haex-space/vault-sdk 5.3.0 → 5.4.1
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 +24 -0
- package/dist/autofill.d.mts +40 -0
- package/dist/autofill.d.ts +40 -0
- package/dist/autofill.js +353 -0
- package/dist/autofill.js.map +1 -0
- package/dist/autofill.mjs +346 -0
- package/dist/autofill.mjs.map +1 -0
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.mjs +1 -1
- package/dist/node.mjs.map +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/passgen.d.mts +28 -0
- package/dist/passgen.d.ts +28 -0
- package/dist/passgen.js +366 -0
- package/dist/passgen.js.map +1 -0
- package/dist/passgen.mjs +362 -0
- package/dist/passgen.mjs.map +1 -0
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.js +2 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +1 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +2 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +44 -6
package/README.md
CHANGED
|
@@ -1697,6 +1697,30 @@ different rules. From Node.js the same functions are available as `verifyBundle`
|
|
|
1697
1697
|
- No way to bypass permission system
|
|
1698
1698
|
- Audit trail for all cross-extension access
|
|
1699
1699
|
|
|
1700
|
+
## Autofill Rule & Password Generator (Browser)
|
|
1701
|
+
|
|
1702
|
+
Two rules of haex-pass have one implementation each, a Rust crate that holzi uses natively. The
|
|
1703
|
+
SDK ships their WebAssembly builds as browser entries; the module is part of the entry's code, so
|
|
1704
|
+
they also work in a browser extension's content script. A page that runs them needs
|
|
1705
|
+
`'wasm-unsafe-eval'` in its `script-src`.
|
|
1706
|
+
|
|
1707
|
+
```typescript
|
|
1708
|
+
import { initAutofill, mapFields } from '@haex-space/vault-sdk/autofill'
|
|
1709
|
+
import { generatePassword, initPassgen } from '@haex-space/vault-sdk/passgen'
|
|
1710
|
+
|
|
1711
|
+
await initAutofill() // once; the functions are synchronous afterwards
|
|
1712
|
+
mapFields([{ inputType: 'email', name: 'email' }], { keys: ['username', 'password'] })
|
|
1713
|
+
// → [{ kind: 'key', key: 'username' }]
|
|
1714
|
+
|
|
1715
|
+
await initPassgen()
|
|
1716
|
+
generatePassword({ length: 24, symbols: false }) // → { value: '…' } or { error: 'no_class' }
|
|
1717
|
+
```
|
|
1718
|
+
|
|
1719
|
+
- `@haex-space/vault-sdk/autofill` (`crates/haex-autofill`): `mapFields`, `showsIcon`,
|
|
1720
|
+
`isOtpField`, `fieldKind`, `fieldIdentifier`. Values never pass through the rule.
|
|
1721
|
+
- `@haex-space/vault-sdk/passgen` (`crates/haex-passgen`): `generatePassword`, with rejection
|
|
1722
|
+
sampling, every chosen class at least once and an error code instead of an empty password.
|
|
1723
|
+
|
|
1700
1724
|
## TypeScript Support
|
|
1701
1725
|
|
|
1702
1726
|
Full TypeScript support included:
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** What a page tells about one input field. */
|
|
2
|
+
interface FieldFacts {
|
|
3
|
+
/** The `type` attribute (`text`, `password`, `email`, …). */
|
|
4
|
+
inputType?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
autocomplete?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The keys of an entry's fields that hold a value, its own aliases and whether it has a TOTP. */
|
|
11
|
+
interface EntryKeys {
|
|
12
|
+
keys: string[];
|
|
13
|
+
/** The entry's own autofill aliases per key; they replace the defaults of that key. */
|
|
14
|
+
aliases?: Record<string, string[]> | null;
|
|
15
|
+
hasTotp?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** What a field gets: the value of an entry key, or the entry's current one-time code. */
|
|
18
|
+
type Target = {
|
|
19
|
+
kind: "key";
|
|
20
|
+
key: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "otp";
|
|
23
|
+
};
|
|
24
|
+
/** What a field asks for. */
|
|
25
|
+
type FieldKind = "username" | "password" | "email" | "otp" | "text";
|
|
26
|
+
/** Loads the module; later calls return the same promise. */
|
|
27
|
+
declare function initAutofill(): Promise<void>;
|
|
28
|
+
/** The kind of a field. */
|
|
29
|
+
declare function fieldKind(field: FieldFacts): FieldKind;
|
|
30
|
+
/** The identifier the rule matches entry keys against. */
|
|
31
|
+
declare function fieldIdentifier(field: FieldFacts): string;
|
|
32
|
+
/** Whether a field takes a one-time code; `aliases` are the entry's own aliases, if any. */
|
|
33
|
+
declare function isOtpField(field: FieldFacts, aliases?: Record<string, string[]> | null): boolean;
|
|
34
|
+
/** The target of every field for `entry`, in the order of `fields`; `null` leaves a field empty. */
|
|
35
|
+
declare function mapFields(fields: FieldFacts[], entry: EntryKeys): (Target | null)[];
|
|
36
|
+
/** Whether to offer filling `field` with one of `entries`, the entries that match the page. */
|
|
37
|
+
declare function showsIcon(field: FieldFacts, entries: EntryKeys[]): boolean;
|
|
38
|
+
|
|
39
|
+
export { fieldIdentifier, fieldKind, initAutofill, isOtpField, mapFields, showsIcon };
|
|
40
|
+
export type { EntryKeys, FieldFacts, FieldKind, Target };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** What a page tells about one input field. */
|
|
2
|
+
interface FieldFacts {
|
|
3
|
+
/** The `type` attribute (`text`, `password`, `email`, …). */
|
|
4
|
+
inputType?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
autocomplete?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The keys of an entry's fields that hold a value, its own aliases and whether it has a TOTP. */
|
|
11
|
+
interface EntryKeys {
|
|
12
|
+
keys: string[];
|
|
13
|
+
/** The entry's own autofill aliases per key; they replace the defaults of that key. */
|
|
14
|
+
aliases?: Record<string, string[]> | null;
|
|
15
|
+
hasTotp?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** What a field gets: the value of an entry key, or the entry's current one-time code. */
|
|
18
|
+
type Target = {
|
|
19
|
+
kind: "key";
|
|
20
|
+
key: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "otp";
|
|
23
|
+
};
|
|
24
|
+
/** What a field asks for. */
|
|
25
|
+
type FieldKind = "username" | "password" | "email" | "otp" | "text";
|
|
26
|
+
/** Loads the module; later calls return the same promise. */
|
|
27
|
+
declare function initAutofill(): Promise<void>;
|
|
28
|
+
/** The kind of a field. */
|
|
29
|
+
declare function fieldKind(field: FieldFacts): FieldKind;
|
|
30
|
+
/** The identifier the rule matches entry keys against. */
|
|
31
|
+
declare function fieldIdentifier(field: FieldFacts): string;
|
|
32
|
+
/** Whether a field takes a one-time code; `aliases` are the entry's own aliases, if any. */
|
|
33
|
+
declare function isOtpField(field: FieldFacts, aliases?: Record<string, string[]> | null): boolean;
|
|
34
|
+
/** The target of every field for `entry`, in the order of `fields`; `null` leaves a field empty. */
|
|
35
|
+
declare function mapFields(fields: FieldFacts[], entry: EntryKeys): (Target | null)[];
|
|
36
|
+
/** Whether to offer filling `field` with one of `entries`, the entries that match the page. */
|
|
37
|
+
declare function showsIcon(field: FieldFacts, entries: EntryKeys[]): boolean;
|
|
38
|
+
|
|
39
|
+
export { fieldIdentifier, fieldKind, initAutofill, isOtpField, mapFields, showsIcon };
|
|
40
|
+
export type { EntryKeys, FieldFacts, FieldKind, Target };
|