Skip to content
/ pontis Public

Painless Chrome extension authentication via AWS Amplify websites

License

Notifications You must be signed in to change notification settings

vocably/pontis

Repository files navigation

@vocably/pontis

npm package

@vocably/pontis makes login into Chrome extension via the AWS Amplify website easy-peasy.

Installation

npm install @vocably/pontis @aws-amplify/core --save

How to use

// website-app/index.js

import { Auth } from '@aws-amplify/auth';
import { AppAuthStorage } from '@vocably/pontis';

const extensionId = 'baocigmmhhdemijfjnjdidbkfgpgogmb';

Auth.configure({
  // The following line sets up the custom storage
  // which exchages auth tokens with the extension
  storage: new AppAuthStorage(extensionId),
  // and the rest of Auth params:
  region: 'eu-central-1',
  userPoolId: 'eu-central-1_uSErPooL',
  //etc...
});
// extension/service-worker.js
import { registerExtensionStorage } from '@vocably/pontis';
import { Auth } from '@aws-amplify/auth';

// The only function param is responsible for
// the storage type. It could be 'sync' or 'local'
const storage = registerExtensionStorage('sync');

Auth.configure({
  // The following line sets up the custom extension
  // storage which exchanges Auth tokens with the app
  storage: storage,
  // and the rest of Auth params:
  region: 'eu-central-1',
  userPoolId: 'eu-central-1_uSErPooL',
  //etc...
});

That's it.

Feel free to check @vocably/hermes if you love painless promise-based messages exchange between the extension and the app.

About

Painless Chrome extension authentication via AWS Amplify websites

Resources

License

Stars

Watchers

Forks

Packages

No packages published