@wix/himalaya-cli 0.1540.0 → 0.1542.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.
@@ -103,4 +103,8 @@ export declare function handleWixGateway(gw: WixGatewayState, app: string, admin
103
103
  /** The ACTIVE app's own Wix clientId (loader.resolveWixClientId) — the mint-retry
104
104
  * below mints an anonymous visitor token from it so each app hits its OWN site.
105
105
  * Falls back to WIX_DEV_CLIENT_ID (env / amit1 default) when absent. */
106
- wixClientId?: string): Promise<boolean>;
106
+ wixClientId?: string,
107
+ /** The ACTIVE app's MetaSite when it is bound with `visitorSource: "one-app"`: no retry then —
108
+ * it has no clientId to mint from (the fallback is another site), and a One App re-mint would
109
+ * be a new visitor. */
110
+ oneAppMetaSiteId?: string): Promise<boolean>;
@@ -1,5 +1,9 @@
1
1
  /** Mint an anonymous visitor access token for the client. */
2
2
  export declare function mintVisitor(clientId: string): Promise<string>;
3
+ /** The site's One App visitor instance (`visitorSource: "one-app"`) for a one-shot CLI read
4
+ * (`render --live`, `test --record`) — sent bare as `Authorization`, like `mintVisitor`'s token.
5
+ * Node only: no CORS stands in the way here. The dev-server's web sessions keep their own. */
6
+ export declare function mintOneAppVisitorToken(metaSiteId: string): Promise<string>;
3
7
  /** Direct (captcha-free) Wix Headless member login → real member access token. */
