Skip to content

Commit

Permalink
chore: pr-comments
Browse files Browse the repository at this point in the history
renamed all per comments to better fit naming schemes
  • Loading branch information
ryanbas21 committed Jan 24, 2025
1 parent 38bb433 commit 1fa8030
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 31 deletions.
28 changes: 12 additions & 16 deletions packages/javascript-sdk/src/device-client/device.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type ConfigOptions } from '../config/interfaces';

import { configureStore } from '@reduxjs/toolkit';
import { deviceService } from './services/index.js';
import type { DeletedOAthDevice, OathDevice, RetrieveOathQuery } from './types/oath.types.js';
import type { DeletedOathDevice, OathDevice, RetrieveOathQuery } from './types/oath.types.js';
import type {
DeleteDeviceQuery,
DeletedPushDevice,
Expand All @@ -14,11 +14,7 @@ import type {
WebAuthnDevice,
WebAuthnQuery,
} from './types/webauthn.types.js';
import type {
BindingDeviceQuery,
Device,
GetBoundDevicesQuery,
} from './types/binding-device.types.js';
import type { BoundDeviceQuery, Device, GetBoundDevicesQuery } from './types/bound-device.types.js';
import type {
GetProfileDevices,
ProfileDevice,
Expand Down Expand Up @@ -78,11 +74,11 @@ export const deviceClient = (config: ConfigOptions) => {
* @async
* @function delete
* @param {DeleteOathQuery & OathDevice} query - The query and device information used to delete the Oath device.
* @returns {Promise<DeletedOAthDevice | { error: unknown }>} - A promise that resolves to the response data or an error object if the response is not valid.
* @returns {Promise<DeletedOathDevice | { error: unknown }>} - A promise that resolves to the response data or an error object if the response is not valid.
*/
delete: async function (
query: RetrieveOathQuery & { device: OathDevice },
): Promise<DeletedOAthDevice | { error: unknown }> {
): Promise<DeletedOathDevice | { error: unknown }> {
try {
const response = await store.dispatch(endpoints.deleteOathDevice.initiate(query));

Expand Down Expand Up @@ -238,7 +234,7 @@ export const deviceClient = (config: ConfigOptions) => {
*
* @async
* @function get
* @param {BindingDeviceQuery} query - The query used to retrieve bound devices.
* @param {BoundDeviceQuery} query - The query used to retrieve bound devices.
* @returns {Promise<Device[] | { error: unknown }>} - A promise that resolves to the retrieved data or an error object if the response is not valid.
*/
get: async function (query: GetBoundDevicesQuery): Promise<Device[] | { error: unknown }> {
Expand All @@ -260,12 +256,12 @@ export const deviceClient = (config: ConfigOptions) => {
*
* @async
* @function delete
* @param {BindingDeviceQuery} query - The query used to delete the bound device.
* @param {BoundDeviceQuery} query - The query used to delete the bound device.
* @returns {Promise<Device | { error: unknown }>} - A promise that resolves to the response data or an error object if the response is not valid.
*/
delete: async function (query: BindingDeviceQuery): Promise<Device | { error: unknown }> {
delete: async function (query: BoundDeviceQuery): Promise<Device | { error: unknown }> {
try {
const response = await store.dispatch(endpoints.deleteBindingDevice.initiate(query));
const response = await store.dispatch(endpoints.deleteBoundDevice.initiate(query));

if (!response || !response.data || !response.data.result) {
throw new Error('response did not contain data');
Expand All @@ -282,12 +278,12 @@ export const deviceClient = (config: ConfigOptions) => {
*
* @async
* @function update
* @param {BindingDeviceQuery} query - The query used to update the bound device name.
* @param {BoundDeviceQuery} query - The query used to update the bound device name.
* @returns {Promise<Device | { error: unknown }>} - A promise that resolves to the response data or an error object if the response is not valid.
*/
update: async function (query: BindingDeviceQuery): Promise<Device | { error: unknown }> {
update: async function (query: BoundDeviceQuery): Promise<Device | { error: unknown }> {
try {
const response = await store.dispatch(endpoints.updateBindingDeviceName.initiate(query));
const response = await store.dispatch(endpoints.updateBoundDevice.initiate(query));

if (!response || !response.data) {
throw new Error('response did not contain data');
Expand All @@ -312,7 +308,7 @@ export const deviceClient = (config: ConfigOptions) => {
query: GetProfileDevices,
): Promise<ProfileDevice[] | { error: unknown }> {
try {
const response = await store.dispatch(endpoints.getDeviceProfile.initiate(query));
const response = await store.dispatch(endpoints.getDeviceProfiles.initiate(query));

if (!response || !response.data || !response.data.result) {
throw new Error('response did not contain data');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GeneralResponse } from '../services/index.js';
import type {
OAthResponse,
OathResponse,
DeletedOAthDevice,
DeviceResponse,
PushDevice,
Expand All @@ -9,7 +9,7 @@ import type {
import { ProfileDevice } from '../types/profile-device.types.js';

// Mock data
export const MOCK_OATH_DEVICES: OAthResponse = {
export const MOCK_OATH_DEVICES: OathResponse = {
pagedResultsCookie: 'cookie',
remainingPagedResults: -1,
resultCount: 2,
Expand Down
16 changes: 8 additions & 8 deletions packages/javascript-sdk/src/device-client/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
import {
DeletedOAthDevice,
DeletedOathDevice,
OathDevice,
OAthResponse,
OathResponse,
RetrieveOathQuery,
} from '../types/oath.types.js';
import {
Expand All @@ -11,7 +11,7 @@ import {
PushDevice,
PushDeviceQuery,
} from '../types/push-device.types.js';
import { BindingDeviceQuery, Device, GetBoundDevicesQuery } from '../types/binding-device.types.js';
import { BoundDeviceQuery, Device, GetBoundDevicesQuery } from '../types/bound-device.types.js';

import { UpdatedWebAuthnDevice, WebAuthnDevice, WebAuthnQuery } from '../types/webauthn.types.js';
import {
Expand Down Expand Up @@ -46,13 +46,13 @@ export const deviceService = ({ baseUrl, realmPath }: { baseUrl: string; realmPa
}),
endpoints: (builder) => ({
// oath endpoints
getOAthDevices: builder.query<OAthResponse, RetrieveOathQuery>({
getOAthDevices: builder.query<OathResponse, RetrieveOathQuery>({
query: ({ realm = realmPath, userId }) =>
`json/realms/${realm}/users/${userId}/devices/2fa/oath?_queryFilter=true`,
}),

deleteOathDevice: builder.mutation<
DeletedOAthDevice,
DeletedOathDevice,
RetrieveOathQuery & { device: OathDevice }
>({
query: ({ realm = realmPath, userId, device }) => ({
Expand Down Expand Up @@ -105,21 +105,21 @@ export const deviceService = ({ baseUrl, realmPath }: { baseUrl: string; realmPa
query: ({ realm = realmPath, userId }) =>
`/json/realms/${realm}/users/${userId}/devices/2fa/binding?_queryFilter=true`,
}),
updateBindingDeviceName: builder.mutation<Device, BindingDeviceQuery>({
updateBoundDevice: builder.mutation<Device, BoundDeviceQuery>({
query: ({ realm = realmPath, userId, device }) => ({
url: `/json/realms/root/realms/${realm}/users/${userId}/devices/2fa/binding/${device.uuid}`,
method: 'PUT',
body: device,
}),
}),
deleteBindingDevice: builder.mutation<GeneralResponse<Device>, BindingDeviceQuery>({
deleteBoundDevice: builder.mutation<GeneralResponse<Device>, BoundDeviceQuery>({
query: ({ realm = realmPath, userId, device }) => ({
url: `/json/realms/root/realms/${realm}/users/${userId}/devices/2fa/binding/${device.uuid}`,
method: 'DELETE',
body: device satisfies Device,
}),
}),
getDeviceProfile: builder.query<GeneralResponse<ProfileDevice[]>, GetProfileDevices>({
getDeviceProfiles: builder.query<GeneralResponse<ProfileDevice[]>, GetProfileDevices>({
query: ({ realm = realmPath, userId }) =>
`json/realms/${realm}/users/${userId}/devices/profile?_queryFilter=true`,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type GetBoundDevicesQuery = {
userId: string;
realm?: string;
};
export type BindingDeviceQuery = GetBoundDevicesQuery & { device: Device };
export type BoundDeviceQuery = GetBoundDevicesQuery & { device: Device };

export type DeviceResponse = {
result: Device[];
Expand Down
2 changes: 1 addition & 1 deletion packages/javascript-sdk/src/device-client/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './oath.types.js';
export * from './webauthn.types.js';
export * from './push-device.types.js';
export * from './binding-device.types.js';
export * from './bound-device.types.js';
export * from './updateDeviceProfile.types.js';
4 changes: 2 additions & 2 deletions packages/javascript-sdk/src/device-client/types/oath.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type RetrieveOathQuery = {
userId: string;
};

export type OAthResponse = {
export type OathResponse = {
pagedResultsCookie: string | null;
remainingPagedResults: number;
resultCount: number;
Expand All @@ -28,7 +28,7 @@ export type OAthResponse = {
result: OathDevice[];
};

export type DeletedOAthDevice = {
export type DeletedOathDevice = {
_id: string;
_rev: string;
uuid: string;
Expand Down
1 change: 0 additions & 1 deletion packages/javascript-sdk/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default defineConfig({
name: 'javascript-sdk',
formats: ['es', 'cjs'],
fileName: (format, fileName) => {
console.log(fileName);
const extension = format === 'es' ? 'js' : 'cjs';
return `${fileName}.${extension}`;
},
Expand Down

0 comments on commit 1fa8030

Please sign in to comment.