@nimbus-sh/sdk 0.1.0 → 0.1.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 +45 -6
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/token.d.ts +3 -4
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +3 -4
- package/dist/worker.d.ts +11 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +9 -0
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @nimbus-sh/sdk
|
|
2
2
|
|
|
3
|
-
SDK for Nimbus — programmatic sandbox handles,
|
|
4
|
-
errors, and session URL helpers.
|
|
3
|
+
SDK for Nimbus — Worker embedder, programmatic sandbox handles,
|
|
4
|
+
token mint/verify, typed errors, and session URL helpers.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -9,6 +9,11 @@ errors, and session URL helpers.
|
|
|
9
9
|
npm install @nimbus-sh/sdk @nimbus-sh/worker @nimbus-sh/config
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
Use `@nimbus-sh/sdk/worker` as the public Worker embedder entrypoint.
|
|
13
|
+
`@nimbus-sh/worker` is still installed because it carries the runtime assets
|
|
14
|
+
and Durable Object implementation, but application code imports the
|
|
15
|
+
deploy-time API through the SDK.
|
|
16
|
+
|
|
12
17
|
The sandbox SDK is meant to run inside the Worker or Durable Object that owns
|
|
13
18
|
the `NIMBUS_SESSION` binding. A minimal project setup is:
|
|
14
19
|
|
|
@@ -16,8 +21,40 @@ the `NIMBUS_SESSION` binding. A minimal project setup is:
|
|
|
16
21
|
npx @nimbus-sh/cli init my-nimbus-worker
|
|
17
22
|
cd my-nimbus-worker
|
|
18
23
|
npm install
|
|
19
|
-
|
|
20
|
-
wrangler
|
|
24
|
+
CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name my-nimbus-worker
|
|
25
|
+
npx wrangler secret put JWT_SECRET
|
|
26
|
+
npx wrangler deploy
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`src/index.ts`:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {
|
|
33
|
+
NimbusSession,
|
|
34
|
+
SupervisorRPC,
|
|
35
|
+
NimbusAssetsRPC,
|
|
36
|
+
NimbusLoaderRPC,
|
|
37
|
+
NimbusLoadedWorker,
|
|
38
|
+
NimbusLoadedEntrypoint,
|
|
39
|
+
NimbusDurableObjectNamespace,
|
|
40
|
+
NimbusDOStub,
|
|
41
|
+
CirrusHmrRPC,
|
|
42
|
+
createNimbusHandler,
|
|
43
|
+
} from '@nimbus-sh/sdk/worker';
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
NimbusSession,
|
|
47
|
+
SupervisorRPC,
|
|
48
|
+
NimbusAssetsRPC,
|
|
49
|
+
NimbusLoaderRPC,
|
|
50
|
+
NimbusLoadedWorker,
|
|
51
|
+
NimbusLoadedEntrypoint,
|
|
52
|
+
NimbusDurableObjectNamespace,
|
|
53
|
+
NimbusDOStub,
|
|
54
|
+
CirrusHmrRPC,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default createNimbusHandler();
|
|
21
58
|
```
|
|
22
59
|
|
|
23
60
|
From this repository, use the source CLI:
|
|
@@ -26,8 +63,9 @@ From this repository, use the source CLI:
|
|
|
26
63
|
bun packages/cli/src/bin.ts init my-nimbus-worker
|
|
27
64
|
cd my-nimbus-worker
|
|
28
65
|
bun install
|
|
29
|
-
|
|
30
|
-
wrangler
|
|
66
|
+
CLOUDFLARE_ACCOUNT_ID=<account-id> bun ../packages/cli/src/bin.ts setup cloudflare --name my-nimbus-worker
|
|
67
|
+
npx wrangler secret put JWT_SECRET
|
|
68
|
+
npx wrangler deploy
|
|
31
69
|
```
|
|
32
70
|
|
|
33
71
|
## Programmatic sandbox quickstart
|
|
@@ -213,6 +251,7 @@ const { token, url } = await mintAndAttach(
|
|
|
213
251
|
| `@nimbus-sh/sdk/errors` | `NimbusAuthError` class hierarchy. |
|
|
214
252
|
| `@nimbus-sh/sdk/session` | `sessionAttachUrl`, `mintAndAttach`. |
|
|
215
253
|
| `@nimbus-sh/sdk/sandbox` | `Nimbus`, `NimbusSandbox`, programmatic exec/files/runtimes/processes/ports/tools. |
|
|
254
|
+
| `@nimbus-sh/sdk/worker` | Worker embedder entrypoint: `NimbusSession`, RPC classes, `createNimbusHandler`, auth helpers. |
|
|
216
255
|
|
|
217
256
|
## Token wire format
|
|
218
257
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @nimbus-sh/sdk —
|
|
2
|
+
* @nimbus-sh/sdk — Public SDK for Nimbus.
|
|
3
3
|
*
|
|
4
|
-
* The SDK is the
|
|
5
|
-
* verify, typed errors, session-handle
|
|
6
|
-
*
|
|
7
|
-
* from a Node SSR layer, a Worker, an Edge function, or a browser
|
|
8
|
-
* build.
|
|
4
|
+
* The SDK is the public surface for Nimbus applications: token mint /
|
|
5
|
+
* verify, typed errors, session-handle helpers, programmatic sandboxes,
|
|
6
|
+
* and the Worker embedder subpath.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Import the deployed Worker embedder from `@nimbus-sh/sdk/worker`.
|
|
9
|
+
* The Durable Object, router, assets, VFS, and facet implementation live
|
|
10
|
+
* in `@nimbus-sh/worker` and are re-exported through that public SDK
|
|
11
|
+
* subpath.
|
|
12
12
|
*
|
|
13
13
|
* @example mint a token in your Worker's `/api/auth/mint` route
|
|
14
14
|
* ```ts
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @nimbus-sh/sdk —
|
|
2
|
+
* @nimbus-sh/sdk — Public SDK for Nimbus.
|
|
3
3
|
*
|
|
4
|
-
* The SDK is the
|
|
5
|
-
* verify, typed errors, session-handle
|
|
6
|
-
*
|
|
7
|
-
* from a Node SSR layer, a Worker, an Edge function, or a browser
|
|
8
|
-
* build.
|
|
4
|
+
* The SDK is the public surface for Nimbus applications: token mint /
|
|
5
|
+
* verify, typed errors, session-handle helpers, programmatic sandboxes,
|
|
6
|
+
* and the Worker embedder subpath.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Import the deployed Worker embedder from `@nimbus-sh/sdk/worker`.
|
|
9
|
+
* The Durable Object, router, assets, VFS, and facet implementation live
|
|
10
|
+
* in `@nimbus-sh/worker` and are re-exported through that public SDK
|
|
11
|
+
* subpath.
|
|
12
12
|
*
|
|
13
13
|
* @example mint a token in your Worker's `/api/auth/mint` route
|
|
14
14
|
* ```ts
|
package/dist/token.d.ts
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* Why a re-export and not a copy? The auth module is the single source
|
|
6
6
|
* of truth — both Worker (verify) and SDK (mint) call the same code
|
|
7
7
|
* paths so wire-format drift is structurally impossible. The
|
|
8
|
-
* `@nimbus-sh/worker`
|
|
9
|
-
* package
|
|
10
|
-
*
|
|
11
|
-
* worker peer-dep is tree-shaken to its auth subpath.
|
|
8
|
+
* `@nimbus-sh/worker` provides the shared auth implementation. The SDK
|
|
9
|
+
* package depends on that single source of truth so token wire-format
|
|
10
|
+
* drift is structurally impossible.
|
|
12
11
|
*
|
|
13
12
|
* @example mint
|
|
14
13
|
* ```ts
|
package/dist/token.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC"}
|
package/dist/token.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* Why a re-export and not a copy? The auth module is the single source
|
|
6
6
|
* of truth — both Worker (verify) and SDK (mint) call the same code
|
|
7
7
|
* paths so wire-format drift is structurally impossible. The
|
|
8
|
-
* `@nimbus-sh/worker`
|
|
9
|
-
* package
|
|
10
|
-
*
|
|
11
|
-
* worker peer-dep is tree-shaken to its auth subpath.
|
|
8
|
+
* `@nimbus-sh/worker` provides the shared auth implementation. The SDK
|
|
9
|
+
* package depends on that single source of truth so token wire-format
|
|
10
|
+
* drift is structurally impossible.
|
|
12
11
|
*
|
|
13
12
|
* @example mint
|
|
14
13
|
* ```ts
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nimbus-sh/sdk/worker - Cloudflare Worker embedder surface.
|
|
3
|
+
*
|
|
4
|
+
* This is the public entrypoint for deploying Nimbus itself inside a
|
|
5
|
+
* Worker. The implementation is provided by @nimbus-sh/worker, but apps
|
|
6
|
+
* should import through the SDK so the interactive app and programmatic
|
|
7
|
+
* sandbox APIs share one public package surface.
|
|
8
|
+
*/
|
|
9
|
+
export { NimbusSession, SupervisorRPC, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub, CirrusHmrRPC, createNimbusHandler, issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from '@nimbus-sh/worker';
|
|
10
|
+
export type { NimbusHandler, NimbusHooks, NimbusHookContext, CustomRoutes, CreateNimbusHandlerOptions, AuthMode, NimbusAuthConfig, NimbusAuthEnv, NimbusTokenClaims, VerifiedNimbusToken, } from '@nimbus-sh/worker';
|
|
11
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nimbus-sh/sdk/worker - Cloudflare Worker embedder surface.
|
|
3
|
+
*
|
|
4
|
+
* This is the public entrypoint for deploying Nimbus itself inside a
|
|
5
|
+
* Worker. The implementation is provided by @nimbus-sh/worker, but apps
|
|
6
|
+
* should import through the SDK so the interactive app and programmatic
|
|
7
|
+
* sandbox APIs share one public package surface.
|
|
8
|
+
*/
|
|
9
|
+
export { NimbusSession, SupervisorRPC, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub, CirrusHmrRPC, createNimbusHandler, issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from '@nimbus-sh/worker';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Nimbus SDK — programmatic sandboxes, token mint,
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Nimbus SDK — Worker embedder, programmatic sandboxes, token mint, and client helpers.",
|
|
5
5
|
"homepage": "https://github.com/AshishKumar4/Nimbus",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"types": "./dist/sandbox.d.ts",
|
|
36
36
|
"import": "./dist/sandbox.js"
|
|
37
37
|
},
|
|
38
|
+
"./worker": {
|
|
39
|
+
"workspace": "./src/worker.ts",
|
|
40
|
+
"types": "./dist/worker.d.ts",
|
|
41
|
+
"import": "./dist/worker.js"
|
|
42
|
+
},
|
|
38
43
|
"./errors": {
|
|
39
44
|
"workspace": "./src/errors.ts",
|
|
40
45
|
"types": "./dist/errors.d.ts",
|
|
@@ -52,14 +57,11 @@
|
|
|
52
57
|
"typecheck": "tsc --noEmit"
|
|
53
58
|
},
|
|
54
59
|
"peerDependencies": {
|
|
55
|
-
"@nimbus-sh/worker": "^0.1.
|
|
56
|
-
},
|
|
57
|
-
"peerDependenciesMeta": {
|
|
58
|
-
"@nimbus-sh/worker": { "optional": true }
|
|
60
|
+
"@nimbus-sh/worker": "^0.1.1"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@cloudflare/workers-types": "^4.20250327.0",
|
|
62
|
-
"@nimbus-sh/worker": "^0.1.
|
|
64
|
+
"@nimbus-sh/worker": "^0.1.1",
|
|
63
65
|
"typescript": "^5.7.0"
|
|
64
66
|
},
|
|
65
67
|
"publishConfig": {
|