@tekcify/auth-backend 2.2.6 → 2.2.7

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 CHANGED
@@ -3,6 +3,7 @@ export * from './verify';
3
3
  export * from './jwks-verifier';
4
4
  export * from './userinfo';
5
5
  export * from './user-profile';
6
+ export * from './user';
6
7
  export * from './application-management';
7
8
  export * from './security';
8
9
  export * from './nestjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ __exportStar(require("./verify"), exports);
19
19
  __exportStar(require("./jwks-verifier"), exports);
20
20
  __exportStar(require("./userinfo"), exports);
21
21
  __exportStar(require("./user-profile"), exports);
22
+ __exportStar(require("./user"), exports);
22
23
  __exportStar(require("./application-management"), exports);
23
24
  __exportStar(require("./security"), exports);
24
25
  __exportStar(require("./nestjs"), exports);
package/dist/user.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ export interface ExportedUserData {
2
+ profile: {
3
+ email: string;
4
+ firstName: string | null;
5
+ lastName: string | null;
6
+ avatarUrl: string | null;
7
+ mfaEnabled: boolean;
8
+ role: string;
9
+ emailVerifiedAt: Date | null;
10
+ lastLoginAt: Date | null;
11
+ createdAt: Date;
12
+ };
13
+ connectedApps: Array<{
14
+ applicationName: string;
15
+ scopes: string[];
16
+ consentedAt: Date;
17
+ }>;
18
+ socialProviders: Array<{
19
+ provider: string;
20
+ email: string;
21
+ connectedAt: Date;
22
+ }>;
23
+ passkeys: Array<{
24
+ name: string | null;
25
+ deviceType: string | null;
26
+ createdAt: Date;
27
+ lastUsedAt: Date | null;
28
+ }>;
29
+ securityActivity: Array<{
30
+ activityType: string;
31
+ ipAddress: string | null;
32
+ location: string | null;
33
+ deviceType: string | null;
34
+ success: boolean | null;
35
+ createdAt: Date;
36
+ }>;
37
+ exportedAt: Date;
38
+ }
39
+ export interface DeleteAccountDto {
40
+ password: string;
41
+ mfaCode?: string;
42
+ confirmDelete: true;
43
+ }
44
+ export declare function exportUserData(accessToken: string): Promise<ExportedUserData>;
45
+ export declare function deleteAccount(accessToken: string, dto: DeleteAccountDto): Promise<{
46
+ message: string;
47
+ }>;
48
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../src/user.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;QAC7B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;QACzB,SAAS,EAAE,IAAI,CAAC;KACjB,CAAC;IACF,a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+ exports.exportUserData = exportUserData;
4
+ exports.deleteAccount = deleteAccount;
5
+ const AUTH_SERVER_URL = 'https://auth-api.tekcify.com';
6
+ function extractErrorMessage(error, fallback) {
7
+ if (error &&
8
+ typeof error === 'object' &&
9
+ 'message' in error &&
10
+ typeof error.message === 'string' &&
11
+ error.message.trim()) {
12
+ return error.message;
13
+ }
14
+ return fallback;
15
+ }
16
+ async function exportUserData(accessToken) {
17
+ const response = await fetch(`${AUTH_SERVER_URL}/api/user/export-data`, {
18
+ method: 'GET',
19
+ headers: {
20
+ Authorization: `Bearer ${accessToken}`,
21
+ },
22
+ });
23
+ if (!response.ok) {
24
+ const error = (await response
25
+ .json()
26
+ .catch(() => ({ message: response.statusText })));
27
+ throw new Error(extractErrorMessage(error, `Failed to export user data: ${response.statusText} (Status: ${response.status})`));
28
+ }
29
+ return response.json();
30
+ }
31
+ async function deleteAccount(accessToken, dto) {
32
+ const response = await fetch(`${AUTH_SERVER_URL}/api/user/account`, {
33
+ method: 'DELETE',
34
+ headers: {
35
+ Authorization: `Bearer ${accessToken}`,
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ body: JSON.stringify(dto),
39
+ });
40
+ if (!response.ok) {
41
+ const error = (await response
42
+ .json()
43
+ .catch(() => ({ message: response.statusText })));
44
+ throw new Error(extractErrorMessage(error, `Failed to delete account: ${response.statusText} (Status: ${response.status})`));
45
+ }
46
+ return response.json();
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekcify/auth-backend",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "description": "Backend authentication helpers for Tekcify Auth. Provides middleware, guards, and utilities for validating JWT tokens and protecting API routes in NestJS and Express applications.",
5
5
  "author": "Tekcify",
6
6
  "main": "./dist/index.js",