space-data-module-sdk 0.1.0 → 0.2.0
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/LICENSE +190 -0
- package/README.md +174 -83
- package/bin/space-data-module.js +24 -0
- package/package.json +8 -3
- package/schemas/ModuleBundle.fbs +108 -0
- package/schemas/PluginManifest.fbs +26 -1
- package/src/bundle/codec.js +244 -0
- package/src/bundle/constants.js +8 -0
- package/src/bundle/index.js +3 -0
- package/src/bundle/wasm.js +447 -0
- package/src/compiler/compileModule.js +189 -41
- package/src/compliance/pluginCompliance.js +334 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +27 -2
- package/src/generated/orbpro/manifest/capability-kind.js +26 -1
- package/src/generated/orbpro/manifest/capability-kind.ts +25 -0
- package/src/generated/orbpro/module/canonicalization-rule.d.ts +48 -0
- package/src/generated/orbpro/module/canonicalization-rule.js +95 -0
- package/src/generated/orbpro/module/canonicalization-rule.ts +142 -0
- package/src/generated/orbpro/module/module-bundle-entry-role.d.ts +11 -0
- package/src/generated/orbpro/module/module-bundle-entry-role.js +14 -0
- package/src/generated/orbpro/module/module-bundle-entry-role.ts +15 -0
- package/src/generated/orbpro/module/module-bundle-entry.d.ts +97 -0
- package/src/generated/orbpro/module/module-bundle-entry.js +219 -0
- package/src/generated/orbpro/module/module-bundle-entry.ts +287 -0
- package/src/generated/orbpro/module/module-bundle.d.ts +86 -0
- package/src/generated/orbpro/module/module-bundle.js +213 -0
- package/src/generated/orbpro/module/module-bundle.ts +277 -0
- package/src/generated/orbpro/module/module-payload-encoding.d.ts +9 -0
- package/src/generated/orbpro/module/module-payload-encoding.js +12 -0
- package/src/generated/orbpro/module/module-payload-encoding.ts +13 -0
- package/src/generated/orbpro/module.d.ts +5 -0
- package/src/generated/orbpro/module.js +7 -0
- package/src/generated/orbpro/module.ts +9 -0
- package/src/host/abi.js +282 -0
- package/src/host/cron.js +247 -0
- package/src/host/index.js +3 -0
- package/src/host/nodeHost.js +2165 -0
- package/src/index.d.ts +880 -0
- package/src/index.js +9 -2
- package/src/manifest/normalize.js +32 -1
- package/src/runtime/constants.js +18 -1
- package/src/transport/pki.js +0 -5
- package/src/utils/encoding.js +9 -1
- package/src/utils/wasmCrypto.js +49 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2024 Digital Arsenal, Inc.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,50 +1,75 @@
|
|
|
1
1
|
# Space Data Module SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`space-data-module-sdk` defines the canonical module artifact for the Space Data
|
|
4
|
+
stack: WebAssembly code, an embedded FlatBuffer manifest, a stable capability
|
|
5
|
+
vocabulary, a single-file bundle format, and the signing and transport records
|
|
6
|
+
used to move modules between hosts.
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
This repository is the source of truth for module-level concerns:
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
- `PluginManifest.fbs` and manifest codecs
|
|
11
|
+
- embedded manifest exports inside `.wasm` modules
|
|
12
|
+
- standards-aware compliance and capability validation
|
|
13
|
+
- module compilation and protection
|
|
14
|
+
- the `sds.bundle` single-file custom section
|
|
15
|
+
- deployment authorization and encrypted transport envelopes
|
|
16
|
+
- the first canonical module hostcall/import ABI surface
|
|
8
17
|
|
|
9
18
|
<p align="center">
|
|
10
|
-
<img src="docs/architecture.svg" alt="
|
|
19
|
+
<img src="docs/architecture.svg" alt="Module architecture overview" width="820" />
|
|
11
20
|
</p>
|
|
12
21
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
## Artifact Model
|
|
23
|
+
|
|
24
|
+
A module built with this SDK is a `.wasm` artifact with:
|
|
25
|
+
|
|
26
|
+
- an embedded `PluginManifest.fbs`
|
|
27
|
+
- exported manifest accessors:
|
|
28
|
+
- `plugin_get_manifest_flatbuffer`
|
|
29
|
+
- `plugin_get_manifest_flatbuffer_size`
|
|
30
|
+
- optional `sds.bundle` custom-section payloads for:
|
|
31
|
+
- manifest bytes
|
|
32
|
+
- deployment authorization
|
|
33
|
+
- detached signatures
|
|
34
|
+
- encrypted transport envelopes
|
|
35
|
+
- auxiliary FlatBuffer or raw payloads
|
|
36
|
+
|
|
37
|
+
The module contract stays the same whether the artifact is loaded directly,
|
|
38
|
+
wrapped in a deployment envelope, or shipped as one bundled `.wasm` file.
|
|
39
|
+
|
|
40
|
+
## Runtime Portability
|
|
41
|
+
|
|
42
|
+
The module format is language-neutral. A host can load modules from this SDK
|
|
43
|
+
anywhere it can:
|
|
44
|
+
|
|
45
|
+
- instantiate WebAssembly
|
|
46
|
+
- read FlatBuffers
|
|
47
|
+
- honor the module capability and host ABI contract
|
|
48
|
+
|
|
49
|
+
That target set matches the WebAssembly and FlatBuffers runtime families already
|
|
50
|
+
used in the companion `flatbuffers/wasm` work:
|
|
51
|
+
|
|
52
|
+
- browser
|
|
53
|
+
- Node.js
|
|
54
|
+
- C#
|
|
55
|
+
- Go
|
|
56
|
+
- Java
|
|
57
|
+
- Kotlin
|
|
58
|
+
- Python
|
|
59
|
+
- Rust
|
|
60
|
+
- Swift
|
|
61
|
+
|
|
62
|
+
This repo currently includes:
|
|
63
|
+
|
|
64
|
+
- the JavaScript reference implementation for manifest, compliance, auth,
|
|
65
|
+
transport, bundle handling, and compilation
|
|
66
|
+
- deterministic `sds.bundle` conformance vectors under
|
|
67
|
+
[`examples/single-file-bundle/vectors`](./examples/single-file-bundle/vectors)
|
|
68
|
+
- non-JS bundle reference clients in
|
|
69
|
+
[`examples/single-file-bundle/go`](./examples/single-file-bundle/go) and
|
|
70
|
+
[`examples/single-file-bundle/python`](./examples/single-file-bundle/python)
|
|
71
|
+
- a reference Node host and sync `sdn_host` bridge for the first hostcall
|
|
72
|
+
surface
|
|
48
73
|
|
|
49
74
|
## Install
|
|
50
75
|
|
|
@@ -56,84 +81,150 @@ npm install space-data-module-sdk
|
|
|
56
81
|
|
|
57
82
|
```js
|
|
58
83
|
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
compileModuleFromSource,
|
|
85
|
+
createSingleFileBundle,
|
|
86
|
+
encodePluginManifest,
|
|
87
|
+
parseSingleFileBundle,
|
|
88
|
+
validateManifestWithStandards,
|
|
64
89
|
} from "space-data-module-sdk";
|
|
65
|
-
```
|
|
66
90
|
|
|
67
|
-
|
|
91
|
+
const manifestBytes = encodePluginManifest(manifest);
|
|
92
|
+
const validation = await validateManifestWithStandards(manifest);
|
|
93
|
+
if (!validation.ok) {
|
|
94
|
+
throw new Error("Manifest validation failed.");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const compilation = await compileModuleFromSource({
|
|
98
|
+
manifest,
|
|
99
|
+
sourceCode,
|
|
100
|
+
language: "c",
|
|
101
|
+
});
|
|
68
102
|
|
|
69
|
-
|
|
103
|
+
const bundle = await createSingleFileBundle({
|
|
104
|
+
wasmBytes: compilation.wasmBytes,
|
|
105
|
+
manifest,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const parsed = await parseSingleFileBundle(bundle.wasmBytes);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Each subsystem is also available as a subpath export:
|
|
70
112
|
|
|
71
113
|
```js
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
114
|
+
import { encodePluginManifest } from "space-data-module-sdk/manifest";
|
|
115
|
+
import { validateManifestWithStandards } from "space-data-module-sdk/compliance";
|
|
116
|
+
import { createDeploymentAuthorization } from "space-data-module-sdk/auth";
|
|
117
|
+
import { encryptJsonForRecipient } from "space-data-module-sdk/transport";
|
|
118
|
+
import { compileModuleFromSource } from "space-data-module-sdk/compiler";
|
|
119
|
+
import { createSingleFileBundle } from "space-data-module-sdk/bundle";
|
|
78
120
|
```
|
|
79
121
|
|
|
80
|
-
##
|
|
122
|
+
## Single-File Bundles
|
|
123
|
+
|
|
124
|
+
`sds.bundle` keeps module delivery to one file without changing WebAssembly
|
|
125
|
+
loadability. The SDK appends a standard custom section, not raw trailer bytes,
|
|
126
|
+
so the bundled artifact still compiles as a normal `.wasm` module.
|
|
81
127
|
|
|
82
|
-
|
|
128
|
+
The reference path lives in
|
|
129
|
+
[`examples/single-file-bundle`](./examples/single-file-bundle):
|
|
130
|
+
|
|
131
|
+
- [`demo.mjs`](./examples/single-file-bundle/demo.mjs) builds and parses a
|
|
132
|
+
bundled module
|
|
133
|
+
- [`generate-vectors.mjs`](./examples/single-file-bundle/generate-vectors.mjs)
|
|
134
|
+
regenerates the checked-in conformance vectors
|
|
135
|
+
- the `go` and `python` directories show non-JS readers against the same
|
|
136
|
+
bundle contract
|
|
137
|
+
|
|
138
|
+
## Host ABI
|
|
139
|
+
|
|
140
|
+
This repo also defines the module-facing capability vocabulary and the first
|
|
141
|
+
synchronous hostcall bridge under the import module `sdn_host`.
|
|
142
|
+
|
|
143
|
+
The current sync import surface is:
|
|
144
|
+
|
|
145
|
+
- `call_json(operation_ptr, operation_len, payload_ptr, payload_len) -> i32`
|
|
146
|
+
- `response_len() -> i32`
|
|
147
|
+
- `read_response(dst_ptr, dst_len) -> i32`
|
|
148
|
+
- `last_status_code() -> i32`
|
|
149
|
+
- `clear_response() -> i32`
|
|
150
|
+
|
|
151
|
+
Use `createNodeHost(...)` and `createNodeHostSyncHostcallBridge(...)` to run
|
|
152
|
+
that contract against the reference Node host while keeping the ABI shape
|
|
153
|
+
portable for non-JS hosts.
|
|
154
|
+
|
|
155
|
+
## Host Capabilities
|
|
156
|
+
|
|
157
|
+
Modules request capabilities by stable ID. The current recommended vocabulary
|
|
158
|
+
includes:
|
|
159
|
+
|
|
160
|
+
`clock` `random` `logging` `timers` `schedule_cron` `http` `tls` `websocket`
|
|
161
|
+
`mqtt` `tcp` `udp` `network` `filesystem` `pipe` `pubsub` `protocol_handle`
|
|
162
|
+
`protocol_dial` `database` `storage_adapter` `storage_query` `storage_write`
|
|
163
|
+
`context_read` `context_write` `process_exec` `crypto_hash` `crypto_sign`
|
|
164
|
+
`crypto_verify` `crypto_encrypt` `crypto_decrypt` `crypto_key_agreement`
|
|
165
|
+
`crypto_kdf` `wallet_sign` `ipfs` `scene_access` `entity_access`
|
|
166
|
+
`render_hooks`
|
|
167
|
+
|
|
168
|
+
Manifests can also declare coarse runtime targets for planning and compliance:
|
|
169
|
+
|
|
170
|
+
`node` `browser` `wasi` `server` `desktop` `edge`
|
|
171
|
+
|
|
172
|
+
## Environment Notes
|
|
173
|
+
|
|
174
|
+
| Surface | Node.js | Browser |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `manifest` | Yes | Yes |
|
|
177
|
+
| `auth` | Yes | Yes |
|
|
178
|
+
| `transport` | Yes | Yes |
|
|
179
|
+
| `bundle` | Yes | Yes |
|
|
180
|
+
| `compliance` | Yes | No |
|
|
181
|
+
| `compiler` | Yes | No |
|
|
182
|
+
| `standards` | Yes | No |
|
|
183
|
+
|
|
184
|
+
## CLI
|
|
83
185
|
|
|
84
186
|
```bash
|
|
85
|
-
# Validate a manifest + wasm pair
|
|
187
|
+
# Validate a manifest + wasm pair
|
|
86
188
|
npx space-data-module check --manifest ./manifest.json --wasm ./dist/module.wasm
|
|
87
189
|
|
|
88
|
-
# Compile C/C++ source
|
|
190
|
+
# Compile C/C++ source and embed the manifest
|
|
89
191
|
npx space-data-module compile --manifest ./manifest.json --source ./src/module.c --out ./dist/module.wasm
|
|
90
192
|
|
|
91
|
-
# Sign and encrypt a
|
|
193
|
+
# Sign and encrypt a deployment payload
|
|
92
194
|
npx space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --json
|
|
195
|
+
|
|
196
|
+
# Emit a single-file bundled wasm
|
|
197
|
+
npx space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --single-file-bundle --out ./dist/module.bundle.wasm
|
|
93
198
|
```
|
|
94
199
|
|
|
95
200
|
## Module Lab
|
|
96
201
|
|
|
97
|
-
|
|
202
|
+
The repo also includes a local browser lab for compiling, validating, and
|
|
203
|
+
packaging modules:
|
|
98
204
|
|
|
99
205
|
```bash
|
|
100
206
|
npm run start:lab
|
|
101
|
-
# http://localhost:4318
|
|
102
207
|
```
|
|
103
208
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Modules declare a `pluginFamily` that tells runtimes what role they serve:
|
|
107
|
-
|
|
108
|
-
| Family | Purpose |
|
|
109
|
-
|---|---|
|
|
110
|
-
| `sensor` | Ingest raw data feeds (radar, optical, RF) |
|
|
111
|
-
| `propagator` | Orbit propagation and state prediction |
|
|
112
|
-
| `renderer` | 3D visualization and scene rendering |
|
|
113
|
-
| `analysis` | Data processing, filtering, aggregation |
|
|
114
|
-
| `data_source` | External data connectors |
|
|
115
|
-
| `comms` | Communications link modeling |
|
|
116
|
-
| `shader` | GPU shader programs |
|
|
117
|
-
| `sdf` | Signed distance field geometry |
|
|
118
|
-
| `infrastructure` | Network and platform services |
|
|
119
|
-
| `flow` | Multi-module data flow orchestration |
|
|
120
|
-
| `bridge` | Cross-runtime adapters |
|
|
121
|
-
|
|
122
|
-
## Host Capabilities
|
|
209
|
+
Then open `http://localhost:4318`.
|
|
123
210
|
|
|
124
|
-
|
|
211
|
+
## Related Projects
|
|
125
212
|
|
|
126
|
-
|
|
213
|
+
- [`spacedatastandards.org`](https://spacedatastandards.org)
|
|
214
|
+
- [`@digitalarsenal/sdn-flow`](https://github.com/DigitalArsenal/sdn-flow)
|
|
215
|
+
- [`hd-wallet-wasm`](https://github.com/nicktj-dev/hd-wallet-wasm)
|
|
127
216
|
|
|
128
217
|
## Development
|
|
129
218
|
|
|
130
219
|
```bash
|
|
131
220
|
npm install
|
|
132
221
|
npm test
|
|
222
|
+
npm run check:compliance
|
|
133
223
|
```
|
|
134
224
|
|
|
135
|
-
|
|
225
|
+
Node.js `>=20` is required. Native compilation paths use Emscripten
|
|
226
|
+
(`emcc` / `em++`) when available.
|
|
136
227
|
|
|
137
228
|
## License
|
|
138
229
|
|
|
139
|
-
|
|
230
|
+
[MIT](./LICENSE)
|
package/bin/space-data-module.js
CHANGED
|
@@ -24,6 +24,11 @@ async function main(argv) {
|
|
|
24
24
|
return runCompile(rest);
|
|
25
25
|
case "protect":
|
|
26
26
|
return runProtect(rest);
|
|
27
|
+
case "help":
|
|
28
|
+
case "--help":
|
|
29
|
+
case "-h":
|
|
30
|
+
printUsage();
|
|
31
|
+
return 0;
|
|
27
32
|
default:
|
|
28
33
|
printUsage();
|
|
29
34
|
return command ? 1 : 0;
|
|
@@ -33,6 +38,7 @@ async function main(argv) {
|
|
|
33
38
|
function parseArgs(argv) {
|
|
34
39
|
const options = {
|
|
35
40
|
json: false,
|
|
41
|
+
singleFileBundle: false,
|
|
36
42
|
repoRoot: process.cwd(),
|
|
37
43
|
manifestPath: null,
|
|
38
44
|
wasmPath: null,
|
|
@@ -49,6 +55,9 @@ function parseArgs(argv) {
|
|
|
49
55
|
case "--json":
|
|
50
56
|
options.json = true;
|
|
51
57
|
break;
|
|
58
|
+
case "--single-file-bundle":
|
|
59
|
+
options.singleFileBundle = true;
|
|
60
|
+
break;
|
|
52
61
|
case "--repo-root":
|
|
53
62
|
options.repoRoot = path.resolve(requireValue(argv, ++index, value));
|
|
54
63
|
break;
|
|
@@ -95,6 +104,7 @@ function printUsage() {
|
|
|
95
104
|
space-data-module check --manifest ./manifest.json --wasm ./dist/module.wasm
|
|
96
105
|
space-data-module compile --manifest ./manifest.json --source ./src/module.c --out ./dist/module.wasm
|
|
97
106
|
space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --json
|
|
107
|
+
space-data-module protect --manifest ./manifest.json --wasm ./dist/module.wasm --single-file-bundle --out ./dist/module.bundle.wasm
|
|
98
108
|
`);
|
|
99
109
|
}
|
|
100
110
|
|
|
@@ -201,6 +211,9 @@ async function runProtect(argv) {
|
|
|
201
211
|
if (!options.manifestPath || !options.wasmPath) {
|
|
202
212
|
throw new Error("protect requires --manifest and --wasm.");
|
|
203
213
|
}
|
|
214
|
+
if (options.outputPath && options.singleFileBundle !== true) {
|
|
215
|
+
throw new Error("protect only supports --out together with --single-file-bundle.");
|
|
216
|
+
}
|
|
204
217
|
const manifest = await loadManifestFromFile(options.manifestPath);
|
|
205
218
|
const wasmBytes = new Uint8Array(await readFile(options.wasmPath));
|
|
206
219
|
const result = await protectModuleArtifact({
|
|
@@ -208,7 +221,11 @@ async function runProtect(argv) {
|
|
|
208
221
|
wasmBytes,
|
|
209
222
|
recipientPublicKeyHex: options.recipientPublicKeyHex,
|
|
210
223
|
mnemonic: options.mnemonic,
|
|
224
|
+
singleFileBundle: options.singleFileBundle,
|
|
211
225
|
});
|
|
226
|
+
if (options.singleFileBundle && options.outputPath && result.bundledWasmBytes) {
|
|
227
|
+
await writeFile(options.outputPath, result.bundledWasmBytes);
|
|
228
|
+
}
|
|
212
229
|
if (options.json) {
|
|
213
230
|
console.log(JSON.stringify(result, null, 2));
|
|
214
231
|
} else {
|
|
@@ -216,6 +233,13 @@ async function runProtect(argv) {
|
|
|
216
233
|
console.log(`signingPublicKeyHex=${result.signingPublicKeyHex}`);
|
|
217
234
|
console.log(`encrypted=${result.encrypted}`);
|
|
218
235
|
console.log(`wasmBase64Length=${bytesToBase64(wasmBytes).length}`);
|
|
236
|
+
if (result.bundledWasmBytes) {
|
|
237
|
+
console.log(`singleFileBundle=true`);
|
|
238
|
+
console.log(`bundledWasmBytes=${result.bundledWasmBytes.length}`);
|
|
239
|
+
}
|
|
240
|
+
if (options.outputPath) {
|
|
241
|
+
console.log(`outputPath=${options.outputPath}`);
|
|
242
|
+
}
|
|
219
243
|
}
|
|
220
244
|
return 0;
|
|
221
245
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "space-data-module-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
6
7
|
"bin": {
|
|
7
8
|
"space-data-module": "./bin/space-data-module.js"
|
|
8
9
|
},
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
"./auth": "./src/auth/index.js",
|
|
14
15
|
"./transport": "./src/transport/index.js",
|
|
15
16
|
"./compiler": "./src/compiler/index.js",
|
|
17
|
+
"./bundle": "./src/bundle/index.js",
|
|
16
18
|
"./standards": "./src/standards/index.js",
|
|
17
19
|
"./schemas/*": "./schemas/*"
|
|
18
20
|
},
|
|
@@ -24,11 +26,14 @@
|
|
|
24
26
|
"scripts": {
|
|
25
27
|
"test": "node --test",
|
|
26
28
|
"start:lab": "node ./lab/server.js",
|
|
27
|
-
"check:compliance": "node ./bin/space-data-module.js check --repo-root ."
|
|
29
|
+
"check:compliance": "node ./bin/space-data-module.js check --repo-root .",
|
|
30
|
+
"generate:vectors": "node ./examples/single-file-bundle/generate-vectors.mjs",
|
|
31
|
+
"prepublishOnly": "npm test && npm run check:compliance"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
34
|
+
"sdn-emception": "1.0.0",
|
|
30
35
|
"flatbuffers": "^25.9.23",
|
|
31
|
-
"hd-wallet-wasm": "
|
|
36
|
+
"hd-wallet-wasm": "1.6.0",
|
|
32
37
|
"spacedatastandards.org": "23.3.3-0.3.4"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|