@bringweb3/chrome-extension-kit 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ interface Configuration$1 {
2
+ iframeEndpoint: string;
3
+ getWalletAddress: () => Promise<WalletAddress>;
4
+ promptLogin: () => Promise<WalletAddress>;
5
+ walletAddressListeners: string[];
6
+ customTheme?: Style;
7
+ }
8
+ /**
9
+ * Initializes the content script for the Bring extension.
10
+ *
11
+ * @async
12
+ * @function bringInitContentScript
13
+ * @param {Object} configuration - The configuration object.
14
+ * @param {Function} configuration.getWalletAddress - A function that returns a Promise resolving to the wallet address.
15
+ * @param {Function} configuration.promptLogin - A function to prompt the user to login.
16
+ * @param {string[]} configuration.walletAddressListeners - An array of strings representing wallet address listeners.
17
+ * @param {Object} [configuration.customTheme] - Optional custom theme settings.
18
+ * @param {string} configuration.iframeEndpoint - The endpoint URL for the iframe.
19
+ * @throws {Error} Throws an error if any required configuration is missing.
20
+ * @returns {Promise<void>}
21
+ *
22
+ * @description
23
+ * This function sets up event listeners for wallet address changes, iframe messages,
24
+ * and Chrome runtime messages. It handles actions such as getting the wallet address
25
+ * and injecting iframes based on received messages.
26
+ *
27
+ * @example
28
+ * bringInitContentScript({
29
+ * getWalletAddress: async () => '0x1234...',
30
+ * promptLogin: () => { ... },
31
+ * walletAddressListeners: ["listener1", "listener2"],
32
+ * iframeEndpoint: 'https://example.com/iframe'
33
+ * });
34
+ */
35
+ declare const bringInitContentScript: ({ getWalletAddress, promptLogin, walletAddressListeners, customTheme, iframeEndpoint }: Configuration$1) => Promise<void>;
36
+
37
+ interface Configuration {
38
+ identifier: string;
39
+ apiEndpoint: string;
40
+ cashbackPagePath?: string;
41
+ }
42
+ /**
43
+ * Initializes the background script for the Bring extension.
44
+ *
45
+ * @async
46
+ * @function bringInitBackground
47
+ * @param {Object} configuration - The configuration object.
48
+ * @param {string} configuration.identifier - The identifier for the extension.
49
+ * @param {string} configuration.apiEndpoint - The API endpoint ('prod' or 'sandbox').
50
+ * @param {string} [configuration.cashbackPagePath] - Optional path to the cashback page.
51
+ * @throws {Error} Throws an error if identifier or apiEndpoint is missing, or if apiEndpoint is invalid.
52
+ * @returns {Promise<void>}
53
+ *
54
+ * @description
55
+ * This function sets up the background processes for the Bring extension. It initializes
56
+ * the API endpoint, sets up listeners for alarms, runtime messages, and tab updates.
57
+ * It handles various actions such as opting out, closing notifications, injecting content
58
+ * based on URL changes, and managing quiet domains.
59
+ *
60
+ * The function performs the following tasks:
61
+ * - Validates and sets the API endpoint
62
+ * - Updates the cache
63
+ * - Sets up listeners for alarms to update cache periodically
64
+ * - Handles runtime messages for opting out and closing notifications
65
+ * - Monitors tab updates to inject content or show notifications based on URL changes
66
+ * - Validates domains and manages quiet domains
67
+ *
68
+ * @example
69
+ * bringInitBackground({
70
+ * identifier: 'my-extension-id',
71
+ * apiEndpoint: 'sandbox',
72
+ * cashbackPagePath: '/cashback.html'
73
+ * });
74
+ */
75
+ declare const bringInitBackground: ({ identifier, apiEndpoint, cashbackPagePath }: Configuration) => Promise<void>;
76
+
77
+ export { bringInitBackground, bringInitContentScript };
@@ -0,0 +1,77 @@
1
+ interface Configuration$1 {
2
+ iframeEndpoint: string;
3
+ getWalletAddress: () => Promise<WalletAddress>;
4
+ promptLogin: () => Promise<WalletAddress>;
5
+ walletAddressListeners: string[];
6
+ customTheme?: Style;
7
+ }
8
+ /**
9
+ * Initializes the content script for the Bring extension.
10
+ *
11
+ * @async
12
+ * @function bringInitContentScript
13
+ * @param {Object} configuration - The configuration object.
14
+ * @param {Function} configuration.getWalletAddress - A function that returns a Promise resolving to the wallet address.
15
+ * @param {Function} configuration.promptLogin - A function to prompt the user to login.
16
+ * @param {string[]} configuration.walletAddressListeners - An array of strings representing wallet address listeners.
17
+ * @param {Object} [configuration.customTheme] - Optional custom theme settings.
18
+ * @param {string} configuration.iframeEndpoint - The endpoint URL for the iframe.
19
+ * @throws {Error} Throws an error if any required configuration is missing.
20
+ * @returns {Promise<void>}
21
+ *
22
+ * @description
23
+ * This function sets up event listeners for wallet address changes, iframe messages,
24
+ * and Chrome runtime messages. It handles actions such as getting the wallet address
25
+ * and injecting iframes based on received messages.
26
+ *
27
+ * @example
28
+ * bringInitContentScript({
29
+ * getWalletAddress: async () => '0x1234...',
30
+ * promptLogin: () => { ... },
31
+ * walletAddressListeners: ["listener1", "listener2"],
32
+ * iframeEndpoint: 'https://example.com/iframe'
33
+ * });
34
+ */
35
+ declare const bringInitContentScript: ({ getWalletAddress, promptLogin, walletAddressListeners, customTheme, iframeEndpoint }: Configuration$1) => Promise<void>;
36
+
37
+ interface Configuration {
38
+ identifier: string;
39
+ apiEndpoint: string;
40
+ cashbackPagePath?: string;
41
+ }
42
+ /**
43
+ * Initializes the background script for the Bring extension.
44
+ *
45
+ * @async
46
+ * @function bringInitBackground
47
+ * @param {Object} configuration - The configuration object.
48
+ * @param {string} configuration.identifier - The identifier for the extension.
49
+ * @param {string} configuration.apiEndpoint - The API endpoint ('prod' or 'sandbox').
50
+ * @param {string} [configuration.cashbackPagePath] - Optional path to the cashback page.
51
+ * @throws {Error} Throws an error if identifier or apiEndpoint is missing, or if apiEndpoint is invalid.
52
+ * @returns {Promise<void>}
53
+ *
54
+ * @description
55
+ * This function sets up the background processes for the Bring extension. It initializes
56
+ * the API endpoint, sets up listeners for alarms, runtime messages, and tab updates.
57
+ * It handles various actions such as opting out, closing notifications, injecting content
58
+ * based on URL changes, and managing quiet domains.
59
+ *
60
+ * The function performs the following tasks:
61
+ * - Validates and sets the API endpoint
62
+ * - Updates the cache
63
+ * - Sets up listeners for alarms to update cache periodically
64
+ * - Handles runtime messages for opting out and closing notifications
65
+ * - Monitors tab updates to inject content or show notifications based on URL changes
66
+ * - Validates domains and manages quiet domains
67
+ *
68
+ * @example
69
+ * bringInitBackground({
70
+ * identifier: 'my-extension-id',
71
+ * apiEndpoint: 'sandbox',
72
+ * cashbackPagePath: '/cashback.html'
73
+ * });
74
+ */
75
+ declare const bringInitBackground: ({ identifier, apiEndpoint, cashbackPagePath }: Configuration) => Promise<void>;
76
+
77
+ export { bringInitBackground, bringInitContentScript };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bringweb3/chrome-extension-kit",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "build": "tsup index.ts --format cjs,esm --dts --minify",
15
15
  "lint": "tsc",
16
16
  "test": "vitest --coverage",
17
- "release": "yarn build & changeset publish"
17
+ "release": "yarn build && changeset publish"
18
18
  },
19
19
  "files": [
20
20
  "dist",