wrangler 0.0.0-e9e9872 → 0.0.0-e9f8a2fa

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 (178) hide show
  1. package/README.md +25 -13
  2. package/bin/wrangler.js +51 -61
  3. package/config-schema.json +2939 -0
  4. package/package.json +222 -160
  5. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  6. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  7. package/templates/__tests__/tsconfig.json +8 -0
  8. package/templates/checked-fetch.js +19 -6
  9. package/templates/facade.d.ts +19 -0
  10. package/templates/gitignore +0 -4
  11. package/templates/init-tests/test-jest-new-worker.js +23 -0
  12. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  13. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  14. package/templates/middleware/common.ts +67 -0
  15. package/templates/middleware/loader-modules.ts +133 -0
  16. package/templates/middleware/loader-sw.ts +229 -0
  17. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  18. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  19. package/templates/middleware/middleware-pretty-error.ts +40 -0
  20. package/templates/middleware/middleware-scheduled.ts +15 -0
  21. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  22. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  23. package/templates/modules-watch-stub.js +4 -0
  24. package/templates/new-worker-scheduled.ts +1 -1
  25. package/templates/new-worker.js +1 -1
  26. package/templates/new-worker.ts +4 -1
  27. package/templates/pages-dev-pipeline.ts +32 -0
  28. package/templates/pages-dev-util.ts +55 -0
  29. package/templates/pages-shim.ts +9 -0
  30. package/templates/pages-template-plugin.ts +53 -18
  31. package/templates/pages-template-worker.ts +49 -12
  32. package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
  33. package/templates/startDevWorker/ProxyWorker.ts +334 -0
  34. package/templates/tsconfig-sanity.ts +11 -0
  35. package/templates/tsconfig.init.json +105 -0
  36. package/templates/tsconfig.json +5 -102
  37. package/wrangler-dist/InspectorProxyWorker.js +464 -0
  38. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  39. package/wrangler-dist/ProxyWorker.js +240 -0
  40. package/wrangler-dist/ProxyWorker.js.map +6 -0
  41. package/wrangler-dist/cli.d.ts +23879 -146
  42. package/wrangler-dist/cli.js +186358 -107113
  43. package/wrangler-dist/wasm-sync.wasm +0 -0
  44. package/import_meta_url.js +0 -3
  45. package/miniflare-config-stubs/.env.empty +0 -0
  46. package/miniflare-config-stubs/package.empty.json +0 -1
  47. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  48. package/miniflare-dist/index.mjs +0 -4894
  49. package/src/__tests__/config-cache-without-cache-dir.test.ts +0 -38
  50. package/src/__tests__/config-cache.test.ts +0 -42
  51. package/src/__tests__/configuration.test.ts +0 -3946
  52. package/src/__tests__/dev.test.tsx +0 -1159
  53. package/src/__tests__/guess-worker-format.test.ts +0 -85
  54. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  55. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  56. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  57. package/src/__tests__/helpers/mock-bin.ts +0 -36
  58. package/src/__tests__/helpers/mock-cfetch.ts +0 -211
  59. package/src/__tests__/helpers/mock-console.ts +0 -97
  60. package/src/__tests__/helpers/mock-dialogs.ts +0 -153
  61. package/src/__tests__/helpers/mock-http-server.ts +0 -46
  62. package/src/__tests__/helpers/mock-istty.ts +0 -74
  63. package/src/__tests__/helpers/mock-kv.ts +0 -33
  64. package/src/__tests__/helpers/mock-oauth-flow.ts +0 -250
  65. package/src/__tests__/helpers/mock-process.ts +0 -39
  66. package/src/__tests__/helpers/mock-stdin.ts +0 -108
  67. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  68. package/src/__tests__/helpers/run-in-tmp.ts +0 -38
  69. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  70. package/src/__tests__/helpers/write-worker-source.ts +0 -31
  71. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  72. package/src/__tests__/https-options.test.ts +0 -163
  73. package/src/__tests__/index.test.ts +0 -262
  74. package/src/__tests__/init.test.ts +0 -1992
  75. package/src/__tests__/jest.setup.ts +0 -120
  76. package/src/__tests__/kv.test.ts +0 -1650
  77. package/src/__tests__/logger.test.ts +0 -141
  78. package/src/__tests__/package-manager.test.ts +0 -353
  79. package/src/__tests__/pages.test.ts +0 -1254
  80. package/src/__tests__/parse.test.ts +0 -330
  81. package/src/__tests__/publish.test.ts +0 -6595
  82. package/src/__tests__/pubsub.test.ts +0 -367
  83. package/src/__tests__/r2.test.ts +0 -233
  84. package/src/__tests__/route.test.ts +0 -45
  85. package/src/__tests__/secret.test.ts +0 -492
  86. package/src/__tests__/tail.test.ts +0 -698
  87. package/src/__tests__/user.test.ts +0 -143
  88. package/src/__tests__/whoami.test.tsx +0 -230
  89. package/src/__tests__/worker-namespace.test.ts +0 -327
  90. package/src/abort.d.ts +0 -3
  91. package/src/api/dev.ts +0 -52
  92. package/src/api/index.ts +0 -1
  93. package/src/bundle-reporter.tsx +0 -29
  94. package/src/bundle.ts +0 -212
  95. package/src/cfetch/index.ts +0 -121
  96. package/src/cfetch/internal.ts +0 -149
  97. package/src/cli.ts +0 -27
  98. package/src/config/README.md +0 -107
  99. package/src/config/config.ts +0 -243
  100. package/src/config/diagnostics.ts +0 -80
  101. package/src/config/environment.ts +0 -453
  102. package/src/config/index.ts +0 -238
  103. package/src/config/validation-helpers.ts +0 -584
  104. package/src/config/validation.ts +0 -1745
  105. package/src/config-cache.ts +0 -83
  106. package/src/create-worker-preview.ts +0 -255
  107. package/src/create-worker-upload-form.ts +0 -263
  108. package/src/dev/dev-vars.ts +0 -36
  109. package/src/dev/dev.tsx +0 -417
  110. package/src/dev/local.tsx +0 -354
  111. package/src/dev/remote.tsx +0 -382
  112. package/src/dev/use-esbuild.ts +0 -150
  113. package/src/dev.tsx +0 -538
  114. package/src/dialogs.tsx +0 -135
  115. package/src/durable.ts +0 -102
  116. package/src/entry.ts +0 -328
  117. package/src/environment-variables.ts +0 -35
  118. package/src/errors.ts +0 -11
  119. package/src/faye-websocket.d.ts +0 -6
  120. package/src/generate.ts +0 -33
  121. package/src/git-client.ts +0 -42
  122. package/src/global-wrangler-config-path.ts +0 -26
  123. package/src/https-options.ts +0 -127
  124. package/src/index.tsx +0 -1896
  125. package/src/init.ts +0 -549
  126. package/src/inspect.ts +0 -662
  127. package/src/intl-polyfill.d.ts +0 -139
  128. package/src/is-interactive.ts +0 -12
  129. package/src/kv.ts +0 -430
  130. package/src/logger.ts +0 -73
  131. package/src/miniflare-cli/README.md +0 -30
  132. package/src/miniflare-cli/enum-keys.ts +0 -17
  133. package/src/miniflare-cli/index.ts +0 -53
  134. package/src/miniflare-cli/request-context.ts +0 -40
  135. package/src/module-collection.ts +0 -258
  136. package/src/open-in-browser.ts +0 -17
  137. package/src/package-manager.ts +0 -219
  138. package/src/pages/build.tsx +0 -202
  139. package/src/pages/constants.ts +0 -7
  140. package/src/pages/deployments.tsx +0 -101
  141. package/src/pages/dev.tsx +0 -964
  142. package/src/pages/functions/buildPlugin.ts +0 -105
  143. package/src/pages/functions/buildWorker.ts +0 -151
  144. package/src/pages/functions/filepath-routing.test.ts +0 -234
  145. package/src/pages/functions/filepath-routing.ts +0 -189
  146. package/src/pages/functions/identifiers.ts +0 -78
  147. package/src/pages/functions/routes.ts +0 -151
  148. package/src/pages/index.tsx +0 -84
  149. package/src/pages/projects.tsx +0 -157
  150. package/src/pages/publish.tsx +0 -335
  151. package/src/pages/types.ts +0 -40
  152. package/src/pages/upload.tsx +0 -396
  153. package/src/pages/utils.ts +0 -12
  154. package/src/parse.ts +0 -286
  155. package/src/paths.ts +0 -26
  156. package/src/preview.ts +0 -31
  157. package/src/proxy.ts +0 -476
  158. package/src/publish.ts +0 -780
  159. package/src/pubsub/index.ts +0 -286
  160. package/src/pubsub/pubsub-commands.tsx +0 -577
  161. package/src/r2.ts +0 -50
  162. package/src/selfsigned.d.ts +0 -29
  163. package/src/sites.tsx +0 -372
  164. package/src/tail/filters.ts +0 -279
  165. package/src/tail/index.ts +0 -299
  166. package/src/tail/printing.ts +0 -67
  167. package/src/update-check.ts +0 -19
  168. package/src/user/choose-account.tsx +0 -60
  169. package/src/user/env-vars.ts +0 -46
  170. package/src/user/generate-auth-url.ts +0 -33
  171. package/src/user/generate-random-state.ts +0 -16
  172. package/src/user/index.ts +0 -3
  173. package/src/user/user.tsx +0 -1170
  174. package/src/whoami.tsx +0 -90
  175. package/src/worker-namespace.ts +0 -190
  176. package/src/worker.ts +0 -191
  177. package/src/zones.ts +0 -76
  178. package/templates/static-asset-facade.js +0 -49
