@tern-secure/backend 1.2.0-canary.v20251125170702 → 1.2.0-canary.v20251127235234
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/admin/index.js +3 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -2
- package/dist/admin/index.mjs.map +1 -1
- package/dist/auth/constants.d.ts +6 -0
- package/dist/auth/constants.d.ts.map +1 -0
- package/dist/auth/credential.d.ts +27 -0
- package/dist/auth/credential.d.ts.map +1 -0
- package/dist/auth/getauth.d.ts +1 -0
- package/dist/auth/getauth.d.ts.map +1 -1
- package/dist/auth/index.js +234 -28
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +3 -3
- package/dist/auth/utils.d.ts +3 -0
- package/dist/auth/utils.d.ts.map +1 -0
- package/dist/{chunk-MS6L7M3C.mjs → chunk-DJLDUW7J.mjs} +174 -12
- package/dist/chunk-DJLDUW7J.mjs.map +1 -0
- package/dist/{chunk-ASGV4MFO.mjs → chunk-GFH5CXQR.mjs} +2 -2
- package/dist/{chunk-DDUNOEIM.mjs → chunk-NXYWC6YO.mjs} +278 -116
- package/dist/chunk-NXYWC6YO.mjs.map +1 -0
- package/dist/{chunk-DFAJCSBJ.mjs → chunk-WIVOBOZR.mjs} +2 -1
- package/dist/chunk-WIVOBOZR.mjs.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/fireRestApi/createFireApi.d.ts +2 -1
- package/dist/fireRestApi/createFireApi.d.ts.map +1 -1
- package/dist/fireRestApi/endpoints/AppCheckApi.d.ts +23 -0
- package/dist/fireRestApi/endpoints/AppCheckApi.d.ts.map +1 -0
- package/dist/fireRestApi/endpoints/TokenApi.d.ts +3 -1
- package/dist/fireRestApi/endpoints/TokenApi.d.ts.map +1 -1
- package/dist/fireRestApi/endpoints/UserData.d.ts.map +1 -1
- package/dist/fireRestApi/endpoints/index.d.ts +1 -0
- package/dist/fireRestApi/endpoints/index.d.ts.map +1 -1
- package/dist/fireRestApi/request.d.ts.map +1 -1
- package/dist/index.js +390 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -14
- package/dist/index.mjs.map +1 -1
- package/dist/jwt/index.d.ts +1 -0
- package/dist/jwt/index.d.ts.map +1 -1
- package/dist/jwt/index.js +51 -19
- package/dist/jwt/index.js.map +1 -1
- package/dist/jwt/index.mjs +8 -132
- package/dist/jwt/index.mjs.map +1 -1
- package/dist/jwt/signJwt.d.ts +8 -0
- package/dist/jwt/signJwt.d.ts.map +1 -1
- package/dist/jwt/verifyJwt.d.ts.map +1 -1
- package/dist/tokens/authstate.d.ts.map +1 -1
- package/dist/tokens/c-authenticateRequestProcessor.d.ts +1 -0
- package/dist/tokens/c-authenticateRequestProcessor.d.ts.map +1 -1
- package/dist/tokens/request.d.ts.map +1 -1
- package/dist/tokens/types.d.ts +2 -1
- package/dist/tokens/types.d.ts.map +1 -1
- package/dist/tokens/verify.d.ts +2 -2
- package/dist/tokens/verify.d.ts.map +1 -1
- package/dist/utils/admin-init.d.ts +1 -0
- package/dist/utils/admin-init.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-DDUNOEIM.mjs.map +0 -1
- package/dist/chunk-DFAJCSBJ.mjs.map +0 -1
- package/dist/chunk-MS6L7M3C.mjs.map +0 -1
- /package/dist/{chunk-ASGV4MFO.mjs.map → chunk-GFH5CXQR.mjs.map} +0 -0
|
@@ -1,99 +1,12 @@
|
|
|
1
|
-
// src/jwt/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.name = "CustomTokenError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var RESERVED_CLAIMS = [
|
|
11
|
-
"acr",
|
|
12
|
-
"amr",
|
|
13
|
-
"at_hash",
|
|
14
|
-
"aud",
|
|
15
|
-
"auth_time",
|
|
16
|
-
"azp",
|
|
17
|
-
"cnf",
|
|
18
|
-
"c_hash",
|
|
19
|
-
"exp",
|
|
20
|
-
"firebase",
|
|
21
|
-
"iat",
|
|
22
|
-
"iss",
|
|
23
|
-
"jti",
|
|
24
|
-
"nbf",
|
|
25
|
-
"nonce",
|
|
26
|
-
"sub"
|
|
27
|
-
];
|
|
28
|
-
async function createCustomTokenJwt(uid, developerClaims) {
|
|
29
|
-
try {
|
|
30
|
-
const privateKey = process.env.FIREBASE_PRIVATE_KEY;
|
|
31
|
-
const clientEmail = process.env.FIREBASE_CLIENT_EMAIL;
|
|
32
|
-
if (!privateKey || !clientEmail) {
|
|
33
|
-
return {
|
|
34
|
-
errors: [
|
|
35
|
-
new CustomTokenError(
|
|
36
|
-
"Missing FIREBASE_PRIVATE_KEY or FIREBASE_CLIENT_EMAIL environment variables",
|
|
37
|
-
"MISSING_ENV_VARS"
|
|
38
|
-
)
|
|
39
|
-
]
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (!uid || typeof uid !== "string") {
|
|
43
|
-
return {
|
|
44
|
-
errors: [new CustomTokenError("uid must be a non-empty string", "INVALID_UID")]
|
|
45
|
-
};
|
|
1
|
+
// src/jwt/guardReturn.ts
|
|
2
|
+
function createJwtGuard(decodedFn) {
|
|
3
|
+
return (...args) => {
|
|
4
|
+
const { data, errors } = decodedFn(...args);
|
|
5
|
+
if (errors) {
|
|
6
|
+
throw errors[0];
|
|
46
7
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
errors: [new CustomTokenError("uid must not exceed 128 characters", "UID_TOO_LONG")]
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (developerClaims) {
|
|
53
|
-
for (const claim of Object.keys(developerClaims)) {
|
|
54
|
-
if (RESERVED_CLAIMS.includes(claim)) {
|
|
55
|
-
return {
|
|
56
|
-
errors: [new CustomTokenError(`Custom claim '${claim}' is reserved`, "RESERVED_CLAIM")]
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const expiresIn = 3600;
|
|
62
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
63
|
-
const parsedPrivateKey = await importPKCS8(privateKey.replace(/\\n/g, "\n"), "RS256");
|
|
64
|
-
const payload = {
|
|
65
|
-
iss: clientEmail,
|
|
66
|
-
sub: clientEmail,
|
|
67
|
-
aud: "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
|
|
68
|
-
iat: now,
|
|
69
|
-
exp: now + expiresIn,
|
|
70
|
-
uid,
|
|
71
|
-
...developerClaims
|
|
72
|
-
};
|
|
73
|
-
const jwt = await new SignJWT(payload).setProtectedHeader({ alg: "RS256", typ: "JWT" }).setIssuedAt(now).setExpirationTime(now + expiresIn).setIssuer(clientEmail).setSubject(clientEmail).setAudience(
|
|
74
|
-
"https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit"
|
|
75
|
-
).sign(parsedPrivateKey);
|
|
76
|
-
return {
|
|
77
|
-
data: jwt
|
|
78
|
-
};
|
|
79
|
-
} catch (error) {
|
|
80
|
-
const message = error instanceof Error ? error.message : "Unknown error occurred";
|
|
81
|
-
return {
|
|
82
|
-
errors: [
|
|
83
|
-
new CustomTokenError(`Failed to create custom token: ${message}`, "TOKEN_CREATION_FAILED")
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async function createCustomToken(uid, developerClaims) {
|
|
89
|
-
const { data, errors } = await createCustomTokenJwt(uid, developerClaims);
|
|
90
|
-
if (errors) {
|
|
91
|
-
throw errors[0];
|
|
92
|
-
}
|
|
93
|
-
return data;
|
|
94
|
-
}
|
|
95
|
-
function createCustomTokenWithResult(uid, developerClaims) {
|
|
96
|
-
return createCustomTokenJwt(uid, developerClaims);
|
|
8
|
+
return data;
|
|
9
|
+
};
|
|
97
10
|
}
|
|
98
11
|
|
|
99
12
|
// src/jwt/verifyJwt.ts
|
|
@@ -348,33 +261,44 @@ async function verifySignature(jwt, key) {
|
|
|
348
261
|
}
|
|
349
262
|
}
|
|
350
263
|
function ternDecodeJwt(token) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
264
|
+
try {
|
|
265
|
+
const header = decodeProtectedHeader(token);
|
|
266
|
+
const payload = decodeJwt(token);
|
|
267
|
+
const tokenParts = (token || "").toString().split(".");
|
|
268
|
+
if (tokenParts.length !== 3) {
|
|
269
|
+
return {
|
|
270
|
+
errors: [
|
|
271
|
+
new TokenVerificationError({
|
|
272
|
+
reason: TokenVerificationErrorReason.TokenInvalid,
|
|
273
|
+
message: "Invalid JWT format"
|
|
274
|
+
})
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const [rawHeader, rawPayload, rawSignature] = tokenParts;
|
|
279
|
+
const signature = base64url.parse(rawSignature, { loose: true });
|
|
280
|
+
const data = {
|
|
281
|
+
header,
|
|
282
|
+
payload,
|
|
283
|
+
signature,
|
|
284
|
+
raw: {
|
|
285
|
+
header: rawHeader,
|
|
286
|
+
payload: rawPayload,
|
|
287
|
+
signature: rawSignature,
|
|
288
|
+
text: token
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
return { data };
|
|
292
|
+
} catch (error) {
|
|
355
293
|
return {
|
|
356
294
|
errors: [
|
|
357
295
|
new TokenVerificationError({
|
|
358
296
|
reason: TokenVerificationErrorReason.TokenInvalid,
|
|
359
|
-
message: "Invalid
|
|
297
|
+
message: `${error.message || "Invalid Token or Protected Header formatting"} (Token length: ${token?.length}, First 10 chars: ${token?.substring(0, 10)}...)`
|
|
360
298
|
})
|
|
361
299
|
]
|
|
362
300
|
};
|
|
363
301
|
}
|
|
364
|
-
const [rawHeader, rawPayload, rawSignature] = tokenParts;
|
|
365
|
-
const signature = base64url.parse(rawSignature, { loose: true });
|
|
366
|
-
const data = {
|
|
367
|
-
header,
|
|
368
|
-
payload,
|
|
369
|
-
signature,
|
|
370
|
-
raw: {
|
|
371
|
-
header: rawHeader,
|
|
372
|
-
payload: rawPayload,
|
|
373
|
-
signature: rawSignature,
|
|
374
|
-
text: token
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
return { data };
|
|
378
302
|
}
|
|
379
303
|
async function verifyJwt(token, options) {
|
|
380
304
|
const { key } = options;
|
|
@@ -407,6 +331,240 @@ async function verifyJwt(token, options) {
|
|
|
407
331
|
return { data: decodedIdToken };
|
|
408
332
|
}
|
|
409
333
|
|
|
334
|
+
// src/jwt/jwt.ts
|
|
335
|
+
import { createRemoteJWKSet, decodeJwt as decodeJwt2, jwtVerify as jwtVerify2 } from "jose";
|
|
336
|
+
var FIREBASE_ID_TOKEN_URL = "https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com";
|
|
337
|
+
var FIREBASE_SESSION_CERT_URL = "https://identitytoolkit.googleapis.com/v1/sessionCookiePublicKeys";
|
|
338
|
+
var idTokenJWKS = null;
|
|
339
|
+
var sessionJWKS = null;
|
|
340
|
+
var getIdTokenJWKS = () => {
|
|
341
|
+
if (!idTokenJWKS) {
|
|
342
|
+
idTokenJWKS = createRemoteJWKSet(new URL(FIREBASE_ID_TOKEN_URL), {
|
|
343
|
+
cacheMaxAge: 36e5,
|
|
344
|
+
// 1 hour
|
|
345
|
+
timeoutDuration: 5e3,
|
|
346
|
+
// 5 seconds
|
|
347
|
+
cooldownDuration: 3e4
|
|
348
|
+
// 30 seconds between retries
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return idTokenJWKS;
|
|
352
|
+
};
|
|
353
|
+
var getSessionJWKS = () => {
|
|
354
|
+
if (!sessionJWKS) {
|
|
355
|
+
sessionJWKS = createRemoteJWKSet(new URL(FIREBASE_SESSION_CERT_URL), {
|
|
356
|
+
cacheMaxAge: 36e5,
|
|
357
|
+
// 1 hour
|
|
358
|
+
timeoutDuration: 5e3,
|
|
359
|
+
// 5 seconds
|
|
360
|
+
cooldownDuration: 3e4
|
|
361
|
+
// 30 seconds between retries
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return sessionJWKS;
|
|
365
|
+
};
|
|
366
|
+
async function verifyToken(token, isSessionCookie = false) {
|
|
367
|
+
try {
|
|
368
|
+
const projectId = process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID;
|
|
369
|
+
if (!projectId) {
|
|
370
|
+
throw new Error("Firebase Project ID is not configured");
|
|
371
|
+
}
|
|
372
|
+
const { decoded } = decodeJwt2(token);
|
|
373
|
+
if (!decoded) {
|
|
374
|
+
throw new Error("Invalid token format");
|
|
375
|
+
}
|
|
376
|
+
let retries = 3;
|
|
377
|
+
let lastError = null;
|
|
378
|
+
while (retries > 0) {
|
|
379
|
+
try {
|
|
380
|
+
const JWKS = isSessionCookie ? getSessionJWKS() : getIdTokenJWKS();
|
|
381
|
+
const { payload } = await jwtVerify2(token, JWKS, {
|
|
382
|
+
issuer: isSessionCookie ? "https://session.firebase.google.com/" + projectId : "https://securetoken.google.com/" + projectId,
|
|
383
|
+
audience: projectId,
|
|
384
|
+
algorithms: ["RS256"]
|
|
385
|
+
});
|
|
386
|
+
const firebasePayload = payload;
|
|
387
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
388
|
+
if (firebasePayload.exp <= now) {
|
|
389
|
+
throw new Error("Token has expired");
|
|
390
|
+
}
|
|
391
|
+
if (firebasePayload.iat > now) {
|
|
392
|
+
throw new Error("Token issued time is in the future");
|
|
393
|
+
}
|
|
394
|
+
if (!firebasePayload.sub) {
|
|
395
|
+
throw new Error("Token subject is empty");
|
|
396
|
+
}
|
|
397
|
+
if (firebasePayload.auth_time > now) {
|
|
398
|
+
throw new Error("Token auth time is in the future");
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
valid: true,
|
|
402
|
+
uid: firebasePayload.sub,
|
|
403
|
+
sub: firebasePayload.sub,
|
|
404
|
+
email: firebasePayload.email,
|
|
405
|
+
email_verified: firebasePayload.email_verified,
|
|
406
|
+
auth_time: firebasePayload.auth_time,
|
|
407
|
+
iat: firebasePayload.iat,
|
|
408
|
+
exp: firebasePayload.exp,
|
|
409
|
+
aud: firebasePayload.aud,
|
|
410
|
+
iss: firebasePayload.iss,
|
|
411
|
+
firebase: firebasePayload.firebase,
|
|
412
|
+
phone_number: firebasePayload.phone_number,
|
|
413
|
+
picture: firebasePayload.picture
|
|
414
|
+
};
|
|
415
|
+
} catch (error) {
|
|
416
|
+
lastError = error;
|
|
417
|
+
if (error instanceof Error && error.name === "JWKSNoMatchingKey") {
|
|
418
|
+
console.warn(`JWKS retry attempt ${4 - retries}:`, error.message);
|
|
419
|
+
retries--;
|
|
420
|
+
if (retries > 0) {
|
|
421
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
throw error;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
throw lastError || new Error("Failed to verify token after retries");
|
|
429
|
+
} catch (error) {
|
|
430
|
+
console.error("Token verification details:", {
|
|
431
|
+
error: error instanceof Error ? {
|
|
432
|
+
name: error.name,
|
|
433
|
+
message: error.message,
|
|
434
|
+
stack: error.stack
|
|
435
|
+
} : error,
|
|
436
|
+
decoded: decodeJwt2(token),
|
|
437
|
+
isSessionCookie
|
|
438
|
+
});
|
|
439
|
+
return {
|
|
440
|
+
valid: false,
|
|
441
|
+
error: {
|
|
442
|
+
success: false,
|
|
443
|
+
message: error instanceof Error ? error.message : "Invalid token",
|
|
444
|
+
code: "INVALID_TOKEN"
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/jwt/customJwt.ts
|
|
451
|
+
import { importPKCS8, SignJWT } from "jose";
|
|
452
|
+
var CustomTokenError = class extends Error {
|
|
453
|
+
constructor(message, code) {
|
|
454
|
+
super(message);
|
|
455
|
+
this.code = code;
|
|
456
|
+
this.name = "CustomTokenError";
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
var RESERVED_CLAIMS = [
|
|
460
|
+
"acr",
|
|
461
|
+
"amr",
|
|
462
|
+
"at_hash",
|
|
463
|
+
"aud",
|
|
464
|
+
"auth_time",
|
|
465
|
+
"azp",
|
|
466
|
+
"cnf",
|
|
467
|
+
"c_hash",
|
|
468
|
+
"exp",
|
|
469
|
+
"firebase",
|
|
470
|
+
"iat",
|
|
471
|
+
"iss",
|
|
472
|
+
"jti",
|
|
473
|
+
"nbf",
|
|
474
|
+
"nonce",
|
|
475
|
+
"sub"
|
|
476
|
+
];
|
|
477
|
+
async function createCustomTokenJwt(uid, developerClaims) {
|
|
478
|
+
try {
|
|
479
|
+
const privateKey = process.env.FIREBASE_PRIVATE_KEY;
|
|
480
|
+
const clientEmail = process.env.FIREBASE_CLIENT_EMAIL;
|
|
481
|
+
if (!privateKey || !clientEmail) {
|
|
482
|
+
return {
|
|
483
|
+
errors: [
|
|
484
|
+
new CustomTokenError(
|
|
485
|
+
"Missing FIREBASE_PRIVATE_KEY or FIREBASE_CLIENT_EMAIL environment variables",
|
|
486
|
+
"MISSING_ENV_VARS"
|
|
487
|
+
)
|
|
488
|
+
]
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (!uid || typeof uid !== "string") {
|
|
492
|
+
return {
|
|
493
|
+
errors: [new CustomTokenError("uid must be a non-empty string", "INVALID_UID")]
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
if (uid.length > 128) {
|
|
497
|
+
return {
|
|
498
|
+
errors: [new CustomTokenError("uid must not exceed 128 characters", "UID_TOO_LONG")]
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
if (developerClaims) {
|
|
502
|
+
for (const claim of Object.keys(developerClaims)) {
|
|
503
|
+
if (RESERVED_CLAIMS.includes(claim)) {
|
|
504
|
+
return {
|
|
505
|
+
errors: [new CustomTokenError(`Custom claim '${claim}' is reserved`, "RESERVED_CLAIM")]
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
const expiresIn = 3600;
|
|
511
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
512
|
+
const parsedPrivateKey = await importPKCS8(privateKey.replace(/\\n/g, "\n"), "RS256");
|
|
513
|
+
const payload = {
|
|
514
|
+
iss: clientEmail,
|
|
515
|
+
sub: clientEmail,
|
|
516
|
+
aud: "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
|
|
517
|
+
iat: now,
|
|
518
|
+
exp: now + expiresIn,
|
|
519
|
+
uid,
|
|
520
|
+
...developerClaims
|
|
521
|
+
};
|
|
522
|
+
const jwt = await new SignJWT(payload).setProtectedHeader({ alg: "RS256", typ: "JWT" }).setIssuedAt(now).setExpirationTime(now + expiresIn).setIssuer(clientEmail).setSubject(clientEmail).setAudience(
|
|
523
|
+
"https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit"
|
|
524
|
+
).sign(parsedPrivateKey);
|
|
525
|
+
return {
|
|
526
|
+
data: jwt
|
|
527
|
+
};
|
|
528
|
+
} catch (error) {
|
|
529
|
+
const message = error instanceof Error ? error.message : "Unknown error occurred";
|
|
530
|
+
return {
|
|
531
|
+
errors: [
|
|
532
|
+
new CustomTokenError(`Failed to create custom token: ${message}`, "TOKEN_CREATION_FAILED")
|
|
533
|
+
]
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
async function createCustomToken(uid, developerClaims) {
|
|
538
|
+
const { data, errors } = await createCustomTokenJwt(uid, developerClaims);
|
|
539
|
+
if (errors) {
|
|
540
|
+
throw errors[0];
|
|
541
|
+
}
|
|
542
|
+
return data;
|
|
543
|
+
}
|
|
544
|
+
function createCustomTokenWithResult(uid, developerClaims) {
|
|
545
|
+
return createCustomTokenJwt(uid, developerClaims);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// src/jwt/signJwt.ts
|
|
549
|
+
import { importPKCS8 as importPKCS82, SignJWT as SignJWT2 } from "jose";
|
|
550
|
+
var ALGORITHM_RS256 = "RS256";
|
|
551
|
+
async function ternSignJwt(opts) {
|
|
552
|
+
const { payload, privateKey, keyId } = opts;
|
|
553
|
+
let key;
|
|
554
|
+
try {
|
|
555
|
+
key = await importPKCS82(privateKey, ALGORITHM_RS256);
|
|
556
|
+
} catch (error) {
|
|
557
|
+
throw new TokenVerificationError({
|
|
558
|
+
message: `Failed to import private key: ${error.message}`,
|
|
559
|
+
reason: TokenVerificationErrorReason.TokenInvalid
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
return new SignJWT2(payload).setProtectedHeader({ alg: ALGORITHM_RS256, kid: keyId }).sign(key);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// src/jwt/index.ts
|
|
566
|
+
var ternDecodeJwt2 = createJwtGuard(ternDecodeJwt);
|
|
567
|
+
|
|
410
568
|
export {
|
|
411
569
|
mapJwtPayloadToDecodedIdToken,
|
|
412
570
|
CustomTokenError,
|
|
@@ -416,6 +574,10 @@ export {
|
|
|
416
574
|
TokenVerificationErrorReason,
|
|
417
575
|
TokenVerificationError,
|
|
418
576
|
ternDecodeJwt,
|
|
419
|
-
verifyJwt
|
|
577
|
+
verifyJwt,
|
|
578
|
+
verifyToken,
|
|
579
|
+
ALGORITHM_RS256,
|
|
580
|
+
ternSignJwt,
|
|
581
|
+
ternDecodeJwt2
|
|
420
582
|
};
|
|
421
|
-
//# sourceMappingURL=chunk-
|
|
583
|
+
//# sourceMappingURL=chunk-NXYWC6YO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jwt/guardReturn.ts","../src/jwt/verifyJwt.ts","../src/utils/errors.ts","../src/utils/mapDecode.ts","../src/utils/rfc4648.ts","../src/jwt/cryptoKeys.ts","../src/jwt/algorithms.ts","../src/jwt/verifyContent.ts","../src/jwt/jwt.ts","../src/jwt/customJwt.ts","../src/jwt/signJwt.ts","../src/jwt/index.ts"],"sourcesContent":["import { type JwtReturnType } from \"./types\";\n\nexport function createJwtGuard<T extends (...args: any[]) => JwtReturnType<any, any>>(decodedFn: T) {\n return (...args: Parameters<T>): NonNullable<Awaited<ReturnType<T>>['data']> | never => {\n const { data, errors } = decodedFn(...args);\n\n if (errors) {\n throw errors[0];\n }\n\n return data;\n };\n}\n","import type { DecodedIdToken, Jwt, JWTPayload } from '@tern-secure/types';\nimport {\n decodeJwt,\n decodeProtectedHeader,\n jwtVerify,\n} from 'jose';\n\nimport { TokenVerificationError, TokenVerificationErrorReason } from '../utils/errors';\nimport { mapJwtPayloadToDecodedIdToken } from '../utils/mapDecode';\nimport { base64url } from '../utils/rfc4648';\nimport { importKey } from './cryptoKeys';\nimport type { JwtReturnType } from './types';\nimport {\n verifyExpirationClaim,\n verifyHeaderKid,\n verifyIssuedAtClaim,\n verifySubClaim,\n} from './verifyContent';\n\nconst DEFAULT_CLOCK_SKEW_IN_MS = 5 * 1000;\n\nexport type VerifyJwtOptions = {\n audience?: string | string[];\n clockSkewInMs?: number;\n key: JsonWebKey | string;\n};\n\nexport async function verifySignature(\n jwt: Jwt,\n key: JsonWebKey | string,\n): Promise<JwtReturnType<JWTPayload, Error>> {\n const { header, raw } = jwt;\n const joseAlgorithm = header.alg || 'RS256';\n\n try {\n const publicKey = await importKey(key, joseAlgorithm);\n\n const { payload } = await jwtVerify(raw.text, publicKey);\n\n return { data: payload };\n } catch (error) {\n return {\n errors: [\n new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalidSignature,\n message: (error as Error).message,\n }),\n ],\n };\n }\n}\n\nexport function ternDecodeJwt(token: string): JwtReturnType<Jwt, TokenVerificationError> {\n try {\n const header = decodeProtectedHeader(token);\n const payload = decodeJwt(token);\n\n const tokenParts = (token || '').toString().split('.');\n if (tokenParts.length !== 3) {\n return {\n errors: [\n new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalid,\n message: 'Invalid JWT format',\n }),\n ],\n };\n }\n\n const [rawHeader, rawPayload, rawSignature] = tokenParts;\n const signature = base64url.parse(rawSignature, { loose: true });\n\n const data = {\n header,\n payload,\n signature,\n raw: {\n header: rawHeader,\n payload: rawPayload,\n signature: rawSignature,\n text: token,\n },\n } satisfies Jwt;\n\n return { data };\n } catch (error) {\n return {\n errors: [\n new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalid,\n message: `${(error as Error).message || 'Invalid Token or Protected Header formatting'} (Token length: ${token?.length}, First 10 chars: ${token?.substring(0, 10)}...)`,\n }),\n ],\n };\n }\n}\n\nexport async function verifyJwt(\n token: string,\n options: VerifyJwtOptions,\n): Promise<JwtReturnType<DecodedIdToken, TokenVerificationError>> {\n const { key } = options;\n const clockSkew = options.clockSkewInMs || DEFAULT_CLOCK_SKEW_IN_MS;\n\n const { data: decoded, errors } = ternDecodeJwt(token);\n if (errors) {\n return { errors };\n }\n\n const { header, payload } = decoded;\n\n try {\n verifyHeaderKid(header.kid);\n verifySubClaim(payload.sub);\n verifyExpirationClaim(payload.exp, clockSkew);\n verifyIssuedAtClaim(payload.iat, clockSkew);\n } catch (error) {\n return { errors: [error as TokenVerificationError] };\n }\n\n const { data: verifiedPayload, errors: signatureErrors } = await verifySignature(decoded, key);\n if (signatureErrors) {\n return {\n errors: [\n new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalidSignature,\n message: 'Token signature verification failed.',\n }),\n ],\n };\n }\n\n const decodedIdToken = mapJwtPayloadToDecodedIdToken(verifiedPayload);\n\n return { data: decodedIdToken };\n}\n","export const RefreshTokenErrorReason = {\n NonEligibleNoCookie: 'non-eligible-no-refresh-cookie',\n NonEligibleNonGet: 'non-eligible-non-get',\n InvalidSessionToken: 'invalid-session-token',\n MissingApiClient: 'missing-api-client',\n MissingIdToken: 'missing-id-token',\n MissingSessionToken: 'missing-session-token',\n MissingRefreshToken: 'missing-refresh-token',\n ExpiredIdTokenDecodeFailed: 'expired-id-token-decode-failed',\n ExpiredSessionTokenDecodeFailed: 'expired-session-token-decode-failed',\n FetchError: 'fetch-error',\n} as const;\n\nexport type TokenCarrier = 'header' | 'cookie';\n\nexport const TokenVerificationErrorReason = {\n TokenExpired: 'token-expired',\n TokenInvalid: 'token-invalid',\n TokenInvalidAlgorithm: 'token-invalid-algorithm',\n TokenInvalidAuthorizedParties: 'token-invalid-authorized-parties',\n TokenInvalidSignature: 'token-invalid-signature',\n TokenNotActiveYet: 'token-not-active-yet',\n TokenIatInTheFuture: 'token-iat-in-the-future',\n TokenVerificationFailed: 'token-verification-failed',\n InvalidSecretKey: 'secret-key-invalid',\n LocalJWKMissing: 'jwk-local-missing',\n RemoteJWKFailedToLoad: 'jwk-remote-failed-to-load',\n RemoteJWKInvalid: 'jwk-remote-invalid',\n RemoteJWKMissing: 'jwk-remote-missing',\n JWKFailedToResolve: 'jwk-failed-to-resolve',\n JWKKidMismatch: 'jwk-kid-mismatch',\n};\n\nexport type TokenVerificationErrorReason =\n (typeof TokenVerificationErrorReason)[keyof typeof TokenVerificationErrorReason];\n\nexport class TokenVerificationError extends Error {\n reason: TokenVerificationErrorReason;\n tokenCarrier?: TokenCarrier;\n\n constructor({\n message,\n reason,\n }: {\n message: string;\n reason: TokenVerificationErrorReason;\n }) {\n super(message);\n\n Object.setPrototypeOf(this, TokenVerificationError.prototype);\n\n this.reason = reason;\n this.message = message;\n }\n\n public getFullMessage() {\n return `${[this.message].filter(m => m).join(' ')} (reason=${this.reason}, token-carrier=${\n this.tokenCarrier\n })`;\n }\n }\n","import type { DecodedIdToken } from \"@tern-secure/types\";\nimport type {\n JWTPayload,\n} from \"jose\";\n\nexport function mapJwtPayloadToDecodedIdToken(payload: JWTPayload) {\n const decodedIdToken = payload as DecodedIdToken;\n decodedIdToken.uid = decodedIdToken.sub;\n return decodedIdToken;\n}","/**\n * The base64url helper was extracted from the rfc4648 package\n * in order to resolve CSJ/ESM interoperability issues\n *\n * https://github.com/swansontec/rfc4648.js\n *\n * For more context please refer to:\n * - https://github.com/evanw/esbuild/issues/1719\n * - https://github.com/evanw/esbuild/issues/532\n * - https://github.com/swansontec/rollup-plugin-mjs-entry\n */\nexport const base64url = {\n parse(string: string, opts?: ParseOptions): Uint8Array {\n return parse(string, base64UrlEncoding, opts);\n },\n\n stringify(data: ArrayLike<number>, opts?: StringifyOptions): string {\n return stringify(data, base64UrlEncoding, opts);\n },\n};\n\nconst base64UrlEncoding: Encoding = {\n chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',\n bits: 6,\n};\n\ninterface Encoding {\n bits: number;\n chars: string;\n codes?: { [char: string]: number };\n}\n\ninterface ParseOptions {\n loose?: boolean;\n out?: new (size: number) => { [index: number]: number };\n}\n\ninterface StringifyOptions {\n pad?: boolean;\n}\n\nfunction parse(string: string, encoding: Encoding, opts: ParseOptions = {}): Uint8Array {\n // Build the character lookup table:\n if (!encoding.codes) {\n encoding.codes = {};\n for (let i = 0; i < encoding.chars.length; ++i) {\n encoding.codes[encoding.chars[i]] = i;\n }\n }\n\n // The string must have a whole number of bytes:\n if (!opts.loose && (string.length * encoding.bits) & 7) {\n throw new SyntaxError('Invalid padding');\n }\n\n // Count the padding bytes:\n let end = string.length;\n while (string[end - 1] === '=') {\n --end;\n\n // If we get a whole number of bytes, there is too much padding:\n if (!opts.loose && !(((string.length - end) * encoding.bits) & 7)) {\n throw new SyntaxError('Invalid padding');\n }\n }\n\n // Allocate the output:\n const out = new (opts.out ?? Uint8Array)(((end * encoding.bits) / 8) | 0) as Uint8Array;\n\n // Parse the data:\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n let written = 0; // Next byte to write\n for (let i = 0; i < end; ++i) {\n // Read one character from the string:\n const value = encoding.codes[string[i]];\n if (value === undefined) {\n throw new SyntaxError('Invalid character ' + string[i]);\n }\n\n // Append the bits to the buffer:\n buffer = (buffer << encoding.bits) | value;\n bits += encoding.bits;\n\n // Write out some bits if the buffer has a byte's worth:\n if (bits >= 8) {\n bits -= 8;\n out[written++] = 0xff & (buffer >> bits);\n }\n }\n\n // Verify that we have received just enough bits:\n if (bits >= encoding.bits || 0xff & (buffer << (8 - bits))) {\n throw new SyntaxError('Unexpected end of data');\n }\n\n return out;\n}\n\nfunction stringify(data: ArrayLike<number>, encoding: Encoding, opts: StringifyOptions = {}): string {\n const { pad = true } = opts;\n const mask = (1 << encoding.bits) - 1;\n let out = '';\n\n let bits = 0; // Number of bits currently in the buffer\n let buffer = 0; // Bits waiting to be written out, MSB first\n for (let i = 0; i < data.length; ++i) {\n // Slurp data into the buffer:\n buffer = (buffer << 8) | (0xff & data[i]);\n bits += 8;\n\n // Write out as much as we can:\n while (bits > encoding.bits) {\n bits -= encoding.bits;\n out += encoding.chars[mask & (buffer >> bits)];\n }\n }\n\n // Partial character:\n if (bits) {\n out += encoding.chars[mask & (buffer << (encoding.bits - bits))];\n }\n\n // Add padding characters until we hit a byte boundary:\n if (pad) {\n while ((out.length * encoding.bits) & 7) {\n out += '=';\n }\n }\n\n return out;\n}\n","import { importJWK, importSPKI,importX509, type KeyLike } from 'jose';\n\nexport async function importKey(key: JsonWebKey | string, algorithm: string): Promise<KeyLike> {\n if (typeof key === 'object') {\n const result = await importJWK(key as Parameters<typeof importJWK>[0], algorithm);\n if (result instanceof Uint8Array) {\n throw new Error('Unexpected Uint8Array result from JWK import');\n }\n return result;\n }\n\n const keyString = key.trim();\n\n if (keyString.includes('-----BEGIN CERTIFICATE-----')) {\n return await importX509(keyString, algorithm);\n }\n\n if (keyString.includes('-----BEGIN PUBLIC KEY-----')) {\n return await importSPKI(keyString, algorithm);\n }\n\n try {\n return await importSPKI(keyString, algorithm);\n } catch (error) {\n throw new Error(\n `Unsupported key format. Supported formats: X.509 certificate (PEM), SPKI (PEM), JWK (JSON object or string). Error: ${error}`,\n );\n }\n}\n","const algToHash: Record<string, string> = {\n RS256: 'SHA-256',\n RS384: 'SHA-384',\n RS512: 'SHA-512',\n};\nconst RSA_ALGORITHM_NAME = 'RSASSA-PKCS1-v1_5';\n\nconst jwksAlgToCryptoAlg: Record<string, string> = {\n RS256: RSA_ALGORITHM_NAME,\n RS384: RSA_ALGORITHM_NAME,\n RS512: RSA_ALGORITHM_NAME,\n};\n\nexport const algs = Object.keys(algToHash);\n\nexport function getCryptoAlgorithm(algorithmName: string): RsaHashedImportParams {\n const hash = algToHash[algorithmName];\n const name = jwksAlgToCryptoAlg[algorithmName];\n\n if (!hash || !name) {\n throw new Error(`Unsupported algorithm ${algorithmName}, expected one of ${algs.join(',')}.`);\n }\n\n return {\n hash: { name: algToHash[algorithmName] },\n name: jwksAlgToCryptoAlg[algorithmName],\n };\n}\n","import { TokenVerificationError, TokenVerificationErrorReason } from '../utils/errors';\nimport { algs } from './algorithms';\n\nexport const verifyHeaderType = (typ?: unknown) => {\n if (typeof typ === 'undefined') {\n return;\n }\n\n if (typ !== 'JWT') {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalid,\n message: `Invalid JWT type ${JSON.stringify(typ)}. Expected \"JWT\".`,\n });\n }\n};\n\nexport const verifyHeaderKid = (kid?: unknown) => {\n if (typeof kid === 'undefined') {\n return;\n }\n\n if (typeof kid !== 'string') {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalid,\n message: `Invalid JWT kid ${JSON.stringify(kid)}. Expected a string.`,\n });\n }\n};\n\nexport const verifyHeaderAlgorithm = (alg: string) => {\n if (!algs.includes(alg)) {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenInvalidAlgorithm,\n message: `Invalid JWT algorithm ${JSON.stringify(alg)}. Supported: ${algs}.`,\n });\n }\n};\n\nexport const verifySubClaim = (sub?: string) => {\n if (typeof sub !== 'string') {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenVerificationFailed,\n message: `Subject claim (sub) is required and must be a string. Received ${JSON.stringify(sub)}.`,\n });\n }\n};\n\nexport const verifyExpirationClaim = (exp: number | undefined, clockSkewInMs: number) => {\n if (typeof exp !== 'number') {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenVerificationFailed,\n message: `Invalid JWT expiry date (exp) claim ${JSON.stringify(exp)}. Expected a number.`,\n });\n }\n\n const currentDate = new Date(Date.now());\n const expiryDate = new Date(0);\n expiryDate.setUTCSeconds(exp);\n\n const expired = expiryDate.getTime() <= currentDate.getTime() - clockSkewInMs;\n if (expired) {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenExpired,\n message: `JWT is expired. Expiry date: ${expiryDate.toUTCString()}, Current date: ${currentDate.toUTCString()}.`,\n });\n }\n};\n\nexport const verifyIssuedAtClaim = (iat: number | undefined, clockSkewInMs: number) => {\n if (typeof iat === 'undefined') {\n return;\n }\n\n if (typeof iat !== 'number') {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenVerificationFailed,\n message: `Invalid JWT issued at date claim (iat) ${JSON.stringify(iat)}. Expected a number.`,\n });\n }\n\n const currentDate = new Date(Date.now());\n const issuedAtDate = new Date(0);\n issuedAtDate.setUTCSeconds(iat);\n\n const postIssued = issuedAtDate.getTime() > currentDate.getTime() + clockSkewInMs;\n if (postIssued) {\n throw new TokenVerificationError({\n reason: TokenVerificationErrorReason.TokenIatInTheFuture,\n message: `JWT issued at date claim (iat) is in the future. Issued at date: ${issuedAtDate.toUTCString()}; Current date: ${currentDate.toUTCString()};`,\n });\n }\n};\n","import type {\n DecodedIdToken,\n TernVerificationResult,\n} from \"@tern-secure/types\";\nimport { createRemoteJWKSet, decodeJwt,jwtVerify } from \"jose\";\n\n\nexport type FirebaseIdTokenPayload = DecodedIdToken;\n\n// Firebase public key endpoints\nconst FIREBASE_ID_TOKEN_URL =\n \"https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com\";\nconst FIREBASE_SESSION_CERT_URL =\n \"https://identitytoolkit.googleapis.com/v1/sessionCookiePublicKeys\";\n\n//const FIREBASE_NEW_SESSION_PK = \"https://www.googleapis.com/identitytoolkit/v3/relyingparty/publicKeys\"\n\n// Simple in-memory cache for JWKS\nlet idTokenJWKS: ReturnType<typeof createRemoteJWKSet> | null = null;\nlet sessionJWKS: ReturnType<typeof createRemoteJWKSet> | null = null;\n\nconst getIdTokenJWKS = () => {\n if (!idTokenJWKS) {\n idTokenJWKS = createRemoteJWKSet(new URL(FIREBASE_ID_TOKEN_URL), {\n cacheMaxAge: 3600000, // 1 hour\n timeoutDuration: 5000, // 5 seconds\n cooldownDuration: 30000, // 30 seconds between retries\n });\n }\n return idTokenJWKS;\n};\n\nconst getSessionJWKS = () => {\n if (!sessionJWKS) {\n sessionJWKS = createRemoteJWKSet(new URL(FIREBASE_SESSION_CERT_URL), {\n cacheMaxAge: 3600000, // 1 hour\n timeoutDuration: 5000, // 5 seconds\n cooldownDuration: 30000, // 30 seconds between retries\n });\n }\n return sessionJWKS;\n};\n\n\n\nexport async function verifyToken(\n token: string,\n isSessionCookie = false\n): Promise<TernVerificationResult> {\n try {\n const projectId = process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID;\n if (!projectId) {\n throw new Error(\"Firebase Project ID is not configured\");\n }\n\n const { decoded } = decodeJwt(token);\n if (!decoded) {\n throw new Error(\"Invalid token format\");\n }\n\n let retries = 3;\n let lastError: Error | null = null;\n\n while (retries > 0) {\n try {\n // Use different JWKS based on token type\n const JWKS = isSessionCookie ? getSessionJWKS() : getIdTokenJWKS();\n\n const { payload } = await jwtVerify(token, JWKS, {\n issuer: isSessionCookie\n ? \"https://session.firebase.google.com/\" + projectId\n : \"https://securetoken.google.com/\" + projectId,\n audience: projectId,\n algorithms: [\"RS256\"],\n });\n\n const firebasePayload = payload as unknown as FirebaseIdTokenPayload;\n const now = Math.floor(Date.now() / 1000);\n\n // Verify token claims\n if (firebasePayload.exp <= now) {\n throw new Error(\"Token has expired\");\n }\n\n if (firebasePayload.iat > now) {\n throw new Error(\"Token issued time is in the future\");\n }\n\n if (!firebasePayload.sub) {\n throw new Error(\"Token subject is empty\");\n }\n\n if (firebasePayload.auth_time > now) {\n throw new Error(\"Token auth time is in the future\");\n }\n\n return {\n valid: true,\n uid: firebasePayload.sub,\n sub: firebasePayload.sub,\n email: firebasePayload.email,\n email_verified: firebasePayload.email_verified,\n auth_time: firebasePayload.auth_time,\n iat: firebasePayload.iat,\n exp: firebasePayload.exp,\n aud: firebasePayload.aud,\n iss: firebasePayload.iss,\n firebase: firebasePayload.firebase,\n phone_number: firebasePayload.phone_number,\n picture: firebasePayload.picture,\n };\n } catch (error) {\n lastError = error as Error;\n if (error instanceof Error && error.name === \"JWKSNoMatchingKey\") {\n console.warn(`JWKS retry attempt ${4 - retries}:`, error.message);\n retries--;\n if (retries > 0) {\n await new Promise((resolve) => setTimeout(resolve, 1000));\n continue;\n }\n }\n throw error;\n }\n }\n\n throw lastError || new Error(\"Failed to verify token after retries\");\n } catch (error) {\n console.error(\"Token verification details:\", {\n error:\n error instanceof Error\n ? {\n name: error.name,\n message: error.message,\n stack: error.stack,\n }\n : error,\n decoded: decodeJwt(token),\n isSessionCookie,\n });\n\n return {\n valid: false,\n error: {\n success: false,\n message: error instanceof Error ? error.message : \"Invalid token\",\n code: \"INVALID_TOKEN\",\n },\n };\n }\n}\n","import type { JWTPayload } from '@tern-secure/types';\nimport { importPKCS8, SignJWT } from 'jose';\n\nimport type { JwtReturnType } from './types';\n\n\nexport interface CustomTokenClaims {\n [key: string]: unknown;\n}\n\nexport class CustomTokenError extends Error {\n constructor(\n message: string,\n public code?: string,\n ) {\n super(message);\n this.name = 'CustomTokenError';\n }\n}\n\nconst RESERVED_CLAIMS = [\n 'acr',\n 'amr',\n 'at_hash',\n 'aud',\n 'auth_time',\n 'azp',\n 'cnf',\n 'c_hash',\n 'exp',\n 'firebase',\n 'iat',\n 'iss',\n 'jti',\n 'nbf',\n 'nonce',\n 'sub',\n];\n\nasync function createCustomTokenJwt(\n uid: string,\n developerClaims?: CustomTokenClaims,\n): Promise<JwtReturnType<string, CustomTokenError>> {\n try {\n const privateKey = process.env.FIREBASE_PRIVATE_KEY;\n const clientEmail = process.env.FIREBASE_CLIENT_EMAIL;\n\n if (!privateKey || !clientEmail) {\n return {\n errors: [\n new CustomTokenError(\n 'Missing FIREBASE_PRIVATE_KEY or FIREBASE_CLIENT_EMAIL environment variables',\n 'MISSING_ENV_VARS',\n ),\n ],\n };\n }\n\n if (!uid || typeof uid !== 'string') {\n return {\n errors: [new CustomTokenError('uid must be a non-empty string', 'INVALID_UID')],\n };\n }\n\n if (uid.length > 128) {\n return {\n errors: [new CustomTokenError('uid must not exceed 128 characters', 'UID_TOO_LONG')],\n };\n }\n\n if (developerClaims) {\n for (const claim of Object.keys(developerClaims)) {\n if (RESERVED_CLAIMS.includes(claim)) {\n return {\n errors: [new CustomTokenError(`Custom claim '${claim}' is reserved`, 'RESERVED_CLAIM')],\n };\n }\n }\n }\n\n // Set expiration (default 1 hour, max 1 hour)\n const expiresIn = 3600;\n const now = Math.floor(Date.now() / 1000);\n\n const parsedPrivateKey = await importPKCS8(privateKey.replace(/\\\\n/g, '\\n'), 'RS256');\n\n const payload: JWTPayload = {\n iss: clientEmail,\n sub: clientEmail,\n aud: 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',\n iat: now,\n exp: now + expiresIn,\n uid: uid,\n ...developerClaims,\n };\n\n const jwt = await new SignJWT(payload)\n .setProtectedHeader({ alg: 'RS256', typ: 'JWT' })\n .setIssuedAt(now)\n .setExpirationTime(now + expiresIn)\n .setIssuer(clientEmail)\n .setSubject(clientEmail)\n .setAudience(\n 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',\n )\n .sign(parsedPrivateKey);\n\n return {\n data: jwt,\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown error occurred';\n return {\n errors: [\n new CustomTokenError(`Failed to create custom token: ${message}`, 'TOKEN_CREATION_FAILED'),\n ],\n };\n }\n}\n\nexport async function createCustomToken(\n uid: string,\n developerClaims?: CustomTokenClaims,\n): Promise<string> {\n const { data, errors } = await createCustomTokenJwt(uid, developerClaims);\n\n if (errors) {\n throw errors[0];\n }\n\n return data;\n}\n\nexport function createCustomTokenWithResult(\n uid: string,\n developerClaims?: CustomTokenClaims,\n): Promise<JwtReturnType<string, CustomTokenError>> {\n return createCustomTokenJwt(uid, developerClaims);\n}","import type { JWTPayload } from '@tern-secure/types';\nimport type { KeyLike } from 'jose';\nimport { importPKCS8, SignJWT } from 'jose';\n\nimport { TokenVerificationError, TokenVerificationErrorReason } from '../utils/errors';\n\nexport interface SignJwtOptions {\n algorithm?: string;\n header?: Record<string, unknown>;\n}\n\nexport const ALGORITHM_RS256 = 'RS256' as const;\n\n\nexport type SignOptions = {\n readonly payload: JWTPayload;\n readonly privateKey: string;\n readonly keyId?: string;\n};\n\n\nexport async function ternSignJwt(opts: SignOptions): Promise<string> {\n const { payload, privateKey, keyId } = opts;\n let key: KeyLike;\n\n try {\n key = await importPKCS8(privateKey, ALGORITHM_RS256);\n } catch (error) {\n throw new TokenVerificationError({\n message: `Failed to import private key: ${(error as Error).message}`,\n reason: TokenVerificationErrorReason.TokenInvalid,\n });\n }\n\n return new SignJWT(payload)\n .setProtectedHeader({ alg: ALGORITHM_RS256, kid: keyId })\n .sign(key);\n}\n","import { createJwtGuard } from './guardReturn';\nimport { ternDecodeJwt as _ternDecodeJwt } from './verifyJwt';\n\nexport const ternDecodeJwt = createJwtGuard(_ternDecodeJwt);\nexport { ternDecodeJwt as ternDecodeJwtUnguarded } from './verifyJwt';\n\nexport * from './jwt';\nexport * from './customJwt';\nexport * from './signJwt';\nexport type { JwtReturnType } from './types';"],"mappings":";AAEO,SAAS,eAAsE,WAAc;AAClG,SAAO,IAAI,SAA6E;AACtF,UAAM,EAAE,MAAM,OAAO,IAAI,UAAU,GAAG,IAAI;AAE1C,QAAI,QAAQ;AACV,YAAM,OAAO,CAAC;AAAA,IAChB;AAEA,WAAO;AAAA,EACT;AACF;;;ACXA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACLA,IA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MAAI;AACF,UAAM,MAAMC,aAAY,YAAY,eAAe;AAAA,EACrD,SAAS,OAAO;AACd,UAAM,IAAI,uBAAuB;AAAA,MAC/B,SAAS,iCAAkC,MAAgB,OAAO;AAAA,MAClE,QAAQ,6BAA6B;AAAA,IACvC,CAAC;AAAA,EACH;AAEA,SAAO,IAAIC,SAAQ,OAAO,EACvB,mBAAmB,EAAE,KAAK,iBAAiB,KAAK,MAAM,CAAC,EACvD,KAAK,GAAG;AACb;;;AClCO,IAAMC,iBAAgB,eAAe,aAAc;","names":["decodeJwt","jwtVerify","importPKCS8","SignJWT","importPKCS8","SignJWT","ternDecodeJwt"]}
|
|
@@ -37,6 +37,7 @@ var QueryParameters = {
|
|
|
37
37
|
};
|
|
38
38
|
var Headers = {
|
|
39
39
|
Accept: "accept",
|
|
40
|
+
AppCheckToken: "x-firebase-appcheck",
|
|
40
41
|
AuthMessage: "x-ternsecure-auth-message",
|
|
41
42
|
Authorization: "authorization",
|
|
42
43
|
AuthReason: "x-ternsecure-auth-reason",
|
|
@@ -82,4 +83,4 @@ export {
|
|
|
82
83
|
CACHE_CONTROL_REGEX,
|
|
83
84
|
constants
|
|
84
85
|
};
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-WIVOBOZR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const GOOGLE_PUBLIC_KEYS_URL =\n 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com';\nexport const SESSION_COOKIE_PUBLIC_KEYS_URL =\n 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/publicKeys';\n\nexport const MAX_CACHE_LAST_UPDATED_AT_SECONDS = 5 * 60;\nexport const DEFAULT_CACHE_DURATION = 3600 * 1000; // 1 hour in milliseconds\nexport const CACHE_CONTROL_REGEX = /max-age=(\\d+)/;\n\nconst Attributes = {\n AuthToken: '__ternsecureAuthToken',\n AuthSignature: '__ternsecureAuthSignature',\n AuthStatus: '__ternsecureAuthStatus',\n AuthReason: '__ternsecureAuthReason',\n AuthMessage: '__ternsecureAuthMessage',\n TernSecureUrl: '__ternsecureUrl',\n} as const;\n\nconst Cookies = {\n Session: '__session',\n CsrfToken: '__terncf',\n IdToken: 'TernSecure_[DEFAULT]',\n Refresh: 'TernSecureID_[DEFAULT]',\n Custom: '__custom',\n TernAut: 'tern_aut',\n Handshake: '__ternsecure_handshake',\n DevBrowser: '__ternsecure_db_jwt',\n RedirectCount: '__ternsecure_redirect_count',\n HandshakeNonce: '__ternsecure_handshake_nonce',\n} as const;\n\n\nconst QueryParameters = {\n TernSynced: '__tern_synced',\n SuffixedCookies: 'suffixed_cookies',\n TernRedirectUrl: '__tern_redirect_url',\n // use the reference to Cookies to indicate that it's the same value\n DevBrowser: Cookies.DevBrowser,\n Handshake: Cookies.Handshake,\n HandshakeHelp: '__tern_help',\n LegacyDevBrowser: '__dev_session',\n HandshakeReason: '__tern_hs_reason',\n HandshakeNonce: Cookies.HandshakeNonce,\n} as const;\n\nconst Headers = {\n Accept: 'accept',\n AppCheckToken: 'x-firebase-appcheck',\n AuthMessage: 'x-ternsecure-auth-message',\n Authorization: 'authorization',\n AuthReason: 'x-ternsecure-auth-reason',\n AuthSignature: 'x-ternsecure-auth-signature',\n AuthStatus: 'x-ternsecure-auth-status',\n AuthToken: 'x-ternsecure-auth-token',\n CacheControl: 'cache-control',\n TernSecureRedirectTo: 'x-ternsecure-redirect-to',\n TernSecureRequestData: 'x-ternsecure-request-data',\n TernSecureUrl: 'x-ternsecure-url',\n CloudFrontForwardedProto: 'cloudfront-forwarded-proto',\n ContentType: 'content-type',\n ContentSecurityPolicy: 'content-security-policy',\n ContentSecurityPolicyReportOnly: 'content-security-policy-report-only',\n EnableDebug: 'x-ternsecure-debug',\n ForwardedHost: 'x-forwarded-host',\n ForwardedPort: 'x-forwarded-port',\n ForwardedProto: 'x-forwarded-proto',\n Host: 'host',\n Location: 'location',\n Nonce: 'x-nonce',\n Origin: 'origin',\n Referrer: 'referer',\n SecFetchDest: 'sec-fetch-dest',\n UserAgent: 'user-agent',\n ReportingEndpoints: 'reporting-endpoints',\n} as const;\n\nconst ContentTypes = {\n Json: 'application/json',\n} as const;\n\n/**\n * @internal\n */\nexport const constants = {\n Attributes,\n Cookies,\n Headers,\n ContentTypes,\n QueryParameters,\n} as const;\n\nexport type Constants = typeof constants;\n"],"mappings":";AAAO,IAAM,yBACX;AAIK,IAAM,oCAAoC,IAAI;AAC9C,IAAM,yBAAyB,OAAO;AACtC,IAAM,sBAAsB;AAEnC,IAAM,aAAa;AAAA,EACjB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,eAAe;AACjB;AAEA,IAAM,UAAU;AAAA,EACd,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,gBAAgB;AAClB;AAGA,IAAM,kBAAkB;AAAA,EACtB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,iBAAiB;AAAA;AAAA,EAEjB,YAAY,QAAQ;AAAA,EACpB,WAAW,QAAQ;AAAA,EACnB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB,QAAQ;AAC1B;AAEA,IAAM,UAAU;AAAA,EACd,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,aAAa;AAAA,EACb,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,0BAA0B;AAAA,EAC1B,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,iCAAiC;AAAA,EACjC,aAAa;AAAA,EACb,eAAe;AAAA,EACf,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,cAAc;AAAA,EACd,WAAW;AAAA,EACX,oBAAoB;AACtB;AAEA,IAAM,eAAe;AAAA,EACnB,MAAM;AACR;AAKO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const constants: {
|
|
|
29
29
|
};
|
|
30
30
|
readonly Headers: {
|
|
31
31
|
readonly Accept: "accept";
|
|
32
|
+
readonly AppCheckToken: "x-firebase-appcheck";
|
|
32
33
|
readonly AuthMessage: "x-ternsecure-auth-message";
|
|
33
34
|
readonly Authorization: "authorization";
|
|
34
35
|
readonly AuthReason: "x-ternsecure-auth-reason";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,6FACyD,CAAC;AAC7F,eAAO,MAAM,8BAA8B,0EAC8B,CAAC;AAE1E,eAAO,MAAM,iCAAiC,QAAS,CAAC;AACxD,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAClD,eAAO,MAAM,mBAAmB,QAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,6FACyD,CAAC;AAC7F,eAAO,MAAM,8BAA8B,0EAC8B,CAAC;AAE1E,eAAO,MAAM,iCAAiC,QAAS,CAAC;AACxD,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAClD,eAAO,MAAM,mBAAmB,QAAkB,CAAC;AAyEnD;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { EmailApi, PasswordApi, SignInApi, SignInTokenApi, SignUpApi, TokenApi, UserData } from './endpoints';
|
|
1
|
+
import { AppCheckApi, EmailApi, PasswordApi, SignInApi, SignInTokenApi, SignUpApi, TokenApi, UserData } from './endpoints';
|
|
2
2
|
import { createRequest } from './request';
|
|
3
3
|
export type CreateFireApiOptions = Parameters<typeof createRequest>[0];
|
|
4
4
|
export type ApiClient = ReturnType<typeof createFireApi>;
|
|
5
5
|
export declare function createFireApi(options: CreateFireApiOptions): {
|
|
6
|
+
appCheck: AppCheckApi;
|
|
6
7
|
email: EmailApi;
|
|
7
8
|
password: PasswordApi;
|
|
8
9
|
signIn: SignInApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFireApi.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/createFireApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"createFireApi.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/createFireApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC3H,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAEzD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;EAY1D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractAPI } from './AbstractApi';
|
|
2
|
+
export interface AppCheckTokenResponse {
|
|
3
|
+
token: string;
|
|
4
|
+
ttl: string;
|
|
5
|
+
}
|
|
6
|
+
type AppCheckParams = {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
appId: string;
|
|
10
|
+
customToken: string;
|
|
11
|
+
limitedUse?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function getSdkVersion(): string;
|
|
14
|
+
/**
|
|
15
|
+
* App Check API for managing Firebase App Check tokens via REST
|
|
16
|
+
* Firebase REST API endpoint: https://firebaseappcheck.googleapis.com/v1beta/projects/{projectId}/apps/{appId}:exchangeCustomToken
|
|
17
|
+
*/
|
|
18
|
+
export declare class AppCheckApi extends AbstractAPI {
|
|
19
|
+
exchangeCustomToken(params: AppCheckParams): Promise<AppCheckTokenResponse>;
|
|
20
|
+
exchangeDebugToken(params: AppCheckParams): Promise<AppCheckTokenResponse>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=AppCheckApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppCheckApi.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/AppCheckApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AAGD,KAAK,cAAc,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAMD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAC3B,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyC3E,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAwC1F"}
|
|
@@ -7,6 +7,7 @@ type RefreshTokenParams = {
|
|
|
7
7
|
request_originating_ip?: string;
|
|
8
8
|
request_headers?: Record<string, string[]>;
|
|
9
9
|
suffixed_cookies?: boolean;
|
|
10
|
+
app_check_token?: string;
|
|
10
11
|
format?: 'token' | 'cookie';
|
|
11
12
|
};
|
|
12
13
|
type IdAndRefreshTokensParams = {
|
|
@@ -15,10 +16,11 @@ type IdAndRefreshTokensParams = {
|
|
|
15
16
|
};
|
|
16
17
|
type IdAndRefreshTokensOptions = {
|
|
17
18
|
referer?: string;
|
|
19
|
+
appCheckToken?: string;
|
|
18
20
|
};
|
|
19
21
|
export declare class TokenApi extends AbstractAPI {
|
|
20
22
|
refreshToken(apiKey: string, params: RefreshTokenParams): Promise<import("../request").BackendApiResponse<unknown>>;
|
|
21
|
-
exchangeCustomForIdAndRefreshTokens(apiKey: string, params: IdAndRefreshTokensParams, options?: IdAndRefreshTokensOptions): Promise<
|
|
23
|
+
exchangeCustomForIdAndRefreshTokens(apiKey: string, params: IdAndRefreshTokensParams, options?: IdAndRefreshTokensOptions): Promise<IdAndRefreshTokens>;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
24
26
|
//# sourceMappingURL=TokenApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenApi.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/TokenApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EA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AC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAAa,QAAS,SAAQ,WAAW;IAC1B,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;IA6BvD,mCAAmC,CAC9C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,wBAAwB,EAChC,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,kBAAkB,CAAC;CA6B/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserData.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/UserData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,QAAS,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"UserData.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/UserData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,QAAS,SAAQ,WAAW;IAC1B,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,eAAe;CAgB3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAa5B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AACrE,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,cAAc,GACd,oBAAoB,GACpB,QAAQ,GACR,uBAAuB,GACvB,eAAe,GACf,aAAa,CAAA;AAEjB,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM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