@tigrisdata/cli 3.10.0 → 3.12.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.
Files changed (126) hide show
  1. package/README.md +35 -3
  2. package/dist/auth/client.js +1 -1
  3. package/dist/auth/iam.js +1 -1
  4. package/dist/auth/provider.js +1 -1
  5. package/dist/browser/index.d.ts +307 -0
  6. package/dist/browser/index.js +2843 -0
  7. package/dist/{chunk-TFXO4OXM.js → chunk-DBDETUU5.js} +1 -1
  8. package/dist/{chunk-CEEDWOY2.js → chunk-DM3Z47H2.js} +1 -1
  9. package/dist/chunk-HBEO4D3T.js +1 -0
  10. package/dist/chunk-IUIKP2LU.js +1 -0
  11. package/dist/{chunk-RDJQLQQY.js → chunk-JSAFHUUW.js} +1 -1
  12. package/dist/{chunk-HAYPV4J6.js → chunk-M7RSEBSZ.js} +1 -1
  13. package/dist/{chunk-PNRZDYCK.js → chunk-NPKVQONE.js} +1 -1
  14. package/dist/{chunk-MQEI5KKF.js → chunk-P2VGCQRK.js} +1 -1
  15. package/dist/chunk-QPUL2AAI.js +1 -0
  16. package/dist/{chunk-IIF5VLQ7.js → chunk-RGFXGPV7.js} +1 -1
  17. package/dist/chunk-T7LA7K35.js +1 -0
  18. package/dist/chunk-UR3ROJIV.js +8 -0
  19. package/dist/{chunk-ZTZF3OHU.js → chunk-WLOUPDQT.js} +1 -1
  20. package/dist/{chunk-JUOJKZRI.js → chunk-XCTJOMF2.js} +1 -1
  21. package/dist/{chunk-4FAKNMI5.js → chunk-YL7RFWZJ.js} +1 -1
  22. package/dist/{chunk-UZIIZW33.js → chunk-YR7ZJNOL.js} +1 -1
  23. package/dist/chunk-Z6R2SWNJ.js +5 -0
  24. package/dist/cli-core.js +1 -1
  25. package/dist/cli.js +1 -1
  26. package/dist/constants.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/lib/access-keys/assign.js +1 -1
  29. package/dist/lib/access-keys/attach-policy.js +1 -1
  30. package/dist/lib/access-keys/create.js +1 -1
  31. package/dist/lib/access-keys/delete.js +1 -1
  32. package/dist/lib/access-keys/detach-policy.js +1 -1
  33. package/dist/lib/access-keys/get.js +1 -1
  34. package/dist/lib/access-keys/list-policies.js +1 -1
  35. package/dist/lib/access-keys/list.js +1 -1
  36. package/dist/lib/access-keys/rotate.js +1 -1
  37. package/dist/lib/buckets/create.js +1 -1
  38. package/dist/lib/buckets/delete.js +1 -1
  39. package/dist/lib/buckets/disable-snapshots.js +1 -1
  40. package/dist/lib/buckets/enable-snapshots.js +1 -1
  41. package/dist/lib/buckets/get.js +1 -1
  42. package/dist/lib/buckets/lifecycle/create.js +1 -1
  43. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  44. package/dist/lib/buckets/lifecycle/list.js +1 -1
  45. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  46. package/dist/lib/buckets/list.js +1 -1
  47. package/dist/lib/buckets/merge.js +1 -1
  48. package/dist/lib/buckets/migrate.js +1 -1
  49. package/dist/lib/buckets/rebase.js +1 -1
  50. package/dist/lib/buckets/restore.js +1 -1
  51. package/dist/lib/buckets/set-cors.js +1 -1
  52. package/dist/lib/buckets/set-locations.js +1 -1
  53. package/dist/lib/buckets/set-migration.js +1 -1
  54. package/dist/lib/buckets/set-notifications.js +1 -1
  55. package/dist/lib/buckets/set.js +1 -1
  56. package/dist/lib/buckets/share.js +1 -0
  57. package/dist/lib/bundle.js +1 -1
  58. package/dist/lib/configure/index.js +1 -1
  59. package/dist/lib/cp.js +1 -1
  60. package/dist/lib/credentials/test.js +1 -1
  61. package/dist/lib/iam/policies/create.js +1 -1
  62. package/dist/lib/iam/policies/delete.js +1 -1
  63. package/dist/lib/iam/policies/edit.js +1 -1
  64. package/dist/lib/iam/policies/get.js +1 -1
  65. package/dist/lib/iam/policies/link-key.js +1 -1
  66. package/dist/lib/iam/policies/list-keys.js +1 -1
  67. package/dist/lib/iam/policies/list.js +1 -1
  68. package/dist/lib/iam/policies/select-policy.js +1 -1
  69. package/dist/lib/iam/policies/unlink-key.js +1 -1
  70. package/dist/lib/iam/teams/create.js +1 -1
  71. package/dist/lib/iam/teams/edit.js +1 -1
  72. package/dist/lib/iam/teams/list.js +1 -1
  73. package/dist/lib/iam/teams/shared.js +1 -1
  74. package/dist/lib/iam/users/invite.js +1 -1
  75. package/dist/lib/iam/users/list.js +1 -1
  76. package/dist/lib/iam/users/remove.js +1 -1
  77. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  78. package/dist/lib/iam/users/update-role.js +1 -1
  79. package/dist/lib/init/index.js +1 -1
  80. package/dist/lib/login/credentials.js +1 -1
  81. package/dist/lib/login/oauth.js +1 -1
  82. package/dist/lib/login/select.js +1 -1
  83. package/dist/lib/logout.js +1 -1
  84. package/dist/lib/ls.js +1 -1
  85. package/dist/lib/mk.js +1 -1
  86. package/dist/lib/mv.js +1 -1
  87. package/dist/lib/objects/delete.js +1 -1
  88. package/dist/lib/objects/get.js +1 -1
  89. package/dist/lib/objects/info.js +1 -1
  90. package/dist/lib/objects/list-versions.js +1 -1
  91. package/dist/lib/objects/list.js +1 -1
  92. package/dist/lib/objects/purge.js +1 -1
  93. package/dist/lib/objects/put.js +1 -1
  94. package/dist/lib/objects/restore-deleted.js +1 -1
  95. package/dist/lib/objects/restore-info.js +1 -1
  96. package/dist/lib/objects/restore.js +1 -1
  97. package/dist/lib/objects/set-access.js +1 -1
  98. package/dist/lib/objects/set.js +1 -1
  99. package/dist/lib/organizations/create.js +1 -1
  100. package/dist/lib/organizations/list.js +1 -1
  101. package/dist/lib/organizations/select.js +1 -1
  102. package/dist/lib/presign.js +2 -2
  103. package/dist/lib/rm.js +1 -1
  104. package/dist/lib/snapshots/delete.js +1 -1
  105. package/dist/lib/snapshots/list.js +1 -1
  106. package/dist/lib/snapshots/take.js +1 -1
  107. package/dist/lib/stat.js +1 -1
  108. package/dist/lib/telemetry/disable.js +1 -1
  109. package/dist/lib/telemetry/enable.js +1 -1
  110. package/dist/lib/telemetry/status.js +1 -1
  111. package/dist/lib/touch.js +1 -1
  112. package/dist/lib/update.js +1 -1
  113. package/dist/lib/whoami.js +1 -1
  114. package/dist/specs.yaml +57 -2
  115. package/dist/utils/analytics.js +1 -1
  116. package/dist/utils/bucket-info.js +1 -1
  117. package/dist/utils/exit.js +1 -1
  118. package/dist/utils/telemetry.js +1 -1
  119. package/dist/utils/update-check.js +1 -1
  120. package/package.json +22 -6
  121. package/dist/chunk-76VFN2EJ.js +0 -8
  122. package/dist/chunk-J3MAV7JB.js +0 -1
  123. package/dist/chunk-JNSFDQGG.js +0 -1
  124. package/dist/chunk-R3KHIAWP.js +0 -5
  125. package/dist/chunk-RH6Z22EN.js +0 -1
  126. package/dist/chunk-V6JZFDRE.js +0 -1