@@ -1,577 +0,0 @@
1
- import { type ConfigPath } from "..";
2
- import { readConfig } from "../config";
3
- import { confirm } from "../dialogs";
4
- import { CommandLineArgsError } from "../index";
5
- import { logger } from "../logger";
6
- import { parseHumanDuration } from "../parse";
7
- import { requireAuth } from "../user";
8
- import * as pubsub from ".";
9
- import type { Argv, CommandModule } from "yargs";
10
-
11
- export function pubSubCommands(
12
- pubsubYargs: Argv,
13
- subHelp: CommandModule
14
- ): Argv {
15
- return pubsubYargs
16
- .command(subHelp)
17
- .command(
18
- "namespace",
19
- "Manage your Pub/Sub Namespaces",
20
- (pubsubNamespaceYargs) => {
21
- return pubsubNamespaceYargs
22
- .command(
23
- "create <name>",
24
- "Create a new Pub/Sub Namespace",
25
- (yargs) => {
26
- return yargs
27
- .positional("name", {
28
- describe:
29
- "The name of the new Namespace. This name will form part of the public endpoint, in the form <broker>.<namespace>.cloudflarepubsub.com",
30
- type: "string",
31
- demandOption: true,
32
- })
33
- .option("description", {
34
- describe: "Textual description of Namespace",
35
- type: "string",
36
- })
37
- .epilogue(pubsub.pubSubBetaWarning);
38
- },
39
- async (args) => {
40
- const config = readConfig(args.config as ConfigPath, args);
41
- const accountId = await requireAuth(config);
42
-
43
- const namespace: pubsub.PubSubNamespace = {
44
- name: args.name,
45
- };
46
- if (args.description) {
47
- namespace.description = args.description;
48
- }
49
-
50
- logger.log(`Creating Pub/SubNamespace ${args.name}...`);
51
- await pubsub.createPubSubNamespace(accountId, namespace);
52
- logger.log(`Success! Created Pub/Sub Namespace ${args.name}`);
53
- }
54
- )
55
- .command(
56
- "list",
57
- "List your existing Pub/Sub Namespaces",
58
- (yargs) => {
59
- return yargs.epilogue(pubsub.pubSubBetaWarning);
60
- },
61
- async (args) => {
62
- const config = readConfig(args.config as ConfigPath, args);
63
- const accountId = await requireAuth(config);
64
-
65
- logger.log(await pubsub.listPubSubNamespaces(accountId));
66
- }
67
- )
68
- .command(
69
- "delete <name>",
70
- "Delete a Pub/Sub Namespace",
71
- (yargs) => {
72
- return yargs
73
- .positional("name", {
74
- describe: "The name of the namespace to delete",
75
- type: "string",
76
- demandOption: true,
77
- })
78
- .epilogue(pubsub.pubSubBetaWarning);
79
- },
80
- async (args) => {
81
- const config = readConfig(args.config as ConfigPath, args);
82
- const accountId = await requireAuth(config);
83
-
84
- if (
85
- await confirm(
86
- `️❗️ Are you sure you want to delete the Pub/Sub Namespace ${args.name}? This cannot be undone.\nThis name will be available for others to register.`
87
- )
88
- ) {
89
- logger.log(`Deleting namespace ${args.name}...`);
90
- await pubsub.deletePubSubNamespace(accountId, args.name);
91
- logger.log(`Deleted namespace ${args.name}.`);
92
- }
93
- }
94
- )
95
- .command(
96
- "describe <name>",
97
- "Describe a Pub/Sub Namespace",
98
- (yargs) => {
99
- return yargs
100
- .positional("name", {
101
- describe: "The name of the namespace to describe.",
102
- type: "string",
103
- demandOption: true,
104
- })
105
- .epilogue(pubsub.pubSubBetaWarning);
106
- },
107
- async (args) => {
108
- const config = readConfig(args.config as ConfigPath, args);
109
- const accountId = await requireAuth(config);
110
-
111
- logger.log(
112
- await pubsub.describePubSubNamespace(accountId, args.name)
113
- );
114
- }
115
- )
116
- .epilogue(pubsub.pubSubBetaWarning);
117
- }
118
- )
119
- .command("broker", "Interact with your Pub/Sub Brokers", (brokersYargs) => {
120
- brokersYargs.command(
121
- "create <name>",
122
- "Create a new Pub/Sub Broker",
123
- (yargs) =>
124
- yargs
125
- .positional("name", {
126
- describe:
127
- "The name of the Pub/Sub Broker. This name will form part of the public endpoint, in the form <broker>.<namespace>.cloudflarepubsub.com",
128
- type: "string",
129
- demandOption: true,
130
- })
131
- .option("namespace", {
132
- describe:
133
- "An existing Namespace to associate the Broker with. This name will form part of the public endpoint, in the form <broker>.<namespace>.cloudflarepubsub.com",
134
- type: "string",
135
- alias: "ns",
136
- demandOption: true,
137
- })
138
- .option("description", {
139
- describe: "Longer description for the broker",
140
- type: "string",
141
- })
142
- .option("expiration", {
143
- describe:
144
- "Time to allow token validity (can use seconds, hours, months, weeks, years)",
145
- type: "string",
146
- })
147
- .option("on-publish-url", {
148
- describe:
149
- "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.",
150
- type: "string",
151
- })
152
- .epilogue(pubsub.pubSubBetaWarning),
153
- async (args) => {
154
- const config = readConfig(args.config as ConfigPath, args);
155
- const accountId = await requireAuth(config);
156
-
157
- const broker: pubsub.PubSubBroker = {
158
- name: args.name,
159
- };
160
- if (args.description) {
161
- broker.description = args.description;
162
- }
163
- if (args.expiration) {
164
- const expiration = parseHumanDuration(args.expiration);
165
- if (isNaN(expiration)) {
166
- throw new CommandLineArgsError(
167
- `${args.expiration} is not a time duration. (Example of valid values are: 1y, 6 days)`
168
- );
169
- }
170
- broker.expiration = expiration;
171
- }
172
- if (args["on-publish-url"]) {
173
- broker.on_publish = {
174
- url: args["on-publish-url"],
175
- };
176
- }
177
-
178
- logger.log(
179
- await pubsub.createPubSubBroker(accountId, args.namespace, broker)
180
- );
181
- }
182
- );
183
-
184
- brokersYargs.command(
185
- "update <name>",
186
- "Update an existing Pub/Sub Broker's configuration.",
187
- (yargs) =>
188
- yargs
189
- .positional("name", {
190
- describe: "The name of an existing Pub/Sub Broker",
191
- type: "string",
192
- demandOption: true,
193
- })
194
- .option("namespace", {
195
- describe: "The Namespace the Broker is associated with",
196
- type: "string",
197
- alias: "ns",
198
- demandOption: true,
199
- })
200
- .option("description", {
201
- describe: "A optional description of the Broker.",
202
- type: "string",
203
- })
204
- .option("expiration", {
205
- describe:
206
- "The expiration date for all client credentials issued by the Broker (can use seconds, hours, months, weeks, years)",
207
- type: "string",
208
- })
209
- .option("on-publish-url", {
210
- describe:
211
- "A (HTTPS) Cloudflare Worker (or webhook) URL that messages will be sent to on-publish.",
212
- type: "string",
213
- })
214
- .epilogue(pubsub.pubSubBetaWarning),
215
- async (args) => {
216
- const config = readConfig(args.config as ConfigPath, args);
217
- const accountId = await requireAuth(config);
218
-
219
- const broker: pubsub.PubSubBrokerUpdate = {};
220
-
221
- if (args.description) {
222
- broker.description = args.description;
223
- }
224
-
225
- if (args.expiration) {
226
- const expiration = parseHumanDuration(args.expiration);
227
- if (isNaN(expiration)) {
228
- throw new CommandLineArgsError(
229
- `${args.expiration} is not a time duration. Examples of valid values include: '1y', '24h', or '6 days'.`
230
- );
231
- }
232
- broker.expiration = expiration;
233
- }
234
-
235
- if (args["on-publish-url"]) {
236
- broker.on_publish = {
237
- url: args["on-publish-url"],
238
- };
239
- }
240
-
241
- logger.log(
242
- await pubsub.updatePubSubBroker(
243
- accountId,
244
- args.namespace,
245
- args.name,
246
- broker
247
- )
248
- );
249
- logger.log(`Successfully updated Pub/Sub Broker ${args.name}`);
250
- }
251
- );
252
-
253
- brokersYargs.command(
254
- "list",
255
- "List the Pub/Sub Brokers within a Namespace",
256
- (yargs) => {
257
- return yargs
258
- .option("namespace", {
259
- describe: "The Namespace the Brokers are associated with.",
260
- type: "string",
261
- alias: "ns",
262
- demandOption: true,
263
- })
264
- .epilogue(pubsub.pubSubBetaWarning);
265
- },
266
- async (args) => {
267
- const config = readConfig(args.config as ConfigPath, args);
268
- const accountId = await requireAuth(config);
269
-
270
- logger.log(await pubsub.listPubSubBrokers(accountId, args.namespace));
271
- }
272
- );
273
-
274
- brokersYargs
275
- .command(
276
- "delete <name>",
277
- "Delete an existing Pub/Sub Broker",
278
- (yargs) => {
279
- return yargs
280
- .positional("name", {
281
- describe: "The name of the Broker to delete",
282
- type: "string",
283
- demandOption: true,
284
- })
285
- .option("namespace", {
286
- describe: "The Namespace the Broker is associated with.",
287
- type: "string",
288
- alias: "ns",
289
- demandOption: true,
290
- })
291
- .epilogue(pubsub.pubSubBetaWarning);
292
- },
293
- async (args) => {
294
- const config = readConfig(args.config as ConfigPath, args);
295
- const accountId = await requireAuth(config);
296
-
297
- if (
298
- await confirm(
299
- `️❗️ Are you sure you want to delete the Pub/Sub Broker ${args.name}? This cannot be undone.\nAll existing clients will be disconnected.`
300
- )
301
- ) {
302
- logger.log(`Deleting Pub/Sub Broker ${args.name}.`);
303
- await pubsub.deletePubSubBroker(
304
- accountId,
305
- args.namespace,
306
- args.name
307
- );
308
- logger.log(`Deleted Pub/Sub Broker ${args.name}.`);
309
- }
310
- }
311
- )
312
- .command(
313
- "describe <name>",
314
- "Describe an existing Pub/Sub Broker.",
315
- (yargs) => {
316
- return yargs
317
- .positional("name", {
318
- describe: "The name of the Broker to describe.",
319
- type: "string",
320
- demandOption: true,
321
- })
322
- .option("namespace", {
323
- describe: "The Namespace the Broker is associated with.",
324
- type: "string",
325
- alias: "ns",
326
- demandOption: true,
327
- })
328
- .epilogue(pubsub.pubSubBetaWarning);
329
- },
330
- async (args) => {
331
- const config = readConfig(args.config as ConfigPath, args);
332
- const accountId = await requireAuth(config);
333
-
334
- logger.log(
335
- await pubsub.describePubSubBroker(
336
- accountId,
337
- args.namespace,
338
- args.name
339
- )
340
- );
341
- }
342
- );
343
-
344
- brokersYargs.command(
345
- "issue <name>",
346
- "Issue new client credentials for a specific Pub/Sub Broker.",
347
- (yargs) => {
348
- return yargs
349
- .positional("name", {
350
- describe: "The name of the Broker to issue credentials for.",
351
- type: "string",
352
- demandOption: true,
353
- })
354
- .option("namespace", {
355
- describe: "The Namespace the Broker is associated with.",
356
- type: "string",
357
- alias: "ns",
358
- demandOption: true,
359
- })
360
- .option("number", {
361
- describe: "The number of credentials to generate.",
362
- type: "number",
363
- alias: "n",
364
- default: 1,
365
- })
366
- .option("type", {
367
- describe: "The type of credential to generate.",
368
- type: "string",
369
- default: "TOKEN",
370
- })
371
- .option("expiration", {
372
- describe:
373
- "The expiration to set on the issued credentials. This overrides any Broker-level expiration that is set.",
374
- type: "string",
375
- alias: "exp",
376
- })
377
- .option("client-id", {
378
- describe:
379
- "A list of existing clientIds to generate tokens for. By default, clientIds are randomly generated.",
380
- type: "string",
381
- alias: "jti",
382
- array: true,
383
- })
384
- .epilogue(pubsub.pubSubBetaWarning);
385
- },
386
- async (args) => {
387
- const config = readConfig(args.config as ConfigPath, args);
388
- const accountId = await requireAuth(config);
389
-
390
- let parsedExpiration: number | undefined;
391
- if (args.expiration) {
392
- const expiration = parseHumanDuration(args.expiration);
393
- if (isNaN(expiration)) {
394
- throw new CommandLineArgsError(
395
- `${args.expiration} is not a time duration. Example of valid values are: 1y, 6 days.`
396
- );
397
- }
398
- parsedExpiration = expiration;
399
- }
400
-
401
- logger.log(
402
- `🔑 Issuing credential(s) for ${args.name}.${args.namespace}...`
403
- );
404
-
405
- logger.log(
406
- await pubsub.issuePubSubBrokerTokens(
407
- accountId,
408
- args.namespace,
409
- args.name,
410
- args.number,
411
- args.type,
412
- args["client-id"],
413
- parsedExpiration
414
- )
415
- );
416
- }
417
- );
418
-
419
- brokersYargs.command(
420
- "revoke <name>",
421
- "Revoke a set of active client credentials associated with the given Broker",
422
- (yargs) => {
423
- return yargs
424
- .positional("name", {
425
- describe: "The name of the Broker to revoke credentials against.",
426
- type: "string",
427
- demandOption: true,
428
- })
429
- .option("namespace", {
430
- describe: "The Namespace the Broker is associated with.",
431
- type: "string",
432
- alias: "ns",
433
- demandOption: true,
434
- })
435
- .option("jti", {
436
- describe: "Tokens to revoke",
437
- type: "string",
438
- demandOption: true,
439
- array: true,
440
- })
441
- .epilogue(pubsub.pubSubBetaWarning);
442
- },
443
- async (args) => {
444
- const config = readConfig(args.config as ConfigPath, args);
445
- const accountId = await requireAuth(config);
446
-
447
- const numTokens = args.jti.length;
448
-
449
- logger.log(
450
- `🔴 Revoking access to ${args.name} for ${numTokens} credential(s)...`
451
- );
452
-
453
- await pubsub.revokePubSubBrokerTokens(
454
- accountId,
455
- args.namespace,
456
- args.name,
457
- args.jti
458
- );
459
-
460
- logger.log(`Revoked ${args.jti.length} credential(s).`);
461
- }
462
- );
463
-
464
- brokersYargs.command(
465
- "unrevoke <name>",
466
- "Restore access to a set of previously revoked client credentials.",
467
- (yargs) => {
468
- return yargs
469
- .positional("name", {
470
- describe: "The name of the Broker to revoke credentials against.",
471
- type: "string",
472
- demandOption: true,
473
- })
474
- .option("namespace", {
475
- describe: "The Namespace the Broker is associated with.",
476
- type: "string",
477
- alias: "ns",
478
- demandOption: true,
479
- })
480
- .option("jti", {
481
- describe: "Tokens to revoke",
482
- type: "string",
483
- demandOption: true,
484
- array: true,
485
- })
486
- .epilogue(pubsub.pubSubBetaWarning);
487
- },
488
- async (args) => {
489
- const config = readConfig(args.config as ConfigPath, args);
490
- const accountId = await requireAuth(config);
491
-
492
- const numTokens = args.jti.length;
493
- logger.log(
494
- `🟢 Restoring access to ${args.broker} for ${numTokens} credential(s)...`
495
- );
496
-
497
- await pubsub.unrevokePubSubBrokerTokens(
498
- accountId,
499
- args.namespace,
500
- args.name,
501
- args.jti
502
- );
503
-
504
- logger.log(`Unrevoked ${numTokens} credential(s)`);
505
- }
506
- );
507
-
508
- brokersYargs.command(
509
- "show-revocations <name>",
510
- "Show all previously revoked client credentials.",
511
- (yargs) => {
512
- return yargs
513
- .positional("name", {
514
- describe: "The name of the Broker to revoke credentials against.",
515
- type: "string",
516
- demandOption: true,
517
- })
518
- .option("namespace", {
519
- describe: "The Namespace the Broker is associated with.",
520
- type: "string",
521
- alias: "ns",
522
- demandOption: true,
523
- })
524
- .epilogue(pubsub.pubSubBetaWarning);
525
- },
526
- async (args) => {
527
- const config = readConfig(args.config as ConfigPath, args);
528
- const accountId = await requireAuth(config);
529
-
530
- logger.log(`Listing previously revoked tokens for ${args.name}...`);
531
- logger.log(
532
- await pubsub.listRevokedPubSubBrokerTokens(
533
- accountId,
534
- args.namespace,
535
- args.name
536
- )
537
- );
538
- }
539
- );
540
-
541
- brokersYargs.command(
542
- "public-keys <name>",
543
- "Show the public keys used for verifying on-publish hooks and credentials for a Broker.",
544
- (yargs) => {
545
- return yargs
546
- .positional("name", {
547
- describe: "The name of the Broker to revoke credentials against.",
548
- type: "string",
549
- demandOption: true,
550
- })
551
- .option("namespace", {
552
- describe: "The Namespace the Broker is associated with.",
553
- type: "string",
554
- alias: "ns",
555
- demandOption: true,
556
- })
557
- .epilogue(pubsub.pubSubBetaWarning);
558
- },
559
- async (args) => {
560
- const config = readConfig(args.config as ConfigPath, args);
561
- const accountId = await requireAuth(config);
562
-
563
- logger.log(
564
- await pubsub.getPubSubBrokerPublicKeys(
565
- accountId,
566
- args.namespace,
567
- args.name
568
- )
569
- );
570
- }
571
- );
572
-
573
- brokersYargs.epilogue(pubsub.pubSubBetaWarning);
574
- return brokersYargs;
575
- })
576
- .epilogue(pubsub.pubSubBetaWarning);
577
- }
package/src/r2.ts DELETED
@@ -1,50 +0,0 @@
1
- import { fetchResult } from "./cfetch";
2
-
3
- /**
4
- * Information about a bucket, returned from `listR2Buckets()`.
5
- */
6
- export interface R2BucketInfo {
7
- name: string;
8
- creation_date: string;
9
- }
10
-
11
- /**
12
- * Fetch a list of all the buckets under the given `accountId`.
13
- */
14
- export async function listR2Buckets(
15
- accountId: string
16
- ): Promise<R2BucketInfo[]> {
17
- const results = await fetchResult<{
18
- buckets: R2BucketInfo[];
19
- }>(`/accounts/${accountId}/r2/buckets`);
20
- return results.buckets;
21
- }
22
-
23
- /**
24
- * Create a bucket with the given `bucketName` within the account given by `accountId`.
25
- *
26
- * A 400 is returned if the account already owns a bucket with this name.
27
- * A bucket must be explicitly deleted to be replaced.
28
- */
29
- export async function createR2Bucket(
30
- accountId: string,
31
- bucketName: string
32
- ): Promise<void> {
33
- return await fetchResult<void>(
34
- `/accounts/${accountId}/r2/buckets/${bucketName}`,
35
- { method: "PUT" }
36
- );
37
- }
38
-
39
- /**
40
- * Delete a bucket with the given name
41
- */
42
- export async function deleteR2Bucket(
43
- accountId: string,
44
- bucketName: string
45
- ): Promise<void> {
46
- return await fetchResult<void>(
47
- `/accounts/${accountId}/r2/buckets/${bucketName}`,
48
- { method: "DELETE" }
49
- );
50
- }
@@ -1,29 +0,0 @@
1
- declare module "selfsigned" {
2
- import type { pki } from "node-forge";
3
-
4
- export type Attributes = pki.CertificateField[];
5
-
6
- export interface Options {
7
- days?: number;
8
- keySize?: number;
9
- extensions?: unknown[];
10
- algorithm?: string;
11
- pkcs7?: boolean;
12
- clientCertificate?: boolean;
13
- clientCertificateCN?: string;
14
- }
15
-
16
- export interface Certificate {
17
- private: string;
18
- public: string;
19
- cert: string;
20
- fingerprint: string;
21
- }
22
-
23
- export function generate(attrs?: Attributes, options?: Options): Certificate;
24
- export function generate(
25
- attrs: Attributes,
26
- options: Options,
27
- callback: (err: Error, certificate: Certificate) => void
28
- ): void;
29
- }