Erster Commit

This commit is contained in:
2026-08-22 08:40:29 +02:00
commit 875477d425
1961 changed files with 930336 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { AccessToken } from "./AccessToken.js";
class ServiceBase {
constructor(apiKeyOrOptions, secret, ttl) {
const options = typeof apiKeyOrOptions === "object" ? apiKeyOrOptions : { apiKey: apiKeyOrOptions, secret, ttl };
this.apiKey = options.apiKey;
this.secret = options.secret;
this.ttl = options.ttl || "10m";
this.token = options.token;
}
async authHeader(grant, sip) {
if (this.token) {
return { Authorization: `Bearer ${this.token}` };
}
const at = new AccessToken(this.apiKey, this.secret, { ttl: this.ttl });
if (grant) {
at.addGrant(grant);
}
if (sip) {
at.addSIPGrant(sip);
}
return {
Authorization: `Bearer ${await at.toJwt()}`
};
}
}
export {
ServiceBase
};
//# sourceMappingURL=ServiceBase.js.map