@c9up/warden 0.1.21 → 0.1.22
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/native/generated.d.ts +8 -0
- package/dist/native/generated.d.ts.map +1 -0
- package/dist/native/generated.js +7 -0
- package/dist/native/generated.js.map +1 -0
- package/dist/native.d.ts +8 -9
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +3 -2
- package/scripts/build-napi-types.mjs +68 -0
- package/scripts/generate-napi-types.mjs +153 -0
- package/src/native/generated.ts +23 -0
- package/src/native.ts +8 -9
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function jwtSign(payload: string, secret: string): string;
|
|
2
|
+
export declare function jwtVerify(token: string, secret: string): string;
|
|
3
|
+
export declare function constantTimeEq(a: string, b: string): boolean;
|
|
4
|
+
export declare function hmacSign(data: string, secret: string): string;
|
|
5
|
+
export declare function hmacVerify(data: string, signature: string, secret: string): boolean;
|
|
6
|
+
export declare function randomBytes(len: number): string;
|
|
7
|
+
export declare function randomHex(len: number): string;
|
|
8
|
+
//# sourceMappingURL=generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../src/native/generated.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;AAEzE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;AAEzE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;AAEtE,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;AAEvE,MAAM,CAAC,OAAO,UAAU,UAAU,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;AAEX,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// GENERATED FROM THE RUST — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// Produced by scripts/generate-napi-types.mjs from napi-derive's type-def
|
|
4
|
+
// output. Editing this file by hand puts it back where it started: a
|
|
5
|
+
// description that can disagree with the code it describes.
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.js","sourceRoot":"","sources":["../../src/native/generated.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,0EAA0E;AAC1E,qEAAqE;AACrE,4DAA4D"}
|
package/dist/native.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The engine's surface, as the Rust declares it.
|
|
3
|
+
*
|
|
4
|
+
* Derived from `./native/generated.js` — written by `pnpm build:napi-types`
|
|
5
|
+
* from napi-derive's own `type-def` output — rather than restated here, where
|
|
6
|
+
* nothing would notice a `pub fn` gaining a parameter or changing its return.
|
|
7
|
+
*/
|
|
8
|
+
export type NativeWarden = typeof import("./native/generated.js");
|
|
10
9
|
/** Whether the Rust NAPI engine loaded. */
|
|
11
10
|
export declare function isNativeAvailable(): boolean;
|
|
12
11
|
/** Get the native engine. Returns undefined if not loaded — caller must throw. */
|
package/dist/native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAuBA
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,uBAAuB,CAAC,CAAC;AAalE,2CAA2C;AAC3C,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,kFAAkF;AAClF,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvD"}
|
package/dist/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,GAA2B;IAC3C,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,YAAY,EAAE,YAAY;IAC1B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,gBAAgB;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,GAA2B;IAC3C,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,YAAY,EAAE,YAAY;IAC1B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,gBAAgB;CAC7B,CAAC;AAWF,IAAI,MAAgC,CAAC;AAErC,IAAI,CAAC;IACJ,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;IAClD,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;AACF,CAAC;AAAC,MAAM,CAAC;IACR,kFAAkF;AACnF,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,iBAAiB;IAChC,OAAO,MAAM,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,YAAY;IAC3B,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/warden",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Warden — Authentication & authorization for the Ream framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsc -p tsconfig.build.json",
|
|
84
84
|
"build:rust": "cargo build --release -p warden-engine-napi",
|
|
85
|
-
"build:napi": "pnpm build:rust && node scripts/copy-napi.mjs",
|
|
85
|
+
"build:napi": "pnpm build:rust && pnpm build:napi-types && node scripts/copy-napi.mjs",
|
|
86
|
+
"build:napi-types": "node scripts/build-napi-types.mjs",
|
|
86
87
|
"test": "vitest run",
|
|
87
88
|
"test:rust": "cargo test -p warden-engine",
|
|
88
89
|
"lint": "biome check src/",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Regenerate `src/native/generated.ts` from the Rust.
|
|
4
|
+
*
|
|
5
|
+
* Node rather than a shell script because this runs inside `build:napi`, and
|
|
6
|
+
* that runs on the Windows prebuild runner too: a bash `mktemp` there hands
|
|
7
|
+
* cargo a `/tmp/...` path the native proc-macro cannot write to, so the
|
|
8
|
+
* type-def file comes back empty and the build fails for no visible reason.
|
|
9
|
+
*
|
|
10
|
+
* One crate at a time on purpose: napi-derive APPENDS to `TYPE_DEF_TMP_PATH`
|
|
11
|
+
* while cargo compiles, and a parallel build interleaves the writes —
|
|
12
|
+
* definitions go missing, silently, and the generated file comes out short.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { execFileSync } from 'node:child_process'
|
|
16
|
+
import { createRequire } from 'node:module'
|
|
17
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
18
|
+
import { tmpdir } from 'node:os'
|
|
19
|
+
import { dirname, join } from 'node:path'
|
|
20
|
+
import { fileURLToPath } from 'node:url'
|
|
21
|
+
|
|
22
|
+
const CRATES = ['warden-engine-napi']
|
|
23
|
+
|
|
24
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
25
|
+
const output = join('src', 'native', 'generated.ts')
|
|
26
|
+
const scratch = mkdtempSync(join(tmpdir(), 'napi-types-'))
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const lines = []
|
|
30
|
+
for (const crate of CRATES) {
|
|
31
|
+
const perCrate = join(scratch, `${crate}.jsonl`)
|
|
32
|
+
writeFileSync(perCrate, '')
|
|
33
|
+
execFileSync('cargo', ['build', '-p', crate], {
|
|
34
|
+
cwd: packageRoot,
|
|
35
|
+
env: { ...process.env, TYPE_DEF_TMP_PATH: perCrate },
|
|
36
|
+
stdio: ['ignore', 'ignore', 'inherit'],
|
|
37
|
+
})
|
|
38
|
+
const emitted = readFileSync(perCrate, 'utf8').split('\n').filter(Boolean)
|
|
39
|
+
if (emitted.length === 0) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`[napi-types] ${crate} emitted nothing — is napi-derive's "type-def" feature on?`,
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
lines.push(...emitted)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const combined = join(scratch, 'combined.jsonl')
|
|
48
|
+
writeFileSync(combined, `${lines.join('\n')}\n`)
|
|
49
|
+
|
|
50
|
+
execFileSync(
|
|
51
|
+
process.execPath,
|
|
52
|
+
[join('scripts', 'generate-napi-types.mjs'), combined, output],
|
|
53
|
+
{ cwd: packageRoot, stdio: 'inherit' },
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
// Formatted here rather than excluded from the linter: the file is checked
|
|
57
|
+
// in, so it should read like the rest of the tree — and formatting it at
|
|
58
|
+
// generation means it never shows up as a diff someone has to fix by hand.
|
|
59
|
+
// Resolved through the package entry rather than `node_modules/.bin`, whose
|
|
60
|
+
// shim is a shell script the Windows runner cannot execute directly.
|
|
61
|
+
const biome = createRequire(import.meta.url).resolve('@biomejs/biome/bin/biome')
|
|
62
|
+
execFileSync(process.execPath, [biome, 'format', '--write', output], {
|
|
63
|
+
cwd: packageRoot,
|
|
64
|
+
stdio: ['ignore', 'ignore', 'inherit'],
|
|
65
|
+
})
|
|
66
|
+
} finally {
|
|
67
|
+
rmSync(scratch, { recursive: true, force: true })
|
|
68
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Generate the TypeScript surface of the native module FROM the Rust.
|
|
4
|
+
*
|
|
5
|
+
* `napi-derive`'s `type-def` feature emits one JSON line per exported item
|
|
6
|
+
* while cargo compiles. Those lines are the source of truth: they are derived
|
|
7
|
+
* from the `#[napi]` items themselves, so a signature cannot drift from the
|
|
8
|
+
* Rust without this file changing.
|
|
9
|
+
*
|
|
10
|
+
* Hand-written interfaces are what this replaces, and they do drift — nothing
|
|
11
|
+
* on the TypeScript side notices when a `pub fn` gains a parameter or stops
|
|
12
|
+
* being `async`.
|
|
13
|
+
*
|
|
14
|
+
* One thing napi-rs cannot infer: the shape of a `JsFunction` callback. It
|
|
15
|
+
* emits `(...args: any[]) => any`. Any such parameter is refined below, by
|
|
16
|
+
* name, and the script fails if a refinement no longer matches anything — so
|
|
17
|
+
* the table cannot rot either.
|
|
18
|
+
*
|
|
19
|
+
* TYPE_DEF_TMP_PATH=<file> cargo build -p <crate>
|
|
20
|
+
* node scripts/generate-napi-types.mjs <file> <out.d.ts>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Callback signatures napi-rs erases to `any`, restored here.
|
|
27
|
+
*
|
|
28
|
+
* Keyed by `<owner>.<method>`; the value replaces the whole parameter. Every
|
|
29
|
+
* entry must match, or the script fails: a stale refinement is how a hand
|
|
30
|
+
* annotation quietly stops describing the Rust.
|
|
31
|
+
*
|
|
32
|
+
* Empty while this crate exposes no `JsFunction` parameter — add an entry the
|
|
33
|
+
* day one appears, rather than letting an `any` through.
|
|
34
|
+
*/
|
|
35
|
+
const CALLBACK_REFINEMENTS = {}
|
|
36
|
+
|
|
37
|
+
const [input, output] = process.argv.slice(2)
|
|
38
|
+
if (!input || !output) {
|
|
39
|
+
console.error('usage: generate-napi-types.mjs <type-def file> <out.d.ts>')
|
|
40
|
+
process.exit(2)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const entries = readFileSync(input, 'utf8')
|
|
44
|
+
.split('\n')
|
|
45
|
+
.map((l) => l.trim())
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.map((l) => JSON.parse(l))
|
|
48
|
+
|
|
49
|
+
const used = new Set()
|
|
50
|
+
|
|
51
|
+
/** Apply the refinements that belong to `owner`, tracking which ones matched. */
|
|
52
|
+
function refine(owner, body) {
|
|
53
|
+
let out = body
|
|
54
|
+
for (const [key, { from, to }] of Object.entries(CALLBACK_REFINEMENTS)) {
|
|
55
|
+
const [entryOwner] = key.split('.')
|
|
56
|
+
if (entryOwner !== owner) continue
|
|
57
|
+
if (out.includes(from)) {
|
|
58
|
+
out = out.replace(from, to)
|
|
59
|
+
used.add(key)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* JSDoc as emitted by napi-derive, indented to sit above its member.
|
|
67
|
+
*
|
|
68
|
+
* `*` followed by `/` inside the text closes the comment early — a Rust doc
|
|
69
|
+
* example holding a cron expression (`0 */5 * * *`) is enough to do it, and
|
|
70
|
+
* the generated file then fails to parse. Escaped rather than stripped, so the
|
|
71
|
+
* example still reads correctly.
|
|
72
|
+
*/
|
|
73
|
+
function docBlock(doc, indent = '') {
|
|
74
|
+
if (!doc) return ''
|
|
75
|
+
// Escape every `*/` EXCEPT the one that closes the block. A Rust doc example
|
|
76
|
+
// holding a cron expression (`0 */5 * * *`) closes the comment early
|
|
77
|
+
// otherwise, and the generated file stops parsing — but escaping the closer
|
|
78
|
+
// too breaks it just as thoroughly, whether the block spans one line or many.
|
|
79
|
+
const closer = doc.lastIndexOf('*/')
|
|
80
|
+
const escaped =
|
|
81
|
+
closer === -1
|
|
82
|
+
? doc
|
|
83
|
+
: doc.slice(0, closer).replaceAll('*/', '*\\/') + doc.slice(closer)
|
|
84
|
+
return (
|
|
85
|
+
escaped
|
|
86
|
+
.split('\n')
|
|
87
|
+
.filter((l) => l.length > 0)
|
|
88
|
+
.map((l) => `${indent}${l}`)
|
|
89
|
+
.join('\n') + '\n'
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const interfaces = entries.filter((e) => e.kind === 'interface')
|
|
94
|
+
const structs = entries.filter((e) => e.kind === 'struct')
|
|
95
|
+
const impls = new Map(entries.filter((e) => e.kind === 'impl').map((e) => [e.name, e]))
|
|
96
|
+
const fns = entries.filter((e) => e.kind === 'fn')
|
|
97
|
+
|
|
98
|
+
const out = [
|
|
99
|
+
'// GENERATED FROM THE RUST — do not edit.',
|
|
100
|
+
'//',
|
|
101
|
+
"// Produced by scripts/generate-napi-types.mjs from napi-derive's type-def",
|
|
102
|
+
'// output. Editing this file by hand puts it back where it started: a',
|
|
103
|
+
'// description that can disagree with the code it describes.',
|
|
104
|
+
'',
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
for (const iface of interfaces) {
|
|
108
|
+
out.push(docBlock(iface.js_doc))
|
|
109
|
+
out.push(`export interface ${iface.name} {`)
|
|
110
|
+
for (const line of iface.def.split('\n')) {
|
|
111
|
+
out.push(line ? ` ${line.trim()}` : '')
|
|
112
|
+
}
|
|
113
|
+
out.push('}', '')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const struct of structs) {
|
|
117
|
+
const impl = impls.get(struct.name)
|
|
118
|
+
out.push(docBlock(struct.js_doc))
|
|
119
|
+
out.push(`export declare class ${struct.name} {`)
|
|
120
|
+
if (impl) {
|
|
121
|
+
for (const line of refine(struct.name, impl.def).split('\n')) {
|
|
122
|
+
out.push(line ? ` ${line.trim()}` : '')
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
out.push('}', '')
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const fn of fns) {
|
|
129
|
+
out.push(docBlock(fn.js_doc))
|
|
130
|
+
// napi-derive emits the whole declaration for a function, unlike a struct
|
|
131
|
+
// where `def` holds only the members.
|
|
132
|
+
const declaration = fn.def.trim()
|
|
133
|
+
out.push(
|
|
134
|
+
declaration.startsWith('export declare function')
|
|
135
|
+
? `${declaration};`
|
|
136
|
+
: `export declare function ${fn.name}${declaration};`,
|
|
137
|
+
'',
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const stale = Object.keys(CALLBACK_REFINEMENTS).filter((k) => !used.has(k))
|
|
142
|
+
if (stale.length > 0) {
|
|
143
|
+
console.error(
|
|
144
|
+
`[napi-types] refinement(s) that matched nothing: ${stale.join(', ')}\n` +
|
|
145
|
+
'[napi-types] the Rust changed under them — update or remove the entry.',
|
|
146
|
+
)
|
|
147
|
+
process.exit(1)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
writeFileSync(output, out.join('\n'))
|
|
151
|
+
console.log(
|
|
152
|
+
`[napi-types] ${output} — ${interfaces.length} interface(s), ${structs.length} class(es), ${fns.length} function(s)`,
|
|
153
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// GENERATED FROM THE RUST — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// Produced by scripts/generate-napi-types.mjs from napi-derive's type-def
|
|
4
|
+
// output. Editing this file by hand puts it back where it started: a
|
|
5
|
+
// description that can disagree with the code it describes.
|
|
6
|
+
|
|
7
|
+
export declare function jwtSign(payload: string, secret: string): string;
|
|
8
|
+
|
|
9
|
+
export declare function jwtVerify(token: string, secret: string): string;
|
|
10
|
+
|
|
11
|
+
export declare function constantTimeEq(a: string, b: string): boolean;
|
|
12
|
+
|
|
13
|
+
export declare function hmacSign(data: string, secret: string): string;
|
|
14
|
+
|
|
15
|
+
export declare function hmacVerify(
|
|
16
|
+
data: string,
|
|
17
|
+
signature: string,
|
|
18
|
+
secret: string,
|
|
19
|
+
): boolean;
|
|
20
|
+
|
|
21
|
+
export declare function randomBytes(len: number): string;
|
|
22
|
+
|
|
23
|
+
export declare function randomHex(len: number): string;
|
package/src/native.ts
CHANGED
|
@@ -21,15 +21,14 @@ const platformMap: Record<string, string> = {
|
|
|
21
21
|
"win32-x64": "win32-x64-msvc",
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* The engine's surface, as the Rust declares it.
|
|
26
|
+
*
|
|
27
|
+
* Derived from `./native/generated.js` — written by `pnpm build:napi-types`
|
|
28
|
+
* from napi-derive's own `type-def` output — rather than restated here, where
|
|
29
|
+
* nothing would notice a `pub fn` gaining a parameter or changing its return.
|
|
30
|
+
*/
|
|
31
|
+
export type NativeWarden = typeof import("./native/generated.js");
|
|
33
32
|
|
|
34
33
|
let native: NativeWarden | undefined;
|
|
35
34
|
|