package/README.md CHANGED
@@ -390,11 +390,13 @@ tigris cp <src> <dest> [flags]
390
390
  |------|-------------|
391
391
  | `-r, --recursive` | Copy directories recursively |
392
392
  | `-a, --access` | Access level for uploaded objects (only applies to local-to-remote uploads) |
393
+ | `--cache-control` | Cache-Control header stored with uploaded objects (only applies to local-to-remote uploads) |
393
394
 
394
395
  **Examples:**
395
396
  ```bash
396
397
  tigris cp ./file.txt t3://my-bucket/file.txt
397
398
  tigris cp ./logo.png t3://my-bucket/logo.png --access public
399
+ tigris cp ./dist/ t3://my-bucket/assets/ -r --cache-control 'public, max-age=31536000, immutable'
398
400
  tigris cp t3://my-bucket/file.txt ./local-copy.txt
399
401
  tigris cp t3://my-bucket/src/ t3://my-bucket/dest/ -r
400
402
  tigris cp ./images/ t3://my-bucket/images/ -r
@@ -541,6 +543,7 @@ Create, inspect, update, and delete buckets. Buckets are top-level containers th
541
543
  | `tigris buckets lifecycle` (lc) | Manage bucket lifecycle rules. Each rule combines an optional storage-class transition and/or expiration (TTL), scoped to an optional key prefix |
542
544
  | `tigris buckets set-notifications` | Configure object event notifications on a bucket. Sends webhook requests to a URL when objects are created, updated, or deleted |
543
545
  | `tigris buckets set-cors` | Configure CORS rules on a bucket. Each invocation adds a rule unless --override or --reset is used |
546
+ | `tigris buckets share` | Share a bucket with your whole organization, specific teams, or specific users. Existing shares are kept unless --override or --reset is used |
544
547
 
545
548
  #### `tigris buckets list` (l)
546
549
 
@@ -938,6 +941,33 @@ tigris buckets set-cors my-bucket --origins https://example.com --override
938
941
  tigris buckets set-cors my-bucket --reset
939
942
  ```
