firebase-login-custom 0.3.0 → 0.4.0
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +62 -0
- package/README.md +1 -61
- package/dist/firebase-login-custom.d.ts +18 -2
- package/dist/firebase-login-custom.js +1 -1
- package/dist/firebase-login-custom.js.map +1 -1
- package/dist/firebase-login-custom.mjs +35 -28
- package/dist/firebase-login-custom.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0](https://github.com/vergissberlin/firebase-login-custom/compare/v0.3.0...v0.4.0) (2026-03-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **tests:** enhance FirebaseLoginCustom tests for validation and token generation errors ([28fe0b6](https://github.com/vergissberlin/firebase-login-custom/commit/28fe0b678e1001844f73fb6c7d6da2b1b07328ca))
|
|
9
|
+
|
|
3
10
|
## [0.3.0](https://github.com/vergissberlin/firebase-login-custom/compare/v0.2.0...v0.3.0) (2026-03-17)
|
|
4
11
|
|
|
5
12
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -6,3 +6,65 @@
|
|
|
6
6
|
4. Finish your implementation (`git flow feature finish my-new-feature`)
|
|
7
7
|
5. Push to origin (`git push origin`)
|
|
8
8
|
6. Create new Pull Request
|
|
9
|
+
|
|
10
|
+
## Install locally and test
|
|
11
|
+
|
|
12
|
+
Tests use a **Firebase mock** by default (no credentials needed). With env vars set, they use real Firebase.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
cd /path/to/firebase-login-custom
|
|
16
|
+
pnpm install
|
|
17
|
+
pnpm run build
|
|
18
|
+
pnpm test
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- **Unit tests** (Vitest): `pnpm run test:unit` (no build required). Watch mode: `pnpm run test:watch`.
|
|
22
|
+
- **Integration tests**: `pnpm run test:integration` (builds first if needed). `pnpm test` runs unit then integration.
|
|
23
|
+
|
|
24
|
+
**Pre-commit hooks (Husky):** Before each commit, `pnpm run lint` and `pnpm run test` run automatically. If either fails, the commit is aborted. Hooks are installed when you run `pnpm install` (via the `prepare` script).
|
|
25
|
+
|
|
26
|
+
To run against real Firebase:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
export FIREBASE_ID=<YOUR_TEST_ID>
|
|
30
|
+
export FIREBASE_UID=<YOUR_USER_ID>
|
|
31
|
+
export FIREBASE_SECRET=<YOUR_SECRET>
|
|
32
|
+
pnpm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For CI, optional: set repository secrets `FIREBASE_ID`, `FIREBASE_UID`, and `FIREBASE_SECRET` to run integration tests against real Firebase on push/PR.
|
|
36
|
+
|
|
37
|
+
## Releasing
|
|
38
|
+
|
|
39
|
+
Releases are automated via GitHub Actions and [Release Please](https://github.com/googleapis/release-please).
|
|
40
|
+
|
|
41
|
+
- **Release Please** (workflow `release-please`): On every push to `main`, it opens or updates a release PR based on [Conventional Commits](https://www.conventionalcommits.org/). Merge that PR; Release Please then creates the version tag and GitHub Release.
|
|
42
|
+
- **Release** (workflow `Release`): Triggered when a GitHub Release is published (e.g. by Release Please), when a version tag (`v*`) is pushed, or **manually**. It builds, **publishes to npm** (requires `NPM_TOKEN` secret), and creates/updates the GitHub Release when triggered by a tag push.
|
|
43
|
+
|
|
44
|
+
### First-time publish (Release workflow never ran)
|
|
45
|
+
|
|
46
|
+
If the Release workflow has never run and nothing is on [npm](https://www.npmjs.com/package/firebase-login-custom) yet:
|
|
47
|
+
|
|
48
|
+
1. **Add `NPM_TOKEN`** (Settings → Secrets and variables → Actions): Create an npm [Access Token](https://www.npmjs.com/settings/~youruser/tokens) with **Automation** or **Publish** scope and add it as repository secret `NPM_TOKEN`.
|
|
49
|
+
2. **Run the Release workflow once**: In the repo go to **Actions → Release → Run workflow** (use "Run workflow" on the default branch). This publishes the current `package.json` version to npm. No GitHub Release is created when run manually.
|
|
50
|
+
3. After that, use either Release Please (conventional commits + merge release PR) or manual tag push (`git tag v0.1.0 && git push origin v0.1.0`) so future releases also trigger the workflow automatically.
|
|
51
|
+
|
|
52
|
+
### Regular releases
|
|
53
|
+
|
|
54
|
+
1. **Secrets** (Settings → Secrets and variables → Actions):
|
|
55
|
+
- **NPM_TOKEN** (required): npm auth token with publish permission. Create at [npmjs.com → Access Tokens](https://www.npmjs.com/settings/~youruser/tokens) (Automation or Publish).
|
|
56
|
+
- **GH_PAT** (optional): GitHub Personal Access Token with `repo` scope. Only needed if the default `GITHUB_TOKEN` cannot create releases (e.g. in some org settings). If you use it, set the Release workflow's "Create GitHub Release" step to `GITHUB_TOKEN: ${{ secrets.GH_PAT }}`.
|
|
57
|
+
|
|
58
|
+
2. **Version and tag (with Release Please)**: Use conventional commits (e.g. `feat:`, `fix:`, `chore:`). After pushing to `main`, Release Please will open or update a release PR. Merge that PR; Release Please creates the tag and GitHub Release. The Release workflow runs on **release published** (and on tag push), so it will build and publish to npm—ensure **NPM_TOKEN** is set in repository secrets.
|
|
59
|
+
|
|
60
|
+
**Without Release Please** (manual): Bump version in `package.json`, commit, push a version tag:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm version patch # or minor / major
|
|
64
|
+
git push origin main
|
|
65
|
+
git push origin v0.0.4 # use the new version number
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Pushing a tag `v*` triggers the Release workflow.
|
|
69
|
+
|
|
70
|
+
3. **Manual run**: You can also trigger the Release workflow manually (Actions → Release → Run workflow). It will publish the current version from `package.json` to npm; no GitHub Release is created unless a tag is pushed.
|
package/README.md
CHANGED
|
@@ -60,67 +60,7 @@ FirebaseLoginCustom(firebaseRef, {
|
|
|
60
60
|
## Issues
|
|
61
61
|
|
|
62
62
|
Please report issues to [ticket system](https://github.com/vergissberlin/firebase-login-custom/issues).
|
|
63
|
-
Pull requests are welcome here! See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute.
|
|
64
|
-
|
|
65
|
-
## Install locally
|
|
66
|
-
|
|
67
|
-
Tests use a **Firebase mock** by default (no credentials needed). With env vars set, they use real Firebase.
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
cd /path/to/firebase-login-custom
|
|
71
|
-
pnpm install
|
|
72
|
-
pnpm run build
|
|
73
|
-
pnpm test
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
- **Unit tests** (Vitest): `pnpm run test:unit` (no build required). Watch mode: `pnpm run test:watch`.
|
|
77
|
-
- **Integration tests**: `pnpm run test:integration` (builds first if needed). `pnpm test` runs unit then integration.
|
|
78
|
-
|
|
79
|
-
**Pre-commit hooks (Husky):** Before each commit, `pnpm run lint` and `pnpm run test` run automatically. If either fails, the commit is aborted. Hooks are installed when you run `pnpm install` (via the `prepare` script).
|
|
80
|
-
|
|
81
|
-
To run against real Firebase:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
export FIREBASE_ID=<YOUR_TEST_ID>
|
|
85
|
-
export FIREBASE_UID=<YOUR_USER_ID>
|
|
86
|
-
export FIREBASE_SECRET=<YOUR_SECRET>
|
|
87
|
-
pnpm test
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
For CI, optional: set repository secrets `FIREBASE_ID`, `FIREBASE_UID`, and `FIREBASE_SECRET` to run integration tests against real Firebase on push/PR.
|
|
91
|
-
|
|
92
|
-
## Releasing
|
|
93
|
-
|
|
94
|
-
Releases are automated via GitHub Actions and [Release Please](https://github.com/googleapis/release-please).
|
|
95
|
-
|
|
96
|
-
- **Release Please** (workflow `release-please`): On every push to `main`, it opens or updates a release PR based on [Conventional Commits](https://www.conventionalcommits.org/). Merge that PR; Release Please then creates the version tag and GitHub Release.
|
|
97
|
-
- **Release** (workflow `Release`): Triggered when a GitHub Release is published (e.g. by Release Please), when a version tag (`v*`) is pushed, or **manually**. It builds, **publishes to npm** (requires `NPM_TOKEN` secret), and creates/updates the GitHub Release when triggered by a tag push.
|
|
98
|
-
|
|
99
|
-
### First-time publish (Release workflow never ran)
|
|
100
|
-
|
|
101
|
-
If the Release workflow has never run and nothing is on [npm](https://www.npmjs.com/package/firebase-login-custom) yet:
|
|
102
|
-
|
|
103
|
-
1. **Add `NPM_TOKEN`** (Settings → Secrets and variables → Actions): Create an npm [Access Token](https://www.npmjs.com/settings/~youruser/tokens) with **Automation** or **Publish** scope and add it as repository secret `NPM_TOKEN`.
|
|
104
|
-
2. **Run the Release workflow once**: In the repo go to **Actions → Release → Run workflow** (use “Run workflow” on the default branch). This publishes the current `package.json` version to npm. No GitHub Release is created when run manually.
|
|
105
|
-
3. After that, use either Release Please (conventional commits + merge release PR) or manual tag push (`git tag v0.1.0 && git push origin v0.1.0`) so future releases also trigger the workflow automatically.
|
|
106
|
-
|
|
107
|
-
### Regular releases
|
|
108
|
-
|
|
109
|
-
1. **Secrets** (Settings → Secrets and variables → Actions):
|
|
110
|
-
- **NPM_TOKEN** (required): npm auth token with publish permission. Create at [npmjs.com → Access Tokens](https://www.npmjs.com/settings/~youruser/tokens) (Automation or Publish).
|
|
111
|
-
- **GH_PAT** (optional): GitHub Personal Access Token with `repo` scope. Only needed if the default `GITHUB_TOKEN` cannot create releases (e.g. in some org settings). If you use it, set the Release workflow's "Create GitHub Release" step to `GITHUB_TOKEN: ${{ secrets.GH_PAT }}`.
|
|
112
|
-
|
|
113
|
-
2. **Version and tag (with Release Please)**: Use conventional commits (e.g. `feat:`, `fix:`, `chore:`). After pushing to `main`, Release Please will open or update a release PR. Merge that PR; Release Please creates the tag and GitHub Release. The Release workflow runs on **release published** (and on tag push), so it will build and publish to npm—ensure **NPM_TOKEN** is set in repository secrets.
|
|
114
|
-
|
|
115
|
-
**Without Release Please** (manual): Bump version in `package.json`, commit, push a version tag:
|
|
116
|
-
```bash
|
|
117
|
-
pnpm version patch # or minor / major
|
|
118
|
-
git push origin main
|
|
119
|
-
git push origin v0.0.4 # use the new version number
|
|
120
|
-
```
|
|
121
|
-
Pushing a tag `v*` triggers the Release workflow.
|
|
122
|
-
|
|
123
|
-
3. **Manual run**: You can also trigger the Release workflow manually (Actions → Release → Run workflow). It will publish the current version from `package.json` to npm; no GitHub Release is created unless a tag is pushed.
|
|
63
|
+
Pull requests are welcome here! See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute (install locally, test, and releasing).
|
|
124
64
|
|
|
125
65
|
## Thanks to {#thanks}
|
|
126
66
|
|
|
@@ -50,16 +50,32 @@ export interface FirebaseLoginOption {
|
|
|
50
50
|
secret: string;
|
|
51
51
|
}
|
|
52
52
|
/** Option type for inputs where secret is not yet validated */
|
|
53
|
-
type FirebaseLoginOptionInput = Omit<FirebaseLoginOption, 'secret'> & {
|
|
53
|
+
export type FirebaseLoginOptionInput = Omit<FirebaseLoginOption, 'secret'> & {
|
|
54
54
|
secret?: string;
|
|
55
55
|
};
|
|
56
56
|
export type FirebaseLoginCallback = (error: Error | string | null, authData?: unknown) => void;
|
|
57
57
|
export interface FirebaseRef {
|
|
58
58
|
authWithCustomToken: (token: string, callback: FirebaseLoginCallback) => void;
|
|
59
59
|
}
|
|
60
|
+
/** Shape of auth errors passed to the callback by Firebase (with optional code). */
|
|
61
|
+
export interface FirebaseAuthError extends Error {
|
|
62
|
+
code?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Custom login helper: generates a Firebase custom token and authenticates via the given ref.
|
|
66
|
+
* Validation errors throw synchronously; token or auth failures are reported to the callback.
|
|
67
|
+
*/
|
|
60
68
|
export declare class FirebaseLoginCustom {
|
|
69
|
+
/**
|
|
70
|
+
* @param ref - Firebase ref with `authWithCustomToken(token, callback)`
|
|
71
|
+
* @param data - Auth payload; must include `uid` (string)
|
|
72
|
+
* @param option - Options; must include `secret`. Optional: admin, debug, expires, notBefore
|
|
73
|
+
* @param callback - Called with (error, authData) when auth completes or token generation fails
|
|
74
|
+
*/
|
|
61
75
|
constructor(ref: FirebaseRef, data?: AuthData, option?: FirebaseLoginOptionInput, callback?: FirebaseLoginCallback);
|
|
62
76
|
}
|
|
63
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Callable form: same as `new FirebaseLoginCustom(...)`. Use without `new` for backward compatibility.
|
|
79
|
+
*/
|
|
64
80
|
declare function firebaseLoginCustom(ref: FirebaseRef, data?: AuthData, option?: FirebaseLoginOptionInput, callback?: FirebaseLoginCallback): void;
|
|
65
81
|
export default firebaseLoginCustom;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`firebase-token-generator`);c=s(c);var l=`FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR`,u=`FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR`,d=class e extends Error{constructor(t){super(t),this.code=l,this.name=`FirebaseLoginCustomValidationError`,Object.setPrototypeOf(this,e.prototype)}},f=class e extends Error{constructor(t,n){super(t),this.code=u,this.name=`FirebaseLoginCustomTokenError`,this.cause=n,Object.setPrototypeOf(this,e.prototype)}},p={admin:!1,expires:0,
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`firebase-token-generator`);c=s(c);var l=`FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR`,u=`FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR`,d=class e extends Error{constructor(t){super(t),this.code=l,this.name=`FirebaseLoginCustomValidationError`,Object.setPrototypeOf(this,e.prototype)}},f=class e extends Error{constructor(t,n){super(t),this.code=u,this.name=`FirebaseLoginCustomTokenError`,this.cause=n,Object.setPrototypeOf(this,e.prototype)}},p={admin:!1,debug:!1,expires:0,notBefore:0},m=86400,h={INVALID_EMAIL:`The specified user account email is invalid.`,INVALID_PASSWORD:`The specified user account password is incorrect.`,INVALID_USER:`The specified user account does not exist.`};function g(e){let t=Date.now()/1e3;return{admin:typeof e.admin==`boolean`?e.admin:p.admin,debug:typeof e.debug==`boolean`?e.debug:p.debug,expires:typeof e.expires==`number`?e.expires:t+m,notBefore:typeof e.notBefore==`number`?e.notBefore:t,secret:e.secret}}var _=class{constructor(e,t={uid:``},n={...p},r=()=>{}){if(typeof e!=`object`||!e)throw new d(`Ref must be an object!`);if(typeof t.uid!=`string`)throw new d(`Data object must have a "uid" field!`);if(typeof n.secret!=`string`)throw new d(`Option object must have a "secret" field!`);if(typeof r!=`function`)throw new d(`Callback must be a function!`);let i=g(n),a;try{a=new c.default(i.secret).createToken(t,{admin:i.admin,debug:i.debug,expires:i.expires,notBefore:i.notBefore})}catch(e){let t=e instanceof Error?new f(`Token generation failed: `+e.message,e):new f(`Token generation failed: `+String(e),e);process.nextTick(()=>r(t,void 0));return}e.authWithCustomToken(a,(e,t)=>{let n=null;if(e){let t=e,r=t?.code===void 0?void 0:h[t.code];n=r===void 0?`Error logging user in: `+String(e):r}r(n,t)})}};function v(e,t,n,r){new _(e,t??{uid:``},n??{...p},r??(()=>{}))}exports.FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR=u,exports.FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR=l,exports.FirebaseLoginCustom=_,exports.FirebaseLoginCustomTokenError=f,exports.FirebaseLoginCustomValidationError=d,exports.default=v;
|
|
2
2
|
//# sourceMappingURL=firebase-login-custom.js.map
|
|
3
3
|
if (typeof module !== 'undefined' && module.exports) { var _def = module.exports.default, _cls = module.exports.FirebaseLoginCustom; module.exports = _def; if (_def) { _def.default = _def; if (_cls !== undefined) _def.FirebaseLoginCustom = _cls; } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-login-custom.js","names":[],"sources":["../src/firebase-login-custom.ts"],"sourcesContent":["/**\n * FirebaseLoginCustom\n *\n * Authenticating Users with Custom login\n * Firebase makes it easy to integrate email and password authentication\n * into your app. Firebase automatically stores your users' credentials\n * securely (using bcrypt) and redundantly (daily off-site backups).\n * This separates sensitive user credentials from your application data,\n * and lets you focus on the user interface and experience for your app.\n *\n * @author André Lademann <vergissberlin@googlemail.com>\n * @link https://www.firebase.com/docs/web/guide/login/password.html\n * @param ref Firebase object reference\n * @param data Authentication object with uid and secret\n * @param option Option object with admin, debug and expire settings\n * @param callback Callback function\n * @return FirebaseLoginCustom\n */\n\nimport FirebaseTokenGenerator from 'firebase-token-generator';\n\n/** Error code for validation failures (invalid ref, data, option, or callback). */\nexport const FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR = 'FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR';\n\n/** Error code for token generation failures (e.g. invalid claims or secret). */\nexport const FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR = 'FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR';\n\n/**\n * Thrown when constructor arguments are invalid (ref, data, option, or callback).\n * Consumers can use `error.code === FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR` or\n * `error instanceof FirebaseLoginCustomValidationError`.\n */\nexport class FirebaseLoginCustomValidationError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR;\n\n constructor(message: string) {\n super(message);\n this.name = 'FirebaseLoginCustomValidationError';\n Object.setPrototypeOf(this, FirebaseLoginCustomValidationError.prototype);\n }\n}\n\n/**\n * Thrown when token generation fails (e.g. invalid secret or claims).\n * Passed to the callback when createToken throws; not thrown from the constructor.\n */\nexport class FirebaseLoginCustomTokenError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR;\n readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'FirebaseLoginCustomTokenError';\n this.cause = cause;\n Object.setPrototypeOf(this, FirebaseLoginCustomTokenError.prototype);\n }\n}\n\nexport interface AuthData {\n uid: string;\n [key: string]: unknown;\n}\n\nexport interface FirebaseLoginOption {\n admin?: boolean;\n debug?: boolean;\n expires?: number;\n notBefore?: number;\n secret: string;\n}\n\n/** Option type for inputs where secret is not yet validated */\
|
|
1
|
+
{"version":3,"file":"firebase-login-custom.js","names":[],"sources":["../src/firebase-login-custom.ts"],"sourcesContent":["/**\n * FirebaseLoginCustom\n *\n * Authenticating Users with Custom login\n * Firebase makes it easy to integrate email and password authentication\n * into your app. Firebase automatically stores your users' credentials\n * securely (using bcrypt) and redundantly (daily off-site backups).\n * This separates sensitive user credentials from your application data,\n * and lets you focus on the user interface and experience for your app.\n *\n * @author André Lademann <vergissberlin@googlemail.com>\n * @link https://www.firebase.com/docs/web/guide/login/password.html\n * @param ref Firebase object reference\n * @param data Authentication object with uid and secret\n * @param option Option object with admin, debug and expire settings\n * @param callback Callback function\n * @return FirebaseLoginCustom\n */\n\nimport FirebaseTokenGenerator from 'firebase-token-generator';\n\n/** Error code for validation failures (invalid ref, data, option, or callback). */\nexport const FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR = 'FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR';\n\n/** Error code for token generation failures (e.g. invalid claims or secret). */\nexport const FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR = 'FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR';\n\n/**\n * Thrown when constructor arguments are invalid (ref, data, option, or callback).\n * Consumers can use `error.code === FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR` or\n * `error instanceof FirebaseLoginCustomValidationError`.\n */\nexport class FirebaseLoginCustomValidationError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR;\n\n constructor(message: string) {\n super(message);\n this.name = 'FirebaseLoginCustomValidationError';\n Object.setPrototypeOf(this, FirebaseLoginCustomValidationError.prototype);\n }\n}\n\n/**\n * Thrown when token generation fails (e.g. invalid secret or claims).\n * Passed to the callback when createToken throws; not thrown from the constructor.\n */\nexport class FirebaseLoginCustomTokenError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR;\n readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'FirebaseLoginCustomTokenError';\n this.cause = cause;\n Object.setPrototypeOf(this, FirebaseLoginCustomTokenError.prototype);\n }\n}\n\nexport interface AuthData {\n uid: string;\n [key: string]: unknown;\n}\n\nexport interface FirebaseLoginOption {\n admin?: boolean;\n debug?: boolean;\n expires?: number;\n notBefore?: number;\n secret: string;\n}\n\n/** Option type for inputs where secret is not yet validated */\nexport type FirebaseLoginOptionInput = Omit<FirebaseLoginOption, 'secret'> & {\n secret?: string;\n};\n\nexport type FirebaseLoginCallback = (\n error: Error | string | null,\n authData?: unknown\n) => void;\n\nexport interface FirebaseRef {\n authWithCustomToken: (\n token: string,\n callback: FirebaseLoginCallback\n ) => void;\n}\n\n/** Shape of auth errors passed to the callback by Firebase (with optional code). */\nexport interface FirebaseAuthError extends Error {\n code?: string;\n}\n\nconst DEFAULT_OPTION: Required<Omit<FirebaseLoginOption, 'secret'>> & {\n secret?: string;\n} = {\n admin: false,\n debug: false,\n expires: 0,\n notBefore: 0,\n};\n\nconst SECONDS_PER_DAY = 86400;\n\n/** User-facing messages for known Firebase auth error codes */\nconst AUTH_ERROR_MESSAGES: Record<string, string> = {\n INVALID_EMAIL: 'The specified user account email is invalid.',\n INVALID_PASSWORD: 'The specified user account password is incorrect.',\n INVALID_USER: 'The specified user account does not exist.',\n};\n\nfunction resolveOption(\n input: FirebaseLoginOptionInput\n): Required<Omit<FirebaseLoginOption, 'secret'>> & { secret: string } {\n const now = Date.now() / 1000;\n return {\n admin: typeof input.admin === 'boolean' ? input.admin : DEFAULT_OPTION.admin,\n debug: typeof input.debug === 'boolean' ? input.debug : DEFAULT_OPTION.debug,\n expires: typeof input.expires === 'number' ? input.expires : now + SECONDS_PER_DAY,\n notBefore: typeof input.notBefore === 'number' ? input.notBefore : now,\n secret: input.secret as string,\n };\n}\n\n/**\n * Custom login helper: generates a Firebase custom token and authenticates via the given ref.\n * Validation errors throw synchronously; token or auth failures are reported to the callback.\n */\nexport class FirebaseLoginCustom {\n /**\n * @param ref - Firebase ref with `authWithCustomToken(token, callback)`\n * @param data - Auth payload; must include `uid` (string)\n * @param option - Options; must include `secret`. Optional: admin, debug, expires, notBefore\n * @param callback - Called with (error, authData) when auth completes or token generation fails\n */\n constructor(\n ref: FirebaseRef,\n data: AuthData = { uid: '' },\n option: FirebaseLoginOptionInput = { ...DEFAULT_OPTION },\n callback: FirebaseLoginCallback = () => {}\n ) {\n if (ref == null || typeof ref !== 'object') {\n throw new FirebaseLoginCustomValidationError('Ref must be an object!');\n }\n if (typeof data.uid !== 'string') {\n throw new FirebaseLoginCustomValidationError('Data object must have a \"uid\" field!');\n }\n if (typeof option.secret !== 'string') {\n throw new FirebaseLoginCustomValidationError('Option object must have a \"secret\" field!');\n }\n if (typeof callback !== 'function') {\n throw new FirebaseLoginCustomValidationError('Callback must be a function!');\n }\n\n const resolvedOption = resolveOption(option);\n\n let authToken: string;\n try {\n const tokenGenerator = new FirebaseTokenGenerator(resolvedOption.secret);\n authToken = tokenGenerator.createToken(data, {\n admin: resolvedOption.admin,\n debug: resolvedOption.debug,\n expires: resolvedOption.expires,\n notBefore: resolvedOption.notBefore,\n });\n } catch (err) {\n const callbackError =\n err instanceof Error\n ? new FirebaseLoginCustomTokenError('Token generation failed: ' + err.message, err)\n : new FirebaseLoginCustomTokenError('Token generation failed: ' + String(err), err);\n process.nextTick(() => callback(callbackError, undefined));\n return;\n }\n\n ref.authWithCustomToken(authToken, (error, authData) => {\n let callbackError: Error | string | null = null;\n if (error) {\n const authErr = error as FirebaseAuthError;\n const knownMessage =\n authErr?.code !== undefined ? AUTH_ERROR_MESSAGES[authErr.code] : undefined;\n callbackError =\n knownMessage !== undefined ? knownMessage : 'Error logging user in: ' + String(error);\n }\n callback(callbackError, authData);\n });\n }\n}\n\n/**\n * Callable form: same as `new FirebaseLoginCustom(...)`. Use without `new` for backward compatibility.\n */\nfunction firebaseLoginCustom(\n ref: FirebaseRef,\n data?: AuthData,\n option?: FirebaseLoginOptionInput,\n callback?: FirebaseLoginCallback\n): void {\n new FirebaseLoginCustom(\n ref,\n data ?? { uid: '' },\n option ?? { ...DEFAULT_OPTION },\n callback ?? (() => {})\n );\n}\n\nexport default firebaseLoginCustom;\n"],"mappings":"8mBAsBA,IAAa,EAAyC,yCAGzC,EAAoC,oCAOpC,EAAb,MAAa,UAA2C,KAAM,CAG5D,YAAY,EAAiB,CAC3B,MAAM,EAAQ,WAHA,EAId,KAAK,KAAO,qCACZ,OAAO,eAAe,KAAM,EAAmC,UAAU,GAQhE,EAAb,MAAa,UAAsC,KAAM,CAIvD,YAAY,EAAiB,EAAiB,CAC5C,MAAM,EAAQ,WAJA,EAKd,KAAK,KAAO,gCACZ,KAAK,MAAQ,EACb,OAAO,eAAe,KAAM,EAA8B,UAAU,GAuClE,EAEF,CACF,MAAO,GACP,MAAO,GACP,QAAS,EACT,UAAW,EACZ,CAEK,EAAkB,MAGlB,EAA8C,CAClD,cAAe,+CACf,iBAAkB,oDAClB,aAAc,6CACf,CAED,SAAS,EACP,EACoE,CACpE,IAAM,EAAM,KAAK,KAAK,CAAG,IACzB,MAAO,CACL,MAAO,OAAO,EAAM,OAAU,UAAY,EAAM,MAAQ,EAAe,MACvE,MAAO,OAAO,EAAM,OAAU,UAAY,EAAM,MAAQ,EAAe,MACvE,QAAS,OAAO,EAAM,SAAY,SAAW,EAAM,QAAU,EAAM,EACnE,UAAW,OAAO,EAAM,WAAc,SAAW,EAAM,UAAY,EACnE,OAAQ,EAAM,OACf,CAOH,IAAa,EAAb,KAAiC,CAO/B,YACE,EACA,EAAiB,CAAE,IAAK,GAAI,CAC5B,EAAmC,CAAE,GAAG,EAAgB,CACxD,MAAwC,GACxC,CACA,GAAmB,OAAO,GAAQ,WAA9B,EACF,MAAM,IAAI,EAAmC,yBAAyB,CAExE,GAAI,OAAO,EAAK,KAAQ,SACtB,MAAM,IAAI,EAAmC,uCAAuC,CAEtF,GAAI,OAAO,EAAO,QAAW,SAC3B,MAAM,IAAI,EAAmC,4CAA4C,CAE3F,GAAI,OAAO,GAAa,WACtB,MAAM,IAAI,EAAmC,+BAA+B,CAG9E,IAAM,EAAiB,EAAc,EAAO,CAExC,EACJ,GAAI,CAEF,EADuB,IAAI,EAAA,QAAuB,EAAe,OAAO,CAC7C,YAAY,EAAM,CAC3C,MAAO,EAAe,MACtB,MAAO,EAAe,MACtB,QAAS,EAAe,QACxB,UAAW,EAAe,UAC3B,CAAC,OACK,EAAK,CACZ,IAAM,EACJ,aAAe,MACX,IAAI,EAA8B,4BAA8B,EAAI,QAAS,EAAI,CACjF,IAAI,EAA8B,4BAA8B,OAAO,EAAI,CAAE,EAAI,CACvF,QAAQ,aAAe,EAAS,EAAe,IAAA,GAAU,CAAC,CAC1D,OAGF,EAAI,oBAAoB,GAAY,EAAO,IAAa,CACtD,IAAI,EAAuC,KAC3C,GAAI,EAAO,CACT,IAAM,EAAU,EACV,EACJ,GAAS,OAAS,IAAA,GAAgD,IAAA,GAApC,EAAoB,EAAQ,MAC5D,EACE,IAAiB,IAAA,GAA2B,0BAA4B,OAAO,EAAM,CAAxD,EAEjC,EAAS,EAAe,EAAS,EACjC,GAON,SAAS,EACP,EACA,EACA,EACA,EACM,CACN,IAAI,EACF,EACA,GAAQ,CAAE,IAAK,GAAI,CACnB,GAAU,CAAE,GAAG,EAAgB,CAC/B,QAAmB,IACpB"}
|
|
@@ -10,50 +10,57 @@ var t = "FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR", n = "FIREBASE_LOGIN_CUSTOM_TOK
|
|
|
10
10
|
}
|
|
11
11
|
}, a = {
|
|
12
12
|
admin: !1,
|
|
13
|
-
expires: 0,
|
|
14
13
|
debug: !1,
|
|
14
|
+
expires: 0,
|
|
15
15
|
notBefore: 0
|
|
16
|
-
}, o =
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
}, o = 86400, s = {
|
|
17
|
+
INVALID_EMAIL: "The specified user account email is invalid.",
|
|
18
|
+
INVALID_PASSWORD: "The specified user account password is incorrect.",
|
|
19
|
+
INVALID_USER: "The specified user account does not exist."
|
|
20
|
+
};
|
|
21
|
+
function c(e) {
|
|
22
|
+
let t = Date.now() / 1e3;
|
|
23
|
+
return {
|
|
24
|
+
admin: typeof e.admin == "boolean" ? e.admin : a.admin,
|
|
25
|
+
debug: typeof e.debug == "boolean" ? e.debug : a.debug,
|
|
26
|
+
expires: typeof e.expires == "number" ? e.expires : t + o,
|
|
27
|
+
notBefore: typeof e.notBefore == "number" ? e.notBefore : t,
|
|
28
|
+
secret: e.secret
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var l = class {
|
|
32
|
+
constructor(t, n = { uid: "" }, o = { ...a }, l = () => {}) {
|
|
33
|
+
if (typeof t != "object" || !t) throw new r("Ref must be an object!");
|
|
19
34
|
if (typeof n.uid != "string") throw new r("Data object must have a \"uid\" field!");
|
|
20
35
|
if (typeof o.secret != "string") throw new r("Option object must have a \"secret\" field!");
|
|
21
|
-
if (typeof
|
|
22
|
-
let c;
|
|
36
|
+
if (typeof l != "function") throw new r("Callback must be a function!");
|
|
37
|
+
let u = c(o), d;
|
|
23
38
|
try {
|
|
24
|
-
|
|
25
|
-
admin:
|
|
26
|
-
debug:
|
|
27
|
-
expires:
|
|
28
|
-
notBefore:
|
|
39
|
+
d = new e(u.secret).createToken(n, {
|
|
40
|
+
admin: u.admin,
|
|
41
|
+
debug: u.debug,
|
|
42
|
+
expires: u.expires,
|
|
43
|
+
notBefore: u.notBefore
|
|
29
44
|
});
|
|
30
45
|
} catch (e) {
|
|
31
46
|
let t = e instanceof Error ? new i("Token generation failed: " + e.message, e) : new i("Token generation failed: " + String(e), e);
|
|
32
|
-
process.nextTick(() =>
|
|
47
|
+
process.nextTick(() => l(t, void 0));
|
|
33
48
|
return;
|
|
34
49
|
}
|
|
35
|
-
t.authWithCustomToken(
|
|
50
|
+
t.authWithCustomToken(d, (e, t) => {
|
|
36
51
|
let n = null;
|
|
37
|
-
if (e)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
break;
|
|
41
|
-
case "INVALID_PASSWORD":
|
|
42
|
-
n = "The specified user account password is incorrect.";
|
|
43
|
-
break;
|
|
44
|
-
case "INVALID_USER":
|
|
45
|
-
n = "The specified user account does not exist.";
|
|
46
|
-
break;
|
|
47
|
-
default: n = "Error logging user in: " + String(e);
|
|
52
|
+
if (e) {
|
|
53
|
+
let t = e, r = t?.code === void 0 ? void 0 : s[t.code];
|
|
54
|
+
n = r === void 0 ? "Error logging user in: " + String(e) : r;
|
|
48
55
|
}
|
|
49
|
-
|
|
56
|
+
l(n, t);
|
|
50
57
|
});
|
|
51
58
|
}
|
|
52
59
|
};
|
|
53
|
-
function
|
|
54
|
-
new
|
|
60
|
+
function u(e, t, n, r) {
|
|
61
|
+
new l(e, t ?? { uid: "" }, n ?? { ...a }, r ?? (() => {}));
|
|
55
62
|
}
|
|
56
63
|
//#endregion
|
|
57
|
-
export { n as FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR, t as FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR,
|
|
64
|
+
export { n as FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR, t as FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR, l as FirebaseLoginCustom, i as FirebaseLoginCustomTokenError, r as FirebaseLoginCustomValidationError, u as default };
|
|
58
65
|
|
|
59
66
|
//# sourceMappingURL=firebase-login-custom.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-login-custom.mjs","names":[],"sources":["../src/firebase-login-custom.ts"],"sourcesContent":["/**\n * FirebaseLoginCustom\n *\n * Authenticating Users with Custom login\n * Firebase makes it easy to integrate email and password authentication\n * into your app. Firebase automatically stores your users' credentials\n * securely (using bcrypt) and redundantly (daily off-site backups).\n * This separates sensitive user credentials from your application data,\n * and lets you focus on the user interface and experience for your app.\n *\n * @author André Lademann <vergissberlin@googlemail.com>\n * @link https://www.firebase.com/docs/web/guide/login/password.html\n * @param ref Firebase object reference\n * @param data Authentication object with uid and secret\n * @param option Option object with admin, debug and expire settings\n * @param callback Callback function\n * @return FirebaseLoginCustom\n */\n\nimport FirebaseTokenGenerator from 'firebase-token-generator';\n\n/** Error code for validation failures (invalid ref, data, option, or callback). */\nexport const FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR = 'FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR';\n\n/** Error code for token generation failures (e.g. invalid claims or secret). */\nexport const FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR = 'FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR';\n\n/**\n * Thrown when constructor arguments are invalid (ref, data, option, or callback).\n * Consumers can use `error.code === FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR` or\n * `error instanceof FirebaseLoginCustomValidationError`.\n */\nexport class FirebaseLoginCustomValidationError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR;\n\n constructor(message: string) {\n super(message);\n this.name = 'FirebaseLoginCustomValidationError';\n Object.setPrototypeOf(this, FirebaseLoginCustomValidationError.prototype);\n }\n}\n\n/**\n * Thrown when token generation fails (e.g. invalid secret or claims).\n * Passed to the callback when createToken throws; not thrown from the constructor.\n */\nexport class FirebaseLoginCustomTokenError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR;\n readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'FirebaseLoginCustomTokenError';\n this.cause = cause;\n Object.setPrototypeOf(this, FirebaseLoginCustomTokenError.prototype);\n }\n}\n\nexport interface AuthData {\n uid: string;\n [key: string]: unknown;\n}\n\nexport interface FirebaseLoginOption {\n admin?: boolean;\n debug?: boolean;\n expires?: number;\n notBefore?: number;\n secret: string;\n}\n\n/** Option type for inputs where secret is not yet validated */\
|
|
1
|
+
{"version":3,"file":"firebase-login-custom.mjs","names":[],"sources":["../src/firebase-login-custom.ts"],"sourcesContent":["/**\n * FirebaseLoginCustom\n *\n * Authenticating Users with Custom login\n * Firebase makes it easy to integrate email and password authentication\n * into your app. Firebase automatically stores your users' credentials\n * securely (using bcrypt) and redundantly (daily off-site backups).\n * This separates sensitive user credentials from your application data,\n * and lets you focus on the user interface and experience for your app.\n *\n * @author André Lademann <vergissberlin@googlemail.com>\n * @link https://www.firebase.com/docs/web/guide/login/password.html\n * @param ref Firebase object reference\n * @param data Authentication object with uid and secret\n * @param option Option object with admin, debug and expire settings\n * @param callback Callback function\n * @return FirebaseLoginCustom\n */\n\nimport FirebaseTokenGenerator from 'firebase-token-generator';\n\n/** Error code for validation failures (invalid ref, data, option, or callback). */\nexport const FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR = 'FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR';\n\n/** Error code for token generation failures (e.g. invalid claims or secret). */\nexport const FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR = 'FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR';\n\n/**\n * Thrown when constructor arguments are invalid (ref, data, option, or callback).\n * Consumers can use `error.code === FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR` or\n * `error instanceof FirebaseLoginCustomValidationError`.\n */\nexport class FirebaseLoginCustomValidationError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_VALIDATION_ERROR;\n\n constructor(message: string) {\n super(message);\n this.name = 'FirebaseLoginCustomValidationError';\n Object.setPrototypeOf(this, FirebaseLoginCustomValidationError.prototype);\n }\n}\n\n/**\n * Thrown when token generation fails (e.g. invalid secret or claims).\n * Passed to the callback when createToken throws; not thrown from the constructor.\n */\nexport class FirebaseLoginCustomTokenError extends Error {\n readonly code = FIREBASE_LOGIN_CUSTOM_TOKEN_ERROR;\n readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'FirebaseLoginCustomTokenError';\n this.cause = cause;\n Object.setPrototypeOf(this, FirebaseLoginCustomTokenError.prototype);\n }\n}\n\nexport interface AuthData {\n uid: string;\n [key: string]: unknown;\n}\n\nexport interface FirebaseLoginOption {\n admin?: boolean;\n debug?: boolean;\n expires?: number;\n notBefore?: number;\n secret: string;\n}\n\n/** Option type for inputs where secret is not yet validated */\nexport type FirebaseLoginOptionInput = Omit<FirebaseLoginOption, 'secret'> & {\n secret?: string;\n};\n\nexport type FirebaseLoginCallback = (\n error: Error | string | null,\n authData?: unknown\n) => void;\n\nexport interface FirebaseRef {\n authWithCustomToken: (\n token: string,\n callback: FirebaseLoginCallback\n ) => void;\n}\n\n/** Shape of auth errors passed to the callback by Firebase (with optional code). */\nexport interface FirebaseAuthError extends Error {\n code?: string;\n}\n\nconst DEFAULT_OPTION: Required<Omit<FirebaseLoginOption, 'secret'>> & {\n secret?: string;\n} = {\n admin: false,\n debug: false,\n expires: 0,\n notBefore: 0,\n};\n\nconst SECONDS_PER_DAY = 86400;\n\n/** User-facing messages for known Firebase auth error codes */\nconst AUTH_ERROR_MESSAGES: Record<string, string> = {\n INVALID_EMAIL: 'The specified user account email is invalid.',\n INVALID_PASSWORD: 'The specified user account password is incorrect.',\n INVALID_USER: 'The specified user account does not exist.',\n};\n\nfunction resolveOption(\n input: FirebaseLoginOptionInput\n): Required<Omit<FirebaseLoginOption, 'secret'>> & { secret: string } {\n const now = Date.now() / 1000;\n return {\n admin: typeof input.admin === 'boolean' ? input.admin : DEFAULT_OPTION.admin,\n debug: typeof input.debug === 'boolean' ? input.debug : DEFAULT_OPTION.debug,\n expires: typeof input.expires === 'number' ? input.expires : now + SECONDS_PER_DAY,\n notBefore: typeof input.notBefore === 'number' ? input.notBefore : now,\n secret: input.secret as string,\n };\n}\n\n/**\n * Custom login helper: generates a Firebase custom token and authenticates via the given ref.\n * Validation errors throw synchronously; token or auth failures are reported to the callback.\n */\nexport class FirebaseLoginCustom {\n /**\n * @param ref - Firebase ref with `authWithCustomToken(token, callback)`\n * @param data - Auth payload; must include `uid` (string)\n * @param option - Options; must include `secret`. Optional: admin, debug, expires, notBefore\n * @param callback - Called with (error, authData) when auth completes or token generation fails\n */\n constructor(\n ref: FirebaseRef,\n data: AuthData = { uid: '' },\n option: FirebaseLoginOptionInput = { ...DEFAULT_OPTION },\n callback: FirebaseLoginCallback = () => {}\n ) {\n if (ref == null || typeof ref !== 'object') {\n throw new FirebaseLoginCustomValidationError('Ref must be an object!');\n }\n if (typeof data.uid !== 'string') {\n throw new FirebaseLoginCustomValidationError('Data object must have a \"uid\" field!');\n }\n if (typeof option.secret !== 'string') {\n throw new FirebaseLoginCustomValidationError('Option object must have a \"secret\" field!');\n }\n if (typeof callback !== 'function') {\n throw new FirebaseLoginCustomValidationError('Callback must be a function!');\n }\n\n const resolvedOption = resolveOption(option);\n\n let authToken: string;\n try {\n const tokenGenerator = new FirebaseTokenGenerator(resolvedOption.secret);\n authToken = tokenGenerator.createToken(data, {\n admin: resolvedOption.admin,\n debug: resolvedOption.debug,\n expires: resolvedOption.expires,\n notBefore: resolvedOption.notBefore,\n });\n } catch (err) {\n const callbackError =\n err instanceof Error\n ? new FirebaseLoginCustomTokenError('Token generation failed: ' + err.message, err)\n : new FirebaseLoginCustomTokenError('Token generation failed: ' + String(err), err);\n process.nextTick(() => callback(callbackError, undefined));\n return;\n }\n\n ref.authWithCustomToken(authToken, (error, authData) => {\n let callbackError: Error | string | null = null;\n if (error) {\n const authErr = error as FirebaseAuthError;\n const knownMessage =\n authErr?.code !== undefined ? AUTH_ERROR_MESSAGES[authErr.code] : undefined;\n callbackError =\n knownMessage !== undefined ? knownMessage : 'Error logging user in: ' + String(error);\n }\n callback(callbackError, authData);\n });\n }\n}\n\n/**\n * Callable form: same as `new FirebaseLoginCustom(...)`. Use without `new` for backward compatibility.\n */\nfunction firebaseLoginCustom(\n ref: FirebaseRef,\n data?: AuthData,\n option?: FirebaseLoginOptionInput,\n callback?: FirebaseLoginCallback\n): void {\n new FirebaseLoginCustom(\n ref,\n data ?? { uid: '' },\n option ?? { ...DEFAULT_OPTION },\n callback ?? (() => {})\n );\n}\n\nexport default firebaseLoginCustom;\n"],"mappings":";;AAsBA,IAAa,IAAyC,0CAGzC,IAAoC,qCAOpC,IAAb,MAAa,UAA2C,MAAM;CAG5D,YAAY,GAAiB;AAG3B,EAFA,MAAM,EAAQ,cAHA,GAId,KAAK,OAAO,sCACZ,OAAO,eAAe,MAAM,EAAmC,UAAU;;GAQhE,IAAb,MAAa,UAAsC,MAAM;CAIvD,YAAY,GAAiB,GAAiB;AAI5C,EAHA,MAAM,EAAQ,cAJA,GAKd,KAAK,OAAO,iCACZ,KAAK,QAAQ,GACb,OAAO,eAAe,MAAM,EAA8B,UAAU;;GAuClE,IAEF;CACF,OAAO;CACP,OAAO;CACP,SAAS;CACT,WAAW;CACZ,EAEK,IAAkB,OAGlB,IAA8C;CAClD,eAAe;CACf,kBAAkB;CAClB,cAAc;CACf;AAED,SAAS,EACP,GACoE;CACpE,IAAM,IAAM,KAAK,KAAK,GAAG;AACzB,QAAO;EACL,OAAO,OAAO,EAAM,SAAU,YAAY,EAAM,QAAQ,EAAe;EACvE,OAAO,OAAO,EAAM,SAAU,YAAY,EAAM,QAAQ,EAAe;EACvE,SAAS,OAAO,EAAM,WAAY,WAAW,EAAM,UAAU,IAAM;EACnE,WAAW,OAAO,EAAM,aAAc,WAAW,EAAM,YAAY;EACnE,QAAQ,EAAM;EACf;;AAOH,IAAa,IAAb,MAAiC;CAO/B,YACE,GACA,IAAiB,EAAE,KAAK,IAAI,EAC5B,IAAmC,EAAE,GAAG,GAAgB,EACxD,UAAwC,IACxC;AACA,MAAmB,OAAO,KAAQ,aAA9B,EACF,OAAM,IAAI,EAAmC,yBAAyB;AAExE,MAAI,OAAO,EAAK,OAAQ,SACtB,OAAM,IAAI,EAAmC,yCAAuC;AAEtF,MAAI,OAAO,EAAO,UAAW,SAC3B,OAAM,IAAI,EAAmC,8CAA4C;AAE3F,MAAI,OAAO,KAAa,WACtB,OAAM,IAAI,EAAmC,+BAA+B;EAG9E,IAAM,IAAiB,EAAc,EAAO,EAExC;AACJ,MAAI;AAEF,OADuB,IAAI,EAAuB,EAAe,OAAO,CAC7C,YAAY,GAAM;IAC3C,OAAO,EAAe;IACtB,OAAO,EAAe;IACtB,SAAS,EAAe;IACxB,WAAW,EAAe;IAC3B,CAAC;WACK,GAAK;GACZ,IAAM,IACJ,aAAe,QACX,IAAI,EAA8B,8BAA8B,EAAI,SAAS,EAAI,GACjF,IAAI,EAA8B,8BAA8B,OAAO,EAAI,EAAE,EAAI;AACvF,WAAQ,eAAe,EAAS,GAAe,KAAA,EAAU,CAAC;AAC1D;;AAGF,IAAI,oBAAoB,IAAY,GAAO,MAAa;GACtD,IAAI,IAAuC;AAC3C,OAAI,GAAO;IACT,IAAM,IAAU,GACV,IACJ,GAAS,SAAS,KAAA,IAAgD,KAAA,IAApC,EAAoB,EAAQ;AAC5D,QACE,MAAiB,KAAA,IAA2B,4BAA4B,OAAO,EAAM,GAAxD;;AAEjC,KAAS,GAAe,EAAS;IACjC;;;AAON,SAAS,EACP,GACA,GACA,GACA,GACM;AACN,KAAI,EACF,GACA,KAAQ,EAAE,KAAK,IAAI,EACnB,KAAU,EAAE,GAAG,GAAgB,EAC/B,YAAmB,IACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-login-custom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "This package is a wrapper to firebase custom login including all dependencies with the exception of firebase it self.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/js": "^10.0.1",
|
|
45
|
-
"@types/node": "^
|
|
45
|
+
"@types/node": "^24.0.0",
|
|
46
46
|
"eslint": "^10.0.3",
|
|
47
47
|
"firebase": "^12.10.0",
|
|
48
48
|
"husky": "^9.1.7",
|