Skip to content

External API

Toshimitsu Takahashi edited this page Feb 7, 2021 · 4 revisions

Config sender extension

Example

Sending the configuration after 10 seconds from browser started. If the sending processing does not wait for a moment, the other extensions may not have launched.

manifest.json

{
  "name": "AESR Configuration Sender",
  "version": "0.0.1",
  "description": "Config sender",
  "short_name": "AESR Sender",
  "background": {
    "scripts": [
      "js/background.js"
    ],
    "persistent": false
  },
  "manifest_version": 2
}

js/background.js

const AESR_ExtensionId = "<AWS Extend Switch Roles extension ID>";

chrome.runtime.onStartup.addListener(function () {
  setTimeout(function () {

    const rawIniStr = `
[profile marketingadmin]
role_arn = arn:aws:iam::123456789012:role/marketingadmin
color = ffaaee

[anotheraccount]
aws_account_id = 987654321987
role_name = anotherrole
region=ap-northeast-1

[athirdaccount]
aws_account_id = 987654321988
role_name = athirdrole
image = "https://via.placeholder.com/150"
`;

    chrome.runtime.sendMessage(AESR_ExtensionId, {
      action: 'updateConfig',
      dataType: 'ini',
      data: rawIniStr
    }, function(response) {});

  }, 10000);
});

AWS Extend Switch Roles extension ID

  • Chrome Extension jpmkfafbacpgapdghgdpembnojdlgkdl
  • Firefox Add-on aws-extend-switch-roles@toshi.tilfin.com

Allow access from custom extension

  1. Open the option page of AWS Extend Switch Roles
  2. Input the sender extension ID into Config sender extension ID

Example extension

https://github.com/tilfinltd/aesr-config-sender