@chrome-stats/app-pass-sdk 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.
- package/README.md +0 -12
- package/dist/index.d.mts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +7 -26
- package/dist/index.mjs +7 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,15 +72,3 @@ if (data.status === 'ok') {
|
|
|
72
72
|
console.log('User is verified:', data.email);
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
|
-
|
|
76
|
-
## Permissions
|
|
77
|
-
|
|
78
|
-
Ensure your `manifest.json` includes the necessary permissions:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"optional_host_permissions": [
|
|
83
|
-
"https://chrome-stats.com/"
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
```
|
package/dist/index.d.mts
CHANGED
|
@@ -3,11 +3,8 @@ interface AppPassResponse {
|
|
|
3
3
|
* The status of the App Pass check.
|
|
4
4
|
* Possible values:
|
|
5
5
|
* - 'ok': App Pass is valid and active.
|
|
6
|
-
* - 'no_perm': Host permission for chrome-stats.com is missing.
|
|
7
6
|
* - 'no_apppass': User does not have an active App Pass subscription.
|
|
8
|
-
* - '
|
|
9
|
-
* - 'err': Connection error or server failure.
|
|
10
|
-
* - 'unknown_error': Unexpected response format.
|
|
7
|
+
* - 'unknown_error': Connection error or server failure.
|
|
11
8
|
*/
|
|
12
9
|
status: string;
|
|
13
10
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,8 @@ interface AppPassResponse {
|
|
|
3
3
|
* The status of the App Pass check.
|
|
4
4
|
* Possible values:
|
|
5
5
|
* - 'ok': App Pass is valid and active.
|
|
6
|
-
* - 'no_perm': Host permission for chrome-stats.com is missing.
|
|
7
6
|
* - 'no_apppass': User does not have an active App Pass subscription.
|
|
8
|
-
* - '
|
|
9
|
-
* - 'err': Connection error or server failure.
|
|
10
|
-
* - 'unknown_error': Unexpected response format.
|
|
7
|
+
* - 'unknown_error': Connection error or server failure.
|
|
11
8
|
*/
|
|
12
9
|
status: string;
|
|
13
10
|
/**
|
package/dist/index.js
CHANGED
|
@@ -26,18 +26,11 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
var urlBase = "https://chrome-stats.com";
|
|
28
28
|
async function checkStatus() {
|
|
29
|
-
const hasPermission = await chrome.permissions.contains({
|
|
30
|
-
origins: [`${urlBase}/`]
|
|
31
|
-
});
|
|
32
|
-
if (!hasPermission) {
|
|
33
|
-
console.log("App Pass not activated - skipping status check");
|
|
34
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
35
|
-
}
|
|
36
29
|
const maxAttempts = 3;
|
|
37
30
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
38
31
|
try {
|
|
39
32
|
const headers = {
|
|
40
|
-
|
|
33
|
+
extensionid: chrome.runtime.id,
|
|
41
34
|
"Content-Type": "application/json"
|
|
42
35
|
};
|
|
43
36
|
const response = await fetch(`${urlBase}/api/check-app-pass`, {
|
|
@@ -46,7 +39,7 @@ async function checkStatus() {
|
|
|
46
39
|
credentials: "include"
|
|
47
40
|
// Include cookies for authentication
|
|
48
41
|
});
|
|
49
|
-
if (response.ok) {
|
|
42
|
+
if (response.ok || response.status < 500 && response.status >= 400) {
|
|
50
43
|
const data = await response.json();
|
|
51
44
|
console.log("App pass status response:", data);
|
|
52
45
|
return {
|
|
@@ -70,30 +63,18 @@ async function checkStatus() {
|
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
65
|
console.error("App pass status check failed after all retry attempts");
|
|
73
|
-
return { status: "
|
|
66
|
+
return { status: "unknown_error", message: "Failed to connect to server" };
|
|
74
67
|
}
|
|
75
68
|
async function checkAppPass() {
|
|
76
|
-
const hasPermission = await chrome.permissions.contains({
|
|
77
|
-
origins: [`${urlBase}/`]
|
|
78
|
-
});
|
|
79
|
-
if (!hasPermission) {
|
|
80
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
81
|
-
}
|
|
82
69
|
const res = await checkStatus();
|
|
83
70
|
return res;
|
|
84
71
|
}
|
|
85
72
|
async function activateAppPass() {
|
|
86
|
-
const
|
|
87
|
-
|
|
73
|
+
const res = await checkStatus();
|
|
74
|
+
await chrome.tabs.create({
|
|
75
|
+
url: `${urlBase}/apppass/add/${encodeURIComponent(chrome.runtime.id)}`
|
|
88
76
|
});
|
|
89
|
-
|
|
90
|
-
const res = await checkStatus();
|
|
91
|
-
await chrome.tabs.create({
|
|
92
|
-
url: `${urlBase}/apppass/add/${encodeURIComponent(chrome.runtime.id)}`
|
|
93
|
-
});
|
|
94
|
-
return res;
|
|
95
|
-
}
|
|
96
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
77
|
+
return res;
|
|
97
78
|
}
|
|
98
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
80
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var urlBase = "https://chrome-stats.com";
|
|
3
3
|
async function checkStatus() {
|
|
4
|
-
const hasPermission = await chrome.permissions.contains({
|
|
5
|
-
origins: [`${urlBase}/`]
|
|
6
|
-
});
|
|
7
|
-
if (!hasPermission) {
|
|
8
|
-
console.log("App Pass not activated - skipping status check");
|
|
9
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
10
|
-
}
|
|
11
4
|
const maxAttempts = 3;
|
|
12
5
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
13
6
|
try {
|
|
14
7
|
const headers = {
|
|
15
|
-
|
|
8
|
+
extensionid: chrome.runtime.id,
|
|
16
9
|
"Content-Type": "application/json"
|
|
17
10
|
};
|
|
18
11
|
const response = await fetch(`${urlBase}/api/check-app-pass`, {
|
|
@@ -21,7 +14,7 @@ async function checkStatus() {
|
|
|
21
14
|
credentials: "include"
|
|
22
15
|
// Include cookies for authentication
|
|
23
16
|
});
|
|
24
|
-
if (response.ok) {
|
|
17
|
+
if (response.ok || response.status < 500 && response.status >= 400) {
|
|
25
18
|
const data = await response.json();
|
|
26
19
|
console.log("App pass status response:", data);
|
|
27
20
|
return {
|
|
@@ -45,30 +38,18 @@ async function checkStatus() {
|
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
40
|
console.error("App pass status check failed after all retry attempts");
|
|
48
|
-
return { status: "
|
|
41
|
+
return { status: "unknown_error", message: "Failed to connect to server" };
|
|
49
42
|
}
|
|
50
43
|
async function checkAppPass() {
|
|
51
|
-
const hasPermission = await chrome.permissions.contains({
|
|
52
|
-
origins: [`${urlBase}/`]
|
|
53
|
-
});
|
|
54
|
-
if (!hasPermission) {
|
|
55
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
56
|
-
}
|
|
57
44
|
const res = await checkStatus();
|
|
58
45
|
return res;
|
|
59
46
|
}
|
|
60
47
|
async function activateAppPass() {
|
|
61
|
-
const
|
|
62
|
-
|
|
48
|
+
const res = await checkStatus();
|
|
49
|
+
await chrome.tabs.create({
|
|
50
|
+
url: `${urlBase}/apppass/add/${encodeURIComponent(chrome.runtime.id)}`
|
|
63
51
|
});
|
|
64
|
-
|
|
65
|
-
const res = await checkStatus();
|
|
66
|
-
await chrome.tabs.create({
|
|
67
|
-
url: `${urlBase}/apppass/add/${encodeURIComponent(chrome.runtime.id)}`
|
|
68
|
-
});
|
|
69
|
-
return res;
|
|
70
|
-
}
|
|
71
|
-
return { status: "no_perm", message: "Permission denied" };
|
|
52
|
+
return res;
|
|
72
53
|
}
|
|
73
54
|
export {
|
|
74
55
|
activateAppPass,
|