@nathapp/nestjs-iam-prisma 0.0.0-stage → 1.0.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/AGENTS.md +160 -0
- package/CLAUDE.md +158 -0
- package/GEMINI.md +158 -0
- package/README.md +360 -2
- package/codex.md +158 -0
- package/dist/credential-id-hash.d.ts +1 -0
- package/dist/credential-id-hash.js +8 -0
- package/dist/credential-id-hash.js.map +1 -0
- package/dist/iam-prisma.module.d.ts +7 -0
- package/dist/iam-prisma.module.js +73 -0
- package/dist/iam-prisma.module.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/prisma-api-key.repository.d.ts +28 -0
- package/dist/prisma-api-key.repository.js +90 -0
- package/dist/prisma-api-key.repository.js.map +1 -0
- package/dist/prisma-auth-attempt.store.d.ts +42 -0
- package/dist/prisma-auth-attempt.store.js +112 -0
- package/dist/prisma-auth-attempt.store.js.map +1 -0
- package/dist/prisma-identity.repository.d.ts +26 -0
- package/dist/prisma-identity.repository.js +107 -0
- package/dist/prisma-identity.repository.js.map +1 -0
- package/dist/prisma-login-history.repository.d.ts +24 -0
- package/dist/prisma-login-history.repository.js +58 -0
- package/dist/prisma-login-history.repository.js.map +1 -0
- package/dist/prisma-mfa.repository.d.ts +20 -0
- package/dist/prisma-mfa.repository.js +57 -0
- package/dist/prisma-mfa.repository.js.map +1 -0
- package/dist/prisma-model.types.d.ts +188 -0
- package/dist/prisma-model.types.js +36 -0
- package/dist/prisma-model.types.js.map +1 -0
- package/dist/prisma-session.repository.d.ts +31 -0
- package/dist/prisma-session.repository.js +97 -0
- package/dist/prisma-session.repository.js.map +1 -0
- package/dist/prisma-sso-account.repository.d.ts +24 -0
- package/dist/prisma-sso-account.repository.js +71 -0
- package/dist/prisma-sso-account.repository.js.map +1 -0
- package/dist/prisma-sso-provider.repository.d.ts +28 -0
- package/dist/prisma-sso-provider.repository.js +91 -0
- package/dist/prisma-sso-provider.repository.js.map +1 -0
- package/dist/prisma-totp-replay.store.d.ts +34 -0
- package/dist/prisma-totp-replay.store.js +78 -0
- package/dist/prisma-totp-replay.store.js.map +1 -0
- package/dist/prisma-user.repository.d.ts +27 -0
- package/dist/prisma-user.repository.js +101 -0
- package/dist/prisma-user.repository.js.map +1 -0
- package/dist/prisma-verification-token.repository.d.ts +23 -0
- package/dist/prisma-verification-token.repository.js +66 -0
- package/dist/prisma-verification-token.repository.js.map +1 -0
- package/dist/prisma-webauthn-credential.repository.d.ts +32 -0
- package/dist/prisma-webauthn-credential.repository.js +113 -0
- package/dist/prisma-webauthn-credential.repository.js.map +1 -0
- package/dist/prisma-webauthn-mfa-binding.store.d.ts +26 -0
- package/dist/prisma-webauthn-mfa-binding.store.js +66 -0
- package/dist/prisma-webauthn-mfa-binding.store.js.map +1 -0
- package/package.json +45 -4
- package/prisma/iam.prisma +246 -0
- package/prisma/sql/api-key-scopes.postgresql.sql +18 -0
- package/prisma/sql/long-text-columns.mysql.sql +15 -0
- package/prisma/sql/primary-identity.mysql.sql +10 -0
- package/prisma/sql/primary-identity.postgresql.sql +11 -0
package/README.md
CHANGED
|
@@ -1,3 +1,361 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nathapp/nestjs-iam-prisma
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Prisma adapter for `@nathapp/nestjs-iam`. Binds the core package's repository
|
|
4
|
+
tokens to `AbstractPrismaRepository`-based implementations.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```shell
|
|
9
|
+
npm i @nathapp/nestjs-iam-prisma @prisma/client@6
|
|
10
|
+
npm i -D prisma@6
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Schema
|
|
14
|
+
|
|
15
|
+
Append the 13 models from the packaged fragment
|
|
16
|
+
`node_modules/@nathapp/nestjs-iam-prisma/prisma/iam.prisma` to your app's
|
|
17
|
+
`schema.prisma`. The fragment carries no `datasource` or `generator` block — it
|
|
18
|
+
is models only. For PostgreSQL, every `DateTime` in it uses `@db.Timestamptz(6)`;
|
|
19
|
+
bare `DateTime` is not correct for these fields. For MySQL, assemble the model
|
|
20
|
+
fragment with `@db.DateTime(6)` as shown below.
|
|
21
|
+
|
|
22
|
+
Two fields in the fragment are load-bearing, not cosmetic:
|
|
23
|
+
|
|
24
|
+
- `UserIdentity` declares its `user` relation and `User` its `identities` back
|
|
25
|
+
relation. `PrismaUserRepository.findByEmail` resolves the user through
|
|
26
|
+
`include: { user: true }` and throws
|
|
27
|
+
`userIdentity.user relation is undefined` when the relation is absent.
|
|
28
|
+
- `UserSession.previousRefreshTokenHash` is written and read by
|
|
29
|
+
`PrismaSessionRepository` for refresh-token replay detection (RFC 6819 §5.2.2.3).
|
|
30
|
+
|
|
31
|
+
`PrismaUserRepository.findByEmail` and `findByIdentifier` require a `tenantId` and
|
|
32
|
+
throw without one — email is stored on `user_identities`, never on `users`.
|
|
33
|
+
|
|
34
|
+
## Schema assembly and database support
|
|
35
|
+
|
|
36
|
+
When using the platform's tenant, IAM, account, notification, and OAuth Prisma
|
|
37
|
+
adapters together, concatenate their five model-only fragments into one schema
|
|
38
|
+
with exactly one generator and datasource. The packages do not publish a schema
|
|
39
|
+
generator or provider-specific copies of these models. This Node recipe writes a
|
|
40
|
+
separate schema file so you can add your application-owned models before running
|
|
41
|
+
Prisma 6:
|
|
42
|
+
|
|
43
|
+
```shell
|
|
44
|
+
mkdir -p scripts
|
|
45
|
+
cat > scripts/assemble-platform-schema.cjs <<'NODE'
|
|
46
|
+
const fs = require('node:fs');
|
|
47
|
+
const path = require('node:path');
|
|
48
|
+
|
|
49
|
+
const provider = process.env.PRISMA_PROVIDER;
|
|
50
|
+
if (provider !== 'postgresql' && provider !== 'mysql') {
|
|
51
|
+
throw new Error('Set PRISMA_PROVIDER to postgresql or mysql');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const fragments = [
|
|
55
|
+
'node_modules/@nathapp/nestjs-tenant-prisma/prisma/tenant.prisma',
|
|
56
|
+
'node_modules/@nathapp/nestjs-iam-prisma/prisma/iam.prisma',
|
|
57
|
+
'node_modules/@nathapp/nestjs-account-prisma/prisma/account.prisma',
|
|
58
|
+
'node_modules/@nathapp/nestjs-notify-prisma/prisma/notify.prisma',
|
|
59
|
+
'node_modules/@nathapp/nestjs-oauth-prisma/prisma/oauth.prisma',
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
let models = fragments.map((file) => fs.readFileSync(file, 'utf8')).join('\n\n');
|
|
63
|
+
if (provider === 'mysql') {
|
|
64
|
+
models = models.replaceAll('@db.Timestamptz(6)', '@db.DateTime(6)');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const schema = [
|
|
68
|
+
'generator client {',
|
|
69
|
+
' provider = "prisma-client-js"',
|
|
70
|
+
' output = "./client"',
|
|
71
|
+
'}',
|
|
72
|
+
'',
|
|
73
|
+
'datasource db {',
|
|
74
|
+
` provider = "${provider}"`,
|
|
75
|
+
' url = env("DATABASE_URL")',
|
|
76
|
+
'}',
|
|
77
|
+
'',
|
|
78
|
+
models,
|
|
79
|
+
'',
|
|
80
|
+
].join('\n');
|
|
81
|
+
fs.mkdirSync('prisma', { recursive: true });
|
|
82
|
+
fs.writeFileSync(path.resolve('prisma/platform.schema.prisma'), schema);
|
|
83
|
+
NODE
|
|
84
|
+
|
|
85
|
+
# PostgreSQL
|
|
86
|
+
PRISMA_PROVIDER=postgresql node ./scripts/assemble-platform-schema.cjs
|
|
87
|
+
DATABASE_URL='postgresql://user:password@localhost:5432/app' ./node_modules/.bin/prisma validate --schema prisma/platform.schema.prisma
|
|
88
|
+
./node_modules/.bin/prisma generate --schema prisma/platform.schema.prisma
|
|
89
|
+
|
|
90
|
+
# MySQL: assemble a fresh schema before validating or generating its client
|
|
91
|
+
PRISMA_PROVIDER=mysql node ./scripts/assemble-platform-schema.cjs
|
|
92
|
+
DATABASE_URL='mysql://user:password@localhost:3306/app' ./node_modules/.bin/prisma validate --schema prisma/platform.schema.prisma
|
|
93
|
+
./node_modules/.bin/prisma generate --schema prisma/platform.schema.prisma
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The commands save a testable assembly script and run it for each provider.
|
|
97
|
+
PostgreSQL keeps
|
|
98
|
+
the published `@db.Timestamptz(6)` annotations. MySQL assembly changes only that
|
|
99
|
+
native annotation to `@db.DateTime(6)`; the model bodies and their relations stay
|
|
100
|
+
the same. Validate and generate with the local Prisma 6 CLI installed by your
|
|
101
|
+
application (`./node_modules/.bin/prisma`); these commands do not need an
|
|
102
|
+
`npx` download fallback.
|
|
103
|
+
|
|
104
|
+
MySQL `DateTime(6)` stores a wall-clock value without timezone metadata. Keep
|
|
105
|
+
application values and MySQL sessions on UTC (`time_zone = '+00:00'`) so Prisma
|
|
106
|
+
round-trips UTC instants consistently. Before migrating existing local wall-clock
|
|
107
|
+
values, determine their original timezone and convert them using a consumer
|
|
108
|
+
specific migration; do not relabel them as UTC in bulk. All fragments and SQL
|
|
109
|
+
files are inputs to consumer-owned schemas and migrations; this adapter does not
|
|
110
|
+
apply migrations for you.
|
|
111
|
+
|
|
112
|
+
## Consumer migrations
|
|
113
|
+
|
|
114
|
+
### Primary identity invariant
|
|
115
|
+
|
|
116
|
+
Primary identity status is scoped by (tenant_id, user_id). The reference DDL is in prisma/sql/primary-identity.postgresql.sql and prisma/sql/primary-identity.mysql.sql; copy the statement for your database into your own migration after confirming the physical table and identifier definitions in your assembled schema. These files are reference SQL, not migrations that the adapter runs for you.
|
|
117
|
+
|
|
118
|
+
Before enabling the index, run the commented GROUP BY tenant_id, user_id HAVING COUNT(*) > 1 preflight in the chosen SQL file. If it returns rows, stop and have an operator choose which identity remains primary; the preflight does not choose or update a winner. Quiesce primary-identity writes from preflight through successful index creation. If index creation fails, rerun preflight after resolving the cause and before retrying. Deploy the clear-before-set DefaultIdentityService.setPrimary implementation before enabling the index, and ensure PrismaModule.forRoot({ transaction: true }) supplies a real interactive transaction. The service re-reads and validates the target inside the transaction, reads its siblings, clears any current primary in the same tenant, then sets the target. When no transaction manager is configured it keeps the warning-backed sequential fallback, which is non-atomic.
|
|
119
|
+
|
|
120
|
+
Keep full tenant_id and user_id comparisons in the unique index. Do not replace it with a normal unique (tenant_id, user_id, is_primary) key; that would allow only one secondary identity per user. Preserve these custom indexes in future consumer migrations.
|
|
121
|
+
|
|
122
|
+
Run the real PostgreSQL 16 and MySQL 8.0 acceptance suites locally with Docker: npm run test:db --workspace=@nathapp/nestjs-iam-prisma. Explicit runs fail when Docker is unavailable.
|
|
123
|
+
|
|
124
|
+
### Long-text columns (MySQL)
|
|
125
|
+
|
|
126
|
+
A bare `String` maps to `VARCHAR(191)` on MySQL. Columns whose values can exceed
|
|
127
|
+
that now carry `@db.Text`: the SSO account's encrypted access/refresh tokens, the
|
|
128
|
+
SSO provider's `issuer`, encrypted client secret and `redirect_uri`, session and
|
|
129
|
+
login-history `user_agent`, and `avatar_url`. Before this, an SSO login with a
|
|
130
|
+
JWT-sized IdP token failed on MySQL. Upgrade a MySQL database built from an
|
|
131
|
+
earlier fragment with `prisma/sql/long-text-columns.mysql.sql`. PostgreSQL needs
|
|
132
|
+
nothing: `String` is already `text` there.
|
|
133
|
+
|
|
134
|
+
### API-key scopes
|
|
135
|
+
|
|
136
|
+
The shipped `ApiKey` fragment stores `scopes` as `Json @default("[]")`. The
|
|
137
|
+
domain API remains `string[]`; the adapter accepts only a native JSON array of
|
|
138
|
+
strings. Do not keep `String[]` in a custom `ApiKey` model or pass JSON text to
|
|
139
|
+
the adapter.
|
|
140
|
+
|
|
141
|
+
For a new install, assemble the updated fragment into your schema and generate
|
|
142
|
+
the Prisma client before deploying this adapter. For an existing PostgreSQL
|
|
143
|
+
database, copy `prisma/sql/api-key-scopes.postgresql.sql` into your own
|
|
144
|
+
migration, review the physical table and column names, and run it before
|
|
145
|
+
deploying the regenerated client and adapter. The file is reference SQL; the
|
|
146
|
+
adapter never runs consumer migrations.
|
|
147
|
+
|
|
148
|
+
The PostgreSQL conversion takes an `ACCESS EXCLUSIVE` table lock for its
|
|
149
|
+
transaction. Schedule a maintenance window, stop API-key writes, and rehearse
|
|
150
|
+
the migration against a recent database copy. Its preflight rejects NULL scope
|
|
151
|
+
arrays and arrays containing NULL entries. Resolve those rows explicitly before
|
|
152
|
+
retrying; the migration does not invent or discard grants. Valid arrays are
|
|
153
|
+
converted with `to_jsonb(scopes)`, preserving `[]`, `['read']`, and other
|
|
154
|
+
existing values, then the column receives a JSONB `[]` default and `NOT NULL`.
|
|
155
|
+
|
|
156
|
+
The old scalar-list client and the new JSON client are not interchangeable:
|
|
157
|
+
Prisma uses different operations for those field types. Apply the schema
|
|
158
|
+
migration, regenerate every consumer client, and deploy the adapter as one
|
|
159
|
+
coordinated cutover. If a maintenance window is not possible, use an
|
|
160
|
+
application-specific expand/contract plan with a shadow JSON column and dual
|
|
161
|
+
writes; retire every old client before cutting over. This adapter maps one
|
|
162
|
+
`scopes` column and does not provide the temporary dual-write path.
|
|
163
|
+
|
|
164
|
+
MySQL consumers can assemble the same `ApiKey` JSON model or update a custom
|
|
165
|
+
model to match it, then regenerate the client. With Prisma 6, the generated
|
|
166
|
+
MySQL table has `scopes JSON NOT NULL` but no SQL-level default; Prisma Client
|
|
167
|
+
applies the schema's `[]` default when a create call omits `scopes`. Raw SQL
|
|
168
|
+
inserts must supply the scopes value or add a consumer-owned MySQL default.
|
|
169
|
+
Consumers that omitted `ApiKey` from their schema must add the model and apply
|
|
170
|
+
their own schema migration before using the repository.
|
|
171
|
+
|
|
172
|
+
The `WebAuthnCredential` fragment is MySQL-portable only after a data migration.
|
|
173
|
+
These are fragments; **the adapter ships no migration** — you assemble them into
|
|
174
|
+
your own Prisma schema and migrations. Apply one authoritative sequence:
|
|
175
|
+
|
|
176
|
+
1. Add the `credential_id_hash` column.
|
|
177
|
+
2. Backfill `credential_id_hash`.
|
|
178
|
+
3. Set `credential_id_hash` NOT NULL.
|
|
179
|
+
4. Add the new unique index on `credential_id_hash`.
|
|
180
|
+
5. Drop the old unique object on `credential_id` (`webauthn_credentials_credential_id_key`).
|
|
181
|
+
6. Convert `credential_id` and `public_key` to `TEXT`.
|
|
182
|
+
|
|
183
|
+
MySQL:
|
|
184
|
+
|
|
185
|
+
```sql
|
|
186
|
+
ALTER TABLE webauthn_credentials
|
|
187
|
+
ADD COLUMN credential_id_hash VARCHAR(64) NULL;
|
|
188
|
+
|
|
189
|
+
UPDATE webauthn_credentials SET credential_id_hash = SHA2(credential_id, 256);
|
|
190
|
+
|
|
191
|
+
ALTER TABLE webauthn_credentials
|
|
192
|
+
MODIFY COLUMN credential_id_hash VARCHAR(64) NOT NULL;
|
|
193
|
+
|
|
194
|
+
ALTER TABLE webauthn_credentials
|
|
195
|
+
ADD UNIQUE INDEX webauthn_credentials_credential_id_hash_key (credential_id_hash);
|
|
196
|
+
|
|
197
|
+
ALTER TABLE webauthn_credentials
|
|
198
|
+
DROP INDEX webauthn_credentials_credential_id_key;
|
|
199
|
+
|
|
200
|
+
ALTER TABLE webauthn_credentials
|
|
201
|
+
MODIFY COLUMN credential_id TEXT NOT NULL,
|
|
202
|
+
MODIFY COLUMN public_key TEXT NOT NULL;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
PostgreSQL:
|
|
206
|
+
|
|
207
|
+
```sql
|
|
208
|
+
ALTER TABLE webauthn_credentials ADD COLUMN credential_id_hash varchar(64);
|
|
209
|
+
UPDATE webauthn_credentials SET credential_id_hash = encode(sha256(convert_to(credential_id, 'UTF8')), 'hex');
|
|
210
|
+
ALTER TABLE webauthn_credentials ALTER COLUMN credential_id_hash SET NOT NULL;
|
|
211
|
+
CREATE UNIQUE INDEX "webauthn_credentials_credential_id_hash_key" ON webauthn_credentials (credential_id_hash);
|
|
212
|
+
DROP INDEX "webauthn_credentials_credential_id_key";
|
|
213
|
+
ALTER TABLE webauthn_credentials ALTER COLUMN credential_id TYPE text, ALTER COLUMN public_key TYPE text;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Ordering matters.** Backfill `credential_id_hash` **BEFORE** adding the NOT NULL
|
|
217
|
+
constraint and **BEFORE** the new unique index — not after. Create the new unique
|
|
218
|
+
index **BEFORE** dropping the old one: adding NOT NULL before the backfill fails on
|
|
219
|
+
existing rows, and dropping the old unique index before the new one exists leaves
|
|
220
|
+
the table without a credential-ID uniqueness guarantee. Backfill with
|
|
221
|
+
`convert_to(credential_id, 'UTF8')` on PostgreSQL, not `credential_id::bytea`: the
|
|
222
|
+
`bytea` cast interprets backslash escapes instead of hashing the text's bytes.
|
|
223
|
+
|
|
224
|
+
On MySQL the old unique index must also be dropped **BEFORE**
|
|
225
|
+
`credential_id` is converted to `TEXT`: MySQL rejects altering an indexed column to
|
|
226
|
+
`TEXT` while its single-column index still exists (error 1170).
|
|
227
|
+
|
|
228
|
+
The old unique object is Prisma's default `@map("credential_id")` name,
|
|
229
|
+
`webauthn_credentials_credential_id_key`, and Prisma Migrate emits it as a unique
|
|
230
|
+
index on both engines (so PostgreSQL uses a standalone `DROP INDEX`, not `ALTER TABLE ... DROP CONSTRAINT`; `ALTER TABLE ... DROP INDEX` is MySQL-only syntax). If
|
|
231
|
+
the database predates Prisma's naming convention, confirm the object name first
|
|
232
|
+
(`SHOW INDEX FROM webauthn_credentials` on MySQL; `\d webauthn_credentials` on
|
|
233
|
+
PostgreSQL).
|
|
234
|
+
|
|
235
|
+
`credential_id_hash` is **SHA-256 hex** (64 characters, `VARCHAR(64)`). Backfill it
|
|
236
|
+
with `SHA2(credential_id, 256)` on MySQL or
|
|
237
|
+
`encode(sha256(convert_to(credential_id, 'UTF8')), 'hex')` on PostgreSQL.
|
|
238
|
+
|
|
239
|
+
Direct `findUnique({ where: { credentialId } })` queries no longer type-check or
|
|
240
|
+
work — the old `credential_id` unique index is gone. Use `findByCredentialId`,
|
|
241
|
+
which looks up by hash, falls back to the raw column, and back-fills the hash on
|
|
242
|
+
read.
|
|
243
|
+
|
|
244
|
+
## Register
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { Module } from '@nestjs/common';
|
|
248
|
+
import { PrismaClient } from '@prisma/client';
|
|
249
|
+
import { ClockModule } from '@nathapp/nestjs-common';
|
|
250
|
+
import { PrismaModule } from '@nathapp/nestjs-prisma';
|
|
251
|
+
import { IamPrismaModule } from '@nathapp/nestjs-iam-prisma';
|
|
252
|
+
|
|
253
|
+
@Module({
|
|
254
|
+
imports: [
|
|
255
|
+
PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
|
|
256
|
+
ClockModule.register(), // provides CLOCK, required by PrismaSessionRepository
|
|
257
|
+
IamPrismaModule.register(),
|
|
258
|
+
],
|
|
259
|
+
})
|
|
260
|
+
export class AppModule {}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`ClockModule.register()` is not optional for this adapter.
|
|
264
|
+
`PrismaSessionRepository` injects `CLOCK` non-optionally for revocation timestamps
|
|
265
|
+
and expired-session sweeps, and no library package in this platform provides it
|
|
266
|
+
for you — omit it and Nest reports
|
|
267
|
+
`Nest can't resolve dependencies of the PrismaSessionRepository (Symbol(TRANSACTION_MANAGER), ?)`.
|
|
268
|
+
Please make sure that the argument Symbol(CLOCK) at index [1] is available in the
|
|
269
|
+
IamPrismaModule module.
|
|
270
|
+
|
|
271
|
+
`register()` takes an optional options object:
|
|
272
|
+
|
|
273
|
+
| Option | Type | Default | Meaning |
|
|
274
|
+
|---|---|---|---|
|
|
275
|
+
| `global` | `boolean` | `true` | Register as a global module so the repository tokens resolve anywhere. |
|
|
276
|
+
|
|
277
|
+
`register()` is the only import form for this adapter. There is no `registerAsync`.
|
|
278
|
+
|
|
279
|
+
### If you already wrap this adapter in `@Global()`
|
|
280
|
+
|
|
281
|
+
Pass `global: false`. Otherwise the adapter's own global exports are injected
|
|
282
|
+
**in addition to** your override, and last-registration-wins silently decides
|
|
283
|
+
which implementation is used:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { Global, Module } from '@nestjs/common';
|
|
287
|
+
import { ClockModule } from '@nathapp/nestjs-common';
|
|
288
|
+
import { USER_REPOSITORY } from '@nathapp/nestjs-iam';
|
|
289
|
+
import { IamPrismaModule } from '@nathapp/nestjs-iam-prisma';
|
|
290
|
+
import { CachedUserRepository } from './cached-user.repository';
|
|
291
|
+
|
|
292
|
+
@Global()
|
|
293
|
+
@Module({
|
|
294
|
+
imports: [
|
|
295
|
+
ClockModule.register(), // required by PrismaSessionRepository
|
|
296
|
+
IamPrismaModule.register({ global: false }),
|
|
297
|
+
],
|
|
298
|
+
providers: [{ provide: USER_REPOSITORY, useClass: CachedUserRepository }],
|
|
299
|
+
exports: [USER_REPOSITORY],
|
|
300
|
+
})
|
|
301
|
+
export class PrismaOverridesModule {}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`global: false` only helps if the adapter is registered once. A second, global
|
|
305
|
+
`register()` elsewhere in the app keeps its global exports, and `global: false`
|
|
306
|
+
here does not remove them — so the collision this section exists to prevent is
|
|
307
|
+
still there. Register the adapter in exactly one place.
|
|
308
|
+
|
|
309
|
+
The `global` option carries no documentation in the published type definitions
|
|
310
|
+
(`removeComments: true` strips the JSDoc from the emitted `.d.ts`), so this README
|
|
311
|
+
is where it is described. The options object is typed as `PrismaAdapterModuleOptions`,
|
|
312
|
+
which is exported from this package if you need to name the type.
|
|
313
|
+
|
|
314
|
+
## Transactions
|
|
315
|
+
|
|
316
|
+
Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`.
|
|
317
|
+
Every repository resolves its client per operation from the `TRANSACTION_MANAGER`
|
|
318
|
+
token, and the two `PrismaModule` registration paths fail differently when
|
|
319
|
+
`transaction` is omitted:
|
|
320
|
+
|
|
321
|
+
- `PrismaModule.forRoot()` binds `TRANSACTION_MANAGER` only when `transaction: true`
|
|
322
|
+
is set. Without it nothing is bound, the repositories cannot resolve their
|
|
323
|
+
dependency, and Nest fails at boot.
|
|
324
|
+
- `PrismaModule.forRootAsync()` always binds the token, but with a manager whose
|
|
325
|
+
`run()` and `getClient()` throw and whose `isInTransaction()` returns `false`, so
|
|
326
|
+
the app boots and fails on first use instead.
|
|
327
|
+
|
|
328
|
+
Neither path is a silent passthrough: a real transaction manager either joins the
|
|
329
|
+
transaction already in scope or opens a Prisma interactive transaction.
|
|
330
|
+
|
|
331
|
+
Both of those are `PrismaModule` from `@nathapp/nestjs-prisma`. These adapters
|
|
332
|
+
expose only the synchronous `register()`; they have no `registerAsync`.
|
|
333
|
+
|
|
334
|
+
`DefaultUserService.register()` is the case that matters most: it creates a
|
|
335
|
+
`User` and a `UserIdentity` in two repository calls, and only rolls them back
|
|
336
|
+
together when `run()` is backed by a real interactive transaction.
|
|
337
|
+
|
|
338
|
+
## Tokens bound
|
|
339
|
+
|
|
340
|
+
| Token | Implementation |
|
|
341
|
+
|---|---|
|
|
342
|
+
| `USER_REPOSITORY` | `PrismaUserRepository` |
|
|
343
|
+
| `USER_IDENTITY_REPOSITORY` | `PrismaIdentityRepository` |
|
|
344
|
+
| `SESSION_REPOSITORY` | `PrismaSessionRepository` |
|
|
345
|
+
| `MFA_REPOSITORY` | `PrismaMfaRepository` |
|
|
346
|
+
| `SSO_ACCOUNT_REPOSITORY` | `PrismaSsoAccountRepository` |
|
|
347
|
+
| `SSO_PROVIDER_REPOSITORY` | `PrismaSsoProviderRepository` |
|
|
348
|
+
| `LOGIN_HISTORY_REPOSITORY` | `PrismaLoginHistoryRepository` |
|
|
349
|
+
| `VERIFICATION_TOKEN_REPOSITORY` | `PrismaVerificationTokenRepository` |
|
|
350
|
+
| `API_KEY_REPOSITORY` | `PrismaApiKeyRepository` |
|
|
351
|
+
| `WEBAUTHN_CREDENTIAL_REPOSITORY` | `PrismaWebAuthnCredentialRepository` |
|
|
352
|
+
| `WEBAUTHN_MFA_BINDING_STORE` | `PrismaWebAuthnMfaBindingStore` |
|
|
353
|
+
| `TOTP_REPLAY_STORE` | `PrismaTotpReplayStore` |
|
|
354
|
+
| `AUTH_ATTEMPT_STORE` | `PrismaAuthAttemptStore` |
|
|
355
|
+
|
|
356
|
+
The last three are store seams rather than repositories — they back the
|
|
357
|
+
WebAuthn MFA binding lookup, TOTP replay detection, and failed-verification
|
|
358
|
+
attempt counting (which trips `VERIFICATION_RATE_LIMIT`) respectively.
|
|
359
|
+
|
|
360
|
+
`PrismaSsoAccountRepository` reads and writes `accessTokenEnc` / `refreshTokenEnc`
|
|
361
|
+
exclusively; the unencrypted `accessToken` / `refreshToken` keys are not used.
|
package/codex.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Codex Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-iam-prisma`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/nestjs-oauth-prisma, @nathapp/nestjs-prisma, @prisma/client, prisma, typescript
|
|
17
|
+
|
|
18
|
+
**Commands:** test: `npm run test` | lint: `npm run lint` | typecheck: `npm run type-check`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
# CLAUDE.md — @nathapp/nestjs-iam-prisma
|
|
22
|
+
|
|
23
|
+
Prisma adapter for `@nathapp/nestjs-iam`. Implements all 8 repository interfaces using `AbstractPrismaRepository` from `@nathapp/nestjs-prisma`.
|
|
24
|
+
|
|
25
|
+
## Status: ✅ Complete
|
|
26
|
+
|
|
27
|
+
## Implemented Repositories
|
|
28
|
+
|
|
29
|
+
All 8 repositories extend `AbstractPrismaRepository` and resolve their Prisma client per-operation from `TRANSACTION_MANAGER`.
|
|
30
|
+
|
|
31
|
+
- `PrismaUserRepository` → `USER_REPOSITORY`
|
|
32
|
+
- `PrismaIdentityRepository` → `USER_IDENTITY_REPOSITORY`
|
|
33
|
+
- `PrismaSessionRepository` → `SESSION_REPOSITORY`
|
|
34
|
+
- `PrismaLoginHistoryRepository` → `LOGIN_HISTORY_REPOSITORY`
|
|
35
|
+
- `PrismaSsoAccountRepository` → `SSO_ACCOUNT_REPOSITORY`
|
|
36
|
+
- `PrismaSsoProviderRepository` → `SSO_PROVIDER_REPOSITORY`
|
|
37
|
+
- `PrismaMfaRepository` → `MFA_REPOSITORY`
|
|
38
|
+
- `PrismaVerificationTokenRepository` → `VERIFICATION_TOKEN_REPOSITORY`
|
|
39
|
+
|
|
40
|
+
`IamPrismaModule` registers all repositories with their DI tokens.
|
|
41
|
+
|
|
42
|
+
## Module Registration
|
|
43
|
+
|
|
44
|
+
`IamPrismaModule.register()` takes no arguments. Consumer wiring:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
PrismaModule.forRoot({ client: PrismaClient, transaction: true, isGlobal: true })
|
|
48
|
+
IamModule.register({...})
|
|
49
|
+
IamPrismaModule.register() // no args
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> **`transaction: true` is mandatory.** `DefaultUserService.register()` creates a User and an Identity in two separate repository calls. Both are wrapped in `txManager.run()` so they roll back together on failure — but only if `TRANSACTION_MANAGER` is backed by a real Prisma interactive transaction. Without `transaction: true`, `txManager.run()` is a passthrough and a failure between the two writes leaves an orphaned User with no Identity.
|
|
53
|
+
|
|
54
|
+
`PrismaModule.forRoot` (from `@nathapp/nestjs-prisma`) provides both the Prisma client and `TRANSACTION_MANAGER`. All repositories resolve the client from `TRANSACTION_MANAGER` at operation time, enabling automatic transaction propagation.
|
|
55
|
+
|
|
56
|
+
## Dependencies
|
|
57
|
+
|
|
58
|
+
- `@nathapp/nestjs-iam` (workspace)
|
|
59
|
+
- `@nathapp/nestjs-prisma` ^3.2.0 (peer) — provides `AbstractPrismaRepository` and `PrismaModule`
|
|
60
|
+
- `@prisma/client` ^6.0.0 (peer)
|
|
61
|
+
|
|
62
|
+
## Schema conventions
|
|
63
|
+
|
|
64
|
+
For PostgreSQL, `DateTime` fields in the consumer's IAM models (User, Identity, Session, LoginHistory, SsoAccount, Mfa, VerificationToken) MUST use `@db.Timestamptz(6)`:
|
|
65
|
+
|
|
66
|
+
```prisma
|
|
67
|
+
createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
|
|
68
|
+
updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
|
|
69
|
+
expiresAt DateTime @db.Timestamptz(6) @map("expires_at")
|
|
70
|
+
revokedAt DateTime? @db.Timestamptz(6) @map("revoked_at")
|
|
71
|
+
consumedAt DateTime? @db.Timestamptz(6) @map("consumed_at")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is not correct for these PostgreSQL fields.
|
|
75
|
+
|
|
76
|
+
### PostgreSQL and MySQL fragment assembly
|
|
77
|
+
|
|
78
|
+
- The tenant, IAM, account, notify, and OAuth Prisma files are model-only fragments. Assemble them into one schema with one generator and datasource; keep each model body and cross-package relation intact.
|
|
79
|
+
- Published fragments retain `@db.Timestamptz(6)` for PostgreSQL. For a MySQL schema, replace only that native annotation with `@db.DateTime(6)` in the assembled output. Do not edit or publish provider-specific copies of the fragments.
|
|
80
|
+
- MySQL `DateTime(6)` stores a wall-clock value without timezone metadata. Keep application values and MySQL sessions on UTC (`time_zone = '+00:00'`). Existing local wall-clock values need a consumer-specific timezone conversion during migration; do not relabel them all as UTC.
|
|
81
|
+
- The adapter README has a copyable Node / Prisma 6 recipe. Its portability test assembles and validates all five fragments with the local Prisma CLI, and confirms that unreplaced `Timestamptz(6)` is rejected for MySQL.
|
|
82
|
+
|
|
83
|
+
When migrating an existing database:
|
|
84
|
+
```sql
|
|
85
|
+
ALTER TABLE <table> ALTER COLUMN <col> TYPE TIMESTAMPTZ(6) USING <col> AT TIME ZONE 'UTC';
|
|
86
|
+
```
|
|
87
|
+
Run one statement per column. Verify `SHOW timezone;` returns `UTC` before migrating production data.
|
|
88
|
+
|
|
89
|
+
## UserSsoAccount schema contract
|
|
90
|
+
|
|
91
|
+
- `accessTokenEnc` and `refreshTokenEnc` store encrypted OAuth/OIDC token values; `PrismaSsoAccountRepository` reads and writes these fields exclusively.
|
|
92
|
+
- If an existing database still uses `access_token` or `refresh_token`, rename them before regenerating the Prisma client:
|
|
93
|
+
|
|
94
|
+
```sql
|
|
95
|
+
ALTER TABLE "user_sso_accounts" RENAME COLUMN "access_token" TO "access_token_enc";
|
|
96
|
+
ALTER TABLE "user_sso_accounts" RENAME COLUMN "refresh_token" TO "refresh_token_enc";
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## UserSession schema contract
|
|
100
|
+
|
|
101
|
+
The consumer's `UserSession` Prisma model MUST include a nullable `previousRefreshTokenHash` column, snake-cased via `@map`. `PrismaSessionRepository.rotateRefreshToken` writes it as part of the CAS, and `PrismaSessionRepository.findByPreviousRefreshToken` reads it to detect OAuth refresh-token replay (RFC 6819 §5.2.2.3).
|
|
102
|
+
|
|
103
|
+
```prisma
|
|
104
|
+
model UserSession {
|
|
105
|
+
id String @id @default(uuid())
|
|
106
|
+
// ... other columns ...
|
|
107
|
+
refreshTokenHash String @map("refresh_token_hash")
|
|
108
|
+
previousRefreshTokenHash String? @map("previous_refresh_token_hash")
|
|
109
|
+
// ... other columns ...
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
A composite index on `(previousRefreshTokenHash)` is recommended for replay-detection lookups: replay attempts are rare but latency-sensitive.
|
|
114
|
+
|
|
115
|
+
This follows the SSO-registry-model precedent: the iam-prisma adapter ships no `.prisma` schema or migration, and the consumer's Prisma model is the schema-of-record for fields the adapter reads or writes.
|
|
116
|
+
|
|
117
|
+
## UserIdentity → User relation contract
|
|
118
|
+
|
|
119
|
+
`PrismaUserRepository.findByEmail` resolves the user by joining it from the EMAIL identity via `include: { user: true }`. The consumer's `UserIdentity` Prisma model MUST therefore declare the relation to `User`, and `User` the reverse `identities` field. The shipped `prisma/iam.prisma` fragment declares both, so consumers who assemble their schema from the fragment get a working client out of the box:
|
|
120
|
+
|
|
121
|
+
```prisma
|
|
122
|
+
model User {
|
|
123
|
+
// ...
|
|
124
|
+
identities UserIdentity[]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
model UserIdentity {
|
|
128
|
+
userId String @map("user_id")
|
|
129
|
+
// ...
|
|
130
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The FK column (`user_id`) already exists with valid data, so adopting the relation on an existing database is a single additive migration with no data-loss risk:
|
|
135
|
+
|
|
136
|
+
```sql
|
|
137
|
+
ALTER TABLE "user_identities"
|
|
138
|
+
ADD CONSTRAINT "user_identities_user_id_fkey"
|
|
139
|
+
FOREIGN KEY ("user_id") REFERENCES "users"("id")
|
|
140
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Without the relation, `findByEmail` throws `PrismaClientValidationError: Unknown field `user` for include statement on model `UserIdentity``. This follows the same schema-of-record precedent as the UserSession contract.
|
|
144
|
+
|
|
145
|
+
## Primary Identity Migration and Acceptance Tests
|
|
146
|
+
|
|
147
|
+
- Primary uniqueness is consumer-owned migration SQL in `prisma/sql/primary-identity.postgresql.sql` and `prisma/sql/primary-identity.mysql.sql`; these are reference statements, not migrations run by this adapter. Run the duplicate-primary preflight first and have an operator choose any cleanup. Deploy the IAM clear-before-set code before enabling the index.
|
|
148
|
+
- Atomic switches require `PrismaModule.forRoot({ transaction: true })` to provide a real interactive transaction manager. The IAM service's no-manager fallback only performs sequential writes and is not atomic. The adapter maps primary-index `P2002` conflicts from `isPrimary: true` creates and updates to IAM code 22035 / HTTP 409, while preserving unrelated duplicate-identity errors.
|
|
149
|
+
- Run real disposable PostgreSQL 16 and MySQL 8.0 acceptance tests with `npm run test:db --workspace=@nathapp/nestjs-iam-prisma`; Docker is required, and an explicitly invoked run must fail if its container runtime is unavailable.
|
|
150
|
+
|
|
151
|
+
## API-key Scope Schema and Migration
|
|
152
|
+
|
|
153
|
+
- Keep the domain contract `ApiKey.scopes: string[]`. The shipped `ApiKey` model stores scopes as `Json @default("[]")`; its database row type is `unknown` and the adapter's local strict decoder accepts only arrays containing strings. Do not parse JSON text, filter mixed arrays, or change shared `readStringArray` behavior.
|
|
154
|
+
- The PostgreSQL reference migration is `prisma/sql/api-key-scopes.postgresql.sql`. It is consumer-owned SQL, not a migration the adapter applies. It locks `api_keys`, rejects NULL arrays and NULL elements for operator repair, converts with `to_jsonb(scopes)`, sets the JSONB `[]` default, and enforces `NOT NULL` in one transaction. Conversion preserves all valid existing arrays.
|
|
155
|
+
- Coordinate the PostgreSQL conversion, Prisma client regeneration, and adapter deployment in a maintenance window because the migration takes an `ACCESS EXCLUSIVE` lock and old scalar-list and new JSON clients are not interchangeable. If zero downtime is required, consumers need their own shadow-column/dual-write expand-contract path and must retire old clients before cutover.
|
|
156
|
+
- MySQL consumers that omitted `ApiKey` or use a custom model must add/update the model to JSON and regenerate their client. With Prisma 6, generated MySQL DDL does not emit a SQL-level default for JSON; Prisma Client still applies `[]` when a create call omits scopes. Raw SQL inserts must supply scopes or use a consumer-owned database default.
|
|
157
|
+
- The DB acceptance suite assembles the published IAM fragment directly for PostgreSQL and MySQL, changing only MySQL's `@db.Timestamptz(6)` annotation to `@db.DateTime(6)`. A separate portability test validates the tenant, IAM, account, notify, and OAuth fragments together for both providers.
|
|
158
|
+
- Timezone round-trip acceptance writes and reads `2026-10-04T08:00:00.123Z` on the same interactive-transaction connection with MySQL session time zone `+00:00` and PostgreSQL session time zone `+08:00`. Restore MySQL session state after the proof; PostgreSQL uses transaction-local timezone state.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashCredentialId(credentialId: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashCredentialId = hashCredentialId;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
function hashCredentialId(credentialId) {
|
|
6
|
+
return (0, node_crypto_1.createHash)('sha256').update(credentialId).digest('hex');
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=credential-id-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-id-hash.js","sourceRoot":"","sources":["../lib/credential-id-hash.ts"],"names":[],"mappings":";;AAcA,4CAEC;AAhBD,6CAAyC;AAczC,SAAgB,gBAAgB,CAAC,YAAoB;IACnD,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var IamPrismaModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.IamPrismaModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const nestjs_iam_1 = require("@nathapp/nestjs-iam");
|
|
13
|
+
const prisma_user_repository_1 = require("./prisma-user.repository");
|
|
14
|
+
const prisma_identity_repository_1 = require("./prisma-identity.repository");
|
|
15
|
+
const prisma_session_repository_1 = require("./prisma-session.repository");
|
|
16
|
+
const prisma_mfa_repository_1 = require("./prisma-mfa.repository");
|
|
17
|
+
const prisma_sso_account_repository_1 = require("./prisma-sso-account.repository");
|
|
18
|
+
const prisma_sso_provider_repository_1 = require("./prisma-sso-provider.repository");
|
|
19
|
+
const prisma_login_history_repository_1 = require("./prisma-login-history.repository");
|
|
20
|
+
const prisma_verification_token_repository_1 = require("./prisma-verification-token.repository");
|
|
21
|
+
const prisma_api_key_repository_1 = require("./prisma-api-key.repository");
|
|
22
|
+
const prisma_webauthn_credential_repository_1 = require("./prisma-webauthn-credential.repository");
|
|
23
|
+
const prisma_webauthn_mfa_binding_store_1 = require("./prisma-webauthn-mfa-binding.store");
|
|
24
|
+
const prisma_totp_replay_store_1 = require("./prisma-totp-replay.store");
|
|
25
|
+
const prisma_auth_attempt_store_1 = require("./prisma-auth-attempt.store");
|
|
26
|
+
let IamPrismaModule = IamPrismaModule_1 = class IamPrismaModule {
|
|
27
|
+
static register(options) {
|
|
28
|
+
var _a;
|
|
29
|
+
return {
|
|
30
|
+
module: IamPrismaModule_1,
|
|
31
|
+
global: (_a = options === null || options === void 0 ? void 0 : options.global) !== null && _a !== void 0 ? _a : true,
|
|
32
|
+
providers: [
|
|
33
|
+
prisma_user_repository_1.PrismaUserRepository,
|
|
34
|
+
{ provide: nestjs_iam_1.USER_REPOSITORY, useExisting: prisma_user_repository_1.PrismaUserRepository },
|
|
35
|
+
prisma_identity_repository_1.PrismaIdentityRepository,
|
|
36
|
+
{ provide: nestjs_iam_1.USER_IDENTITY_REPOSITORY, useExisting: prisma_identity_repository_1.PrismaIdentityRepository },
|
|
37
|
+
prisma_session_repository_1.PrismaSessionRepository,
|
|
38
|
+
{ provide: nestjs_iam_1.SESSION_REPOSITORY, useExisting: prisma_session_repository_1.PrismaSessionRepository },
|
|
39
|
+
prisma_mfa_repository_1.PrismaMfaRepository,
|
|
40
|
+
{ provide: nestjs_iam_1.MFA_REPOSITORY, useExisting: prisma_mfa_repository_1.PrismaMfaRepository },
|
|
41
|
+
prisma_sso_account_repository_1.PrismaSsoAccountRepository,
|
|
42
|
+
{ provide: nestjs_iam_1.SSO_ACCOUNT_REPOSITORY, useExisting: prisma_sso_account_repository_1.PrismaSsoAccountRepository },
|
|
43
|
+
prisma_sso_provider_repository_1.PrismaSsoProviderRepository,
|
|
44
|
+
{ provide: nestjs_iam_1.SSO_PROVIDER_REPOSITORY, useExisting: prisma_sso_provider_repository_1.PrismaSsoProviderRepository },
|
|
45
|
+
prisma_login_history_repository_1.PrismaLoginHistoryRepository,
|
|
46
|
+
{ provide: nestjs_iam_1.LOGIN_HISTORY_REPOSITORY, useExisting: prisma_login_history_repository_1.PrismaLoginHistoryRepository },
|
|
47
|
+
prisma_verification_token_repository_1.PrismaVerificationTokenRepository,
|
|
48
|
+
{ provide: nestjs_iam_1.VERIFICATION_TOKEN_REPOSITORY, useExisting: prisma_verification_token_repository_1.PrismaVerificationTokenRepository },
|
|
49
|
+
prisma_api_key_repository_1.PrismaApiKeyRepository,
|
|
50
|
+
{ provide: nestjs_iam_1.API_KEY_REPOSITORY, useExisting: prisma_api_key_repository_1.PrismaApiKeyRepository },
|
|
51
|
+
prisma_webauthn_credential_repository_1.PrismaWebAuthnCredentialRepository,
|
|
52
|
+
{ provide: nestjs_iam_1.WEBAUTHN_CREDENTIAL_REPOSITORY, useExisting: prisma_webauthn_credential_repository_1.PrismaWebAuthnCredentialRepository },
|
|
53
|
+
prisma_webauthn_mfa_binding_store_1.PrismaWebAuthnMfaBindingStore,
|
|
54
|
+
{ provide: nestjs_iam_1.WEBAUTHN_MFA_BINDING_STORE, useExisting: prisma_webauthn_mfa_binding_store_1.PrismaWebAuthnMfaBindingStore },
|
|
55
|
+
prisma_totp_replay_store_1.PrismaTotpReplayStore,
|
|
56
|
+
{ provide: nestjs_iam_1.TOTP_REPLAY_STORE, useExisting: prisma_totp_replay_store_1.PrismaTotpReplayStore },
|
|
57
|
+
prisma_auth_attempt_store_1.PrismaAuthAttemptStore,
|
|
58
|
+
{ provide: nestjs_iam_1.AUTH_ATTEMPT_STORE, useExisting: prisma_auth_attempt_store_1.PrismaAuthAttemptStore },
|
|
59
|
+
],
|
|
60
|
+
exports: [
|
|
61
|
+
nestjs_iam_1.USER_REPOSITORY, nestjs_iam_1.USER_IDENTITY_REPOSITORY, nestjs_iam_1.SESSION_REPOSITORY, nestjs_iam_1.MFA_REPOSITORY,
|
|
62
|
+
nestjs_iam_1.SSO_ACCOUNT_REPOSITORY, nestjs_iam_1.SSO_PROVIDER_REPOSITORY, nestjs_iam_1.LOGIN_HISTORY_REPOSITORY,
|
|
63
|
+
nestjs_iam_1.VERIFICATION_TOKEN_REPOSITORY, nestjs_iam_1.API_KEY_REPOSITORY, nestjs_iam_1.WEBAUTHN_CREDENTIAL_REPOSITORY,
|
|
64
|
+
nestjs_iam_1.WEBAUTHN_MFA_BINDING_STORE, nestjs_iam_1.TOTP_REPLAY_STORE, nestjs_iam_1.AUTH_ATTEMPT_STORE,
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.IamPrismaModule = IamPrismaModule;
|
|
70
|
+
exports.IamPrismaModule = IamPrismaModule = IamPrismaModule_1 = __decorate([
|
|
71
|
+
(0, common_1.Module)({})
|
|
72
|
+
], IamPrismaModule);
|
|
73
|
+
//# sourceMappingURL=iam-prisma.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam-prisma.module.js","sourceRoot":"","sources":["../lib/iam-prisma.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,oDAK6B;AAC7B,qEAAgE;AAChE,6EAAwE;AACxE,2EAAsE;AACtE,mEAA8D;AAC9D,mFAA6E;AAC7E,qFAA+E;AAC/E,uFAAiF;AACjF,iGAA2F;AAC3F,2EAAqE;AACrE,mGAA6F;AAC7F,2FAAoF;AACpF,yEAAmE;AACnE,2EAAqE;AAoB9D,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,OAAoC;;QAClD,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,MAAM,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,IAAI;YAC/B,SAAS,EAAE;gBACT,6CAAoB;gBACpB,EAAE,OAAO,EAAE,4BAAe,EAAE,WAAW,EAAE,6CAAoB,EAAE;gBAC/D,qDAAwB;gBACxB,EAAE,OAAO,EAAE,qCAAwB,EAAE,WAAW,EAAE,qDAAwB,EAAE;gBAC5E,mDAAuB;gBACvB,EAAE,OAAO,EAAE,+BAAkB,EAAE,WAAW,EAAE,mDAAuB,EAAE;gBACrE,2CAAmB;gBACnB,EAAE,OAAO,EAAE,2BAAc,EAAE,WAAW,EAAE,2CAAmB,EAAE;gBAC7D,0DAA0B;gBAC1B,EAAE,OAAO,EAAE,mCAAsB,EAAE,WAAW,EAAE,0DAA0B,EAAE;gBAC5E,4DAA2B;gBAC3B,EAAE,OAAO,EAAE,oCAAuB,EAAE,WAAW,EAAE,4DAA2B,EAAE;gBAC9E,8DAA4B;gBAC5B,EAAE,OAAO,EAAE,qCAAwB,EAAE,WAAW,EAAE,8DAA4B,EAAE;gBAChF,wEAAiC;gBACjC,EAAE,OAAO,EAAE,0CAA6B,EAAE,WAAW,EAAE,wEAAiC,EAAE;gBAC1F,kDAAsB;gBACtB,EAAE,OAAO,EAAE,+BAAkB,EAAE,WAAW,EAAE,kDAAsB,EAAE;gBACpE,0EAAkC;gBAClC,EAAE,OAAO,EAAE,2CAA8B,EAAE,WAAW,EAAE,0EAAkC,EAAE;gBAC5F,iEAA6B;gBAC7B,EAAE,OAAO,EAAE,uCAA0B,EAAE,WAAW,EAAE,iEAA6B,EAAE;gBACnF,gDAAqB;gBACrB,EAAE,OAAO,EAAE,8BAAiB,EAAE,WAAW,EAAE,gDAAqB,EAAE;gBAClE,kDAAsB;gBACtB,EAAE,OAAO,EAAE,+BAAkB,EAAE,WAAW,EAAE,kDAAsB,EAAE;aACrE;YACD,OAAO,EAAE;gBACP,4BAAe,EAAE,qCAAwB,EAAE,+BAAkB,EAAE,2BAAc;gBAC7E,mCAAsB,EAAE,oCAAuB,EAAE,qCAAwB;gBACzE,0CAA6B,EAAE,+BAAkB,EAAE,2CAA8B;gBACjF,uCAA0B,EAAE,8BAAiB,EAAE,+BAAkB;aAClE;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAzCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CAyC3B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from '@nathapp/nestjs-iam';
|
|
2
|
+
export { PrismaUserRepository } from './prisma-user.repository';
|
|
3
|
+
export { PrismaIdentityRepository } from './prisma-identity.repository';
|
|
4
|
+
export { PrismaSessionRepository } from './prisma-session.repository';
|
|
5
|
+
export { PrismaMfaRepository } from './prisma-mfa.repository';
|
|
6
|
+
export { PrismaSsoAccountRepository } from './prisma-sso-account.repository';
|
|
7
|
+
export { PrismaSsoProviderRepository } from './prisma-sso-provider.repository';
|
|
8
|
+
export { PrismaLoginHistoryRepository } from './prisma-login-history.repository';
|
|
9
|
+
export { PrismaVerificationTokenRepository } from './prisma-verification-token.repository';
|
|
10
|
+
export { PrismaApiKeyRepository } from './prisma-api-key.repository';
|
|
11
|
+
export { PrismaWebAuthnCredentialRepository } from './prisma-webauthn-credential.repository';
|
|
12
|
+
export { PrismaWebAuthnMfaBindingStore } from './prisma-webauthn-mfa-binding.store';
|
|
13
|
+
export { PrismaTotpReplayStore } from './prisma-totp-replay.store';
|
|
14
|
+
export { PrismaAuthAttemptStore } from './prisma-auth-attempt.store';
|
|
15
|
+
export { IamPrismaModule, type PrismaAdapterModuleOptions } from './iam-prisma.module';
|