@tekcify/auth-backend 2.0.2 → 2.0.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/application-management.js +18 -9
- package/dist/express/index.d.ts +2 -2
- package/dist/express/index.d.ts.map +1 -1
- package/dist/express/index.js +5 -1
- package/dist/express/middleware.d.ts +1 -1
- package/dist/express/middleware.d.ts.map +1 -1
- package/dist/express/middleware.js +6 -3
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -7
- package/dist/nestjs/decorator.js +5 -2
- package/dist/nestjs/guard.d.ts +1 -1
- package/dist/nestjs/guard.d.ts.map +1 -1
- package/dist/nestjs/guard.js +11 -8
- package/dist/nestjs/index.d.ts +4 -4
- package/dist/nestjs/index.d.ts.map +1 -1
- package/dist/nestjs/index.js +7 -2
- package/dist/types.js +2 -1
- package/dist/user-profile.js +12 -7
- package/dist/userinfo.js +9 -5
- package/dist/verify.d.ts +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +40 -3
- package/package.json +1 -2
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listApplications = listApplications;
|
|
4
|
+
exports.getApplicationByClientId = getApplicationByClientId;
|
|
5
|
+
exports.createApplication = createApplication;
|
|
6
|
+
exports.updateApplication = updateApplication;
|
|
7
|
+
exports.deleteApplication = deleteApplication;
|
|
8
|
+
exports.uploadApplicationLogo = uploadApplicationLogo;
|
|
9
|
+
exports.regenerateApplicationSecret = regenerateApplicationSecret;
|
|
10
|
+
const auth_core_client_1 = require("@tekcify/auth-core-client");
|
|
2
11
|
function buildUrl(path, query) {
|
|
3
|
-
const url = new URL(`${AUTH_SERVER_URL}${path}`);
|
|
12
|
+
const url = new URL(`${auth_core_client_1.AUTH_SERVER_URL}${path}`);
|
|
4
13
|
Object.entries(query ?? {}).forEach(([key, value]) => {
|
|
5
14
|
if (value !== undefined) {
|
|
6
15
|
url.searchParams.set(key, String(value));
|
|
@@ -62,7 +71,7 @@ async function request(config) {
|
|
|
62
71
|
}
|
|
63
72
|
return payload;
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
async function listApplications(accessToken, options) {
|
|
66
75
|
const page = options?.page ?? 1;
|
|
67
76
|
const limit = options?.limit ?? 10;
|
|
68
77
|
return request({
|
|
@@ -73,14 +82,14 @@ export async function listApplications(accessToken, options) {
|
|
|
73
82
|
query: { page, limit },
|
|
74
83
|
});
|
|
75
84
|
}
|
|
76
|
-
|
|
85
|
+
async function getApplicationByClientId(clientId) {
|
|
77
86
|
return request({
|
|
78
87
|
path: `/api/applications/public/${clientId}`,
|
|
79
88
|
method: 'GET',
|
|
80
89
|
defaultError: 'Failed to get application',
|
|
81
90
|
});
|
|
82
91
|
}
|
|
83
|
-
|
|
92
|
+
async function createApplication(accessToken, data) {
|
|
84
93
|
return request({
|
|
85
94
|
path: '/api/applications',
|
|
86
95
|
method: 'POST',
|
|
@@ -89,7 +98,7 @@ export async function createApplication(accessToken, data) {
|
|
|
89
98
|
body: data,
|
|
90
99
|
});
|
|
91
100
|
}
|
|
92
|
-
|
|
101
|
+
async function updateApplication(accessToken, clientId, data) {
|
|
93
102
|
return request({
|
|
94
103
|
path: `/api/applications/${clientId}`,
|
|
95
104
|
method: 'PUT',
|
|
@@ -98,7 +107,7 @@ export async function updateApplication(accessToken, clientId, data) {
|
|
|
98
107
|
body: data,
|
|
99
108
|
});
|
|
100
109
|
}
|
|
101
|
-
|
|
110
|
+
async function deleteApplication(accessToken, clientId) {
|
|
102
111
|
return request({
|
|
103
112
|
path: `/api/applications/${clientId}`,
|
|
104
113
|
method: 'DELETE',
|
|
@@ -106,7 +115,7 @@ export async function deleteApplication(accessToken, clientId) {
|
|
|
106
115
|
token: accessToken,
|
|
107
116
|
});
|
|
108
117
|
}
|
|
109
|
-
|
|
118
|
+
async function uploadApplicationLogo(accessToken, clientId, file, fileName) {
|
|
110
119
|
const formData = new FormData();
|
|
111
120
|
if (fileName && !(file instanceof File)) {
|
|
112
121
|
formData.append('file', file, fileName);
|
|
@@ -122,7 +131,7 @@ export async function uploadApplicationLogo(accessToken, clientId, file, fileNam
|
|
|
122
131
|
formData,
|
|
123
132
|
});
|
|
124
133
|
}
|
|
125
|
-
|
|
134
|
+
async function regenerateApplicationSecret(accessToken, clientId) {
|
|
126
135
|
return request({
|
|
127
136
|
path: `/api/applications/${clientId}/regenerate-secret`,
|
|
128
137
|
method: 'POST',
|
package/dist/express/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createAuthMiddleware } from './middleware
|
|
2
|
-
export type { ExpressAuthOptions } from './middleware
|
|
1
|
+
export { createAuthMiddleware } from './middleware';
|
|
2
|
+
export type { ExpressAuthOptions } from './middleware';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/express/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthMiddleware = void 0;
|
|
4
|
+
var middleware_1 = require("./middleware");
|
|
5
|
+
Object.defineProperty(exports, "createAuthMiddleware", { enumerable: true, get: function () { return middleware_1.createAuthMiddleware; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Request, Response, NextFunction } from 'express';
|
|
2
|
-
import type { VerifyTokenOptions, UserPayload } from '../types
|
|
2
|
+
import type { VerifyTokenOptions, UserPayload } from '../types';
|
|
3
3
|
export interface ExpressAuthOptions extends VerifyTokenOptions {
|
|
4
4
|
getUserInfo?: (userId: string) => Promise<{
|
|
5
5
|
email: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/express/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/express/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;CACrE;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE,WAAW,CAAC;SACpB;KACF;CACF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,IAE5D,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAAC,CAsCjB"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthMiddleware = createAuthMiddleware;
|
|
4
|
+
const verify_1 = require("../verify");
|
|
5
|
+
function createAuthMiddleware(options) {
|
|
3
6
|
return async (req, res, next) => {
|
|
4
7
|
const authHeader = req.headers.authorization;
|
|
5
8
|
if (!authHeader?.startsWith('Bearer ')) {
|
|
@@ -9,7 +12,7 @@ export function createAuthMiddleware(options) {
|
|
|
9
12
|
return;
|
|
10
13
|
}
|
|
11
14
|
const token = authHeader.substring(7);
|
|
12
|
-
const verified = verifyAccessToken(token, options);
|
|
15
|
+
const verified = (0, verify_1.verifyAccessToken)(token, options);
|
|
13
16
|
if (!verified.valid) {
|
|
14
17
|
res.status(401).json({ message: 'Invalid or expired token' });
|
|
15
18
|
return;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './types
|
|
2
|
-
export * from './verify
|
|
3
|
-
export * from './userinfo
|
|
4
|
-
export * from './user-profile
|
|
5
|
-
export * from './application-management
|
|
6
|
-
export * from './nestjs
|
|
7
|
-
export * from './express
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './verify';
|
|
3
|
+
export * from './userinfo';
|
|
4
|
+
export * from './user-profile';
|
|
5
|
+
export * from './application-management';
|
|
6
|
+
export * from './nestjs';
|
|
7
|
+
export * from './express';
|
|
8
8
|
//# 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":"AAAA,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,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./verify"), exports);
|
|
19
|
+
__exportStar(require("./userinfo"), exports);
|
|
20
|
+
__exportStar(require("./user-profile"), exports);
|
|
21
|
+
__exportStar(require("./application-management"), exports);
|
|
22
|
+
__exportStar(require("./nestjs"), exports);
|
|
23
|
+
__exportStar(require("./express"), exports);
|
package/dist/nestjs/decorator.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
3
6
|
const request = ctx
|
|
4
7
|
.switchToHttp()
|
|
5
8
|
.getRequest();
|
package/dist/nestjs/guard.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import type { VerifyTokenOptions } from '../types
|
|
2
|
+
import type { VerifyTokenOptions } from '../types';
|
|
3
3
|
export interface JwtAuthGuardOptions extends VerifyTokenOptions {
|
|
4
4
|
getUserInfo?: (userId: string) => Promise<{
|
|
5
5
|
email: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/nestjs/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/nestjs/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;CACrE;AAED,qBACa,YAAa,YAAW,WAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,mBAAmB;IAEnD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAsC/D"}
|
package/dist/nestjs/guard.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
3
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
4
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -36,10 +37,12 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
36
37
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
37
38
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.JwtAuthGuard = void 0;
|
|
42
|
+
const common_1 = require("@nestjs/common");
|
|
43
|
+
const verify_1 = require("../verify");
|
|
41
44
|
let JwtAuthGuard = (() => {
|
|
42
|
-
let _classDecorators = [Injectable()];
|
|
45
|
+
let _classDecorators = [(0, common_1.Injectable)()];
|
|
43
46
|
let _classDescriptor;
|
|
44
47
|
let _classExtraInitializers = [];
|
|
45
48
|
let _classThis;
|
|
@@ -53,18 +56,18 @@ let JwtAuthGuard = (() => {
|
|
|
53
56
|
.getRequest();
|
|
54
57
|
const authHeader = request.headers.authorization;
|
|
55
58
|
if (!authHeader?.startsWith('Bearer ')) {
|
|
56
|
-
throw new UnauthorizedException('Missing or invalid authorization header');
|
|
59
|
+
throw new common_1.UnauthorizedException('Missing or invalid authorization header');
|
|
57
60
|
}
|
|
58
61
|
const token = authHeader.substring(7);
|
|
59
|
-
const verified = verifyAccessToken(token, this.options);
|
|
62
|
+
const verified = (0, verify_1.verifyAccessToken)(token, this.options);
|
|
60
63
|
if (!verified.valid) {
|
|
61
|
-
throw new UnauthorizedException('Invalid or expired token');
|
|
64
|
+
throw new common_1.UnauthorizedException('Invalid or expired token');
|
|
62
65
|
}
|
|
63
66
|
let email = '';
|
|
64
67
|
if (this.options.getUserInfo) {
|
|
65
68
|
const userInfo = await this.options.getUserInfo(verified.payload.sub);
|
|
66
69
|
if (!userInfo) {
|
|
67
|
-
throw new UnauthorizedException('User not found');
|
|
70
|
+
throw new common_1.UnauthorizedException('User not found');
|
|
68
71
|
}
|
|
69
72
|
email = userInfo.email;
|
|
70
73
|
}
|
|
@@ -88,4 +91,4 @@ let JwtAuthGuard = (() => {
|
|
|
88
91
|
})();
|
|
89
92
|
return JwtAuthGuard = _classThis;
|
|
90
93
|
})();
|
|
91
|
-
|
|
94
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
package/dist/nestjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { JwtAuthGuard } from './guard
|
|
2
|
-
export type { JwtAuthGuardOptions } from './guard
|
|
3
|
-
export { CurrentUser } from './decorator
|
|
4
|
-
export type { UserPayload } from '../types
|
|
1
|
+
export { JwtAuthGuard } from './guard';
|
|
2
|
+
export type { JwtAuthGuardOptions } from './guard';
|
|
3
|
+
export { CurrentUser } from './decorator';
|
|
4
|
+
export type { UserPayload } from '../types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/nestjs/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = exports.JwtAuthGuard = void 0;
|
|
4
|
+
var guard_1 = require("./guard");
|
|
5
|
+
Object.defineProperty(exports, "JwtAuthGuard", { enumerable: true, get: function () { return guard_1.JwtAuthGuard; } });
|
|
6
|
+
var decorator_1 = require("./decorator");
|
|
7
|
+
Object.defineProperty(exports, "CurrentUser", { enumerable: true, get: function () { return decorator_1.CurrentUser; } });
|
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/user-profile.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserProfile = getUserProfile;
|
|
4
|
+
exports.updateUserProfile = updateUserProfile;
|
|
5
|
+
exports.uploadProfilePicture = uploadProfilePicture;
|
|
6
|
+
const auth_core_client_1 = require("@tekcify/auth-core-client");
|
|
7
|
+
async function getUserProfile(accessToken) {
|
|
8
|
+
const response = await fetch(`${auth_core_client_1.AUTH_SERVER_URL}/api/user/profile`, {
|
|
4
9
|
method: 'GET',
|
|
5
10
|
headers: {
|
|
6
11
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -20,8 +25,8 @@ export async function getUserProfile(accessToken) {
|
|
|
20
25
|
}
|
|
21
26
|
return response.json();
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
const response = await fetch(`${AUTH_SERVER_URL}/api/user/profile`, {
|
|
28
|
+
async function updateUserProfile(accessToken, data) {
|
|
29
|
+
const response = await fetch(`${auth_core_client_1.AUTH_SERVER_URL}/api/user/profile`, {
|
|
25
30
|
method: 'PUT',
|
|
26
31
|
headers: {
|
|
27
32
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -42,7 +47,7 @@ export async function updateUserProfile(accessToken, data) {
|
|
|
42
47
|
}
|
|
43
48
|
return response.json();
|
|
44
49
|
}
|
|
45
|
-
|
|
50
|
+
async function uploadProfilePicture(accessToken, file, fileName) {
|
|
46
51
|
const formData = new FormData();
|
|
47
52
|
if (fileName && !(file instanceof File)) {
|
|
48
53
|
formData.append('file', file, fileName);
|
|
@@ -50,7 +55,7 @@ export async function uploadProfilePicture(accessToken, file, fileName) {
|
|
|
50
55
|
else {
|
|
51
56
|
formData.append('file', file);
|
|
52
57
|
}
|
|
53
|
-
const response = await fetch(`${AUTH_SERVER_URL}/api/user/profile/picture`, {
|
|
58
|
+
const response = await fetch(`${auth_core_client_1.AUTH_SERVER_URL}/api/user/profile/picture`, {
|
|
54
59
|
method: 'POST',
|
|
55
60
|
headers: {
|
|
56
61
|
Authorization: `Bearer ${accessToken}`,
|
package/dist/userinfo.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchUserInfo = fetchUserInfo;
|
|
4
|
+
exports.introspectAccessToken = introspectAccessToken;
|
|
5
|
+
const auth_core_client_1 = require("@tekcify/auth-core-client");
|
|
6
|
+
async function fetchUserInfo(accessToken) {
|
|
7
|
+
return (0, auth_core_client_1.getUserInfo)(accessToken);
|
|
4
8
|
}
|
|
5
|
-
|
|
6
|
-
return introspectToken({
|
|
9
|
+
async function introspectAccessToken(options) {
|
|
10
|
+
return (0, auth_core_client_1.introspectToken)({
|
|
7
11
|
token: options.token,
|
|
8
12
|
clientId: options.clientId,
|
|
9
13
|
clientSecret: options.clientSecret,
|
package/dist/verify.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TokenPayload, VerifyTokenOptions, VerifiedToken } from "./types
|
|
1
|
+
import type { TokenPayload, VerifyTokenOptions, VerifiedToken } from "./types";
|
|
2
2
|
export declare function verifyAccessToken(token: string, options: VerifyTokenOptions): VerifiedToken;
|
|
3
3
|
export declare function decodeToken(token: string): TokenPayload | null;
|
|
4
4
|
//# sourceMappingURL=verify.d.ts.map
|
package/dist/verify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/E,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAqBf;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAM9D"}
|
package/dist/verify.js
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.verifyAccessToken = verifyAccessToken;
|
|
37
|
+
exports.decodeToken = decodeToken;
|
|
38
|
+
const jwt = __importStar(require("jsonwebtoken"));
|
|
39
|
+
function verifyAccessToken(token, options) {
|
|
3
40
|
try {
|
|
4
41
|
const decoded = jwt.verify(token, options.secret, {
|
|
5
42
|
issuer: options.issuer ?? "tekcify-auth",
|
|
@@ -20,7 +57,7 @@ export function verifyAccessToken(token, options) {
|
|
|
20
57
|
throw error;
|
|
21
58
|
}
|
|
22
59
|
}
|
|
23
|
-
|
|
60
|
+
function decodeToken(token) {
|
|
24
61
|
try {
|
|
25
62
|
return jwt.decode(token);
|
|
26
63
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tekcify/auth-backend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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
|
-
"type": "module",
|
|
7
6
|
"main": "./dist/index.js",
|
|
8
7
|
"types": "./dist/index.d.ts",
|
|
9
8
|
"repository": {
|