Skip to content

Commit 8e4977d

Browse files
Code-Hexgithub-actions[bot]
authored andcommitted
Apply auto lint-fix changes
1 parent 49587db commit 8e4977d

21 files changed

+485
-485
lines changed

example/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { EmulatorEnv } from '../src'
2-
import { Auth, emulatorHost, WorkersKVStoreSingle } from '../src'
1+
import type { EmulatorEnv } from '../src';
2+
import { Auth, emulatorHost, WorkersKVStoreSingle } from '../src';
33

44
interface Bindings extends EmulatorEnv {
55
EMAIL_ADDRESS: string;
@@ -10,13 +10,13 @@ interface Bindings extends EmulatorEnv {
1010
PUBLIC_JWK_CACHE_KEY: string;
1111
}
1212

13-
const signInPath = '/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=test1234'
13+
const signInPath = '/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=test1234';
1414

1515
export async function handleRequest(req: Request, env: Bindings) {
16-
const url = new URL(req.url)
17-
const firebaseEmuHost = emulatorHost(env)
16+
const url = new URL(req.url);
17+
const firebaseEmuHost = emulatorHost(env);
1818
if (url.pathname === '/get-jwt' && !!firebaseEmuHost) {
19-
const firebaseEmulatorSignInUrl = 'http://' + firebaseEmuHost + signInPath
19+
const firebaseEmulatorSignInUrl = 'http://' + firebaseEmuHost + signInPath;
2020
const resp = await fetch(firebaseEmulatorSignInUrl, {
2121
method: 'POST',
2222
body: JSON.stringify({
@@ -27,28 +27,28 @@ export async function handleRequest(req: Request, env: Bindings) {
2727
headers: {
2828
'Content-Type': 'application/json',
2929
},
30-
})
31-
return resp
30+
});
31+
return resp;
3232
}
3333

34-
const authorization = req.headers.get('Authorization')
34+
const authorization = req.headers.get('Authorization');
3535
if (authorization === null) {
3636
return new Response(null, {
3737
status: 400,
38-
})
38+
});
3939
}
40-
const jwt = authorization.replace(/Bearer\s+/i, '')
40+
const jwt = authorization.replace(/Bearer\s+/i, '');
4141
const auth = Auth.getOrInitialize(
4242
env.PROJECT_ID,
4343
WorkersKVStoreSingle.getOrInitialize(env.PUBLIC_JWK_CACHE_KEY, env.PUBLIC_JWK_CACHE_KV)
44-
)
45-
const firebaseToken = await auth.verifyIdToken(jwt, env)
44+
);
45+
const firebaseToken = await auth.verifyIdToken(jwt, env);
4646

4747
return new Response(JSON.stringify(firebaseToken), {
4848
headers: {
4949
'Content-Type': 'application/json',
5050
},
51-
})
51+
});
5252
}
5353

54-
export default { fetch: handleRequest }
54+
export default { fetch: handleRequest };

src/auth.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { EmulatorEnv } from './emulator'
2-
import { useEmulator } from './emulator'
3-
import type { KeyStorer } from './key-store'
4-
import type { FirebaseIdToken, FirebaseTokenVerifier } from './token-verifier'
5-
import { createIdTokenVerifier } from './token-verifier'
1+
import type { EmulatorEnv } from './emulator';
2+
import { useEmulator } from './emulator';
3+
import type { KeyStorer } from './key-store';
4+
import type { FirebaseIdToken, FirebaseTokenVerifier } from './token-verifier';
5+
import { createIdTokenVerifier } from './token-verifier';
66

77
export class BaseAuth {
88
/** @internal */
9-
protected readonly idTokenVerifier: FirebaseTokenVerifier
9+
protected readonly idTokenVerifier: FirebaseTokenVerifier;
1010

1111
constructor(projectId: string, keyStore: KeyStorer) {
12-
this.idTokenVerifier = createIdTokenVerifier(projectId, keyStore)
12+
this.idTokenVerifier = createIdTokenVerifier(projectId, keyStore);
1313
}
1414

1515
/**
@@ -25,7 +25,7 @@ export class BaseAuth {
2525
* promise.
2626
*/
2727
public verifyIdToken(idToken: string, env?: EmulatorEnv): Promise<FirebaseIdToken> {
28-
const isEmulator = useEmulator(env)
29-
return this.idTokenVerifier.verifyJWT(idToken, isEmulator)
28+
const isEmulator = useEmulator(env);
29+
return this.idTokenVerifier.verifyJWT(idToken, isEmulator);
3030
}
3131
}

