@backstage/plugin-app-backend 0.5.4 → 0.5.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @backstage/plugin-app-backend
2
2
 
3
+ ## 0.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-auth-node@0.6.6
9
+ - @backstage/backend-plugin-api@1.4.2
10
+ - @backstage/plugin-app-node@0.1.36
11
+
12
+ ## 0.5.5-next.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @backstage/plugin-auth-node@0.6.6-next.0
18
+ - @backstage/backend-plugin-api@1.4.2-next.0
19
+ - @backstage/config-loader@1.10.2
20
+ - @backstage/config@1.3.3
21
+ - @backstage/errors@1.2.7
22
+ - @backstage/types@1.2.1
23
+ - @backstage/plugin-app-node@0.1.36-next.0
24
+
3
25
  ## 0.5.4
4
26
 
5
27
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"StaticAssetsStore.cjs.js","sources":["../../../src/lib/assets/StaticAssetsStore.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Knex } from 'knex';\nimport { DateTime } from 'luxon';\nimport partition from 'lodash/partition';\nimport { StaticAsset, StaticAssetInput, StaticAssetProvider } from './types';\nimport {\n DatabaseService,\n LoggerService,\n resolvePackagePath,\n} from '@backstage/backend-plugin-api';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-app-backend',\n 'migrations',\n);\n\ninterface StaticAssetRow {\n path: string;\n content: Buffer;\n namespace: string | null;\n last_modified_at: Date;\n}\n\n/** @internal */\nexport interface StaticAssetsStoreOptions {\n database: DatabaseService;\n logger: LoggerService;\n}\n\n/**\n * A storage for static assets that are assumed to be immutable.\n *\n * @internal\n */\nexport class StaticAssetsStore implements StaticAssetProvider {\n #db: Knex;\n #logger: LoggerService;\n #namespace: string;\n\n static async create(options: StaticAssetsStoreOptions) {\n const { database } = options;\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new StaticAssetsStore(client, options.logger);\n }\n\n private constructor(client: Knex, logger: LoggerService, namespace?: string) {\n this.#db = client;\n this.#logger = logger;\n this.#namespace = namespace ?? 'default';\n }\n\n /**\n * Creates a new store with the provided namespace, using the same underlying storage.\n */\n withNamespace(namespace: string): StaticAssetsStore {\n return new StaticAssetsStore(this.#db, this.#logger, namespace);\n }\n\n /**\n * Store the provided assets.\n *\n * If an asset for a given path already exists the modification time will be\n * updated, but the contents will not.\n */\n async storeAssets(assets: StaticAssetInput[]) {\n const existingRows = await this.#db<StaticAssetRow>('static_assets_cache')\n .where('namespace', this.#namespace)\n .whereIn(\n 'path',\n assets.map(a => a.path),\n );\n const existingAssetPaths = new Set(existingRows.map(r => r.path));\n\n const [modified, added] = partition(assets, asset =>\n existingAssetPaths.has(asset.path),\n );\n\n this.#logger.info(\n `Storing ${modified.length} updated assets and ${added.length} new assets`,\n );\n\n await this.#db('static_assets_cache')\n .update({\n last_modified_at: this.#db.fn.now(),\n })\n .where('namespace', this.#namespace)\n .whereIn(\n 'path',\n modified.map(a => a.path),\n );\n\n for (const asset of added) {\n // We ignore conflicts with other nodes, it doesn't matter if someone else\n // added the same asset just before us.\n await this.#db('static_assets_cache')\n .insert({\n path: asset.path,\n content: await asset.content(),\n namespace: this.#namespace,\n })\n .onConflict(['namespace', 'path'])\n .ignore();\n }\n }\n\n /**\n * Retrieve an asset from the store with the given path.\n */\n async getAsset(path: string): Promise<StaticAsset | undefined> {\n const [row] = await this.#db<StaticAssetRow>('static_assets_cache').where({\n path,\n namespace: this.#namespace,\n });\n if (!row) {\n return undefined;\n }\n return {\n path: row.path,\n content: row.content,\n lastModifiedAt:\n typeof row.last_modified_at === 'string'\n ? DateTime.fromSQL(row.last_modified_at, { zone: 'UTC' }).toJSDate()\n : row.last_modified_at,\n };\n }\n\n /**\n * Delete any assets from the store whose modification time is older than the max age.\n */\n async trimAssets(options: { maxAgeSeconds: number }) {\n const { maxAgeSeconds } = options;\n let lastModifiedInterval = this.#db.raw(\n `now() + interval '${-maxAgeSeconds} seconds'`,\n );\n if (this.#db.client.config.client.includes('mysql')) {\n lastModifiedInterval = this.#db.raw(\n `date_sub(now(), interval ${maxAgeSeconds} second)`,\n );\n } else if (this.#db.client.config.client.includes('sqlite3')) {\n lastModifiedInterval = this.#db.raw(`datetime('now', ?)`, [\n `-${maxAgeSeconds} seconds`,\n ]);\n }\n await this.#db<StaticAssetRow>('static_assets_cache')\n .where('namespace', this.#namespace)\n .where('last_modified_at', '<=', lastModifiedInterval)\n .delete();\n }\n}\n"],"names":["resolvePackagePath","partition","DateTime"],"mappings":";;;;;;;;;;AA0BA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,+BAAA;AAAA,EACA;AACF,CAAA;AAoBO,MAAM,iBAAiD,CAAA;AAAA,EAC5D,GAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EAEA,aAAa,OAAO,OAAmC,EAAA;AACrD,IAAM,MAAA,EAAE,UAAa,GAAA,OAAA;AACrB,IAAM,MAAA,MAAA,GAAS,MAAM,QAAA,CAAS,SAAU,EAAA;AAExC,IAAI,IAAA,CAAC,QAAS,CAAA,UAAA,EAAY,IAAM,EAAA;AAC9B,MAAM,MAAA,MAAA,CAAO,QAAQ,MAAO,CAAA;AAAA,QAC1B,SAAW,EAAA;AAAA,OACZ,CAAA;AAAA;AAGH,IAAA,O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AA;AAC1B,IAAI,IAAA,oBAAA,GAAuB,KAAK,GAAI,CAAA,GAAA;AAAA,MAClC,CAAA,kBAAA,EAAqB,CAAC,aAAa,CAAA,SAAA;AAAA,KACrC;AACA,IAAA,IAAI,KAAK,GAAI,CAAA,MAAA,CAAO,OAAO,MAAO,CAAA,QAAA,CAAS,OAAO,CAAG,EAAA;AACnD,MAAA,oBAAA,GAAuB,KAAK,GAAI,CAAA,GAAA;AAAA,QAC9B,4BAA4B,aAAa,CAAA,QAAA;AAAA,OAC3C;AAAA,KACF,MAAA,IAAW,KAAK,GAAI,CAAA,MAAA,CAAO,OAAO,MAAO,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA;AAC5D,MAAuB,oBAAA,GAAA,IAAA,CAAK,GAAI,CAAA,GAAA,CAAI,CAAsB,kBAAA,CAAA,EAAA;AAAA,QACxD,IAAI,aAAa,CAAA,QAAA;AAAA,OAClB,CAAA;AAAA;AAEH,IAAA,MAAM,IAAK,CAAA,GAAA,CAAoB,qBAAqB,CAAA,CACjD,MAAM,WAAa,EAAA,IAAA,CAAK,UAAU,CAAA,CAClC,KAAM,CAAA,kBAAA,EAAoB,IAAM,EAAA,oBAAoB,EACpD,MAAO,EAAA;AAAA;AAEd;;;;"}
1
+ {"version":3,"file":"StaticAssetsStore.cjs.js","sources":["../../../src/lib/assets/StaticAssetsStore.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Knex } from 'knex';\nimport { DateTime } from 'luxon';\nimport partition from 'lodash/partition';\nimport { StaticAsset, StaticAssetInput, StaticAssetProvider } from './types';\nimport {\n DatabaseService,\n LoggerService,\n resolvePackagePath,\n} from '@backstage/backend-plugin-api';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-app-backend',\n 'migrations',\n);\n\ninterface StaticAssetRow {\n path: string;\n content: Buffer;\n namespace: string | null;\n last_modified_at: Date;\n}\n\n/** @internal */\nexport interface StaticAssetsStoreOptions {\n database: DatabaseService;\n logger: LoggerService;\n}\n\n/**\n * A storage for static assets that are assumed to be immutable.\n *\n * @internal\n */\nexport class StaticAssetsStore implements StaticAssetProvider {\n #db: Knex;\n #logger: LoggerService;\n #namespace: string;\n\n static async create(options: StaticAssetsStoreOptions) {\n const { database } = options;\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new StaticAssetsStore(client, options.logger);\n }\n\n private constructor(client: Knex, logger: LoggerService, namespace?: string) {\n this.#db = client;\n this.#logger = logger;\n this.#namespace = namespace ?? 'default';\n }\n\n /**\n * Creates a new store with the provided namespace, using the same underlying storage.\n */\n withNamespace(namespace: string): StaticAssetsStore {\n return new StaticAssetsStore(this.#db, this.#logger, namespace);\n }\n\n /**\n * Store the provided assets.\n *\n * If an asset for a given path already exists the modification time will be\n * updated, but the contents will not.\n */\n async storeAssets(assets: StaticAssetInput[]) {\n const existingRows = await this.#db<StaticAssetRow>('static_assets_cache')\n .where('namespace', this.#namespace)\n .whereIn(\n 'path',\n assets.map(a => a.path),\n );\n const existingAssetPaths = new Set(existingRows.map(r => r.path));\n\n const [modified, added] = partition(assets, asset =>\n existingAssetPaths.has(asset.path),\n );\n\n this.#logger.info(\n `Storing ${modified.length} updated assets and ${added.length} new assets`,\n );\n\n await this.#db('static_assets_cache')\n .update({\n last_modified_at: this.#db.fn.now(),\n })\n .where('namespace', this.#namespace)\n .whereIn(\n 'path',\n modified.map(a => a.path),\n );\n\n for (const asset of added) {\n // We ignore conflicts with other nodes, it doesn't matter if someone else\n // added the same asset just before us.\n await this.#db('static_assets_cache')\n .insert({\n path: asset.path,\n content: await asset.content(),\n namespace: this.#namespace,\n })\n .onConflict(['namespace', 'path'])\n .ignore();\n }\n }\n\n /**\n * Retrieve an asset from the store with the given path.\n */\n async getAsset(path: string): Promise<StaticAsset | undefined> {\n const [row] = await this.#db<StaticAssetRow>('static_assets_cache').where({\n path,\n namespace: this.#namespace,\n });\n if (!row) {\n return undefined;\n }\n return {\n path: row.path,\n content: row.content,\n lastModifiedAt:\n typeof row.last_modified_at === 'string'\n ? DateTime.fromSQL(row.last_modified_at, { zone: 'UTC' }).toJSDate()\n : row.last_modified_at,\n };\n }\n\n /**\n * Delete any assets from the store whose modification time is older than the max age.\n */\n async trimAssets(options: { maxAgeSeconds: number }) {\n const { maxAgeSeconds } = options;\n let lastModifiedInterval = this.#db.raw(\n `now() + interval '${-maxAgeSeconds} seconds'`,\n );\n if (this.#db.client.config.client.includes('mysql')) {\n lastModifiedInterval = this.#db.raw(\n `date_sub(now(), interval ${maxAgeSeconds} second)`,\n );\n } else if (this.#db.client.config.client.includes('sqlite3')) {\n lastModifiedInterval = this.#db.raw(`datetime('now', ?)`, [\n `-${maxAgeSeconds} seconds`,\n ]);\n }\n await this.#db<StaticAssetRow>('static_assets_cache')\n .where('namespace', this.#namespace)\n .where('last_modified_at', '<=', lastModifiedInterval)\n .delete();\n }\n}\n"],"names":["resolvePackagePath","partition","DateTime"],"mappings":";;;;;;;;;;AA0BA,MAAM,aAAA,GAAgBA,mCAAA;AAAA,EACpB,+BAAA;AAAA,EACA;AACF,CAAA;AAoBO,MAAM,iBAAA,CAAiD;AAAA,EAC5D,GAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EAEA,aAAa,OAAO,OAAA,EAAmC;AACrD,IAAA,MAAM,EAAE,UAAS,GAAI,OAAA;AACrB,IAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,SAAA,EAAU;AAExC,IAAA,IAAI,CAAC,QAAA,CAAS,UAAA,EAAY,IA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A,EAAO,CAAA,CAAE,QAAA,KACxD,GAAA,CAAI;AAAA,KACZ;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,OAAA,EAAoC;AACnD,IAAA,MAAM,EAAE,eAAc,GAAI,OAAA;AAC1B,IAAA,IAAI,oBAAA,GAAuB,KAAK,GAAA,CAAI,GAAA;AAAA,MAClC,CAAA,kBAAA,EAAqB,CAAC,aAAa,CAAA,SAAA;AAAA,KACrC;AACA,IAAA,IAAI,KAAK,GAAA,CAAI,MAAA,CAAO,OAAO,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA,EAAG;AACnD,MAAA,oBAAA,GAAuB,KAAK,GAAA,CAAI,GAAA;AAAA,QAC9B,4BAA4B,aAAa,CAAA,QAAA;AAAA,OAC3C;AAAA,IACF,CAAA,MAAA,IAAW,KAAK,GAAA,CAAI,MAAA,CAAO,OAAO,MAAA,CAAO,QAAA,CAAS,SAAS,CAAA,EAAG;AAC5D,MAAA,oBAAA,GAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,CAAA,kBAAA,CAAA,EAAsB;AAAA,QACxD,IAAI,aAAa,CAAA,QAAA;AAAA,OAClB,CAAA;AAAA,IACH;AACA,IAAA,MAAM,IAAA,CAAK,GAAA,CAAoB,qBAAqB,CAAA,CACjD,MAAM,WAAA,EAAa,IAAA,CAAK,UAAU,CAAA,CAClC,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM,oBAAoB,EACpD,MAAA,EAAO;AAAA,EACZ;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createStaticAssetMiddleware.cjs.js","sources":["../../../src/lib/assets/createStaticAssetMiddleware.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { extname } from 'path';\nimport { RequestHandler } from 'express';\nimport { StaticAssetProvider } from './types';\nimport { CACHE_CONTROL_MAX_CACHE } from '../headers';\n\n/**\n * Creates a middleware that serves static assets from a static asset provider\n *\n * @internal\n */\nexport function createStaticAssetMiddleware(\n store: StaticAssetProvider,\n): RequestHandler {\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n\n // Let's not assume we're in promise-router\n Promise.resolve(\n (async () => {\n // Drop leading slashes from the incoming path\n const path = req.path.startsWith('/') ? req.path.slice(1) : req.path;\n\n const asset = await store.getAsset(path);\n if (!asset) {\n next();\n return;\n }\n\n // Set the Content-Type header, falling back to octet-stream\n const ext = extname(asset.path);\n if (ext) {\n res.type(ext);\n } else {\n res.type('bin');\n }\n\n // Same as our express.static override\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n res.setHeader('Last-Modified', asset.lastModifiedAt.toUTCString());\n\n res.send(asset.content);\n })(),\n ).catch(next);\n };\n}\n"],"names":["path","extname","CACHE_CONTROL_MAX_CACHE"],"mappings":";;;;;AA0BO,SAAS,4BACd,KACgB,EAAA;AAChB,EAAO,OAAA,CAAC,GAAK,EAAA,GAAA,EAAK,IAAS,KAAA;AACzB,IAAA,IAAI,GAAI,CAAA,MAAA,KAAW,KAAS,IAAA,GAAA,CAAI,WAAW,MAAQ,EAAA;AACjD,MAAK,IAAA,EAAA;AACL,MAAA;AAAA;AAIF,IAAQ,OAAA,CAAA,OAAA;AAAA,MAAA,CACL,YAAY;AAEX,QAAM,MAAAA,MAAA,GAAO,GAAI,CAAA,IAAA,CAAK,UAAW,CAAA,GAAG,CAAI,GAAA,GAAA,CAAI,IAAK,CAAA,KAAA,CAAM,CAAC,CAAA,GAAI,GAAI,CAAA,IAAA;AAEhE,QAAA,MAAM,KAAQ,GAAA,MAAM,KAAM,CAAA,QAAA,CAASA,MAAI,CAAA;AACvC,QAAA,IAAI,CAAC,KAAO,EAAA;AACV,UAAK,IAAA,EAAA;AACL,UAAA;AAAA;AAIF,QAAM,MAAA,GAAA,GAAMC,YAAQ,CAAA,KAAA,CAAM,IAAI,CAAA;AAC9B,QAAA,IAAI,GAAK,EAAA;AACP,UAAA,GAAA,CAAI,KAAK,GAAG,CAAA;AAAA,SACP,MAAA;AACL,UAAA,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA;AAIhB,QAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBC,+BAAuB,CAAA;AACtD,QAAA,GAAA,CAAI,SAAU,CAAA,eAAA,EAAiB,KAAM,CAAA,cAAA,CAAe,aAAa,CAAA;AAEjE,QAAI,GAAA,CAAA,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,OACrB;AAAA,KACL,CAAE,MAAM,IAAI,CAAA;AAAA,GACd;AACF;;;;"}
1
+ {"version":3,"file":"createStaticAssetMiddleware.cjs.js","sources":["../../../src/lib/assets/createStaticAssetMiddleware.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { extname } from 'path';\nimport { RequestHandler } from 'express';\nimport { StaticAssetProvider } from './types';\nimport { CACHE_CONTROL_MAX_CACHE } from '../headers';\n\n/**\n * Creates a middleware that serves static assets from a static asset provider\n *\n * @internal\n */\nexport function createStaticAssetMiddleware(\n store: StaticAssetProvider,\n): RequestHandler {\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n\n // Let's not assume we're in promise-router\n Promise.resolve(\n (async () => {\n // Drop leading slashes from the incoming path\n const path = req.path.startsWith('/') ? req.path.slice(1) : req.path;\n\n const asset = await store.getAsset(path);\n if (!asset) {\n next();\n return;\n }\n\n // Set the Content-Type header, falling back to octet-stream\n const ext = extname(asset.path);\n if (ext) {\n res.type(ext);\n } else {\n res.type('bin');\n }\n\n // Same as our express.static override\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n res.setHeader('Last-Modified', asset.lastModifiedAt.toUTCString());\n\n res.send(asset.content);\n })(),\n ).catch(next);\n };\n}\n"],"names":["path","extname","CACHE_CONTROL_MAX_CACHE"],"mappings":";;;;;AA0BO,SAAS,4BACd,KAAA,EACgB;AAChB,EAAA,OAAO,CAAC,GAAA,EAAK,GAAA,EAAK,IAAA,KAAS;AACzB,IAAA,IAAI,GAAA,CAAI,MAAA,KAAW,KAAA,IAAS,GAAA,CAAI,WAAW,MAAA,EAAQ;AACjD,MAAA,IAAA,EAAK;AACL,MAAA;AAAA,IACF;AAGA,IAAA,OAAA,CAAQ,OAAA;AAAA,MAAA,CACL,YAAY;AAEX,QAAA,MAAMA,MAAA,GAAO,GAAA,CAAI,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA,GAAI,GAAA,CAAI,IAAA;AAEhE,QAAA,MAAM,KAAA,GAAQ,MAAM,KAAA,CAAM,QAAA,CAASA,MAAI,CAAA;AACvC,QAAA,IAAI,CAAC,KAAA,EAAO;AACV,UAAA,IAAA,EAAK;AACL,UAAA;AAAA,QACF;AAGA,QAAA,MAAM,GAAA,GAAMC,YAAA,CAAQ,KAAA,CAAM,IAAI,CAAA;AAC9B,QAAA,IAAI,GAAA,EAAK;AACP,UAAA,GAAA,CAAI,KAAK,GAAG,CAAA;AAAA,QACd,CAAA,MAAO;AACL,UAAA,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,QAChB;AAGA,QAAA,GAAA,CAAI,SAAA,CAAU,iBAAiBC,+BAAuB,CAAA;AACtD,QAAA,GAAA,CAAI,SAAA,CAAU,eAAA,EAAiB,KAAA,CAAM,cAAA,CAAe,aAAa,CAAA;AAEjE,QAAA,GAAA,CAAI,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,MACxB,CAAA;AAAG,KACL,CAAE,MAAM,IAAI,CAAA;AAAA,EACd,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"findStaticAssets.cjs.js","sources":["../../../src/lib/assets/findStaticAssets.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { StaticAssetInput } from './types';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\n\n/**\n * Finds all static assets within a directory\n *\n * @internal\n */\nexport async function findStaticAssets(\n staticDir: string,\n): Promise<StaticAssetInput[]> {\n const assetPaths = await globby('**/*', {\n ignore: ['**/*.map'], // Ignore source maps since they're quite large\n cwd: staticDir,\n dot: true,\n });\n\n return assetPaths.map(path => ({\n path,\n content: async () => fs.readFile(resolveSafeChildPath(staticDir, path)),\n }));\n}\n"],"names":["globby","fs","resolveSafeChildPath"],"mappings":";;;;;;;;;;;AA0BA,eAAsB,iBACpB,SAC6B,EAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,MAAMA,uBAAA,CAAO,MAAQ,EAAA;AAAA,IACtC,MAAA,EAAQ,CAAC,UAAU,CAAA;AAAA;AAAA,IACnB,GAAK,EAAA,SAAA;AAAA,IACL,GAAK,EAAA;AAAA,GACN,CAAA;AAED,EAAO,OAAA,UAAA,CAAW,IAAI,CAAS,IAAA,MAAA;AAAA,IAC7B,IAAA;AAAA,IACA,SAAS,YAAYC,mBAAA,CAAG,SAASC,qCAAqB,CAAA,SAAA,EAAW,IAAI,CAAC;AAAA,GACtE,CAAA,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"findStaticAssets.cjs.js","sources":["../../../src/lib/assets/findStaticAssets.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { StaticAssetInput } from './types';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\n\n/**\n * Finds all static assets within a directory\n *\n * @internal\n */\nexport async function findStaticAssets(\n staticDir: string,\n): Promise<StaticAssetInput[]> {\n const assetPaths = await globby('**/*', {\n ignore: ['**/*.map'], // Ignore source maps since they're quite large\n cwd: staticDir,\n dot: true,\n });\n\n return assetPaths.map(path => ({\n path,\n content: async () => fs.readFile(resolveSafeChildPath(staticDir, path)),\n }));\n}\n"],"names":["globby","fs","resolveSafeChildPath"],"mappings":";;;;;;;;;;;AA0BA,eAAsB,iBACpB,SAAA,EAC6B;AAC7B,EAAA,MAAM,UAAA,GAAa,MAAMA,uBAAA,CAAO,MAAA,EAAQ;AAAA,IACtC,MAAA,EAAQ,CAAC,UAAU,CAAA;AAAA;AAAA,IACnB,GAAA,EAAK,SAAA;AAAA,IACL,GAAA,EAAK;AAAA,GACN,CAAA;AAED,EAAA,OAAO,UAAA,CAAW,IAAI,CAAA,IAAA,MAAS;AAAA,IAC7B,IAAA;AAAA,IACA,SAAS,YAAYC,mBAAA,CAAG,SAASC,qCAAA,CAAqB,SAAA,EAAW,IAAI,CAAC;AAAA,GACxE,CAAE,CAAA;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectConfig.cjs.js","sources":["../../../src/lib/config/injectConfig.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { injectConfigIntoHtml } from './injectConfigIntoHtml';\nimport { injectConfigIntoStatic } from './injectConfigIntoStatic';\nimport { InjectOptions } from './types';\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n * @internal\n */\nexport async function injectConfig(\n options: InjectOptions,\n): Promise<{ injectedPath?: string | undefined; indexHtmlContent?: Buffer }> {\n const indexHtmlContent = await injectConfigIntoHtml(options);\n if (indexHtmlContent) {\n return { indexHtmlContent };\n }\n\n const injectedPath = await injectConfigIntoStatic(options);\n return { injectedPath };\n}\n"],"names":["injectConfigIntoHtml","injectConfigIntoStatic"],"mappings":";;;;;AAwBA,eAAsB,aACpB,OAC2E,EAAA;AAC3E,EAAM,MAAA,gBAAA,GAAmB,MAAMA,yCAAA,CAAqB,OAAO,CAAA;AAC3D,EAAA,IAAI,gBAAkB,EAAA;AACpB,IAAA,OAAO,EAAE,gBAAiB,EAAA;AAAA;AAG5B,EAAM,MAAA,YAAA,GAAe,MAAMC,6CAAA,CAAuB,OAAO,CAAA;AACzD,EAAA,OAAO,EAAE,YAAa,EAAA;AACxB;;;;"}
1
+ {"version":3,"file":"injectConfig.cjs.js","sources":["../../../src/lib/config/injectConfig.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { injectConfigIntoHtml } from './injectConfigIntoHtml';\nimport { injectConfigIntoStatic } from './injectConfigIntoStatic';\nimport { InjectOptions } from './types';\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n * @internal\n */\nexport async function injectConfig(\n options: InjectOptions,\n): Promise<{ injectedPath?: string | undefined; indexHtmlContent?: Buffer }> {\n const indexHtmlContent = await injectConfigIntoHtml(options);\n if (indexHtmlContent) {\n return { indexHtmlContent };\n }\n\n const injectedPath = await injectConfigIntoStatic(options);\n return { injectedPath };\n}\n"],"names":["injectConfigIntoHtml","injectConfigIntoStatic"],"mappings":";;;;;AAwBA,eAAsB,aACpB,OAAA,EAC2E;AAC3E,EAAA,MAAM,gBAAA,GAAmB,MAAMA,yCAAA,CAAqB,OAAO,CAAA;AAC3D,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,OAAO,EAAE,gBAAA,EAAiB;AAAA,EAC5B;AAEA,EAAA,MAAM,YAAA,GAAe,MAAMC,6CAAA,CAAuB,OAAO,CAAA;AACzD,EAAA,OAAO,EAAE,YAAA,EAAa;AACxB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectConfigIntoHtml.cjs.js","sources":["../../../src/lib/config/injectConfigIntoHtml.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { InjectOptions } from './types';\nimport compileTemplate from 'lodash/template';\nimport { Config, ConfigReader } from '@backstage/config';\n\nconst HTML_TEMPLATE_NAME = 'index.html.tmpl';\n\n/** @internal */\nexport async function injectConfigIntoHtml(\n options: InjectOptions,\n): Promise<Buffer | undefined> {\n const { rootDir, appConfigs } = options;\n\n const templatePath = resolvePath(rootDir, HTML_TEMPLATE_NAME);\n\n if (!(await fs.exists(templatePath))) {\n return undefined;\n }\n\n const templateContent = await fs.readFile(\n resolvePath(rootDir, HTML_TEMPLATE_NAME),\n 'utf8',\n );\n\n const config = ConfigReader.fromConfigs(appConfigs);\n\n const templateSource = compileTemplate(templateContent, {\n interpolate: /<%=([\\s\\S]+?)%>/g,\n });\n\n const publicPath = resolvePublicPath(config);\n const indexHtmlContent = templateSource({\n config,\n publicPath,\n });\n\n const indexHtmlContentWithConfig = indexHtmlContent.replace(\n '</head>',\n `\n<script type=\"backstage.io/config\">\n${JSON.stringify(appConfigs, null, 2)\n // Note on the security aspects of this: We generally trust the app config to\n // be safe, since control of the app config effectively means full control of\n // the app. These substitutions are here as an extra precaution to avoid\n // unintentionally breaking the app, to avoid this being flagged, and in case\n // someone decides to hook up user input to the app config in their own setup.\n .replaceAll('</script', '')\n .replaceAll('<!--', '')}\n</script>\n</head>`,\n );\n\n return Buffer.from(indexHtmlContentWithConfig, 'utf8');\n}\n\nexport function resolvePublicPath(config: Config) {\n const baseUrl = new URL(\n config.getOptionalString('app.baseUrl') ?? '/',\n 'http://localhost:7007',\n );\n return baseUrl.pathname.replace(/\\/+$/, '');\n}\n"],"names":["resolvePath","fs","config","ConfigReader","compileTemplate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AAA,GAAA;AAAA,IAC3C;AAAA,GACF;AACA,EAAA,OAAO,OAAQ,CAAA,QAAA,CAAS,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAA;AAC5C;;;;;"}
1
+ {"version":3,"file":"injectConfigIntoHtml.cjs.js","sources":["../../../src/lib/config/injectConfigIntoHtml.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { InjectOptions } from './types';\nimport compileTemplate from 'lodash/template';\nimport { Config, ConfigReader } from '@backstage/config';\n\nconst HTML_TEMPLATE_NAME = 'index.html.tmpl';\n\n/** @internal */\nexport async function injectConfigIntoHtml(\n options: InjectOptions,\n): Promise<Buffer | undefined> {\n const { rootDir, appConfigs } = options;\n\n const templatePath = resolvePath(rootDir, HTML_TEMPLATE_NAME);\n\n if (!(await fs.exists(templatePath))) {\n return undefined;\n }\n\n const templateContent = await fs.readFile(\n resolvePath(rootDir, HTML_TEMPLATE_NAME),\n 'utf8',\n );\n\n const config = ConfigReader.fromConfigs(appConfigs);\n\n const templateSource = compileTemplate(templateContent, {\n interpolate: /<%=([\\s\\S]+?)%>/g,\n });\n\n const publicPath = resolvePublicPath(config);\n const indexHtmlContent = templateSource({\n config,\n publicPath,\n });\n\n const indexHtmlContentWithConfig = indexHtmlContent.replace(\n '</head>',\n `\n<script type=\"backstage.io/config\">\n${JSON.stringify(appConfigs, null, 2)\n // Note on the security aspects of this: We generally trust the app config to\n // be safe, since control of the app config effectively means full control of\n // the app. These substitutions are here as an extra precaution to avoid\n // unintentionally breaking the app, to avoid this being flagged, and in case\n // someone decides to hook up user input to the app config in their own setup.\n .replaceAll('</script', '')\n .replaceAll('<!--', '')}\n</script>\n</head>`,\n );\n\n return Buffer.from(indexHtmlContentWithConfig, 'utf8');\n}\n\nexport function resolvePublicPath(config: Config) {\n const baseUrl = new URL(\n config.getOptionalString('app.baseUrl') ?? '/',\n 'http://localhost:7007',\n );\n return baseUrl.pathname.replace(/\\/+$/, '');\n}\n"],"names":["resolvePath","fs","config","ConfigReader","compileTemplate"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,kBAAA,GAAqB,iBAAA;AAG3B,eAAsB,qBACpB,OAAA,EAC6B;AAC7B,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAW,GAAI,OAAA;AAEhC,EAAA,MAAM,YAAA,GAAeA,YAAA,CAAY,OAAA,EAAS,kBAAkB,CAAA;AAE5D,EAAA,IAAI,CAAE,MAAMC,mBAAA,CAAG,MAAA,CAAO,YAAY,CAAA,EAAI;AACpC,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,eAAA,GAAkB,MAAMA,mBAAA,CAAG,QAAA;AAAA,IAC/BD,YAAA,CAAY,SAAS,kBAAkB,CAAA;AAAA,IACvC;AAAA,GACF;AAEA,EAAA,MAAME,QAAA,GAASC,mBAAA,CAAa,WAAA,CAAY,UAAU,CAAA;AAElD,EAAA,MAAM,cAAA,GAAiBC,iCAAgB,eAAA,EAAiB;AAAA,IACtD,WAAA,EAAa;AAAA,GACd,CAAA;AAED,EAAA,MAAM,UAAA,GAAa,kBAAkBF,QAAM,CAAA;AAC3C,EAAA,MAAM,mBAAmB,cAAA,CAAe;AAAA,YACtCA,QAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,6BAA6B,gBAAA,CAAiB,OAAA;AAAA,IAClD,SAAA;AAAA,IACA;AAAA;AAAA,EAEF,IAAA,CAAK,SAAA,CAAU,UAAA,EAAY,IAAA,EAAM,CAAC,CAAA,CAMjC,UAAA,CAAW,WAAA,EAAY,EAAE,CAAA,CACzB,UAAA,CAAW,MAAA,EAAQ,EAAE,CAAC;AAAA;AAAA,OAAA;AAAA,GAGvB;AAEA,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,0BAAA,EAA4B,MAAM,CAAA;AACvD;AAEO,SAAS,kBAAkB,MAAA,EAAgB;AAChD,EAAA,MAAM,UAAU,IAAI,GAAA;AAAA,IAClB,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA,IAAK,GAAA;AAAA,IAC3C;AAAA,GACF;AACA,EAAA,OAAO,OAAA,CAAQ,QAAA,CAAS,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AAC5C;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectConfigIntoStatic.cjs.js","sources":["../../../src/lib/config/injectConfigIntoStatic.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { InjectOptions } from './types';\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n */\nexport async function injectConfigIntoStatic(\n options: InjectOptions,\n): Promise<string | undefined> {\n const { staticDir, logger, appConfigs } = options;\n\n const files = await fs.readdir(staticDir);\n const jsFiles = files.filter(file => file.endsWith('.js'));\n\n const escapedData = JSON.stringify(appConfigs).replace(/(\"|'|\\\\)/g, '\\\\$1');\n const injected = `/*__APP_INJECTED_CONFIG_MARKER__*/\"${escapedData}\"/*__INJECTED_END__*/`;\n\n for (const jsFile of jsFiles) {\n const path = resolvePath(staticDir, jsFile);\n\n const content = await fs.readFile(path, 'utf8');\n if (content.includes('__APP_INJECTED_RUNTIME_CONFIG__')) {\n logger.info(`Injecting env config into ${jsFile}`);\n\n const newContent = content.replaceAll(\n '\"__APP_INJECTED_RUNTIME_CONFIG__\"',\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return path;\n } else if (content.includes('__APP_INJECTED_CONFIG_MARKER__')) {\n logger.info(`Replacing injected env config in ${jsFile}`);\n\n const newContent = content.replaceAll(\n /\\/\\*__APP_INJECTED_CONFIG_MARKER__\\*\\/.*?\\/\\*__INJECTED_END__\\*\\//g,\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return path;\n }\n }\n logger.info('Env config not injected');\n return undefined;\n}\n"],"names":["fs","path","resolvePath"],"mappings":";;;;;;;;;AAuBA,eAAsB,uBACpB,OAC6B,EAAA;AAC7B,EAAA,MAAM,EAAE,SAAA,EAAW,MAAQ,EAAA,UAAA,EAAe,GAAA,OAAA;AAE1C,EAAA,MAAM,KAAQ,GAAA,MAAMA,mBAAG,CAAA,OAAA,CAAQ,SAAS,CAAA;AACxC,EAAA,MAAM,UAAU,KAAM,CAAA,MAAA,CAAO,UAAQ,IAAK,CAAA,QAAA,CAAS,KAAK,CAAC,CAAA;AAEzD,EAAA,MAAM,cAAc,IAAK,CAAA,SAAA,CAAU,UAAU,CAAE,CAAA,OAAA,CAAQ,aAAa,MAAM,CAAA;AAC1E,EAAM,MAAA,QAAA,GAAW,sCAAsC,WAAW,CAAA,qBAAA,CAAA;AAElE,EAAA,KAAA,MAAW,UAAU,OAAS,EAAA;AAC5B,IAAM,MAAAC,MAAA,GAAOC,YAAY,CAAA,SAAA,EAAW,MAAM,CAAA;AAE1C,IAAA,MAAM,OAAU,GAAA,MAAMF,mBAAG,CAAA,QAAA,CAASC,QAAM,MAAM,CAAA;AAC9C,IAAI,IAAA,OAAA,CAAQ,QAAS,CAAA,iCAAiC,CAAG,EAAA;AACvD,MAAO,MAAA,CAAA,IAAA,CAAK,CAA6B,0BAAA,EAAA,MAAM,CAAE,CAAA,CAAA;AAEjD,MAAA,MAAM,aAAa,OAAQ,CAAA,UAAA;AAAA,QACzB,mCAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAMD,mBAAG,CAAA,SAAA,CAAUC,MAAM,EAAA,UAAA,EAAY,MAAM,CAAA;AAC3C,MAAO,OAAAA,MAAA;AAAA,KACE,MAAA,IAAA,OAAA,CAAQ,QAAS,CAAA,gCAAgC,CAAG,EAAA;AAC7D,MAAO,MAAA,CAAA,IAAA,CAAK,CAAoC,iCAAA,EAAA,MAAM,CAAE,CAAA,CAAA;AAExD,MAAA,MAAM,aAAa,OAAQ,CAAA,UAAA;AAAA,QACzB,oEAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAMD,mBAAG,CAAA,SAAA,CAAUC,MAAM,EAAA,UAAA,EAAY,MAAM,CAAA;AAC3C,MAAO,OAAAA,MAAA;AAAA;AACT;AAEF,EAAA,MAAA,CAAO,KAAK,yBAAyB,CAAA;AACrC,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"injectConfigIntoStatic.cjs.js","sources":["../../../src/lib/config/injectConfigIntoStatic.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { InjectOptions } from './types';\n\n/**\n * Injects configs into the app bundle, replacing any existing injected config.\n */\nexport async function injectConfigIntoStatic(\n options: InjectOptions,\n): Promise<string | undefined> {\n const { staticDir, logger, appConfigs } = options;\n\n const files = await fs.readdir(staticDir);\n const jsFiles = files.filter(file => file.endsWith('.js'));\n\n const escapedData = JSON.stringify(appConfigs).replace(/(\"|'|\\\\)/g, '\\\\$1');\n const injected = `/*__APP_INJECTED_CONFIG_MARKER__*/\"${escapedData}\"/*__INJECTED_END__*/`;\n\n for (const jsFile of jsFiles) {\n const path = resolvePath(staticDir, jsFile);\n\n const content = await fs.readFile(path, 'utf8');\n if (content.includes('__APP_INJECTED_RUNTIME_CONFIG__')) {\n logger.info(`Injecting env config into ${jsFile}`);\n\n const newContent = content.replaceAll(\n '\"__APP_INJECTED_RUNTIME_CONFIG__\"',\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return path;\n } else if (content.includes('__APP_INJECTED_CONFIG_MARKER__')) {\n logger.info(`Replacing injected env config in ${jsFile}`);\n\n const newContent = content.replaceAll(\n /\\/\\*__APP_INJECTED_CONFIG_MARKER__\\*\\/.*?\\/\\*__INJECTED_END__\\*\\//g,\n injected,\n );\n await fs.writeFile(path, newContent, 'utf8');\n return path;\n }\n }\n logger.info('Env config not injected');\n return undefined;\n}\n"],"names":["fs","path","resolvePath"],"mappings":";;;;;;;;;AAuBA,eAAsB,uBACpB,OAAA,EAC6B;AAC7B,EAAA,MAAM,EAAE,SAAA,EAAW,MAAA,EAAQ,UAAA,EAAW,GAAI,OAAA;AAE1C,EAAA,MAAM,KAAA,GAAQ,MAAMA,mBAAA,CAAG,OAAA,CAAQ,SAAS,CAAA;AACxC,EAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,UAAQ,IAAA,CAAK,QAAA,CAAS,KAAK,CAAC,CAAA;AAEzD,EAAA,MAAM,cAAc,IAAA,CAAK,SAAA,CAAU,UAAU,CAAA,CAAE,OAAA,CAAQ,aAAa,MAAM,CAAA;AAC1E,EAAA,MAAM,QAAA,GAAW,sCAAsC,WAAW,CAAA,qBAAA,CAAA;AAElE,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,MAAMC,MAAA,GAAOC,YAAA,CAAY,SAAA,EAAW,MAAM,CAAA;AAE1C,IAAA,MAAM,OAAA,GAAU,MAAMF,mBAAA,CAAG,QAAA,CAASC,QAAM,MAAM,CAAA;AAC9C,IAAA,IAAI,OAAA,CAAQ,QAAA,CAAS,iCAAiC,CAAA,EAAG;AACvD,MAAA,MAAA,CAAO,IAAA,CAAK,CAAA,0BAAA,EAA6B,MAAM,CAAA,CAAE,CAAA;AAEjD,MAAA,MAAM,aAAa,OAAA,CAAQ,UAAA;AAAA,QACzB,mCAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAMD,mBAAA,CAAG,SAAA,CAAUC,MAAA,EAAM,UAAA,EAAY,MAAM,CAAA;AAC3C,MAAA,OAAOA,MAAA;AAAA,IACT,CAAA,MAAA,IAAW,OAAA,CAAQ,QAAA,CAAS,gCAAgC,CAAA,EAAG;AAC7D,MAAA,MAAA,CAAO,IAAA,CAAK,CAAA,iCAAA,EAAoC,MAAM,CAAA,CAAE,CAAA;AAExD,MAAA,MAAM,aAAa,OAAA,CAAQ,UAAA;AAAA,QACzB,oEAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAMD,mBAAA,CAAG,SAAA,CAAUC,MAAA,EAAM,UAAA,EAAY,MAAM,CAAA;AAC3C,MAAA,OAAOA,MAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,MAAA,CAAO,KAAK,yBAAyB,CAAA;AACrC,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"readFrontendConfig.cjs.js","sources":["../../../src/lib/config/readFrontendConfig.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { AppConfig, Config } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport {\n ConfigSchema,\n loadConfigSchema,\n readEnvConfig,\n} from '@backstage/config-loader';\n\n/**\n * Read config from environment and process the backend config using the\n * schema that is embedded in the frontend build.\n */\nexport async function readFrontendConfig(options: {\n env: { [name: string]: string | undefined };\n appDistDir: string;\n config: Config;\n schema?: ConfigSchema;\n}): Promise<AppConfig[]> {\n const { env, appDistDir, config } = options;\n\n const schemaPath = resolvePath(appDistDir, '.config-schema.json');\n if (await fs.pathExists(schemaPath)) {\n const envConfigs = readEnvConfig(env);\n const serializedSchema = await fs.readJson(schemaPath);\n\n try {\n const schema =\n options.schema ||\n (await loadConfigSchema({\n serialized: serializedSchema,\n }));\n\n return await schema.process(\n [...envConfigs, { data: config.get() as JsonObject, context: 'app' }],\n { visibility: ['frontend'], withDeprecatedKeys: true },\n );\n } catch (error) {\n throw new Error(\n 'Invalid app bundle schema. If this error is unexpected you need to run `yarn build` in the app. ' +\n `If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. ` +\n `Caused by the following schema error, ${error}`,\n );\n }\n }\n\n return [];\n}\n"],"names":["resolvePath","fs","readEnvConfig","loadConfigSchema"],"mappings":";;;;;;;;;;AA8BA,eAAsB,mBAAmB,OAKhB,EAAA;AACvB,EAAA,MAAM,EAAE,GAAA,EAAK,UAAY,EAAA,MAAA,EAAW,GAAA,OAAA;AAEpC,EAAM,MAAA,UAAA,GAAaA,YAAY,CAAA,UAAA,EAAY,qBAAqB,CAAA;AAChE,EAAA,IAAI,MAAMC,mBAAA,CAAG,UAAW,CAAA,UAAU,CAAG,EAAA;AACnC,IAAM,MAAA,UAAA,GAAaC,2BAAc,GAAG,CAAA;AACpC,IAAA,MAAM,gBAAmB,GAAA,MAAMD,mBAAG,CAAA,QAAA,CAAS,UAAU,CAAA;AAErD,IAAI,IAAA;AACF,MAAA,MAAM,MACJ,GAAA,OAAA,CAAQ,MACP,IAAA,MAAME,6BAAiB,CAAA;AAAA,QACtB,UAAY,EAAA;AAAA,OACb,CAAA;AAEH,MAAA,OAAO,MAAM,MAAO,CAAA,OAAA;AAAA,QAClB,CAAC,GAAG,UAAA,EAAY,EAAE,IAAA,EAAM,OAAO,GAAI,EAAA,EAAiB,OAAS,EAAA,KAAA,EAAO,CAAA;AAAA,QACpE,EAAE,UAAY,EAAA,CAAC,UAAU,CAAA,EAAG,oBAAoB,IAAK;AAAA,OACvD;AAAA,aACO,KAAO,EAAA;AACd,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,qPAE2C,KAAK,CAAA;AAAA,OAClD;AAAA;AACF;AAGF,EAAA,OAAO,EAAC;AACV;;;;"}
1
+ {"version":3,"file":"readFrontendConfig.cjs.js","sources":["../../../src/lib/config/readFrontendConfig.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { AppConfig, Config } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport {\n ConfigSchema,\n loadConfigSchema,\n readEnvConfig,\n} from '@backstage/config-loader';\n\n/**\n * Read config from environment and process the backend config using the\n * schema that is embedded in the frontend build.\n */\nexport async function readFrontendConfig(options: {\n env: { [name: string]: string | undefined };\n appDistDir: string;\n config: Config;\n schema?: ConfigSchema;\n}): Promise<AppConfig[]> {\n const { env, appDistDir, config } = options;\n\n const schemaPath = resolvePath(appDistDir, '.config-schema.json');\n if (await fs.pathExists(schemaPath)) {\n const envConfigs = readEnvConfig(env);\n const serializedSchema = await fs.readJson(schemaPath);\n\n try {\n const schema =\n options.schema ||\n (await loadConfigSchema({\n serialized: serializedSchema,\n }));\n\n return await schema.process(\n [...envConfigs, { data: config.get() as JsonObject, context: 'app' }],\n { visibility: ['frontend'], withDeprecatedKeys: true },\n );\n } catch (error) {\n throw new Error(\n 'Invalid app bundle schema. If this error is unexpected you need to run `yarn build` in the app. ' +\n `If that doesn't help you should make sure your config schema is correct and rebuild the app bundle again. ` +\n `Caused by the following schema error, ${error}`,\n );\n }\n }\n\n return [];\n}\n"],"names":["resolvePath","fs","readEnvConfig","loadConfigSchema"],"mappings":";;;;;;;;;;AA8BA,eAAsB,mBAAmB,OAAA,EAKhB;AACvB,EAAA,MAAM,EAAE,GAAA,EAAK,UAAA,EAAY,MAAA,EAAO,GAAI,OAAA;AAEpC,EAAA,MAAM,UAAA,GAAaA,YAAA,CAAY,UAAA,EAAY,qBAAqB,CAAA;AAChE,EAAA,IAAI,MAAMC,mBAAA,CAAG,UAAA,CAAW,UAAU,CAAA,EAAG;AACnC,IAAA,MAAM,UAAA,GAAaC,2BAAc,GAAG,CAAA;AACpC,IAAA,MAAM,gBAAA,GAAmB,MAAMD,mBAAA,CAAG,QAAA,CAAS,UAAU,CAAA;AAErD,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GACJ,OAAA,CAAQ,MAAA,IACP,MAAME,6BAAA,CAAiB;AAAA,QACtB,UAAA,EAAY;AAAA,OACb,CAAA;AAEH,MAAA,OAAO,MAAM,MAAA,CAAO,OAAA;AAAA,QAClB,CAAC,GAAG,UAAA,EAAY,EAAE,IAAA,EAAM,OAAO,GAAA,EAAI,EAAiB,OAAA,EAAS,KAAA,EAAO,CAAA;AAAA,QACpE,EAAE,UAAA,EAAY,CAAC,UAAU,CAAA,EAAG,oBAAoB,IAAA;AAAK,OACvD;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,qPAE2C,KAAK,CAAA;AAAA,OAClD;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAC;AACV;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"headers.cjs.js","sources":["../../src/lib/headers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const CACHE_CONTROL_NO_CACHE = 'no-store, max-age=0';\nexport const CACHE_CONTROL_MAX_CACHE = 'public, max-age=1209600'; // 14 days\nexport const CACHE_CONTROL_REVALIDATE_CACHE = 'no-cache'; // require revalidating cached responses before reuse them.\n"],"names":[],"mappings":";;AAgBO,MAAM,sBAAyB,GAAA;AAC/B,MAAM,uBAA0B,GAAA;AAChC,MAAM,8BAAiC,GAAA;;;;;;"}
1
+ {"version":3,"file":"headers.cjs.js","sources":["../../src/lib/headers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const CACHE_CONTROL_NO_CACHE = 'no-store, max-age=0';\nexport const CACHE_CONTROL_MAX_CACHE = 'public, max-age=1209600'; // 14 days\nexport const CACHE_CONTROL_REVALIDATE_CACHE = 'no-cache'; // require revalidating cached responses before reuse them.\n"],"names":[],"mappings":";;AAgBO,MAAM,sBAAA,GAAyB;AAC/B,MAAM,uBAAA,GAA0B;AAChC,MAAM,8BAAA,GAAiC;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"appPlugin.cjs.js","sources":["../../src/service/appPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express from 'express';\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './router';\nimport {\n configSchemaExtensionPoint,\n staticFallbackHandlerExtensionPoint,\n} from '@backstage/plugin-app-node';\nimport { ConfigSchema } from '@backstage/config-loader';\n\n/**\n * The App plugin is responsible for serving the frontend app bundle and static assets.\n * @public\n */\nexport const appPlugin = createBackendPlugin({\n pluginId: 'app',\n register(env) {\n let staticFallbackHandler: express.Handler | undefined;\n let schema: ConfigSchema | undefined;\n\n env.registerExtensionPoint(staticFallbackHandlerExtensionPoint, {\n setStaticFallbackHandler(handler) {\n if (staticFallbackHandler) {\n throw new Error(\n 'Attempted to install a static fallback handler for the app-backend twice',\n );\n }\n staticFallbackHandler = handler;\n },\n });\n\n env.registerExtensionPoint(configSchemaExtensionPoint, {\n setConfigSchema(configSchema) {\n if (schema) {\n throw new Error(\n 'Attempted to set config schema for the app-backend twice',\n );\n }\n schema = configSchema;\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n },\n async init({ logger, config, database, httpRouter, auth, httpAuth }) {\n const appPackageName =\n config.getOptionalString('app.packageName') ?? 'app';\n\n const router = await createRouter({\n logger,\n config,\n database,\n auth,\n httpAuth,\n appPackageName,\n staticFallbackHandler,\n schema,\n });\n httpRouter.use(router);\n\n // Access control is handled within the router\n httpRouter.addAuthPolicy({\n allow: 'unauthenticated',\n path: '/',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","staticFallbackHandlerExtensionPoint","configSchemaExtensionPoint","coreServices","router","createRouter"],"mappings":";;;;;;AAgCO,MAAM,YAAYA,oCAAoB,CAAA;AAAA,EAC3C,QAAU,EAAA,KAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAI,IAAA,qBAAA;AACJ,IAAI,IAAA,MAAA;AAEJ,IAAA,GAAA,CAAI,uBAAuBC,iDAAqC,EAAA;AAAA,MAC9D,yBAAyB,OAAS,EAAA;AAChC,QAAA,IAAI,qBAAuB,EAAA;AACzB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA;AAEF,QAAwB,qBAAA,GAAA,OAAA;AAAA;AAC1B,KACD,CAAA;AAED,IAAA,GAAA,CAAI,uBAAuBC,wCAA4B,EAAA;AAAA,MACrD,gBAAgB,YAAc,EAAA;AAC5B,QAAA,IAAI,MAAQ,EAAA;AACV,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA;AAEF,QAAS,MAAA,GAAA,YAAA;AAAA;AACX,KACD,CAAA;AAED,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,MAAMA,6BAAa,CAAA,IAAA;AAAA,QACnB,UAAUA,6BAAa,CAAA;AAAA,OACzB;AAAA,MACA,MAAM,KAAK,EAAE,MAAA,EAAQ,QAAQ,QAAU,EAAA,UAAA,EAAY,IAAM,EAAA,QAAA,EAAY,EAAA;AACnE,QAAA,MAAM,cACJ,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,CAAK,IAAA,KAAA;AAEjD,QAAM,MAAAC,QAAA,GAAS,MAAMC,mBAAa,CAAA;AAAA,UAChC,MAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,UACA,QAAA;AAAA,UACA,cAAA;AAAA,UACA,qBAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA;AAGrB,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,KAAO,EAAA,iBAAA;AAAA,UACP,IAAM,EAAA;AAAA,SACP,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"appPlugin.cjs.js","sources":["../../src/service/appPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express from 'express';\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './router';\nimport {\n configSchemaExtensionPoint,\n staticFallbackHandlerExtensionPoint,\n} from '@backstage/plugin-app-node';\nimport { ConfigSchema } from '@backstage/config-loader';\n\n/**\n * The App plugin is responsible for serving the frontend app bundle and static assets.\n * @public\n */\nexport const appPlugin = createBackendPlugin({\n pluginId: 'app',\n register(env) {\n let staticFallbackHandler: express.Handler | undefined;\n let schema: ConfigSchema | undefined;\n\n env.registerExtensionPoint(staticFallbackHandlerExtensionPoint, {\n setStaticFallbackHandler(handler) {\n if (staticFallbackHandler) {\n throw new Error(\n 'Attempted to install a static fallback handler for the app-backend twice',\n );\n }\n staticFallbackHandler = handler;\n },\n });\n\n env.registerExtensionPoint(configSchemaExtensionPoint, {\n setConfigSchema(configSchema) {\n if (schema) {\n throw new Error(\n 'Attempted to set config schema for the app-backend twice',\n );\n }\n schema = configSchema;\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n },\n async init({ logger, config, database, httpRouter, auth, httpAuth }) {\n const appPackageName =\n config.getOptionalString('app.packageName') ?? 'app';\n\n const router = await createRouter({\n logger,\n config,\n database,\n auth,\n httpAuth,\n appPackageName,\n staticFallbackHandler,\n schema,\n });\n httpRouter.use(router);\n\n // Access control is handled within the router\n httpRouter.addAuthPolicy({\n allow: 'unauthenticated',\n path: '/',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","staticFallbackHandlerExtensionPoint","configSchemaExtensionPoint","coreServices","router","createRouter"],"mappings":";;;;;;AAgCO,MAAM,YAAYA,oCAAA,CAAoB;AAAA,EAC3C,QAAA,EAAU,KAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,IAAI,qBAAA;AACJ,IAAA,IAAI,MAAA;AAEJ,IAAA,GAAA,CAAI,uBAAuBC,iDAAA,EAAqC;AAAA,MAC9D,yBAAyB,OAAA,EAAS;AAChC,QAAA,IAAI,qBAAA,EAAuB;AACzB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF;AACA,QAAA,qBAAA,GAAwB,OAAA;AAAA,MAC1B;AAAA,KACD,CAAA;AAED,IAAA,GAAA,CAAI,uBAAuBC,wCAAA,EAA4B;AAAA,MACrD,gBAAgB,YAAA,EAAc;AAC5B,QAAA,IAAI,MAAA,EAAQ;AACV,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF;AACA,QAAA,MAAA,GAAS,YAAA;AAAA,MACX;AAAA,KACD,CAAA;AAED,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,QAAQC,6BAAA,CAAa,MAAA;AAAA,QACrB,QAAQA,6BAAA,CAAa,UAAA;AAAA,QACrB,UAAUA,6BAAA,CAAa,QAAA;AAAA,QACvB,YAAYA,6BAAA,CAAa,UAAA;AAAA,QACzB,MAAMA,6BAAA,CAAa,IAAA;AAAA,QACnB,UAAUA,6BAAA,CAAa;AAAA,OACzB;AAAA,MACA,MAAM,KAAK,EAAE,MAAA,EAAQ,QAAQ,QAAA,EAAU,UAAA,EAAY,IAAA,EAAM,QAAA,EAAS,EAAG;AACnE,QAAA,MAAM,cAAA,GACJ,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,CAAA,IAAK,KAAA;AAEjD,QAAA,MAAMC,QAAA,GAAS,MAAMC,mBAAA,CAAa;AAAA,UAChC,MAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,UACA,QAAA;AAAA,UACA,cAAA;AAAA,UACA,qBAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA;AAGrB,QAAA,UAAA,CAAW,aAAA,CAAc;AAAA,UACvB,KAAA,EAAO,iBAAA;AAAA,UACP,IAAA,EAAM;AAAA,SACP,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DatabaseService,\n resolvePackagePath,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport type { AppConfig } from '@backstage/config';\nimport helmet from 'helmet';\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport {\n createStaticAssetMiddleware,\n findStaticAssets,\n StaticAssetsStore,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n CACHE_CONTROL_REVALIDATE_CACHE,\n} from '../lib/headers';\nimport type { ConfigSchema } from '@backstage/config-loader';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { injectConfig, readFrontendConfig } from '../lib/config';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\n/**\n * @internal\n */\nexport interface RouterOptions {\n config: RootConfigService;\n logger: LoggerService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database: DatabaseService;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n *\n * Provides a ConfigSchema.\n *\n */\n schema?: ConfigSchema;\n}\n\n/**\n * @internal\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n appPackageName,\n staticFallbackHandler,\n auth,\n httpAuth,\n schema,\n } = options;\n\n const disableConfigInjection = config.getOptionalBoolean(\n 'app.disableConfigInjection',\n );\n const disableStaticFallbackCache = config.getOptionalBoolean(\n 'app.disableStaticFallbackCache',\n );\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n if (process.env.NODE_ENV === 'production') {\n logger.error(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n }\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n const appConfigs = disableConfigInjection\n ? undefined\n : await readFrontendConfig({\n config,\n appDistDir,\n env: process.env,\n schema,\n });\n\n const assetStore = !disableStaticFallbackCache\n ? await StaticAssetsStore.create({\n logger,\n database: options.database,\n })\n : undefined;\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n const publicDistDir = resolvePath(appDistDir, 'public');\n\n const enablePublicEntryPoint = await fs.pathExists(publicDistDir);\n\n if (enablePublicEntryPoint) {\n logger.info(\n `App is running in protected mode, serving public content from ${publicDistDir}`,\n );\n\n const publicRouter = Router();\n\n publicRouter.use(async (req, res, next) => {\n try {\n const credentials = await httpAuth.credentials(req, {\n allow: ['user', 'service', 'none'],\n allowLimitedAccess: true,\n });\n\n if (credentials.principal.type === 'none') {\n next();\n } else {\n next('router');\n }\n } catch {\n // If we fail to authenticate, make sure the session cookie is cleared\n // and continue as unauthenticated. If the user is logged in they will\n // immediately be redirected back to the protected app via the POST.\n await httpAuth.issueUserCookie(res, {\n credentials: await auth.getNoneCredentials(),\n });\n next();\n }\n });\n\n publicRouter.post(\n '*',\n express.urlencoded({ extended: true }),\n async (req, res, next) => {\n if (req.body.type === 'sign-in') {\n const credentials = await auth.authenticate(req.body.token);\n\n if (!auth.isPrincipal(credentials, 'user')) {\n throw new AuthenticationError('Invalid token, not a user');\n }\n\n await httpAuth.issueUserCookie(res, {\n credentials,\n });\n\n // Resume as if it was a GET request towards the outer protected router, serving index.html\n req.method = 'GET';\n next('router');\n } else {\n throw new InputError(\n 'Invalid POST request to app-backend wildcard endpoint',\n );\n }\n },\n );\n\n publicRouter.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'public' }),\n rootDir: publicDistDir,\n assetStore: assetStore?.withNamespace('public'),\n appConfigs, // TODO(Rugvip): We should not be including the full config here\n }),\n );\n\n router.use(publicRouter);\n }\n\n router.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'main' }),\n rootDir: appDistDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n }),\n );\n\n return router;\n}\n\nasync function createEntryPointRouter({\n logger,\n rootDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n}: {\n logger: LoggerService;\n rootDir: string;\n assetStore?: StaticAssetsStore;\n staticFallbackHandler?: express.Handler;\n appConfigs?: AppConfig[];\n}) {\n const staticDir = resolvePath(rootDir, 'static');\n\n const injectResult =\n appConfigs &&\n (await injectConfig({ appConfigs, logger, rootDir, staticDir }));\n\n const router = Router();\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(staticDir, {\n setHeaders: (res, path) => {\n if (injectResult?.injectedPath === path) {\n res.setHeader('Cache-Control', CACHE_CONTROL_REVALIDATE_CACHE);\n } else {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n }\n },\n }),\n );\n\n if (assetStore) {\n const assets = await findStaticAssets(staticDir);\n await assetStore.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await assetStore.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(assetStore));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use((_req: Request, res: Response) => {\n res.status(404).end();\n });\n\n router.use('/static', staticRouter);\n\n const rootRouter = Router();\n rootRouter.use((req, _res, next) => {\n // Make sure / and /index.html are handled by the HTML5 route below\n if (req.path === '/' || req.path === '/index.html') {\n next('router');\n } else {\n next();\n }\n });\n rootRouter.use(\n express.static(rootDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.use(rootRouter);\n\n // HTML5 routing\n router.get('/*', (_req, res) => {\n if (injectResult?.indexHtmlContent) {\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n res.send(injectResult.indexHtmlContent);\n } else {\n res.sendFile(resolvePath(rootDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n }\n });\n\n return router;\n}\n"],"names":["resolvePackagePath","resolvePath","fs","Router","readFrontendConfig","StaticAssetsStore","helmet","express","AuthenticationError","InputError","injectConfig","CACHE_CONTROL_REVALIDATE_CACHE","CACHE_CONTROL_MAX_CACHE","findStaticAssets","createStaticAssetMiddleware","CACHE_CONTROL_NO_CACHE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkGA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,qBAAA;AAAA,IACA,IAAA;AAAA,IACA,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AAA,KACR,MAAA;AACL,MAAK,IAAA,EAAA;AAAA;AACP,GACD,CAAA;AACD,EAAW,UAAA,CAAA,GAAA;AAAA,IACTI,wBAAA,CAAQ,OAAO,OAAS,EAAA;AAAA,MACtB,UAAA,EAAY,CAAC,GAAA,EAAK,IAAS,KAAA;AAGzB,QAAA,IACGA,yBAAQ,MAAO,CAAA,IAAA,CAAyB,MAAO,CAAA,IAAI,MAAM,WAC1D,EAAA;AACA,UAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBQ,8BAAsB,CAAA;AAAA;AACvD;AACF,KACD;AAAA,GACH;AACA,EAAA,MAAA,CAAO,IAAI,UAAU,CAAA;AAGrB,EAAA,MAAA,CAAO,GAAI,CAAA,IAAA,EAAM,CAAC,IAAA,EAAM,GAAQ,KAAA;AAC9B,IAAA,IAAI,cAAc,gBAAkB,EAAA;AAClC,MAAI,GAAA,CAAA,SAAA,CAAU,gBAAgB,0BAA0B,CAAA;AACxD,MAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBA,8BAAsB,CAAA;AACrD,MAAI,GAAA,CAAA,IAAA,CAAK,aAAa,gBAAgB,CAAA;AAAA,KACjC,MAAA;AACL,MAAA,GAAA,CAAI,QAAS,CAAAd,YAAA,CAAY,OAAS,EAAA,YAAY,CAAG,EAAA;AAAA,QAC/C,OAAS,EAAA;AAAA;AAAA;AAAA,UAGP,eAAiB,EAAAc;AAAA;AACnB,OACD,CAAA;AAAA;AACH,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DatabaseService,\n resolvePackagePath,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport type { AppConfig } from '@backstage/config';\nimport helmet from 'helmet';\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport {\n createStaticAssetMiddleware,\n findStaticAssets,\n StaticAssetsStore,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n CACHE_CONTROL_REVALIDATE_CACHE,\n} from '../lib/headers';\nimport type { ConfigSchema } from '@backstage/config-loader';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { injectConfig, readFrontendConfig } from '../lib/config';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\n/**\n * @internal\n */\nexport interface RouterOptions {\n config: RootConfigService;\n logger: LoggerService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database: DatabaseService;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n *\n * Provides a ConfigSchema.\n *\n */\n schema?: ConfigSchema;\n}\n\n/**\n * @internal\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n appPackageName,\n staticFallbackHandler,\n auth,\n httpAuth,\n schema,\n } = options;\n\n const disableConfigInjection = config.getOptionalBoolean(\n 'app.disableConfigInjection',\n );\n const disableStaticFallbackCache = config.getOptionalBoolean(\n 'app.disableStaticFallbackCache',\n );\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n if (process.env.NODE_ENV === 'production') {\n logger.error(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n }\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n const appConfigs = disableConfigInjection\n ? undefined\n : await readFrontendConfig({\n config,\n appDistDir,\n env: process.env,\n schema,\n });\n\n const assetStore = !disableStaticFallbackCache\n ? await StaticAssetsStore.create({\n logger,\n database: options.database,\n })\n : undefined;\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n const publicDistDir = resolvePath(appDistDir, 'public');\n\n const enablePublicEntryPoint = await fs.pathExists(publicDistDir);\n\n if (enablePublicEntryPoint) {\n logger.info(\n `App is running in protected mode, serving public content from ${publicDistDir}`,\n );\n\n const publicRouter = Router();\n\n publicRouter.use(async (req, res, next) => {\n try {\n const credentials = await httpAuth.credentials(req, {\n allow: ['user', 'service', 'none'],\n allowLimitedAccess: true,\n });\n\n if (credentials.principal.type === 'none') {\n next();\n } else {\n next('router');\n }\n } catch {\n // If we fail to authenticate, make sure the session cookie is cleared\n // and continue as unauthenticated. If the user is logged in they will\n // immediately be redirected back to the protected app via the POST.\n await httpAuth.issueUserCookie(res, {\n credentials: await auth.getNoneCredentials(),\n });\n next();\n }\n });\n\n publicRouter.post(\n '*',\n express.urlencoded({ extended: true }),\n async (req, res, next) => {\n if (req.body.type === 'sign-in') {\n const credentials = await auth.authenticate(req.body.token);\n\n if (!auth.isPrincipal(credentials, 'user')) {\n throw new AuthenticationError('Invalid token, not a user');\n }\n\n await httpAuth.issueUserCookie(res, {\n credentials,\n });\n\n // Resume as if it was a GET request towards the outer protected router, serving index.html\n req.method = 'GET';\n next('router');\n } else {\n throw new InputError(\n 'Invalid POST request to app-backend wildcard endpoint',\n );\n }\n },\n );\n\n publicRouter.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'public' }),\n rootDir: publicDistDir,\n assetStore: assetStore?.withNamespace('public'),\n appConfigs, // TODO(Rugvip): We should not be including the full config here\n }),\n );\n\n router.use(publicRouter);\n }\n\n router.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'main' }),\n rootDir: appDistDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n }),\n );\n\n return router;\n}\n\nasync function createEntryPointRouter({\n logger,\n rootDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n}: {\n logger: LoggerService;\n rootDir: string;\n assetStore?: StaticAssetsStore;\n staticFallbackHandler?: express.Handler;\n appConfigs?: AppConfig[];\n}) {\n const staticDir = resolvePath(rootDir, 'static');\n\n const injectResult =\n appConfigs &&\n (await injectConfig({ appConfigs, logger, rootDir, staticDir }));\n\n const router = Router();\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(staticDir, {\n setHeaders: (res, path) => {\n if (injectResult?.injectedPath === path) {\n res.setHeader('Cache-Control', CACHE_CONTROL_REVALIDATE_CACHE);\n } else {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n }\n },\n }),\n );\n\n if (assetStore) {\n const assets = await findStaticAssets(staticDir);\n await assetStore.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await assetStore.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(assetStore));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use((_req: Request, res: Response) => {\n res.status(404).end();\n });\n\n router.use('/static', staticRouter);\n\n const rootRouter = Router();\n rootRouter.use((req, _res, next) => {\n // Make sure / and /index.html are handled by the HTML5 route below\n if (req.path === '/' || req.path === '/index.html') {\n next('router');\n } else {\n next();\n }\n });\n rootRouter.use(\n express.static(rootDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.use(rootRouter);\n\n // HTML5 routing\n router.get('/*', (_req, res) => {\n if (injectResult?.indexHtmlContent) {\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n res.send(injectResult.indexHtmlContent);\n } else {\n res.sendFile(resolvePath(rootDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n }\n });\n\n return router;\n}\n"],"names":["resolvePackagePath","resolvePath","fs","Router","readFrontendConfig","StaticAssetsStore","helmet","express","AuthenticationError","InputError","injectConfig","CACHE_CONTROL_REVALIDATE_CACHE","CACHE_CONTROL_MAX_CACHE","findStaticAssets","createStaticAssetMiddleware","CACHE_CONTROL_NO_CACHE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkGA,eAAsB,aACpB,OAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,qBAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,yBAAyB,MAAA,CAAO,kBAAA;AAAA,IACpC;AAAA,GACF;AACA,EAAA,MAAM,6BAA6B,MAAA,CAAO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ACP;AAAA,EACF,CAAC,CAAA;AACD,EAAA,UAAA,CAAW,GAAA;AAAA,IACTI,wBAAA,CAAQ,OAAO,OAAA,EAAS;AAAA,MACtB,UAAA,EAAY,CAAC,GAAA,EAAK,IAAA,KAAS;AAGzB,QAAA,IACGA,yBAAQ,MAAA,CAAO,IAAA,CAAyB,MAAA,CAAO,IAAI,MAAM,WAAA,EAC1D;AACA,UAAA,GAAA,CAAI,SAAA,CAAU,iBAAiBQ,8BAAsB,CAAA;AAAA,QACvD;AAAA,MACF;AAAA,KACD;AAAA,GACH;AACA,EAAA,MAAA,CAAO,IAAI,UAAU,CAAA;AAGrB,EAAA,MAAA,CAAO,GAAA,CAAI,IAAA,EAAM,CAAC,IAAA,EAAM,GAAA,KAAQ;AAC9B,IAAA,IAAI,cAAc,gBAAA,EAAkB;AAClC,MAAA,GAAA,CAAI,SAAA,CAAU,gBAAgB,0BAA0B,CAAA;AACxD,MAAA,GAAA,CAAI,SAAA,CAAU,iBAAiBA,8BAAsB,CAAA;AACrD,MAAA,GAAA,CAAI,IAAA,CAAK,aAAa,gBAAgB,CAAA;AAAA,IACxC,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,QAAA,CAASd,YAAA,CAAY,OAAA,EAAS,YAAY,CAAA,EAAG;AAAA,QAC/C,OAAA,EAAS;AAAA;AAAA;AAAA,UAGP,eAAA,EAAiBc;AAAA;AACnB,OACD,CAAA;AAAA,IACH;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-app-backend",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "A Backstage backend plugin that serves the Backstage frontend app",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",
@@ -61,12 +61,12 @@
61
61
  "test": "backstage-cli package test"
62
62
  },
63
63
  "dependencies": {
64
- "@backstage/backend-plugin-api": "^1.4.1",
64
+ "@backstage/backend-plugin-api": "^1.4.2",
65
65
  "@backstage/config": "^1.3.3",
66
66
  "@backstage/config-loader": "^1.10.2",
67
67
  "@backstage/errors": "^1.2.7",
68
- "@backstage/plugin-app-node": "^0.1.35",
69
- "@backstage/plugin-auth-node": "^0.6.5",
68
+ "@backstage/plugin-app-node": "^0.1.36",
69
+ "@backstage/plugin-auth-node": "^0.6.6",
70
70
  "@backstage/types": "^1.2.1",
71
71
  "express": "^4.17.1",
72
72
  "express-promise-router": "^4.1.0",
@@ -79,10 +79,10 @@
79
79
  "yn": "^4.0.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@backstage/backend-app-api": "^1.2.5",
83
- "@backstage/backend-defaults": "^0.11.1",
84
- "@backstage/backend-test-utils": "^1.7.0",
85
- "@backstage/cli": "^0.33.1",
82
+ "@backstage/backend-app-api": "^1.2.6",
83
+ "@backstage/backend-defaults": "^0.12.0",
84
+ "@backstage/backend-test-utils": "^1.8.0",
85
+ "@backstage/cli": "^0.34.0",
86
86
  "@backstage/types": "^1.2.1",
87
87
  "@types/express": "^4.17.6",
88
88
  "@types/supertest": "^2.0.8",