meet-my-ride 1.0.8 → 1.2.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.
@@ -0,0 +1,12 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { UserLogin, AuthResponse, UserRegisterResponse, VerifyEmailResponse, UserRefreshResponse } from "../users/user.types";
3
+ import { TokenStorage } from "../tokenstorage/tokenstorage";
4
+ export declare class AuthService {
5
+ private http;
6
+ private storage;
7
+ constructor(http: AxiosInstance, storage: TokenStorage);
8
+ login(data: UserLogin): Promise<AuthResponse>;
9
+ register(data: any): Promise<UserRegisterResponse>;
10
+ refresh(refreshToken: string): Promise<UserRefreshResponse>;
11
+ verifyEmail(userId: string, token: string): Promise<VerifyEmailResponse>;
12
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthService = void 0;
4
+ class AuthService {
5
+ constructor(http, storage) {
6
+ this.http = http;
7
+ this.storage = storage;
8
+ }
9
+ async login(data) {
10
+ const res = await this.http.post("/users/login", data);
11
+ if (res.data.accessToken && res.data.refreshToken) {
12
+ await this.storage.setTokens(res.data.accessToken, res.data.refreshToken);
13
+ }
14
+ return res.data;
15
+ }
16
+ async register(data) {
17
+ const res = await this.http.post("/users/register", data);
18
+ return res.data;
19
+ }
20
+ async refresh(refreshToken) {
21
+ var _a;
22
+ const res = await this.http.post("/users/refresh", {
23
+ refreshToken
24
+ });
25
+ if (res.data.accessToken) {
26
+ await this.storage.setTokens(res.data.accessToken, (_a = res.data.refreshToken) !== null && _a !== void 0 ? _a : "");
27
+ }
28
+ return res.data;
29
+ }
30
+ async verifyEmail(userId, token) {
31
+ const res = await this.http.post("/users/verify-email", {
32
+ userId,
33
+ token
34
+ });
35
+ return res.data;
36
+ }
37
+ }
38
+ exports.AuthService = AuthService;
package/dist/client.js CHANGED
@@ -18,7 +18,7 @@ class MeetMyRideClient {
18
18
  }
19
19
  });
20
20
  // Initialize modules/services
21
- this.user = new user_service_1.UserService(this.http, this.setToken.bind(this));
21
+ this.user = new user_service_1.UserService(this.http);
22
22
  }
23
23
  /**
24
24
  * Allow services (like login/refresh) to update the Authorization header.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { MeetMyRideClient } from "./client";
2
- export * from "./models";
2
+ export * from "../src/users/user.types";
package/dist/index.js CHANGED
@@ -17,4 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.MeetMyRideClient = void 0;
18
18
  var client_1 = require("./client");
19
19
  Object.defineProperty(exports, "MeetMyRideClient", { enumerable: true, get: function () { return client_1.MeetMyRideClient; } });
20
- __exportStar(require("./models"), exports);
20
+ __exportStar(require("../src/users/user.types"), exports);
@@ -0,0 +1,6 @@
1
+ export interface TokenStorage {
2
+ getAccessToken(): Promise<string | null>;
3
+ getRefreshToken(): Promise<string | null>;
4
+ setTokens(access: string, refresh: string): Promise<void>;
5
+ clear(): Promise<void>;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,23 +1,11 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { UserLogin, UserRegister, User, UserUpdate, UserRefreshResponse, AuthResponse, UserRegisterResponse, VerifyEmailResponse } from "./user.types";
2
+ import { User, UserUpdate } from "./user.types";
3
3
  export declare class UserService {
4
4
  private http;
5
- private updateToken;
6
- constructor(http: AxiosInstance, updateToken: (token: string) => void);
7
- /** GET /api/Users */
5
+ constructor(http: AxiosInstance);
8
6
  getAll(): Promise<User[]>;
9
- /** GET /api/Users/{userId} */
7
+ create(data: UserUpdate): Promise<User>;
10
8
  getById(userId: string): Promise<User>;
11
- /** PUT /api/Users/{userId} */
12
9
  update(userId: string, data: UserUpdate): Promise<User>;
13
- /** DELETE /api/Users/{userId} */
14
10
  delete(userId: string): Promise<void>;
15
- /** POST /api/Users/register */
16
- register(data: UserRegister): Promise<UserRegisterResponse>;
17
- /** POST /api/Users/login */
18
- login(data: UserLogin): Promise<AuthResponse>;
19
- /** POST /api/Users/refresh */
20
- refresh(refreshToken: string): Promise<UserRefreshResponse>;
21
- /** POST /api/Users/verify-email */
22
- verifyEmail(userId: string, token: string): Promise<VerifyEmailResponse>;
23
11
  }
