@di-framework/cli-plugin-platform 0.0.1 → 6.0.2
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 +408 -0
- package/dist/actor-protocol.d.ts +4 -0
- package/dist/actor-protocol.js +162 -0
- package/dist/actors.d.ts +31 -0
- package/dist/actors.js +296 -0
- package/dist/args.d.ts +15 -0
- package/dist/args.js +66 -0
- package/dist/assets/http-adapter.js +876 -0
- package/dist/assets/platform/.gitignore.tmpl +6 -0
- package/dist/assets/platform/Pulumi.yaml.tmpl +6 -0
- package/dist/assets/platform/README.md +208 -0
- package/dist/assets/platform/index.ts.tmpl +2 -0
- package/dist/assets/platform/package.json.tmpl +18 -0
- package/dist/assets/platform/tsconfig.json +11 -0
- package/dist/assets/queue-adapter.js +60 -0
- package/dist/assets/sqlite/BUILD-INFO.txt +13 -0
- package/dist/assets/sqlite/SHA256SUMS +2 -0
- package/dist/assets/sqlite/di-framework-sqlite.wasm +0 -0
- package/dist/assets/sqlite/di-framework-sqlite.wit +337 -0
- package/dist/assets/wit/deps/LICENSE.md +8 -0
- package/dist/assets/wit/deps/di-framework-queues/package.wit +18 -0
- package/dist/assets/wit/deps/di-framework-sqlite/package.wit +211 -0
- package/dist/assets/wit/deps/wasi-cli/package.wit +70 -0
- package/dist/assets/wit/deps/wasi-clocks/package.wit +42 -0
- package/dist/assets/wit/deps/wasi-config/package.wit +15 -0
- package/dist/assets/wit/deps/wasi-filesystem/package.wit +184 -0
- package/dist/assets/wit/deps/wasi-http/package.wit +170 -0
- package/dist/assets/wit/deps/wasi-random/package.wit +17 -0
- package/dist/assets/wit/deps/wasi-sockets/package.wit +105 -0
- package/dist/assets/wit/deps/wasi-tls/package.wit +26 -0
- package/dist/assets/wit/deps/wasmcloud-blobstore/package.wit +153 -0
- package/dist/assets/wit/deps/wasmcloud-keyvalue/package.wit +370 -0
- package/dist/assets/wit/deps/wasmcloud-messaging/package.wit +125 -0
- package/dist/assets/wit/deps/wasmcloud-postgres/package.wit +435 -0
- package/dist/assets/wit/deps/wasmcloud-secrets/package.wit +80 -0
- package/dist/async-transform.d.ts +3 -0
- package/dist/async-transform.js +60 -0
- package/dist/bindings.d.ts +34 -0
- package/dist/bindings.js +307 -0
- package/dist/build.d.ts +29 -0
- package/dist/build.js +325 -0
- package/dist/command.d.ts +3 -0
- package/dist/command.js +141 -0
- package/dist/control/auth.d.ts +18 -0
- package/dist/control/auth.js +89 -0
- package/dist/control/cron.d.ts +7 -0
- package/dist/control/cron.js +86 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.js +4 -0
- package/dist/control/network.d.ts +12 -0
- package/dist/control/network.js +49 -0
- package/dist/control/queues.d.ts +15 -0
- package/dist/control/queues.js +77 -0
- package/dist/cron.d.ts +26 -0
- package/dist/cron.js +239 -0
- package/dist/deploy.d.ts +29 -0
- package/dist/deploy.js +57 -0
- package/dist/deps.d.ts +96 -0
- package/dist/deps.js +303 -0
- package/dist/destroy.d.ts +3 -0
- package/dist/destroy.js +24 -0
- package/dist/dev-runner.d.ts +24 -0
- package/dist/dev-runner.js +83 -0
- package/dist/dev.d.ts +8 -0
- package/dist/dev.js +76 -0
- package/dist/discovery.d.ts +15 -0
- package/dist/discovery.js +182 -0
- package/dist/doctor.d.ts +8 -0
- package/dist/doctor.js +82 -0
- package/dist/guests.d.ts +9 -0
- package/dist/guests.js +56 -0
- package/dist/host-interface.d.ts +29 -0
- package/dist/host-interface.js +142 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +39 -0
- package/dist/kubernetes.d.ts +9 -0
- package/dist/kubernetes.js +17 -0
- package/dist/managed-bindings.d.ts +9 -0
- package/dist/managed-bindings.js +150 -0
- package/dist/manifest.d.ts +36 -0
- package/dist/manifest.js +257 -0
- package/dist/namespace.d.ts +2 -0
- package/dist/namespace.js +4 -0
- package/dist/node-compat/async-hooks.d.ts +29 -0
- package/dist/node-compat/async-hooks.js +80 -0
- package/dist/node-compat/bootstrap.d.ts +1 -0
- package/dist/node-compat/bootstrap.js +9 -0
- package/dist/node-compat/bytes.d.ts +7 -0
- package/dist/node-compat/bytes.js +41 -0
- package/dist/node-compat/crypto-hash.d.ts +27 -0
- package/dist/node-compat/crypto-hash.js +108 -0
- package/dist/node-compat/crypto-subtle.d.ts +59 -0
- package/dist/node-compat/crypto-subtle.js +288 -0
- package/dist/node-compat/crypto.d.ts +136 -0
- package/dist/node-compat/crypto.js +142 -0
- package/dist/node-compat/dgram.d.ts +49 -0
- package/dist/node-compat/dgram.js +197 -0
- package/dist/node-compat/env.d.ts +6 -0
- package/dist/node-compat/env.js +88 -0
- package/dist/node-compat/fetch-runtime.d.ts +80 -0
- package/dist/node-compat/fetch-runtime.js +314 -0
- package/dist/node-compat/fs.d.ts +84 -0
- package/dist/node-compat/fs.js +285 -0
- package/dist/node-compat/http-parser.d.ts +40 -0
- package/dist/node-compat/http-parser.js +185 -0
- package/dist/node-compat/http.d.ts +130 -0
- package/dist/node-compat/http.js +688 -0
- package/dist/node-compat/https.d.ts +28 -0
- package/dist/node-compat/https.js +88 -0
- package/dist/node-compat/module.d.ts +11 -0
- package/dist/node-compat/module.js +35 -0
- package/dist/node-compat/net.d.ts +119 -0
- package/dist/node-compat/net.js +441 -0
- package/dist/node-compat/process.d.ts +25 -0
- package/dist/node-compat/process.js +63 -0
- package/dist/node-compat/runtime-application.d.ts +4 -0
- package/dist/node-compat/runtime-application.js +24 -0
- package/dist/node-compat/seed-virtual.d.ts +6 -0
- package/dist/node-compat/seed-virtual.js +6 -0
- package/dist/node-compat/seed.d.ts +20 -0
- package/dist/node-compat/seed.js +106 -0
- package/dist/node-compat/socket-address.d.ts +35 -0
- package/dist/node-compat/socket-address.js +162 -0
- package/dist/node-compat/timers.d.ts +32 -0
- package/dist/node-compat/timers.js +96 -0
- package/dist/node-compat/tls.d.ts +57 -0
- package/dist/node-compat/tls.js +290 -0
- package/dist/node-compat/wasi-random.d.ts +2 -0
- package/dist/node-compat/wasi-random.js +25 -0
- package/dist/node-compat/wasi-sockets.d.ts +47 -0
- package/dist/node-compat/wasi-sockets.js +134 -0
- package/dist/oci.d.ts +9 -0
- package/dist/oci.js +9 -0
- package/dist/paths.d.ts +7 -0
- package/dist/paths.js +13 -0
- package/dist/platform-init.d.ts +13 -0
- package/dist/platform-init.js +265 -0
- package/dist/platform.d.ts +22 -0
- package/dist/platform.js +170 -0
- package/dist/project.d.ts +39 -0
- package/dist/project.js +130 -0
- package/dist/publish.d.ts +15 -0
- package/dist/publish.js +57 -0
- package/dist/pulumi.d.ts +4 -0
- package/dist/pulumi.js +27 -0
- package/dist/queues-module.d.ts +4 -0
- package/dist/queues-module.js +89 -0
- package/dist/queues.d.ts +16 -0
- package/dist/queues.js +167 -0
- package/dist/registry.d.ts +16 -0
- package/dist/registry.js +27 -0
- package/dist/service.d.ts +162 -0
- package/dist/service.js +678 -0
- package/dist/support.d.ts +14 -0
- package/dist/support.js +37 -0
- package/dist/target.d.ts +18 -0
- package/dist/target.js +45 -0
- package/dist/toml.d.ts +6 -0
- package/dist/toml.js +245 -0
- package/dist/wash-dev.d.ts +18 -0
- package/dist/wash-dev.js +80 -0
- package/dist/wit.d.ts +76 -0
- package/dist/wit.js +248 -0
- package/dist/workload-members.d.ts +12 -0
- package/dist/workload-members.js +136 -0
- package/dist/workload.d.ts +45 -0
- package/dist/workload.js +457 -0
- package/package.json +55 -8
- package/src/index.ts +0 -2
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { CommandFailure } from '@di-framework/cli-extension';
|
|
5
|
+
import { captureKubectl, runKubectl } from './kubernetes.js';
|
|
6
|
+
export const ASSOCIATION_WORKLOAD_LABEL = 'di-framework.dev/binding-workload';
|
|
7
|
+
const RESOURCE = 'servicebindings.platform.di-framework.dev';
|
|
8
|
+
export function associationName(workload, bindingName) {
|
|
9
|
+
return `di-bind-${createHash('sha256')
|
|
10
|
+
.update(JSON.stringify([workload, bindingName]))
|
|
11
|
+
.digest('hex')
|
|
12
|
+
.slice(0, 32)}`;
|
|
13
|
+
}
|
|
14
|
+
function fail(message) {
|
|
15
|
+
throw new CommandFailure('WASMCLOUD_MANAGED_BINDING_FAILED', message, 3);
|
|
16
|
+
}
|
|
17
|
+
async function getPostgresServiceUid(project, connection, serviceName, deps) {
|
|
18
|
+
const result = await captureKubectl(deps, connection, ['get', 'backingservices.platform.di-framework.dev', serviceName, '-o', 'json'], project.projectRoot);
|
|
19
|
+
if (result.exitCode !== 0)
|
|
20
|
+
fail(`BackingService ${serviceName} is unavailable in namespace ${connection.namespace}`);
|
|
21
|
+
const service = JSON.parse(result.stdout);
|
|
22
|
+
if (service.metadata.deletionTimestamp)
|
|
23
|
+
fail(`BackingService ${serviceName} is deleting; new associations are refused`);
|
|
24
|
+
if (service.spec.type !== 'postgres')
|
|
25
|
+
fail(`BackingService ${serviceName} must have type postgres`);
|
|
26
|
+
return service.metadata.uid;
|
|
27
|
+
}
|
|
28
|
+
function validateAssociationPeers(workloadName, binding, peers) {
|
|
29
|
+
const name = associationName(workloadName, binding.name);
|
|
30
|
+
for (const peer of peers) {
|
|
31
|
+
if (peer.metadata.name === name) {
|
|
32
|
+
if (peer.metadata.labels?.[ASSOCIATION_WORKLOAD_LABEL] !== workloadName ||
|
|
33
|
+
peer.metadata.labels?.['app.kubernetes.io/managed-by'] !== 'di-framework')
|
|
34
|
+
fail(`Refusing to adopt ServiceBinding ${peer.metadata.name}`);
|
|
35
|
+
if (peer.metadata.deletionTimestamp)
|
|
36
|
+
fail(`ServiceBinding ${peer.metadata.name} is still deleting`);
|
|
37
|
+
}
|
|
38
|
+
else if (peer.spec.bindingName === binding.name &&
|
|
39
|
+
!peer.metadata.deletionTimestamp &&
|
|
40
|
+
(peer.spec.serviceName !== binding.serviceName || peer.spec.capability !== 'postgres')) {
|
|
41
|
+
fail(`Binding ${binding.name} is already associated with another service by ${peer.metadata.name}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function validateBindingReferences(project, connection, bindings, deps) {
|
|
46
|
+
const result = await captureKubectl(deps, connection, ['get', RESOURCE, '-o', 'json'], project.projectRoot);
|
|
47
|
+
if (result.exitCode !== 0)
|
|
48
|
+
fail('Cannot read ServiceBindings; install the platform backing-service CRDs and check tenant permissions');
|
|
49
|
+
const peers = JSON.parse(result.stdout).items;
|
|
50
|
+
const serviceUids = new Map();
|
|
51
|
+
for (const binding of bindings) {
|
|
52
|
+
const uid = await getPostgresServiceUid(project, connection, binding.serviceName, deps);
|
|
53
|
+
serviceUids.set(binding.name, uid);
|
|
54
|
+
validateAssociationPeers(project.witName, binding, peers);
|
|
55
|
+
}
|
|
56
|
+
return serviceUids;
|
|
57
|
+
}
|
|
58
|
+
function writeServiceBindingManifest(project, connection, bindings) {
|
|
59
|
+
const items = bindings.map((binding) => ({
|
|
60
|
+
apiVersion: 'platform.di-framework.dev/v1alpha1',
|
|
61
|
+
kind: 'ServiceBinding',
|
|
62
|
+
metadata: {
|
|
63
|
+
name: associationName(project.witName, binding.name),
|
|
64
|
+
namespace: connection.namespace,
|
|
65
|
+
labels: {
|
|
66
|
+
'app.kubernetes.io/managed-by': 'di-framework',
|
|
67
|
+
[ASSOCIATION_WORKLOAD_LABEL]: project.witName,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
spec: {
|
|
71
|
+
serviceName: binding.serviceName,
|
|
72
|
+
bindingName: binding.name,
|
|
73
|
+
capability: 'postgres',
|
|
74
|
+
workloadName: project.witName,
|
|
75
|
+
},
|
|
76
|
+
}));
|
|
77
|
+
const directory = join(project.projectRoot, '.di-framework', 'deploy');
|
|
78
|
+
mkdirSync(directory, { recursive: true });
|
|
79
|
+
const path = join(directory, 'service-bindings.json');
|
|
80
|
+
writeFileSync(path, JSON.stringify({ apiVersion: 'v1', kind: 'List', items }, null, 2));
|
|
81
|
+
return path;
|
|
82
|
+
}
|
|
83
|
+
async function waitForManagedBinding(project, connection, binding, serviceUid, deps) {
|
|
84
|
+
const name = associationName(project.witName, binding.name);
|
|
85
|
+
let message = 'Waiting for provisioning';
|
|
86
|
+
for (let attempt = 0; attempt < 90; attempt++) {
|
|
87
|
+
const result = await captureKubectl(deps, connection, ['get', RESOURCE, name, '-o', 'json'], project.projectRoot);
|
|
88
|
+
if (result.exitCode !== 0)
|
|
89
|
+
fail(`Cannot read ServiceBinding ${name}`);
|
|
90
|
+
const association = JSON.parse(result.stdout);
|
|
91
|
+
const condition = association.status?.conditions?.find((c) => c.type === 'Ready');
|
|
92
|
+
message = condition?.message ?? message;
|
|
93
|
+
if (!association.metadata.deletionTimestamp &&
|
|
94
|
+
association.spec.serviceName === binding.serviceName &&
|
|
95
|
+
association.status?.observedGeneration === association.metadata.generation &&
|
|
96
|
+
association.status?.serviceRef?.uid === serviceUid &&
|
|
97
|
+
condition?.status === 'True')
|
|
98
|
+
return;
|
|
99
|
+
await deps.wait(2000);
|
|
100
|
+
}
|
|
101
|
+
fail(`ServiceBinding ${name} did not become ready: ${message}`);
|
|
102
|
+
}
|
|
103
|
+
export async function applyManagedBindings(project, connection, bindings, deps) {
|
|
104
|
+
const managed = bindings.filter((b) => b.serviceName !== undefined);
|
|
105
|
+
const desired = new Set(managed.map((b) => associationName(project.witName, b.name)));
|
|
106
|
+
if (!managed.length)
|
|
107
|
+
return desired;
|
|
108
|
+
// Validate every reference and ownership before applying any associations.
|
|
109
|
+
const serviceUids = await validateBindingReferences(project, connection, managed, deps);
|
|
110
|
+
const path = writeServiceBindingManifest(project, connection, managed);
|
|
111
|
+
await runKubectl(deps, connection, ['apply', '-f', path], project.projectRoot);
|
|
112
|
+
for (const binding of managed)
|
|
113
|
+
await waitForManagedBinding(project, connection, binding, serviceUids.get(binding.name), deps);
|
|
114
|
+
return desired;
|
|
115
|
+
}
|
|
116
|
+
/** Called only after a successful rollout, or after workload deletion completes. */
|
|
117
|
+
export async function cleanupManagedBindings(project, connection, desired, deps) {
|
|
118
|
+
const result = await captureKubectl(deps, connection, [
|
|
119
|
+
'get',
|
|
120
|
+
RESOURCE,
|
|
121
|
+
'-l',
|
|
122
|
+
`${ASSOCIATION_WORKLOAD_LABEL}=${project.witName},app.kubernetes.io/managed-by=di-framework`,
|
|
123
|
+
'-o',
|
|
124
|
+
'json',
|
|
125
|
+
'--ignore-not-found',
|
|
126
|
+
], project.projectRoot);
|
|
127
|
+
if (result.exitCode !== 0) {
|
|
128
|
+
if (/the server doesn't have a resource type|could not find the requested resource/i.test(result.stderr))
|
|
129
|
+
return;
|
|
130
|
+
fail('Cannot list obsolete deployment-owned ServiceBindings');
|
|
131
|
+
}
|
|
132
|
+
const items = result.stdout.trim()
|
|
133
|
+
? (JSON.parse(result.stdout).items ?? [])
|
|
134
|
+
: [];
|
|
135
|
+
for (const association of items) {
|
|
136
|
+
if (desired.has(association.metadata.name))
|
|
137
|
+
continue;
|
|
138
|
+
if (association.metadata.labels?.[ASSOCIATION_WORKLOAD_LABEL] !== project.witName ||
|
|
139
|
+
association.metadata.labels?.['app.kubernetes.io/managed-by'] !== 'di-framework')
|
|
140
|
+
continue;
|
|
141
|
+
await runKubectl(deps, connection, [
|
|
142
|
+
'delete',
|
|
143
|
+
RESOURCE,
|
|
144
|
+
association.metadata.name,
|
|
145
|
+
'--ignore-not-found',
|
|
146
|
+
'--wait=true',
|
|
147
|
+
'--timeout=180s',
|
|
148
|
+
], project.projectRoot);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RegistryInput } from './registry.js';
|
|
2
|
+
export declare const DEPLOY_MANIFEST_NAME = "di-framework.deploy.toml";
|
|
3
|
+
export declare const DEFAULT_DISCOVERY_EXCLUDE: string[];
|
|
4
|
+
export declare const ALWAYS_SKIP_DIRECTORIES: Set<string>;
|
|
5
|
+
export type DiscoveryConfig = {
|
|
6
|
+
include: string[];
|
|
7
|
+
exclude: string[];
|
|
8
|
+
};
|
|
9
|
+
export type ManagedTarget = {
|
|
10
|
+
kind: 'managed';
|
|
11
|
+
name: string;
|
|
12
|
+
platform: string;
|
|
13
|
+
stack: string;
|
|
14
|
+
};
|
|
15
|
+
export type ExternalTarget = {
|
|
16
|
+
kind: 'external';
|
|
17
|
+
name: string;
|
|
18
|
+
kubeconfig: string;
|
|
19
|
+
namespace: string;
|
|
20
|
+
registry: RegistryInput;
|
|
21
|
+
context?: string;
|
|
22
|
+
hostgroup?: string;
|
|
23
|
+
storageHostgroup?: string;
|
|
24
|
+
};
|
|
25
|
+
export type DeployTarget = ManagedTarget | ExternalTarget;
|
|
26
|
+
export type DeployManifest = {
|
|
27
|
+
path: string;
|
|
28
|
+
workspaceRoot: string;
|
|
29
|
+
defaultTarget?: string;
|
|
30
|
+
discovery: DiscoveryConfig;
|
|
31
|
+
targets: Record<string, DeployTarget>;
|
|
32
|
+
};
|
|
33
|
+
export declare function findDeployManifest(startDirectory: string): string | undefined;
|
|
34
|
+
export declare function loadDeployManifest(startDirectory: string, env: Record<string, string | undefined>): DeployManifest;
|
|
35
|
+
export declare function parseDeployManifest(path: string, source: string, env: Record<string, string | undefined>): DeployManifest;
|
|
36
|
+
export declare function interpolateEnv(value: unknown, env: Record<string, string | undefined>, manifestPath: string): unknown;
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { CommandFailure } from '@di-framework/cli-extension';
|
|
4
|
+
import { isNamespace } from './namespace.js';
|
|
5
|
+
import { findUp } from './project.js';
|
|
6
|
+
import { parseToml, TomlParseError } from './toml.js';
|
|
7
|
+
export const DEPLOY_MANIFEST_NAME = 'di-framework.deploy.toml';
|
|
8
|
+
export const DEFAULT_DISCOVERY_EXCLUDE = ['dist/**', 'coverage/**', '**/dist/**', '**/coverage/**'];
|
|
9
|
+
export const ALWAYS_SKIP_DIRECTORIES = new Set(['.git', 'node_modules', '.di-framework']);
|
|
10
|
+
const ENV_TOKEN = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
11
|
+
function manifestInvalid(message, details) {
|
|
12
|
+
throw new CommandFailure('WASMCLOUD_DEPLOY_MANIFEST_INVALID', message, 2, details);
|
|
13
|
+
}
|
|
14
|
+
export function findDeployManifest(startDirectory) {
|
|
15
|
+
return findUp(startDirectory, DEPLOY_MANIFEST_NAME);
|
|
16
|
+
}
|
|
17
|
+
export function loadDeployManifest(startDirectory, env) {
|
|
18
|
+
const path = findDeployManifest(startDirectory);
|
|
19
|
+
if (path === undefined) {
|
|
20
|
+
throw new CommandFailure('WASMCLOUD_DEPLOY_MANIFEST_NOT_FOUND', `No ${DEPLOY_MANIFEST_NAME} found above ${startDirectory}. Add one at the workspace root to describe deployment targets.`, 2, { startDirectory });
|
|
21
|
+
}
|
|
22
|
+
return parseDeployManifest(path, readFileSync(path, 'utf8'), env);
|
|
23
|
+
}
|
|
24
|
+
export function parseDeployManifest(path, source, env) {
|
|
25
|
+
let parsed;
|
|
26
|
+
try {
|
|
27
|
+
parsed = parseToml(source);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const line = error instanceof TomlParseError ? error.line : undefined;
|
|
31
|
+
manifestInvalid(`Could not parse ${path}${line === undefined ? '' : ` (line ${line})`}: ${error instanceof Error ? error.message : String(error)}`, { manifestPath: path, ...(line === undefined ? {} : { line }) });
|
|
32
|
+
}
|
|
33
|
+
if ('apps' in parsed) {
|
|
34
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} must not declare "apps"; project identity comes only from the "name" in di-framework.config.json`, { manifestPath: path });
|
|
35
|
+
}
|
|
36
|
+
const interpolated = interpolateEnv(parsed, env, path);
|
|
37
|
+
const defaultTarget = optionalString(interpolated['default-target'], 'default-target', path);
|
|
38
|
+
const discovery = parseDiscovery(interpolated.discovery, path);
|
|
39
|
+
const targetsValue = interpolated.targets;
|
|
40
|
+
if (targetsValue === undefined) {
|
|
41
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} must declare at least one [targets.<name>] table`, {
|
|
42
|
+
manifestPath: path,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!isRecord(targetsValue) || Object.keys(targetsValue).length === 0) {
|
|
46
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} "targets" must be a non-empty table`, {
|
|
47
|
+
manifestPath: path,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const targets = {};
|
|
51
|
+
for (const [name, value] of Object.entries(targetsValue)) {
|
|
52
|
+
targets[name] = parseTarget(name, value, path);
|
|
53
|
+
}
|
|
54
|
+
if (defaultTarget !== undefined && targets[defaultTarget] === undefined) {
|
|
55
|
+
manifestInvalid(`default-target "${defaultTarget}" does not match any declared target. Known targets: ${Object.keys(targets).join(', ')}`, { manifestPath: path, defaultTarget, targets: Object.keys(targets) });
|
|
56
|
+
}
|
|
57
|
+
const knownKeys = new Set(['default-target', 'discovery', 'targets']);
|
|
58
|
+
const unknown = Object.keys(interpolated).filter((key) => !knownKeys.has(key));
|
|
59
|
+
if (unknown.length > 0) {
|
|
60
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} has unsupported fields: ${unknown.join(', ')}. Valid fields are default-target, discovery, and targets.`, { manifestPath: path, fields: unknown });
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
path,
|
|
64
|
+
workspaceRoot: dirname(path),
|
|
65
|
+
defaultTarget,
|
|
66
|
+
discovery,
|
|
67
|
+
targets,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function interpolateEnv(value, env, manifestPath) {
|
|
71
|
+
if (typeof value === 'string')
|
|
72
|
+
return interpolateString(value, env, manifestPath);
|
|
73
|
+
if (Array.isArray(value))
|
|
74
|
+
return value.map((entry) => interpolateEnv(entry, env, manifestPath));
|
|
75
|
+
if (isRecord(value)) {
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
78
|
+
result[key] = interpolateEnv(entry, env, manifestPath);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function interpolateString(value, env, manifestPath) {
|
|
85
|
+
return value.replace(ENV_TOKEN, (_match, name) => {
|
|
86
|
+
const replacement = env[name];
|
|
87
|
+
if (replacement === undefined || replacement === '') {
|
|
88
|
+
throw new CommandFailure('WASMCLOUD_ENV_UNSET', `Environment variable ${name} is not set (required by ${manifestPath}). Set ${name} or remove the \${${name}} interpolation.`, 2, { variable: name, manifestPath });
|
|
89
|
+
}
|
|
90
|
+
return replacement;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function parseDiscovery(value, manifestPath) {
|
|
94
|
+
if (value === undefined) {
|
|
95
|
+
return { include: ['**'], exclude: [...DEFAULT_DISCOVERY_EXCLUDE] };
|
|
96
|
+
}
|
|
97
|
+
if (!isRecord(value)) {
|
|
98
|
+
manifestInvalid(`${DEPLOY_MANIFEST_NAME} "discovery" must be a table`, { manifestPath });
|
|
99
|
+
}
|
|
100
|
+
const include = optionalStringArray(value.include, 'discovery.include', manifestPath) ?? ['**'];
|
|
101
|
+
const userExclude = optionalStringArray(value.exclude, 'discovery.exclude', manifestPath) ?? [];
|
|
102
|
+
const unknown = Object.keys(value).filter((key) => key !== 'include' && key !== 'exclude');
|
|
103
|
+
if (unknown.length > 0) {
|
|
104
|
+
manifestInvalid(`discovery has unsupported fields: ${unknown.join(', ')}. Valid fields are include and exclude.`, { manifestPath, fields: unknown });
|
|
105
|
+
}
|
|
106
|
+
if (include.length === 0) {
|
|
107
|
+
manifestInvalid('discovery.include must contain at least one pattern', { manifestPath });
|
|
108
|
+
}
|
|
109
|
+
return { include, exclude: [...DEFAULT_DISCOVERY_EXCLUDE, ...userExclude] };
|
|
110
|
+
}
|
|
111
|
+
function parseTarget(name, value, manifestPath) {
|
|
112
|
+
if (!isRecord(value)) {
|
|
113
|
+
manifestInvalid(`targets.${name} must be a table`, { manifestPath, target: name });
|
|
114
|
+
}
|
|
115
|
+
const platform = optionalString(value.platform, `targets.${name}.platform`, manifestPath);
|
|
116
|
+
const stack = optionalString(value.stack, `targets.${name}.stack`, manifestPath);
|
|
117
|
+
const kubeconfig = optionalString(value.kubeconfig, `targets.${name}.kubeconfig`, manifestPath);
|
|
118
|
+
const context = optionalString(value.context, `targets.${name}.context`, manifestPath);
|
|
119
|
+
const hostgroup = optionalString(value.hostgroup, `targets.${name}.hostgroup`, manifestPath);
|
|
120
|
+
const storageHostgroup = optionalString(value['storage-hostgroup'], `targets.${name}.storage-hostgroup`, manifestPath);
|
|
121
|
+
for (const [field, group] of [
|
|
122
|
+
['hostgroup', hostgroup],
|
|
123
|
+
['storage-hostgroup', storageHostgroup],
|
|
124
|
+
]) {
|
|
125
|
+
if (group !== undefined && !isNamespace(group))
|
|
126
|
+
manifestInvalid(`targets.${name}.${field} must be a DNS label of at most 63 characters`, {
|
|
127
|
+
manifestPath,
|
|
128
|
+
target: name,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const namespace = optionalString(value.namespace, `targets.${name}.namespace`, manifestPath);
|
|
132
|
+
if (namespace !== undefined && !isNamespace(namespace)) {
|
|
133
|
+
manifestInvalid(`targets.${name}.namespace must be a Kubernetes namespace (a DNS label of at most 63 characters)`, { manifestPath, target: name });
|
|
134
|
+
}
|
|
135
|
+
const registry = optionalRegistry(value.registry, `targets.${name}.registry`, manifestPath);
|
|
136
|
+
const known = new Set([
|
|
137
|
+
'platform',
|
|
138
|
+
'stack',
|
|
139
|
+
'kubeconfig',
|
|
140
|
+
'context',
|
|
141
|
+
'namespace',
|
|
142
|
+
'registry',
|
|
143
|
+
'hostgroup',
|
|
144
|
+
'storage-hostgroup',
|
|
145
|
+
]);
|
|
146
|
+
const unknown = Object.keys(value).filter((key) => !known.has(key));
|
|
147
|
+
if (unknown.length > 0) {
|
|
148
|
+
manifestInvalid(`Target "${name}" has unsupported fields: ${unknown.join(', ')}. Managed targets accept platform and stack; external targets accept kubeconfig, context, namespace, registry, hostgroup, and storage-hostgroup.`, { manifestPath, target: name, fields: unknown });
|
|
149
|
+
}
|
|
150
|
+
const managedFields = [platform ? 'platform' : undefined, stack ? 'stack' : undefined].filter((field) => field !== undefined);
|
|
151
|
+
const externalFields = [
|
|
152
|
+
kubeconfig ? 'kubeconfig' : undefined,
|
|
153
|
+
context ? 'context' : undefined,
|
|
154
|
+
hostgroup ? 'hostgroup' : undefined,
|
|
155
|
+
storageHostgroup ? 'storage-hostgroup' : undefined,
|
|
156
|
+
namespace ? 'namespace' : undefined,
|
|
157
|
+
registry ? 'registry' : undefined,
|
|
158
|
+
].filter((field) => field !== undefined);
|
|
159
|
+
if (managedFields.length > 0 && externalFields.length > 0) {
|
|
160
|
+
manifestInvalid(`Target "${name}" mixes managed-platform and kubeconfig fields (${[...managedFields, ...externalFields].join(', ')}). Use either platform (and optional stack), or kubeconfig + namespace + registry.`, { manifestPath, target: name });
|
|
161
|
+
}
|
|
162
|
+
if (stack !== undefined && platform === undefined) {
|
|
163
|
+
manifestInvalid(`Target "${name}" sets stack without platform. stack is only valid on managed Pulumi targets.`, { manifestPath, target: name });
|
|
164
|
+
}
|
|
165
|
+
if (platform !== undefined) {
|
|
166
|
+
return { kind: 'managed', name, platform, stack: stack ?? 'dev' };
|
|
167
|
+
}
|
|
168
|
+
if (kubeconfig !== undefined || namespace !== undefined || registry !== undefined) {
|
|
169
|
+
const missing = [
|
|
170
|
+
kubeconfig === undefined ? 'kubeconfig' : undefined,
|
|
171
|
+
namespace === undefined ? 'namespace' : undefined,
|
|
172
|
+
registry === undefined ? 'registry' : undefined,
|
|
173
|
+
].filter((field) => field !== undefined);
|
|
174
|
+
if (missing.length > 0) {
|
|
175
|
+
manifestInvalid(`Target "${name}" is incomplete; external targets require kubeconfig, namespace, and registry. Missing: ${missing.join(', ')}.`, { manifestPath, target: name, missing });
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
kind: 'external',
|
|
179
|
+
name,
|
|
180
|
+
kubeconfig: kubeconfig,
|
|
181
|
+
namespace: namespace,
|
|
182
|
+
registry: registry,
|
|
183
|
+
context,
|
|
184
|
+
...(hostgroup ? { hostgroup } : {}),
|
|
185
|
+
...(storageHostgroup ? { storageHostgroup } : {}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
manifestInvalid(`Target "${name}" is empty. Set platform (and optional stack) for a managed Pulumi platform, or kubeconfig, namespace, and registry for an external cluster.`, { manifestPath, target: name });
|
|
189
|
+
}
|
|
190
|
+
function optionalString(value, label, manifestPath) {
|
|
191
|
+
if (value === undefined)
|
|
192
|
+
return undefined;
|
|
193
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
194
|
+
manifestInvalid(`${label} must be a non-empty string`, { manifestPath, field: label });
|
|
195
|
+
}
|
|
196
|
+
return value;
|
|
197
|
+
}
|
|
198
|
+
function optionalRegistry(value, label, manifestPath) {
|
|
199
|
+
if (value === undefined)
|
|
200
|
+
return undefined;
|
|
201
|
+
if (typeof value === 'string')
|
|
202
|
+
return optionalString(value, label, manifestPath);
|
|
203
|
+
if (!isRecord(value)) {
|
|
204
|
+
manifestInvalid(`${label} must be a string or a table with push, pull, and insecure`, {
|
|
205
|
+
manifestPath,
|
|
206
|
+
field: label,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const push = optionalString(value.push, `${label}.push`, manifestPath);
|
|
210
|
+
const pull = optionalString(value.pull, `${label}.pull`, manifestPath);
|
|
211
|
+
const insecure = value.insecure;
|
|
212
|
+
const unknown = Object.keys(value).filter((key) => key !== 'push' && key !== 'pull' && key !== 'insecure');
|
|
213
|
+
if (unknown.length > 0) {
|
|
214
|
+
manifestInvalid(`${label} has unsupported fields: ${unknown.join(', ')}`, {
|
|
215
|
+
manifestPath,
|
|
216
|
+
field: label,
|
|
217
|
+
fields: unknown,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const missing = [
|
|
221
|
+
push === undefined ? 'push' : undefined,
|
|
222
|
+
pull === undefined ? 'pull' : undefined,
|
|
223
|
+
].filter((field) => field !== undefined);
|
|
224
|
+
if (missing.length > 0) {
|
|
225
|
+
manifestInvalid(`${label} requires push and pull. Missing: ${missing.join(', ')}.`, {
|
|
226
|
+
manifestPath,
|
|
227
|
+
field: label,
|
|
228
|
+
missing,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (insecure !== undefined && typeof insecure !== 'boolean') {
|
|
232
|
+
manifestInvalid(`${label}.insecure must be a boolean when present`, {
|
|
233
|
+
manifestPath,
|
|
234
|
+
field: `${label}.insecure`,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
push: push,
|
|
239
|
+
pull: pull,
|
|
240
|
+
...(insecure === undefined ? {} : { insecure }),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function optionalStringArray(value, label, manifestPath) {
|
|
244
|
+
if (value === undefined)
|
|
245
|
+
return undefined;
|
|
246
|
+
if (!Array.isArray(value) ||
|
|
247
|
+
value.some((entry) => typeof entry !== 'string' || entry.trim() === '')) {
|
|
248
|
+
manifestInvalid(`${label} must be an array of non-empty strings`, {
|
|
249
|
+
manifestPath,
|
|
250
|
+
field: label,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return value;
|
|
254
|
+
}
|
|
255
|
+
function isRecord(value) {
|
|
256
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
257
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare class AsyncLocalStorage<T> {
|
|
2
|
+
private key;
|
|
3
|
+
private defaultValue;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
constructor(options?: {
|
|
6
|
+
defaultValue?: T;
|
|
7
|
+
name?: string;
|
|
8
|
+
});
|
|
9
|
+
getStore(): T | undefined;
|
|
10
|
+
run<R, A extends unknown[]>(store: T, callback: (...args: A) => R, ...args: A): R;
|
|
11
|
+
exit<R, A extends unknown[]>(callback: (...args: A) => R, ...args: A): R;
|
|
12
|
+
enterWith(store: T): void;
|
|
13
|
+
disable(): void;
|
|
14
|
+
static bind<F extends (...args: any[]) => any>(callback: F): F;
|
|
15
|
+
static snapshot(): <R, A extends unknown[]>(callback: (...args: A) => R, ...args: A) => R;
|
|
16
|
+
}
|
|
17
|
+
export declare class AsyncResource {
|
|
18
|
+
private scope;
|
|
19
|
+
constructor(_type: string, _options?: unknown);
|
|
20
|
+
runInAsyncScope<R, A extends unknown[]>(callback: (...args: A) => R, thisArg: unknown, ...args: A): R;
|
|
21
|
+
bind<F extends (...args: any[]) => any>(callback: F, thisArg?: unknown): F;
|
|
22
|
+
emitDestroy(): this;
|
|
23
|
+
}
|
|
24
|
+
export declare function installAsyncContext(): void;
|
|
25
|
+
declare const _default: {
|
|
26
|
+
AsyncLocalStorage: typeof AsyncLocalStorage;
|
|
27
|
+
AsyncResource: typeof AsyncResource;
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The bundler lowers async functions to Promise continuations. Native await does
|
|
2
|
+
// not call Promise.prototype.then and cannot be instrumented by this JS runtime.
|
|
3
|
+
let current = new Map();
|
|
4
|
+
function inContext(context, callback) {
|
|
5
|
+
const previous = current;
|
|
6
|
+
current = context;
|
|
7
|
+
try {
|
|
8
|
+
return callback();
|
|
9
|
+
}
|
|
10
|
+
finally {
|
|
11
|
+
current = previous;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class AsyncLocalStorage {
|
|
15
|
+
key = Symbol();
|
|
16
|
+
defaultValue;
|
|
17
|
+
name;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.defaultValue = options?.defaultValue;
|
|
20
|
+
this.name = options?.name ?? '';
|
|
21
|
+
}
|
|
22
|
+
getStore() {
|
|
23
|
+
return current.has(this.key) ? current.get(this.key) : this.defaultValue;
|
|
24
|
+
}
|
|
25
|
+
run(store, callback, ...args) {
|
|
26
|
+
const context = new Map(current);
|
|
27
|
+
context.set(this.key, store);
|
|
28
|
+
return inContext(context, () => callback(...args));
|
|
29
|
+
}
|
|
30
|
+
exit(callback, ...args) {
|
|
31
|
+
const context = new Map(current);
|
|
32
|
+
context.delete(this.key);
|
|
33
|
+
return inContext(context, () => callback(...args));
|
|
34
|
+
}
|
|
35
|
+
enterWith(store) {
|
|
36
|
+
current = new Map(current);
|
|
37
|
+
current.set(this.key, store);
|
|
38
|
+
}
|
|
39
|
+
disable() {
|
|
40
|
+
current = new Map(current);
|
|
41
|
+
current.delete(this.key);
|
|
42
|
+
this.key = Symbol();
|
|
43
|
+
}
|
|
44
|
+
static bind(callback) {
|
|
45
|
+
const context = current;
|
|
46
|
+
return function (...args) {
|
|
47
|
+
return inContext(context, () => callback.apply(this, args));
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static snapshot() {
|
|
51
|
+
const context = current;
|
|
52
|
+
return (callback, ...args) => inContext(context, () => callback(...args));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class AsyncResource {
|
|
56
|
+
scope = AsyncLocalStorage.snapshot();
|
|
57
|
+
// biome-ignore lint/complexity/noUselessConstructor: Match the Node constructor signature.
|
|
58
|
+
constructor(_type, _options) { }
|
|
59
|
+
runInAsyncScope(callback, thisArg, ...args) {
|
|
60
|
+
return this.scope(() => callback.apply(thisArg, args));
|
|
61
|
+
}
|
|
62
|
+
bind(callback, thisArg) {
|
|
63
|
+
return ((...args) => this.runInAsyncScope(callback, thisArg, ...args));
|
|
64
|
+
}
|
|
65
|
+
emitDestroy() {
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let installed = false;
|
|
70
|
+
export function installAsyncContext() {
|
|
71
|
+
if (installed)
|
|
72
|
+
return;
|
|
73
|
+
installed = true;
|
|
74
|
+
const then = Promise.prototype.then;
|
|
75
|
+
// biome-ignore lint/suspicious/noThenProperty: Bind real Promise continuations to the captured guest context.
|
|
76
|
+
Promise.prototype.then = function (onfulfilled, onrejected) {
|
|
77
|
+
return then.call(this, typeof onfulfilled === 'function' ? AsyncLocalStorage.bind(onfulfilled) : onfulfilled, typeof onrejected === 'function' ? AsyncLocalStorage.bind(onrejected) : onrejected);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export default { AsyncLocalStorage, AsyncResource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './fetch-runtime.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './fetch-runtime.js';
|
|
2
|
+
import { installAsyncContext } from './async-hooks.js';
|
|
3
|
+
import timers from './timers.js';
|
|
4
|
+
installAsyncContext();
|
|
5
|
+
const global = globalThis;
|
|
6
|
+
for (const [name, implementation] of Object.entries(timers)) {
|
|
7
|
+
if (typeof global[name] !== 'function')
|
|
8
|
+
global[name] = implementation;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Byte helpers shared by the Node overlays. Do not import WASI from here. */
|
|
2
|
+
export declare function toBytes(data: unknown): Uint8Array;
|
|
3
|
+
export declare function toNodeBuffer(bytes: Uint8Array): Uint8Array;
|
|
4
|
+
export declare function concatBytes(...parts: readonly Uint8Array[]): Uint8Array;
|
|
5
|
+
export declare function toArrayBuffer(bytes: Uint8Array): ArrayBuffer;
|
|
6
|
+
export declare function encodeUtf8(text: string): Uint8Array;
|
|
7
|
+
export declare function decodeUtf8(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Byte helpers shared by the Node overlays. Do not import WASI from here. */
|
|
2
|
+
export function toBytes(data) {
|
|
3
|
+
if (typeof data === 'number')
|
|
4
|
+
return Uint8Array.of(data & 0xff);
|
|
5
|
+
if (typeof data === 'string')
|
|
6
|
+
return new TextEncoder().encode(data);
|
|
7
|
+
if (data instanceof Uint8Array)
|
|
8
|
+
return data;
|
|
9
|
+
if (ArrayBuffer.isView(data)) {
|
|
10
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
11
|
+
}
|
|
12
|
+
if (data instanceof ArrayBuffer)
|
|
13
|
+
return new Uint8Array(data);
|
|
14
|
+
if (Array.isArray(data))
|
|
15
|
+
return Uint8Array.from(data.map((byte) => Number(byte) & 0xff));
|
|
16
|
+
return new Uint8Array();
|
|
17
|
+
}
|
|
18
|
+
export function toNodeBuffer(bytes) {
|
|
19
|
+
return typeof Buffer === 'undefined' ? bytes : Buffer.from(bytes);
|
|
20
|
+
}
|
|
21
|
+
export function concatBytes(...parts) {
|
|
22
|
+
let total = 0;
|
|
23
|
+
for (const part of parts)
|
|
24
|
+
total += part.length;
|
|
25
|
+
const out = new Uint8Array(total);
|
|
26
|
+
let offset = 0;
|
|
27
|
+
for (const part of parts) {
|
|
28
|
+
out.set(part, offset);
|
|
29
|
+
offset += part.length;
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
export function toArrayBuffer(bytes) {
|
|
34
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
35
|
+
}
|
|
36
|
+
export function encodeUtf8(text) {
|
|
37
|
+
return new TextEncoder().encode(text);
|
|
38
|
+
}
|
|
39
|
+
export function decodeUtf8(bytes) {
|
|
40
|
+
return new TextDecoder().decode(bytes);
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type HashFn = {
|
|
2
|
+
create(): HashState;
|
|
3
|
+
outputLen: number;
|
|
4
|
+
};
|
|
5
|
+
type HashState = {
|
|
6
|
+
update(data: Uint8Array): HashState;
|
|
7
|
+
digest(): Uint8Array;
|
|
8
|
+
clone(): HashState;
|
|
9
|
+
};
|
|
10
|
+
export declare function normalizeHashName(algorithm: string): string;
|
|
11
|
+
export declare function hashFunction(algorithm: string): HashFn;
|
|
12
|
+
export declare class Hash {
|
|
13
|
+
algorithm: string;
|
|
14
|
+
state: HashState;
|
|
15
|
+
finalized: boolean;
|
|
16
|
+
constructor(algorithm: string, state?: HashState);
|
|
17
|
+
update(data: unknown, encoding?: string): this;
|
|
18
|
+
digest(encoding?: string): string | Uint8Array;
|
|
19
|
+
copy(): Hash;
|
|
20
|
+
}
|
|
21
|
+
export declare class Hmac extends Hash {
|
|
22
|
+
constructor(algorithm: string, key: unknown);
|
|
23
|
+
}
|
|
24
|
+
export declare function createHash(algorithm: string): Hash;
|
|
25
|
+
export declare function createHmac(algorithm: string, key: unknown): Hmac;
|
|
26
|
+
export declare function digestSync(algorithm: string, data: Uint8Array): Uint8Array;
|
|
27
|
+
export {};
|