// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_WEBAPPS_COMMON_WEB_APP_ID_H_
#define COMPONENTS_WEBAPPS_COMMON_WEB_APP_ID_H_

#include <string>

#include "components/webapps/common/manifest_id.h"

namespace webapps {

// An example AppId id is "fedbieoalmbobgfjapopkghdmhgncnaa", and is derived
// from the web app's ManifestId (see below).
// This id starts with a URL which is then:
// - hashed using SHA256,
// - hashed using SHA256 again,
// - hex encoded into the characters 0-f,
// - transformed to only use alpha characters between a-p (inclusive).
// This algorithm was designed for historical reasons and needs to stay this way
// for backwards compatibility.
using AppId = std::string;

// This is computed from the manifest's `start_url` and `id` members:
// https://www.w3.org/TR/appmanifest/#id-member. This can be hashed using
// GenerateAppIdFromManifestId in
// chrome/browser/web_applications/web_app_helpers.h to produce an AppId above.
// NOTE: Prefer ManifestId::Create() for safe creation.
// This constructor enforces validity via a hard CHECK.
using ManifestId = ValidManifestId;

}  // namespace webapps

#endif  // COMPONENTS_WEBAPPS_COMMON_WEB_APP_ID_H_