4
8
  export declare function memberDirectLogin(clientId: string, redirectUri: string, email: string, password: string): Promise<{
5
9
  memberToken: string;
@@ -14,6 +14,27 @@ export interface WixBridgeEnvelope {
14
14
  * one per pod any more — the one server-side use left is the member-login redirect, which needs a
15
15
  * visitor token to build Wix's hosted-login URL once per login. */
16
16
  export declare function mintAnonymousVisitor(clientId: string, fetchImpl?: typeof fetch): Promise<string>;
17
+ /** A One App visitor signed instance and the time Wix stops honouring it (`validUntil`). */
18
+ export interface OneAppVisitorInstance {
19
+ instance: string;
20
+ expiresAt: number;
21
+ }
22
+ /**
23
+ * The site's One App VISITOR signed instance — the anonymous identity a Branded One App visitor
24
+ * uses (`WixConsumerAuthProvider({ visitorSource: "one-app", metaSiteId })`). Needs no credential
25
+ * and no OAuth client on the site. Sent to wixapis.com as a bare `Authorization` value: `Bearer
26
+ * <instance>` is a 400. Each mint is a NEW visitor, so callers keep it until `expiresAt`.
27
+ * Server-side only for the browser: the endpoint sends no CORS headers.
28
+ */
29
+ export declare function mintOneAppVisitor(msid: string, fetchImpl?: typeof fetch, timeoutMs?: number): Promise<OneAppVisitorInstance>;
30
+ /** The MetaSite an auth provider binds through the One App visitor identity
31
+ * (`WixConsumerAuthProvider({ visitorSource: "one-app", metaSiteId })`), or null. */
32
+ export declare function oneAppMetaSiteIdOf(auth: {
33
+ providerId?: unknown;
34
+ config?: unknown;
35
+ } | null | undefined): string | null;
36
+ /** The same, read off a published app-config's `authConfig`. */
37
+ export declare function oneAppVisitorMsidOf(appConfigJson: string): string | null;
17
38
  /**
18
39
  * Proxy one REST call to wixapis.com with the given token. `path` must be
19
40
  * origin-relative — an absolute URL is the caller trying to use the bridge as an
@@ -3545,6 +3545,25 @@ export interface SearchableConfig {
3545
3545
  onCancel?: Action;
3546
3546
  /** `$service:` bool: the search is busy. */
3547
3547
  loadingPath?: string;
3548
+ /** Static suggestions. On the wire for a later release: no shell draws them yet (RFC 0010 decision 11). */
3549
+ suggestions?: SearchSuggestion[];
3550
+ /** `$service:` array of `{ id, label, icon? }`. Not drawn yet (decision 11). */
3551
+ suggestionsPath?: string;
3552
+ /** `args.id` (+ `args.label`) of the tapped suggestion; a static suggestion's own `onTap` wins. */
3553
+ onSuggestionTap?: Action;
3554
+ /** Scope bar (`TabItem` reused). */
3555
+ scopes?: TabItem[];
3556
+ /** `$service:` selected scope id. */
3557
+ scopePath?: string;
3558
+ /** `args.selectedId`. */
3559
+ onScopeChange?: Action;
3560
+ }
3561
+ /** RFC 0066 §2 — one static search suggestion (`SearchableConfig.suggestions`). */
3562
+ export interface SearchSuggestion {
3563
+ id: string;
3564
+ label: string;
3565
+ icon?: IconRef;
3566
+ onTap?: Action;
3548
3567
  }
3549
3568
  /** `ScreenDescriptor.hostTitle`. Each value is a literal, a `$t:` key, or a `$service:` path. */
3550
3569
  export interface HostTitle {
@@ -449,6 +449,67 @@ export declare const screenDescriptorSchema: {
449
449
  readonly loadingPath: {
450
450
  readonly type: "string";
451
451
  };
452
+ readonly suggestions: {
453
+ readonly type: "array";
454
+ readonly items: {
455
+ readonly $ref: "#/$defs/searchSuggestion";
456
+ };
457
+ };
458
+ readonly suggestionsPath: {
459
+ readonly type: "string";
460
+ };
461
+ readonly onSuggestionTap: {
462
+ readonly $ref: "#/$defs/action";
463
+ };
464
+ readonly scopes: {
465
+ readonly type: "array";
466
+ readonly items: {
467
+ readonly $ref: "#/$defs/searchScope";
468
+ };
469
+ };
470
+ readonly scopePath: {
471
+ readonly type: "string";
472
+ };
473
+ readonly onScopeChange: {
474
+ readonly $ref: "#/$defs/action";
475
+ };
476
+ };
477
+ };
478
+ readonly searchSuggestion: {
479
+ readonly type: "object";
480
+ readonly additionalProperties: false;
481
+ readonly required: readonly ["id", "label"];
482
+ readonly properties: {
483
+ readonly id: {
484
+ readonly type: "string";
485
+ readonly minLength: 1;
486
+ };
487
+ readonly label: {
488
+ readonly type: "string";
489
+ };
490
+ readonly icon: {
491
+ readonly type: "string";
492
+ };
493
+ readonly onTap: {
494
+ readonly $ref: "#/$defs/action";
495
+ };
496
+ };
497
+ };
498
+ readonly searchScope: {
499
+ readonly type: "object";
500
+ readonly additionalProperties: false;
501
+ readonly required: readonly ["id", "label"];
502
+ readonly properties: {
503
+ readonly id: {
504
+ readonly type: "string";
505
+ readonly minLength: 1;
506
+ };
507
+ readonly label: {
508
+ readonly type: "string";
509
+ };
510
+ readonly badge: {
511
+ readonly type: "string";
512
+ };
452
513
  };
453
514
  };
454
515
  readonly toolbarItem: {
@@ -1787,6 +1848,67 @@ export declare const widgetSnapshotSchema: {
1787
1848
  readonly loadingPath: {
1788
1849
  readonly type: "string";
1789
1850
  };
1851
+ readonly suggestions: {
1852
+ readonly type: "array";
1853
+ readonly items: {
1854
+ readonly $ref: "#/$defs/searchSuggestion";
1855
+ };
1856
+ };
1857
+ readonly suggestionsPath: {
1858
+ readonly type: "string";
1859
+ };
1860
+ readonly onSuggestionTap: {
1861
+ readonly $ref: "#/$defs/action";
1862
+ };
1863
+ readonly scopes: {
1864
+ readonly type: "array";
1865
+ readonly items: {
1866
+ readonly $ref: "#/$defs/searchScope";
1867
+ };
1868
+ };
1869
+ readonly scopePath: {
1870
+ readonly type: "string";
1871
+ };
1872
+ readonly onScopeChange: {
1873
+ readonly $ref: "#/$defs/action";
1874
+ };
1875
+ };
1876
+ };
1877
+ readonly searchSuggestion: {
1878
+ readonly type: "object";
1879
+ readonly additionalProperties: false;
1880
+ readonly required: readonly ["id", "label"];
1881
+ readonly properties: {
1882
+ readonly id: {
1883
+ readonly type: "string";
1884
+ readonly minLength: 1;
1885
+ };
1886
+ readonly label: {
1887
+ readonly type: "string";
1888
+ };
1889
+ readonly icon: {
1890
+ readonly type: "string";
1891
+ };
1892
+ readonly onTap: {
1893
+ readonly $ref: "#/$defs/action";
1894
+ };
1895
+ };
1896
+ };
1897
+ readonly searchScope: {
1898
+ readonly type: "object";
1899
+ readonly additionalProperties: false;
1900
+ readonly required: readonly ["id", "label"];
1901
+ readonly properties: {
1902
+ readonly id: {
1903
+ readonly type: "string";
1904
+ readonly minLength: 1;
1905
+ };
1906
+ readonly label: {
1907
+ readonly type: "string";
1908
+ };
1909
+ readonly badge: {
1910
+ readonly type: "string";
1911
+ };
1790
1912
  };
1791
1913
  };
1792
1914
  readonly toolbarItem: {
@@ -42,8 +42,18 @@ export interface MemberCaptchaKey {
42
42
  siteKeyId: string;
43
43
  }
44
44
  export interface WixConsumerAuthConfig {
45
- /** Per-site Wix Headless OAuth client id. */
46
- clientId: string;
45
+ /** Per-site Wix Headless OAuth client id. Required unless `visitorSource` is `"one-app"`;
46
+ * there it is optional and only enables member sign-in. */
47
+ clientId?: string;
48
+ /** Where the anonymous visitor credential comes from. `"oauth"` (default) mints
49
+ * `POST /oauth2/token {clientId, grantType:"anonymous"}` and needs a Headless OAuth client on
50
+ * the site. `"one-app"` mints the site's One App visitor signed instance
51
+ * (`GET apps.wix.com/_api/one-app-session-web/v3/businesses/<metaSiteId>/signed-instance
52
+ * ?signed_instance_type=Visitor`), the same identity a Branded One App visitor uses, so a
53
+ * migrated One App binds to its site WITHOUT creating anything on it. Requires `metaSiteId`. */
54
+ visitorSource?: "oauth" | "one-app";
55
+ /** The site's MetaSite ID. Required when `visitorSource` is `"one-app"`. */
56
+ metaSiteId?: string;
47
57
  /** Wix site binding for native CAPTCHA configuration. */
48
58
  siteId?: string;
49
59
  /** Public identifiers only. Never supply the server app secret here. */
@@ -53,8 +63,8 @@ export interface WixConsumerAuthConfig {
53
63
  };
54
64
  /** Site root URL — e.g. "https://example.wix.com/cafe". */
55
65
  siteUrl: string;
56
- /** Custom URL scheme for the member-login redirect. */
57
- redirectUri: string;
66
+ /** Custom URL scheme for the member-login redirect. Required whenever `clientId` is set. */
67
+ redirectUri?: string;
58
68
  /**
59
69
  * Where the password-reset email's link lands. Must be an http(s) WEB url:
60
70
  * IAM recovery shortens it into the mail body, so `redirectUri` — an app scheme
@@ -8659,7 +8659,7 @@ var screenDescriptorSchema = {
8659
8659
  visibilityPath: { type: "string" }
8660
8660
  }
8661
8661
  },
8662
- // RFC 0010 "Native top-bar search" (SearchableConfig fields 1–5, 12–15). `placement` stays a free string.
8662
+ // RFC 0010 "Native top-bar search" (SearchableConfig fields 1–15). `placement` stays a free string.
8663
8663
  searchableConfig: {
8664
8664
  type: "object",
8665
8665
  additionalProperties: false,
@@ -8672,7 +8672,35 @@ var screenDescriptorSchema = {
8672
8672
  placement: { type: "string" },
8673
8673
  focusPath: { type: "string" },
8674
8674
  onCancel: { $ref: "#/$defs/action" },
8675
- loadingPath: { type: "string" }
8675
+ loadingPath: { type: "string" },
8676
+ suggestions: { type: "array", items: { $ref: "#/$defs/searchSuggestion" } },
8677
+ suggestionsPath: { type: "string" },
8678
+ onSuggestionTap: { $ref: "#/$defs/action" },
8679
+ scopes: { type: "array", items: { $ref: "#/$defs/searchScope" } },
8680
+ scopePath: { type: "string" },
8681
+ onScopeChange: { $ref: "#/$defs/action" }
8682
+ }
8683
+ },
8684
+ searchSuggestion: {
8685
+ type: "object",
8686
+ additionalProperties: false,
8687
+ required: ["id", "label"],
8688
+ properties: {
8689
+ id: { type: "string", minLength: 1 },
8690
+ label: { type: "string" },
8691
+ icon: { type: "string" },
8692
+ onTap: { $ref: "#/$defs/action" }
8693
+ }
8694
+ },
8695
+ // A scope is a `TabItem`.
8696
+ searchScope: {
8697
+ type: "object",
8698
+ additionalProperties: false,
8699
+ required: ["id", "label"],
8700
+ properties: {
8701
+ id: { type: "string", minLength: 1 },
8702
+ label: { type: "string" },
8703
+ badge: { type: "string" }
8676
8704
  }
8677
8705
  },
8678
8706
  toolbarItem: {
@@ -7231,7 +7231,7 @@ var screenDescriptorSchema = {
7231
7231
  visibilityPath: { type: "string" }
7232
7232
  }
7233
7233
  },
7234
- // RFC 0010 "Native top-bar search" (SearchableConfig fields 1–5, 12–15). `placement` stays a free string.
7234
+ // RFC 0010 "Native top-bar search" (SearchableConfig fields 1–15). `placement` stays a free string.
7235
7235
  searchableConfig: {
7236
7236
  type: "object",
7237
7237
  additionalProperties: false,
@@ -7244,7 +7244,35 @@ var screenDescriptorSchema = {
7244
7244
  placement: { type: "string" },
7245
7245
  focusPath: { type: "string" },
7246
7246
  onCancel: { $ref: "#/$defs/action" },
7247
- loadingPath: { type: "string" }
7247
+ loadingPath: { type: "string" },
7248
+ suggestions: { type: "array", items: { $ref: "#/$defs/searchSuggestion" } },
7249
+ suggestionsPath: { type: "string" },
7250
+ onSuggestionTap: { $ref: "#/$defs/action" },
7251
+ scopes: { type: "array", items: { $ref: "#/$defs/searchScope" } },
7252
+ scopePath: { type: "string" },
7253
+ onScopeChange: { $ref: "#/$defs/action" }
7254
+ }
7255
+ },
7256
+ searchSuggestion: {
7257
+ type: "object",
7258
+ additionalProperties: false,
7259
+ required: ["id", "label"],
7260
+ properties: {
7261
+ id: { type: "string", minLength: 1 },
7262
+ label: { type: "string" },
7263
+ icon: { type: "string" },
7264
+ onTap: { $ref: "#/$defs/action" }
7265
+ }
7266
+ },
7267
+ // A scope is a `TabItem`.
7268
+ searchScope: {
7269
+ type: "object",
7270
+ additionalProperties: false,
7271
+ required: ["id", "label"],
7272
+ properties: {
7273
+ id: { type: "string", minLength: 1 },
7274
+ label: { type: "string" },
7275
+ badge: { type: "string" }
7248
7276
  }
7249
7277
  },
7250
7278
  toolbarItem: {
@@ -1194,14 +1194,22 @@ function isWebUrl(value) {
1194
1194
  return false;
1195
1195
  }
1196
1196
  }
1197
+ var META_SITE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1197
1198
  function WixConsumerAuthProvider(config) {
1198
- if (!config.clientId) {
1199
+ const oneApp = config.visitorSource === "one-app";
1200
+ if (config.visitorSource !== void 0 && config.visitorSource !== "oauth" && !oneApp) {
1201
+ throw new Error('WixConsumerAuthProvider: visitorSource must be "oauth" or "one-app".');
1202
+ }
1203
+ if (oneApp && !META_SITE_ID.test(config.metaSiteId ?? "")) {
1204
+ throw new Error(`WixConsumerAuthProvider: visitorSource "one-app" requires metaSiteId (the site's MetaSite ID).`);
1205
+ }
1206
+ if (!oneApp && !config.clientId) {
1199
1207
  throw new Error("WixConsumerAuthProvider: clientId is required.");
1200
1208
  }
1201
1209
  if (!config.siteUrl) {
1202
1210
  throw new Error("WixConsumerAuthProvider: siteUrl is required.");
1203
1211
  }
1204
- if (!config.redirectUri) {
1212
+ if (config.clientId && !config.redirectUri) {
1205
1213
  throw new Error("WixConsumerAuthProvider: redirectUri is required.");
1206
1214
  }
1207
1215
  if (config.passwordResetUrl && !isWebUrl(config.passwordResetUrl)) {
@@ -1209,16 +1217,17 @@ function WixConsumerAuthProvider(config) {
1209
1217
  `WixConsumerAuthProvider: passwordResetUrl must be an http(s) web URL with a host (got "${config.passwordResetUrl}") \u2014 the reset email's link cannot be an app scheme.`
1210
1218
  );
1211
1219
  }
1212
- if (!config.siteId) {
1220
+ if (!config.siteId && config.clientId) {
1213
1221
  const siteId = pairedEnvSiteId(config.clientId);
1214
1222
  if (siteId) config = { ...config, siteId };
1215
1223
  }
1216
1224
  return {
1217
1225
  providerId: "wix-consumer",
1218
1226
  config: {
1219
- clientId: config.clientId,
1227
+ ...config.clientId ? { clientId: config.clientId } : {},
1228
+ ...oneApp ? { visitorSource: "one-app", metaSiteId: config.metaSiteId.toLowerCase() } : {},
1220
1229
  siteUrl: config.siteUrl,
1221
- redirectUri: config.redirectUri,
1230
+ ...config.redirectUri ? { redirectUri: config.redirectUri } : {},
1222
1231
  bootAsVisitor: config.bootAsVisitor ?? true,
1223
1232
  ...config.passwordResetUrl ? { passwordResetUrl: config.passwordResetUrl } : {},
1224
1233
  preserveVisitorOnSignOut: config.preserveVisitorOnSignOut ?? true,