940
943
 
944
+ #### `tigris buckets share`
945
+
946
+ Share a bucket with your whole organization, specific teams, or specific users. Existing shares are kept unless --override or --reset is used
947
+
948
+ ```
949
+ tigris buckets share <name> [flags]
950
+ ```
951
+
952
+ | Flag | Description |
953
+ |------|-------------|
954
+ | `-org, --organization` | Give access to everyone in your organization. Takes exactly one --role and cannot be combined with --team or --user |
955
+ | `-t, --team` | Team ID to share with (can specify multiple, comma-separated). Each team is paired positionally with a --role value |
956
+ | `-u, --user` | User ID to share with (can specify multiple, comma-separated). Each user is paired positionally with a --role value |
957
+ | `-r, --role` | Role to grant (can specify multiple, comma-separated). A single role applies to every target; otherwise each role pairs with the corresponding --team or --user value |
958
+ | `--override` | Replace all existing shares instead of merging with them |
959
+ | `--reset` | Remove all shares from the bucket |
960
+
961
+ **Examples:**
962
+ ```bash
963
+ tigris buckets share my-bucket --organization --role ReadOnly
964
+ tigris buckets share my-bucket --team tmid_MQQUhV --role Editor
965
+ tigris buckets share my-bucket --user uid_MQQUhV --role ReadOnly
966
+ tigris buckets share my-bucket --team tmid_A,tmid_B --role Editor,ReadOnly
967
+ tigris buckets share my-bucket --team tmid_MQQUhV --role Editor --override
968
+ tigris buckets share my-bucket --reset
969
+ ```
970
+
941
971
  ### `tigris snapshots` (s)
