Skip to content

Commit

Permalink
feat(math): rename deviceId to clientId
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Feb 6, 2023
1 parent 097f60f commit b211fd4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions core/math/src/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ export const hex = (bytes: Uint8Array): string => {
return str;
};

export const getDeviceUuid = (): string => {
let uuid = localStorage.getItem('device-uuid');
export const getClientId = (): string => {
let uuid = localStorage.getItem('client-id');
if (uuid == null) {
uuid = random.uuid;
localStorage.setItem('device-uuid', uuid);
localStorage.setItem('client-id', uuid);
}
return uuid;
};
6 changes: 3 additions & 3 deletions demo/math/translate-unicode-digits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UnicodeDigits, getDeviceUuid} from '@alwatr/math';
import {UnicodeDigits, getClientId} from '@alwatr/math';

const unicodeDigits = new UnicodeDigits('fa', 'all');

Expand Down Expand Up @@ -28,5 +28,5 @@ for (let i = count; i > 0; i--) {

console.log((count / (Date.now() - start)) * 1000);

console.log('device-uuid', getDeviceUuid());
console.log('device-uuid', getDeviceUuid());
console.log('client-id', getClientId());
console.log('client-id', getClientId());
6 changes: 3 additions & 3 deletions services/form-registration/src/route/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ async function setForm(connection: AlwatrConnection): Promise<AlwatrServiceRespo
connection.requireToken(config.nanoServer.accessToken);
const params = connection.requireQueryParams<{form: string}>({form: 'string'});
const remoteAddress = connection.incomingMessage.socket.remoteAddress ?? 'unknown';
const deviceId = connection.incomingMessage.headers['device-id'];
const clientId = connection.incomingMessage.headers['client-id'] ?? 'unknown';

if (!(typeof deviceId === 'string' && deviceId !== '')) {
if (!(typeof clientId === 'string' && clientId !== '')) {
return {
ok: false,
statusCode: 401,
Expand All @@ -33,7 +33,7 @@ async function setForm(connection: AlwatrConnection): Promise<AlwatrServiceRespo
const bodyJson = await connection.requireJsonBody<Form>();
bodyJson.id = 'auto_increment';
bodyJson.remoteAddress = remoteAddress;
bodyJson.deviceId = deviceId;
bodyJson.clientId = clientId;

await storageClient.set(bodyJson, 'form-' + params.form);

Expand Down
2 changes: 1 addition & 1 deletion services/form-registration/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AlwatrDocumentObject} from '@alwatr/type';

export type Form = AlwatrDocumentObject & {
deviceId: string;
clientId: string;
remoteAddress: string;
}

0 comments on commit b211fd4

Please sign in to comment.