@vibes.diy/identity 14.3.459 → 14.3.461

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.
@@ -0,0 +1 @@
1
+ export declare function cliLoginConfirmCode(csr: string): Promise<string>;
@@ -0,0 +1,10 @@
1
+ import { TxtEnDecoderSingleton } from "@adviser/cement";
2
+ const CODE_BYTES = 4;
3
+ export async function cliLoginConfirmCode(csr) {
4
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", TxtEnDecoderSingleton().encode(csr));
5
+ const hex = Array.from(new Uint8Array(digest).slice(0, CODE_BYTES))
6
+ .map((b) => b.toString(16).padStart(2, "0"))
7
+ .join("")
8
+ .toUpperCase();
9
+ return `${hex.slice(0, 4)}-${hex.slice(4)}`;
10
+ }
@@ -30,6 +30,7 @@ export declare function detectHeadlessBrowser({ env, platform, noBrowser }: Head
30
30
  export declare function formatRemaining(seconds: number): string;
31
31
  export declare function heartbeatMessage(callbackUrl: string, remainingSeconds: number, pickupEnabled?: boolean): string;
32
32
  export declare function manualCompletionHint(pasteEnabled: boolean, pickupEnabled?: boolean): string;
33
+ export declare function confirmCodeLines(code: string): string;
33
34
  export interface ApprovingAccount {
34
35
  readonly userId: string;
35
36
  readonly ownerHandle?: string;
@@ -114,6 +114,9 @@ export function manualCompletionHint(pasteEnabled, pickupEnabled = false) {
114
114
  }
115
115
  return lines.join("\n");
116
116
  }
117
+ export function confirmCodeLines(code) {
118
+ return [`Confirmation code: ${code}`, "The approval page shows this same code. Check that they match, then approve.\n"].join("\n");
119
+ }
117
120
  export function normalizeExpectedHandle(handle) {
118
121
  const h = handle?.trim().replace(/^@/, "");
119
122
  return h === undefined || h === "" ? undefined : h;
@@ -10,7 +10,8 @@ import { isUnreadableDeviceIdKeybagError } from "../keybag/key-bag.js";
10
10
  import { deviceIdInstanceForApiUrl } from "../keybag/instance.js";
11
11
  import { DeviceIdKey } from "./key.js";
12
12
  import { DeviceIdCSR } from "./csr.js";
13
- import { checkExistingCertExpectations, checkLoginExpectations, clerkUserIdFromCertPayload, detectHeadlessBrowser, extractCertValue, heartbeatMessage, manualCompletionHint, normalizeExpectedHandle, parseCertJWT, signedInAsLine, storeDeviceCert, timeoutMessage, } from "./register-support.js";
13
+ import { cliLoginConfirmCode } from "../cli-login-confirm-code.js";
14
+ import { checkExistingCertExpectations, checkLoginExpectations, clerkUserIdFromCertPayload, confirmCodeLines, detectHeadlessBrowser, extractCertValue, heartbeatMessage, manualCompletionHint, normalizeExpectedHandle, parseCertJWT, signedInAsLine, storeDeviceCert, timeoutMessage, } from "./register-support.js";
14
15
  function stdinPasteSource() {
15
16
  if (!process.stdin.isTTY) {
16
17
  return undefined;
@@ -319,6 +320,7 @@ export const deviceIdRegisterEvento = {
319
320
  await sendProgress(ctx, "info", `Started local callback server on port ${port}...`);
320
321
  const caUri = BuildURI.from(args.caUrl).setParam("csr", csrJWS).setParam("returnUrl", callbackUrl);
321
322
  const caUrlWithParams = caUri.toString();
323
+ const confirmLines = confirmCodeLines(await cliLoginConfirmCode(csrJWS));
322
324
  const paste = deps.pasteSource();
323
325
  paste?.onLine((line) => {
324
326
  if (line.trim() === "") {
@@ -344,11 +346,13 @@ export const deviceIdRegisterEvento = {
344
346
  if (headless.headless) {
345
347
  await sendProgress(ctx, "info", `\nNot opening a browser (${headless.reason}).`);
346
348
  await sendProgress(ctx, "info", `URL: ${caUrlWithParams}\n`);
349
+ await sendProgress(ctx, "info", confirmLines);
347
350
  await sendProgress(ctx, "info", manualCompletionHint(paste !== undefined, pickupEnabled));
348
351
  }
349
352
  else {
350
353
  await sendProgress(ctx, "info", "\nOpening browser to CA for certificate signing...");
351
354
  await sendProgress(ctx, "info", `URL: ${caUrlWithParams}\n`);
355
+ await sendProgress(ctx, "info", confirmLines);
352
356
  try {
353
357
  await deps.openBrowser(caUrlWithParams);
354
358
  }
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { ClerkClaimSchema, ClerkEmailTemplateClaimSchema, type ClerkClaim } from
3
3
  export { ensureSuperThis, ensureLogger, runtimeFn } from "./runtime/superthis.js";
4
4
  export * as sts from "./sts/index.js";
5
5
  export { hashObjectSync } from "./runtime/hashing.js";
6
+ export { cliLoginConfirmCode } from "./cli-login-confirm-code.js";
6
7
  export { settledKeyedOnce, settledOnce, type SettledKeyedOnce, type SettledKeyedOnceOpts } from "./runtime/settled-once.js";
7
8
  export type { DashAuthType, ReqCertFromCsr, ResCertFromCsr, VerifiedClaimsResult, VerifiedAuthResult, WithAuth, FPApiParameters, FPApiToken, } from "./types/wire.js";
8
9
  export type { VerifiedResult } from "./dash-api/protocols-dashboard/index.js";
package/index.js CHANGED
@@ -3,6 +3,7 @@ export { ClerkClaimSchema, ClerkEmailTemplateClaimSchema } from "./clerk-claim.j
3
3
  export { ensureSuperThis, ensureLogger, runtimeFn } from "./runtime/superthis.js";
4
4
  export * as sts from "./sts/index.js";
5
5
  export { hashObjectSync } from "./runtime/hashing.js";
6
+ export { cliLoginConfirmCode } from "./cli-login-confirm-code.js";
6
7
  export { settledKeyedOnce, settledOnce } from "./runtime/settled-once.js";
7
8
  export { JWKPrivateSchema, JWKPublicSchema } from "./types/wire.js";
8
9
  export { ClerkApiToken } from "./dash-api/clerk-token.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/identity",
3
- "version": "14.3.459",
3
+ "version": "14.3.461",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -19,7 +19,7 @@
19
19
  "@adviser/ts-xxhash": "~1.0.2",
20
20
  "@clerk/shared": "~4.50.0",
21
21
  "@hono/node-server": "~2.1.9",
22
- "@vibes.diy/cmd-tools": "14.3.459",
22
+ "@vibes.diy/cmd-tools": "14.3.461",
23
23
  "arktype": "~2.2.10",
24
24
  "hono": "~4.13.19",
25
25
  "jose": "~6.2.18",
package/types/wire.d.ts CHANGED
@@ -185,6 +185,8 @@ export interface ReqCertFromCsr {
185
185
  readonly type: "reqCertFromCsr";
186
186
  readonly auth: DashAuthType;
187
187
  readonly csr: string;
188
+ readonly confirmCode?: string;
189
+ readonly expectedUserId?: string;
188
190
  }
189
191
  export interface ResCertFromCsr {
190
192
  readonly type: "resCertFromCsr";