{"version":3,"sources":["jsdelivr-header.js","/npm/@octokit/app@16.1.2/dist-src/index.js","/npm/@octokit/app@16.1.2/dist-src/version.js","/npm/@octokit/app@16.1.2/dist-src/webhooks.js","/npm/@octokit/app@16.1.2/dist-src/each-installation.js","/npm/@octokit/app@16.1.2/dist-src/get-installation-octokit.js","/npm/@octokit/app@16.1.2/dist-src/each-repository.js","/npm/@octokit/app@16.1.2/dist-src/get-installation-url.js","/npm/@octokit/app@16.1.2/dist-src/middleware/node/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,kBCNoB,gBAAmB,wCAC9B,mBAAqB,2BACrB,aAAgB,qBCFzB,IAAM,QAAU,gBCAP,kBAAqB,2BACrB,8BAAiC,uCACjC,aAAgB,oBACzB,SAAS,SAAS,EAAY,GAC5B,OAAO,IAAI,SAAS,CAClB,OAAQ,EAAQ,OAChB,UAAW,MAAO,IAChB,KAAM,iBAAkB,EAAM,UAAkD,iBAA/B,EAAM,QAAQ,aAA2B,CACxF,MAAM,EAAW,IAAI,EAAW,YAAY,CAC1C,aAAc,0BACd,KAAM,CACJ,OAAQ,yDAGZ,MAAO,IACF,EACH,QAAS,EAEb,CACA,MAAM,EAAiB,EAAM,QAAQ,aAAa,GAC5C,QAAgB,EAAW,KAAK,CACpC,KAAM,eACN,iBACA,QAAQ,GACC,IAAI,EAAK,QAAQ,YAAY,IAC/B,EAAK,eACR,aAAc,cAEZ,KAAM,IACD,EACH,sBASV,OAHA,EAAQ,KAAK,OAAO,WAAY,IAC9B,EAAS,QAAQ,qBAAuB,EAAM,EAAA,IAEzC,IACF,EACH,UACF,GAGN,QC7CS,wBAA2B,wDCA3B,mBAAqB,oBAC9B,eAAe,uBAAuB,EAAK,GACzC,OAAO,EAAI,QAAQ,KAAK,CACtB,KAAM,eACN,iBACA,OAAA,CAAQ,GACN,MAAM,EAAU,IACX,EAAK,eACR,aAAc,eACT,KAAM,IAAK,EAAM,mBAExB,OAAO,IAAI,EAAK,QAAQ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A,IAAe,GACb,MAAM,IACD,KACA,EAAK,IAEZ,EAGJ,CACA,QAEA,SAEA,MACA,uBACA,iBACA,eACA,mBACA,IACA,WAAA,CAAY,GACV,MAAM,EAAU,EAAQ,SAAW,YAC7B,EAAc,OAAO,OACzB,CACE,MAAO,EAAQ,MACf,WAAY,EAAQ,YAEtB,EAAQ,MAAQ,CACd,SAAU,EAAQ,MAAM,SACxB,aAAc,EAAQ,MAAM,cAC1B,CAAC,GAED,EAAiB,CACrB,aAAc,eACd,KAAM,GAEJ,QAAS,QAAkC,IAAhB,EAAQ,MACrC,EAAe,IAAM,EAAQ,KAE/B,KAAK,QAAU,IAAI,EAAQ,GAC3B,KAAK,IAAM,OAAO,OAChB,CACE,MAAO,OAEP,KAAM,OAEN,KAAM,QAAQ,KAAK,KAAK,SACxB,MAAO,QAAQ,MAAM,KAAK,UAE5B,EAAQ,KAEN,EAAQ,SACV,KAAK,SAAW,SAAS,KAAK,QAAS,EAAQ,UAE/C,OAAO,eAAe,KAAM,WAAY,CACtC,GAAA,GACE,MAAM,IAAI,MAAM,yCAClB,IAGA,EAAQ,MACV,KAAK,MAAQ,IAAI,SAAS,IACrB,EAAQ,MACX,WAAY,aACZ,YAGF,OAAO,eAAe,KAAM,QAAS,CACnC,GAAA,GACE,MAAM,IAAI,MACR,yEAEJ,IAGJ,KAAK,uBAAyB,uBAAuB,KACnD,KACA,MAEF,KAAK,iBAAmB,wBACtB,MAEF,KAAK,eAAiB,sBACpB,MAEF,KAAK,mBAAqB,0BAA0B,KACtD,U","file":"/npm/@octokit/app@16.1.2/dist-node/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@octokit/app@16.1.2/dist-node/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { Octokit as OctokitCore } from \"@octokit/core\";\nimport { createAppAuth } from \"@octokit/auth-app\";\nimport { OAuthApp } from \"@octokit/oauth-app\";\nimport { VERSION } from \"./version.js\";\nimport { webhooks } from \"./webhooks.js\";\nimport { eachInstallationFactory } from \"./each-installation.js\";\nimport { eachRepositoryFactory } from \"./each-repository.js\";\nimport { getInstallationOctokit } from \"./get-installation-octokit.js\";\nimport { getInstallationUrlFactory } from \"./get-installation-url.js\";\nclass App {\n  static VERSION = VERSION;\n  static defaults(defaults) {\n    const AppWithDefaults = class extends this {\n      constructor(...args) {\n        super({\n          ...defaults,\n          ...args[0]\n        });\n      }\n    };\n    return AppWithDefaults;\n  }\n  octokit;\n  // @ts-ignore calling app.webhooks will throw a helpful error when options.webhooks is not set\n  webhooks;\n  // @ts-ignore calling app.oauth will throw a helpful error when options.oauth is not set\n  oauth;\n  getInstallationOctokit;\n  eachInstallation;\n  eachRepository;\n  getInstallationUrl;\n  log;\n  constructor(options) {\n    const Octokit = options.Octokit || OctokitCore;\n    const authOptions = Object.assign(\n      {\n        appId: options.appId,\n        privateKey: options.privateKey\n      },\n      options.oauth ? {\n        clientId: options.oauth.clientId,\n        clientSecret: options.oauth.clientSecret\n      } : {}\n    );\n    const octokitOptions = {\n      authStrategy: createAppAuth,\n      auth: authOptions\n    };\n    if (\"log\" in options && typeof options.log !== \"undefined\") {\n      octokitOptions.log = options.log;\n    }\n    this.octokit = new Octokit(octokitOptions);\n    this.log = Object.assign(\n      {\n        debug: () => {\n        },\n        info: () => {\n        },\n        warn: console.warn.bind(console),\n        error: console.error.bind(console)\n      },\n      options.log\n    );\n    if (options.webhooks) {\n      this.webhooks = webhooks(this.octokit, options.webhooks);\n    } else {\n      Object.defineProperty(this, \"webhooks\", {\n        get() {\n          throw new Error(\"[@octokit/app] webhooks option not set\");\n        }\n      });\n    }\n    if (options.oauth) {\n      this.oauth = new OAuthApp({\n        ...options.oauth,\n        clientType: \"github-app\",\n        Octokit\n      });\n    } else {\n      Object.defineProperty(this, \"oauth\", {\n        get() {\n          throw new Error(\n            \"[@octokit/app] oauth.clientId / oauth.clientSecret options are not set\"\n          );\n        }\n      });\n    }\n    this.getInstallationOctokit = getInstallationOctokit.bind(\n      null,\n      this\n    );\n    this.eachInstallation = eachInstallationFactory(\n      this\n    );\n    this.eachRepository = eachRepositoryFactory(\n      this\n    );\n    this.getInstallationUrl = getInstallationUrlFactory(this);\n  }\n}\nimport { createNodeMiddleware } from \"./middleware/node/index.js\";\nexport {\n  App,\n  createNodeMiddleware\n};\n","const VERSION = \"16.1.2\";\nexport {\n  VERSION\n};\n","import { createAppAuth } from \"@octokit/auth-app\";\nimport { createUnauthenticatedAuth } from \"@octokit/auth-unauthenticated\";\nimport { Webhooks } from \"@octokit/webhooks\";\nfunction webhooks(appOctokit, options) {\n  return new Webhooks({\n    secret: options.secret,\n    transform: async (event) => {\n      if (!(\"installation\" in event.payload) || typeof event.payload.installation !== \"object\") {\n        const octokit2 = new appOctokit.constructor({\n          authStrategy: createUnauthenticatedAuth,\n          auth: {\n            reason: `\"installation\" key missing in webhook event payload`\n          }\n        });\n        return {\n          ...event,\n          octokit: octokit2\n        };\n      }\n      const installationId = event.payload.installation.id;\n      const octokit = await appOctokit.auth({\n        type: \"installation\",\n        installationId,\n        factory(auth) {\n          return new auth.octokit.constructor({\n            ...auth.octokitOptions,\n            authStrategy: createAppAuth,\n            ...{\n              auth: {\n                ...auth,\n                installationId\n              }\n            }\n          });\n        }\n      });\n      octokit.hook.before(\"request\", (options2) => {\n        options2.headers[\"x-github-delivery\"] = event.id;\n      });\n      return {\n        ...event,\n        octokit\n      };\n    }\n  });\n}\nexport {\n  webhooks\n};\n","import { composePaginateRest } from \"@octokit/plugin-paginate-rest\";\nimport { getInstallationOctokit } from \"./get-installation-octokit.js\";\nfunction eachInstallationFactory(app) {\n  return Object.assign(eachInstallation.bind(null, app), {\n    iterator: eachInstallationIterator.bind(null, app)\n  });\n}\nasync function eachInstallation(app, callback) {\n  const i = eachInstallationIterator(app)[Symbol.asyncIterator]();\n  let result = await i.next();\n  while (!result.done) {\n    await callback(result.value);\n    result = await i.next();\n  }\n}\nfunction eachInstallationIterator(app) {\n  return {\n    async *[Symbol.asyncIterator]() {\n      const iterator = composePaginateRest.iterator(\n        app.octokit,\n        \"GET /app/installations\"\n      );\n      for await (const { data: installations } of iterator) {\n        for (const installation of installations) {\n          const installationOctokit = await getInstallationOctokit(\n            app,\n            installation.id\n          );\n          yield { octokit: installationOctokit, installation };\n        }\n      }\n    }\n  };\n}\nexport {\n  eachInstallation,\n  eachInstallationFactory,\n  eachInstallationIterator\n};\n","import { createAppAuth } from \"@octokit/auth-app\";\nasync function getInstallationOctokit(app, installationId) {\n  return app.octokit.auth({\n    type: \"installation\",\n    installationId,\n    factory(auth) {\n      const options = {\n        ...auth.octokitOptions,\n        authStrategy: createAppAuth,\n        ...{ auth: { ...auth, installationId } }\n      };\n      return new auth.octokit.constructor(options);\n    }\n  });\n}\nexport {\n  getInstallationOctokit\n};\n","import { composePaginateRest } from \"@octokit/plugin-paginate-rest\";\nfunction eachRepositoryFactory(app) {\n  return Object.assign(eachRepository.bind(null, app), {\n    iterator: eachRepositoryIterator.bind(null, app)\n  });\n}\nasync function eachRepository(app, queryOrCallback, callback) {\n  const i = eachRepositoryIterator(\n    app,\n    callback ? queryOrCallback : void 0\n  )[Symbol.asyncIterator]();\n  let result = await i.next();\n  while (!result.done) {\n    if (callback) {\n      await callback(result.value);\n    } else {\n      await queryOrCallback(result.value);\n    }\n    result = await i.next();\n  }\n}\nfunction singleInstallationIterator(app, installationId) {\n  return {\n    async *[Symbol.asyncIterator]() {\n      yield {\n        octokit: await app.getInstallationOctokit(installationId)\n      };\n    }\n  };\n}\nfunction eachRepositoryIterator(app, query) {\n  return {\n    async *[Symbol.asyncIterator]() {\n      const iterator = query ? singleInstallationIterator(app, query.installationId) : app.eachInstallation.iterator();\n      for await (const { octokit } of iterator) {\n        const repositoriesIterator = composePaginateRest.iterator(\n          octokit,\n          \"GET /installation/repositories\"\n        );\n        for await (const { data: repositories } of repositoriesIterator) {\n          for (const repository of repositories) {\n            yield { octokit, repository };\n          }\n        }\n      }\n    }\n  };\n}\nexport {\n  eachRepository,\n  eachRepositoryFactory,\n  eachRepositoryIterator\n};\n","function getInstallationUrlFactory(app) {\n  let installationUrlBasePromise;\n  return async function getInstallationUrl(options = {}) {\n    if (!installationUrlBasePromise) {\n      installationUrlBasePromise = getInstallationUrlBase(app);\n    }\n    const installationUrlBase = await installationUrlBasePromise;\n    const installationUrl = new URL(installationUrlBase);\n    if (options.target_id !== void 0) {\n      installationUrl.pathname += \"/permissions\";\n      installationUrl.searchParams.append(\n        \"target_id\",\n        options.target_id.toFixed()\n      );\n    }\n    if (options.state !== void 0) {\n      installationUrl.searchParams.append(\"state\", options.state);\n    }\n    return installationUrl.href;\n  };\n}\nasync function getInstallationUrlBase(app) {\n  const { data: appInfo } = await app.octokit.request(\"GET /app\");\n  if (!appInfo) {\n    throw new Error(\"[@octokit/app] unable to fetch metadata for app\");\n  }\n  return `${appInfo.html_url}/installations/new`;\n}\nexport {\n  getInstallationUrlFactory\n};\n","import {\n  createNodeMiddleware as oauthNodeMiddleware,\n  sendNodeResponse,\n  unknownRouteResponse\n} from \"@octokit/oauth-app\";\nimport { createNodeMiddleware as webhooksNodeMiddleware } from \"@octokit/webhooks\";\nfunction noop() {\n}\nfunction createNodeMiddleware(app, options = {}) {\n  const log = Object.assign(\n    {\n      debug: noop,\n      info: noop,\n      warn: console.warn.bind(console),\n      error: console.error.bind(console)\n    },\n    options.log\n  );\n  const optionsWithDefaults = {\n    pathPrefix: \"/api/github\",\n    ...options,\n    log\n  };\n  const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {\n    path: optionsWithDefaults.pathPrefix + \"/webhooks\",\n    log\n  });\n  const oauthMiddleware = oauthNodeMiddleware(app.oauth, {\n    pathPrefix: optionsWithDefaults.pathPrefix + \"/oauth\"\n  });\n  return middleware.bind(\n    null,\n    optionsWithDefaults.pathPrefix,\n    webhooksMiddleware,\n    oauthMiddleware\n  );\n}\nasync function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) {\n  const { pathname } = new URL(request.url, \"http://localhost\");\n  if (pathname.startsWith(`${pathPrefix}/`)) {\n    if (pathname === `${pathPrefix}/webhooks`) {\n      webhooksMiddleware(request, response);\n    } else if (pathname.startsWith(`${pathPrefix}/oauth/`)) {\n      oauthMiddleware(request, response);\n    } else {\n      sendNodeResponse(unknownRouteResponse(request), response);\n    }\n    return true;\n  } else {\n    next?.();\n    return false;\n  }\n}\nexport {\n  createNodeMiddleware,\n  middleware\n};\n"]}