@intelicity/gates-sdk 0.1.1 → 0.1.3
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.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/models/profile.d.ts +12 -0
- package/dist/models/profile.d.ts.map +1 -0
- package/dist/models/profile.js +1 -0
- package/dist/models/user.d.ts +1 -1
- package/dist/models/user.d.ts.map +1 -1
- package/dist/services/auth-service.d.ts +3 -3
- package/dist/services/auth-service.d.ts.map +1 -1
- package/dist/services/auth-service.js +1 -1
- package/dist/services/user-service.d.ts +5 -16
- package/dist/services/user-service.d.ts.map +1 -1
- package/dist/services/user-service.js +22 -14
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type { GatesUser } from "./models/user.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export type { User as GatesUser } from "./models/user.js";
|
|
2
|
+
export type { UserProfile as Profile, ProfileAttribute, } from "./models/profile.js";
|
|
3
|
+
export { GatesUserService as UserService, type UserListResponse, type GetAllUsersOptions, } from "./services/user-service.js";
|
|
4
|
+
export { GatesAuthService as AuthService, type VerifyOptions, } from "./services/auth-service.js";
|
|
4
5
|
export { AuthenticationError, TokenExpiredError, InvalidTokenError, MissingAuthorizationError, } from "./errors/error.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EACV,WAAW,IAAI,OAAO,EACtB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,IAAI,WAAW,EAC/B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,IAAI,WAAW,EAC/B,KAAK,aAAa,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { UserService, } from "./services/user-service.js";
|
|
2
|
-
export { AuthService } from "./services/auth-service.js";
|
|
1
|
+
export { GatesUserService as UserService, } from "./services/user-service.js";
|
|
2
|
+
export { GatesAuthService as AuthService, } from "./services/auth-service.js";
|
|
3
3
|
export { AuthenticationError, TokenExpiredError, InvalidTokenError, MissingAuthorizationError, } from "./errors/error.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UserProfile {
|
|
2
|
+
user_id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
name: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
profile_attributes: ProfileAttribute[];
|
|
7
|
+
}
|
|
8
|
+
export interface ProfileAttribute {
|
|
9
|
+
attribute_name: string;
|
|
10
|
+
value: string | boolean | number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/models/profile.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,gBAAgB,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/models/user.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { User } from "../models/user.js";
|
|
2
2
|
export type VerifyOptions = {
|
|
3
3
|
region: string;
|
|
4
4
|
userPoolId: string;
|
|
5
5
|
audience: string;
|
|
6
6
|
requiredGroup?: string | string[];
|
|
7
7
|
};
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class GatesAuthService {
|
|
9
9
|
private readonly region;
|
|
10
10
|
private readonly userPoolId;
|
|
11
11
|
private readonly audience;
|
|
@@ -13,6 +13,6 @@ export declare class AuthService {
|
|
|
13
13
|
constructor(region: string, userPoolId: string, audience: string, requiredGroup?: string | string[]);
|
|
14
14
|
private get issuer();
|
|
15
15
|
isMemberOf(groups?: string[]): boolean;
|
|
16
|
-
verifyToken(token: string): Promise<
|
|
16
|
+
verifyToken(token: string): Promise<User>;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=auth-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../../src/services/auth-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../../src/services/auth-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;gBAGjD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAiCnC,OAAO,KAAK,MAAM,GAEjB;IAED,UAAU,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO;IAgBpC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAiDhD"}
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
+
import { UserProfile } from "../models/profile.js";
|
|
1
2
|
export interface UserListResponse {
|
|
2
|
-
profiles:
|
|
3
|
+
profiles: UserProfile[];
|
|
3
4
|
total?: number;
|
|
4
5
|
page?: number;
|
|
5
6
|
limit?: number;
|
|
6
7
|
nextToken?: string;
|
|
7
8
|
}
|
|
8
|
-
export interface Profile {
|
|
9
|
-
user_id: string;
|
|
10
|
-
email: string;
|
|
11
|
-
name: string;
|
|
12
|
-
enabled: boolean;
|
|
13
|
-
profile_attributes: ProfileAttribute[];
|
|
14
|
-
}
|
|
15
|
-
export interface ProfileAttribute {
|
|
16
|
-
attribute_name: string;
|
|
17
|
-
value: string | boolean | number;
|
|
18
|
-
}
|
|
19
9
|
export interface GetAllUsersOptions {
|
|
20
10
|
page?: number;
|
|
21
11
|
limit?: number;
|
|
22
12
|
filter?: string;
|
|
23
13
|
group?: string;
|
|
24
14
|
}
|
|
25
|
-
export declare class
|
|
15
|
+
export declare class GatesUserService {
|
|
26
16
|
private readonly baseUrl;
|
|
27
17
|
private readonly system;
|
|
28
18
|
private readonly defaultHeaders;
|
|
@@ -37,10 +27,9 @@ export declare class UserService {
|
|
|
37
27
|
getAllUsers(idToken: string): Promise<UserListResponse>;
|
|
38
28
|
/**
|
|
39
29
|
* Busca um usuário específico por ID
|
|
40
|
-
* @param
|
|
41
|
-
* @param userId ID do usuário
|
|
30
|
+
* @param accessToken Token de autenticação
|
|
42
31
|
* @returns Dados do usuário
|
|
43
32
|
*/
|
|
44
|
-
|
|
33
|
+
login(accessToken: string): Promise<UserProfile>;
|
|
45
34
|
}
|
|
46
35
|
//# sourceMappingURL=user-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-service.d.ts","sourceRoot":"","sources":["../../src/services/user-service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"user-service.d.ts","sourceRoot":"","sources":["../../src/services/user-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;gBAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQ3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAExB;IAEF;;;;;OAKG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,GAEd,OAAO,CAAC,gBAAgB,CAAC;IAiD5B;;;;OAIG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CA2CvD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class GatesUserService {
|
|
2
2
|
baseUrl;
|
|
3
3
|
system;
|
|
4
4
|
defaultHeaders;
|
|
@@ -61,31 +61,39 @@ export class UserService {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Busca um usuário específico por ID
|
|
64
|
-
* @param
|
|
65
|
-
* @param userId ID do usuário
|
|
64
|
+
* @param accessToken Token de autenticação
|
|
66
65
|
* @returns Dados do usuário
|
|
67
66
|
*/
|
|
68
|
-
async
|
|
69
|
-
if (!
|
|
70
|
-
throw new Error("
|
|
71
|
-
}
|
|
72
|
-
if (!userId) {
|
|
73
|
-
throw new Error("User ID is required");
|
|
67
|
+
async login(accessToken) {
|
|
68
|
+
if (!accessToken) {
|
|
69
|
+
throw new Error("Access Token is required");
|
|
74
70
|
}
|
|
75
71
|
try {
|
|
76
|
-
const response = await fetch(`${this.baseUrl}/
|
|
77
|
-
method: "
|
|
72
|
+
const response = await fetch(`${this.baseUrl}/login`, {
|
|
73
|
+
method: "POST",
|
|
78
74
|
headers: {
|
|
79
75
|
...this.defaultHeaders,
|
|
80
|
-
Authorization:
|
|
76
|
+
Authorization: `${accessToken}`,
|
|
81
77
|
},
|
|
78
|
+
body: JSON.stringify({ system_name: this.system }),
|
|
82
79
|
});
|
|
83
80
|
if (!response.ok) {
|
|
84
81
|
const errorText = await response.text();
|
|
85
82
|
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
86
83
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
84
|
+
const data = (await response.json());
|
|
85
|
+
// A API retorna { user: {...}, message: "..." }
|
|
86
|
+
if (!data.user) {
|
|
87
|
+
throw new Error("Invalid response format: missing user data");
|
|
88
|
+
}
|
|
89
|
+
const userProfile = {
|
|
90
|
+
user_id: data.user.user_id,
|
|
91
|
+
email: data.user.email,
|
|
92
|
+
name: data.user.name,
|
|
93
|
+
enabled: data.user.enabled,
|
|
94
|
+
profile_attributes: data.user.profile_attributes || [],
|
|
95
|
+
};
|
|
96
|
+
return userProfile;
|
|
89
97
|
}
|
|
90
98
|
catch (error) {
|
|
91
99
|
if (error instanceof Error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intelicity/gates-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Simple SDK for authenticating users with AWS Cognito JWT tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/inteli-city/gates-sdk.git"
|
|
34
|
+
"url": "https://github.com/inteli-city/gates-node-sdk.git"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^24.1.0",
|