@1auth/account 0.0.0-alpha.33 → 0.0.0-alpha.35

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 (3) hide show
  1. package/index.js +17 -9
  2. package/package.json +4 -7
  3. package/LICENSE +0 -21
package/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  symetricDecryptFields
10
10
  } from '@1auth/crypto'
11
11
 
12
- const id = 'authn'
12
+ const id = 'account'
13
13
  const randomSubject = {
14
14
  type: 'id',
15
15
  minLength: entropyToCharacterLength(64, charactersAlphaNumeric.length),
@@ -40,17 +40,17 @@ export const exists = async (sub) => {
40
40
  }
41
41
 
42
42
  export const lookup = async (sub) => {
43
- let item = await options.store.select(options.table, { sub })
44
- if (!item) return
45
- const { encryptionKey: encryptedKey } = item
46
- delete item.encryptionKey
47
- delete item.privateKey
48
- item = symetricDecryptFields(
49
- item,
43
+ const account = await options.store.select(options.table, { sub })
44
+ if (!account) return
45
+ const { encryptionKey: encryptedKey } = account
46
+ delete account.encryptionKey
47
+ delete account.privateKey
48
+ const decryptedAccount = symetricDecryptFields(
49
+ account,
50
50
  { encryptedKey, sub },
51
51
  options.encryptedFields
52
52
  )
53
- return item
53
+ return decryptedAccount
54
54
  }
55
55
 
56
56
  export const create = async (values = {}) => {
@@ -104,6 +104,14 @@ export const update = async (sub, values = {}) => {
104
104
  )
105
105
  }
106
106
 
107
+ export const expire = async (sub) => {
108
+ await options.store.update(
109
+ options.table,
110
+ { sub },
111
+ { expire: nowInSeconds() }
112
+ )
113
+ }
114
+
107
115
  export const remove = async (sub) => {
108
116
  // Should trigger removal of credentials and messengers
109
117
  await options.store.remove(options.table, { sub })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1auth/account",
3
- "version": "0.0.0-alpha.33",
3
+ "version": "0.0.0-alpha.35",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "engines": {
@@ -21,10 +21,7 @@
21
21
  }
22
22
  },
23
23
  "types": "index.d.ts",
24
- "files": [
25
- "index.js",
26
- "index.d.ts"
27
- ],
24
+ "files": ["index.js", "index.d.ts"],
28
25
  "scripts": {
29
26
  "test": "npm run test:unit",
30
27
  "test:unit": "node --test"
@@ -48,8 +45,8 @@
48
45
  "url": "https://github.com/willfarrell/1auth/issues"
49
46
  },
50
47
  "homepage": "https://github.com/willfarrell/1auth",
51
- "gitHead": "14b8c5bd83728c460fdcc4c3af5ae5c3c2bb9007",
48
+ "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
52
49
  "dependencies": {
53
- "@1auth/crypto": "0.0.0-alpha.33"
50
+ "@1auth/crypto": "0.0.0-alpha.35"
54
51
  }
55
52
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 will Farrell
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.