@playcademy/sdk 0.0.7 → 0.0.8

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 +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2596,11 +2596,12 @@ function getReferrerOrigin() {
2596
2596
  function buildAllowedOrigins(explicit) {
2597
2597
  if (Array.isArray(explicit) && explicit.length > 0)
2598
2598
  return explicit;
2599
- const implicit = [getReferrerOrigin()].filter((v) => !!v);
2600
- return Array.from(new Set(implicit));
2599
+ const ref = getReferrerOrigin();
2600
+ return ref ? [ref] : [];
2601
2601
  }
2602
2602
  function isOriginAllowed(origin, allowlist) {
2603
2603
  if (!allowlist || allowlist.length === 0) {
2604
+ console.error("[Playcademy SDK] No allowed origins configured. Consider passing allowedParentOrigins explicitly to init().");
2604
2605
  return false;
2605
2606
  }
2606
2607
  return allowlist.includes(origin);
@@ -2610,11 +2611,18 @@ async function waitForPlaycademyInit(allowedParentOrigins) {
2610
2611
  let contextReceived = false;
2611
2612
  const timeoutDuration = 5000;
2612
2613
  const allowlist = buildAllowedOrigins(allowedParentOrigins);
2614
+ let hasWarnedAboutUntrustedOrigin = false;
2615
+ function warnAboutUntrustedOrigin(origin) {
2616
+ if (hasWarnedAboutUntrustedOrigin)
2617
+ return;
2618
+ hasWarnedAboutUntrustedOrigin = true;
2619
+ console.warn("[Playcademy SDK] Ignoring INIT from untrusted origin:", origin);
2620
+ }
2613
2621
  const handleMessage = (event) => {
2614
2622
  if (event.data?.type !== "PLAYCADEMY_INIT" /* INIT */)
2615
2623
  return;
2616
2624
  if (!isOriginAllowed(event.origin, allowlist)) {
2617
- console.warn("[Playcademy SDK] Ignoring INIT from untrusted origin:", event.origin);
2625
+ warnAboutUntrustedOrigin(event.origin);
2618
2626
  return;
2619
2627
  }
2620
2628
  contextReceived = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {