@owlmeans/auth-otp 0.1.18-rc.32 → 0.1.18-rc.34
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/package.json +4 -4
- package/tests/contract.spec.ts +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth-otp",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
25
|
+
"@owlmeans/context": "^0.1.18-rc.34",
|
|
26
|
+
"@owlmeans/error": "^0.1.18-rc.38"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@owlmeans/dep-config": "workspace:*",
|
|
30
|
-
"@types/bun": "^1.4.
|
|
30
|
+
"@types/bun": "^1.4.2",
|
|
31
31
|
"nodemon": "^3.1.14",
|
|
32
32
|
"typescript": "^7.0.2"
|
|
33
33
|
},
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, expectTypeOf, test } from 'bun:test'
|
|
2
|
+
import * as otp from '../src/index.js'
|
|
3
|
+
import type { OtpService } from '../src/index.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This package is the contract between the OTP server (`@owlmeans/server-auth-otp`) and the clients
|
|
7
|
+
* that select it: a value changed here changes what both sides agree on, so each one is pinned.
|
|
8
|
+
*/
|
|
9
|
+
describe('@owlmeans/auth-otp — the shared contract', () => {
|
|
10
|
+
test('names the service, the auth type and the code store', () => {
|
|
11
|
+
expect(otp.OTP_SERVICE).toBe('auth-otp-service')
|
|
12
|
+
expect(otp.OTP_AUTH_TYPE).toBe('email-otp')
|
|
13
|
+
expect(otp.OTP_RESOURCE).toBe('auth-otp-cache')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('a code is six digits, lives ten minutes and survives four wrong guesses', () => {
|
|
17
|
+
expect(otp.OTP_CODE_LENGTH).toBe(6)
|
|
18
|
+
expect(otp.OTP_TTL_SECONDS).toBe(600)
|
|
19
|
+
expect(otp.OTP_MAX_FAILED_ATTEMPTS).toBe(5)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('the barrel exports constants only — no runtime code to drift', () => {
|
|
23
|
+
expect(Object.keys(otp).sort()).toEqual([
|
|
24
|
+
'OTP_AUTH_TYPE', 'OTP_CODE_LENGTH', 'OTP_MAX_FAILED_ATTEMPTS', 'OTP_RESOURCE', 'OTP_SERVICE', 'OTP_TTL_SECONDS',
|
|
25
|
+
])
|
|
26
|
+
expect(Object.values(otp).every(value => typeof value === 'string' || typeof value === 'number')).toBe(true)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('the service issues an opaque id and verifies by email, id and code', () => {
|
|
30
|
+
expectTypeOf<OtpService['issueChallenge']>().parameters.toEqualTypeOf<[string]>()
|
|
31
|
+
expectTypeOf<OtpService['issueChallenge']>().returns.toEqualTypeOf<Promise<string>>()
|
|
32
|
+
expectTypeOf<OtpService['verifyChallenge']>().parameters.toEqualTypeOf<[string, string, string]>()
|
|
33
|
+
expectTypeOf<OtpService['verifyChallenge']>().returns.toEqualTypeOf<Promise<void>>()
|
|
34
|
+
})
|
|
35
|
+
})
|