@@ -2,62 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = void 0;
4
4
  class UserService {
5
- constructor(http, updateToken) {
5
+ constructor(http) {
6
6
  this.http = http;
7
- this.updateToken = updateToken;
8
7
  }
9
- /** GET /api/Users */
10
8
  async getAll() {
11
- const response = await this.http.get("/api/Users");
12
- return response.data;
9
+ const res = await this.http.get("/api/Users");
10
+ return res.data;
11
+ }
12
+ async create(data) {
13
+ const res = await this.http.post("/api/Users", data);
14
+ return res.data;
13
15
  }
14
- /** GET /api/Users/{userId} */
15
16
  async getById(userId) {
16
- const response = await this.http.get(`/api/Users/${userId}`);
17
- return response.data;
17
+ const res = await this.http.get(`/api/Users/${userId}`);
18
+ return res.data;
18
19
  }
19
- /** PUT /api/Users/{userId} */
20
20
  async update(userId, data) {
21
- const response = await this.http.put(`/api/Users/${userId}`, data);
22
- return response.data;
21
+ const res = await this.http.put(`/api/Users/${userId}`, data);
22
+ return res.data;
23
23
  }
24
- /** DELETE /api/Users/{userId} */
25
24
  async delete(userId) {
26
25
  await this.http.delete(`/api/Users/${userId}`);
27
26
  }
28
- /** POST /api/Users/register */
29
- async register(data) {
30
- const response = await this.http.post("/api/Users/register", data);
31
- return response.data;
32
- }
33
- /** POST /api/Users/login */
34
- async login(data) {
35
- const response = await this.http.post("/api/Users/login", data);
36
- const resData = response.data;
37
- // Only update token if it exists
38
- if (resData.accessToken) {
39
- this.updateToken(resData.accessToken);
40
- }
41
- return resData;
42
- }
43
- /** POST /api/Users/refresh */
44
- async refresh(refreshToken) {
45
- const response = await this.http.post("/api/Users/refresh", {
46
- refreshToken
47
- });
48
- const resData = response.data;
49
- if (resData.accessToken) {
50
- this.updateToken(resData.accessToken);
51
- }
52
- return resData;
53
- }
54
- /** POST /api/Users/verify-email */
55
- async verifyEmail(userId, token) {
56
- const response = await this.http.post("/api/Users/verifyEmail", {
57
- userId,
58
- token
59
- });
60
- return response.data;
61
- }
62
27
  }
63
28
  exports.UserService = UserService;
@@ -1,10 +1,18 @@
1
- export interface User {
2
- id: string;
3
- email: string;
4
- emailVerified?: string;
1
+ export interface UserBase {
5
2
  firstName: string;
6
3
  lastName: string;
7
4
  username: string;
5
+ email: string;
6
+ }
7
+ export interface User extends UserBase {
8
+ id: string;
9
+ emailVerified?: string;
10
+ }
11
+ export interface UserRegister extends UserBase {
12
+ password: string;
13
+ }
14
+ export interface UserRegisterResponse extends UserBase {
15
+ id: string;
8
16
  }
9
17
  export interface UserLogin {
10
18
  email: string;
@@ -15,26 +23,8 @@ export interface AuthResponse {
15
23
  accessToken?: string;
16
24
  refreshToken?: string;
17
25
  }
18
- export interface UserRegister {
19
- email: string;
20
- password: string;
21
- firstName: string;
22
- lastName: string;
23
- username: string;
24
- }
25
- export interface UserRegisterResponse {
26
- id: string;
27
- username: string;
28
- firstName: string;
29
- lastName: string;
30
- email: string;
31
- }
32
- export interface UserUpdate {
33
- email?: string;
34
- firstName?: string;
35
- lastName?: string;
26
+ export interface UserUpdate extends Partial<UserBase> {
36
27
  password?: string;
37
- username?: string;
38
28
  }
39
29
  export interface UserRefreshResponse {
40
30
  accessToken: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meet-my-ride",
3
- "version": "1.0.8",
3
+ "version": "1.2.0",
4
4
  "description": "Private library for the MeetMyRide applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,13 +15,15 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "tsc",
18
- "publish:patch": "npm run build && npm version patch && npm publish",
19
- "publish:minor": "npm run build && npm version minor && npm publish",
20
- "publish:major": "npm run build && npm version major && npm publish",
18
+ "publish:patch": "npm version patch && npm run build && npm publish",
19
+ "publish:minor": "npm version minor && npm run build && npm publish",
20
+ "publish:major": "npm version major && npm run build && npm publish",
21
21
  "test": "echo \"Error: no test specified\" && exit 1"
22
22
  },
23
23
  "dependencies": {
24
- "axios": "^1.13.2"
24
+ "@capacitor/preferences": "^7.0.2",
25
+ "axios": "^1.13.2",
26
+ "rxjs": "^7.8.2"
25
27
  },
26
28
  "devDependencies": {
27
29
  "@types/node": "^24.10.1",