@pulsar.money/atlas-sdk 0.1.0
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/README.md +5 -0
- package/dist/config/api-config.service.d.ts +5 -0
- package/dist/config/api-config.service.js +29 -0
- package/dist/config/api-config.service.js.map +1 -0
- package/dist/decorator/wallet-address.decorator.d.ts +1 -0
- package/dist/decorator/wallet-address.decorator.js +28 -0
- package/dist/decorator/wallet-address.decorator.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/profiles/dto/index.d.ts +0 -0
- package/dist/modules/profiles/dto/index.js +1 -0
- package/dist/modules/profiles/dto/index.js.map +1 -0
- package/dist/modules/profiles/dto/link-address.dto.d.ts +3 -0
- package/dist/modules/profiles/dto/link-address.dto.js +24 -0
- package/dist/modules/profiles/dto/link-address.dto.js.map +1 -0
- package/dist/modules/profiles/dto/resend-verification.dto.d.ts +3 -0
- package/dist/modules/profiles/dto/resend-verification.dto.js +24 -0
- package/dist/modules/profiles/dto/resend-verification.dto.js.map +1 -0
- package/dist/modules/profiles/dto/update-profile.dto.d.ts +7 -0
- package/dist/modules/profiles/dto/update-profile.dto.js +46 -0
- package/dist/modules/profiles/dto/update-profile.dto.js.map +1 -0
- package/dist/modules/profiles/dto/verify-email.dto.d.ts +3 -0
- package/dist/modules/profiles/dto/verify-email.dto.js +24 -0
- package/dist/modules/profiles/dto/verify-email.dto.js.map +1 -0
- package/dist/modules/profiles/index.d.ts +3 -0
- package/dist/modules/profiles/index.js +20 -0
- package/dist/modules/profiles/index.js.map +1 -0
- package/dist/modules/profiles/profiles.controller.d.ts +17 -0
- package/dist/modules/profiles/profiles.controller.js +139 -0
- package/dist/modules/profiles/profiles.controller.js.map +1 -0
- package/dist/modules/profiles/profiles.service.d.ts +15 -0
- package/dist/modules/profiles/profiles.service.js +134 -0
- package/dist/modules/profiles/profiles.service.js.map +1 -0
- package/dist/modules/profiles/profiles.types.d.ts +19 -0
- package/dist/modules/profiles/profiles.types.js +3 -0
- package/dist/modules/profiles/profiles.types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ProfilesService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const axios_1 = require("axios");
|
|
15
|
+
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
16
|
+
const api_config_service_1 = require("../../config/api-config.service");
|
|
17
|
+
let ProfilesService = class ProfilesService {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.axiosInstance = axios_1.default.create({
|
|
20
|
+
baseURL: api_config_service_1.ApiConfigService.getAtlasBaseUrl(),
|
|
21
|
+
});
|
|
22
|
+
this.axiosInstance.interceptors.request.use((config) => {
|
|
23
|
+
const token = this.createJwt();
|
|
24
|
+
config.headers["Authorization"] = `Bearer ${token}`;
|
|
25
|
+
return config;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
createJwt() {
|
|
29
|
+
const payload = {
|
|
30
|
+
exp: Math.floor(Date.now() / 1000) + 60,
|
|
31
|
+
};
|
|
32
|
+
return (0, jsonwebtoken_1.sign)(payload, api_config_service_1.ApiConfigService.getAtlasJwtSecret());
|
|
33
|
+
}
|
|
34
|
+
async linkAddress(email, address) {
|
|
35
|
+
try {
|
|
36
|
+
await this.axiosInstance.post("/users/link-email", {
|
|
37
|
+
email,
|
|
38
|
+
address,
|
|
39
|
+
chain: api_config_service_1.ApiConfigService.getServiceType(),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.handleAxiosError(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async verifyEmail(address, code) {
|
|
47
|
+
try {
|
|
48
|
+
await this.axiosInstance.post("/users/verify-email", {
|
|
49
|
+
address,
|
|
50
|
+
code,
|
|
51
|
+
chain: "evm",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.handleAxiosError(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async resendVerificationCode(address, email) {
|
|
59
|
+
try {
|
|
60
|
+
await this.axiosInstance.post("/users/resend-verification", {
|
|
61
|
+
address,
|
|
62
|
+
email,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
this.handleAxiosError(error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async getUserProfile(address) {
|
|
70
|
+
try {
|
|
71
|
+
const response = await this.axiosInstance.get(`/users/${address}`);
|
|
72
|
+
return response.data;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.handleAxiosError(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async checkUsername(username) {
|
|
79
|
+
try {
|
|
80
|
+
const response = await this.axiosInstance.get(`/users/check-username/${username}`);
|
|
81
|
+
return response.data;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.handleAxiosError(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async updateUserProfile(address, updateData, profileImage) {
|
|
88
|
+
const formData = new FormData();
|
|
89
|
+
Object.keys(updateData).forEach((key) => {
|
|
90
|
+
formData.append(key, updateData[key]);
|
|
91
|
+
});
|
|
92
|
+
if (profileImage) {
|
|
93
|
+
const blob = new Blob([profileImage.buffer], {
|
|
94
|
+
type: profileImage.mimetype,
|
|
95
|
+
});
|
|
96
|
+
formData.append("profileImage", blob, profileImage.originalname);
|
|
97
|
+
}
|
|
98
|
+
formData.append("address", address);
|
|
99
|
+
try {
|
|
100
|
+
const response = await this.axiosInstance.put(`/users/${address}`, formData, {
|
|
101
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
102
|
+
});
|
|
103
|
+
return response.data;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
this.handleAxiosError(error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async unlinkAddress(address) {
|
|
110
|
+
try {
|
|
111
|
+
await this.axiosInstance.post("/users/unlink-address", { address });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
this.handleAxiosError(error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
handleAxiosError(error) {
|
|
118
|
+
if (error.response) {
|
|
119
|
+
throw new common_1.HttpException(error.response.data, error.response.status);
|
|
120
|
+
}
|
|
121
|
+
else if (error.request) {
|
|
122
|
+
throw new common_1.HttpException("No response received from the server", common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new common_1.HttpException("Error setting up the request", common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
exports.ProfilesService = ProfilesService;
|
|
130
|
+
exports.ProfilesService = ProfilesService = __decorate([
|
|
131
|
+
(0, common_1.Injectable)(),
|
|
132
|
+
__metadata("design:paramtypes", [])
|
|
133
|
+
], ProfilesService);
|
|
134
|
+
//# sourceMappingURL=profiles.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.service.js","sourceRoot":"","sources":["../../../src/modules/profiles/profiles.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuE;AACvE,iCAA6C;AAC7C,+CAAoC;AAEpC,wEAAmE;AAG5D,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B;QACE,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,qCAAgB,CAAC,eAAe,EAAE;SAC5C,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACrD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;YACpD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,SAAS;QACf,MAAM,OAAO,GAAG;YACd,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;SACxC,CAAC;QACF,OAAO,IAAA,mBAAI,EAAC,OAAO,EAAE,qCAAgB,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,OAAe;QAC9C,IAAI;YACF,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,mBAAmB,EAAE;gBACjD,KAAK;gBACL,OAAO;gBACP,KAAK,EAAE,qCAAgB,CAAC,cAAc,EAAE;aACzC,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EA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C,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACrE;aAAM,IAAI,KAAK,CAAC,OAAO,EAAE;YACxB,MAAM,IAAI,sBAAa,CACrB,sCAAsC,EACtC,mBAAU,CAAC,qBAAqB,CACjC,CAAC;SACH;aAAM;YACL,MAAM,IAAI,sBAAa,CACrB,8BAA8B,EAC9B,mBAAU,CAAC,qBAAqB,CACjC,CAAC;SACH;IACH,CAAC;CACF,CAAA;AArIY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;;GACA,eAAe,CAqI3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface LinkAddressInput {
|
|
2
|
+
email: string;
|
|
3
|
+
}
|
|
4
|
+
export interface ResendVerificationInput {
|
|
5
|
+
email: string;
|
|
6
|
+
phoneNumber: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UserProfile {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
phoneNumber: string;
|
|
12
|
+
username: string;
|
|
13
|
+
profileImageUrl: string;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateUserProfileInput {
|
|
16
|
+
firstName?: string;
|
|
17
|
+
surname?: string;
|
|
18
|
+
username?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../../src/modules/profiles/profiles.types.ts"],"names":[],"mappings":""}
|