@aooth/user 0.1.7 → 0.1.8
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/atscript-db.cjs +108 -22
- package/dist/atscript-db.d.cts +69 -12
- package/dist/atscript-db.d.mts +69 -12
- package/dist/atscript-db.mjs +103 -18
- package/dist/{user-store-BaBmH13V.mjs → federated-identity-store-Cmc7jBrw.mjs} +40 -1
- package/dist/{user-store-62LCSa8q.d.mts → federated-identity-store-DEEed8lA.d.cts} +148 -24
- package/dist/{user-store-BZsKtBHy.d.cts → federated-identity-store-DEEed8lA.d.mts} +148 -24
- package/dist/{user-store-BPZVAboN.cjs → federated-identity-store-oRjhnR5l.cjs} +51 -0
- package/dist/index.cjs +281 -219
- package/dist/index.d.cts +101 -72
- package/dist/index.d.mts +101 -72
- package/dist/index.mjs +248 -188
- package/package.json +23 -9
- package/src/atscript-db/federated-identity.as +44 -0
- package/src/atscript-db/federated-identity.as.d.ts +62 -0
- package/src/atscript-db/user-credentials.as +7 -2
- package/src/atscript-db/user-credentials.as.d.ts +62 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aooth/user",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "User credential primitives for aoothjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aoothjs",
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
-
"src/atscript-db/user-credentials.as"
|
|
24
|
+
"src/atscript-db/user-credentials.as",
|
|
25
|
+
"src/atscript-db/user-credentials.as.d.ts",
|
|
26
|
+
"src/atscript-db/federated-identity.as",
|
|
27
|
+
"src/atscript-db/federated-identity.as.d.ts"
|
|
25
28
|
],
|
|
26
29
|
"type": "module",
|
|
27
30
|
"sideEffects": false,
|
|
@@ -39,21 +42,32 @@
|
|
|
39
42
|
"import": "./dist/atscript-db.mjs",
|
|
40
43
|
"require": "./dist/atscript-db.cjs"
|
|
41
44
|
},
|
|
42
|
-
"./atscript-db/model.as":
|
|
45
|
+
"./atscript-db/model.as": {
|
|
46
|
+
"types": "./src/atscript-db/user-credentials.as.d.ts",
|
|
47
|
+
"default": "./src/atscript-db/user-credentials.as"
|
|
48
|
+
},
|
|
49
|
+
"./atscript-db/federated-model": {
|
|
50
|
+
"types": "./src/atscript-db/federated-identity.as.d.ts",
|
|
51
|
+
"default": "./src/atscript-db/federated-identity.as"
|
|
52
|
+
},
|
|
53
|
+
"./atscript-db/federated-model.as": {
|
|
54
|
+
"types": "./src/atscript-db/federated-identity.as.d.ts",
|
|
55
|
+
"default": "./src/atscript-db/federated-identity.as"
|
|
56
|
+
},
|
|
43
57
|
"./package.json": "./package.json"
|
|
44
58
|
},
|
|
45
59
|
"publishConfig": {
|
|
46
60
|
"access": "public"
|
|
47
61
|
},
|
|
48
62
|
"devDependencies": {
|
|
49
|
-
"@atscript/core": "^0.1.
|
|
50
|
-
"@atscript/db": "^0.1.
|
|
51
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
52
|
-
"@atscript/db-sqlite": "^0.1.
|
|
53
|
-
"@atscript/typescript": "^0.1.
|
|
63
|
+
"@atscript/core": "^0.1.69",
|
|
64
|
+
"@atscript/db": "^0.1.96",
|
|
65
|
+
"@atscript/db-sql-tools": "^0.1.96",
|
|
66
|
+
"@atscript/db-sqlite": "^0.1.96",
|
|
67
|
+
"@atscript/typescript": "^0.1.69",
|
|
54
68
|
"@types/better-sqlite3": "^7.6.13",
|
|
55
69
|
"better-sqlite3": "^12.6.2",
|
|
56
|
-
"unplugin-atscript": "^0.1.
|
|
70
|
+
"unplugin-atscript": "^0.1.69"
|
|
57
71
|
},
|
|
58
72
|
"peerDependencies": {
|
|
59
73
|
"@atscript/db": ">=0.1.79"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Account-linking table: one external-provider account → exactly one aooth
|
|
2
|
+
// user. The genuinely new piece of persistent state for federated login —
|
|
3
|
+
// the `(provider, subject) → userId` map (RFC IDP.md §3.3). Shipped concrete
|
|
4
|
+
// (own `@db.table`), like `AoothAuthCredential`; consumers can extend it with
|
|
5
|
+
// `extends AoothFederatedIdentity {}` to re-own the table name, exactly as
|
|
6
|
+
// `DemoAuthCredential` does.
|
|
7
|
+
@db.table 'aooth_federated_identities'
|
|
8
|
+
@db.depth.limit 0
|
|
9
|
+
export interface AoothFederatedIdentity {
|
|
10
|
+
// Surrogate PK — lets a row be addressed (unlink-by-id) / extended.
|
|
11
|
+
@meta.id
|
|
12
|
+
@db.default.uuid
|
|
13
|
+
id: string
|
|
14
|
+
|
|
15
|
+
// Composite identity key. The SAME index name on both fields collapses
|
|
16
|
+
// into ONE compound UNIQUE index (atscript-db groups index fields by
|
|
17
|
+
// (type, name)) — so a provider account maps to at most one row, which is
|
|
18
|
+
// the anti-account-takeover guarantee (RFC §1 note #4, §4).
|
|
19
|
+
@db.index.unique 'provider_subject_idx'
|
|
20
|
+
provider: string // 'google' | 'github' | 'oidc:<issuer>' ...
|
|
21
|
+
@db.index.unique 'provider_subject_idx'
|
|
22
|
+
subject: string // the IdP's stable subject id (`sub`)
|
|
23
|
+
|
|
24
|
+
// Owner — the user's stable surrogate `id`. A PLAIN indexed string, NOT a
|
|
25
|
+
// `@db.rel.FK`: `@aooth/user` cannot know the consumer's concrete user
|
|
26
|
+
// table (`AoothUserCredentials` is an abstract, table-less base), so this
|
|
27
|
+
// mirrors `AoothAuthCredential.userId`. Cross-row cleanup is the explicit
|
|
28
|
+
// `FederatedIdentityStore.deleteAllForUser` (GDPR), not a DB cascade.
|
|
29
|
+
// Consumers wanting a hard FK + cascade re-declare it in their subclass.
|
|
30
|
+
@db.index.plain
|
|
31
|
+
userId: string
|
|
32
|
+
|
|
33
|
+
// Display snapshots — refreshed by `touchLogin` on each federated login;
|
|
34
|
+
// NOT join keys (the stable join is always `(provider, subject)`). A
|
|
35
|
+
// provider's snapshot email (e.g. Apple Private Relay) may differ from the
|
|
36
|
+
// user-row `email` handle, so these live here per-identity.
|
|
37
|
+
email?: string
|
|
38
|
+
emailVerified?: boolean
|
|
39
|
+
displayName?: string
|
|
40
|
+
avatarUrl?: string
|
|
41
|
+
|
|
42
|
+
linkedAt: number.timestamp
|
|
43
|
+
lastLoginAt?: number.timestamp
|
|
44
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// prettier-ignore-start
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* oxlint-disable */
|
|
4
|
+
/// <reference path="./federated-identity.as" />
|
|
5
|
+
/**
|
|
6
|
+
* 🪄 This file was generated by Atscript
|
|
7
|
+
* Do not edit this file!
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { TAtscriptTypeObject, TAtscriptTypeComplex, TAtscriptTypeFinal, TAtscriptTypeArray, TAtscriptAnnotatedType, TMetadataMap, Validator, TValidatorOptions } from "@atscript/typescript/utils"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Atscript interface **AoothFederatedIdentity**
|
|
14
|
+
* @see {@link ./federated-identity.as:9:18}
|
|
15
|
+
*/
|
|
16
|
+
export declare class AoothFederatedIdentity {
|
|
17
|
+
id: string
|
|
18
|
+
provider: string
|
|
19
|
+
subject: string
|
|
20
|
+
userId: string
|
|
21
|
+
email?: string
|
|
22
|
+
emailVerified?: boolean
|
|
23
|
+
displayName?: string
|
|
24
|
+
avatarUrl?: string
|
|
25
|
+
linkedAt: number /* timestamp */
|
|
26
|
+
lastLoginAt?: number /* timestamp */
|
|
27
|
+
static __is_atscript_annotated_type: true
|
|
28
|
+
static type: TAtscriptTypeObject<keyof AoothFederatedIdentity, AoothFederatedIdentity>
|
|
29
|
+
static metadata: TMetadataMap<AtscriptMetadata>
|
|
30
|
+
static validator: (opts?: Partial<TValidatorOptions>) => Validator<typeof AoothFederatedIdentity>
|
|
31
|
+
/** @deprecated JSON Schema support is disabled. Calling this method will throw a runtime error. To enable, set `jsonSchema: 'lazy'` or `jsonSchema: 'bundle'` in tsPlugin options, or add `@emit.jsonSchema` annotation to individual interfaces. */
|
|
32
|
+
static toJsonSchema: () => any
|
|
33
|
+
/** @deprecated Example Data support is disabled. To enable, set `exampleData: true` in tsPlugin options. */
|
|
34
|
+
static toExampleData?: () => any
|
|
35
|
+
static __flat: {
|
|
36
|
+
"id": string
|
|
37
|
+
"provider": string
|
|
38
|
+
"subject": string
|
|
39
|
+
"userId": string
|
|
40
|
+
"email"?: string
|
|
41
|
+
"emailVerified"?: boolean
|
|
42
|
+
"displayName"?: string
|
|
43
|
+
"avatarUrl"?: string
|
|
44
|
+
"linkedAt": number /* timestamp */
|
|
45
|
+
"lastLoginAt"?: number /* timestamp */
|
|
46
|
+
}
|
|
47
|
+
static __ownProps: {
|
|
48
|
+
"id": string
|
|
49
|
+
"provider": string
|
|
50
|
+
"subject": string
|
|
51
|
+
"userId": string
|
|
52
|
+
"email"?: string
|
|
53
|
+
"emailVerified"?: boolean
|
|
54
|
+
"displayName"?: string
|
|
55
|
+
"avatarUrl"?: string
|
|
56
|
+
"linkedAt": number /* timestamp */
|
|
57
|
+
"lastLoginAt"?: number /* timestamp */
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static __pk: string
|
|
61
|
+
}
|
|
62
|
+
// prettier-ignore-end
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export interface AoothUserCredentials {
|
|
2
|
+
@meta.id
|
|
3
|
+
@db.default.uuid
|
|
4
|
+
id: string
|
|
5
|
+
|
|
2
6
|
@db.index.unique 'username_idx'
|
|
3
7
|
username: string
|
|
4
8
|
|
|
9
|
+
@db.index.unique 'email_idx'
|
|
10
|
+
email?: string
|
|
11
|
+
|
|
5
12
|
@db.column.version
|
|
6
13
|
version: number.int
|
|
7
14
|
|
|
@@ -42,6 +49,4 @@ export interface AoothUserCredentials {
|
|
|
42
49
|
expiresAt: number.timestamp
|
|
43
50
|
name?: string
|
|
44
51
|
}[]
|
|
45
|
-
|
|
46
|
-
backupCodes?: string[]
|
|
47
52
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// prettier-ignore-start
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* oxlint-disable */
|
|
4
|
+
/// <reference path="./user-credentials.as" />
|
|
5
|
+
/**
|
|
6
|
+
* 🪄 This file was generated by Atscript
|
|
7
|
+
* Do not edit this file!
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { TAtscriptTypeObject, TAtscriptTypeComplex, TAtscriptTypeFinal, TAtscriptTypeArray, TAtscriptAnnotatedType, TMetadataMap, Validator, TValidatorOptions } from "@atscript/typescript/utils"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Atscript interface **AoothUserCredentials**
|
|
14
|
+
* @see {@link ./user-credentials.as:1:18}
|
|
15
|
+
*/
|
|
16
|
+
export declare class AoothUserCredentials {
|
|
17
|
+
id: string
|
|
18
|
+
username: string
|
|
19
|
+
email?: string
|
|
20
|
+
version: number /* int */
|
|
21
|
+
password: {
|
|
22
|
+
hash: string
|
|
23
|
+
history: string[]
|
|
24
|
+
lastChanged: number /* timestamp */
|
|
25
|
+
isInitial: boolean
|
|
26
|
+
}
|
|
27
|
+
account: {
|
|
28
|
+
active: boolean
|
|
29
|
+
locked: boolean
|
|
30
|
+
lockReason: string
|
|
31
|
+
lockEnds: number /* timestamp */
|
|
32
|
+
failedLoginAttempts: number
|
|
33
|
+
lastLogin: number /* timestamp */
|
|
34
|
+
pendingInvitation?: boolean
|
|
35
|
+
}
|
|
36
|
+
mfa: {
|
|
37
|
+
methods: {
|
|
38
|
+
name: string
|
|
39
|
+
confirmed: boolean
|
|
40
|
+
value: string
|
|
41
|
+
lastUsedWindow?: number /* int */
|
|
42
|
+
}[]
|
|
43
|
+
defaultMethod: string
|
|
44
|
+
autoSend: boolean
|
|
45
|
+
}
|
|
46
|
+
trustedDevices?: {
|
|
47
|
+
token: string
|
|
48
|
+
ip?: string
|
|
49
|
+
issuedAt: number /* timestamp */
|
|
50
|
+
expiresAt: number /* timestamp */
|
|
51
|
+
name?: string
|
|
52
|
+
}[]
|
|
53
|
+
static __is_atscript_annotated_type: true
|
|
54
|
+
static type: TAtscriptTypeObject<keyof AoothUserCredentials, AoothUserCredentials>
|
|
55
|
+
static metadata: TMetadataMap<AtscriptMetadata>
|
|
56
|
+
static validator: (opts?: Partial<TValidatorOptions>) => Validator<typeof AoothUserCredentials>
|
|
57
|
+
/** @deprecated JSON Schema support is disabled. Calling this method will throw a runtime error. To enable, set `jsonSchema: 'lazy'` or `jsonSchema: 'bundle'` in tsPlugin options, or add `@emit.jsonSchema` annotation to individual interfaces. */
|
|
58
|
+
static toJsonSchema: () => any
|
|
59
|
+
/** @deprecated Example Data support is disabled. To enable, set `exampleData: true` in tsPlugin options. */
|
|
60
|
+
static toExampleData?: () => any
|
|
61
|
+
}
|
|
62
|
+
// prettier-ignore-end
|