@stacksjs/auth 0.68.2 → 0.69.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/dist/authentication.d.ts +73 -3
- package/dist/index.js +4342 -354
- package/dist/passkey.d.ts +44 -11
- package/package.json +6 -8
- package/dist/fsevents-hj42pnne.node +0 -0
package/dist/passkey.d.ts
CHANGED
|
@@ -2,16 +2,11 @@ import type { Insertable } from '@stacksjs/database';
|
|
|
2
2
|
import type { UserModel } from '../../../orm/src/models/User';
|
|
3
3
|
import type { VerifiedRegistrationResponse } from '@simplewebauthn/server';
|
|
4
4
|
|
|
5
|
-
export {
|
|
6
|
-
generateAuthenticationOptions,
|
|
7
|
-
generateRegistrationOptions,
|
|
8
|
-
verifyAuthenticationResponse,
|
|
9
|
-
verifyRegistrationResponse,
|
|
10
|
-
} from '@simplewebauthn/server'
|
|
11
5
|
export declare type * from '@simplewebauthn/types'
|
|
12
6
|
|
|
13
7
|
type PasskeyInsertable = Insertable<PasskeyAttribute>
|
|
14
|
-
|
|
8
|
+
|
|
9
|
+
export interface PasskeyAttribute {
|
|
15
10
|
id: string
|
|
16
11
|
cred_public_key: string
|
|
17
12
|
user_id: number
|
|
@@ -25,7 +20,45 @@ export declare interface PasskeyAttribute {
|
|
|
25
20
|
created_at?: Date
|
|
26
21
|
last_used_at: string
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
|
|
24
|
+
export async function getUserPasskeys(userId: number): Promise<PasskeyAttribute[]> {
|
|
25
|
+
return await db.selectFrom('passkeys').selectAll().where('user_id', '=', userId).execute()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function getUserPasskey(userId: number, passkeyId: string): Promise<PasskeyAttribute | undefined> {
|
|
29
|
+
return await db
|
|
30
|
+
.selectFrom('passkeys')
|
|
31
|
+
.selectAll()
|
|
32
|
+
.where('id', '=', passkeyId)
|
|
33
|
+
.where('user_id', '=', userId)
|
|
34
|
+
.executeTakeFirst()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function setCurrentRegistrationOptions(
|
|
38
|
+
user: UserModel,
|
|
39
|
+
verified: VerifiedRegistrationResponse,
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
const passkeyData: PasskeyInsertable = {
|
|
42
|
+
id: verified.registrationInfo?.credential.id || '',
|
|
43
|
+
cred_public_key: JSON.stringify(verified.registrationInfo?.credential.publicKey),
|
|
44
|
+
user_id: user.id as number,
|
|
45
|
+
webauthn_user_id: user.email || '',
|
|
46
|
+
counter: verified.registrationInfo?.credential.counter || 0,
|
|
47
|
+
credential_type: verified.registrationInfo?.credentialType || '',
|
|
48
|
+
device_type: verified.registrationInfo?.credentialDeviceType || '',
|
|
49
|
+
backup_eligible: false,
|
|
50
|
+
backup_status: verified.registrationInfo?.credentialBackedUp || false,
|
|
51
|
+
transports: JSON.stringify(['internal']),
|
|
52
|
+
last_used_at: formatDateTime(),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await db.insertInto('passkeys').values(passkeyData).executeTakeFirstOrThrow()
|
|
56
|
+
}
|
|
57
|
+
declare function formatDateTime(): string;
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
generateAuthenticationOptions,
|
|
61
|
+
generateRegistrationOptions,
|
|
62
|
+
verifyAuthenticationResponse,
|
|
63
|
+
verifyRegistrationResponse,
|
|
64
|
+
} from '@simplewebauthn/server'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.69.0",
|
|
5
5
|
"description": "A more simplistic way to authenticate.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
|
|
@@ -33,14 +33,12 @@
|
|
|
33
33
|
"typecheck": "bun tsc --noEmit",
|
|
34
34
|
"prepublishOnly": "bun run build"
|
|
35
35
|
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@simplewebauthn/browser": "^11.0.0",
|
|
38
|
-
"@simplewebauthn/server": "^11.0.0"
|
|
39
|
-
},
|
|
40
36
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@stacksjs/
|
|
37
|
+
"@simplewebauthn/browser": "^13.1.0",
|
|
38
|
+
"@simplewebauthn/server": "^13.1.1",
|
|
39
|
+
"@stacksjs/development": "0.68.2",
|
|
40
|
+
"@stacksjs/error-handling": "0.68.2",
|
|
41
|
+
"@stacksjs/router": "0.68.2",
|
|
44
42
|
"@types/qrcode": "^1.5.5",
|
|
45
43
|
"otplib": "^12.0.1",
|
|
46
44
|
"qrcode": "^1.5.4"
|
|
Binary file
|