Mariana Anemone (BETA)

Mariana Anemone is a JavaScript SDK for embedding your app within the Mariana Tek Admin Application.

Note: This is an advanced feature. Please contact integrations@marianatek.com about pricing and availability.


Getting Started

1. Installation

Mariana Anemone can be installed using npm.

npm install @mariana-tek/anemone

2. Initialize the SDK

In order to begin using Mariana Anemone, you'll first need to initialize it with some basic configuration information. This method will return an object that should be used for all subsequent interaction with the SDK.

initialize(appId, clientId, baseUrl)

ParameterRequired?Description
appIdyesThe appId configured for your Embedded App.
clientIdyesThe clientID credential issued for your Embedded App.
baseUrlyesThe URL where your Embedded App is hosted.

Example usage:

import { initialize } from '@mariana-tek/anemone';
const mariana = initialize('my_app_id', 'my_client_id', 'https://example.com');

3. Create the Embedded Component

Establish a connection with the Admin Application to enable cross-domain communication.

createComponent()

Note: This function should be called only once within your application. Repeated calls will result in errors.

Example usage:

mariana.createComponent();

4. Authenticate the User

In order to start making authenticated requests against the Mariana Tek Admin API, you will need to obtain an access token. For standalone apps this is done using an OAuth flow, but for Embedded Apps you can simply use the getToken method from the SDK which will handle this for you. An active token for your App will be returned if the user has already accessed your application during the current session. If there is not an active token, the user will be redirected to begin the OAuth flow, and will be returned to the initial location once the flow is complete. We highly recommend using this method to obtain and retrieve stored access tokens to avoid common issues that arise when attempting to use third-party cookies in many browsers.

Example usage:

const bearerToken = mariana.auth.getToken();

You can find a complete example that puts all of these steps together on GitHub.


Full SDK Reference

Auth

getToken()

Retrieve a bearer token from the Admin Application that your embedded application can use to make authenticated requests for the current user. If this user does not yet have an active token for your application, this function will redirect the user to authenticate them and grant a new token, then return them to the point where they initiated the authentication flow with a usable token.

Example usage:

const token = await mariana.auth.getToken();

Admin API

getApiBaseUrl()

Returns the base URL for the API corresponding to the brand where your Embedded App has been accessed. This will be most useful if your application is used by multiple brands so that you can ensure you are using the correct endpoints for the context.

Example usage:

const baseUrl = mariana.api.getApiBaseUrl();

Navigation

goToClass(classId)

Redirect the user to the class roster page.

ParameterRequired?Description
classIdyesThe classId for the roster page where the user should be taken.

Example usage:

mariana.navigation.goToClass('123');

goToProfile(userId)

Redirect the user to a user profile page.

ParameterRequired?Description
userIdyesThe userId for the profile page where the user should be taken.

Example usage:

mariana.navigation.goToProfile('123');

redirect(url)

Redirect the Admin Application window to an external URL.

Example usage:

mariana.navigation.redirect('https://marianatek.com');