wrangler 0.0.0-cd66b67 → 0.0.0-ce00a44c

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