@tern-secure/backend 1.2.0-canary.v20251108045933 → 1.2.0-canary.v20251125170702

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.
@@ -1,11 +1,12 @@
1
- import { EmailApi, PasswordApi, SignInTokenApi, SignUpApi, TokenApi, UserData } from './endpoints';
1
+ import { 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
6
  email: EmailApi;
7
7
  password: PasswordApi;
8
- signIn: SignInTokenApi;
8
+ signIn: SignInApi;
9
+ signInToken: SignInTokenApi;
9
10
  signUp: SignUpApi;
10
11
  tokens: TokenApi;
11
12
  userData: UserData;
@@ -1 +1 @@
1
- {"version":3,"file":"createFireApi.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/createFireApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnG,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;;;;;;;EAU1D"}
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;AAC9G,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;;;;;;;;EAW1D"}
@@ -3,6 +3,7 @@ export declare const lookupEndpoint: (apiKey: string) => string;
3
3
  export declare const getRefreshTokenEndpoint: (apiKey: string) => string;
4
4
  export declare const signInWithPassword: (apiKey: string) => string;
5
5
  export declare const signUpEndpoint: (apiKey: string) => string;
6
+ export declare const sendOobCode: (apiKey: string) => string;
6
7
  export declare const getCustomTokenEndpoint: (apiKey: string) => string;
7
- export declare const passwordResetEndpoint: (apiKey: string) => string;
8
+ export declare const verifyPasswordResetCode: (apiKey: string) => string;
8
9
  //# sourceMappingURL=endpointUrl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpointUrl.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/endpointUrl.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,EAAE,SAAS,MAAM,WAElF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,WAE5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,WAErD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,WAEhD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,WAE5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,WAUpD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,WAEnD,CAAC"}
1
+ {"version":3,"file":"endpointUrl.d.ts","sourceRoot":"","sources":["../../src/fireRestApi/endpointUrl.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,EAAE,SAAS,MAAM,WAElF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,WAE5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,WAErD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,WAEhD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,WAE5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,WAEzC,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,WAUpD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,WAErD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ResetPasswordEmail } from '../resources/EmailAddress';
2
+ import { AbstractAPI } from './AbstractApi';
3
+ type ResetPasswordEmailParams = {
4
+ email: string;
5
+ requestType: 'PASSWORD_RESET';
6
+ };
7
+ export declare class SignInApi extends AbstractAPI {
8
+ resetPasswordEmail(apiKey: string, params: ResetPasswordEmailParams): Promise<ResetPasswordEmail>;
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=SignInApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignInApi.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/endpoints/SignInApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,wBAAwB,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,qBAAa,SAAU,SAAQ,WAAW;IACzB,kBAAkB,CAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,wBAAwB,GACjC,OAAO,CAAC,kBAAkB,CAAC;CAsBjC"}
@@ -1,5 +1,6 @@
1
1
  export * from './EmailApi';
2
2
  export * from './PasswordApi';
3
+ export * from './SignInApi';
3
4
  export * from './SignInTokenApi';
4
5
  export * from './SignUpApi';
5
6
  export * from './TokenApi';
@@ -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,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,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"}
@@ -0,0 +1,7 @@
1
+ import type { EmailAddressJson } from "./JSON";
2
+ export declare class ResetPasswordEmail {
3
+ readonly email: string;
4
+ constructor(email: string);
5
+ static fromJSON(data: EmailAddressJson): ResetPasswordEmail;
6
+ }
7
+ //# sourceMappingURL=EmailAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailAddress.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/resources/EmailAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C,qBAAa,kBAAkB;IACf,QAAQ,CAAC,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB;CAG9D"}
@@ -48,6 +48,10 @@ export interface IdAndRefreshTokenJSON {
48
48
  idToken: string;
49
49
  refreshToken: string;
50
50
  }
51
+ export interface EmailAddressJson {
52
+ object: typeof ObjectType.EmailAddress;
53
+ email: string;
54
+ }
51
55
  export interface UserJson {
52
56
  object: typeof ObjectType.User;
53
57
  localId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"JSON.d.ts","sourceRoot":"","sources":["../../../src/fireRestApi/resources/JSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAuBb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAGtE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,UAAU,CAAC,OAAO,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,UAAU,CAAC,kBAAkB,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC/B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,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,UAAU,CAAC,kBAAkB,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,UAAU,CAAC,YAAY,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
package/dist/index.js CHANGED
@@ -424,6 +424,30 @@ var PasswordApi = class extends AbstractAPI {
424
424
  }
425
425
  };
426
426
 
427
+ // src/fireRestApi/endpoints/SignInApi.ts
428
+ var SignInApi = class extends AbstractAPI {
429
+ async resetPasswordEmail(apiKey, params) {
430
+ try {
431
+ this.requireApiKey(apiKey);
432
+ const { ...restParams } = params;
433
+ const response = await this.request({
434
+ endpoint: "sendOobCode",
435
+ method: "POST",
436
+ apiKey,
437
+ bodyParams: restParams
438
+ });
439
+ if (response.errors) {
440
+ const errorMessage = response.errors[0]?.message || "Failed to send reset password email";
441
+ throw new Error(errorMessage);
442
+ }
443
+ return response.data;
444
+ } catch (error) {
445
+ const contextualMessage = `Failed to send reset password email: ${error instanceof Error ? error.message : "Unknown error"}`;
446
+ throw new Error(contextualMessage);
447
+ }
448
+ }
449
+ };
450
+
427
451
  // src/fireRestApi/endpoints/SignInTokenApi.ts
428
452
  var SignInTokenApi = class extends AbstractAPI {
429
453
  async createCustomToken(apiKey, params) {
@@ -556,6 +580,9 @@ var signInWithPassword = (apiKey) => {
556
580
  var signUpEndpoint = (apiKey) => {
557
581
  return `https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${apiKey}`;
558
582
  };
583
+ var sendOobCode = (apiKey) => {
584
+ return `https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${apiKey}`;
585
+ };
559
586
  var getCustomTokenEndpoint = (apiKey) => {
560
587
  if (useEmulator() && FIREBASE_AUTH_EMULATOR_HOST) {
561
588
  let protocol = "http://";
@@ -566,9 +593,6 @@ var getCustomTokenEndpoint = (apiKey) => {
566
593
  }
567
594
  return `https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${apiKey}`;
568
595
  };
569
- var passwordResetEndpoint = (apiKey) => {
570
- return `https://identitytoolkit.googleapis.com/v1/accounts:resetPassword?key=${apiKey}`;
571
- };
572
596
 
573
597
  // src/fireRestApi/request.ts
574
598
  var FIREBASE_ENDPOINT_MAP = {
@@ -576,8 +600,8 @@ var FIREBASE_ENDPOINT_MAP = {
576
600
  signInWithPassword,
577
601
  signUp: signUpEndpoint,
578
602
  signInWithCustomToken: getCustomTokenEndpoint,
579
- passwordReset: passwordResetEndpoint,
580
- sendOobCode: signInWithPassword,
603
+ passwordReset: sendOobCode,
604
+ sendOobCode,
581
605
  lookup: lookupEndpoint
582
606
  };
583
607
  function createRequest(options) {
@@ -710,7 +734,8 @@ function createFireApi(options) {
710
734
  return {
711
735
  email: new EmailApi(request),
712
736
  password: new PasswordApi(request),
713
- signIn: new SignInTokenApi(request),
737
+ signIn: new SignInApi(request),
738
+ signInToken: new SignInTokenApi(request),
714
739
  signUp: new SignUpApi(request),
715
740
  tokens: new TokenApi(request),
716
741
  userData: new UserData(request)
@@ -1458,7 +1483,6 @@ async function authenticateRequest(request, options) {
1458
1483
  const REAUTH_PERIOD_SECONDS = context.session?.maxAge ? convertToSeconds(context.session.maxAge) : defaultMaxAgeSeconds;
1459
1484
  const currentTime = Math.floor(Date.now() / 1e3);
1460
1485
  const authAge = currentTime - authTimeValue;
1461
- console.log("Current time:", currentTime, "Auth age:", authAge, "Reauth period (s):", REAUTH_PERIOD_SECONDS);
1462
1486
  if (authTimeValue > 0 && authAge > REAUTH_PERIOD_SECONDS) {
1463
1487
  return signedOut(context, AuthErrorReason.AuthTimeout, "Authentication expired");
1464
1488
  }