@autenticar-me/vue 0.1.0 → 0.3.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/dist/components/AuthSwitcher.vue.d.ts +2 -2
- package/dist/components/AuthSwitcher.vue.d.ts.map +1 -0
- package/dist/components/Buttons/SignInButton.vue.d.ts +2 -2
- package/dist/components/Buttons/SignInButton.vue.d.ts.map +1 -0
- package/dist/components/Buttons/SignOutButton.vue.d.ts +2 -2
- package/dist/components/Buttons/SignOutButton.vue.d.ts.map +1 -0
- package/dist/components/Buttons/SignUpButton.vue.d.ts +2 -2
- package/dist/components/Buttons/SignUpButton.vue.d.ts.map +1 -0
- package/dist/components/Layout/SignedIn.vue.d.ts +12 -7
- package/dist/components/Layout/SignedIn.vue.d.ts.map +1 -0
- package/dist/components/Layout/SignedOut.vue.d.ts +12 -7
- package/dist/components/Layout/SignedOut.vue.d.ts.map +1 -0
- package/dist/components/Modals/Modal.vue.d.ts +15 -10
- package/dist/components/Modals/Modal.vue.d.ts.map +1 -0
- package/dist/components/Modals/SignInModal.vue.d.ts +4 -4
- package/dist/components/Modals/SignInModal.vue.d.ts.map +1 -0
- package/dist/components/Modals/SignUpModal.vue.d.ts +4 -4
- package/dist/components/Modals/SignUpModal.vue.d.ts.map +1 -0
- package/dist/components/Notification.vue.d.ts +3 -3
- package/dist/components/Notification.vue.d.ts.map +1 -0
- package/dist/components/SignIn.vue.d.ts +7 -4
- package/dist/components/SignIn.vue.d.ts.map +1 -0
- package/dist/components/SignUp.vue.d.ts +7 -4
- package/dist/components/SignUp.vue.d.ts.map +1 -0
- package/dist/components/UserProfile.vue.d.ts +4 -2
- package/dist/components/UserProfile.vue.d.ts.map +1 -0
- package/dist/composables/useAtm.d.ts +5 -4
- package/dist/composables/useAtm.d.ts.map +1 -0
- package/dist/composables/useAtmClient.d.ts +2 -1
- package/dist/composables/useAtmClient.d.ts.map +1 -0
- package/dist/composables/useAuth.d.ts +3 -2
- package/dist/composables/useAuth.d.ts.map +1 -0
- package/dist/index.cjs +2278 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +18 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2277 -31
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.d.ts.map +1 -0
- package/dist/types/configurations.type.d.ts +10 -0
- package/dist/types/configurations.type.d.ts.map +1 -0
- package/dist/types/session.type.d.ts +1 -0
- package/dist/types/session.type.d.ts.map +1 -0
- package/dist/types/user-attribute.type.d.ts +1 -0
- package/dist/types/user-attribute.type.d.ts.map +1 -0
- package/dist/types/user.type.d.ts +2 -1
- package/dist/types/user.type.d.ts.map +1 -0
- package/dist/utils/device.d.ts +2 -1
- package/dist/utils/device.d.ts.map +1 -0
- package/dist/utils/fetch-configurations.d.ts +3 -2
- package/dist/utils/fetch-configurations.d.ts.map +1 -0
- package/dist/utils/fetch-user.d.ts +3 -2
- package/dist/utils/fetch-user.d.ts.map +1 -0
- package/dist/utils/tokens.d.ts +1 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/package.json +28 -5
- package/.claude/settings.local.json +0 -7
- package/dist/components/AuthSwitcher.vue.js +0 -76
- package/dist/components/Buttons/SignInButton.vue.js +0 -110
- package/dist/components/Buttons/SignOutButton.vue.js +0 -68
- package/dist/components/Buttons/SignUpButton.vue.js +0 -86
- package/dist/components/Layout/SignedIn.vue.js +0 -54
- package/dist/components/Layout/SignedOut.vue.js +0 -54
- package/dist/components/Modals/Modal.vue.js +0 -133
- package/dist/components/Modals/SignInModal.vue.js +0 -149
- package/dist/components/Modals/SignUpModal.vue.js +0 -165
- package/dist/components/Notification.vue.js +0 -95
- package/dist/components/SignIn.vue.js +0 -485
- package/dist/components/SignUp.vue.js +0 -339
- package/dist/components/UserProfile.vue.js +0 -916
- package/dist/composables/useAtm.js +0 -11
- package/dist/composables/useAtmClient.js +0 -8
- package/dist/composables/useAuth.js +0 -38
- package/dist/plugin.js +0 -33
- package/dist/types/configurations.type.js +0 -2
- package/dist/types/session.type.js +0 -2
- package/dist/types/user-attribute.type.js +0 -2
- package/dist/types/user.type.js +0 -2
- package/dist/utils/device.js +0 -46
- package/dist/utils/fetch-configurations.js +0 -45
- package/dist/utils/fetch-user.js +0 -36
- package/dist/utils/tokens.js +0 -46
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAtm = useAtm;
|
|
4
|
-
const vue_1 = require("vue");
|
|
5
|
-
function useAtm() {
|
|
6
|
-
const ctx = (0, vue_1.inject)('atm');
|
|
7
|
-
if (!ctx) {
|
|
8
|
-
throw new Error('[Autenticar.me] É necessário configurar o plugin no main.ts');
|
|
9
|
-
}
|
|
10
|
-
return ctx;
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useAuth = useAuth;
|
|
13
|
-
const fetch_user_1 = require("../utils/fetch-user");
|
|
14
|
-
const tokens_1 = require("../utils/tokens");
|
|
15
|
-
const useAtm_1 = require("./useAtm");
|
|
16
|
-
function useAuth() {
|
|
17
|
-
const { client, user } = (0, useAtm_1.useAtm)();
|
|
18
|
-
const signInByAccessToken = (accessToken) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
(0, tokens_1.writeAccessTokenInCookie)(accessToken);
|
|
20
|
-
yield (0, fetch_user_1.fetchUser)(client, user);
|
|
21
|
-
});
|
|
22
|
-
const logout = () => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const accessToken = yield (0, tokens_1.getAccessToken)();
|
|
24
|
-
if (accessToken == null) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
yield client.value.account(accessToken).logout();
|
|
28
|
-
user.value = null;
|
|
29
|
-
(0, tokens_1.writeAccessTokenInCookie)(null);
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
user,
|
|
33
|
-
signInByAccessToken,
|
|
34
|
-
getAccessToken: tokens_1.getAccessToken,
|
|
35
|
-
fetchUser: fetch_user_1.fetchUser,
|
|
36
|
-
logout,
|
|
37
|
-
};
|
|
38
|
-
}
|
package/dist/plugin.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.atmPlugin = void 0;
|
|
4
|
-
const vue_1 = require("vue");
|
|
5
|
-
const client_js_1 = require("@autenticar-me/client-js");
|
|
6
|
-
const fetch_user_1 = require("./utils/fetch-user");
|
|
7
|
-
const fetch_configurations_1 = require("./utils/fetch-configurations");
|
|
8
|
-
exports.atmPlugin = {
|
|
9
|
-
install(app, pluginOptions) {
|
|
10
|
-
const atmClient = new client_js_1.AtmClient({
|
|
11
|
-
domain: pluginOptions.domain,
|
|
12
|
-
publicKey: pluginOptions.publicKey,
|
|
13
|
-
ssl: false,
|
|
14
|
-
});
|
|
15
|
-
const client = (0, vue_1.ref)(atmClient);
|
|
16
|
-
const user = (0, vue_1.ref)(null);
|
|
17
|
-
const configurations = (0, vue_1.ref)(null);
|
|
18
|
-
const isSignedIn = (0, vue_1.computed)(() => user.value !== undefined && user.value !== null);
|
|
19
|
-
const isLoaded = (0, vue_1.ref)(false);
|
|
20
|
-
Promise.all([
|
|
21
|
-
(0, fetch_user_1.fetchUser)(client, user),
|
|
22
|
-
(0, fetch_configurations_1.fetchConfigurations)(client, configurations)
|
|
23
|
-
])
|
|
24
|
-
.then(() => isLoaded.value = true);
|
|
25
|
-
app.provide('atm', {
|
|
26
|
-
client,
|
|
27
|
-
user,
|
|
28
|
-
configurations,
|
|
29
|
-
isSignedIn,
|
|
30
|
-
isLoaded,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
package/dist/types/user.type.js
DELETED
package/dist/utils/device.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.clearDeviceToken = exports.getDeviceToken = void 0;
|
|
13
|
-
const DEVICE_TOKEN_KEY = 'atm_device_token';
|
|
14
|
-
const getDeviceToken = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
try {
|
|
16
|
-
const storedToken = localStorage.getItem(DEVICE_TOKEN_KEY);
|
|
17
|
-
if (storedToken) {
|
|
18
|
-
return storedToken;
|
|
19
|
-
}
|
|
20
|
-
const response = yield fetch(`${client.getProjectUrl()}/api/v1/devices`, {
|
|
21
|
-
method: 'POST',
|
|
22
|
-
headers: {
|
|
23
|
-
'accept': 'application/json',
|
|
24
|
-
'x-public-key': client.getPublicKey(),
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
const errorBody = yield response.json();
|
|
29
|
-
throw new Error(errorBody.message || 'Falha ao criar o token do dispositivo.');
|
|
30
|
-
}
|
|
31
|
-
const data = yield response.json();
|
|
32
|
-
if (!data.token) {
|
|
33
|
-
throw new Error('O token do dispositivo não foi retornado pelo servidor.');
|
|
34
|
-
}
|
|
35
|
-
localStorage.setItem(DEVICE_TOKEN_KEY, data.token);
|
|
36
|
-
return data.token;
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
exports.getDeviceToken = getDeviceToken;
|
|
43
|
-
const clearDeviceToken = () => {
|
|
44
|
-
localStorage.removeItem(DEVICE_TOKEN_KEY);
|
|
45
|
-
};
|
|
46
|
-
exports.clearDeviceToken = clearDeviceToken;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.fetchConfigurations = void 0;
|
|
13
|
-
const fetchConfigurations = (client, configurations) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const response = yield client.value.project().configurations();
|
|
15
|
-
configurations.value = {
|
|
16
|
-
project: {
|
|
17
|
-
name: response.project.name,
|
|
18
|
-
domain: response.project.domain,
|
|
19
|
-
},
|
|
20
|
-
design: {
|
|
21
|
-
primaryColor: response.design.primary_color,
|
|
22
|
-
secondaryColor: response.design.secondary_color,
|
|
23
|
-
},
|
|
24
|
-
username: {
|
|
25
|
-
enable: response.username.enable,
|
|
26
|
-
length: {
|
|
27
|
-
min: response.username.length.min,
|
|
28
|
-
max: response.username.length.max,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
password: {
|
|
32
|
-
enable: response.password.enable,
|
|
33
|
-
},
|
|
34
|
-
firstName: {
|
|
35
|
-
required: response.first_name.required,
|
|
36
|
-
},
|
|
37
|
-
lastName: {
|
|
38
|
-
required: response.last_name.required,
|
|
39
|
-
},
|
|
40
|
-
register: {
|
|
41
|
-
enable: response.register.enable,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
exports.fetchConfigurations = fetchConfigurations;
|
package/dist/utils/fetch-user.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.fetchUser = void 0;
|
|
13
|
-
const tokens_1 = require("./tokens");
|
|
14
|
-
const fetchUser = (client, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
let accessToken = yield (0, tokens_1.getAccessToken)();
|
|
16
|
-
if (accessToken == null) {
|
|
17
|
-
user.value = null;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const response = yield client.value.account(accessToken).getProfile();
|
|
21
|
-
user.value = {
|
|
22
|
-
id: response.id,
|
|
23
|
-
username: response.username,
|
|
24
|
-
firstName: response.first_name,
|
|
25
|
-
lastName: response.last_name,
|
|
26
|
-
primaryEmailAddress: response.primary_email_address,
|
|
27
|
-
primaryEmailAddressId: response.primary_email_address_id,
|
|
28
|
-
profileImage: response.profile_image,
|
|
29
|
-
attributes: response.attributes.map((atribute) => ({
|
|
30
|
-
key: atribute.key,
|
|
31
|
-
mode: atribute.mode,
|
|
32
|
-
value: atribute.value,
|
|
33
|
-
})),
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
exports.fetchUser = fetchUser;
|
package/dist/utils/tokens.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getRefreshToken = exports.writeRefreshTokenInCookie = exports.getAccessToken = exports.writeAccessTokenInCookie = void 0;
|
|
16
|
-
const universal_cookie_1 = __importDefault(require("universal-cookie"));
|
|
17
|
-
const writeAccessTokenInCookie = (accessToken) => {
|
|
18
|
-
const cookies = new universal_cookie_1.default();
|
|
19
|
-
if (accessToken === null) {
|
|
20
|
-
cookies.remove('atm_access_token');
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
cookies.set('atm_access_token', accessToken);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.writeAccessTokenInCookie = writeAccessTokenInCookie;
|
|
27
|
-
const getAccessToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
const cookies = new universal_cookie_1.default();
|
|
29
|
-
return cookies.get('atm_access_token');
|
|
30
|
-
});
|
|
31
|
-
exports.getAccessToken = getAccessToken;
|
|
32
|
-
const writeRefreshTokenInCookie = (refreshToken) => {
|
|
33
|
-
const cookies = new universal_cookie_1.default();
|
|
34
|
-
if (refreshToken === null) {
|
|
35
|
-
cookies.remove('atm_refresh_token');
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
cookies.set('atm_refresh_token', refreshToken);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
exports.writeRefreshTokenInCookie = writeRefreshTokenInCookie;
|
|
42
|
-
const getRefreshToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const cookies = new universal_cookie_1.default();
|
|
44
|
-
return cookies.get('atm_refresh_token');
|
|
45
|
-
});
|
|
46
|
-
exports.getRefreshToken = getRefreshToken;
|