own-auth 0.1.0 → 0.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/dist/postgres/hosted-projects.d.ts +88 -0
- package/dist/postgres/hosted-projects.d.ts.map +1 -0
- package/dist/postgres/hosted-projects.js +454 -0
- package/dist/postgres/hosted-projects.js.map +1 -0
- package/dist/postgres/index.d.ts +20 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +18 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/postgres-storage.d.ts +55 -0
- package/dist/postgres/postgres-storage.d.ts.map +1 -0
- package/dist/postgres/postgres-storage.js +648 -0
- package/dist/postgres/postgres-storage.js.map +1 -0
- package/migrations/001_initial.sql +227 -0
- package/migrations/002_hosted_projects.sql +38 -0
- package/package.json +14 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Account, ApiKey, AuditEvent, AuthStorage, AuthToken, Invitation, Organisation, OrganisationMember, Session, SmsOtp, TokenType, User } from "../index.js";
|
|
2
|
+
export interface PostgresQueryResult<Row> {
|
|
3
|
+
rows: Row[];
|
|
4
|
+
}
|
|
5
|
+
export interface PostgresQueryable {
|
|
6
|
+
query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<PostgresQueryResult<Row>>;
|
|
7
|
+
}
|
|
8
|
+
export declare class PostgresAuthStorage implements AuthStorage {
|
|
9
|
+
private readonly db;
|
|
10
|
+
constructor(db: PostgresQueryable);
|
|
11
|
+
createUser(user: User): Promise<User>;
|
|
12
|
+
updateUser(id: string, patch: Partial<User>): Promise<User | null>;
|
|
13
|
+
getUserById(id: string): Promise<User | null>;
|
|
14
|
+
getUserByEmail(email: string): Promise<User | null>;
|
|
15
|
+
getUserByPhone(phone: string): Promise<User | null>;
|
|
16
|
+
createAccount(account: Account): Promise<Account>;
|
|
17
|
+
getAccountByProvider(provider: string, providerAccountId: string): Promise<Account | null>;
|
|
18
|
+
createSession(session: Session): Promise<Session>;
|
|
19
|
+
getSessionByTokenHash(tokenHash: string): Promise<Session | null>;
|
|
20
|
+
updateSession(id: string, patch: Partial<Session>): Promise<Session | null>;
|
|
21
|
+
listSessionsByUserId(userId: string): Promise<Session[]>;
|
|
22
|
+
createToken(token: AuthToken): Promise<AuthToken>;
|
|
23
|
+
getTokenByHash(tokenHash: string, type?: TokenType): Promise<AuthToken | null>;
|
|
24
|
+
updateToken(id: string, patch: Partial<AuthToken>): Promise<AuthToken | null>;
|
|
25
|
+
createSmsOtp(otp: SmsOtp): Promise<SmsOtp>;
|
|
26
|
+
getLatestSmsOtp(phone: string, purpose: string): Promise<SmsOtp | null>;
|
|
27
|
+
updateSmsOtp(id: string, patch: Partial<SmsOtp>): Promise<SmsOtp | null>;
|
|
28
|
+
createApiKey(apiKey: ApiKey): Promise<ApiKey>;
|
|
29
|
+
getApiKeyByPrefix(keyPrefix: string): Promise<ApiKey | null>;
|
|
30
|
+
updateApiKey(id: string, patch: Partial<ApiKey>): Promise<ApiKey | null>;
|
|
31
|
+
createOrganisation(organisation: Organisation): Promise<Organisation>;
|
|
32
|
+
updateOrganisation(id: string, patch: Partial<Organisation>): Promise<Organisation | null>;
|
|
33
|
+
getOrganisationById(id: string): Promise<Organisation | null>;
|
|
34
|
+
getOrganisationBySlug(slug: string): Promise<Organisation | null>;
|
|
35
|
+
createOrganisationMember(member: OrganisationMember): Promise<OrganisationMember>;
|
|
36
|
+
updateOrganisationMember(id: string, patch: Partial<OrganisationMember>): Promise<OrganisationMember | null>;
|
|
37
|
+
getOrganisationMember(organisationId: string, userId: string): Promise<OrganisationMember | null>;
|
|
38
|
+
getOrganisationMemberById(id: string): Promise<OrganisationMember | null>;
|
|
39
|
+
listOrganisationMembers(organisationId: string): Promise<OrganisationMember[]>;
|
|
40
|
+
createInvitation(invitation: Invitation): Promise<Invitation>;
|
|
41
|
+
updateInvitation(id: string, patch: Partial<Invitation>): Promise<Invitation | null>;
|
|
42
|
+
getInvitationById(id: string): Promise<Invitation | null>;
|
|
43
|
+
getPendingInvitationByOrganisationAndEmail(organisationId: string, email: string): Promise<Invitation | null>;
|
|
44
|
+
createAuditEvent(event: AuditEvent): Promise<AuditEvent>;
|
|
45
|
+
listAuditEvents(filter?: {
|
|
46
|
+
userId?: string;
|
|
47
|
+
organisationId?: string;
|
|
48
|
+
apiKeyId?: string;
|
|
49
|
+
}): Promise<AuditEvent[]>;
|
|
50
|
+
private insertOne;
|
|
51
|
+
private updateOne;
|
|
52
|
+
private selectOne;
|
|
53
|
+
}
|
|
54
|
+
export declare function createPostgresAuthStorage(db: PostgresQueryable): PostgresAuthStorage;
|
|
55
|
+
//# sourceMappingURL=postgres-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-storage.d.ts","sourceRoot":"","sources":["../../src/postgres/postgres-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAEP,MAAM,EAEN,UAAU,EAEV,WAAW,EACX,SAAS,EACT,UAAU,EAIV,YAAY,EACZ,kBAAkB,EAElB,OAAO,EACP,MAAM,EAEN,SAAS,EACT,IAAI,EACL,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mBAAmB,CAAC,GAAG;IACtC,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;CACtC;AAMD,qBAAa,mBAAoB,YAAW,WAAW;IACzC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,iBAAiB;IAE5C,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,UAAU,CAAC,EAAE,EAA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