@poly-x/react 0.1.0-alpha.17 → 0.1.0-alpha.18

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.
package/dist/index.cjs CHANGED
@@ -578,6 +578,23 @@ async function capturePreciseLocation(consented, opts = {}) {
578
578
  return (await attemptCapture(geo, false, lowAccuracyMs)).result;
579
579
  }
580
580
  //#endregion
581
+ //#region src/device-context.ts
582
+ /** Capture the browser's timezone + screen resolution. Never throws; omits anything unavailable. */
583
+ function captureDeviceContext() {
584
+ const context = {};
585
+ try {
586
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
587
+ if (typeof timezone === "string" && timezone) context.timezone = timezone;
588
+ } catch {}
589
+ try {
590
+ if (typeof window !== "undefined" && window.screen) {
591
+ const { width, height } = window.screen;
592
+ if (Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) context.screenResolution = `${Math.round(width)}x${Math.round(height)}`;
593
+ }
594
+ } catch {}
595
+ return context;
596
+ }
597
+ //#endregion
581
598
  //#region src/components/sign-in.tsx
582
599
  const DEFAULT_LABELS$3 = {
583
600
  heading: "Sign in",
@@ -738,6 +755,7 @@ function SignIn(props) {
738
755
  setError(null);
739
756
  try {
740
757
  const geo = props.captureLocation ? await capturePreciseLocation(true) : void 0;
758
+ const deviceContext = captureDeviceContext();
741
759
  const body = await (await fetch(action, {
742
760
  method: "POST",
743
761
  headers: { "content-type": "application/json" },
@@ -747,6 +765,7 @@ function SignIn(props) {
747
765
  organizationCode: props.organizationCode,
748
766
  tenantId: options.tenantId,
749
767
  ...geo ? { geo } : {},
768
+ ...Object.keys(deviceContext).length ? { deviceContext } : {},
750
769
  ...options.passwords
751
770
  })
752
771
  })).json().catch(() => ({}));
package/dist/index.mjs CHANGED
@@ -577,6 +577,23 @@ async function capturePreciseLocation(consented, opts = {}) {
577
577
  return (await attemptCapture(geo, false, lowAccuracyMs)).result;
578
578
  }
579
579
  //#endregion
580
+ //#region src/device-context.ts
581
+ /** Capture the browser's timezone + screen resolution. Never throws; omits anything unavailable. */
582
+ function captureDeviceContext() {
583
+ const context = {};
584
+ try {
585
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
586
+ if (typeof timezone === "string" && timezone) context.timezone = timezone;
587
+ } catch {}
588
+ try {
589
+ if (typeof window !== "undefined" && window.screen) {
590
+ const { width, height } = window.screen;
591
+ if (Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) context.screenResolution = `${Math.round(width)}x${Math.round(height)}`;
592
+ }
593
+ } catch {}
594
+ return context;
595
+ }
596
+ //#endregion
580
597
  //#region src/components/sign-in.tsx
581
598
  const DEFAULT_LABELS$3 = {
582
599
  heading: "Sign in",
@@ -737,6 +754,7 @@ function SignIn(props) {
737
754
  setError(null);
738
755
  try {
739
756
  const geo = props.captureLocation ? await capturePreciseLocation(true) : void 0;
757
+ const deviceContext = captureDeviceContext();
740
758
  const body = await (await fetch(action, {
741
759
  method: "POST",
742
760
  headers: { "content-type": "application/json" },
@@ -746,6 +764,7 @@ function SignIn(props) {
746
764
  organizationCode: props.organizationCode,
747
765
  tenantId: options.tenantId,
748
766
  ...geo ? { geo } : {},
767
+ ...Object.keys(deviceContext).length ? { deviceContext } : {},
749
768
  ...options.passwords
750
769
  })
751
770
  })).json().catch(() => ({}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poly-x/react",
3
- "version": "0.1.0-alpha.17",
3
+ "version": "0.1.0-alpha.18",
4
4
  "description": "PolyX SDK for React SPAs - provider, hooks, drop-in auth UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "module": "./dist/index.mjs",
28
28
  "types": "./dist/index.d.cts",
29
29
  "dependencies": {
30
- "@poly-x/core": "0.1.0-alpha.17"
30
+ "@poly-x/core": "0.1.0-alpha.18"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18",