@1auth/authn-recovery-codes 0.0.0-alpha.55 → 0.0.0-alpha.56
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/index.js +15 -13
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
getOptions as authnGetOptions,
|
|
10
10
|
count as authnCount,
|
|
11
11
|
list as authnList,
|
|
12
|
-
create as authnCreate,
|
|
12
|
+
// create as authnCreate,
|
|
13
|
+
createList as authnCreateList,
|
|
13
14
|
authenticate as authnAuthenticate,
|
|
14
15
|
remove as authnRemove
|
|
15
16
|
} from '@1auth/authn'
|
|
@@ -74,9 +75,10 @@ export const update = async (sub) => {
|
|
|
74
75
|
type: options.secret.id + '-' + options.secret.type
|
|
75
76
|
})
|
|
76
77
|
const secrets = await createSecrets(sub, options.count)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
|
|
79
|
+
const id = existingSecrets.map((item) => item.id)
|
|
80
|
+
await authnRemove(options.secret, sub, id)
|
|
81
|
+
|
|
80
82
|
await options.notify.trigger('authn-recovery-codes-update', sub)
|
|
81
83
|
return secrets
|
|
82
84
|
}
|
|
@@ -85,16 +87,16 @@ export const remove = async (sub, id) => {
|
|
|
85
87
|
if (options.log) {
|
|
86
88
|
options.log('@1auth/authn-recovery-codes remove(', sub, id, ')')
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
id ??= await options.store
|
|
92
|
+
.selectList(options.table, {
|
|
90
93
|
sub,
|
|
91
94
|
type: options.id + '-' + options.secret.type
|
|
92
95
|
})
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
96
|
+
.then((res) => res.map((item) => item.id))
|
|
97
|
+
|
|
98
|
+
await authnRemove(options.secret, sub, id)
|
|
99
|
+
|
|
98
100
|
await options.notify.trigger('authn-recovery-codes-remove', sub)
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -103,12 +105,12 @@ const createSecrets = async (sub, count = options.count) => {
|
|
|
103
105
|
const now = nowInSeconds()
|
|
104
106
|
for (let i = count; i--;) {
|
|
105
107
|
const secret = await options.secret.create()
|
|
106
|
-
|
|
108
|
+
secrets.push({
|
|
107
109
|
value: secret,
|
|
108
110
|
verify: now
|
|
109
111
|
})
|
|
110
|
-
secrets.push({ id, secret })
|
|
111
112
|
}
|
|
113
|
+
await authnCreateList(options.secret, sub, secrets)
|
|
112
114
|
return secrets
|
|
113
115
|
}
|
|
114
116
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1auth/authn-recovery-codes",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.56",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"homepage": "https://github.com/willfarrell/1auth",
|
|
51
51
|
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@1auth/authn": "0.0.0-alpha.
|
|
54
|
-
"@1auth/crypto": "0.0.0-alpha.
|
|
53
|
+
"@1auth/authn": "0.0.0-alpha.56",
|
|
54
|
+
"@1auth/crypto": "0.0.0-alpha.56"
|
|
55
55
|
}
|
|
56
56
|
}
|