@tangle-network/sandbox 0.0.3

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 ADDED
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2025 Tangle Network
2
+
3
+ All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are proprietary
6
+ and confidential. No part of this Software may be reproduced, distributed, or
7
+ transmitted in any form or by any means, including photocopying, recording, or
8
+ other electronic or mechanical methods, without the prior written permission of
9
+ Tangle Network.
10
+
11
+ For licensing inquiries, contact: hello@tangle.tools
package/README.md ADDED
@@ -0,0 +1,610 @@
1
+ # @tangle-network/sandbox
2
+
3
+ TypeScript SDK for the Tangle Sandbox platform. Create isolated dev containers, run AI agents, and build automation workflows.
4
+
5
+ A separate CLI is published as `@tangle-network/sandbox-cli`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @tangle-network/sandbox
11
+ # or
12
+ pnpm add @tangle-network/sandbox
13
+ # or
14
+ yarn add @tangle-network/sandbox
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { Sandbox } from "@tangle-network/sandbox";
21
+
22
+ // Initialize the client
23
+ const client = new Sandbox({
24
+ apiKey: "sk_sandbox_...",
25
+ baseUrl: "https://your-sandbox-api.example.com",
26
+ });
27
+
28
+ // Create a sandbox
29
+ const box = await client.create({
30
+ name: "my-project",
31
+ image: "node:20",
32
+ });
33
+
34
+ // Execute commands
35
+ const result = await box.exec("npm install && npm test");
36
+ console.log(result.stdout);
37
+
38
+ // Run an AI agent task
39
+ const task = await box.task("Fix any failing tests and commit the changes");
40
+ console.log(task.response);
41
+
42
+ // Clean up
43
+ await box.delete();
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - **Sandbox Management** - Create, list, stop, resume, and delete sandboxes
49
+ - **Command Execution** - Run shell commands in isolated containers
50
+ - **AI Agent Tasks** - Multi-turn agent execution with automatic tool use
51
+ - **Snapshots** - Save and restore sandbox state
52
+ - **BYOS3** - Bring your own S3 storage for snapshots
53
+ - **Batch Execution** - Run tasks across multiple sandboxes in parallel
54
+ - **Event Streaming** - Real-time SSE streams for agent events
55
+ - **Collaboration Foundations** - Token issuance and document identity helpers for collaborative editing
56
+
57
+ ## Collaboration Foundations
58
+
59
+ The SDK now includes the first collaboration primitives for product backends:
60
+
61
+ - collaboration token issuance from `@tangle-network/sandbox/auth`
62
+ - stable document identity helpers from `@tangle-network/sandbox/collaboration`
63
+ - a collaboration API client for bootstrap / token refresh / snapshot calls
64
+ - a headless file bridge for syncing document adapters with sandbox files
65
+
66
+ Example:
67
+
68
+ ```typescript
69
+ import {
70
+ buildCollaborationDocumentId,
71
+ } from "@tangle-network/sandbox/collaboration";
72
+ import { ProductTokenIssuer } from "@tangle-network/sandbox/auth";
73
+
74
+ const issuer = new ProductTokenIssuer({
75
+ productId: "gtm-agent",
76
+ signingSecret: process.env.SANDBOX_SIGNING_SECRET!,
77
+ });
78
+
79
+ const documentId = buildCollaborationDocumentId({
80
+ workspaceId: "ws_123",
81
+ relativePath: "system/operating-system.md",
82
+ });
83
+
84
+ const { token, expiresAt } = issuer.issueCollaboration({
85
+ userId: "user_123",
86
+ sessionId: "sess_456",
87
+ projectId: "ws_123",
88
+ documentId,
89
+ access: "write",
90
+ });
91
+ ```
92
+
93
+ Bootstrap and snapshot helpers:
94
+
95
+ ```typescript
96
+ import { CollaborationClient } from "@tangle-network/sandbox/collaboration";
97
+
98
+ const collab = new CollaborationClient({
99
+ baseUrl: "https://app.example.com",
100
+ headers: () => ({
101
+ Authorization: `Bearer ${sessionToken}`,
102
+ }),
103
+ });
104
+
105
+ const bootstrap = await collab.bootstrap({
106
+ workspaceId: "ws_123",
107
+ relativePath: "system/operating-system.md",
108
+ });
109
+ ```
110
+
111
+ The bridge and client are SDK-side primitives. Product/backend endpoints and CRDT runtime integration still need to be wired by the application.
112
+
113
+ ## Core Concepts
114
+
115
+ ### Sandboxes
116
+
117
+ A sandbox is an isolated dev container with:
118
+ - A programmatic runtime API
119
+ - Optional SSH access
120
+ - Optional web terminal
121
+ - Persistent storage with snapshots
122
+
123
+ ```typescript
124
+ const box = await client.create({
125
+ name: "my-sandbox",
126
+ image: "python:3.12",
127
+ env: { DEBUG: "true" },
128
+ sshEnabled: true,
129
+ maxLifetimeSeconds: 7200, // 2 hours
130
+ idleTimeoutSeconds: 1800, // 30 min idle timeout
131
+ resources: {
132
+ cpuCores: 2,
133
+ memoryMB: 4096,
134
+ diskGB: 20,
135
+ },
136
+ });
137
+ ```
138
+
139
+ ### Status Lifecycle
140
+
141
+ ```
142
+ pending -> provisioning -> running -> stopped -> deleted
143
+ |
144
+ v
145
+ failed
146
+ ```
147
+
148
+ ## API Reference
149
+
150
+ ### Client
151
+
152
+ ```typescript
153
+ import { Sandbox } from "@tangle-network/sandbox";
154
+
155
+ const client = new Sandbox({
156
+ apiKey: "sk_sandbox_...",
157
+ baseUrl: "https://your-sandbox-api.example.com", // required
158
+ timeoutMs: 30000, // optional
159
+ });
160
+ ```
161
+
162
+ #### `client.create(options?)`
163
+
164
+ Create a new sandbox.
165
+
166
+ ```typescript
167
+ const box = await client.create({
168
+ name: "my-project",
169
+ image: "node:20", // or "typescript" for pre-built image
170
+ agentIdentifier: "my-agent", // agent to run
171
+ env: { NODE_ENV: "development" },
172
+ sshEnabled: true,
173
+ sshPublicKey: "ssh-ed25519 AAAA...",
174
+ webTerminalEnabled: true,
175
+ maxLifetimeSeconds: 3600,
176
+ idleTimeoutSeconds: 900,
177
+ resources: {
178
+ cpuCores: 2,
179
+ memoryMB: 4096,
180
+ diskGB: 20,
181
+ },
182
+ metadata: { team: "platform" },
183
+ // BYOS3: Customer-provided storage
184
+ storage: {
185
+ type: "s3",
186
+ bucket: "my-snapshots",
187
+ region: "us-east-1",
188
+ credentials: {
189
+ accessKeyId: "AKIA...",
190
+ secretAccessKey: "...",
191
+ },
192
+ },
193
+ fromSnapshot: "snap_abc123", // restore from snapshot
194
+ });
195
+ ```
196
+
197
+ #### `client.list(options?)`
198
+
199
+ List all sandboxes.
200
+
201
+ ```typescript
202
+ const sandboxes = await client.list({
203
+ status: "running", // filter by status
204
+ limit: 10,
205
+ offset: 0,
206
+ });
207
+ ```
208
+
209
+ #### `client.get(id)`
210
+
211
+ Get a sandbox by ID.
212
+
213
+ ```typescript
214
+ const box = await client.get("sandbox_abc123");
215
+ if (box) {
216
+ console.log(box.status);
217
+ }
218
+ ```
219
+
220
+ #### `client.usage()`
221
+
222
+ Get account usage information.
223
+
224
+ ```typescript
225
+ const usage = await client.usage();
226
+ console.log(`Active: ${usage.activeSandboxes}`);
227
+ console.log(`Compute: ${usage.computeMinutes} minutes`);
228
+ ```
229
+
230
+ #### `client.runBatch(tasks, options?)`
231
+
232
+ Run tasks across multiple sandboxes in parallel.
233
+
234
+ ```typescript
235
+ const result = await client.runBatch([
236
+ { id: "task-1", message: "Analyze code quality" },
237
+ { id: "task-2", message: "Run security scan" },
238
+ { id: "task-3", message: "Generate documentation" },
239
+ ], {
240
+ timeoutMs: 300000,
241
+ scalingMode: "balanced", // "fastest" | "balanced" | "cheapest"
242
+ });
243
+
244
+ console.log(`Success rate: ${result.successRate}%`);
245
+ ```
246
+
247
+ ### Sandbox Instance
248
+
249
+ After creating or retrieving a sandbox, you get a `SandboxInstance` with these methods:
250
+
251
+ #### `box.exec(command, options?)`
252
+
253
+ Execute a shell command.
254
+
255
+ ```typescript
256
+ const result = await box.exec("npm install", {
257
+ cwd: "/workspace",
258
+ env: { CI: "true" },
259
+ timeoutMs: 60000,
260
+ });
261
+
262
+ console.log(result.exitCode); // 0
263
+ console.log(result.stdout);
264
+ console.log(result.stderr);
265
+ ```
266
+
267
+ #### `box.prompt(message, options?)`
268
+
269
+ Send a single prompt to the AI agent.
270
+
271
+ ```typescript
272
+ const result = await box.prompt("What files are in this project?", {
273
+ sessionId: "session_123", // for conversation continuity
274
+ model: "anthropic/claude-sonnet-4-20250514",
275
+ timeoutMs: 120000,
276
+ });
277
+
278
+ console.log(result.response);
279
+ console.log(result.usage); // { inputTokens, outputTokens }
280
+ ```
281
+
282
+ #### Backend Selection
283
+
284
+ Each sandbox runs one AI backend. Pass `backend.type` to choose it:
285
+
286
+ | Type | Runtime | When to use |
287
+ |------|---------|-------------|
288
+ | `opencode` | [OpenCode](https://github.com/anomalyco/opencode) | Default. Multi-provider, profile system, MCP support |
289
+ | `claude-code` | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Anthropic-native. Needs ANTHROPIC_API_KEY |
290
+ | `codex` | [Codex CLI](https://github.com/openai/codex) | OpenAI-native. Needs OPENAI_API_KEY |
291
+ | `amp` | [AMP](https://sourcegraph.com/amp) | Sourcegraph AMP agent |
292
+ | `factory-droids` | [Factory](https://factory.ai) | Factory Droid agent |
293
+
294
+ ```typescript
295
+ // Use Claude Code backend
296
+ await box.prompt("Fix the auth bug", {
297
+ backend: { type: "claude-code" },
298
+ });
299
+
300
+ // Use Codex with a named profile
301
+ await box.prompt("Audit this repo", {
302
+ backend: { type: "codex", profile: "browser-codex-fast" },
303
+ });
304
+
305
+ // Use OpenCode with an inline profile
306
+ await box.prompt("Audit this repo", {
307
+ backend: {
308
+ type: "opencode",
309
+ profile: {
310
+ name: "security-auditor",
311
+ prompt: {
312
+ systemPrompt: "Focus on authorization and sandbox boundary mistakes.",
313
+ },
314
+ tools: { bash: true },
315
+ permissions: { bash: "allow" },
316
+ },
317
+ },
318
+ });
319
+
320
+ // BYOK (Bring Your Own Key)
321
+ await box.prompt("Analyze this", {
322
+ backend: {
323
+ type: "opencode",
324
+ model: {
325
+ provider: "anthropic",
326
+ model: "claude-sonnet-4-20250514",
327
+ apiKey: process.env.MY_ANTHROPIC_KEY,
328
+ },
329
+ },
330
+ });
331
+ ```
332
+
333
+ The SDK serializes `backend.profile` into the required wire format automatically.
334
+
335
+ #### `box.task(message, options?)`
336
+
337
+ Run a multi-turn agent task. The agent keeps working until completion.
338
+
339
+ ```typescript
340
+ const result = await box.task("Set up a REST API with authentication", {
341
+ maxTurns: 20, // limit turns (0 = unlimited)
342
+ sessionId: "...", // continue previous session
343
+ });
344
+
345
+ console.log(result.turnsUsed);
346
+ console.log(result.response);
347
+ ```
348
+
349
+ #### `box.streamPrompt(message, options?)`
350
+
351
+ Stream agent events in real-time.
352
+
353
+ ```typescript
354
+ for await (const event of box.streamPrompt("Explain this codebase")) {
355
+ switch (event.type) {
356
+ case "message.part.updated": {
357
+ const part = event.data.part as { type?: string; text?: string };
358
+ if (part.type === "text" && event.data.delta) {
359
+ process.stdout.write(String(event.data.delta));
360
+ }
361
+ if (part.type === "reasoning" && event.data.delta) {
362
+ // Reasoning/thinking tokens from extended thinking models
363
+ process.stderr.write(`[thinking] ${String(event.data.delta)}`);
364
+ }
365
+ break;
366
+ }
367
+ case "result":
368
+ console.log("\nFinal:", event.data.finalText);
369
+ break;
370
+ case "done":
371
+ console.log("\nComplete!");
372
+ break;
373
+ }
374
+ }
375
+ ```
376
+
377
+ #### `box.streamTask(message, options?)`
378
+
379
+ Stream a multi-turn task with real-time events.
380
+
381
+ ```typescript
382
+ for await (const event of box.streamTask("Build a CLI tool")) {
383
+ // Handle events...
384
+ }
385
+ ```
386
+
387
+ #### `box.direct()`
388
+
389
+ Create an explicit advanced direct-runtime view of the sandbox.
390
+
391
+ ```typescript
392
+ const directBox = box.direct();
393
+ const result = await directBox.exec("npm test");
394
+ ```
395
+
396
+ #### `box.events(options?)`
397
+
398
+ Subscribe to sandbox lifecycle events.
399
+
400
+ ```typescript
401
+ for await (const event of box.events({ signal: controller.signal })) {
402
+ console.log(`Event: ${event.type}`, event.data);
403
+ }
404
+ ```
405
+
406
+ ### Snapshots
407
+
408
+ #### `box.snapshot(options?)`
409
+
410
+ Create a snapshot of the sandbox state.
411
+
412
+ ```typescript
413
+ const snapshot = await box.snapshot({
414
+ tags: ["v1.0", "stable"],
415
+ paths: ["/workspace"], // specific paths (default: all)
416
+ });
417
+
418
+ console.log(snapshot.snapshotId);
419
+ console.log(snapshot.sizeBytes);
420
+ ```
421
+
422
+ #### `box.listSnapshots()`
423
+
424
+ List all snapshots for this sandbox.
425
+
426
+ ```typescript
427
+ const snapshots = await box.listSnapshots();
428
+ for (const snap of snapshots) {
429
+ console.log(`${snap.snapshotId}: ${snap.createdAt}`);
430
+ }
431
+ ```
432
+
433
+ ### BYOS3 (Bring Your Own S3)
434
+
435
+ Store snapshots in your own S3-compatible storage. Supports AWS S3, Google Cloud Storage, and Cloudflare R2.
436
+
437
+ #### Creating a sandbox with BYOS3
438
+
439
+ ```typescript
440
+ const box = await client.create({
441
+ name: "my-sandbox",
442
+ storage: {
443
+ type: "s3", // "s3" | "gcs" | "r2"
444
+ bucket: "my-snapshots",
445
+ region: "us-east-1",
446
+ endpoint: "https://s3.us-east-1.amazonaws.com", // optional
447
+ credentials: {
448
+ accessKeyId: "AKIA...",
449
+ secretAccessKey: "...",
450
+ },
451
+ prefix: "sandbox-snapshots/", // optional path prefix
452
+ },
453
+ fromSnapshot: "snap_abc123", // restore from your storage
454
+ });
455
+ ```
456
+
457
+ #### Snapshots with BYOS3
458
+
459
+ When storage is configured, snapshots are written directly to your bucket:
460
+
461
+ ```typescript
462
+ // Create snapshot to your S3
463
+ const snap = await box.snapshot({
464
+ tags: ["production"],
465
+ storage: {
466
+ type: "s3",
467
+ bucket: "my-snapshots",
468
+ credentials: { accessKeyId: "...", secretAccessKey: "..." },
469
+ },
470
+ });
471
+
472
+ // List snapshots from your S3
473
+ const snapshots = await box.listSnapshots({
474
+ type: "s3",
475
+ bucket: "my-snapshots",
476
+ credentials: { ... },
477
+ });
478
+
479
+ // Restore from your S3
480
+ await box.restoreFromStorage({
481
+ type: "s3",
482
+ bucket: "my-snapshots",
483
+ credentials: { ... },
484
+ });
485
+ ```
486
+
487
+ ### Runtime Routing
488
+
489
+ By default, SDK runtime calls like `exec()`, `prompt()`, `task()`, file ops, git, and process management go through the Sandbox API, which dispatches them to the correct running sandbox for the authenticated user.
490
+
491
+ Runtime agent calls can pass a named backend profile or an inline provider-neutral profile object:
492
+
493
+ ```typescript
494
+ const result = await box.prompt("Audit the authentication flow", {
495
+ backend: {
496
+ profile: {
497
+ name: "security-auditor",
498
+ prompt: {
499
+ systemPrompt: "You are a senior application security auditor.",
500
+ instructions: ["Prioritize authz, tenancy, and secret handling."],
501
+ },
502
+ tools: { bash: true },
503
+ permissions: { bash: "allow" },
504
+ },
505
+ },
506
+ });
507
+ ```
508
+
509
+ ### Direct Runtime Access
510
+
511
+ For advanced use cases, use `box.direct()` to make runtime calls directly against the sandbox runtime while keeping normal lifecycle methods on the API client:
512
+
513
+ ```typescript
514
+ const directBox = box.direct();
515
+ const result = await directBox.exec("npm test");
516
+ ```
517
+
518
+ This is the recommended advanced path for power users who want runtime-level access without re-implementing auth/header plumbing themselves.
519
+
520
+ ### Lifecycle Methods
521
+
522
+ ```typescript
523
+ // Stop (preserves state)
524
+ await box.stop();
525
+
526
+ // Resume
527
+ await box.resume();
528
+
529
+ // Delete (destroys everything)
530
+ await box.delete();
531
+
532
+ // Refresh status from API
533
+ await box.refresh();
534
+
535
+ // Wait for specific status
536
+ await box.waitFor("running", { timeoutMs: 60000 });
537
+ ```
538
+
539
+ ### Properties
540
+
541
+ ```typescript
542
+ box.id // Unique identifier
543
+ box.name // Human-readable name
544
+ box.status // "pending" | "provisioning" | "running" | "stopped" | "failed"
545
+ box.connection // raw direct connection info for advanced use
546
+ box.metadata // Custom metadata
547
+ box.createdAt // Date
548
+ box.startedAt // Date | undefined
549
+ box.lastActivityAt // Date | undefined
550
+ box.expiresAt // Date | undefined
551
+ box.error // Error message if failed
552
+ ```
553
+
554
+ ## Error Handling
555
+
556
+ ```typescript
557
+ import {
558
+ AuthError,
559
+ NetworkError,
560
+ NotFoundError,
561
+ QuotaError,
562
+ StateError,
563
+ TimeoutError,
564
+ ValidationError,
565
+ } from "@tangle-network/sandbox";
566
+
567
+ try {
568
+ await box.exec("npm test");
569
+ } catch (err) {
570
+ if (err instanceof TimeoutError) {
571
+ console.log("Command timed out");
572
+ } else if (err instanceof StateError) {
573
+ console.log(`Invalid state: ${err.currentState}`);
574
+ } else if (err instanceof NetworkError) {
575
+ console.log("Connection failed");
576
+ }
577
+ }
578
+ ```
579
+
580
+ ## TypeScript
581
+
582
+ Full TypeScript support with exported types:
583
+
584
+ ```typescript
585
+ import type {
586
+ SandboxClientConfig,
587
+ CreateSandboxOptions,
588
+ SandboxInfo,
589
+ SandboxStatus,
590
+ SandboxConnection,
591
+ ExecResult,
592
+ ExecOptions,
593
+ PromptResult,
594
+ PromptOptions,
595
+ TaskResult,
596
+ TaskOptions,
597
+ SnapshotResult,
598
+ SnapshotOptions,
599
+ SnapshotInfo,
600
+ StorageConfig,
601
+ BatchTask,
602
+ BatchResult,
603
+ BatchOptions,
604
+ UsageInfo,
605
+ } from "@tangle-network/sandbox";
606
+ ```
607
+
608
+ ## License
609
+
610
+ MIT
@@ -0,0 +1,2 @@
1
+ import { _ as SessionScopedTokenPayload, a as issueBatchScopedToken, c as issueReadToken, d as BatchScopedTokenPayload, f as CollaborationAccess, g as ReadTokenPayload, h as ProjectScopedTokenPayload, i as isTokenExpiringSoon, l as issueSessionScopedToken, m as IssueCollaborationTokenOptions, n as decodeToken, o as issueCollaborationToken, p as CollaborationTokenPayload, r as getTokenTTL, s as issueProjectScopedToken, t as ProductTokenIssuer, u as AnyTokenPayload, v as TokenScope } from "../index-A6QuCBt3.js";
2
+ export { AnyTokenPayload, BatchScopedTokenPayload, CollaborationAccess, CollaborationTokenPayload, IssueCollaborationTokenOptions, ProductTokenIssuer, ProjectScopedTokenPayload, ReadTokenPayload, SessionScopedTokenPayload, TokenScope, decodeToken, getTokenTTL, isTokenExpiringSoon, issueBatchScopedToken, issueCollaborationToken, issueProjectScopedToken, issueReadToken, issueSessionScopedToken };
@@ -0,0 +1 @@
1
+ (function(_0x4137b3,_0x1d0c4d){var _0x3e81e1=a0_0xc9bf,_0x50f32b=_0x4137b3();while(!![]){try{var _0x45fbdb=parseInt(_0x3e81e1(0x11c))/0x1+-parseInt(_0x3e81e1(0x11b))/0x2*(parseInt(_0x3e81e1(0x11e))/0x3)+-parseInt(_0x3e81e1(0x120))/0x4+parseInt(_0x3e81e1(0x119))/0x5+parseInt(_0x3e81e1(0x11d))/0x6*(parseInt(_0x3e81e1(0x118))/0x7)+parseInt(_0x3e81e1(0x121))/0x8*(-parseInt(_0x3e81e1(0x11a))/0x9)+parseInt(_0x3e81e1(0x11f))/0xa;if(_0x45fbdb===_0x1d0c4d)break;else _0x50f32b['push'](_0x50f32b['shift']());}catch(_0x4beab5){_0x50f32b['push'](_0x50f32b['shift']());}}}(a0_0x46ad,0x630f0));import{a as a0_0x5a04e1,c as a0_0x1377bf,i as a0_0x472185,l as a0_0x360bff,n as a0_0x5d5658,o as a0_0x4fecd9,r as a0_0x108440,s as a0_0x13ed17,t as a0_0x42a88c}from'\x2e\x2e\x2f\x61\x75\x74\x68\x2d\x42\x49\x38\x47\x55\x64\x6e\x32\x2e\x6a\x73';function a0_0x46ad(){var _0xe7862e=['\x6d\x4a\x6d\x35\x6d\x5a\x6d\x32\x71\x4b\x72\x6b\x75\x32\x76\x6f','\x6d\x5a\x69\x30\x6f\x64\x69\x30\x73\x4d\x54\x59\x75\x4b\x7a\x66','\x6d\x74\x75\x30\x6d\x4b\x44\x49\x77\x4d\x44\x50\x7a\x47','\x6d\x74\x76\x71\x74\x31\x44\x57\x76\x65\x75','\x6d\x4a\x61\x34\x6e\x64\x43\x33\x6d\x65\x44\x69\x74\x66\x6a\x4d\x73\x57','\x6d\x4a\x4b\x32\x6e\x4a\x47\x30\x6d\x68\x72\x56\x75\x4b\x6e\x73\x7a\x61','\x6d\x74\x75\x58\x6e\x64\x4b\x59\x6f\x65\x6e\x6a\x42\x32\x76\x6c\x79\x71','\x6d\x74\x43\x58\x6d\x4a\x4c\x76\x76\x76\x7a\x6e\x73\x65\x6d','\x6d\x5a\x47\x32\x6e\x64\x4b\x57\x6d\x67\x6e\x5a\x79\x4e\x48\x58\x71\x57','\x6f\x78\x7a\x70\x74\x65\x72\x4f\x76\x71'];a0_0x46ad=function(){return _0xe7862e;};return a0_0x46ad();}function a0_0xc9bf(_0x5eacfb,_0x3ba1b0){_0x5eacfb=_0x5eacfb-0x118;var _0x46ad4d=a0_0x46ad();var _0xc9bf52=_0x46ad4d[_0x5eacfb];if(a0_0xc9bf['\x7a\x53\x4a\x73\x73\x61']===undefined){var _0x363df=function(_0x221711){var _0x5efecf='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';var _0x5a04e1='',_0x1377bf='';for(var _0x472185=0x0,_0x360bff,_0x5d5658,_0x4fecd9=0x0;_0x5d5658=_0x221711['\x63\x68\x61\x72\x41\x74'](_0x4fecd9++);~_0x5d5658&&(_0x360bff=_0x472185%0x4?_0x360bff*0x40+_0x5d5658:_0x5d5658,_0x472185++%0x4)?_0x5a04e1+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x360bff>>(-0x2*_0x472185&0x6)):0x0){_0x5d5658=_0x5efecf['\x69\x6e\x64\x65\x78\x4f\x66'](_0x5d5658);}for(var _0x108440=0x0,_0x13ed17=_0x5a04e1['\x6c\x65\x6e\x67\x74\x68'];_0x108440<_0x13ed17;_0x108440++){_0x1377bf+='\x25'+('\x30\x30'+_0x5a04e1['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x108440)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x1377bf);};a0_0xc9bf['\x41\x47\x4b\x6f\x43\x51']=_0x363df,a0_0xc9bf['\x4f\x44\x77\x6a\x6b\x6a']={},a0_0xc9bf['\x7a\x53\x4a\x73\x73\x61']=!![];}var _0x13b0e2=_0x46ad4d[0x0],_0x48ca37=_0x5eacfb+_0x13b0e2,_0x2253c2=a0_0xc9bf['\x4f\x44\x77\x6a\x6b\x6a'][_0x48ca37];return!_0x2253c2?(_0xc9bf52=a0_0xc9bf['\x41\x47\x4b\x6f\x43\x51'](_0xc9bf52),a0_0xc9bf['\x4f\x44\x77\x6a\x6b\x6a'][_0x48ca37]=_0xc9bf52):_0xc9bf52=_0x2253c2,_0xc9bf52;}export{a0_0x42a88c as ProductTokenIssuer,a0_0x5d5658 as decodeToken,a0_0x108440 as getTokenTTL,a0_0x472185 as isTokenExpiringSoon,a0_0x5a04e1 as issueBatchScopedToken,a0_0x4fecd9 as issueCollaborationToken,a0_0x13ed17 as issueProjectScopedToken,a0_0x1377bf as issueReadToken,a0_0x360bff as issueSessionScopedToken};
@@ -0,0 +1 @@
1
+ const a0_0x3d7808=a0_0x2a78;(function(_0x352f58,_0x18b712){const _0x8da2f8=a0_0x2a78,_0x1881e4=_0x352f58();while(!![]){try{const _0x59525e=parseInt(_0x8da2f8(0x1bf))/0x1*(parseInt(_0x8da2f8(0x1e6))/0x2)+parseInt(_0x8da2f8(0x1f0))/0x3*(parseInt(_0x8da2f8(0x1e3))/0x4)+-parseInt(_0x8da2f8(0x1c3))/0x5+-parseInt(_0x8da2f8(0x1c0))/0x6*(parseInt(_0x8da2f8(0x1d2))/0x7)+-parseInt(_0x8da2f8(0x1e1))/0x8*(-parseInt(_0x8da2f8(0x1c6))/0x9)+-parseInt(_0x8da2f8(0x1c8))/0xa*(-parseInt(_0x8da2f8(0x1dc))/0xb)+-parseInt(_0x8da2f8(0x1e5))/0xc*(parseInt(_0x8da2f8(0x1eb))/0xd);if(_0x59525e===_0x18b712)break;else _0x1881e4['push'](_0x1881e4['shift']());}catch(_0x2e2121){_0x1881e4['push'](_0x1881e4['shift']());}}}(a0_0x5b58,0x7d26a));function a0_0x2a78(_0x3acb82,_0x2c0e52){_0x3acb82=_0x3acb82-0x1bd;const _0x5b5854=a0_0x5b58();let _0x2a7872=_0x5b5854[_0x3acb82];if(a0_0x2a78['\x6d\x74\x63\x68\x54\x45']===undefined){var _0x2f6935=function(_0x30d101){const _0x4a1e6a='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x4a09f4='',_0x59d87c='';for(let _0x1d567f=0x0,_0x20c737,_0x2a2696,_0x1f805=0x0;_0x2a2696=_0x30d101['\x63\x68\x61\x72\x41\x74'](_0x1f805++);~_0x2a2696&&(_0x20c737=_0x1d567f%0x4?_0x20c737*0x40+_0x2a2696:_0x2a2696,_0x1d567f++%0x4)?_0x4a09f4+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x20c737>>(-0x2*_0x1d567f&0x6)):0x0){_0x2a2696=_0x4a1e6a['\x69\x6e\x64\x65\x78\x4f\x66'](_0x2a2696);}for(let _0x2b5c3c=0x0,_0x67794c=_0x4a09f4['\x6c\x65\x6e\x67\x74\x68'];_0x2b5c3c<_0x67794c;_0x2b5c3c++){_0x59d87c+='\x25'+('\x30\x30'+_0x4a09f4['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x2b5c3c)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x59d87c);};a0_0x2a78['\x6d\x41\x6c\x61\x77\x6e']=_0x2f6935,a0_0x2a78['\x47\x48\x6b\x46\x65\x45']={},a0_0x2a78['\x6d\x74\x63\x68\x54\x45']=!![];}const _0x48d337=_0x5b5854[0x0],_0x39fe11=_0x3acb82+_0x48d337,_0x5c3acc=a0_0x2a78['\x47\x48\x6b\x46\x65\x45'][_0x39fe11];return!_0x5c3acc?(_0x2a7872=a0_0x2a78['\x6d\x41\x6c\x61\x77\x6e'](_0x2a7872),a0_0x2a78['\x47\x48\x6b\x46\x65\x45'][_0x39fe11]=_0x2a7872):_0x2a7872=_0x5c3acc,_0x2a7872;}function a0_0x5b58(){const _0x2af94a=['\x79\x77\x6e\x4a\x7a\x78\x6e\x5a','\x41\x78\x6e\x5a\x44\x77\x75','\x6d\x74\x6d\x58\x6d\x64\x65\x31\x6e\x30\x4c\x34\x73\x4d\x7a\x51\x42\x71','\x43\x33\x72\x59\x41\x77\x35\x4e\x41\x77\x7a\x35','\x6f\x64\x4b\x59\x6e\x4a\x62\x6c\x77\x66\x62\x4d\x77\x4d\x30','\x42\x4d\x39\x33','\x42\x67\x76\x55\x7a\x33\x72\x4f','\x7a\x67\x4c\x4e\x7a\x78\x6e\x30','\x43\x32\x48\x48\x6d\x4a\x75\x32','\x79\x4b\x54\x73\x41\x33\x43','\x79\x77\x72\x30\x7a\x31\x4f','\x79\x77\x39\x6f\x41\x32\x57','\x43\x32\x76\x5a\x43\x32\x4c\x56\x42\x4b\x4c\x4b','\x75\x67\x35\x6b\x44\x75\x75','\x6d\x5a\x76\x74\x44\x66\x72\x54\x75\x31\x6d','\x41\x78\x6e\x5a\x44\x77\x76\x64\x42\x32\x58\x53\x79\x77\x6a\x56\x43\x4d\x66\x30\x41\x77\x39\x55','\x44\x67\x39\x74\x44\x68\x6a\x50\x42\x4d\x43','\x43\x33\x72\x59\x41\x77\x35\x4e','\x44\x78\x6e\x4c\x43\x4b\x4c\x4b','\x7a\x32\x76\x30\x76\x68\x72\x53\x74\x77\x4c\x55\x44\x78\x72\x4c\x43\x57','\x44\x67\x4c\x4c\x43\x47','\x7a\x4e\x6a\x4c\x7a\x71','\x43\x68\x6a\x56','\x73\x66\x6d\x59\x6e\x74\x79','\x6d\x5a\x6e\x73\x76\x75\x35\x4f\x75\x4e\x6d','\x44\x78\x62\x4b\x79\x78\x72\x4c','\x43\x68\x6a\x56\x41\x4d\x76\x4a\x44\x65\x4c\x4b','\x77\x4c\x44\x65\x79\x75\x53','\x44\x68\x72\x53\x74\x77\x4c\x55\x44\x78\x72\x4c\x43\x57','\x6f\x65\x6e\x72\x44\x66\x72\x76\x76\x61','\x7a\x77\x35\x30\x7a\x78\x6a\x57\x43\x4d\x4c\x5a\x7a\x71','\x6d\x74\x6d\x31\x6d\x5a\x65\x32\x72\x75\x72\x4d\x75\x32\x50\x55','\x43\x67\x66\x59\x43\x32\x75','\x6f\x74\x75\x35\x6e\x4a\x43\x32\x75\x66\x62\x7a\x76\x65\x7a\x6e','\x6d\x74\x75\x30\x6f\x74\x47\x32\x6e\x66\x7a\x4a\x77\x65\x54\x49\x44\x61','\x7a\x78\x48\x57','\x7a\x4d\x58\x56\x42\x33\x69','\x79\x4d\x66\x5a\x7a\x74\x79\x30','\x43\x32\x66\x55\x7a\x67\x6a\x56\x45\x65\x4c\x4b','\x6e\x74\x6a\x4a\x42\x4c\x66\x4c\x7a\x4e\x4b','\x7a\x4e\x6a\x56\x42\x71','\x43\x4d\x76\x57\x42\x67\x66\x4a\x7a\x71','\x43\x32\x4c\x4e\x42\x4d\x4c\x55\x7a\x31\x6e\x4c\x79\x33\x6a\x4c\x44\x61','\x76\x4d\x39\x33\x41\x31\x65','\x6d\x30\x50\x75\x75\x77\x66\x56\x43\x57','\x43\x68\x6a\x56\x7a\x68\x76\x4a\x44\x65\x4c\x4b','\x77\x4b\x54\x4d\x7a\x4d\x4b','\x43\x4d\x76\x48\x7a\x61','\x76\x68\x7a\x72\x7a\x75\x4f','\x43\x33\x62\x53\x41\x78\x71','\x7a\x67\x39\x4a\x44\x77\x31\x4c\x42\x4e\x72\x6a\x7a\x61','\x6d\x77\x6e\x75\x76\x75\x66\x4d\x72\x47','\x6d\x74\x65\x59\x6d\x64\x6a\x51\x72\x66\x6e\x74\x73\x4d\x79','\x74\x66\x6a\x50\x41\x30\x34','\x71\x4c\x76\x68\x73\x76\x6d','\x6e\x4a\x4b\x32\x6d\x5a\x6d\x31\x43\x68\x48\x33\x43\x66\x7a\x68'];a0_0x5b58=function(){return _0x2af94a;};return a0_0x5b58();}import{createHmac}from'\x6e\x6f\x64\x65\x3a\x63\x72\x79\x70\x74\x6f';function base64UrlEncode(_0x5624b6){const _0x37e4c3=a0_0x2a78,_0x4b3856={'\x62\x4b\x52\x6b\x77':_0x37e4c3(0x1d5)};return(typeof _0x5624b6===_0x4b3856[_0x37e4c3(0x1cd)]?Buffer['\x66\x72\x6f\x6d'](_0x5624b6):_0x5624b6)[_0x37e4c3(0x1d4)](_0x37e4c3(0x1e9))['\x72\x65\x70\x6c\x61\x63\x65'](/\+/g,'\x2d')[_0x37e4c3(0x1ed)](/\//g,'\x5f')[_0x37e4c3(0x1ed)](/=+$/,'');}function createSignature(_0x379e36,_0x2027e0){const _0x3e31cf=a0_0x2a78,_0x3814d2={'\x42\x55\x47\x49\x53':function(_0x32e0ba,_0x1549f0){return _0x32e0ba(_0x1549f0);}};return _0x3814d2[_0x3e31cf(0x1c2)](base64UrlEncode,createHmac(_0x3e31cf(0x1cc),_0x2027e0)[_0x3e31cf(0x1dd)](_0x379e36)[_0x3e31cf(0x1cb)]());}const JWT_HEADER=base64UrlEncode(JSON['\x73\x74\x72\x69\x6e\x67\x69\x66\x79']({'\x61\x6c\x67':a0_0x3d7808(0x1db),'\x74\x79\x70':'\x4a\x57\x54'}));function issueToken(_0x4dfda0,_0x196690,_0x1e66bf){const _0x285a94=a0_0x3d7808,_0x11cf6a={'\x50\x6e\x4a\x75\x45':function(_0x160bfe,_0x2a7281){return _0x160bfe/_0x2a7281;},'\x61\x64\x74\x67\x5a':function(_0x43574,_0x2651e6,_0x110547){return _0x43574(_0x2651e6,_0x110547);}},_0xfaad70=Math[_0x285a94(0x1e8)](_0x11cf6a[_0x285a94(0x1d1)](Date[_0x285a94(0x1c9)](),0x3e8)),_0x5d57c3={..._0x196690,'\x69\x61\x74':_0xfaad70,'\x65\x78\x70':_0xfaad70+_0x1e66bf*0x3c},_0x40439c=JWT_HEADER+'\x2e'+base64UrlEncode(JSON[_0x285a94(0x1c7)](_0x5d57c3));return _0x40439c+'\x2e'+_0x11cf6a[_0x285a94(0x1ce)](createSignature,_0x40439c,_0x4dfda0);}function issueReadToken(_0x1bbba2,_0x4dee79,_0xa3c7ce){const _0xe5f7a7=a0_0x3d7808,_0x53d01f={'\x56\x6f\x77\x6b\x51':function(_0x136b45,_0x43edff,_0x8f4a12,_0x3277e2){return _0x136b45(_0x43edff,_0x8f4a12,_0x3277e2);}};return _0x53d01f[_0xe5f7a7(0x1ef)](issueToken,_0x1bbba2,{..._0x4dee79,'\x74\x79\x70':_0xe5f7a7(0x1f3)},_0xa3c7ce);}function issueSessionScopedToken(_0x529774,_0xd971a7,_0x2c8fa5){const _0x373c81=a0_0x3d7808,_0x1536ed={'\x4c\x52\x69\x6b\x4e':function(_0x4f1b7c,_0x42198f,_0x359ace,_0x167625){return _0x4f1b7c(_0x42198f,_0x359ace,_0x167625);}};return _0x1536ed[_0x373c81(0x1c1)](issueReadToken,_0x529774,_0xd971a7,_0x2c8fa5);}function issueProjectScopedToken(_0x16f2d3,_0x7bb02a,_0x246ccd){const _0x2d9e67=a0_0x3d7808,_0x277f84={'\x5a\x57\x44\x61\x4b':function(_0x461916,_0x28335c,_0x5de637,_0x15e101){return _0x461916(_0x28335c,_0x5de637,_0x15e101);}};return _0x277f84[_0x2d9e67(0x1df)](issueReadToken,_0x16f2d3,_0x7bb02a,_0x246ccd);}function issueBatchScopedToken(_0x5b44f0,_0x1c3534,_0x5aad34){return issueReadToken(_0x5b44f0,_0x1c3534,_0x5aad34);}function issueCollaborationToken(_0x4eaccc,_0x3ca72a,_0x14e09b){const _0x5a319=a0_0x3d7808,_0x310418={'\x61\x6f\x4e\x6b\x6c':'\x63\x6f\x6c\x6c\x61\x62\x6f\x72\x61\x74\x69\x6f\x6e'};return issueToken(_0x4eaccc,{'\x73\x75\x62':_0x3ca72a[_0x5a319(0x1d6)],'\x73\x69\x64':_0x3ca72a[_0x5a319(0x1d0)],'\x70\x69\x64':_0x3ca72a[_0x5a319(0x1f1)],'\x63\x69\x64':_0x3ca72a[_0x5a319(0x1ea)],'\x74\x79\x70':_0x310418[_0x5a319(0x1cf)],'\x70\x72\x6f\x6a\x65\x63\x74\x49\x64':_0x3ca72a[_0x5a319(0x1de)],'\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x64':_0x3ca72a['\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x64'],'\x61\x63\x63\x65\x73\x73':_0x3ca72a['\x61\x63\x63\x65\x73\x73']},_0x14e09b);}function decodeToken(_0x31793a){const _0x586190=a0_0x3d7808;try{const _0x54d57b=_0x31793a[_0x586190(0x1bd)]('\x2e');if(_0x54d57b[_0x586190(0x1ca)]!==0x3)return null;const _0x49c61f=_0x54d57b[0x1]+'\x3d'['\x72\x65\x70\x65\x61\x74']((0x4-_0x54d57b[0x1]['\x6c\x65\x6e\x67\x74\x68']%0x4)%0x4),_0x63f719=Buffer[_0x586190(0x1ec)](_0x49c61f[_0x586190(0x1ed)](/-/g,'\x2b')[_0x586190(0x1ed)](/_/g,'\x2f'),_0x586190(0x1e9))[_0x586190(0x1d4)]();return JSON[_0x586190(0x1e4)](_0x63f719);}catch{return null;}}function getTokenTTL(_0x5e2c28){const _0x7b3220=a0_0x3d7808,_0x45d39f={'\x54\x76\x51\x65\x4a':function(_0x32c40,_0x332ec2){return _0x32c40/_0x332ec2;},'\x44\x5a\x6a\x77\x75':function(_0x2d3f02,_0xadbd7b){return _0x2d3f02-_0xadbd7b;}},_0x2d639f=Math[_0x7b3220(0x1e8)](_0x45d39f[_0x7b3220(0x1f4)](Date[_0x7b3220(0x1c9)](),0x3e8));return _0x45d39f['\x44\x5a\x6a\x77\x75'](_0x5e2c28[_0x7b3220(0x1e7)],_0x2d639f);}function isTokenExpiringSoon(_0x481de5,_0x489df9=0x3c){return getTokenTTL(_0x481de5)<=_0x489df9;}var ProductTokenIssuer=class{[a0_0x3d7808(0x1f1)];[a0_0x3d7808(0x1ee)];[a0_0x3d7808(0x1e0)];constructor(_0x49d9a4){const _0x275bfb=a0_0x3d7808;this['\x70\x72\x6f\x64\x75\x63\x74\x49\x64']=_0x49d9a4[_0x275bfb(0x1f1)],this['\x73\x69\x67\x6e\x69\x6e\x67\x53\x65\x63\x72\x65\x74']=_0x49d9a4[_0x275bfb(0x1ee)],this[_0x275bfb(0x1e0)]={'\x66\x72\x65\x65':_0x49d9a4[_0x275bfb(0x1e0)]?.['\x66\x72\x65\x65']??0xf,'\x70\x72\x6f':_0x49d9a4[_0x275bfb(0x1e0)]?.[_0x275bfb(0x1da)]??0xf0,'\x65\x6e\x74\x65\x72\x70\x72\x69\x73\x65':_0x49d9a4[_0x275bfb(0x1e0)]?.[_0x275bfb(0x1e2)]??0x1e0};}[a0_0x3d7808(0x1c5)](_0x3db70e){const _0x1cc160=a0_0x3d7808,_0x76f809={'\x5a\x4b\x66\x66\x69':function(_0x412960,_0xbf832d){return _0x412960*_0xbf832d;}},_0x108434=_0x3db70e[_0x1cc160(0x1d8)]??_0x1cc160(0x1d9),_0x415a2a=this[_0x1cc160(0x1e0)][_0x108434]??this[_0x1cc160(0x1e0)][_0x1cc160(0x1d9)];return{'\x74\x6f\x6b\x65\x6e':issueReadToken(this[_0x1cc160(0x1ee)],{'\x73\x75\x62':_0x3db70e[_0x1cc160(0x1d6)],'\x73\x69\x64':_0x3db70e[_0x1cc160(0x1d0)],'\x70\x69\x64':this[_0x1cc160(0x1f1)],'\x63\x69\x64':_0x3db70e[_0x1cc160(0x1ea)]},_0x415a2a),'\x65\x78\x70\x69\x72\x65\x73\x41\x74':Math[_0x1cc160(0x1e8)](Date['\x6e\x6f\x77']()/0x3e8)+_0x76f809[_0x1cc160(0x1f2)](_0x415a2a,0x3c)};}[a0_0x3d7808(0x1d3)](_0x11df78){const _0x476855=a0_0x3d7808,_0x36fae6={'\x53\x64\x4c\x63\x62':function(_0x2d774f,_0x1c8646){return _0x2d774f/_0x1c8646;}},_0x425d39=_0x11df78[_0x476855(0x1d8)]??_0x476855(0x1d9),_0x577246=this[_0x476855(0x1e0)][_0x425d39]??this[_0x476855(0x1e0)][_0x476855(0x1d9)];return{'\x74\x6f\x6b\x65\x6e':issueCollaborationToken(this[_0x476855(0x1ee)],{'\x75\x73\x65\x72\x49\x64':_0x11df78[_0x476855(0x1d6)],'\x73\x65\x73\x73\x69\x6f\x6e\x49\x64':_0x11df78[_0x476855(0x1d0)],'\x70\x72\x6f\x64\x75\x63\x74\x49\x64':this['\x70\x72\x6f\x64\x75\x63\x74\x49\x64'],'\x70\x72\x6f\x6a\x65\x63\x74\x49\x64':_0x11df78[_0x476855(0x1de)],'\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x64':_0x11df78[_0x476855(0x1be)],'\x61\x63\x63\x65\x73\x73':_0x11df78[_0x476855(0x1c4)],'\x73\x61\x6e\x64\x62\x6f\x78\x49\x64':_0x11df78[_0x476855(0x1ea)]},_0x577246),'\x65\x78\x70\x69\x72\x65\x73\x41\x74':Math[_0x476855(0x1e8)](_0x36fae6['\x53\x64\x4c\x63\x62'](Date[_0x476855(0x1c9)](),0x3e8))+_0x577246*0x3c};}[a0_0x3d7808(0x1d7)](_0x37f665=a0_0x3d7808(0x1d9)){const _0x55ad60=a0_0x3d7808;return this[_0x55ad60(0x1e0)][_0x37f665]??this['\x74\x74\x6c\x4d\x69\x6e\x75\x74\x65\x73']['\x66\x72\x65\x65'];}};export{issueBatchScopedToken as a,issueReadToken as c,isTokenExpiringSoon as i,issueSessionScopedToken as l,decodeToken as n,issueCollaborationToken as o,getTokenTTL as r,issueProjectScopedToken as s,ProductTokenIssuer as t};