DiscoveryService API Reference

Functions

json_mdq_get(string)

An MDQ client using fetch (https://fetch.spec.whatwg.org/). The function returns a Promise which must be resolved before the object can be accessed.

Arguments:
  • string (mdq_url) – an entityID (must be urlencoded) or sha1 id
  • string – a URL of an MDQ service incl trailing slash - eg https://md.thiss.io/entities/
Returns:

Promise – a Promise resolving an Object observing the discojson schema

parse_qs(paramsArray)

Parse an array of querystring components into an Object

Returns:an object with each k,v-pair as properties.
ds_response_url(Object)

Create a SAML discovery service protocol response URL from the entity_id property of the entity object and the return and returnIDParam (if present) of the params object. Combine with a base URL to form a full discovery service response.

Arguments:
  • Object (params) – a discojson entity
  • Object – an object from which ‘returnIDParams’ and ‘return’ will be used
Returns:

string – a query string

Classes

class DiscoveryService(function (entity_id) {}|string, string|PersistenceService, string)

A DiscoveryService class representing the business logic of a SAML disocvery service.

The constructor takes 3 parameters:

Arguments:
  • function (entity_id) {}|string (mdq) – a callable or a URL to be used for MDQ-style lookups of entity objects.
  • string|PersistenceService (persistence) – the URL of a persistence service or an instance of the PersistanceService
  • string (context) – the default context identifier
DiscoveryService.DiscoveryService

The constructor takes 3 parameters:

DiscoveryService.do_saml_discovery_response(string, (persist))

The main entrypoint of the class. Performs the following actions in a Promise-chain: 1. fetches the entity from the persistence service 2. performs an MDQ lookup if the entity was not found 3. returns an item (entity+last_used timestamp)

Arguments:
  • string (entity_id) – the entityID of the SAML identity provider
  • (persist) – [boolean] set to true (default) to persist the discovery metadata
DiscoveryService.pin(string)

Shorthand for do_saml_discovery_response. Convenience method for the case when you want to pre-populate (aka pin) an identity provider choice. The idea is to call this function, resolve the Promise but not redirect the user.

Arguments:
  • string (entity_id) – the entityID of the SAML identity provider
DiscoveryService.remove(string)

Removes an entity by calling the remove function of the underlying PersistenceService instance.

Arguments:
  • string (entity_id) – the entityID of the SAML identity provider to be removed
DiscoveryService.saml_discovery_response(string)

Call do_saml_discovery_response and then set window.top.location.href to the discovery response URL This assumes that the code is running on the discovery service URL so the relative redirect works.

Arguments:
  • string (entity_id) – an entityID of the chosen SAML identity provider.
DiscoveryService.with_items(function (entity) {})

Preform callback on all entities in the persistence-service.

Arguments:
  • function (entity) {} (callback) – a callable taking a single entity parameter