Skip to content

Commit 63e1c78

Browse files
committed
refactor: client auth flows
1 parent e429ca0 commit 63e1c78

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/client.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ export class SurrealDBClient {
3737
}
3838

3939
if (isUrlConfig(config)) {
40-
await this.db.connect(config.url, {
40+
await this.db.connect(config.url);
41+
await this.db.signin({
42+
username: config.username,
43+
password: config.password,
44+
});
45+
await this.db.use({
4146
namespace: this.namespace,
4247
database: this.database,
43-
authentication: {
44-
username: config.username,
45-
password: config.password,
46-
},
4748
});
4849
} else if (isTokenConfig(config)) {
49-
await this.db.connect(config.url, {
50+
await this.db.connect(config.url);
51+
await this.db.authenticate(config.token);
52+
await this.db.use({
5053
namespace: this.namespace,
5154
database: this.database,
52-
authentication: config.token,
5355
});
5456
}
5557

0 commit comments

Comments
 (0)