@dereekb/firebase-server 13.6.16 → 13.7.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/index.cjs.js +2615 -951
- package/index.esm.js +2598 -932
- package/mailgun/package.json +9 -9
- package/model/package.json +9 -9
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +4 -13
- package/oidc/index.cjs.js +245 -180
- package/oidc/index.esm.js +242 -178
- package/oidc/package.json +10 -10
- package/oidc/src/lib/middleware/oauth-auth.module.d.ts +18 -25
- package/package.json +11 -10
- package/src/lib/function/error.d.ts +11 -28
- package/src/lib/nest/app.d.ts +4 -45
- package/src/lib/nest/app.module.d.ts +4 -2
- package/src/lib/nest/auth/auth.util.d.ts +71 -5
- package/src/lib/nest/controller/index.d.ts +1 -0
- package/src/lib/nest/controller/model/index.d.ts +4 -0
- package/src/lib/nest/controller/model/model.api.controller.d.ts +93 -0
- package/src/lib/nest/controller/model/model.api.dispatch.d.ts +73 -0
- package/src/lib/nest/controller/model/model.api.get.service.d.ts +73 -0
- package/src/lib/nest/controller/model/model.api.module.d.ts +32 -0
- package/src/lib/nest/model/analytics.handler.d.ts +2 -0
- package/src/lib/nest/model/api.details.d.ts +53 -1
- package/src/lib/nest/model/call.model.function.d.ts +8 -5
- package/src/lib/nest/model/create.model.function.d.ts +1 -1
- package/src/lib/nest/model/crud.assert.function.d.ts +1 -1
- package/src/lib/nest/model/delete.model.function.d.ts +1 -1
- package/src/lib/nest/model/index.d.ts +1 -0
- package/src/lib/nest/model/query.model.function.d.ts +207 -0
- package/src/lib/nest/model/read.model.function.d.ts +1 -1
- package/src/lib/nest/model/update.model.function.d.ts +1 -1
- package/src/lib/nest/nest.provider.d.ts +19 -0
- package/test/index.cjs.js +1358 -398
- package/test/index.esm.js +1355 -400
- package/test/package.json +13 -11
- package/test/src/lib/firebase/firebase.test.d.ts +1 -1
- package/test/src/lib/index.d.ts +1 -0
- package/test/src/lib/oidc/index.d.ts +2 -0
- package/test/src/lib/oidc/oidc.test.fixture.d.ts +126 -0
- package/test/src/lib/oidc/oidc.test.flow.d.ts +43 -0
- package/zoho/package.json +9 -9
package/test/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/test",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/analytics": "13.
|
|
6
|
-
"@dereekb/date": "13.
|
|
7
|
-
"@dereekb/firebase": "13.
|
|
8
|
-
"@dereekb/firebase-server": "13.
|
|
9
|
-
"@dereekb/
|
|
10
|
-
"@dereekb/
|
|
11
|
-
"@dereekb/
|
|
12
|
-
"@dereekb/
|
|
5
|
+
"@dereekb/analytics": "13.7.0",
|
|
6
|
+
"@dereekb/date": "13.7.0",
|
|
7
|
+
"@dereekb/firebase": "13.7.0",
|
|
8
|
+
"@dereekb/firebase-server": "13.7.0",
|
|
9
|
+
"@dereekb/firebase-server/oidc": "13.7.0",
|
|
10
|
+
"@dereekb/model": "13.7.0",
|
|
11
|
+
"@dereekb/nestjs": "13.7.0",
|
|
12
|
+
"@dereekb/rxjs": "13.7.0",
|
|
13
|
+
"@dereekb/util": "13.7.0",
|
|
13
14
|
"@google-cloud/firestore": "^7.11.6",
|
|
14
15
|
"@google-cloud/storage": "^7.19.0",
|
|
15
16
|
"@nestjs/common": "^11.1.17",
|
|
@@ -18,10 +19,11 @@
|
|
|
18
19
|
"firebase-functions": "^7.0.0",
|
|
19
20
|
"firebase-functions-test": "3.4.1",
|
|
20
21
|
"jsonwebtoken": "^9.0.0",
|
|
21
|
-
"make-error": "^1.3.0"
|
|
22
|
+
"make-error": "^1.3.0",
|
|
23
|
+
"supertest": "^7.2.2"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
|
-
"@dereekb/nestjs": "13.
|
|
26
|
+
"@dereekb/nestjs": "13.7.0"
|
|
25
27
|
},
|
|
26
28
|
"exports": {
|
|
27
29
|
"./package.json": "./package.json",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExpectFailAssertionFunction } from '@dereekb/util/test';
|
|
2
|
-
import { HttpsError } from 'firebase-functions/
|
|
2
|
+
import { HttpsError } from 'firebase-functions/https';
|
|
3
3
|
import { BaseError } from 'make-error';
|
|
4
4
|
/**
|
|
5
5
|
* Error thrown when the error type was different than the expected type.
|
package/test/src/lib/index.d.ts
CHANGED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import request from 'supertest';
|
|
2
|
+
import { type INestApplication } from '@nestjs/common';
|
|
3
|
+
import { AbstractTestContextFixture } from '@dereekb/util/test';
|
|
4
|
+
import { FirebaseAdminNestTestContextFixture } from '../firebase/firebase.admin.nest';
|
|
5
|
+
import { AuthorizedUserTestContextFixture } from '../firebase';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for {@link oAuthAuthorizedSuperTestContextFactory}.
|
|
8
|
+
*/
|
|
9
|
+
export interface OAuthAuthorizedSuperTestContextFactoryConfig {
|
|
10
|
+
/**
|
|
11
|
+
* OAuth scopes (space-separated). If omitted, all registered scopes are
|
|
12
|
+
* resolved from `OidcAccountService.providerConfig.claims`.
|
|
13
|
+
*/
|
|
14
|
+
readonly scopes?: string;
|
|
15
|
+
/**
|
|
16
|
+
* OAuth redirect URI. Defaults to `'https://example.com/callback'`.
|
|
17
|
+
*/
|
|
18
|
+
readonly redirectUri?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Client name. Defaults to `'test-oauth-context'`.
|
|
21
|
+
*/
|
|
22
|
+
readonly clientName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Vitest hook/test timeout in milliseconds. Defaults to `30_000`.
|
|
25
|
+
*/
|
|
26
|
+
readonly timeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Optional custom fixture creator.
|
|
29
|
+
*/
|
|
30
|
+
readonly makeFixture?: () => OAuthAuthorizedSuperTestFixture;
|
|
31
|
+
/**
|
|
32
|
+
* Optional custom instance creator.
|
|
33
|
+
*/
|
|
34
|
+
readonly makeInstance?: (server: ReturnType<INestApplication['getHttpServer']>, accessToken: string) => OAuthAuthorizedSuperTestInstance;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parameters passed when invoking the factory returned by {@link oAuthAuthorizedSuperTestContextFactory}.
|
|
38
|
+
*/
|
|
39
|
+
export interface OAuthAuthorizedSuperTestContextParams {
|
|
40
|
+
/**
|
|
41
|
+
* A fixture that provides NestJS app access (DI container, HTTP server).
|
|
42
|
+
*/
|
|
43
|
+
readonly f: FirebaseAdminNestTestContextFixture;
|
|
44
|
+
/**
|
|
45
|
+
* A fixture or object that provides the test user's UID.
|
|
46
|
+
*/
|
|
47
|
+
readonly u: AuthorizedUserTestContextFixture;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Instance holding authenticated OAuth state for a single test.
|
|
51
|
+
*/
|
|
52
|
+
export declare class OAuthAuthorizedSuperTestInstance {
|
|
53
|
+
readonly server: ReturnType<INestApplication['getHttpServer']>;
|
|
54
|
+
readonly accessToken: string;
|
|
55
|
+
constructor(server: ReturnType<INestApplication['getHttpServer']>, accessToken: string);
|
|
56
|
+
/**
|
|
57
|
+
* Apply Bearer auth to a supertest request.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* await oauth.withAuth(request(oauth.server).get('/oidc/me')).expect(200);
|
|
62
|
+
* await oauth.withAuth(request(oauth.server).post('/api/model/call')).send(body).expect(200);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
withAuth(test: request.Test): request.Test;
|
|
66
|
+
/**
|
|
67
|
+
* Shorthand: create a supertest request with auth already applied.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* await oauth.authRequest('get', '/oidc/me').expect(200);
|
|
72
|
+
* await oauth.authRequest('post', '/api/model/call').send(body).expect(200);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
authRequest(method: 'get' | 'post' | 'put' | 'patch' | 'delete', path: string): request.Test;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Fixture that wraps {@link OAuthAuthorizedSuperTestInstance} and delegates to it.
|
|
79
|
+
*/
|
|
80
|
+
export declare class OAuthAuthorizedSuperTestFixture extends AbstractTestContextFixture<OAuthAuthorizedSuperTestInstance> {
|
|
81
|
+
get server(): any;
|
|
82
|
+
get accessToken(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Apply Bearer auth to a supertest request.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* await oauth.withAuth(request(oauth.server).get('/oidc/me')).expect(200);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
withAuth(test: request.Test): request.Test;
|
|
92
|
+
/**
|
|
93
|
+
* Shorthand: create a supertest request with auth already applied.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* await oauth.authRequest('get', '/oidc/me').expect(200);
|
|
98
|
+
* await oauth.authRequest('post', '/api/model/call').send(body).expect(200);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
authRequest(method: 'get' | 'post' | 'put' | 'patch' | 'delete', path: string): request.Test;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a factory that sets up an OAuth-authenticated supertest context.
|
|
105
|
+
*
|
|
106
|
+
* The returned factory function performs a full OAuth authorization code flow
|
|
107
|
+
* and provides an authenticated supertest agent and helper methods.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // In shared test setup (e.g. fixture.oidc.ts)
|
|
112
|
+
* export const myOAuthContext = oAuthAuthorizedSuperTestContextFactory();
|
|
113
|
+
*
|
|
114
|
+
* // In test file
|
|
115
|
+
* myAppFunctionContextFactory((f) => {
|
|
116
|
+
* authorizedUserContext({ f }, (u) => {
|
|
117
|
+
* myOAuthContext({ f, u }, (oauth) => {
|
|
118
|
+
* it('should fetch userinfo', async () => {
|
|
119
|
+
* await oauth.authRequest('get', '/oidc/me').expect(200);
|
|
120
|
+
* });
|
|
121
|
+
* });
|
|
122
|
+
* });
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function oAuthAuthorizedSuperTestContextFactory(config?: OAuthAuthorizedSuperTestContextFactoryConfig): (params: OAuthAuthorizedSuperTestContextParams, buildTests: (oauth: OAuthAuthorizedSuperTestFixture) => void) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type INestApplication } from '@nestjs/common';
|
|
2
|
+
import type { OidcTokenEndpointAuthMethod } from '@dereekb/firebase';
|
|
3
|
+
import { OidcClientService } from '@dereekb/firebase-server/oidc';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for {@link performFullOAuthFlow}.
|
|
6
|
+
*/
|
|
7
|
+
export interface OAuthTestFlowConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Space-separated OAuth scopes to request.
|
|
10
|
+
*
|
|
11
|
+
* If omitted, all registered scopes are resolved from {@link OidcAccountService.allRegisteredScopes}.
|
|
12
|
+
*/
|
|
13
|
+
readonly scopes?: string;
|
|
14
|
+
/**
|
|
15
|
+
* OAuth redirect URI. Defaults to `'https://example.com/callback'`.
|
|
16
|
+
*/
|
|
17
|
+
readonly redirectUri?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Client name used when creating the test OAuth client. Defaults to `'test-oauth-context'`.
|
|
20
|
+
*/
|
|
21
|
+
readonly clientName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Token endpoint auth method. Defaults to `'client_secret_post'`.
|
|
24
|
+
*/
|
|
25
|
+
readonly tokenEndpointAuthMethod?: OidcTokenEndpointAuthMethod;
|
|
26
|
+
}
|
|
27
|
+
export interface PerformFullOAuthFlowResult {
|
|
28
|
+
readonly accessToken: string;
|
|
29
|
+
readonly idToken: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Performs the full OAuth authorization code flow with PKCE and returns tokens.
|
|
33
|
+
*
|
|
34
|
+
* Steps: create client → PKCE → auth redirect → login → consent → code exchange → token
|
|
35
|
+
*/
|
|
36
|
+
export declare function performFullOAuthFlow(server: ReturnType<INestApplication['getHttpServer']>, oidcClientService: OidcClientService, nestApp: INestApplication, uid: string, config?: OAuthTestFlowConfig): Promise<PerformFullOAuthFlowResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Higher-level helper that resolves OIDC services from the NestJS DI container,
|
|
39
|
+
* rotates JWKS keys, and then performs the full OAuth flow.
|
|
40
|
+
*
|
|
41
|
+
* This avoids callers needing to import from `@dereekb/firebase-server/oidc` directly.
|
|
42
|
+
*/
|
|
43
|
+
export declare function setupAndPerformFullOAuthFlow(nestApp: INestApplication, uid: string, config?: OAuthTestFlowConfig): Promise<PerformFullOAuthFlowResult>;
|
package/zoho/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/zoho",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/analytics": "13.
|
|
6
|
-
"@dereekb/date": "13.
|
|
7
|
-
"@dereekb/model": "13.
|
|
8
|
-
"@dereekb/nestjs": "13.
|
|
9
|
-
"@dereekb/rxjs": "13.
|
|
10
|
-
"@dereekb/firebase": "13.
|
|
11
|
-
"@dereekb/util": "13.
|
|
12
|
-
"@dereekb/zoho": "13.
|
|
5
|
+
"@dereekb/analytics": "13.7.0",
|
|
6
|
+
"@dereekb/date": "13.7.0",
|
|
7
|
+
"@dereekb/model": "13.7.0",
|
|
8
|
+
"@dereekb/nestjs": "13.7.0",
|
|
9
|
+
"@dereekb/rxjs": "13.7.0",
|
|
10
|
+
"@dereekb/firebase": "13.7.0",
|
|
11
|
+
"@dereekb/util": "13.7.0",
|
|
12
|
+
"@dereekb/zoho": "13.7.0"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
"./package.json": "./package.json",
|