@heyputer/puter.js 2.0.16 → 2.1.2
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/dist/puter.cjs +2 -2
- package/package.json +2 -2
- package/src/modules/Auth.js +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyputer/puter.js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Puter.js - A JavaScript library for interacting with Puter services.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@heyputer/kv.js": "^0.2.1",
|
|
43
|
-
"@heyputer/putility": "^1.
|
|
43
|
+
"@heyputer/putility": "^1.1.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/modules/Auth.js
CHANGED
|
@@ -251,6 +251,44 @@ class Auth{
|
|
|
251
251
|
throw error;
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
async getGlobalUsage() {
|
|
256
|
+
try {
|
|
257
|
+
const resp = await fetch(`${this.APIOrigin}/metering/globalUsage`, {
|
|
258
|
+
headers: {
|
|
259
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const result = await resp.json();
|
|
264
|
+
|
|
265
|
+
// Log the response
|
|
266
|
+
if ( globalThis.puter?.apiCallLogger?.isEnabled() ) {
|
|
267
|
+
globalThis.puter.apiCallLogger.logRequest({
|
|
268
|
+
service: 'auth',
|
|
269
|
+
operation: 'global_usage',
|
|
270
|
+
params: {},
|
|
271
|
+
result: result,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return result;
|
|
276
|
+
} catch( error ) {
|
|
277
|
+
// Log the error
|
|
278
|
+
if ( globalThis.puter?.apiCallLogger?.isEnabled() ) {
|
|
279
|
+
globalThis.puter.apiCallLogger.logRequest({
|
|
280
|
+
service: 'auth',
|
|
281
|
+
operation: 'global_usage',
|
|
282
|
+
params: {},
|
|
283
|
+
error: {
|
|
284
|
+
message: error.message || error.toString(),
|
|
285
|
+
stack: error.stack,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
254
292
|
}
|
|
255
293
|
|
|
256
294
|
export default Auth;
|