942
972
 
943
973
  List, take, and delete snapshots. A snapshot is a point-in-time, read-only copy of a bucket's state
@@ -1035,7 +1065,7 @@ tigris objects list <bucket> [flags]
1035
1065
  | `--limit` | Maximum number of items to return per page |
1036
1066
  | `-pt, --page-token` | Pagination token from a previous request to fetch the next page |
1037
1067
  | `--source` | List objects from a specific storage source on buckets with shadow migration enabled |
1038
- | `--deleted` | List soft-deleted objects instead of live ones. Requires soft delete on the bucket. Not the recovery path for snapshot buckets use "tigris objects list-versions" for those |
1068
+ | `--deleted` | List soft-deleted objects instead of live ones. Requires soft delete on the bucket. On a snapshot bucket a plain delete records a delete marker instead, so use "tigris objects list-versions" for those |
1039
1069
 
1040
1070
  **Examples:**
1041
1071
  ```bash
@@ -1108,6 +1138,7 @@ tigris objects put <bucket> [key] [file] [flags]
1108
1138
  |------|-------------|
1109
1139
  | `-a, --access` | Access level (default: private) |
1110
1140
  | `-t, --content-type` | Content type (auto-detected from extension if omitted) |
1141
+ | `--cache-control` | Cache-Control header stored with the object and returned on every read (e.g. "public, max-age=31536000, immutable") |
1111
1142
  | `--format` | Output format (default: table) |
1112
1143
 
1113
1144
  **Examples:**
@@ -1115,6 +1146,7 @@ tigris objects put <bucket> [key] [file] [flags]
1115
1146
  tigris objects put my-bucket report.pdf ./report.pdf
1116
1147
  tigris objects put t3://my-bucket/report.pdf ./report.pdf
1117
1148
  tigris objects put my-bucket logo.png ./logo.png --access public --content-type image/png
1149
+ tigris objects put my-bucket app.js ./app.js --cache-control 'public, max-age=31536000, immutable'
1118
1150
  echo 'hello' | tigris objects put t3://my-bucket/hello.txt
1119
1151
  cat report.pdf | tigris objects put my-bucket report.pdf --content-type application/pdf
1120
1152
  ```
@@ -1295,7 +1327,7 @@ Create, list, inspect, delete, and assign roles to access keys. Access keys are
1295
1327
  | `tigris access-keys create` (c) | Create a new access key with the given name. Returns the key ID and secret (shown only once) |
1296
1328
  | `tigris access-keys delete` (d) | Permanently delete an access key by its ID. This revokes all access immediately |
1297
1329
  | `tigris access-keys get` (g) | Show details for an access key including its name, creation date, and assigned bucket roles |
1298
- | `tigris access-keys assign` (a) | Assign per-bucket roles to an access key. Pair each --bucket with a --role (Editor or ReadOnly), or use --admin for org-wide access |
1330
+ | `tigris access-keys assign` (a) | Assign per-bucket roles to an access key. Pair each --bucket with a --role (Editor, ReadWrite, or ReadOnly), or use --admin for org-wide access |
1299
1331
  | `tigris access-keys rotate` (r) | Rotate an access key's secret. The current secret is immediately invalidated and a new one is returned (shown only once) |
1300
1332
  | `tigris access-keys attach-policy` (ap) | Attach an IAM policy to an access key. If no policy ARN is provided, shows interactive selection of available policies |
1301
1333
  | `tigris access-keys detach-policy` (dp) | Detach an IAM policy from an access key. If no policy ARN is provided, shows interactive selection of attached policies |
@@ -1365,7 +1397,7 @@ tigris access-keys get tid_AaBbCcDdEeFf
1365
1397
 
1366
1398
  #### `tigris access-keys assign` (a)
1367
1399
 
