@bigbinary/neeto-playwright-commons 4.11.16 → 4.12.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.
Files changed (3) hide show
  1. package/index.d.ts +8 -4
  2. package/index.js +36 -19
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -9691,7 +9691,9 @@ declare const getListCount: ({
9691
9691
  declare const getGlobalUserProps: (page: Page) => Promise<Record<string, string>>;
9692
9692
  /**
9693
9693
  *
9694
- * Fetches the current text content from the system clipboard in the browser context. It first attempts to use the native clipboard API (navigator.clipboard.readText()). If that fails, it falls back to creating a temporary textarea and using keyboard paste to retrieve the clipboard content.
9694
+ * Reads the current text from the system clipboard. Every browser, including WebKit, tries navigator.clipboard.readText() first. When that API is missing or returns null or undefined, the helper inserts a temporary textarea, focuses it, and pastes with ControlOrMeta+v.
9695
+ *
9696
+ * Call grantClipboardPermissions on the page's browser context before reading, so the native Clipboard API is allowed to run.
9695
9697
  *
9696
9698
  * page: The Playwright Page object representing the current browser page.
9697
9699
  *
@@ -9703,13 +9705,13 @@ declare const getGlobalUserProps: (page: Page) => Promise<Record<string, string>
9703
9705
  declare const getClipboardContent: (page: Page) => Promise<string>;
9704
9706
  /**
9705
9707
  *
9706
- * Grants clipboard read and write permissions to the browser context. It takes the following parameters:
9708
+ * Grants the clipboard permissions the current browser accepts. Chromium and Firefox receive clipboard-read and clipboard-write. WebKit receives clipboard-read, because that is the clipboard permission WebKit accepts.
9707
9709
  *
9708
9710
  * context: The Playwright BrowserContext object to grant permissions to.
9709
9711
  *
9710
9712
  * @example
9711
9713
  *
9712
- * await grantClipboardPermissions(context);
9714
+ * await grantClipboardPermissions(context);
9713
9715
  * @endexample
9714
9716
  */
9715
9717
  declare const grantClipboardPermissions: (context: BrowserContext) => Promise<void>;
@@ -10786,7 +10788,8 @@ interface ReplyInboundEmailParams extends InboundEmailParams {
10786
10788
  replyToMessageId: string;
10787
10789
  }
10788
10790
  /**
10789
- * Injects inbound emails via the Rails ActionMailbox conductor (development only).
10791
+ * Injects inbound emails via the Rails ActionMailbox conductor in development
10792
+ * and via the signed Mailgun ingress elsewhere.
10790
10793
  */
10791
10794
  declare class InboundEmailApis {
10792
10795
  private neetoPlaywrightUtilities;
@@ -10824,6 +10827,7 @@ declare class InboundEmailApis {
10824
10827
  */
10825
10828
  reply: (emailParams: ReplyInboundEmailParams) => Promise<playwright_core.APIResponse<any> | undefined>;
10826
10829
  private deliverSource;
10830
+ private deliverViaMailgunIngress;
10827
10831
  }
10828
10832
  export { ACTIONS, ADMIN_PANEL_SELECTORS, ALL_RESOURCES, ANALYTICS_RESOURCES, API_KEYS_SELECTORS, API_ROUTES, APP_RESOURCES, AUDIT_LOGS_SELECTORS, ApiKeysApi, ApiKeysPage, ApiKeysPageV2, AuditLogsPage, BASE_URL, CALENDAR_LABELS, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE, CERTIFICATE_LIMIT_EXCEEDED_REGEXP, CERTIFICATE_PROVISION_FAILED_MESSAGE, CERTIFICATE_PROVISION_FAILED_REGEXP, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, CHAT_WIDGET_TEXTS, COLOR, COMMON_SELECTORS, COMMON_TEXTS, COMMUNITY_TEXTS, CREDENTIALS, CURRENT_TIME_RANGES, CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX, CUSTOM_DOMAIN_SELECTORS, CUSTOM_DOMAIN_SUFFIX, ColorPickerUtils, CustomCommands, CustomCommandsV2, CustomDomainApi, CustomDomainPage, DATE_FORMATS, DATE_PICKER_SELECTORS, DATE_RANGES, DATE_TEXTS, DEFAULT_TIMEZONE_ID, DEFAULT_WEBHOOKS_RESPONSE_TEXT, DESCRIPTION_EDITOR_TEXTS, EDITOR_VERIFY_TEXT_COLOR, EMBED_SELECTORS, EMOJI_LABEL, EMPTY_STORAGE_STATE, ENGAGE_TEXTS, ENVIRONMENT, EXAMPLE_URL, EXPANDED_FONT_SIZE, EXPORT_FILE_TYPES, EditorPage, EmailDeliveryUtils, EmbedBase, FILE_FORMATS, FONTS_RESOURCES, FONT_SIZE_SELECTORS, FROM_EMAIL_ENV_KEYS, GLOBAL_TRANSLATIONS_PATTERN, GOOGLE_ANALYTICS_SELECTORS, GOOGLE_CALENDAR_DATE_FORMAT, GOOGLE_LOGIN_SELECTORS, GOOGLE_LOGIN_TEXTS, GOOGLE_SHEETS_SELECTORS, GooglePage, HELP_CENTER_ROUTES, HELP_CENTER_SELECTORS, HelpAndProfilePage, HelpAndProfilePageV2, INTEGRATIONS_TEXTS, INTEGRATION_SELECTORS, IPRestrictionsPage, IP_RESTRICTIONS_SELECTORS, IS_CI, IS_DEV_CI, IS_DEV_ENV, IS_MAILPIT_ENABLED, IS_PLAYWRIGHT_RUN, IS_REVIEW_ENV, IS_SHADCN_UI, IS_STAGING_ENV, IS_WEBKIT, ImageUploader, InboundEmailApis, IntegrationBase, IpRestrictionsApi, KEYBOARD_SHORTCUTS_SELECTORS, KEYBOARD_SHORTCUT_TEST_CASES, LIST_MODIFIER_SELECTORS, LIST_MODIFIER_TAGS, LOGIN_DEFAULTS, LOGIN_SELECTORS, LOGIN_STRATEGIES, LOGIN_TIMEOUT, MAILPIT_BASE_URL, MAILPIT_DOMAIN_NAME, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MEMBER_TEXTS, MERGE_TAGS_SELECTORS, MICROSOFT_LOGIN_SELECTORS, MICROSOFT_LOGIN_TEXTS, MailerUtils, MailpitApi, Member, MemberApis, MicrosoftPage, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, NEETO_IMAGE_UPLOADER_SELECTORS, NEETO_ROUTES, NEETO_SEO_SELECTORS, NEETO_TEXT_MODIFIER_SELECTORS, NeetoAuthServer, NeetoChatWidget, NeetoEmailDeliveryApi, NeetoTowerApi, ONBOARDING_SELECTORS, ORGANIZATION_TEXTS, OTP_EMAIL_PATTERN, OTP_FETCH_TIMEOUT, OrganizationPage, PAST_TIME_RANGES, PHONE_NUMBER_FORMATS, PLURAL, PRODUCT_ROLES_ROUTE_MAP, PROFILE_LINKS, PROFILE_SECTION_SELECTORS, PROJECT_NAMES, PROJECT_TRANSLATIONS_PATH, REVIEW_APP_CUSTOM_DOMAIN_SUFFIX, ROLES_SELECTORS, ROUTES, RailsEmailApiClient, RailsEmailUtils, RoleApis, RolesPage, RolesPageV2, SIGNUP_SELECTORS, SINGULAR, SLACK_DATA_QA_SELECTORS, SLACK_DEFAULT_CHANNEL, SLACK_SELECTORS, SLACK_WEB_TEXTS, STATUS_TEXTS, STORAGE_STATE, SecurityApi, SidebarSection, SlackApi, SlackPage, SmsApi, SmsUtils, TABLE_SELECTORS, TAB_SELECTORS, TAGS_SELECTORS, TEAM_MEMBER_TEXTS, TEXT_MODIFIER_ROLES, TEXT_MODIFIER_SELECTORS, TEXT_MODIFIER_TAGS, THANK_YOU_SELECTORS, THEMES_SELECTORS, THEMES_TEXTS, THIRD_PARTY_RESOURCES, THIRD_PARTY_ROUTES, TIME_RANGES, TOASTR_MESSAGES, TWILIO_SELECTORS, TagsApi, TagsPage, TeamMembers, TeamMembersV2, ThankYouApi, ThankYouPage, TwilioApi, USER_AGENTS, WEBHOOK_SELECTORS, WebhookSiteApi, WebhooksPage, ZAPIER_LIMIT_EXHAUSTED_MESSAGE, ZAPIER_SELECTORS, ZAPIER_TEST_EMAIL, ZAPIER_TEST_EMAIL_V2, ZAPIER_WEB_TEXTS, ZapierPage, authenticateUser, baseURLGenerator, basicHTMLContent, clearCredentials, commands, cpuThrottlingUsingCDP, createOrganizationViaApi, createOrganizationViaRake, currencyUtils, dataQa, decodeQRCodeFromFile, definePlaywrightConfig, exampleEmail, executeWithThrottledResources, extractSubdomainFromError, filterUtils, fixedMenuSelector, generatePhoneNumber, generatePhoneNumberDetails, generateRandomBypassEmail, generateRandomFile, generateStagingData, getByDataQA, getClipboardContent, getDirname, getFormattedPhoneNumber, getFullUrl, getGithubToken, getGlobalUserProps, getGlobalUserState, getImagePathAndName, getIsoCodeFromPhoneCode, getListCount, globalShortcuts, grantClipboardPermissions, hexToRGB, hexToRGBA, i18nFixture, imageRegex, initializeCredentials, initializeReviewAppCredentials, initializeTestData, initializeTotp, isGithubIssueOpen, isStagingOrganizationExpired, joinHyphenCase, joinString, login, loginToReviewApp, mailpitDomainName, minutesAgo, networkConditions, networkThrottlingUsingCDP, optionSelector, readFileAsBrowserFile, readFileSyncIfExists, removeCredentialFile, reviewAppBaseURL, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, _default as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };
10829
10833
  export type { BaseThemeStyle, BaseThemeStyleType, ColumnMenuAction, CountryProps, CustomFixture, EmailDeliveryConnectParams, EmailDeliveryProvider, EmailDeliveryVerifiedEmail, EmailDeliveryVerifyEmailParams, EmailDeliveryVerifyEmailResponse, EmailMatchCriteria, InboundEmailParams, IntroPageThemeStyle, IntroPageThemeStyleType, LoginStrategy, OAuthEmailDeliveryProvider, ProjectName, ReplyInboundEmailParams, Sms, SmsFilters, SmsProvider, SmsSearchCriteria, SmsSearchParams, ThemeCategory, ValueOf, WaitForSmsOptions };
package/index.js CHANGED
@@ -23,7 +23,7 @@ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
23
23
  import timezone from 'dayjs/plugin/timezone.js';
24
24
  import utc from 'dayjs/plugin/utc.js';
25
25
  import https from 'https';
26
- import { createPrivateKey } from 'node:crypto';
26
+ import { createPrivateKey, randomBytes, createHmac } from 'node:crypto';
27
27
  import { countries } from 'countries-list';
28
28
  import { parsePhoneNumberWithError } from 'libphonenumber-js';
29
29
  import * as http from 'http';
@@ -2359,24 +2359,21 @@ const createTextareaAndEvaluateCopiedText = async (page) => {
2359
2359
  }
2360
2360
  };
2361
2361
  const getClipboardContent = async (page) => {
2362
- const isWebkit = page.context().browser()?.browserType().name() === "webkit";
2363
- if (!isWebkit) {
2364
- // Attempt 1: Native Clipboard API
2365
- const clipboardText = await page.evaluate(async () => {
2366
- if (!navigator.clipboard?.readText)
2367
- return null;
2368
- return await navigator.clipboard.readText();
2369
- });
2370
- if (isNotNil(clipboardText))
2371
- return clipboardText;
2372
- }
2362
+ // Attempt 1: Native Clipboard API
2363
+ const clipboardText = await page.evaluate(async () => {
2364
+ if (!navigator.clipboard?.readText)
2365
+ return null;
2366
+ return await navigator.clipboard.readText();
2367
+ });
2368
+ if (isNotNil(clipboardText))
2369
+ return clipboardText;
2373
2370
  // Attempt 2: Keyboard paste fallback
2374
2371
  return createTextareaAndEvaluateCopiedText(page);
2375
2372
  };
2376
2373
  const grantClipboardPermissions = async (context) => {
2377
- if (context.browser()?.browserType().name() === "webkit")
2378
- return;
2379
- await context.grantPermissions(["clipboard-read", "clipboard-write"]);
2374
+ const isWebkit = context.browser()?.browserType().name() === "webkit";
2375
+ // WebKit supports "clipboard-read" but rejects "clipboard-write".
2376
+ await context.grantPermissions(isWebkit ? ["clipboard-read"] : ["clipboard-read", "clipboard-write"]);
2380
2377
  };
2381
2378
  const getFullUrl = (path) => shouldSkipCustomDomainSetup() ? path : `${process.env.BASE_URL}${path}`;
2382
2379
  const globalShortcuts = (t) => [
@@ -13173,10 +13170,12 @@ const definePlaywrightConfig = (overrides) => {
13173
13170
  };
13174
13171
 
13175
13172
  const INBOUND_EMAIL_SOURCES_URL = "/rails/conductor/action_mailbox/inbound_emails/sources";
13173
+ const MAILGUN_INGRESS_URL = "/rails/action_mailbox/mailgun/inbound_emails/mime";
13176
13174
  const normalizeMessageId = (id) => id.replace(/^<|>$/g, "");
13177
13175
  const sanitizeHeaderValue = (value) => value.replace(/[\r\n]+/g, " ");
13178
13176
  /**
13179
- * Injects inbound emails via the Rails ActionMailbox conductor (development only).
13177
+ * Injects inbound emails via the Rails ActionMailbox conductor in development
13178
+ * and via the signed Mailgun ingress elsewhere.
13180
13179
  */
13181
13180
  class InboundEmailApis {
13182
13181
  neetoPlaywrightUtilities;
@@ -13233,11 +13232,29 @@ class InboundEmailApis {
13233
13232
  "",
13234
13233
  body,
13235
13234
  ].join("\r\n");
13235
+ return IS_DEV_ENV
13236
+ ? this.neetoPlaywrightUtilities.apiRequest({
13237
+ url: INBOUND_EMAIL_SOURCES_URL,
13238
+ method: "post",
13239
+ body: { source },
13240
+ headers: { accept: "text/html" },
13241
+ })
13242
+ : this.deliverViaMailgunIngress(source);
13243
+ };
13244
+ deliverViaMailgunIngress = (source) => {
13245
+ const signingKey = process.env.MAILGUN_INGRESS_SIGNING_KEY;
13246
+ if (!signingKey) {
13247
+ throw new Error("MAILGUN_INGRESS_SIGNING_KEY is required to inject inbound emails outside development");
13248
+ }
13249
+ const timestamp = Math.floor(Date.now() / 1000).toString();
13250
+ const token = randomBytes(25).toString("hex");
13251
+ const signature = createHmac("sha256", signingKey)
13252
+ .update(`${timestamp}${token}`)
13253
+ .digest("hex");
13236
13254
  return this.neetoPlaywrightUtilities.apiRequest({
13237
- url: INBOUND_EMAIL_SOURCES_URL,
13255
+ url: MAILGUN_INGRESS_URL,
13238
13256
  method: "post",
13239
- body: { source },
13240
- headers: { accept: "text/html" },
13257
+ form: { "body-mime": source, timestamp, token, signature },
13241
13258
  });
13242
13259
  };
13243
13260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-playwright-commons",
3
- "version": "4.11.16",
3
+ "version": "4.12.0",
4
4
  "description": "A package encapsulating common playwright code across neeto projects.",
5
5
  "repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
6
6
  "license": "apache-2.0",