cloudflare
Version:
The official TypeScript library for the Cloudflare API
83 lines • 3.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tokens = exports.BaseTokens = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseTokens = /* @__PURE__ */ (() => {
class BaseTokens extends resource_1.APIResource {
/**
* Mints a new relay-scoped token and adds it to the relay's accepted-auth
* registry. The token value (secret) is shown once in the response. A relay may
* hold up to 10 tokens; creating an 11th is rejected.
*
* @example
* ```ts
* const token = await client.moq.relays.tokens.create(
* 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* operations: ['publish', 'subscribe'],
* },
* );
* ```
*/
create(relayID, params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/moq/relays/${relayID}/tokens`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns metadata for every token the relay accepts. Secrets are never returned,
* so a token that has been lost cannot be recovered here. There is no expiry
* filter: compare each token's `expires` to the current time to tell which ones
* have lapsed.
*
* @example
* ```ts
* const tokens = await client.moq.relays.tokens.list(
* 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
list(relayID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/moq/relays/${relayID}/tokens`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Revokes a token by removing it from the set the relay accepts. Relays cache that
* set, so revocation takes effect within seconds rather than instantly, and
* connections already established with the token are not closed. Revoking an
* unknown token succeeds, so the call is idempotent.
*
* @example
* ```ts
* const token = await client.moq.relays.tokens.delete(
* 'f3a1b2c3d4e5f67890a1b2c3d4e5f678',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* relay_id: 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* },
* );
* ```
*/
delete(jti, params, options) {
const { account_id, relay_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/moq/relays/${relay_id}/tokens/${jti}`, options);
}
}
BaseTokens._key = Object.freeze([
'moq',
'relays',
'tokens',
]);
return BaseTokens;
})();
exports.BaseTokens = BaseTokens;
class Tokens extends BaseTokens {
}
exports.Tokens = Tokens;
//# sourceMappingURL=tokens.js.map