npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@govflanders/mbp-embed-sdk

v0.0.3

Published

Library to integrate designated pages into Mijn Burgerprofiel (App and Web).

Downloads

49

Readme

Mijn Burgerprofiel Embed SDK

@govflanders/mbp-embed-sdk - a javascript library designed to integrate designated pages into Mijn Burgerprofiel.

ℹ️ TIP:
The preferred way to read this is on our documentation site.
That way, you are working with the most recent version, and you get additional information (like generated type definitions).

What is this?

Digitaal Vlaanderen provides and hosts 'Mijn Burgerprofiel' applications, both for the Flemish government and local municipalities. Citizens either download a mobile app or log in to burgerprofiel.be.

There are a lot of external data sources and functionality that would be useful to include in those applications. Historically, this meant either linking to external pages, or custom development to build API's and integrate that external content. A more flexible approach would be to embed externally hosted content directly by using either iframes (for web aplications), or webviews (for native apps).

To enable this efficiently and securely, @govflanders/mbp-embed-sdk was created. It defines an official interface to embed your content in Mijn Burgerprofiel applications (and interact with them).

Main Components

  1. Host Environment: The application that will integrate your content, which could be burgerprofiel.be (via iframes) or a mobile app (via webviews).
  2. Embedded Page: The content you wish to embed.
  3. MbpEmbedClient: The client interface/library responsible for managing communication between the embedded page and the host.

Diagram: connection/communication flow

┌──────────┐                  ┌───────────────┐                ┌───────────────┐
│   Host   │                  │ Embedded Page │                │ mbp-embed-sdk │
└────┬─────┘                  └───────┬───────┘                └───────┬───────┘
     ├────┐                           │                                │
     │    │ Listens for connections   │                                │
     │    │  [status = loading]       │                                │
     │◄───┘                           │                                │
     │       Load page                │    createMbpEmbedClient(id)    │
     ├───────────────────────────────►├───────────────────────────────►│
     │                                │◄───────────────────────────────┤
     │                                │                                │
     │                                │            connect()           │
     │                                ├───────────────────────────────►│
     │      <connection request>      │                                │
     │◄----------------------------------------------------------------┤
     │----┐                           │                                │
     │    │ Validate connection       │                                │
     │◄---┘                           │     <connection response>      │
     │----------------------------------------------------------------►│
     │                                │                           ┌────┤
     │                                │       Validate connection │    │
     │                                │                           └───►│
     │                                │      success | exception       │
     │                                │◄───────────────────────────────┤
     │                                │                                │
     │                                │    setStatusLoading(false)     │
     │                                ├───────────────────────────────►│
     │      <status request>          │                                │
     │◄----------------------------------------------------------------┤
     ├────┐                           │                                │
     │    │ Show embedded page        │                                │
     │    │  [status = ready]         │                                │
     │◄───┘                           │        <status updated>        │
     │----------------------------------------------------------------►│
     │                                │◄───────────────────────────────┤
     │                                │                                │

Setup

Onboarding

To get started, you need to go through a short onboarding process with Digitaal Vlaanderen.
Contact Mijn Burgerprofiel aansluitingen with the following details:

  • The URL (or URLs) of the page(s) you want to embed
  • Where/how you would like them embedded (City app, Burgerprofiel app, burgerprofiel.be)

Once the integration has been approved, you will receive a client ID to use with the SDK.

Installation

You can install the library from npm (it's publicly available):

npm install @govflanders/mbp-embed-sdk

Client creation and connection

Next, import the library and create a client in your project:

import { createMbpEmbedClient } from '@govflanders/mbp-embed-sdk';

const mbpClient = createMbpEmbedClient('your-client-id', {
  allowedHosts: [
    'https://*.burgerprofiel.be/*',
    'https://admin.vlaanderen.be/*',
  ],
});

Then, connect the client to the host environment (this is an asynchronous operation, so either use await or .then()):

try {
  await mbpClient.connect();
  console.log('Connection successful!');
} catch (e) {
  console.error('Failed to connect:', e);
}

Testing

When using the library in a standalone page, the client will time out after a while because there is no host environment to connect to.

To check if everything works correctly, you can use our embed preview tool.

Usage

ℹ️ NOTE:
For detailed usage, it's best to consult the official API documentation.
It is generated automatically based on the most recent version of the library.
Examples below are simplified and may not cover all available functionality.

UI Management

// Set the title
mbpClient.ui.setTitle('Mijn loket');

// Set loading status
mbpClient.ui.setStatusLoading(true);
setTimeout(() => {
  mbpClient.ui.setStatusLoading(false);
}, 1000);

// Make sure user confirms before leaving embed page
mbpClient.ui.enableExitConfirmation({
  title: 'Are you sure?',
  message: 'There are unsaved changes - you will lose them!',
});

// Set error status
mbpClient.ui.setStatusError({
  title: 'Oops',
  message: 'We are experiencing some problems, try again later!',
});

And more, see API documentation.

Navigation

// Navigate back
mbpClient.navigation.back();

// Open a new embed
mbpClient.navigation.openNewEmbed('https://my-embed-url.local/new-page');

// Open an external link
mbpClient.navigation.openExternal('https://www.vlaanderen.be');

And more, see API documentation.

Retrieving context/data from host

// Get tenant information
const tenant = await mbpClient.context.getTenant();
console.log(tenant.branding.primaryColor); // '#0070c0', for example

// In cases where user was directed from a specific product/context, you can retrieve that information.
const ipdcProduct = await mbpClient.context.getIpdcProduct();
console.log(ipdcProduct.title); // 'Jobbonus voor werknemers en ambtenaren', for example

And more, see API documentation.

Contributing

This library is managed and developed internally by Digitaal Vlaanderen. For technical questions, feedback or suggestions: please contact Mijn Burgerprofiel App team.

Internal developers can consult CONTRIBUTING.md for details on getting things set up.