src/base64.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
export const decodeBase64Url = (str: string): Uint8Array => {
2-
return decodeBase64(str.replace(/_|-/g, m => ({ _: '/', '-': '+' })[m] ?? m))
3-
}
2+
return decodeBase64(str.replace(/_|-/g, m => ({ _: '/', '-': '+' })[m] ?? m));
3+
};
44

55
export const encodeBase64Url = (buf: ArrayBufferLike): string =>
6-
encodeBase64(buf).replace(/\/|\+/g, m => ({ '/': '_', '+': '-' })[m] ?? m)
6+
encodeBase64(buf).replace(/\/|\+/g, m => ({ '/': '_', '+': '-' })[m] ?? m);
77

88
// This approach is written in MDN.
99
// btoa does not support utf-8 characters. So we need a little bit hack.
1010
export const encodeBase64 = (buf: ArrayBufferLike): string => {
11-
const binary = String.fromCharCode(...new Uint8Array(buf))
12-
return btoa(binary)
13-
}
11+
const binary = String.fromCharCode(...new Uint8Array(buf));
12+
return btoa(binary);
13+
};
1414

1515
// atob does not support utf-8 characters. So we need a little bit hack.
1616
const decodeBase64 = (str: string): Uint8Array => {
17-
const binary = atob(str)
18-
const bytes = new Uint8Array(new ArrayBuffer(binary.length))
19-
const half = binary.length / 2
17+
const binary = atob(str);
18+
const bytes = new Uint8Array(new ArrayBuffer(binary.length));
19+
const half = binary.length / 2;
2020
for (let i = 0, j = binary.length - 1; i <= half; i++, j--) {
21-
bytes[i] = binary.charCodeAt(i)
22-
bytes[j] = binary.charCodeAt(j)
21+
bytes[i] = binary.charCodeAt(i);
22+
bytes[j] = binary.charCodeAt(j);
2323
}
24-
return bytes
25-
}
24+
return bytes;
25+
};

src/emulator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ export interface EmulatorEnv {
33
}
44

55
export function emulatorHost(env?: EmulatorEnv): string | undefined {
6-
return env?.FIREBASE_AUTH_EMULATOR_HOST
6+
return env?.FIREBASE_AUTH_EMULATOR_HOST;
77
}
88

99
/**
1010
* When true the SDK should communicate with the Auth Emulator for all API
1111
* calls and also produce unsigned tokens.
1212
*/
1313
export const useEmulator = (env?: EmulatorEnv): boolean => {
14-
return !!emulatorHost(env)
15-
}
14+
return !!emulatorHost(env);
15+
};

src/errors.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class JwtError extends Error {
1111
readonly message: string
1212
) {
1313
super(message);
14-
(this as any).__proto__ = JwtError.prototype
14+
(this as any).__proto__ = JwtError.prototype;
1515
}
1616
}
1717

@@ -32,7 +32,7 @@ export enum JwtErrorCode {
3232
* App client error codes and their default messages.
3333
*/
3434
export class AppErrorCodes {
35-
public static INVALID_CREDENTIAL = 'invalid-credential'
35+
public static INVALID_CREDENTIAL = 'invalid-credential';
3636
}
3737

3838
/**
@@ -42,31 +42,31 @@ export class AuthClientErrorCode {
4242
public static INVALID_ARGUMENT = {
4343
code: 'argument-error',
4444
message: 'Invalid argument provided.',
45-
}
45+
};
4646
public static INVALID_CREDENTIAL = {
4747
code: 'invalid-credential',
4848
message: 'Invalid credential object provided.',
49-
}
49+
};
5050
public static ID_TOKEN_EXPIRED = {
5151
code: 'id-token-expired',
5252
message: 'The provided Firebase ID token is expired.',
53-
}
53+
};
5454
public static ID_TOKEN_REVOKED = {
5555
code: 'id-token-revoked',
5656
message: 'The Firebase ID token has been revoked.',
57-
}
57+
};
5858
public static INTERNAL_ERROR = {
5959
code: 'internal-error',
6060
message: 'An internal error has occurred.',
61-
}
61+
};
6262
public static USER_NOT_FOUND = {
6363
code: 'user-not-found',
6464
message: 'There is no user record corresponding to the provided identifier.',
65-
}
65+
};
6666
public static USER_DISABLED = {
6767
code: 'user-disabled',
6868
message: 'The user record is disabled.',
69-
}
69+
};
7070
}
7171

7272
/**
@@ -124,25 +124,25 @@ export class FirebaseError extends Error implements FirebaseErrorInterface {
124124
// Set the prototype explicitly. See the following link for more details:
125125
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
126126
/* tslint:enable:max-line-length */
127-
(this as any).__proto__ = FirebaseError.prototype
127+
(this as any).__proto__ = FirebaseError.prototype;
128128
}
129129

