pxt-core 12.2.13 → 12.2.14

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/built/pxt.js CHANGED
@@ -108276,6 +108276,31 @@ var pxt;
108276
108276
  return false;
108277
108277
  return hasProxy();
108278
108278
  }
108279
+ /**
108280
+ * Organizations that require SAML SSO for OAuth tokens.
108281
+ * User tokens without SAML authorization will fail with 403 errors for these orgs.
108282
+ * We should use the proxy instead when a token is present.
108283
+ */
108284
+ const samlProtectedOrgs = ["microsoft"];
108285
+ /**
108286
+ * Determines if we should use the proxy for a specific repo to avoid SAML SSO issues.
108287
+ * Returns true if the repo is owned by an organization that requires SAML and we have a token.
108288
+ */
108289
+ function shouldUseProxyForRepo(repoPath) {
108290
+ // If no token, let normal proxy logic apply
108291
+ if (!github.token)
108292
+ return shouldUseProxy();
108293
+ const parsed = parseRepoId(repoPath);
108294
+ if (!parsed)
108295
+ return shouldUseProxy();
108296
+ // Check if the repo owner requires SAML SSO
108297
+ const ownerLower = parsed.owner.toLowerCase();
108298
+ const requiresSaml = samlProtectedOrgs.some(org => org === ownerLower);
108299
+ // If SAML is required and we have a token, force proxy to avoid auth issues
108300
+ // Otherwise use normal logic (which will skip proxy if we have a token)
108301
+ return requiresSaml ? true : shouldUseProxy();
108302
+ }
108303
+ github.shouldUseProxyForRepo = shouldUseProxyForRepo;
108279
108304
  const isPrivateRepoCache = {};
108280
108305
  function ghRequestAsync(options) {
108281
108306
  var _a;
@@ -131073,14 +131098,15 @@ ${output}</xml>`;
131073
131098
  if (checkIfWithinFunction(n)) {
131074
131099
  return undefined;
131075
131100
  }
131076
- return pxtc.Util.lf("Return statements can only be used within top-level function declarations");
131077
- function checkIfWithinFunction(n) {
131078
- const enclosing = ts.getEnclosingBlockScopeContainer(n);
131101
+ return pxtc.Util.lf("Return statements can only return values inside user-defined functions");
131102
+ function checkIfWithinFunction(toCheck) {
131103
+ const enclosing = ts.getEnclosingBlockScopeContainer(toCheck);
131079
131104
  if (enclosing) {
131080
131105
  switch (enclosing.kind) {
131081
- case SK.SourceFile:
131082
131106
  case SK.ArrowFunction:
131083
131107
  case SK.FunctionExpression:
131108
+ return !n.expression;
131109
+ case SK.SourceFile:
131084
131110
  return false;
131085
131111
  case SK.FunctionDeclaration:
131086
131112
  return enclosing.parent && enclosing.parent.kind === SK.SourceFile && !checkStatement(enclosing, env, false, true);
@@ -7,3 +7,4 @@ export declare class DuplicateOnDragConnectionChecker extends Blockly.Connection
7
7
  */
8
8
  doSafetyChecks(a: Blockly.Connection | null, b: Blockly.Connection | null): number;
9
9
  }
10
+ export declare function getContainingFunction(block: Blockly.Block): Blockly.Block;
@@ -6632,14 +6632,15 @@ ${output}</xml>`;
6632
6632
  if (checkIfWithinFunction(n)) {
6633
6633
  return undefined;
6634
6634
  }
6635
- return pxtc.Util.lf("Return statements can only be used within top-level function declarations");
6636
- function checkIfWithinFunction(n) {
6637
- const enclosing = ts.getEnclosingBlockScopeContainer(n);
6635
+ return pxtc.Util.lf("Return statements can only return values inside user-defined functions");
6636
+ function checkIfWithinFunction(toCheck) {
6637
+ const enclosing = ts.getEnclosingBlockScopeContainer(toCheck);
6638
6638
  if (enclosing) {
6639
6639
  switch (enclosing.kind) {
6640
- case SK.SourceFile:
6641
6640
  case SK.ArrowFunction:
6642
6641
  case SK.FunctionExpression:
6642
+ return !n.expression;
6643
+ case SK.SourceFile:
6643
6644
  return false;
6644
6645
  case SK.FunctionDeclaration:
6645
6646
  return enclosing.parent && enclosing.parent.kind === SK.SourceFile && !checkStatement(enclosing, env, false, true);
package/built/pxtlib.d.ts CHANGED
@@ -1441,6 +1441,11 @@ declare namespace pxt.github {
1441
1441
  latestVersion?: string;
1442
1442
  }
1443
1443
  let forceProxy: boolean;
1444
+ /**
1445
+ * Determines if we should use the proxy for a specific repo to avoid SAML SSO issues.
1446
+ * Returns true if the repo is owned by an organization that requires SAML and we have a token.
1447
+ */
1448
+ function shouldUseProxyForRepo(repoPath: string): boolean;
1444
1449
  let handleGithubNetworkError: (opts: U.HttpRequestOptions, e: any) => boolean;
1445
1450
  interface CachedPackage {
1446
1451
  files: Map<string>;
package/built/pxtlib.js CHANGED
@@ -10555,6 +10555,31 @@ var pxt;
10555
10555
  return false;
10556
10556
  return hasProxy();
10557
10557
  }
10558
+ /**
10559
+ * Organizations that require SAML SSO for OAuth tokens.
10560
+ * User tokens without SAML authorization will fail with 403 errors for these orgs.
10561
+ * We should use the proxy instead when a token is present.
10562
+ */
10563
+ const samlProtectedOrgs = ["microsoft"];
10564
+ /**
10565
+ * Determines if we should use the proxy for a specific repo to avoid SAML SSO issues.
10566
+ * Returns true if the repo is owned by an organization that requires SAML and we have a token.
10567
+ */
10568
+ function shouldUseProxyForRepo(repoPath) {
10569
+ // If no token, let normal proxy logic apply
10570
+ if (!github.token)
10571
+ return shouldUseProxy();
10572
+ const parsed = parseRepoId(repoPath);
10573
+ if (!parsed)
10574
+ return shouldUseProxy();
10575
+ // Check if the repo owner requires SAML SSO
10576
+ const ownerLower = parsed.owner.toLowerCase();
10577
+ const requiresSaml = samlProtectedOrgs.some(org => org === ownerLower);
10578
+ // If SAML is required and we have a token, force proxy to avoid auth issues
10579
+ // Otherwise use normal logic (which will skip proxy if we have a token)
10580
+ return requiresSaml ? true : shouldUseProxy();
10581
+ }
10582
+ github.shouldUseProxyForRepo = shouldUseProxyForRepo;
10558
10583
  const isPrivateRepoCache = {};
10559
10584
  function ghRequestAsync(options) {
10560
10585
  var _a;