@truenas/api-client 3.0.5 → 3.0.6
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/index.cjs +127 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -2
- package/dist/index.d.ts +75 -2
- package/dist/index.js +127 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -12851,6 +12851,20 @@ interface ApiKeyCreate {
|
|
|
12851
12851
|
declare enum UserRole {
|
|
12852
12852
|
FullAdmin = "FULL_ADMIN"
|
|
12853
12853
|
}
|
|
12854
|
+
/**
|
|
12855
|
+
* A role as middleware reports it.
|
|
12856
|
+
*
|
|
12857
|
+
* `UserRole` names only the role this client itself had a use for. Middleware
|
|
12858
|
+
* defines many more — `SHARING_ADMIN`, `READONLY_ADMIN` and so on — and this
|
|
12859
|
+
* client does not enumerate them, because it no longer makes any decision from
|
|
12860
|
+
* a role and would only be maintaining a second copy of someone else's list.
|
|
12861
|
+
*
|
|
12862
|
+
* Widened to `string` so a consumer can compare against the roles it cares
|
|
12863
|
+
* about without a cast, while `UserRole` still autocompletes. Consumers are
|
|
12864
|
+
* where role policy lives now, so the type they are handed has to admit the
|
|
12865
|
+
* roles they will actually test for.
|
|
12866
|
+
*/
|
|
12867
|
+
type UserRoleName = UserRole | (string & {});
|
|
12854
12868
|
|
|
12855
12869
|
interface UserPreferences {
|
|
12856
12870
|
language: string;
|
|
@@ -12896,7 +12910,7 @@ interface AuthResponse {
|
|
|
12896
12910
|
groups: number[];
|
|
12897
12911
|
privilege: {
|
|
12898
12912
|
roles: {
|
|
12899
|
-
$set:
|
|
12913
|
+
$set: UserRoleName[];
|
|
12900
12914
|
};
|
|
12901
12915
|
};
|
|
12902
12916
|
two_factor_auth_configured: boolean;
|
|
@@ -12935,6 +12949,13 @@ interface AuthResponse {
|
|
|
12935
12949
|
* TrueNAS authenticator using the JSON-RPC 2.0 protocol.
|
|
12936
12950
|
*
|
|
12937
12951
|
* It handles authentication using the JSON-RPC 2.0 message format.
|
|
12952
|
+
*
|
|
12953
|
+
* Authentication only: any credential middleware accepts logs in here, whatever
|
|
12954
|
+
* roles it carries. No path checks privilege, and that is the design — the
|
|
12955
|
+
* appliance authorizes every privileged call on its own, and which roles a given
|
|
12956
|
+
* product requires is that product's policy, not this client's. Consumers who
|
|
12957
|
+
* need one read `user_info.privilege.roles` off the response and enforce it
|
|
12958
|
+
* themselves; embedding a rule here would impose it on every consumer at once.
|
|
12938
12959
|
*/
|
|
12939
12960
|
declare class TrueNasAuthenticator {
|
|
12940
12961
|
private connection;
|
|
@@ -12958,6 +12979,38 @@ declare class TrueNasAuthenticator {
|
|
|
12958
12979
|
key: string;
|
|
12959
12980
|
};
|
|
12960
12981
|
sessionLifetime: number;
|
|
12982
|
+
/**
|
|
12983
|
+
* Claimed by each login when it sends and checked when its answer lands: a
|
|
12984
|
+
* difference means another login or a logout was issued in between, so this
|
|
12985
|
+
* answer is stale and must not write session state. Responses on one socket
|
|
12986
|
+
* are not ordered, which is why arrival is not enough to make an answer
|
|
12987
|
+
* current.
|
|
12988
|
+
*
|
|
12989
|
+
* `logout()` bumps it without claiming one. It has no answer to guard —
|
|
12990
|
+
* it settles its own state at the call — and bumping is what invalidates the
|
|
12991
|
+
* logins already on the wire that a logout is meant to override.
|
|
12992
|
+
*/
|
|
12993
|
+
private authEpoch;
|
|
12994
|
+
/**
|
|
12995
|
+
* Caller-issued logins still awaiting an answer, keyed by the epoch each
|
|
12996
|
+
* claimed. The value is whether its frame has been written to a socket yet.
|
|
12997
|
+
*
|
|
12998
|
+
* The auto-relogin below defers while any entry exists. It is this class
|
|
12999
|
+
* retrying a cached credential, not a request anyone made, so it must never
|
|
13000
|
+
* outrank an explicit login — and it would: `TrueNasConnection.send` holds a
|
|
13001
|
+
* frame through an outage rather than dropping it, so a login submitted while
|
|
13002
|
+
* the socket is down is still pending when `opened` fires, and a relogin
|
|
13003
|
+
* claiming the newer epoch has that login answered `LoginSuperseded` while the
|
|
13004
|
+
* client authenticates as the previously cached account.
|
|
13005
|
+
*
|
|
13006
|
+
* Keyed rather than counted, because a count cannot say *which* login a
|
|
13007
|
+
* removal belongs to: a login torn down by its caller would retire a slot
|
|
13008
|
+
* belonging to a different login that is still waiting, and the retry would
|
|
13009
|
+
* overtake it again. Identity also makes a double-subscribed login harmless.
|
|
13010
|
+
*/
|
|
13011
|
+
private liveCallerLogins;
|
|
13012
|
+
/** True only while the constructor's relogin is being constructed. */
|
|
13013
|
+
private reloginInProgress;
|
|
12961
13014
|
constructor(connection: TrueNasConnection, version?: ApiVersion | undefined);
|
|
12962
13015
|
/**
|
|
12963
13016
|
* `login_options` asking for a reconnect token, when the server understands it.
|
|
@@ -12979,6 +13032,14 @@ declare class TrueNasAuthenticator {
|
|
|
12979
13032
|
* reconnect case the feature is named for.
|
|
12980
13033
|
*/
|
|
12981
13034
|
private reconnectTokenOption;
|
|
13035
|
+
/**
|
|
13036
|
+
* Throws when another login or a logout was issued after this one was sent,
|
|
13037
|
+
* so a stale answer cannot be reported to its caller as a successful login.
|
|
13038
|
+
*/
|
|
13039
|
+
private assertNotSuperseded;
|
|
13040
|
+
/** Claim the next epoch for a login, and record it if a caller asked for it. */
|
|
13041
|
+
private beginLogin;
|
|
13042
|
+
private endLogin;
|
|
12982
13043
|
loginWithUserPass(username: string, password: string): rxjs.Observable<AuthResponse>;
|
|
12983
13044
|
loginWithOtp(code: string): rxjs.Observable<AuthResponse>;
|
|
12984
13045
|
/**
|
|
@@ -28108,6 +28169,18 @@ declare enum AuthErrorCode {
|
|
|
28108
28169
|
OtpAuthFailed = "OTP_AUTH_FAILED",
|
|
28109
28170
|
ApiKeyAuthFailed = "API_KEY_AUTH_FAILED",
|
|
28110
28171
|
TokenAuthFailed = "TOKEN_AUTH_FAILED",
|
|
28172
|
+
/**
|
|
28173
|
+
* A login was overtaken by a logout, or by a later login, while its response
|
|
28174
|
+
* was in flight. The server may well have accepted it; this client discarded
|
|
28175
|
+
* the result rather than authenticate a session the caller had moved on from.
|
|
28176
|
+
*/
|
|
28177
|
+
LoginSuperseded = "LOGIN_SUPERSEDED",
|
|
28178
|
+
/**
|
|
28179
|
+
* @deprecated Nothing throws this. The authenticator no longer refuses a
|
|
28180
|
+
* login for want of a role — see `TrueNasAuthenticator`. Kept so consumers
|
|
28181
|
+
* still narrowing on the code keep compiling; removing it would be a breaking
|
|
28182
|
+
* change for a member that can no longer occur.
|
|
28183
|
+
*/
|
|
28111
28184
|
FullAdminRequired = "FULL_ADMIN_REQUIRED"
|
|
28112
28185
|
}
|
|
28113
28186
|
declare class AuthError extends Error {
|
|
@@ -28168,4 +28241,4 @@ type ApiError = JsonRpcError | TrueNasError;
|
|
|
28168
28241
|
*/
|
|
28169
28242
|
declare function getApiErrorMessage(error: unknown, fallback?: string): string;
|
|
28170
28243
|
|
|
28171
|
-
export { type ApiCallDirectory$7 as ApiCallDirectoryV25_10_0, type ApiCallDirectory$6 as ApiCallDirectoryV25_10_1, type ApiCallDirectory$5 as ApiCallDirectoryV25_10_2, type ApiCallDirectory$4 as ApiCallDirectoryV25_10_3, type ApiCallDirectory$3 as ApiCallDirectoryV25_10_4, type ApiCallDirectory$2 as ApiCallDirectoryV25_10_5, type ApiCallDirectory$1 as ApiCallDirectoryV26_0_0, type ApiCallDirectory as ApiCallDirectoryV27_0_0, type ApiDirectoryByVersion, type ApiDirectoryShape, type ApiDirectory$7 as ApiDirectoryV25_10_0, type ApiDirectory$6 as ApiDirectoryV25_10_1, type ApiDirectory$5 as ApiDirectoryV25_10_2, type ApiDirectory$4 as ApiDirectoryV25_10_3, type ApiDirectory$3 as ApiDirectoryV25_10_4, type ApiDirectory$2 as ApiDirectoryV25_10_5, type ApiDirectory$1 as ApiDirectoryV26_0_0, type ApiDirectory as ApiDirectoryV27_0_0, type ApiError, type ApiEventDirectory$7 as ApiEventDirectoryV25_10_0, type ApiEventDirectory$6 as ApiEventDirectoryV25_10_1, type ApiEventDirectory$5 as ApiEventDirectoryV25_10_2, type ApiEventDirectory$4 as ApiEventDirectoryV25_10_3, type ApiEventDirectory$3 as ApiEventDirectoryV25_10_4, type ApiEventDirectory$2 as ApiEventDirectoryV25_10_5, type ApiEventDirectory$1 as ApiEventDirectoryV26_0_0, type ApiEventDirectory as ApiEventDirectoryV27_0_0, type ApiJobDirectory$7 as ApiJobDirectoryV25_10_0, type ApiJobDirectory$6 as ApiJobDirectoryV25_10_1, type ApiJobDirectory$5 as ApiJobDirectoryV25_10_2, type ApiJobDirectory$4 as ApiJobDirectoryV25_10_3, type ApiJobDirectory$3 as ApiJobDirectoryV25_10_4, type ApiJobDirectory$2 as ApiJobDirectoryV25_10_5, type ApiJobDirectory$1 as ApiJobDirectoryV26_0_0, type ApiJobDirectory as ApiJobDirectoryV27_0_0, type ApiKeyCreate, type ApiVersion, type ApiVersionResponse, AppState, type ApplianceProtocol, type ArgsOf, AuthError, AuthErrorCode, type AuthResponse, type BaseApiDirectory, type CallMethod, type CallParams, type CallResponse, type Container, type CreateClientOptions, type DefaultApiDirectory, type EventKind, type EventName, type EventUnion, InvalidVersionResponseError, type Job, type JobMethod, type JobParams, type JobProgress, type JobResult, JobState, type Logger, NoCompatibleVersionsError, type OperationMappings, type QueryDirectory, type QueryEntity, type QueryListOptions, type QueryMethod, type QuerySingleOptions, SUPPORTED_API_VERSIONS, type SupportedApiVersion, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, type TrueNasDate, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, index$7 as v25_10_0, index$6 as v25_10_1, index$5 as v25_10_2, index$4 as v25_10_3, index$3 as v25_10_4, index$2 as v25_10_5, index$1 as v26_0_0, index as v27_0_0 };
|
|
28244
|
+
export { type ApiCallDirectory$7 as ApiCallDirectoryV25_10_0, type ApiCallDirectory$6 as ApiCallDirectoryV25_10_1, type ApiCallDirectory$5 as ApiCallDirectoryV25_10_2, type ApiCallDirectory$4 as ApiCallDirectoryV25_10_3, type ApiCallDirectory$3 as ApiCallDirectoryV25_10_4, type ApiCallDirectory$2 as ApiCallDirectoryV25_10_5, type ApiCallDirectory$1 as ApiCallDirectoryV26_0_0, type ApiCallDirectory as ApiCallDirectoryV27_0_0, type ApiDirectoryByVersion, type ApiDirectoryShape, type ApiDirectory$7 as ApiDirectoryV25_10_0, type ApiDirectory$6 as ApiDirectoryV25_10_1, type ApiDirectory$5 as ApiDirectoryV25_10_2, type ApiDirectory$4 as ApiDirectoryV25_10_3, type ApiDirectory$3 as ApiDirectoryV25_10_4, type ApiDirectory$2 as ApiDirectoryV25_10_5, type ApiDirectory$1 as ApiDirectoryV26_0_0, type ApiDirectory as ApiDirectoryV27_0_0, type ApiError, type ApiEventDirectory$7 as ApiEventDirectoryV25_10_0, type ApiEventDirectory$6 as ApiEventDirectoryV25_10_1, type ApiEventDirectory$5 as ApiEventDirectoryV25_10_2, type ApiEventDirectory$4 as ApiEventDirectoryV25_10_3, type ApiEventDirectory$3 as ApiEventDirectoryV25_10_4, type ApiEventDirectory$2 as ApiEventDirectoryV25_10_5, type ApiEventDirectory$1 as ApiEventDirectoryV26_0_0, type ApiEventDirectory as ApiEventDirectoryV27_0_0, type ApiJobDirectory$7 as ApiJobDirectoryV25_10_0, type ApiJobDirectory$6 as ApiJobDirectoryV25_10_1, type ApiJobDirectory$5 as ApiJobDirectoryV25_10_2, type ApiJobDirectory$4 as ApiJobDirectoryV25_10_3, type ApiJobDirectory$3 as ApiJobDirectoryV25_10_4, type ApiJobDirectory$2 as ApiJobDirectoryV25_10_5, type ApiJobDirectory$1 as ApiJobDirectoryV26_0_0, type ApiJobDirectory as ApiJobDirectoryV27_0_0, type ApiKeyCreate, type ApiVersion, type ApiVersionResponse, AppState, type ApplianceProtocol, type ArgsOf, AuthError, AuthErrorCode, type AuthResponse, type BaseApiDirectory, type CallMethod, type CallParams, type CallResponse, type Container, type CreateClientOptions, type DefaultApiDirectory, type EventKind, type EventName, type EventUnion, InvalidVersionResponseError, type Job, type JobMethod, type JobParams, type JobProgress, type JobResult, JobState, type Logger, NoCompatibleVersionsError, type OperationMappings, type QueryDirectory, type QueryEntity, type QueryListOptions, type QueryMethod, type QuerySingleOptions, SUPPORTED_API_VERSIONS, type SupportedApiVersion, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, type TrueNasDate, UserRole, type UserRoleName, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, index$7 as v25_10_0, index$6 as v25_10_1, index$5 as v25_10_2, index$4 as v25_10_3, index$3 as v25_10_4, index$2 as v25_10_5, index$1 as v26_0_0, index as v27_0_0 };
|
package/dist/index.d.ts
CHANGED
|
@@ -12851,6 +12851,20 @@ interface ApiKeyCreate {
|
|
|
12851
12851
|
declare enum UserRole {
|
|
12852
12852
|
FullAdmin = "FULL_ADMIN"
|
|
12853
12853
|
}
|
|
12854
|
+
/**
|
|
12855
|
+
* A role as middleware reports it.
|
|
12856
|
+
*
|
|
12857
|
+
* `UserRole` names only the role this client itself had a use for. Middleware
|
|
12858
|
+
* defines many more — `SHARING_ADMIN`, `READONLY_ADMIN` and so on — and this
|
|
12859
|
+
* client does not enumerate them, because it no longer makes any decision from
|
|
12860
|
+
* a role and would only be maintaining a second copy of someone else's list.
|
|
12861
|
+
*
|
|
12862
|
+
* Widened to `string` so a consumer can compare against the roles it cares
|
|
12863
|
+
* about without a cast, while `UserRole` still autocompletes. Consumers are
|
|
12864
|
+
* where role policy lives now, so the type they are handed has to admit the
|
|
12865
|
+
* roles they will actually test for.
|
|
12866
|
+
*/
|
|
12867
|
+
type UserRoleName = UserRole | (string & {});
|
|
12854
12868
|
|
|
12855
12869
|
interface UserPreferences {
|
|
12856
12870
|
language: string;
|
|
@@ -12896,7 +12910,7 @@ interface AuthResponse {
|
|
|
12896
12910
|
groups: number[];
|
|
12897
12911
|
privilege: {
|
|
12898
12912
|
roles: {
|
|
12899
|
-
$set:
|
|
12913
|
+
$set: UserRoleName[];
|
|
12900
12914
|
};
|
|
12901
12915
|
};
|
|
12902
12916
|
two_factor_auth_configured: boolean;
|
|
@@ -12935,6 +12949,13 @@ interface AuthResponse {
|
|
|
12935
12949
|
* TrueNAS authenticator using the JSON-RPC 2.0 protocol.
|
|
12936
12950
|
*
|
|
12937
12951
|
* It handles authentication using the JSON-RPC 2.0 message format.
|
|
12952
|
+
*
|
|
12953
|
+
* Authentication only: any credential middleware accepts logs in here, whatever
|
|
12954
|
+
* roles it carries. No path checks privilege, and that is the design — the
|
|
12955
|
+
* appliance authorizes every privileged call on its own, and which roles a given
|
|
12956
|
+
* product requires is that product's policy, not this client's. Consumers who
|
|
12957
|
+
* need one read `user_info.privilege.roles` off the response and enforce it
|
|
12958
|
+
* themselves; embedding a rule here would impose it on every consumer at once.
|
|
12938
12959
|
*/
|
|
12939
12960
|
declare class TrueNasAuthenticator {
|
|
12940
12961
|
private connection;
|
|
@@ -12958,6 +12979,38 @@ declare class TrueNasAuthenticator {
|
|
|
12958
12979
|
key: string;
|
|
12959
12980
|
};
|
|
12960
12981
|
sessionLifetime: number;
|
|
12982
|
+
/**
|
|
12983
|
+
* Claimed by each login when it sends and checked when its answer lands: a
|
|
12984
|
+
* difference means another login or a logout was issued in between, so this
|
|
12985
|
+
* answer is stale and must not write session state. Responses on one socket
|
|
12986
|
+
* are not ordered, which is why arrival is not enough to make an answer
|
|
12987
|
+
* current.
|
|
12988
|
+
*
|
|
12989
|
+
* `logout()` bumps it without claiming one. It has no answer to guard —
|
|
12990
|
+
* it settles its own state at the call — and bumping is what invalidates the
|
|
12991
|
+
* logins already on the wire that a logout is meant to override.
|
|
12992
|
+
*/
|
|
12993
|
+
private authEpoch;
|
|
12994
|
+
/**
|
|
12995
|
+
* Caller-issued logins still awaiting an answer, keyed by the epoch each
|
|
12996
|
+
* claimed. The value is whether its frame has been written to a socket yet.
|
|
12997
|
+
*
|
|
12998
|
+
* The auto-relogin below defers while any entry exists. It is this class
|
|
12999
|
+
* retrying a cached credential, not a request anyone made, so it must never
|
|
13000
|
+
* outrank an explicit login — and it would: `TrueNasConnection.send` holds a
|
|
13001
|
+
* frame through an outage rather than dropping it, so a login submitted while
|
|
13002
|
+
* the socket is down is still pending when `opened` fires, and a relogin
|
|
13003
|
+
* claiming the newer epoch has that login answered `LoginSuperseded` while the
|
|
13004
|
+
* client authenticates as the previously cached account.
|
|
13005
|
+
*
|
|
13006
|
+
* Keyed rather than counted, because a count cannot say *which* login a
|
|
13007
|
+
* removal belongs to: a login torn down by its caller would retire a slot
|
|
13008
|
+
* belonging to a different login that is still waiting, and the retry would
|
|
13009
|
+
* overtake it again. Identity also makes a double-subscribed login harmless.
|
|
13010
|
+
*/
|
|
13011
|
+
private liveCallerLogins;
|
|
13012
|
+
/** True only while the constructor's relogin is being constructed. */
|
|
13013
|
+
private reloginInProgress;
|
|
12961
13014
|
constructor(connection: TrueNasConnection, version?: ApiVersion | undefined);
|
|
12962
13015
|
/**
|
|
12963
13016
|
* `login_options` asking for a reconnect token, when the server understands it.
|
|
@@ -12979,6 +13032,14 @@ declare class TrueNasAuthenticator {
|
|
|
12979
13032
|
* reconnect case the feature is named for.
|
|
12980
13033
|
*/
|
|
12981
13034
|
private reconnectTokenOption;
|
|
13035
|
+
/**
|
|
13036
|
+
* Throws when another login or a logout was issued after this one was sent,
|
|
13037
|
+
* so a stale answer cannot be reported to its caller as a successful login.
|
|
13038
|
+
*/
|
|
13039
|
+
private assertNotSuperseded;
|
|
13040
|
+
/** Claim the next epoch for a login, and record it if a caller asked for it. */
|
|
13041
|
+
private beginLogin;
|
|
13042
|
+
private endLogin;
|
|
12982
13043
|
loginWithUserPass(username: string, password: string): rxjs.Observable<AuthResponse>;
|
|
12983
13044
|
loginWithOtp(code: string): rxjs.Observable<AuthResponse>;
|
|
12984
13045
|
/**
|
|
@@ -28108,6 +28169,18 @@ declare enum AuthErrorCode {
|
|
|
28108
28169
|
OtpAuthFailed = "OTP_AUTH_FAILED",
|
|
28109
28170
|
ApiKeyAuthFailed = "API_KEY_AUTH_FAILED",
|
|
28110
28171
|
TokenAuthFailed = "TOKEN_AUTH_FAILED",
|
|
28172
|
+
/**
|
|
28173
|
+
* A login was overtaken by a logout, or by a later login, while its response
|
|
28174
|
+
* was in flight. The server may well have accepted it; this client discarded
|
|
28175
|
+
* the result rather than authenticate a session the caller had moved on from.
|
|
28176
|
+
*/
|
|
28177
|
+
LoginSuperseded = "LOGIN_SUPERSEDED",
|
|
28178
|
+
/**
|
|
28179
|
+
* @deprecated Nothing throws this. The authenticator no longer refuses a
|
|
28180
|
+
* login for want of a role — see `TrueNasAuthenticator`. Kept so consumers
|
|
28181
|
+
* still narrowing on the code keep compiling; removing it would be a breaking
|
|
28182
|
+
* change for a member that can no longer occur.
|
|
28183
|
+
*/
|
|
28111
28184
|
FullAdminRequired = "FULL_ADMIN_REQUIRED"
|
|
28112
28185
|
}
|
|
28113
28186
|
declare class AuthError extends Error {
|
|
@@ -28168,4 +28241,4 @@ type ApiError = JsonRpcError | TrueNasError;
|
|
|
28168
28241
|
*/
|
|
28169
28242
|
declare function getApiErrorMessage(error: unknown, fallback?: string): string;
|
|
28170
28243
|
|
|
28171
|
-
export { type ApiCallDirectory$7 as ApiCallDirectoryV25_10_0, type ApiCallDirectory$6 as ApiCallDirectoryV25_10_1, type ApiCallDirectory$5 as ApiCallDirectoryV25_10_2, type ApiCallDirectory$4 as ApiCallDirectoryV25_10_3, type ApiCallDirectory$3 as ApiCallDirectoryV25_10_4, type ApiCallDirectory$2 as ApiCallDirectoryV25_10_5, type ApiCallDirectory$1 as ApiCallDirectoryV26_0_0, type ApiCallDirectory as ApiCallDirectoryV27_0_0, type ApiDirectoryByVersion, type ApiDirectoryShape, type ApiDirectory$7 as ApiDirectoryV25_10_0, type ApiDirectory$6 as ApiDirectoryV25_10_1, type ApiDirectory$5 as ApiDirectoryV25_10_2, type ApiDirectory$4 as ApiDirectoryV25_10_3, type ApiDirectory$3 as ApiDirectoryV25_10_4, type ApiDirectory$2 as ApiDirectoryV25_10_5, type ApiDirectory$1 as ApiDirectoryV26_0_0, type ApiDirectory as ApiDirectoryV27_0_0, type ApiError, type ApiEventDirectory$7 as ApiEventDirectoryV25_10_0, type ApiEventDirectory$6 as ApiEventDirectoryV25_10_1, type ApiEventDirectory$5 as ApiEventDirectoryV25_10_2, type ApiEventDirectory$4 as ApiEventDirectoryV25_10_3, type ApiEventDirectory$3 as ApiEventDirectoryV25_10_4, type ApiEventDirectory$2 as ApiEventDirectoryV25_10_5, type ApiEventDirectory$1 as ApiEventDirectoryV26_0_0, type ApiEventDirectory as ApiEventDirectoryV27_0_0, type ApiJobDirectory$7 as ApiJobDirectoryV25_10_0, type ApiJobDirectory$6 as ApiJobDirectoryV25_10_1, type ApiJobDirectory$5 as ApiJobDirectoryV25_10_2, type ApiJobDirectory$4 as ApiJobDirectoryV25_10_3, type ApiJobDirectory$3 as ApiJobDirectoryV25_10_4, type ApiJobDirectory$2 as ApiJobDirectoryV25_10_5, type ApiJobDirectory$1 as ApiJobDirectoryV26_0_0, type ApiJobDirectory as ApiJobDirectoryV27_0_0, type ApiKeyCreate, type ApiVersion, type ApiVersionResponse, AppState, type ApplianceProtocol, type ArgsOf, AuthError, AuthErrorCode, type AuthResponse, type BaseApiDirectory, type CallMethod, type CallParams, type CallResponse, type Container, type CreateClientOptions, type DefaultApiDirectory, type EventKind, type EventName, type EventUnion, InvalidVersionResponseError, type Job, type JobMethod, type JobParams, type JobProgress, type JobResult, JobState, type Logger, NoCompatibleVersionsError, type OperationMappings, type QueryDirectory, type QueryEntity, type QueryListOptions, type QueryMethod, type QuerySingleOptions, SUPPORTED_API_VERSIONS, type SupportedApiVersion, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, type TrueNasDate, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, index$7 as v25_10_0, index$6 as v25_10_1, index$5 as v25_10_2, index$4 as v25_10_3, index$3 as v25_10_4, index$2 as v25_10_5, index$1 as v26_0_0, index as v27_0_0 };
|
|
28244
|
+
export { type ApiCallDirectory$7 as ApiCallDirectoryV25_10_0, type ApiCallDirectory$6 as ApiCallDirectoryV25_10_1, type ApiCallDirectory$5 as ApiCallDirectoryV25_10_2, type ApiCallDirectory$4 as ApiCallDirectoryV25_10_3, type ApiCallDirectory$3 as ApiCallDirectoryV25_10_4, type ApiCallDirectory$2 as ApiCallDirectoryV25_10_5, type ApiCallDirectory$1 as ApiCallDirectoryV26_0_0, type ApiCallDirectory as ApiCallDirectoryV27_0_0, type ApiDirectoryByVersion, type ApiDirectoryShape, type ApiDirectory$7 as ApiDirectoryV25_10_0, type ApiDirectory$6 as ApiDirectoryV25_10_1, type ApiDirectory$5 as ApiDirectoryV25_10_2, type ApiDirectory$4 as ApiDirectoryV25_10_3, type ApiDirectory$3 as ApiDirectoryV25_10_4, type ApiDirectory$2 as ApiDirectoryV25_10_5, type ApiDirectory$1 as ApiDirectoryV26_0_0, type ApiDirectory as ApiDirectoryV27_0_0, type ApiError, type ApiEventDirectory$7 as ApiEventDirectoryV25_10_0, type ApiEventDirectory$6 as ApiEventDirectoryV25_10_1, type ApiEventDirectory$5 as ApiEventDirectoryV25_10_2, type ApiEventDirectory$4 as ApiEventDirectoryV25_10_3, type ApiEventDirectory$3 as ApiEventDirectoryV25_10_4, type ApiEventDirectory$2 as ApiEventDirectoryV25_10_5, type ApiEventDirectory$1 as ApiEventDirectoryV26_0_0, type ApiEventDirectory as ApiEventDirectoryV27_0_0, type ApiJobDirectory$7 as ApiJobDirectoryV25_10_0, type ApiJobDirectory$6 as ApiJobDirectoryV25_10_1, type ApiJobDirectory$5 as ApiJobDirectoryV25_10_2, type ApiJobDirectory$4 as ApiJobDirectoryV25_10_3, type ApiJobDirectory$3 as ApiJobDirectoryV25_10_4, type ApiJobDirectory$2 as ApiJobDirectoryV25_10_5, type ApiJobDirectory$1 as ApiJobDirectoryV26_0_0, type ApiJobDirectory as ApiJobDirectoryV27_0_0, type ApiKeyCreate, type ApiVersion, type ApiVersionResponse, AppState, type ApplianceProtocol, type ArgsOf, AuthError, AuthErrorCode, type AuthResponse, type BaseApiDirectory, type CallMethod, type CallParams, type CallResponse, type Container, type CreateClientOptions, type DefaultApiDirectory, type EventKind, type EventName, type EventUnion, InvalidVersionResponseError, type Job, type JobMethod, type JobParams, type JobProgress, type JobResult, JobState, type Logger, NoCompatibleVersionsError, type OperationMappings, type QueryDirectory, type QueryEntity, type QueryListOptions, type QueryMethod, type QuerySingleOptions, SUPPORTED_API_VERSIONS, type SupportedApiVersion, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, type TrueNasDate, UserRole, type UserRoleName, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, index$7 as v25_10_0, index$6 as v25_10_1, index$5 as v25_10_2, index$4 as v25_10_3, index$3 as v25_10_4, index$2 as v25_10_5, index$1 as v26_0_0, index as v27_0_0 };
|
package/dist/index.js
CHANGED
|
@@ -2399,6 +2399,7 @@ var AuthErrorCode = /* @__PURE__ */ ((AuthErrorCode2) => {
|
|
|
2399
2399
|
AuthErrorCode2["OtpAuthFailed"] = "OTP_AUTH_FAILED";
|
|
2400
2400
|
AuthErrorCode2["ApiKeyAuthFailed"] = "API_KEY_AUTH_FAILED";
|
|
2401
2401
|
AuthErrorCode2["TokenAuthFailed"] = "TOKEN_AUTH_FAILED";
|
|
2402
|
+
AuthErrorCode2["LoginSuperseded"] = "LOGIN_SUPERSEDED";
|
|
2402
2403
|
AuthErrorCode2["FullAdminRequired"] = "FULL_ADMIN_REQUIRED";
|
|
2403
2404
|
return AuthErrorCode2;
|
|
2404
2405
|
})(AuthErrorCode || {});
|
|
@@ -2437,24 +2438,70 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2437
2438
|
this.authenticating$ = new BehaviorSubject(false);
|
|
2438
2439
|
this.credentials = { username: "", password: "", key: "" };
|
|
2439
2440
|
this.sessionLifetime = _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2441
|
+
/**
|
|
2442
|
+
* Claimed by each login when it sends and checked when its answer lands: a
|
|
2443
|
+
* difference means another login or a logout was issued in between, so this
|
|
2444
|
+
* answer is stale and must not write session state. Responses on one socket
|
|
2445
|
+
* are not ordered, which is why arrival is not enough to make an answer
|
|
2446
|
+
* current.
|
|
2447
|
+
*
|
|
2448
|
+
* `logout()` bumps it without claiming one. It has no answer to guard —
|
|
2449
|
+
* it settles its own state at the call — and bumping is what invalidates the
|
|
2450
|
+
* logins already on the wire that a logout is meant to override.
|
|
2451
|
+
*/
|
|
2452
|
+
this.authEpoch = 0;
|
|
2453
|
+
/**
|
|
2454
|
+
* Caller-issued logins still awaiting an answer, keyed by the epoch each
|
|
2455
|
+
* claimed. The value is whether its frame has been written to a socket yet.
|
|
2456
|
+
*
|
|
2457
|
+
* The auto-relogin below defers while any entry exists. It is this class
|
|
2458
|
+
* retrying a cached credential, not a request anyone made, so it must never
|
|
2459
|
+
* outrank an explicit login — and it would: `TrueNasConnection.send` holds a
|
|
2460
|
+
* frame through an outage rather than dropping it, so a login submitted while
|
|
2461
|
+
* the socket is down is still pending when `opened` fires, and a relogin
|
|
2462
|
+
* claiming the newer epoch has that login answered `LoginSuperseded` while the
|
|
2463
|
+
* client authenticates as the previously cached account.
|
|
2464
|
+
*
|
|
2465
|
+
* Keyed rather than counted, because a count cannot say *which* login a
|
|
2466
|
+
* removal belongs to: a login torn down by its caller would retire a slot
|
|
2467
|
+
* belonging to a different login that is still waiting, and the retry would
|
|
2468
|
+
* overtake it again. Identity also makes a double-subscribed login harmless.
|
|
2469
|
+
*/
|
|
2470
|
+
this.liveCallerLogins = /* @__PURE__ */ new Map();
|
|
2471
|
+
/** True only while the constructor's relogin is being constructed. */
|
|
2472
|
+
this.reloginInProgress = false;
|
|
2473
|
+
this.connection.opened.subscribe((isOpen) => {
|
|
2474
|
+
if (!isOpen) return;
|
|
2475
|
+
for (const epoch of this.liveCallerLogins.keys()) {
|
|
2476
|
+
this.liveCallerLogins.set(epoch, true);
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2440
2479
|
this.connection.opened.pipe(
|
|
2441
2480
|
filter(
|
|
2442
|
-
(isOpen) => !!(isOpen && this.credentials?.username && (this.credentials.password || this.credentials.key)
|
|
2481
|
+
(isOpen) => !!(isOpen && this.credentials?.username && (this.credentials.password || this.credentials.key) && // An explicit login already on the wire outranks this retry.
|
|
2482
|
+
this.liveCallerLogins.size === 0)
|
|
2443
2483
|
),
|
|
2444
2484
|
switchMap(() => {
|
|
2445
|
-
|
|
2446
|
-
|
|
2485
|
+
this.reloginInProgress = true;
|
|
2486
|
+
let relogin;
|
|
2487
|
+
try {
|
|
2488
|
+
relogin = this.credentials.password ? this.loginWithUserPass(
|
|
2447
2489
|
this.credentials.username,
|
|
2448
2490
|
this.credentials.password
|
|
2449
|
-
)
|
|
2491
|
+
) : this.loginWithApiKey({
|
|
2492
|
+
username: this.credentials.username,
|
|
2493
|
+
key: this.credentials.key
|
|
2494
|
+
});
|
|
2495
|
+
} finally {
|
|
2496
|
+
this.reloginInProgress = false;
|
|
2450
2497
|
}
|
|
2451
|
-
return
|
|
2452
|
-
username: this.credentials.username,
|
|
2453
|
-
key: this.credentials.key
|
|
2454
|
-
});
|
|
2498
|
+
return relogin.pipe(catchError$1(() => EMPTY));
|
|
2455
2499
|
})
|
|
2456
2500
|
).subscribe();
|
|
2457
2501
|
connection.closed.subscribe(() => {
|
|
2502
|
+
for (const [epoch, flushed] of this.liveCallerLogins) {
|
|
2503
|
+
if (flushed) this.liveCallerLogins.delete(epoch);
|
|
2504
|
+
}
|
|
2458
2505
|
this.sessionLifetime = _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2459
2506
|
this.authenticated$.next(false);
|
|
2460
2507
|
});
|
|
@@ -2485,7 +2532,36 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2485
2532
|
if (!this.version || this.version.year <= legacyCutoffYear) return void 0;
|
|
2486
2533
|
return { login_options: { reconnect_token: true } };
|
|
2487
2534
|
}
|
|
2535
|
+
/**
|
|
2536
|
+
* Throws when another login or a logout was issued after this one was sent,
|
|
2537
|
+
* so a stale answer cannot be reported to its caller as a successful login.
|
|
2538
|
+
*/
|
|
2539
|
+
assertNotSuperseded(sentDuring) {
|
|
2540
|
+
if (this.authEpoch === sentDuring) return;
|
|
2541
|
+
throw new AuthError(
|
|
2542
|
+
"LOGIN_SUPERSEDED" /* LoginSuperseded */,
|
|
2543
|
+
"Login was superseded by a later logout or login and was discarded."
|
|
2544
|
+
);
|
|
2545
|
+
}
|
|
2546
|
+
/** Claim the next epoch for a login, and record it if a caller asked for it. */
|
|
2547
|
+
beginLogin() {
|
|
2548
|
+
const callerInitiated = !this.reloginInProgress;
|
|
2549
|
+
const sentDuring = ++this.authEpoch;
|
|
2550
|
+
if (callerInitiated) {
|
|
2551
|
+
this.liveCallerLogins.set(sentDuring, this.connection.opened.value);
|
|
2552
|
+
}
|
|
2553
|
+
return { sentDuring, callerInitiated };
|
|
2554
|
+
}
|
|
2555
|
+
endLogin(sentDuring, callerInitiated, answered) {
|
|
2556
|
+
const flushed = this.liveCallerLogins.get(sentDuring);
|
|
2557
|
+
if (callerInitiated && (answered || flushed)) {
|
|
2558
|
+
this.liveCallerLogins.delete(sentDuring);
|
|
2559
|
+
}
|
|
2560
|
+
this.authenticating$.next(false);
|
|
2561
|
+
}
|
|
2488
2562
|
loginWithUserPass(username, password) {
|
|
2563
|
+
const { sentDuring, callerInitiated } = this.beginLogin();
|
|
2564
|
+
let answered = false;
|
|
2489
2565
|
const message = createJsonRpcMessage("auth.login_ex", [
|
|
2490
2566
|
{
|
|
2491
2567
|
mechanism: "PASSWORD_PLAIN" /* Password */,
|
|
@@ -2499,6 +2575,9 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2499
2575
|
const messageId = message.id ?? "";
|
|
2500
2576
|
return this.connection.messages().pipe(
|
|
2501
2577
|
withId(messageId),
|
|
2578
|
+
tap(() => {
|
|
2579
|
+
answered = true;
|
|
2580
|
+
}),
|
|
2502
2581
|
map((msg) => {
|
|
2503
2582
|
if (msg.error) {
|
|
2504
2583
|
const errorMessage = getApiErrorMessage(
|
|
@@ -2515,28 +2594,21 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2515
2594
|
),
|
|
2516
2595
|
tap((res) => {
|
|
2517
2596
|
if (res.response_type === "SUCCESS" /* Success */) {
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
this.authenticated$.next(true);
|
|
2523
|
-
} else {
|
|
2524
|
-
this.logout();
|
|
2525
|
-
this.authenticated$.next(false);
|
|
2526
|
-
throw new AuthError(
|
|
2527
|
-
"FULL_ADMIN_REQUIRED" /* FullAdminRequired */,
|
|
2528
|
-
"User account must have full admin privileges"
|
|
2529
|
-
);
|
|
2530
|
-
}
|
|
2597
|
+
this.assertNotSuperseded(sentDuring);
|
|
2598
|
+
this.credentials = { username, password, key: "" };
|
|
2599
|
+
this.sessionLifetime = res.user_info?.attributes?.preferences?.lifetime ?? _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2600
|
+
this.authenticated$.next(true);
|
|
2531
2601
|
}
|
|
2532
2602
|
}),
|
|
2533
2603
|
finalize(() => {
|
|
2534
|
-
this.
|
|
2604
|
+
this.endLogin(sentDuring, callerInitiated, answered);
|
|
2535
2605
|
}),
|
|
2536
2606
|
take(1)
|
|
2537
2607
|
);
|
|
2538
2608
|
}
|
|
2539
2609
|
loginWithOtp(code) {
|
|
2610
|
+
const { sentDuring, callerInitiated } = this.beginLogin();
|
|
2611
|
+
let answered = false;
|
|
2540
2612
|
const message = createJsonRpcMessage("auth.login_ex", [
|
|
2541
2613
|
{
|
|
2542
2614
|
mechanism: "OTP_TOKEN" /* Otp */,
|
|
@@ -2548,6 +2620,9 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2548
2620
|
const messageId = message.id ?? "";
|
|
2549
2621
|
return this.connection.messages().pipe(
|
|
2550
2622
|
withId(messageId),
|
|
2623
|
+
tap(() => {
|
|
2624
|
+
answered = true;
|
|
2625
|
+
}),
|
|
2551
2626
|
map((msg) => {
|
|
2552
2627
|
if (msg.error) {
|
|
2553
2628
|
const errorMessage = getApiErrorMessage(
|
|
@@ -2560,6 +2635,7 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2560
2635
|
}),
|
|
2561
2636
|
tap((res) => {
|
|
2562
2637
|
if (res?.response_type === "SUCCESS" /* Success */) {
|
|
2638
|
+
this.assertNotSuperseded(sentDuring);
|
|
2563
2639
|
this.sessionLifetime = res.user_info?.attributes?.preferences?.lifetime ?? _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2564
2640
|
this.authenticated$.next(true);
|
|
2565
2641
|
}
|
|
@@ -2569,7 +2645,7 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2569
2645
|
"TrueNAS authentication failed. Please verify your one-time passcode and try again."
|
|
2570
2646
|
),
|
|
2571
2647
|
finalize(() => {
|
|
2572
|
-
this.
|
|
2648
|
+
this.endLogin(sentDuring, callerInitiated, answered);
|
|
2573
2649
|
}),
|
|
2574
2650
|
take(1)
|
|
2575
2651
|
);
|
|
@@ -2594,6 +2670,8 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2594
2670
|
* reason the socket dropped in the first place.
|
|
2595
2671
|
*/
|
|
2596
2672
|
loginWithToken(token) {
|
|
2673
|
+
const { sentDuring, callerInitiated } = this.beginLogin();
|
|
2674
|
+
let answered = false;
|
|
2597
2675
|
const message = createJsonRpcMessage("auth.login_ex", [
|
|
2598
2676
|
{
|
|
2599
2677
|
mechanism: "TOKEN_PLAIN" /* Token */,
|
|
@@ -2606,6 +2684,9 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2606
2684
|
const messageId = message.id ?? "";
|
|
2607
2685
|
return this.connection.messages().pipe(
|
|
2608
2686
|
withId(messageId),
|
|
2687
|
+
tap(() => {
|
|
2688
|
+
answered = true;
|
|
2689
|
+
}),
|
|
2609
2690
|
map((msg) => {
|
|
2610
2691
|
if (msg.error) {
|
|
2611
2692
|
const errorMessage = getApiErrorMessage(
|
|
@@ -2632,21 +2713,13 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2632
2713
|
}),
|
|
2633
2714
|
tap((res) => {
|
|
2634
2715
|
if (res.response_type === "SUCCESS" /* Success */) {
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
} else {
|
|
2639
|
-
this.logout();
|
|
2640
|
-
this.authenticated$.next(false);
|
|
2641
|
-
throw new AuthError(
|
|
2642
|
-
"FULL_ADMIN_REQUIRED" /* FullAdminRequired */,
|
|
2643
|
-
"User account must have full admin privileges"
|
|
2644
|
-
);
|
|
2645
|
-
}
|
|
2716
|
+
this.assertNotSuperseded(sentDuring);
|
|
2717
|
+
this.sessionLifetime = res.user_info?.attributes?.preferences?.lifetime ?? _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2718
|
+
this.authenticated$.next(true);
|
|
2646
2719
|
}
|
|
2647
2720
|
}),
|
|
2648
2721
|
finalize(() => {
|
|
2649
|
-
this.
|
|
2722
|
+
this.endLogin(sentDuring, callerInitiated, answered);
|
|
2650
2723
|
}),
|
|
2651
2724
|
take(1)
|
|
2652
2725
|
);
|
|
@@ -2657,6 +2730,8 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2657
2730
|
* and replayed. The token exists for the credential that cannot be.
|
|
2658
2731
|
*/
|
|
2659
2732
|
loginWithApiKey(credentials) {
|
|
2733
|
+
const { sentDuring, callerInitiated } = this.beginLogin();
|
|
2734
|
+
let answered = false;
|
|
2660
2735
|
const { username, key } = credentials;
|
|
2661
2736
|
const message = createJsonRpcMessage("auth.login_ex", [
|
|
2662
2737
|
{
|
|
@@ -2670,6 +2745,9 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2670
2745
|
const messageId = message.id ?? "";
|
|
2671
2746
|
return this.connection.messages().pipe(
|
|
2672
2747
|
withId(messageId),
|
|
2748
|
+
tap(() => {
|
|
2749
|
+
answered = true;
|
|
2750
|
+
}),
|
|
2673
2751
|
map((msg) => {
|
|
2674
2752
|
if (msg.error) {
|
|
2675
2753
|
const errorMessage = getApiErrorMessage(
|
|
@@ -2685,13 +2763,13 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2685
2763
|
"TrueNAS authentication failed. Has the TrueNAS Connect API key been removed from your TrueNAS server?"
|
|
2686
2764
|
),
|
|
2687
2765
|
tap((res) => {
|
|
2688
|
-
this.
|
|
2689
|
-
this.credentials
|
|
2766
|
+
this.assertNotSuperseded(sentDuring);
|
|
2767
|
+
this.credentials = { username, password: "", key };
|
|
2690
2768
|
this.sessionLifetime = res.user_info?.attributes?.preferences?.lifetime ?? _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2691
2769
|
this.authenticated$.next(true);
|
|
2692
2770
|
}),
|
|
2693
2771
|
finalize(() => {
|
|
2694
|
-
this.
|
|
2772
|
+
this.endLogin(sentDuring, callerInitiated, answered);
|
|
2695
2773
|
}),
|
|
2696
2774
|
take(1)
|
|
2697
2775
|
);
|
|
@@ -2718,6 +2796,10 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2718
2796
|
);
|
|
2719
2797
|
}
|
|
2720
2798
|
logout() {
|
|
2799
|
+
this.credentials = { username: "", password: "", key: "" };
|
|
2800
|
+
this.sessionLifetime = _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2801
|
+
this.authEpoch += 1;
|
|
2802
|
+
this.authenticated$.next(false);
|
|
2721
2803
|
const message = createJsonRpcMessage("auth.logout");
|
|
2722
2804
|
this.connection.send(message);
|
|
2723
2805
|
const messageId = message.id ?? "";
|
|
@@ -2729,10 +2811,6 @@ var TrueNasAuthenticator = class _TrueNasAuthenticator {
|
|
|
2729
2811
|
}
|
|
2730
2812
|
return msg.result;
|
|
2731
2813
|
}),
|
|
2732
|
-
tap((success) => {
|
|
2733
|
-
this.sessionLifetime = _TrueNasAuthenticator.DefaultSessionLifetime;
|
|
2734
|
-
this.authenticated$.next(!success);
|
|
2735
|
-
}),
|
|
2736
2814
|
take(1)
|
|
2737
2815
|
);
|
|
2738
2816
|
}
|
|
@@ -3923,6 +4001,12 @@ function errorMessageOrDefault(error, fallback) {
|
|
|
3923
4001
|
return fallback;
|
|
3924
4002
|
}
|
|
3925
4003
|
|
|
3926
|
-
|
|
4004
|
+
// src/enums/user-role.enum.ts
|
|
4005
|
+
var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
4006
|
+
UserRole2["FullAdmin"] = "FULL_ADMIN";
|
|
4007
|
+
return UserRole2;
|
|
4008
|
+
})(UserRole || {});
|
|
4009
|
+
|
|
4010
|
+
export { AppState, AuthError, AuthErrorCode, InvalidVersionResponseError, JobState, NoCompatibleVersionsError, SUPPORTED_API_VERSIONS, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, UserRole, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, v25_10_0_exports as v25_10_0, v25_10_1_exports as v25_10_1, v25_10_2_exports as v25_10_2, v25_10_3_exports as v25_10_3, v25_10_4_exports as v25_10_4, v25_10_5_exports as v25_10_5, v26_0_0_exports as v26_0_0, v27_0_0_exports as v27_0_0 };
|
|
3927
4011
|
//# sourceMappingURL=index.js.map
|
|
3928
4012
|
//# sourceMappingURL=index.js.map
|