@bagelink/auth 1.1.45 → 1.1.47

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.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const axios = require('axios');
4
+ const vue = require('vue');
4
5
 
5
6
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
6
7
 
@@ -102,19 +103,14 @@ class AuthApi {
102
103
  }
103
104
 
104
105
  let authApi = null;
105
- const currentUser = {
106
- value: {
107
- id: "",
108
- email: "",
109
- first_name: "",
110
- last_name: "",
111
- is_superuser: false,
112
- is_active: false
113
- },
114
- set: (newValue) => {
115
- currentUser.value = newValue;
116
- }
117
- };
106
+ const currentUser = vue.ref({
107
+ id: "",
108
+ email: "",
109
+ first_name: "",
110
+ last_name: "",
111
+ is_superuser: false,
112
+ is_active: false
113
+ });
118
114
  function initAuth({
119
115
  axios,
120
116
  baseURL
@@ -156,7 +152,7 @@ function useAuth() {
156
152
  try {
157
153
  if (!getIsLoggedIn()) {
158
154
  const { data } = await authApi.getCurrentUser();
159
- currentUser.set(data);
155
+ currentUser.value = data;
160
156
  }
161
157
  } catch (error) {
162
158
  return false;
@@ -169,7 +165,7 @@ function useAuth() {
169
165
  throw new Error("Passwords do not match");
170
166
  }
171
167
  const { data } = await authApi.signup(user);
172
- currentUser.set(data);
168
+ currentUser.value = data;
173
169
  } catch (error) {
174
170
  throw error;
175
171
  }
@@ -201,7 +197,7 @@ function useAuth() {
201
197
  async function updateProfile(user) {
202
198
  try {
203
199
  const { data } = await authApi.updateUserProfile(user);
204
- currentUser.set({ ...currentUser.value, ...data });
200
+ currentUser.value = { ...currentUser.value, ...data };
205
201
  } catch (error) {
206
202
  throw error;
207
203
  }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse, AxiosInstance } from 'axios';
2
+ import * as vue from 'vue';
2
3
  import { App } from 'vue';
3
4
 
4
5
  interface User {
@@ -23,12 +24,6 @@ interface UpdatePasswordForm {
23
24
  new_password: string;
24
25
  confirmNewPassword: string;
25
26
  }
26
- interface ReactiveFactory {
27
- <T>(initial: T): {
28
- value: T;
29
- set: (newValue: T) => void;
30
- };
31
- }
32
27
  interface Token {
33
28
  access_token: string;
34
29
  }
@@ -113,10 +108,21 @@ declare function initAuth({ axios, baseURL, }: {
113
108
  install(app: App): void;
114
109
  };
115
110
  declare function useAuth(): {
116
- currentUser: {
117
- value: User;
118
- set: (newValue: User) => void;
119
- };
111
+ currentUser: vue.Ref<{
112
+ id: string;
113
+ email: string;
114
+ first_name?: string | undefined;
115
+ last_name?: string | undefined;
116
+ is_superuser?: boolean | undefined;
117
+ is_active?: boolean | undefined;
118
+ }, User | {
119
+ id: string;
120
+ email: string;
121
+ first_name?: string | undefined;
122
+ last_name?: string | undefined;
123
+ is_superuser?: boolean | undefined;
124
+ is_active?: boolean | undefined;
125
+ }>;
120
126
  getFullName: () => string;
121
127
  getIsLoggedIn: () => boolean;
122
128
  logout: () => Promise<void>;
@@ -134,4 +140,4 @@ declare function useAuth(): {
134
140
  deleteUser: (userId: string) => Promise<void>;
135
141
  };
136
142
 
137
- export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
143
+ export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse, AxiosInstance } from 'axios';
2
+ import * as vue from 'vue';
2
3
  import { App } from 'vue';
3
4
 
4
5
  interface User {
@@ -23,12 +24,6 @@ interface UpdatePasswordForm {
23
24
  new_password: string;
24
25
  confirmNewPassword: string;
25
26
  }
26
- interface ReactiveFactory {
27
- <T>(initial: T): {
28
- value: T;
29
- set: (newValue: T) => void;
30
- };
31
- }
32
27
  interface Token {
33
28
  access_token: string;
34
29
  }
@@ -113,10 +108,21 @@ declare function initAuth({ axios, baseURL, }: {
113
108
  install(app: App): void;
114
109
  };
115
110
  declare function useAuth(): {
116
- currentUser: {
117
- value: User;
118
- set: (newValue: User) => void;
119
- };
111
+ currentUser: vue.Ref<{
112
+ id: string;
113
+ email: string;
114
+ first_name?: string | undefined;
115
+ last_name?: string | undefined;
116
+ is_superuser?: boolean | undefined;
117
+ is_active?: boolean | undefined;
118
+ }, User | {
119
+ id: string;
120
+ email: string;
121
+ first_name?: string | undefined;
122
+ last_name?: string | undefined;
123
+ is_superuser?: boolean | undefined;
124
+ is_active?: boolean | undefined;
125
+ }>;
120
126
  getFullName: () => string;
121
127
  getIsLoggedIn: () => boolean;
122
128
  logout: () => Promise<void>;
@@ -134,4 +140,4 @@ declare function useAuth(): {
134
140
  deleteUser: (userId: string) => Promise<void>;
135
141
  };
136
142
 
137
- export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
143
+ export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse, AxiosInstance } from 'axios';
2
+ import * as vue from 'vue';
2
3
  import { App } from 'vue';
3
4
 
4
5
  interface User {
@@ -23,12 +24,6 @@ interface UpdatePasswordForm {
23
24
  new_password: string;
24
25
  confirmNewPassword: string;
25
26
  }
26
- interface ReactiveFactory {
27
- <T>(initial: T): {
28
- value: T;
29
- set: (newValue: T) => void;
30
- };
31
- }
32
27
  interface Token {
33
28
  access_token: string;
34
29
  }
@@ -113,10 +108,21 @@ declare function initAuth({ axios, baseURL, }: {
113
108
  install(app: App): void;
114
109
  };
115
110
  declare function useAuth(): {
116
- currentUser: {
117
- value: User;
118
- set: (newValue: User) => void;
119
- };
111
+ currentUser: vue.Ref<{
112
+ id: string;
113
+ email: string;
114
+ first_name?: string | undefined;
115
+ last_name?: string | undefined;
116
+ is_superuser?: boolean | undefined;
117
+ is_active?: boolean | undefined;
118
+ }, User | {
119
+ id: string;
120
+ email: string;
121
+ first_name?: string | undefined;
122
+ last_name?: string | undefined;
123
+ is_superuser?: boolean | undefined;
124
+ is_active?: boolean | undefined;
125
+ }>;
120
126
  getFullName: () => string;
121
127
  getIsLoggedIn: () => boolean;
122
128
  logout: () => Promise<void>;
@@ -134,4 +140,4 @@ declare function useAuth(): {
134
140
  deleteUser: (userId: string) => Promise<void>;
135
141
  };
136
142
 
137
- export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
143
+ export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import axios from 'axios';
2
+ import { ref } from 'vue';
2
3
 
3
4
  function createAxiosInstance(baseURL = "") {
4
5
  return axios.create({
@@ -96,19 +97,14 @@ class AuthApi {
96
97
  }
97
98
 
98
99
  let authApi = null;
99
- const currentUser = {
100
- value: {
101
- id: "",
102
- email: "",
103
- first_name: "",
104
- last_name: "",
105
- is_superuser: false,
106
- is_active: false
107
- },
108
- set: (newValue) => {
109
- currentUser.value = newValue;
110
- }
111
- };
100
+ const currentUser = ref({
101
+ id: "",
102
+ email: "",
103
+ first_name: "",
104
+ last_name: "",
105
+ is_superuser: false,
106
+ is_active: false
107
+ });
112
108
  function initAuth({
113
109
  axios,
114
110
  baseURL
@@ -150,7 +146,7 @@ function useAuth() {
150
146
  try {
151
147
  if (!getIsLoggedIn()) {
152
148
  const { data } = await authApi.getCurrentUser();
153
- currentUser.set(data);
149
+ currentUser.value = data;
154
150
  }
155
151
  } catch (error) {
156
152
  return false;
@@ -163,7 +159,7 @@ function useAuth() {
163
159
  throw new Error("Passwords do not match");
164
160
  }
165
161
  const { data } = await authApi.signup(user);
166
- currentUser.set(data);
162
+ currentUser.value = data;
167
163
  } catch (error) {
168
164
  throw error;
169
165
  }
@@ -195,7 +191,7 @@ function useAuth() {
195
191
  async function updateProfile(user) {
196
192
  try {
197
193
  const { data } = await authApi.updateUserProfile(user);
198
- currentUser.set({ ...currentUser.value, ...data });
194
+ currentUser.value = { ...currentUser.value, ...data };
199
195
  } catch (error) {
200
196
  throw error;
201
197
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/auth",
3
3
  "type": "module",
4
- "version": "1.1.45",
4
+ "version": "1.1.47",
5
5
  "description": "Bagelink auth package",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -20,8 +20,8 @@ import type {
20
20
  UpdateMeResponse,
21
21
  UpdatePasswordResponse,
22
22
  SignupResponse,
23
- } from '../types'
24
- import { createAxiosInstance } from '../utils'
23
+ } from './types'
24
+ import { createAxiosInstance } from './utils'
25
25
 
26
26
  export class AuthApi {
27
27
  private api: AxiosInstance
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './api/auth'
2
- export * from './composable/useAuth'
1
+ export * from './api'
3
2
  export * from './types'
3
+ export * from './useAuth'
package/src/types.ts CHANGED
@@ -26,13 +26,6 @@ export interface UpdatePasswordForm {
26
26
  confirmNewPassword: string
27
27
  }
28
28
 
29
- export interface ReactiveFactory {
30
- <T>(initial: T): {
31
- value: T
32
- set: (newValue: T) => void
33
- }
34
- }
35
-
36
29
  // API Response Types
37
30
  export interface Token {
38
31
  access_token: string
@@ -1,23 +1,19 @@
1
1
  import type { AxiosInstance } from 'axios'
2
2
  import type { App } from 'vue'
3
- import type { User, NewUser, UpdatePasswordForm } from '../types'
4
- import { AuthApi } from '../api/auth'
3
+ import type { User, NewUser, UpdatePasswordForm } from './types'
4
+ import { ref } from 'vue'
5
+ import { AuthApi } from './api'
5
6
 
6
7
  // Global state
7
8
  let authApi: AuthApi | null = null
8
- const currentUser = {
9
- value: {
10
- id: '',
11
- email: '',
12
- first_name: '',
13
- last_name: '',
14
- is_superuser: false,
15
- is_active: false,
16
- } as User,
17
- set: (newValue: User) => {
18
- currentUser.value = newValue
19
- },
20
- }
9
+ const currentUser = ref<User>({
10
+ id: '',
11
+ email: '',
12
+ first_name: '',
13
+ last_name: '',
14
+ is_superuser: false,
15
+ is_active: false,
16
+ })
21
17
 
22
18
  // Initialize auth
23
19
  export function initAuth({
@@ -74,7 +70,7 @@ export function useAuth() {
74
70
  try {
75
71
  if (!getIsLoggedIn()) {
76
72
  const { data } = await authApi!.getCurrentUser()
77
- currentUser.set(data)
73
+ currentUser.value = data
78
74
  }
79
75
  } catch (error) {
80
76
  return false
@@ -88,7 +84,7 @@ export function useAuth() {
88
84
  throw new Error('Passwords do not match')
89
85
  }
90
86
  const { data } = await authApi!.signup(user)
91
- currentUser.set(data)
87
+ currentUser.value = data
92
88
  } catch (error) {
93
89
  throw error
94
90
  }
@@ -124,7 +120,7 @@ export function useAuth() {
124
120
  async function updateProfile(user: Partial<User>) {
125
121
  try {
126
122
  const { data } = await authApi!.updateUserProfile(user)
127
- currentUser.set({ ...currentUser.value, ...data })
123
+ currentUser.value = { ...currentUser.value, ...data }
128
124
  } catch (error) {
129
125
  throw error
130
126
  }