@tern-secure/backend 1.2.0-canary.v20251202164451 → 1.2.0-canary.v20251202172616
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/app-check/package.json +5 -0
- package/dist/admin/index.mjs +561 -23
- package/dist/admin/index.mjs.map +1 -1
- package/dist/app-check/index.js +4 -119
- package/dist/app-check/index.js.map +1 -1
- package/dist/app-check/index.mjs +2 -2
- package/dist/app-check/serverAppCheck.d.ts.map +1 -1
- package/dist/auth/index.js +3 -148
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +2 -2
- package/dist/chunk-4NYVEI6S.mjs +142 -0
- package/dist/chunk-4NYVEI6S.mjs.map +1 -0
- package/dist/chunk-PYNFU7M3.mjs +71 -0
- package/dist/chunk-PYNFU7M3.mjs.map +1 -0
- package/dist/{chunk-UCSJDX6Y.mjs → chunk-ZGZR5TER.mjs} +7 -6
- package/dist/chunk-ZGZR5TER.mjs.map +1 -0
- package/dist/index.js +8 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/dist/chunk-34QENCWP.mjs +0 -784
- package/dist/chunk-34QENCWP.mjs.map +0 -1
- package/dist/chunk-UCSJDX6Y.mjs.map +0 -1
package/dist/app-check/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/app-check/index.ts
|
|
@@ -337,14 +327,6 @@ var ONE_HOUR_IN_SECONDS = 60 * 60;
|
|
|
337
327
|
var ONE_MINUTE_IN_SECONDS = 60;
|
|
338
328
|
var ONE_MINUTE_IN_MILLIS = ONE_MINUTE_IN_SECONDS * 1e3;
|
|
339
329
|
var ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1e3;
|
|
340
|
-
var Attributes = {
|
|
341
|
-
AuthToken: "__ternsecureAuthToken",
|
|
342
|
-
AuthSignature: "__ternsecureAuthSignature",
|
|
343
|
-
AuthStatus: "__ternsecureAuthStatus",
|
|
344
|
-
AuthReason: "__ternsecureAuthReason",
|
|
345
|
-
AuthMessage: "__ternsecureAuthMessage",
|
|
346
|
-
TernSecureUrl: "__ternsecureUrl"
|
|
347
|
-
};
|
|
348
330
|
var Cookies = {
|
|
349
331
|
Session: "__session",
|
|
350
332
|
CsrfToken: "__terncf",
|
|
@@ -369,46 +351,6 @@ var QueryParameters = {
|
|
|
369
351
|
HandshakeReason: "__tern_hs_reason",
|
|
370
352
|
HandshakeNonce: Cookies.HandshakeNonce
|
|
371
353
|
};
|
|
372
|
-
var Headers2 = {
|
|
373
|
-
Accept: "accept",
|
|
374
|
-
AppCheckToken: "x-ternsecure-appcheck",
|
|
375
|
-
AuthMessage: "x-ternsecure-auth-message",
|
|
376
|
-
Authorization: "authorization",
|
|
377
|
-
AuthReason: "x-ternsecure-auth-reason",
|
|
378
|
-
AuthSignature: "x-ternsecure-auth-signature",
|
|
379
|
-
AuthStatus: "x-ternsecure-auth-status",
|
|
380
|
-
AuthToken: "x-ternsecure-auth-token",
|
|
381
|
-
CacheControl: "cache-control",
|
|
382
|
-
TernSecureRedirectTo: "x-ternsecure-redirect-to",
|
|
383
|
-
TernSecureRequestData: "x-ternsecure-request-data",
|
|
384
|
-
TernSecureUrl: "x-ternsecure-url",
|
|
385
|
-
CloudFrontForwardedProto: "cloudfront-forwarded-proto",
|
|
386
|
-
ContentType: "content-type",
|
|
387
|
-
ContentSecurityPolicy: "content-security-policy",
|
|
388
|
-
ContentSecurityPolicyReportOnly: "content-security-policy-report-only",
|
|
389
|
-
EnableDebug: "x-ternsecure-debug",
|
|
390
|
-
ForwardedHost: "x-forwarded-host",
|
|
391
|
-
ForwardedPort: "x-forwarded-port",
|
|
392
|
-
ForwardedProto: "x-forwarded-proto",
|
|
393
|
-
Host: "host",
|
|
394
|
-
Location: "location",
|
|
395
|
-
Nonce: "x-nonce",
|
|
396
|
-
Origin: "origin",
|
|
397
|
-
Referrer: "referer",
|
|
398
|
-
SecFetchDest: "sec-fetch-dest",
|
|
399
|
-
UserAgent: "user-agent",
|
|
400
|
-
ReportingEndpoints: "reporting-endpoints"
|
|
401
|
-
};
|
|
402
|
-
var ContentTypes = {
|
|
403
|
-
Json: "application/json"
|
|
404
|
-
};
|
|
405
|
-
var constants = {
|
|
406
|
-
Attributes,
|
|
407
|
-
Cookies,
|
|
408
|
-
Headers: Headers2,
|
|
409
|
-
ContentTypes,
|
|
410
|
-
QueryParameters
|
|
411
|
-
};
|
|
412
354
|
|
|
413
355
|
// src/utils/config.ts
|
|
414
356
|
var loadAdminConfig = () => ({
|
|
@@ -814,64 +756,6 @@ var AppCheckTokenGenerator = class {
|
|
|
814
756
|
|
|
815
757
|
// src/app-check/serverAppCheck.ts
|
|
816
758
|
var import_redis = require("@upstash/redis");
|
|
817
|
-
|
|
818
|
-
// src/admin/sessionTernSecure.ts
|
|
819
|
-
var import_errors6 = require("@tern-secure/shared/errors");
|
|
820
|
-
|
|
821
|
-
// src/utils/admin-init.ts
|
|
822
|
-
var import_firebase_admin = __toESM(require("firebase-admin"));
|
|
823
|
-
var import_app_check2 = require("firebase-admin/app-check");
|
|
824
|
-
if (!import_firebase_admin.default.apps.length) {
|
|
825
|
-
try {
|
|
826
|
-
const config = initializeAdminConfig();
|
|
827
|
-
import_firebase_admin.default.initializeApp({
|
|
828
|
-
credential: import_firebase_admin.default.credential.cert({
|
|
829
|
-
...config,
|
|
830
|
-
privateKey: config.privateKey.replace(/\\n/g, "\n")
|
|
831
|
-
})
|
|
832
|
-
});
|
|
833
|
-
} catch (error) {
|
|
834
|
-
console.error("Firebase admin initialization error", error);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
var adminTernSecureAuth = import_firebase_admin.default.auth();
|
|
838
|
-
var adminTernSecureDb = import_firebase_admin.default.firestore();
|
|
839
|
-
var TernSecureTenantManager = import_firebase_admin.default.auth().tenantManager();
|
|
840
|
-
var appCheckAdmin = (0, import_app_check2.getAppCheck)();
|
|
841
|
-
|
|
842
|
-
// src/admin/sessionTernSecure.ts
|
|
843
|
-
var DEFAULT_COOKIE_CONFIG = {
|
|
844
|
-
DEFAULT_EXPIRES_IN_MS: 5 * 60 * 1e3,
|
|
845
|
-
// 5 minutes
|
|
846
|
-
DEFAULT_EXPIRES_IN_SECONDS: 5 * 60,
|
|
847
|
-
REVOKE_REFRESH_TOKENS_ON_SIGNOUT: true
|
|
848
|
-
};
|
|
849
|
-
var DEFAULT_COOKIE_OPTIONS = {
|
|
850
|
-
httpOnly: true,
|
|
851
|
-
secure: process.env.NODE_ENV === "production",
|
|
852
|
-
sameSite: "strict",
|
|
853
|
-
path: "/"
|
|
854
|
-
};
|
|
855
|
-
|
|
856
|
-
// src/admin/nextSessionTernSecure.ts
|
|
857
|
-
var import_cookie = require("@tern-secure/shared/cookie");
|
|
858
|
-
var import_errors7 = require("@tern-secure/shared/errors");
|
|
859
|
-
var import_headers = require("next/headers");
|
|
860
|
-
var SESSION_CONSTANTS = {
|
|
861
|
-
COOKIE_NAME: constants.Cookies.Session,
|
|
862
|
-
DEFAULT_EXPIRES_IN_MS: 60 * 60 * 24 * 5 * 1e3,
|
|
863
|
-
// 5 days
|
|
864
|
-
DEFAULT_EXPIRES_IN_SECONDS: 60 * 60 * 24 * 5,
|
|
865
|
-
REVOKE_REFRESH_TOKENS_ON_SIGNOUT: true
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
// src/tokens/ternSecureRequest.ts
|
|
869
|
-
var import_cookie2 = require("cookie");
|
|
870
|
-
|
|
871
|
-
// src/admin/user.ts
|
|
872
|
-
var import_errors8 = require("@tern-secure/shared/errors");
|
|
873
|
-
|
|
874
|
-
// src/app-check/serverAppCheck.ts
|
|
875
759
|
var ServerAppCheckManager = class _ServerAppCheckManager {
|
|
876
760
|
static instances = /* @__PURE__ */ new Map();
|
|
877
761
|
memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -902,10 +786,9 @@ var ServerAppCheckManager = class _ServerAppCheckManager {
|
|
|
902
786
|
url: config.url,
|
|
903
787
|
token: config.token
|
|
904
788
|
});
|
|
905
|
-
console.info("[AppCheck] Redis client initialized for token caching");
|
|
906
789
|
} catch (error) {
|
|
907
790
|
console.error("[AppCheck] Failed to initialize Redis client:", error);
|
|
908
|
-
throw new Error(
|
|
791
|
+
throw new Error("[AppCheck] Redis initialization failed.");
|
|
909
792
|
}
|
|
910
793
|
};
|
|
911
794
|
static getInstance(options) {
|
|
@@ -995,7 +878,9 @@ var ServerAppCheckManager = class _ServerAppCheckManager {
|
|
|
995
878
|
generateAndCacheToken = async (appId) => {
|
|
996
879
|
try {
|
|
997
880
|
const now = Date.now();
|
|
998
|
-
const
|
|
881
|
+
const config = initializeAdminConfig();
|
|
882
|
+
const appCheck = getAppCheck(config);
|
|
883
|
+
const appCheckToken = await appCheck.createToken(config.projectId, appId, {
|
|
999
884
|
ttlMillis: this.options.ttlMillis
|
|
1000
885
|
});
|
|
1001
886
|
const expiresAt = now + this.options.ttlMillis;
|