1368
- Assign per-bucket roles to an access key. Pair each --bucket with a --role (Editor or ReadOnly), or use --admin for org-wide access
1400
+ Assign per-bucket roles to an access key. Pair each --bucket with a --role (Editor, ReadWrite, or ReadOnly), or use --admin for org-wide access
1369
1401
 
1370
1402
  ```
1371
1403
  tigris access-keys assign <id> [flags]
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";export{b as TigrisAuthClient,a as getAuth0Config,c as getAuthClient};
1
+ import{a,b,c,d}from"../chunk-HBEO4D3T.js";import"../chunk-F4AGJWCK.js";export{c as TigrisAuthClient,a as getAuth0Config,d as getAuthClient,b as setExternalTokenRefresher};
package/dist/auth/iam.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c}from"../chunk-UZIIZW33.js";import"../chunk-R3KHIAWP.js";import"../chunk-IIF5VLQ7.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-RDJQLQQY.js";import"../chunk-DV3LCXRH.js";import"../chunk-RH6Z22EN.js";import"../chunk-BMWWPXMU.js";import"../chunk-APJUJ6TW.js";import"../chunk-V6JZFDRE.js";import"../chunk-J3MAV7JB.js";import{a}from"../chunk-KJBSIIND.js";import"../chunk-F4AGJWCK.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
1
+ import{a as b,b as c}from"../chunk-YR7ZJNOL.js";import"../chunk-Z6R2SWNJ.js";import"../chunk-RGFXGPV7.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-JSAFHUUW.js";import"../chunk-DV3LCXRH.js";import"../chunk-T7LA7K35.js";import"../chunk-BMWWPXMU.js";import"../chunk-APJUJ6TW.js";import"../chunk-QPUL2AAI.js";import"../chunk-HBEO4D3T.js";import{a}from"../chunk-KJBSIIND.js";import"../chunk-F4AGJWCK.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"../chunk-R3KHIAWP.js";import"../chunk-V6JZFDRE.js";import"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";export{c as getEnvCredentials,b as getEnvForcePathStyle,e as getStorageConfig,f as getStorageConfigWithOrg,a as getTigrisConfig,g as requireOAuthLogin,d as resolveAuthMethod};
1
+ import{a,b,c,d,e,f,g,h}from"../chunk-Z6R2SWNJ.js";import"../chunk-QPUL2AAI.js";import"../chunk-HBEO4D3T.js";import"../chunk-F4AGJWCK.js";export{c as getEnvCredentials,b as getEnvForcePathStyle,f as getStorageConfig,g as getStorageConfigWithOrg,a as getTigrisConfig,h as requireOAuthLogin,d as resetAutoLogin,e as resolveAuthMethod};
@@ -0,0 +1,307 @@
1
+ import { Organization } from '@tigrisdata/iam';
2
+ import * as memfs from 'memfs';
3
+ import { Volume } from 'memfs';
4
+
5
+ interface Argument {
6
+ name: string;
7
+ description?: string;
8
+ alias?: string;
9
+ options?: string[] | Array<{
10
+ name: string;
11
+ value: string;
12
+ description: string;
13
+ }>;
14
+ default?: string;
15
+ required?: boolean;
16
+ 'required-when'?: string;
17
+ type?: 'positional' | 'flag' | string;
18
+ multiple?: boolean;
19
+ examples?: string[];
20
+ /** Hard-removed: providing the flag exits with a redirect message. */
21
+ removed?: boolean;
22
+ /** Soft-deprecated: still works, but flagged in help and superseded by `replaced_by`. */
23
+ deprecated?: boolean;
24
+ /** Replacement to suggest when a removed or deprecated argument or command is used. */
25
+ replaced_by?: string;
26
+ }
27
+ interface NextAction {
28
+ command: string;
29
+ description: string;
30
+ }
31
+ interface Messages {
32
+ onStart?: string;
33
+ onSuccess?: string;
34
+ onFailure?: string;
35
+ onEmpty?: string;
36
+ onAlreadyDone?: string;
37
+ onDeprecated?: string;
38
+ hint?: string;
39
+ nextActions?: NextAction[];
40
+ }
41
+ interface CommandSpec {
42
+ name: string;
43
+ description?: string;
44
+ alias?: string | string[];
45
+ arguments?: Argument[];
46
+ examples?: string[];
47
+ commands?: CommandSpec[];
48
+ default?: string;
49
+ deprecated?: boolean;
50
+ /** Hard-removed: invoking the command exits with a redirect message. */
51
+ removed?: boolean;
52
+ /** Replacement to suggest when a removed argument or command is used. */
53
+ replaced_by?: string;
54
+ message?: string;
55
+ messages?: Messages;
56
+ }
57
+ interface Specs {
58
+ name: string;
59
+ description: string;
60
+ version: string;
61
+ definitions?: {
62
+ global_arguments?: Argument[];
63
+ [key: string]: unknown;
64
+ };
65
+ commands: CommandSpec[];
66
+ }
67
+
68
+ /**
69
+ * The host environment a browser-embedded CLI runs against.
70
+ *
71
+ * Shims read the *current* host through `getHost()` rather than taking it as a
72
+ * parameter: the CLI's handlers are reached through commander and have no way
73
+ * to thread a context object down. `runCli()` installs the host for the
74
+ * duration of one invocation.
75
+ *
76
+ * The filesystem is deliberately not part of this interface — it is the
77
+ * process-wide memfs volume in `./volume.js`, which the surrounding shell also
78
+ * mounts, so both see the same bytes.
79
+ */
80
+ interface SelectChoice {
81
+ /** Value handed back to the caller. */
82
+ value: string;
83
+ /** Text shown in the terminal. */
84
+ label: string;
85
+ hint?: string;
86
+ }
87
+ interface BrowserHost {
88
+ /** Terminal width, used by the table formatter. Defaults to 120. */
89
+ columns?: number;
90
+ /** Environment variables visible to the CLI. */
91
+ env?: Record<string, string>;
92
+ /**
93
+ * Ask a yes/no question. Backs enquirer's `confirm`; `initial` is what an
94
+ * empty answer means, as in enquirer.
95
+ */
96
+ confirm(message: string, options?: {
97
+ initial?: boolean;
98
+ }): Promise<boolean>;
99
+ /** Ask for a line of text. Backs enquirer's `input`/`password` prompts. */
100
+ input(message: string, options?: {
101
+ password?: boolean;
102
+ initial?: string;
103
+ }): Promise<string>;
104
+ /**
105
+ * Ask the user to pick from a list. Backs enquirer's `select`; `initial` is
106
+ * the choice an empty answer means — an index, or a choice's value — as in
107
+ * enquirer.
108
+ */
109
+ select(message: string, choices: SelectChoice[], options?: {
110
+ initial?: number | string;
111
+ }): Promise<string>;
112
+ /**
113
+ * Start an interactive login. Replaces the CLI's device-flow login, which
114
+ * cannot run in a page: `auth.storage.tigrisdata.io/oauth/device/code`
115
+ * returns no `Access-Control-Allow-Origin`. Implementations use Auth0's
116
+ * official SPA SDK and write the result through `auth/storage.ts`.
117
+ */
118
+ login?(): Promise<void>;
119
+ /**
120
+ * Discard any browser-side session the host holds, on `tigris logout`.
121
+ *
122
+ * The CLI's own logout clears its credential store, but it knows nothing
123
+ * about an Auth0 SPA session in `localStorage` — without this, logging out
124
+ * and reloading signs you straight back in.
125
+ */
126
+ logout?(): Promise<void>;
127
+ /** Open a URL — the browser equivalent of the `open` package. */
128
+ openUrl?(url: string): void;
129
+ /**
130
+ * Renew the OAuth session, on demand from the CLI. Its own refresh path
131
+ * posts a refresh token, which it does not hold in a browser — Auth0's SPA
132
+ * SDK keeps that in its own cache. Implementations refresh through the SDK
133
+ * and install the result with `setOAuthSession`. Called when the access
134
+ * token is within five minutes of expiry, including mid-command during a
135
+ * long upload.
136
+ */
137
+ refreshSession?(): Promise<void>;
138
+ }
139
+
140
+ /**
141
+ * Thrown by the browser `process.exit` shim in place of terminating the process.
142
+ *
143
+ * The Node CLI reaches `process.exit()` from ~330 call sites (302 via
144
+ * `exitWithError`/`failWithError`, plus direct calls). Those functions are typed
145
+ * `: never`, and throwing preserves that contract exactly — so no handler needs
146
+ * to change for the browser build. `runCli()` catches this and turns it back
147
+ * into an exit code.
148
+ */
149
+ declare class ExitSignal extends Error {
150
+ readonly exitCode: number;
151
+ constructor(exitCode: number);
152
+ }
153
+ declare function isExitSignal(error: unknown): error is ExitSignal;
154
+
155
+ /**
156
+ * Auth provider
157
+ * Resolves auth method and provides storage config + service endpoints
158
+ */
159
+
160
+ type TigrisStorageConfig = {
161
+ bucket?: string;
162
+ accessKeyId?: string;
163
+ secretAccessKey?: string;
164
+ endpoint?: string;
165
+ forcePathStyle?: boolean;
166
+ sessionToken?: string;
167
+ organizationId?: string;
168
+ iamEndpoint?: string;
169
+ authDomain?: string;
170
+ credentialProvider?: () => Promise<{
171
+ accessKeyId: string;
172
+ secretAccessKey: string;
173
+ sessionToken?: string;
174
+ expiration?: Date;
175
+ }>;
176
+ };
177
+
178
+ /**
179
+ * Installing credentials into the CLI's own credential store.
180
+ *
181
+ * The browser build cannot run the CLI's device-flow login — Auth0's
182
+ * `/oauth/device/code` sends no CORS headers — so the host performs login (via
183
+ * Auth0's SPA SDK) and hands the result here. Everything downstream then works
184
+ * unmodified: `getStorageConfig()` resolves it, `whoami` reports it, `logout`
185
+ * clears it, and token refresh goes through the CLI's existing client.
186
+ *
187
+ * The store writes to `~/.tigris/config.json` on the in-memory volume, so
188
+ * nothing survives a page reload.
189
+ */
190
+
191
+ interface OAuthSession {
192
+ accessToken: string;
193
+ refreshToken?: string;
194
+ idToken?: string;
195
+ /** Unix ms. Defaults to one hour out when the provider does not say. */
196
+ expiresAt?: number;
197
+ organizations?: Organization[];
198
+ /** Organization id to make active. Defaults to the first one. */
199
+ selectedOrganization?: string;
200
+ }
201
+ interface AccessKeySession {
202
+ accessKeyId: string;
203
+ secretAccessKey: string;
204
+ endpoint?: string;
205
+ organizationId?: string;
206
+ }
207
+ /** Install an OAuth session obtained by the host. */
208
+ declare function setOAuthSession(session: OAuthSession): Promise<void>;
209
+ interface RenewedTokens {
210
+ accessToken: string;
211
+ /** Kept from the current session when the refresh response carries none. */
212
+ idToken?: string;
213
+ /** Unix ms. Defaults to one hour out when the provider does not say. */
214
+ expiresAt?: number;
215
+ }
216
+ /**
217
+ * Replace the access token of the current OAuth session, keeping everything
218
+ * else. A refresh response does not always carry an ID token, and `whoami`
219
+ * reads the user's identity out of the stored one — installing the refreshed
220
+ * set with `setOAuthSession` would wipe it.
221
+ *
222
+ * @throws if there is no OAuth session to renew.
223
+ */
224
+ declare function renewOAuthSession(tokens: RenewedTokens): Promise<void>;
225
+ /**
226
+ * Install access-key credentials. Stored as *temporary* credentials — the same
227
+ * slot `tigris login credentials` uses, which `logout` clears.
228
+ */
229
+ declare function setAccessKeySession(session: AccessKeySession): Promise<void>;
230
+ /** Forget everything. Equivalent to `tigris logout`. */
231
+ declare function clearSession(): Promise<void>;
232
+ /**
233
+ * The resolved storage config for the active session — the same object every
234
+ * CLI handler passes to the SDK. Exposed so a host can mount buckets or make
235
+ * SDK calls of its own without re-deriving credentials.
236
+ *
237
+ * @throws if nothing is authenticated.
238
+ */
239
+ declare function getSessionConfig(): Promise<TigrisStorageConfig>;
240
+ interface SessionState {
241
+ method: 'oauth' | 'credentials' | null;
242
+ organizationId: string | null;
243
+ }
244
+ declare function getSessionState(): SessionState;
245
+
246
+ declare const HOME_DIR = "/home/tigris";
247
+ declare const volume: Volume;
248
+ /** Node-compatible `fs` bound to {@link volume}. */
249
+ declare const fs: memfs.IFs;
250
+ /** Drop every file and start clean — used between tests and on logout. */
251
+ declare function resetVolume(): void;
252
+
253
+ /**
254
+ * Browser entry point for Tigris CLI.
255
+ *
256
+ * Runs the *same* commander program and the *same* `src/lib` handlers as the
257
+ * Node CLI, driven by the same `specs.yaml`. The differences are confined to
258
+ * the build: node builtins are aliased to the shims in `./shims`, and the free
259
+ * `process` and `console` identifiers are replaced at bundle time so
260
+ * `process.exit()` becomes a catchable throw and output is captured instead of
261
+ * being written to a terminal.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * import { createBrowserCli, volume } from '@tigrisdata/cli/browser';
266
+ *
267
+ * const cli = createBrowserCli({
268
+ * confirm: (message) => terminal.confirm(message),
269
+ * input: (message, options) => terminal.input(message, options),
270
+ * select: (message, choices) => terminal.select(message, choices),
271
+ * login: () => auth0Login(),
272
+ * });
273
+ *
274
+ * const { stdout, exitCode } = await cli.run(['objects', 'list', 'my-bucket']);
275
+ * ```
276
+ */
277
+
278
+ interface CliResult {
279
+ stdout: string;
280
+ stderr: string;
281
+ exitCode: number;
282
+ /**
283
+ * `'bytes'` when the command streamed binary to stdout — `stdout` is then a
284
+ * latin1 string (one char per byte) to be forwarded verbatim. Otherwise
285
+ * `'text'`.
286
+ */
287
+ stdoutKind: 'text' | 'bytes';
288
+ }
289
+ interface RunOptions {
290
+ /**
291
+ * Bytes piped into this invocation. Providing it makes `process.stdin.isTTY`
292
+ * false, which is how the CLI detects piped input (`objects put`, `bundle`).
293
+ */
294
+ stdin?: Uint8Array;
295
+ /** Directory to run in, so relative paths resolve as the user expects. */
296
+ cwd?: string;
297
+ }
298
+ interface BrowserCli {
299
+ run(argv: string[], options?: RunOptions): Promise<CliResult>;
300
+ /** Command paths available in this build, e.g. `['objects/list', ...]`. */
301
+ commands(): string[];
302
+ /** The parsed command tree, for help text and tab completion. */
303
+ specs(): Specs;
304
+ }
305
+ declare function createBrowserCli(host: BrowserHost): BrowserCli;
306
+
307
+ export { type AccessKeySession, type BrowserCli, type BrowserHost, type CliResult, ExitSignal, HOME_DIR, type OAuthSession, type RenewedTokens, type RunOptions, type SelectChoice, type SessionState, type TigrisStorageConfig, clearSession, createBrowserCli, fs, getSessionConfig, getSessionState, isExitSignal, renewOAuthSession, resetVolume, setAccessKeySession, setOAuthSession, volume };