🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@miaaguard/ui-core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miaaguard/ui-core

Core library for miaa UI widgets

latest
Source
npmnpm
Version
22.3.1
Version published
Maintainers
1
Created
Source

@miaaguard/ui-core

This package offers a JavaScript SDK to facilitate integration with miaa Guards CloudWare components.

Installation

Install using yarn or npm

$ npm i @miaaguard/ui-core

Auth

import { auth } from '@miaaguard/ui-core';

auth.init({
    authority: '<miaa PolicyGate endpoint>',
    client_id: 'your login client ID',
    audiences: {
        '__default__': {
            scope: 'openid email profile'
        }
    }
});

auth.login();

Settings

The following settings can be passed at initialization time

NameRequiredTypeDescription
authority✓stringThe base URI of your miaa PolicyGate instance
client_id✓stringThe id of the login client used to connect to PolicyGate
audiences✓objectOIDC audience configuration object

Additionally, the settings may contain any of the settings defined by the OIDC client library. These settings can be applied generally, for all audiences, by adding them to the root of the settings object. Alternatively, settings can be overridden per audience by defining them on the corresponding object, as shown in the example below:

auth.init({
    post_logout_redirect_uri: 'https://your-redirect.uri',
    audiences: {
        '__default__': {
            scope: 'openid email profile'
        },
        foobar: {
            scope: 'openid',
            post_logout_redirect_uri: 'https://your-specific-redirect.uri/for-foobar'
        }
    }
})

In the example above, the default audience will use https://your-redirect.uri as its post_logout_redirect_uri, while the foobar audience will use https://your-specific-redirect.uri/for-foobar.

Methods

NameReturnsDescription
init(settings)PromiseConfigures the authorization module and will log the user in if they have a valid session with PolicyGate
login(redirect?: boolean, state?: any)PromiseStarts the login process via popup (default) or redirect. Default values are "redirect": false and "state": undefined. The state can be any data you want to associate with the request.
logout(silent?: boolean)PromiseStarts the logout process via the popup flow. If true is passed, the logout process will be handled via a hidden iframe
isLoggedIn()PromiseReturns true if the user has a valid session with PolicyGate
getAccessToken(audience?: string)PromiseReturns the access token corresponding to the audience. If no audience is specified, the default audience is assumed
getUser()PromiseReturns the profile information stored in the identity token of the default audience

ProfileConnectProxy

import { ProfileConnectProxy } from '@miaaguard/ui-core';

const profile = new ProfileConnectProxy({
    baseUri: '<miaa ProfileConnect API endpoint>',
    getBearerHeader: () => return new Headers({ Authorization: 'Bearer <JWT>' }),
    profileType: 'profile'
});

// retrieve the profile
profile.get('id')
    .then(profile => console.log(profile));

// save a profile
profile.save('id', { name: 'John Doe' })
    .then(profile => console.log(profile));

Settings

The following settings can be passed at construction time

NameRequiredTypeDescription
baseUri✓stringThe base URI of your miaa cloudware instance
getBearerHeaderfunctionA function returning a (Promise for a) Headers object containing at least an Authorization header. Defaults to a Headers object with a Bearer Authorization header with the value of the access token for the default audience
profileTypestringThe type of the profile you are creating a Proxy for. Defaults to profile

Methods

The following methods are available on a Proxy instance. All methods return a Promise.

NameReturnsDescription
get(id)PromiseRetrieves the profile for the specified id
save(id, data)PromiseSaves the data to the profile for the specified id and returns the updated profile

FAQs

Package last updated on 08 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts