Introduction

Introduction

MetaKeep JS is a lightweight SDK that can be used in any JavaScript/TypeScript browser application. It can be used to integrate MetaKeep into your web applications, browser extensions, and more. Note that MetaKeep JS is not compatible with backend Node.js applications. Please use the APIs directly for backend applications.

Importing the library

Here's what a sample client-facing developer app might look like-

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    
    <!--import metakeep js-->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.js"
        		integrity="sha256-TWKHMFsH9J8Wxykmxb0MjkC0gt76XUFsQ8pRQfhJiAs="
    	    	crossorigin="anonymous">
    </script>
    
  </head>
</html>

❗️

Security Advisory

MetaKeep strongly recommends adding integrity="sha256-TWKHMFsH9J8Wxykmxb0MjkC0gt76XUFsQ8pRQfhJiAs=" tag to the <script> tag used to import MetaKeep's client JS library. An example is given above.

This ensures that even in the case when an end-user is in an insecure network, or if the CDN servers get compromised, the users are only running the javascript libraries officially signed by MetaKeep, mitigating any man-in-the-middle (MITM) attacks.

Alternatively, if you're using a node based build system/app framework, you should install MetaKeep SDK via npm. It looks something like-

$ npm install [email protected]

Initializing the library

Now that you've imported MetaKeep Client SDK, in the javascript, you need to first initialize the SDK with the appId. You can find appId in the developer console. Here's an example-

/* Init SDK */
const sdk = new MetaKeep({
    /* App id to configure UI */
    appId: "9cc98bca-da35-4da8-8f10-655b3e51cb9e",
});

If you already have a signed-in user, you can provide the user's email address when initializing the MetaKeep SDK. This provides a native logged-in user experience when your app and MetaKeep SDK are interacting. If the user's email is not provided, the SDK will ask the user for their email address when you perform the first SDK operation.

const sdk = new MetaKeep({
    /* App id to configure UI */
    appId: "9cc98bca-da35-4da8-8f10-655b3e51cb9e",
    /* Signed in user's email address */
    user: {
        email: "[email protected]"
    }
});

Configuration options

Here are all possible configuration options supported by the SDK

OptionDescriptionRequired
appIdThis is your public app ID that you get from the MetaKeep Developer Console. Use this to customize the look and feel of the MetaKeep wallet UI for your users.Yes
userUse this to provide the email address of the signed-in user to create a seamless UI experience.

If not specified, users will be asked for their identity.
No

© Copyright 2024, Passbird Research Inc.