src/app-registry.js
/**
 * Registers a given entry in the app registry.
 * @method registerApp
 * @param profile {SolidProfile}
 * @param app {AppRegistration}
 * @param webClient {SolidWebClient}
 * @return {Promise<SolidProfile>} Returns updated profile.
 */
Registers a given entry in the app registry.
Registers a given entry in the app registry .
function registerApp (profile, app, webClient) {
  if (!profile) {
    throw new Error('No profile provided')
  }
  if (!profile.isLoaded) {
    throw new Error('Profile is not loaded')
  }
  if (!app || !app.isValid()) {
    throw new Error('Invalid app registration')
  }
  return loadAppRegistry(profile, webClient)
    .then(function (profile) {
      if (app.isListed && !profile.hasAppRegistryPublic()) {
        return initAppRegistryPublic(profile, webClient)
      }
      if (!app.isListed && !profile.hasAppRegistryPrivate()) {
        return initAppRegistryPrivate(profile, webClient)
      }
      return profile
    })
    .then(function (profile) {
      return addToAppRegistry(profile, app, webClient)
    })
}
function registerApp ( profile , app , webClient ) { if ( ! profile ) { throw new Error ( 'No profile provided' ) } if ( ! profile . isLoaded ) { throw new Error ( 'Profile is not loaded' ) } if ( ! app || ! app . isValid ( ) ) { throw new Error ( 'Invalid app registration' ) } return loadAppRegistry ( profile , webClient ) . then ( function ( profile ) { if ( app . isListed && ! profile . hasAppRegistryPublic ( ) ) { return initAppRegistryPublic ( profile , webClient ) } if ( ! app . isListed && ! profile . hasAppRegistryPrivate ( ) ) { return initAppRegistryPrivate ( profile , webClient ) } return profile } ) . then ( function ( profile ) { return addToAppRegistry ( profile , app , webClient ) } ) }
Registers a given entry in the app registry.
Registers a given entry in the app registry .
// make sure app registry is loaded // Public App registry is needed, but doesn't exist. Create it. // Private App registry is needed, but doesn't exist. Create it. // Relevant App registry exists, proceed // Made sure the relevant app registry exists, and can now add to it