130130
/** @returns The error code. */
131131
public get code(): string {
132-
return this.errorInfo.code
132+
return this.errorInfo.code;
133133
}
134134

135135
/** @returns The error message. */
136136
public get message(): string {
137-
return this.errorInfo.message
137+
return this.errorInfo.message;
138138
}
139139

140140
/** @returns The object representation of the error. */
141141
public toJSON(): object {
142142
return {
143143
code: this.code,
144144
message: this.message,
145-
}
145+
};
146146
}
147147
}
148148

@@ -177,7 +177,7 @@ export class PrefixedFirebaseError extends FirebaseError {
177177
// Set the prototype explicitly. See the following link for more details:
178178
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
179179
/* tslint:enable:max-line-length */
180-
(this as any).__proto__ = PrefixedFirebaseError.prototype
180+
(this as any).__proto__ = PrefixedFirebaseError.prototype;
181181
}
182182

183183
/**
@@ -188,7 +188,7 @@ export class PrefixedFirebaseError extends FirebaseError {
188188
* @returns True if the code matches, false otherwise.
189189
*/
190190
public hasCode(code: string): boolean {
191-
return `${this.codePrefix}/${code}` === this.code
191+
return `${this.codePrefix}/${code}` === this.code;
192192
}
193193
}
194194

@@ -209,6 +209,6 @@ export class FirebaseAuthError extends PrefixedFirebaseError {
209209
// Set the prototype explicitly. See the following link for more details:
210210
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
211211
/* tslint:enable:max-line-length */
212-
(this as any).__proto__ = FirebaseAuthError.prototype
212+
(this as any).__proto__ = FirebaseAuthError.prototype;
213213
}
214214
}

src/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import { BaseAuth } from './auth'
2-
import type { KeyStorer } from './key-store'
3-
import { WorkersKVStore } from './key-store'
1+
import { BaseAuth } from './auth';
2+
import type { KeyStorer } from './key-store';
3+
import { WorkersKVStore } from './key-store';
44

5-
export { emulatorHost, useEmulator } from './emulator'
6-
export type { KeyStorer }
7-
export type { EmulatorEnv } from './emulator'
8-
export type { FirebaseIdToken } from './token-verifier'
5+
export { emulatorHost, useEmulator } from './emulator';
6+
export type { KeyStorer };
7+
export type { EmulatorEnv } from './emulator';
8+
export type { FirebaseIdToken } from './token-verifier';
99

1010
export class Auth extends BaseAuth {
11-
private static instance?: Auth
11+
private static instance?: Auth;
1212

1313
private constructor(projectId: string, keyStore: KeyStorer) {
14-
super(projectId, keyStore)
14+
super(projectId, keyStore);
1515
}
1616

1717
static getOrInitialize(projectId: string, keyStore: KeyStorer): Auth {
1818
if (!Auth.instance) {
19-
Auth.instance = new Auth(projectId, keyStore)
19+
Auth.instance = new Auth(projectId, keyStore);
2020
}
21-
return Auth.instance
21+
return Auth.instance;
2222
}
2323
}
2424

2525
export class WorkersKVStoreSingle extends WorkersKVStore {
26-
private static instance?: WorkersKVStoreSingle
26+
private static instance?: WorkersKVStoreSingle;
2727

2828
private constructor(cacheKey: string, cfKVNamespace: KVNamespace) {
29-
super(cacheKey, cfKVNamespace)
29+
super(cacheKey, cfKVNamespace);
3030
}
3131

3232
static getOrInitialize(cacheKey: string, cfKVNamespace: KVNamespace): WorkersKVStoreSingle {
3333
if (!WorkersKVStoreSingle.instance) {
34-
WorkersKVStoreSingle.instance = new WorkersKVStoreSingle(cacheKey, cfKVNamespace)
34+
WorkersKVStoreSingle.instance = new WorkersKVStoreSingle(cacheKey, cfKVNamespace);
3535
}
36-
return WorkersKVStoreSingle.instance
36+
return WorkersKVStoreSingle.instance;
3737
}
3838
}

0 commit comments

Comments
 (0)