Skip to content

Commit 0cf4e1c

Browse files
committed
FIX types
1 parent 1012d5a commit 0cf4e1c

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"@angular/compiler-cli": "17.1.2",
127127
"@angular/language-service": "17.1.2",
128128
"@types/faker": "5.5.9",
129+
"@types/jsonwebtoken": "9.0.5",
129130
"@types/lokijs": "1.5.12",
130131
"@types/node": "20.11.16",
131132
"@types/pouchdb": "6.4.2",

projects/aws/src/app/fake-auth.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import jwt from 'jsonwebtoken';
33
const STORAGE_KEY = 'mock-amplify-auth.state';
44
const USER_ID_PREFIX = 'mock-auth-';
55

6-
let authState;
6+
let authState: any;
77

88
try {
9-
authState = JSON.parse(window.localStorage.getItem(STORAGE_KEY)) || {};
9+
authState = JSON.parse(window.localStorage.getItem(STORAGE_KEY) as any) || {};
1010
} catch (err) {
1111
authState = {};
1212
}
@@ -21,12 +21,12 @@ export const Auth = {
2121
extractEmail
2222
};
2323

24-
function signUp(email) {
24+
function signUp(email: string) {
2525
updateState({ email, loggedIn: false });
2626
return timerPromise(1200);
2727
}
2828

29-
function signIn(email) {
29+
function signIn(email: string) {
3030
updateState({ email, session: createSession({ email }), loggedIn: true });
3131
return timerPromise(700);
3232
}
@@ -48,12 +48,12 @@ function resendSignUp() {
4848
return timerPromise(100);
4949
}
5050

51-
function updateState(newState) {
51+
function updateState(newState: any) {
5252
Object.assign(authState, newState);
5353
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(authState));
5454
}
5555

56-
function timerPromise(ms, success = true, arg = {}) {
56+
function timerPromise(ms: number, success = true, arg = {}) {
5757
if (!success && !arg) {
5858
arg = new Error();
5959
}
@@ -62,16 +62,16 @@ function timerPromise(ms, success = true, arg = {}) {
6262
);
6363
}
6464

65-
function extractEmail(userId) {
65+
function extractEmail(userId: string) {
6666
return Buffer.from(
6767
userId.substring(USER_ID_PREFIX.length),
6868
"base64"
6969
).toString();
7070
}
7171

72-
function createSession({ email }) {
72+
function createSession(args: { email: string }) {
7373
const timeS = Math.floor(Date.now() / 1000);
74-
const cognitoUsername = `${USER_ID_PREFIX}${Buffer.from(email).toString(
74+
const cognitoUsername = `${USER_ID_PREFIX}${Buffer.from(args.email).toString(
7575
"base64"
7676
)}`;
7777
const idTokenPayload = {
@@ -84,7 +84,7 @@ function createSession({ email }) {
8484
exp: timeS + 100000,
8585
iss: "https://cognito-idp.local.amazonaws.com/local_mock-auth",
8686
"cognito:username": cognitoUsername,
87-
email
87+
email: args.email
8888
};
8989
const idToken = {
9090
jwtToken: jwt.sign(idTokenPayload, "mock-auth-secret"),

0 commit comments

Comments
 (0)