@mearl/browser-core 3.1.11 → 3.1.12-beta.0
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.
|
@@ -7,6 +7,7 @@ export interface DomainPermissionFailure {
|
|
|
7
7
|
domain: string;
|
|
8
8
|
requestDispatched: false;
|
|
9
9
|
}
|
|
10
|
+
export declare const DOMAIN_PERMISSION_ACTION_TIMEOUT_MS = 100000;
|
|
10
11
|
export declare class DomainPermissionError extends Error implements DomainPermissionFailure {
|
|
11
12
|
readonly action: string;
|
|
12
13
|
readonly domain: string;
|
|
@@ -14,6 +15,11 @@ export declare class DomainPermissionError extends Error implements DomainPermis
|
|
|
14
15
|
readonly requestDispatched = false;
|
|
15
16
|
constructor(action: string, domain: string, message?: string);
|
|
16
17
|
}
|
|
18
|
+
export declare function getDomainPermissionFailure(value: unknown): DomainPermissionFailure | undefined;
|
|
19
|
+
export declare function browserActionResponseError(response: {
|
|
20
|
+
error?: string;
|
|
21
|
+
errorDetails?: unknown;
|
|
22
|
+
}, fallback: string): Error;
|
|
17
23
|
export declare const ALLOWED_ORIGINS: readonly ["*://localhost/*", "*://127.0.0.1/*"];
|
|
18
24
|
export declare const ALLOWED_ORIGINS_LIST: string[];
|
|
19
25
|
export declare function normalizeDomainInputToOrigin(input: string): string | null;
|
package/dist/proxyPermissions.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Proxy/cookie domain permission utilities — pure functions, no chrome.* or storage deps.
|
|
3
3
|
*/
|
|
4
|
+
// Leave time for the browser's confirmation window to return its decision.
|
|
5
|
+
export const DOMAIN_PERMISSION_ACTION_TIMEOUT_MS = 100_000;
|
|
4
6
|
export class DomainPermissionError extends Error {
|
|
5
7
|
action;
|
|
6
8
|
domain;
|
|
@@ -13,6 +15,28 @@ export class DomainPermissionError extends Error {
|
|
|
13
15
|
this.name = 'DomainPermissionError';
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
export function getDomainPermissionFailure(value) {
|
|
19
|
+
const failure = value;
|
|
20
|
+
if (failure?.code === 'DOMAIN_PERMISSION_REQUIRED' &&
|
|
21
|
+
failure.requestDispatched === false &&
|
|
22
|
+
typeof failure.action === 'string' &&
|
|
23
|
+
failure.action.length > 0 &&
|
|
24
|
+
typeof failure.domain === 'string' &&
|
|
25
|
+
failure.domain.length > 0) {
|
|
26
|
+
return {
|
|
27
|
+
code: failure.code,
|
|
28
|
+
action: failure.action,
|
|
29
|
+
domain: failure.domain,
|
|
30
|
+
requestDispatched: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function browserActionResponseError(response, fallback) {
|
|
35
|
+
const failure = getDomainPermissionFailure(response.errorDetails);
|
|
36
|
+
return failure
|
|
37
|
+
? new DomainPermissionError(failure.action, failure.domain, response.error || undefined)
|
|
38
|
+
: new Error(response.error || fallback);
|
|
39
|
+
}
|
|
16
40
|
export const ALLOWED_ORIGINS = ['*://localhost/*', '*://127.0.0.1/*'];
|
|
17
41
|
export const ALLOWED_ORIGINS_LIST = [...ALLOWED_ORIGINS];
|
|
18
42
|
function normalizeHost(input) {
|
package/package.json
CHANGED