packages/cors/lib/cors.js
async function isValidOrigin(origin, sourceOrigin) {
    // This will fetch the caches from https://cdn.ampproject.org/caches.json the first time it's
    // called. Subsequent calls will receive a cached version.
    const officialCacheList = await caches.list();
    // Calculate the cache specific origin
    const cacheSubdomain = `https://${await createCacheSubdomain(sourceOrigin)}.`;
    // Check all caches listed on ampproject.org
    for (const cache of officialCacheList) {
      const cachedOrigin = cacheSubdomain + cache.cacheDomain;
      if (origin === cachedOrigin) {
        return true;
      }
    }
    return false;
  }
async function isValidOrigin(origin, sourceOrigin) {
    // This will fetch the caches from https://cdn.ampproject.org/caches.json the first time it's
    // called. Subsequent calls will receive a cached version.
    const officialCacheList = await caches.list();
    // Calculate the cache specific origin
    const cacheSubdomain = `https://${await createCacheSubdomain(sourceOrigin)}.`;
    // Check all caches listed on ampproject.org
    for (const cache of officialCacheList) {
      const cachedOrigin = cacheSubdomain + cache.cacheDomain;
      if (origin === cachedOrigin) {
        return true;
      }
    }
    return false;
  }
async function isValidOrigin ( origin , sourceOrigin ) { // This will fetch the caches from https://cdn.ampproject.org/caches.json the first time it's // called. Subsequent calls will receive a cached version. const officialCacheList = await caches . list ( ) ; // Calculate the cache specific origin const cacheSubdomain = ` ${ await createCacheSubdomain ( sourceOrigin ) } ` ; // Check all caches listed on ampproject.org for ( const cache of officialCacheList ) { const cachedOrigin = cacheSubdomain + cache . cacheDomain ; if ( origin === cachedOrigin ) { return true ; } } return false ; }
Checks whether the given origin is a valid AMP cache.

@param {String} origin
@return {boolean} true if origin is valid
@private
Checks whether the given origin is a valid AMP cache .