tale-js-sdk 1.1.0 → 1.1.1
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/auth/index.d.ts +25 -0
- package/dist/auth/index.js +34 -2
- package/dist/auth/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -26,9 +26,34 @@ export type { LoginRequest, LoginOptions, LoginWithSmsOptions, VerifySmsOptions,
|
|
|
26
26
|
* }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { login } from '@tale/client';
|
|
32
|
+
*
|
|
33
|
+
* // Login with include parameters to control what data is returned
|
|
34
|
+
* const result = await login({
|
|
35
|
+
* username: 'johndoe',
|
|
36
|
+
* password: 'secure_password_123'
|
|
37
|
+
* }, {
|
|
38
|
+
* include_rbac: true, // Include roles and privileges (SDK default: false)
|
|
39
|
+
* include_user_groups: true, // Include user groups (SDK default: false)
|
|
40
|
+
* include_login_methods: true, // Include login methods (SDK default: false)
|
|
41
|
+
* include_attributes: true, // Include user attributes (SDK default: false)
|
|
42
|
+
* include_acl: true // Include ACL records (SDK default: false)
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
29
46
|
* @note The function requires the following environment variables:
|
|
30
47
|
* - TALE_BASE_URL: Base URL for Tale backend services
|
|
31
48
|
* - TALE_APP_KEY: Application key for authentication
|
|
49
|
+
* @note By default, all include parameters are set to false for better performance.
|
|
50
|
+
* Explicitly set them to true if you need the additional data.
|
|
51
|
+
*
|
|
52
|
+
* @param options.include_rbac Include roles and privileges; default false
|
|
53
|
+
* @param options.include_login_methods Include user login methods; default false
|
|
54
|
+
* @param options.include_user_groups Include user groups; default false
|
|
55
|
+
* @param options.include_attributes Include user attributes; default false
|
|
56
|
+
* @param options.include_acl Include ACL records; default false
|
|
32
57
|
*/
|
|
33
58
|
export declare function login(credentials: LoginRequest, options?: LoginOptions): Promise<LoginResponse>;
|
|
34
59
|
/**
|
package/dist/auth/index.js
CHANGED
|
@@ -26,9 +26,34 @@ import { ApiError, ConfigurationError, NetworkError } from "../errors.js";
|
|
|
26
26
|
* }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { login } from '@tale/client';
|
|
32
|
+
*
|
|
33
|
+
* // Login with include parameters to control what data is returned
|
|
34
|
+
* const result = await login({
|
|
35
|
+
* username: 'johndoe',
|
|
36
|
+
* password: 'secure_password_123'
|
|
37
|
+
* }, {
|
|
38
|
+
* include_rbac: true, // Include roles and privileges (SDK default: false)
|
|
39
|
+
* include_user_groups: true, // Include user groups (SDK default: false)
|
|
40
|
+
* include_login_methods: true, // Include login methods (SDK default: false)
|
|
41
|
+
* include_attributes: true, // Include user attributes (SDK default: false)
|
|
42
|
+
* include_acl: true // Include ACL records (SDK default: false)
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
29
46
|
* @note The function requires the following environment variables:
|
|
30
47
|
* - TALE_BASE_URL: Base URL for Tale backend services
|
|
31
48
|
* - TALE_APP_KEY: Application key for authentication
|
|
49
|
+
* @note By default, all include parameters are set to false for better performance.
|
|
50
|
+
* Explicitly set them to true if you need the additional data.
|
|
51
|
+
*
|
|
52
|
+
* @param options.include_rbac Include roles and privileges; default false
|
|
53
|
+
* @param options.include_login_methods Include user login methods; default false
|
|
54
|
+
* @param options.include_user_groups Include user groups; default false
|
|
55
|
+
* @param options.include_attributes Include user attributes; default false
|
|
56
|
+
* @param options.include_acl Include ACL records; default false
|
|
32
57
|
*/
|
|
33
58
|
export async function login(credentials, options) {
|
|
34
59
|
// Validate required fields
|
|
@@ -49,7 +74,14 @@ export async function login(credentials, options) {
|
|
|
49
74
|
if (!appKey) {
|
|
50
75
|
throw new ConfigurationError("Missing required environment variable: TALE_APP_KEY");
|
|
51
76
|
}
|
|
52
|
-
|
|
77
|
+
// Build URL with query parameters
|
|
78
|
+
const url = new URL(String(base).replace(/\/+$/, "") + "/auth/v1/login/username-password");
|
|
79
|
+
// Add include parameters as query params (SDK defaults to false)
|
|
80
|
+
url.searchParams.set("include_rbac", String(options?.include_rbac ?? false));
|
|
81
|
+
url.searchParams.set("include_login_methods", String(options?.include_login_methods ?? false));
|
|
82
|
+
url.searchParams.set("include_user_groups", String(options?.include_user_groups ?? false));
|
|
83
|
+
url.searchParams.set("include_attributes", String(options?.include_attributes ?? false));
|
|
84
|
+
url.searchParams.set("include_acl", String(options?.include_acl ?? false));
|
|
53
85
|
// Build request body
|
|
54
86
|
const requestBody = {
|
|
55
87
|
username: credentials.username.trim(),
|
|
@@ -61,7 +93,7 @@ export async function login(credentials, options) {
|
|
|
61
93
|
};
|
|
62
94
|
let response;
|
|
63
95
|
try {
|
|
64
|
-
response = await globalThis.fetch(url, {
|
|
96
|
+
response = await globalThis.fetch(url.toString(), {
|
|
65
97
|
method: "POST",
|
|
66
98
|
headers: {
|
|
67
99
|
"Content-Type": "application/json",
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -54,6 +54,11 @@ export interface LoginOptions {
|
|
|
54
54
|
device_name?: string;
|
|
55
55
|
device_fingerprint?: string;
|
|
56
56
|
scope?: string;
|
|
57
|
+
include_rbac?: boolean;
|
|
58
|
+
include_login_methods?: boolean;
|
|
59
|
+
include_user_groups?: boolean;
|
|
60
|
+
include_attributes?: boolean;
|
|
61
|
+
include_acl?: boolean;
|
|
57
62
|
}
|
|
58
63
|
export interface LoginResponse {
|
|
59
64
|
app: AppInfo;
|