@go-labs-sg/registration 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +104 -82
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -372,9 +372,6 @@ var import_dotenv = __toESM(require_main(), 1);
372
372
  import path from "path";
373
373
  import_dotenv.config({ path: path.resolve(process.cwd(), ".env"), quiet: true });
374
374
 
375
- // src/index.ts
376
- import { readFileSync } from "fs";
377
-
378
375
  // ../../cli-auth/src/protocol/constants.ts
379
376
  var CLI_ACCESS_TOKEN_TTL_MS = 15 * 60 * 1000;
380
377
  var CLI_DEVICE_AUTHORIZATION_TTL_MS = 10 * 60 * 1000;
@@ -14753,6 +14750,22 @@ var assertBunRuntime = (runtime = globalThis.Bun) => {
14753
14750
  };
14754
14751
 
14755
14752
  // ../../cli-auth/src/client/credential-store.ts
14753
+ class CliCredentialStoreUnavailableError extends Error {
14754
+ code = "CLI_CREDENTIAL_STORE_UNAVAILABLE";
14755
+ constructor(product, options) {
14756
+ super(`Secure credential storage is unavailable for the ${product} CLI. Bun.secrets requires the operating system credential store, including Secret Service on Linux. Browser authentication cannot continue without a supported secure store.`, options);
14757
+ this.name = "CliCredentialStoreUnavailableError";
14758
+ }
14759
+ }
14760
+ var useSecrets = async (product, operation) => {
14761
+ try {
14762
+ return await operation();
14763
+ } catch (cause) {
14764
+ if (cause instanceof CliCredentialStoreUnavailableError)
14765
+ throw cause;
14766
+ throw new CliCredentialStoreUnavailableError(product, { cause });
14767
+ }
14768
+ };
14756
14769
  var defaultSecrets = () => {
14757
14770
  assertBunRuntime();
14758
14771
  return Bun.secrets;
@@ -14765,10 +14778,10 @@ var createBunCredentialStore = ({
14765
14778
  const service = `go-labs-cli:${product}`;
14766
14779
  return {
14767
14780
  delete: async () => {
14768
- await secrets.delete({ name: account, service });
14781
+ await useSecrets(product, () => secrets.delete({ name: account, service }));
14769
14782
  },
14770
14783
  get: async () => {
14771
- const value = await secrets.get({ name: account, service });
14784
+ const value = await useSecrets(product, () => secrets.get({ name: account, service }));
14772
14785
  if (value === null)
14773
14786
  return null;
14774
14787
  try {
@@ -14779,11 +14792,11 @@ var createBunCredentialStore = ({
14779
14792
  },
14780
14793
  set: async (credentials) => {
14781
14794
  const parsed = storedCliCredentialsSchema.parse(credentials);
14782
- await secrets.set({
14795
+ await useSecrets(product, () => secrets.set({
14783
14796
  name: account,
14784
14797
  service,
14785
14798
  value: JSON.stringify(parsed)
14786
- });
14799
+ }));
14787
14800
  }
14788
14801
  };
14789
14802
  };
@@ -14947,24 +14960,16 @@ var logoutCliSession = async ({
14947
14960
  await store.delete();
14948
14961
  return { remoteRevoked };
14949
14962
  };
14963
+ // src/cli.ts
14964
+ import { readFileSync } from "fs";
14965
+
14950
14966
  // src/api-client.ts
14951
14967
  import {
14952
14968
  createTRPCProxyClient,
14953
14969
  httpBatchLink
14954
14970
  } from "@trpc/client";
14955
14971
  import SuperJSON from "superjson";
14956
- var DEFAULT_API_BASE_URL = "https://registration.getout.events";
14957
- var normalizeApiBaseUrl = (value) => {
14958
- const url2 = new URL(value);
14959
- const localHttp = url2.protocol === "http:" && (url2.hostname === "localhost" || url2.hostname === "127.0.0.1");
14960
- if (url2.protocol !== "https:" && !localHttp) {
14961
- throw new Error("Registration API URL must use HTTPS, except for localhost development.");
14962
- }
14963
- url2.pathname = url2.pathname.replace(/\/$/, "");
14964
- return url2.toString().replace(/\/$/, "");
14965
- };
14966
- var getApiBaseUrl = (override) => normalizeApiBaseUrl(override ?? process.env.REG_API_URL ?? DEFAULT_API_BASE_URL);
14967
- var createApiClient = (apiBaseUrl, accessToken) => createTRPCProxyClient({
14972
+ var createRegistrationClient = (apiBaseUrl, accessToken) => createTRPCProxyClient({
14968
14973
  links: [
14969
14974
  httpBatchLink({
14970
14975
  url: `${apiBaseUrl}/api/trpc`,
@@ -14976,6 +14981,8 @@ var createApiClient = (apiBaseUrl, accessToken) => createTRPCProxyClient({
14976
14981
  })
14977
14982
  ]
14978
14983
  });
14984
+
14985
+ // src/command-client.ts
14979
14986
  var invokeCommand = (client, procedure, input) => {
14980
14987
  const objectInput = input ?? {};
14981
14988
  switch (procedure) {
@@ -15102,72 +15109,13 @@ var invokeCommand = (client, procedure, input) => {
15102
15109
  }
15103
15110
  };
15104
15111
  var createCommandClient = (apiBaseUrl, accessToken) => {
15105
- const client = createApiClient(apiBaseUrl, accessToken);
15112
+ const client = createRegistrationClient(apiBaseUrl, accessToken);
15106
15113
  return {
15107
15114
  invoke: (procedure, input) => invokeCommand(client, procedure, input)
15108
15115
  };
15109
15116
  };
15110
15117
 
15111
- // src/parse-args.ts
15112
- var BOOLEAN_FLAGS = new Set([
15113
- "allow-state-change",
15114
- "allow-email",
15115
- "allow-external-write",
15116
- "allow-delete",
15117
- "allow-financial-write",
15118
- "ack-sensitive-data",
15119
- "debug",
15120
- "help",
15121
- "no-browser",
15122
- "quiet"
15123
- ]);
15124
- var KNOWN_FLAGS = new Set([...BOOLEAN_FLAGS, "api-url", "input", "target"]);
15125
- var parseArguments = (args) => {
15126
- const flags = new Map;
15127
- const positionals = [];
15128
- for (let index = 0;index < args.length; index += 1) {
15129
- const arg = args[index];
15130
- if (arg === "-q") {
15131
- flags.set("quiet", true);
15132
- continue;
15133
- }
15134
- if (!arg?.startsWith("--")) {
15135
- if (arg)
15136
- positionals.push(arg);
15137
- continue;
15138
- }
15139
- const [rawName, inlineValue] = arg.slice(2).split(/=(.*)/s, 2);
15140
- if (!rawName)
15141
- throw new Error(`Invalid option: ${arg}`);
15142
- if (inlineValue !== undefined) {
15143
- flags.set(rawName, inlineValue);
15144
- continue;
15145
- }
15146
- if (BOOLEAN_FLAGS.has(rawName)) {
15147
- flags.set(rawName, true);
15148
- continue;
15149
- }
15150
- const value = args[index + 1];
15151
- if (!value || value.startsWith("--")) {
15152
- throw new Error(`--${rawName} requires a value`);
15153
- }
15154
- flags.set(rawName, value);
15155
- index += 1;
15156
- }
15157
- return { flags, positionals };
15158
- };
15159
- var assertKnownFlags = (flags) => {
15160
- const unknown2 = [...flags.keys()].filter((name) => !KNOWN_FLAGS.has(name));
15161
- if (unknown2.length === 0)
15162
- return;
15163
- throw new Error(`Unknown option${unknown2.length === 1 ? "" : "s"}: ${unknown2.map((name) => `--${name}`).join(", ")}.`);
15164
- };
15165
- var getStringFlag = (flags, name) => {
15166
- const value = flags.get(name);
15167
- return typeof value === "string" ? value : undefined;
15168
- };
15169
-
15170
- // src/registry.ts
15118
+ // src/commands/index.ts
15171
15119
  var globalCommandOptions = [
15172
15120
  "--api-url <url>",
15173
15121
  "--input <json>",
@@ -15323,7 +15271,79 @@ _arguments '*: :(${words})'
15323
15271
  }
15324
15272
  };
15325
15273
 
15326
- // src/runtime.ts
15274
+ // src/config.ts
15275
+ var DEFAULT_API_BASE_URL = "https://registration.getout.events";
15276
+ var normalizeApiBaseUrl = (value) => {
15277
+ const url2 = new URL(value);
15278
+ const localHttp = url2.protocol === "http:" && (url2.hostname === "localhost" || url2.hostname === "127.0.0.1");
15279
+ if (url2.protocol !== "https:" && !localHttp) {
15280
+ throw new Error("Registration API URL must use HTTPS, except for localhost development.");
15281
+ }
15282
+ url2.pathname = url2.pathname.replace(/\/$/, "");
15283
+ return url2.toString().replace(/\/$/, "");
15284
+ };
15285
+ var getApiBaseUrl = (override) => normalizeApiBaseUrl(override ?? process.env.REG_API_URL ?? DEFAULT_API_BASE_URL);
15286
+
15287
+ // src/parse-args.ts
15288
+ var BOOLEAN_FLAGS = new Set([
15289
+ "allow-state-change",
15290
+ "allow-email",
15291
+ "allow-external-write",
15292
+ "allow-delete",
15293
+ "allow-financial-write",
15294
+ "ack-sensitive-data",
15295
+ "debug",
15296
+ "help",
15297
+ "no-browser",
15298
+ "quiet"
15299
+ ]);
15300
+ var KNOWN_FLAGS = new Set([...BOOLEAN_FLAGS, "api-url", "input", "target"]);
15301
+ var parseArguments = (args) => {
15302
+ const flags = new Map;
15303
+ const positionals = [];
15304
+ for (let index = 0;index < args.length; index += 1) {
15305
+ const arg = args[index];
15306
+ if (arg === "-q") {
15307
+ flags.set("quiet", true);
15308
+ continue;
15309
+ }
15310
+ if (!arg?.startsWith("--")) {
15311
+ if (arg)
15312
+ positionals.push(arg);
15313
+ continue;
15314
+ }
15315
+ const [rawName, inlineValue] = arg.slice(2).split(/=(.*)/s, 2);
15316
+ if (!rawName)
15317
+ throw new Error(`Invalid option: ${arg}`);
15318
+ if (inlineValue !== undefined) {
15319
+ flags.set(rawName, inlineValue);
15320
+ continue;
15321
+ }
15322
+ if (BOOLEAN_FLAGS.has(rawName)) {
15323
+ flags.set(rawName, true);
15324
+ continue;
15325
+ }
15326
+ const value = args[index + 1];
15327
+ if (!value || value.startsWith("--")) {
15328
+ throw new Error(`--${rawName} requires a value`);
15329
+ }
15330
+ flags.set(rawName, value);
15331
+ index += 1;
15332
+ }
15333
+ return { flags, positionals };
15334
+ };
15335
+ var assertKnownFlags = (flags) => {
15336
+ const unknown2 = [...flags.keys()].filter((name) => !KNOWN_FLAGS.has(name));
15337
+ if (unknown2.length === 0)
15338
+ return;
15339
+ throw new Error(`Unknown option${unknown2.length === 1 ? "" : "s"}: ${unknown2.map((name) => `--${name}`).join(", ")}.`);
15340
+ };
15341
+ var getStringFlag = (flags, name) => {
15342
+ const value = flags.get(name);
15343
+ return typeof value === "string" ? value : undefined;
15344
+ };
15345
+
15346
+ // src/runtime/index.ts
15327
15347
  class CliError extends Error {
15328
15348
  code;
15329
15349
  details;
@@ -15429,7 +15449,7 @@ var normalizeError = (error51) => {
15429
15449
  };
15430
15450
  };
15431
15451
 
15432
- // src/index.ts
15452
+ // src/cli.ts
15433
15453
  var dateInputKeys = new Set([
15434
15454
  "from",
15435
15455
  "to",
@@ -15656,6 +15676,8 @@ Waiting for approval\u2026
15656
15676
  return ["USAGE", "VALIDATION", "CONFIRMATION_REQUIRED"].includes(normalized.code) ? 2 : 1;
15657
15677
  }
15658
15678
  };
15679
+
15680
+ // src/index.ts
15659
15681
  if (import.meta.main) {
15660
15682
  assertBunRuntime();
15661
15683
  process.exitCode = await runCli();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-labs-sg/registration",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Registration System CLI for organizations, events, forms, registrations, and attendee operations.",
5
5
  "type": "module",
6
6
  "bin": {