@1auth/authn 0.0.0-alpha.2 → 0.0.0-alpha.4

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.
Files changed (2) hide show
  1. package/index.js +10 -9
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -32,7 +32,7 @@ export const create = async (
32
32
  encryptedKey,
33
33
  sub
34
34
  )
35
- return parentOptions.store.insert(options.table, {
35
+ await options.store.insert(options.table, {
36
36
  expire,
37
37
  ...rest,
38
38
  id,
@@ -44,6 +44,7 @@ export const create = async (
44
44
  create: now,
45
45
  update: now
46
46
  })
47
+ return id
47
48
  }
48
49
 
49
50
  export const update = async (
@@ -57,7 +58,7 @@ export const update = async (
57
58
  encryptionKey,
58
59
  sub
59
60
  )
60
- return parentOptions.store.update(
61
+ return options.store.update(
61
62
  options.table,
62
63
  { id, sub },
63
64
  {
@@ -82,7 +83,7 @@ export const authenticate = async (username, secret, parentOptions) => {
82
83
 
83
84
  const sub = await subject(username)
84
85
 
85
- const credentials = await parentOptions.store.selectList(options.table, {
86
+ const credentials = await options.store.selectList(options.table, {
86
87
  sub,
87
88
  type
88
89
  }) // TODO and verify is not null
@@ -99,7 +100,7 @@ export const authenticate = async (username, secret, parentOptions) => {
99
100
  }
100
101
 
101
102
  if (valid && parentOptions.secret.otp) {
102
- await parentOptions.store.remove(options.table, { id, sub })
103
+ await options.store.remove(options.table, { id, sub })
103
104
  }
104
105
  await timeout
105
106
  if (!valid) throw new Error('401 Unauthorized')
@@ -108,7 +109,7 @@ export const authenticate = async (username, secret, parentOptions) => {
108
109
 
109
110
  export const verifySecret = async (sub, id, parentOptions) => {
110
111
  // const type = parentOptions.id + '-' + parentOptions.secret.type
111
- await parentOptions.store.update(
112
+ await options.store.update(
112
113
  options.table,
113
114
  { id, sub },
114
115
  { verify: nowInSeconds() }
@@ -119,7 +120,7 @@ export const verify = async (credentialType, sub, token, parentOptions) => {
119
120
  const timeout = setTimeout(() => {}, options.authenticationDuration)
120
121
  const type = parentOptions.id + '-' + parentOptions[credentialType].type
121
122
  let id
122
- const credentials = await parentOptions.store.selectList(options.table, {
123
+ const credentials = await options.store.selectList(options.table, {
123
124
  sub,
124
125
  type
125
126
  })
@@ -129,7 +130,7 @@ export const verify = async (credentialType, sub, token, parentOptions) => {
129
130
  // return rows
130
131
  // }
131
132
  //
132
- // return parentOptions.store.select(options.table, { id: sub, type })
133
+ // return options.store.select(options.table, { id: sub, type })
133
134
  // })
134
135
 
135
136
  let valid
@@ -147,7 +148,7 @@ export const verify = async (credentialType, sub, token, parentOptions) => {
147
148
  }
148
149
  }
149
150
  if (valid && parentOptions[credentialType].otp) {
150
- await parentOptions.store.remove(options.table, { id, sub })
151
+ await options.store.remove(options.table, { id, sub })
151
152
  }
152
153
  if (!valid) throw new Error('401 Unauthorized')
153
154
  await timeout
@@ -155,7 +156,7 @@ export const verify = async (credentialType, sub, token, parentOptions) => {
155
156
  }
156
157
 
157
158
  export const expire = async (sub, id, parentOptions = options) => {
158
- await parentOptions.store.remove(options.table, { id, sub })
159
+ await options.store.remove(options.table, { id, sub })
159
160
  }
160
161
 
161
162
  // TODO manage onboard state
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1auth/authn",
3
- "version": "0.0.0-alpha.2",
3
+ "version": "0.0.0-alpha.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "engines": {
@@ -48,8 +48,8 @@
48
48
  "url": "https://github.com/willfarrell/1auth/issues"
49
49
  },
50
50
  "homepage": "https://github.com/willfarrell/1auth",
51
- "gitHead": "a02b1e01f039718f213d79b91d04ed660a955c73",
51
+ "gitHead": "47894073ee5f1b6754cef5e482f123dc81575b1c",
52
52
  "dependencies": {
53
- "@1auth/crypto": "0.0.0-alpha.2"
53
+ "@1auth/crypto": "0.0.0-alpha.4"
54
54
  }
55
55
  }