@metaplay/metaplay-auth 1.9.1 → 1.9.2

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/index.ts CHANGED
@@ -13,7 +13,7 @@ import { portalBaseUrl, setPortalBaseUrl } from './src/config.js'
13
13
  import { checkGameServerDeployment, debugGameServer } from './src/deployment.js'
14
14
  import { logger, setLogLevel } from './src/logging.js'
15
15
  import { TargetEnvironment } from './src/targetenvironment.js'
16
- import { isValidFQDN, removeTrailingSlash, fetchHelmChartVersions, resolveBestMatchingVersion, executeHelmCommand, getGameServerHelmRelease } from './src/utils.js'
16
+ import { isValidFQDN, removeTrailingSlash, fetchHelmChartVersions, resolveBestMatchingVersion, checkHelmVersion, executeHelmCommand, getGameServerHelmRelease } from './src/utils.js'
17
17
  import { PACKAGE_VERSION } from './src/version.js'
18
18
 
19
19
  /** Stack API base url override, specified with the '--stack-api' global flag. */
@@ -250,6 +250,10 @@ program
250
250
  setLogLevel(10)
251
251
  }
252
252
 
253
+ // Show a deprecation warning.
254
+ console.warn('Warning: The metaplay-auth CLI is deprecated and will only receive critical updates.')
255
+ console.warn(' Please upgrade to Metaplay SDK release 32 or newer and the new Metaplay CLI (https://github.com/metaplay/cli).')
256
+
253
257
  // Store the portal base URL for accessing globally
254
258
  const overridePortalUrl: string | undefined = opts.portalBaseUrl ?? process.env.AUTHCLI_PORTAL_BASEURL
255
259
  if (overridePortalUrl) {
@@ -783,6 +787,9 @@ program
783
787
  }
784
788
  logger.debug('Resolved Helm chart version: ', resolvedHelmChartVersion)
785
789
 
790
+ // Check that the Helm version is compatible
791
+ await checkHelmVersion()
792
+
786
793
  // Fetch kubeconfig and write it to a temporary file
787
794
  // \todo allow passing a custom kubeconfig file?
788
795
  const kubeconfigPayload = await targetEnv.getKubeConfigWithEmbeddedCredentials()
@@ -866,6 +873,9 @@ program
866
873
  exit(0)
867
874
  }
868
875
 
876
+ // Check that the Helm version is compatible
877
+ await checkHelmVersion()
878
+
869
879
  // Construct Helm invocation.
870
880
  const deploymentName = gameServerHelmRelease.name
871
881
  const helmArgs = ['uninstall', '--wait'] // \note waits for resources to be deleted before returning
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metaplay/metaplay-auth",
3
3
  "description": "Utility CLI for authenticating with the Metaplay Auth and making authenticated calls to infrastructure endpoints.",
4
- "version": "1.9.1",
4
+ "version": "1.9.2",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "homepage": "https://metaplay.io",
package/src/auth.ts CHANGED
@@ -323,7 +323,6 @@ async function extendCurrentSessionWithRefreshToken(
323
323
  * @param code
324
324
  * @returns
325
325
  */
326
-
327
326
  async function getTokensWithAuthorizationCode(
328
327
  state: string,
329
328
  redirectUri: string,
package/src/utils.ts CHANGED
@@ -220,6 +220,58 @@ export function resolveBestMatchingVersion(versions: string[], range: semver.Ran
220
220
  return sortedVersions[0]
221
221
  }
222
222
 
223
+ /**
224
+ * Check that the installed Helm version is compatible with the required version range.
225
+ * Validates that Helm version is >= 3.18.0 and < 3.18.5.
226
+ *
227
+ * Version 3.18.5 (and recent other patch versions) tightened up the Helm chart validation logic
228
+ * and we can't retroactively fix the charts. The path forward is to upgrade to more recent Metaplay
229
+ * SDK versions and switch to the new CLI (https://github.com/metaplay/cli).
230
+ *
231
+ * @throws Error if Helm is not installed, version cannot be determined, or version is incompatible
232
+ */
233
+ export async function checkHelmVersion(): Promise<void> {
234
+ try {
235
+ // Execute 'helm version' command to get version information
236
+ const result = await executeCommand('helm', ['version', '--short'])
237
+
238
+ if (result.exitCode !== 0) {
239
+ throw new Error(`Helm version command failed with exit code ${result.exitCode}: ${result.stderr.join('')}`)
240
+ }
241
+
242
+ // Parse version from output (format: "v3.18.0+g123abc")
243
+ const versionOutput = result.stdout.join('').trim()
244
+ const versionRegex = /v(\d+\.\d+\.\d+)/
245
+ const versionMatch = versionRegex.exec(versionOutput)
246
+
247
+ if (!versionMatch) {
248
+ throw new Error(`Could not parse Helm version from output: ${versionOutput}`)
249
+ }
250
+
251
+ const helmVersion = versionMatch[1]
252
+ logger.debug(`Detected Helm version: ${helmVersion}`)
253
+
254
+ // Check version constraints: >= 3.18.0 and <= 3.18.4
255
+ const minVersion = '3.18.0'
256
+ const maxVersion = '3.18.4'
257
+
258
+ if (!semver.gte(helmVersion, minVersion)) {
259
+ throw new Error(`Locally installed Helm version ${helmVersion} is too old. Use Helm v${maxVersion} which is the latest compatible version`)
260
+ }
261
+
262
+ if (!semver.lte(helmVersion, maxVersion)) {
263
+ throw new Error(`Locally installed Helm version ${helmVersion} is too new. Use Helm v${maxVersion} which is the latest compatible version`)
264
+ }
265
+
266
+ logger.debug(`Helm version ${helmVersion} is compatible`)
267
+ } catch (error) {
268
+ if (error instanceof Error && error.message.includes('ENOENT')) {
269
+ throw new Error('Helm is not installed or not found in PATH. Please install Helm version >= 3.18.0 and < 3.18.5')
270
+ }
271
+ throw error
272
+ }
273
+ }
274
+
223
275
  /**
224
276
  * Execute a Helm command by invoking the Helm CLI client with the given kubeconfig and arguments to `helm`.
225
277
  * The provided kubeconfig is written to a temporary file and cleaned up after, and passed to `helm` with
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = "1.9.1"
1
+ export const PACKAGE_VERSION = "1.9.2"