npm package diff

Package: @forge/manifest

Versions: 7.10.0-next.3 - 7.10.0-next.4

File: package/out/validators/providers-validator.js

Index: package/out/validators/providers-validator.js
===================================================================
--- package/out/validators/providers-validator.js
+++ package/out/validators/providers-validator.js
@@ -2,17 +2,18 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.ProvidersValidator = void 0;
 const utils_1 = require("../utils");
 const text_1 = require("../text");
+const remote_regions_validator_1 = require("./remote-regions-validator");
 class ProvidersValidator {
     async validate(manifest) {
         if (!manifest || !manifest.typedContent || !manifest.typedContent.providers) {
             return {
                 success: true,
                 manifestObject: manifest
             };
         }
-        const validationErrors = [];
+        let validationErrors = [];
         const auth = manifest.typedContent.providers.auth;
         const remotes = manifest.typedContent.remotes;
         const permissions = manifest.typedContent.permissions;
         auth?.forEach((provider) => {
@@ -59,8 +60,11 @@
             if (message) {
                 validationErrors.push(message);
             }
         });
+        auth?.forEach((provider) => {
+            validationErrors = [...validationErrors, ...this.isValidAuthRemote(provider, manifest, remotes)];
+        });
         return {
             success: validationErrors.length === 0,
             errors: validationErrors
         };
@@ -89,6 +93,33 @@
                 };
             }
         }
     }
+    isValidAuthRemote(provider, manifest, remotes) {
+        const validationErrors = [];
+        const referencedRemotes = [...(provider.remotes || [])];
+        if ('actions' in provider) {
+            referencedRemotes.push(provider.actions.retrieveProfile.remote);
+            referencedRemotes.push(provider.actions.exchange.remote);
+            referencedRemotes.push(provider.actions.authorization.remote);
+            provider.actions.revokeToken && referencedRemotes.push(provider.actions.revokeToken.remote);
+            provider.actions.refreshToken && referencedRemotes.push(provider.actions.refreshToken.remote);
+        }
+        referencedRemotes?.forEach((providerRemoteKey) => {
+            const remote = remotes?.find((remote) => remote.key === providerRemoteKey);
+            if (!remote) {
+                return;
+            }
+            const remoteRegions = (0, remote_regions_validator_1.getRegionsFromBaseUrl)(remote.baseUrl);
+            if (remoteRegions.size != 1) {
+                validationErrors.push({
+                    message: text_1.errors.providers.hasRegionUrls(provider.key, remote.key),
+                    reference: text_1.References.Providers,
+                    level: 'error',
+                    ...(0, utils_1.findPosition)(providerRemoteKey, manifest.yamlContentByLine)
+                });
+            }
+        });
+        return validationErrors;
+    }
 }
 exports.ProvidersValidator = ProvidersValidator;