@ydbjs/auth
Version:
Authentication providers for YDB: static credentials, tokens, anonymous, and cloud metadata. Integrates with the core driver for secure access.
17 lines • 695 B
JavaScript
import { Metadata } from 'nice-grpc';
export class CredentialsProvider {
constructor() {
// @ts-expect-error Inside middleware perform `this.getToken` call
// to get the token. This is a workaround for the fact that
// `this` is not bound to the class instance inside the middleware.
this.middleware = this.middleware.bind(this);
}
middleware = async function* (call, options) {
let token = await this.getToken(false, options.signal);
return yield* call.next(call.request, {
...options,
metadata: Metadata(options.metadata).set('x-ydb-auth-ticket', token),
});
};
}
//# sourceMappingURL=index.js.map