@aurorajs.dev/catalyst-cli 3.1.0 → 3.1.1
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/README.md +1 -1
- package/dist/templates/backend/packages/identity/package.yaml +1 -0
- package/dist/templates/backend/packages/identity/test/acceptance/authentication/authentication-access-token.fixture.ts +80 -0
- package/dist/templates/frontend/packages/identity/package.yaml +1 -0
- package/oclif.manifest.json +34 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ $ npm install -g @aurorajs.dev/catalyst-cli
|
|
|
41
41
|
$ catalyst COMMAND
|
|
42
42
|
running command...
|
|
43
43
|
$ catalyst (--version)
|
|
44
|
-
@aurorajs.dev/catalyst-cli/3.1.
|
|
44
|
+
@aurorajs.dev/catalyst-cli/3.1.1 darwin-arm64 node-v26.13.0
|
|
45
45
|
$ catalyst --help [COMMAND]
|
|
46
46
|
USAGE
|
|
47
47
|
$ catalyst COMMAND
|
|
@@ -77,6 +77,7 @@ backend:
|
|
|
77
77
|
- src/@bridges/providers/access-token-state-reader.bridge.ts
|
|
78
78
|
- src/@bridges/providers/o-auth-second-factor.bridge.ts
|
|
79
79
|
- test/acceptance/o-auth
|
|
80
|
+
- test/acceptance/authentication/authentication-access-token.fixture.ts
|
|
80
81
|
frontend:
|
|
81
82
|
routes: [iam, o-auth]
|
|
82
83
|
navigation: { navMain: [iam, o-auth] }
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared e2e fixture: a Bearer token the guard accepts.
|
|
3
|
+
*
|
|
4
|
+
* The guard only trusts a signed access token whose `o_auth_access_token` row (id = the `jti`
|
|
5
|
+
* claim) is live, so a spec that needs a bearer must persist that row AND sign the token with the
|
|
6
|
+
* real `JWT_SIGNER`. Test support, not production code: it sits under `test/acceptance/`, which
|
|
7
|
+
* the packager excludes from the scaffold.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BOOTSTRAP_OAUTH_APP_CODE,
|
|
12
|
+
BOOTSTRAP_OAUTH_CLIENT_ID,
|
|
13
|
+
} from '@api/o-auth/o-auth-bootstrap.seeder.js';
|
|
14
|
+
import type { IJwtSigner } from '@aurora/modules/authentication/domain/ports/index.js';
|
|
15
|
+
import { sql } from 'drizzle-orm';
|
|
16
|
+
import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
17
|
+
import { randomUUID } from 'node:crypto';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Rows created by this module instance. Vitest isolates each spec file, so the list is per spec
|
|
21
|
+
* and `deleteAccessTokenFixtures` needs no arguments beyond the connection.
|
|
22
|
+
*/
|
|
23
|
+
const createdIds: string[] = [];
|
|
24
|
+
|
|
25
|
+
export interface AccessTokenFixtureOptions {
|
|
26
|
+
/** Account the token acts as (`sub`, and `account_id` of the row). */
|
|
27
|
+
accountId: string;
|
|
28
|
+
/** `OAuthClient.id` stored on the row. Defaults to the bootstrap client. */
|
|
29
|
+
clientId?: string;
|
|
30
|
+
/** `OAuthApplication.code` signed as `client_id` and `aud`. Defaults to the bootstrap application. */
|
|
31
|
+
clientCode?: string;
|
|
32
|
+
/** Real operator behind an impersonated token (`act.sub`). */
|
|
33
|
+
actorId?: string;
|
|
34
|
+
/** Overrides `JWT_ACCESS_TTL_SECONDS` for this token; a negative value mints an expired one. */
|
|
35
|
+
ttlSeconds?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AccessTokenFixture {
|
|
39
|
+
/** The signed JWT to send as `Authorization: Bearer <token>`. */
|
|
40
|
+
token: string;
|
|
41
|
+
/** Id of the persisted row, equal to the `jti` claim. */
|
|
42
|
+
jti: string;
|
|
43
|
+
expiresAt: Date;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Inserts the access-token row and signs the matching token through the real signer. */
|
|
47
|
+
export async function createAccessTokenFixture(
|
|
48
|
+
db: NodePgDatabase,
|
|
49
|
+
jwtSigner: IJwtSigner,
|
|
50
|
+
options: AccessTokenFixtureOptions,
|
|
51
|
+
): Promise<AccessTokenFixture> {
|
|
52
|
+
const jti = randomUUID();
|
|
53
|
+
const clientId = options.clientId ?? BOOTSTRAP_OAUTH_CLIENT_ID;
|
|
54
|
+
|
|
55
|
+
const signed = await jwtSigner.signAccess(
|
|
56
|
+
{
|
|
57
|
+
sub: options.accountId,
|
|
58
|
+
jti,
|
|
59
|
+
clientId: options.clientCode ?? BOOTSTRAP_OAUTH_APP_CODE,
|
|
60
|
+
...(options.actorId ? { act: { sub: options.actorId } } : {}),
|
|
61
|
+
},
|
|
62
|
+
options.ttlSeconds === undefined ? undefined : { ttlSeconds: options.ttlSeconds },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
await db.execute(sql`
|
|
66
|
+
INSERT INTO o_auth_access_token (id, client_id, account_id, is_revoked, expires_at, created_at)
|
|
67
|
+
VALUES (${jti}, ${clientId}, ${options.accountId}, false, ${signed.expiresAt.toISOString()}, NOW())
|
|
68
|
+
`);
|
|
69
|
+
|
|
70
|
+
createdIds.push(jti);
|
|
71
|
+
|
|
72
|
+
return { token: signed.token, jti, expiresAt: signed.expiresAt };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Removes every row created by `createAccessTokenFixture` in this spec file. */
|
|
76
|
+
export async function deleteAccessTokenFixtures(db: NodePgDatabase): Promise<void> {
|
|
77
|
+
for (const id of createdIds.splice(0)) {
|
|
78
|
+
await db.execute(sql`DELETE FROM o_auth_access_token WHERE id = ${id}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -77,6 +77,7 @@ backend:
|
|
|
77
77
|
- src/@bridges/providers/access-token-state-reader.bridge.ts
|
|
78
78
|
- src/@bridges/providers/o-auth-second-factor.bridge.ts
|
|
79
79
|
- test/acceptance/o-auth
|
|
80
|
+
- test/acceptance/authentication/authentication-access-token.fixture.ts
|
|
80
81
|
frontend:
|
|
81
82
|
routes: [iam, o-auth]
|
|
82
83
|
navigation: { navMain: [iam, o-auth] }
|
package/oclif.manifest.json
CHANGED
|
@@ -590,39 +590,6 @@
|
|
|
590
590
|
"index.js"
|
|
591
591
|
]
|
|
592
592
|
},
|
|
593
|
-
"pipeline": {
|
|
594
|
-
"aliases": [],
|
|
595
|
-
"args": {},
|
|
596
|
-
"description": "Generate a deploy workflow and its supporting files from templates (interactive).",
|
|
597
|
-
"examples": [
|
|
598
|
-
"<%= config.bin %> pipeline",
|
|
599
|
-
"<%= config.bin %> pipeline --force"
|
|
600
|
-
],
|
|
601
|
-
"flags": {
|
|
602
|
-
"force": {
|
|
603
|
-
"char": "f",
|
|
604
|
-
"description": "Overwrite existing files of the set",
|
|
605
|
-
"name": "force",
|
|
606
|
-
"allowNo": false,
|
|
607
|
-
"type": "boolean"
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
"hasDynamicHelp": false,
|
|
611
|
-
"hiddenAliases": [],
|
|
612
|
-
"id": "pipeline",
|
|
613
|
-
"pluginAlias": "@aurorajs.dev/catalyst-cli",
|
|
614
|
-
"pluginName": "@aurorajs.dev/catalyst-cli",
|
|
615
|
-
"pluginType": "core",
|
|
616
|
-
"strict": true,
|
|
617
|
-
"enableJsonFlag": false,
|
|
618
|
-
"isESM": true,
|
|
619
|
-
"relativePath": [
|
|
620
|
-
"dist",
|
|
621
|
-
"commands",
|
|
622
|
-
"pipeline",
|
|
623
|
-
"index.js"
|
|
624
|
-
]
|
|
625
|
-
},
|
|
626
593
|
"origin:accept": {
|
|
627
594
|
"aliases": [],
|
|
628
595
|
"args": {
|
|
@@ -846,6 +813,39 @@
|
|
|
846
813
|
"review.js"
|
|
847
814
|
]
|
|
848
815
|
},
|
|
816
|
+
"pipeline": {
|
|
817
|
+
"aliases": [],
|
|
818
|
+
"args": {},
|
|
819
|
+
"description": "Generate a deploy workflow and its supporting files from templates (interactive).",
|
|
820
|
+
"examples": [
|
|
821
|
+
"<%= config.bin %> pipeline",
|
|
822
|
+
"<%= config.bin %> pipeline --force"
|
|
823
|
+
],
|
|
824
|
+
"flags": {
|
|
825
|
+
"force": {
|
|
826
|
+
"char": "f",
|
|
827
|
+
"description": "Overwrite existing files of the set",
|
|
828
|
+
"name": "force",
|
|
829
|
+
"allowNo": false,
|
|
830
|
+
"type": "boolean"
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
"hasDynamicHelp": false,
|
|
834
|
+
"hiddenAliases": [],
|
|
835
|
+
"id": "pipeline",
|
|
836
|
+
"pluginAlias": "@aurorajs.dev/catalyst-cli",
|
|
837
|
+
"pluginName": "@aurorajs.dev/catalyst-cli",
|
|
838
|
+
"pluginType": "core",
|
|
839
|
+
"strict": true,
|
|
840
|
+
"enableJsonFlag": false,
|
|
841
|
+
"isESM": true,
|
|
842
|
+
"relativePath": [
|
|
843
|
+
"dist",
|
|
844
|
+
"commands",
|
|
845
|
+
"pipeline",
|
|
846
|
+
"index.js"
|
|
847
|
+
]
|
|
848
|
+
},
|
|
849
849
|
"provision:audit": {
|
|
850
850
|
"aliases": [],
|
|
851
851
|
"args": {},
|
|
@@ -1242,5 +1242,5 @@
|
|
|
1242
1242
|
]
|
|
1243
1243
|
}
|
|
1244
1244
|
},
|
|
1245
|
-
"version": "3.1.
|
|
1245
|
+
"version": "3.1.1"
|
|
1246
1246
|
}
|
package/package.json
CHANGED