@3sixty/vault-models 0.0.0-stage → 0.20.0-next.1
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/LICENSE +201 -0
- package/README.md +24 -2
- package/dist/es/factories/vaultConnectorFactory.js +9 -0
- package/dist/es/factories/vaultConnectorFactory.js.map +1 -0
- package/dist/es/index.js +8 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IVaultConnector.js +2 -0
- package/dist/es/models/IVaultConnector.js.map +1 -0
- package/dist/es/models/vaultEncryptionType.js +13 -0
- package/dist/es/models/vaultEncryptionType.js.map +1 -0
- package/dist/es/models/vaultKeyType.js +17 -0
- package/dist/es/models/vaultKeyType.js.map +1 -0
- package/dist/es/utils/vaultConnectorHelper.js +57 -0
- package/dist/es/utils/vaultConnectorHelper.js.map +1 -0
- package/dist/types/factories/vaultConnectorFactory.d.ts +6 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/models/IVaultConnector.d.ts +129 -0
- package/dist/types/models/vaultEncryptionType.d.ts +13 -0
- package/dist/types/models/vaultKeyType.d.ts +17 -0
- package/dist/types/utils/vaultConnectorHelper.d.ts +37 -0
- package/docs/changelog.md +9 -0
- package/docs/examples.md +141 -0
- package/docs/reference/classes/VaultConnectorHelper.md +127 -0
- package/docs/reference/index.md +20 -0
- package/docs/reference/interfaces/IVaultConnector.md +449 -0
- package/docs/reference/type-aliases/VaultEncryptionType.md +5 -0
- package/docs/reference/type-aliases/VaultKeyType.md +5 -0
- package/docs/reference/variables/VaultConnectorFactory.md +5 -0
- package/docs/reference/variables/VaultEncryptionType.md +13 -0
- package/docs/reference/variables/VaultKeyType.md +19 -0
- package/locales/en.json +7 -0
- package/package.json +54 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 IOTA Stiftung.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 3Sixty Vault Models
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package defines the shared contracts, enums, and factory helpers used by vault connectors, so applications can integrate key and secret operations through a consistent model.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @3sixty/vault-models
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
14
|
+
|
|
15
|
+
## Reference
|
|
16
|
+
|
|
17
|
+
Detailed reference documentation for the API can be found in [docs/reference/index.md](docs/reference/index.md)
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
|
|
22
|
+
|
|
23
|
+
## Origin
|
|
24
|
+
|
|
25
|
+
This package is derived from the original [iotaledger/twin-vault](https://github.com/iotaledger/twin-vault/tree/next/packages/vault-models) repository.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Factory } from "@3sixty/core";
|
|
4
|
+
/**
|
|
5
|
+
* Factory for creating vault connectors.
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8
|
+
export const VaultConnectorFactory = Factory.createFactory("vault");
|
|
9
|
+
//# sourceMappingURL=vaultConnectorFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultConnectorFactory.js","sources":["../../../src/factories/vaultConnectorFactory.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAkB,OAAO,CAAC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Factory } from \"@3sixty/core\";\nimport type { IVaultConnector } from \"../models/IVaultConnector.js\";\n\n/**\n * Factory for creating vault connectors.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VaultConnectorFactory = Factory.createFactory<IVaultConnector>(\"vault\");\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./factories/vaultConnectorFactory.js";
|
|
4
|
+
export * from "./models/IVaultConnector.js";
|
|
5
|
+
export * from "./models/vaultEncryptionType.js";
|
|
6
|
+
export * from "./models/vaultKeyType.js";
|
|
7
|
+
export * from "./utils/vaultConnectorHelper.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./factories/vaultConnectorFactory.js\";\nexport * from \"./models/IVaultConnector.js\";\nexport * from \"./models/vaultEncryptionType.js\";\nexport * from \"./models/vaultKeyType.js\";\nexport * from \"./utils/vaultConnectorHelper.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IVaultConnector.js","sources":["../../../src/models/IVaultConnector.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@3sixty/core\";\nimport type { VaultEncryptionType } from \"./vaultEncryptionType.js\";\nimport type { VaultKeyType } from \"./vaultKeyType.js\";\n\n/**\n * Interface describing a vault securely storing data.\n */\nexport interface IVaultConnector extends IComponent {\n\t/**\n\t * Generate a new key and store it in the vault.\n\t * @param name The name of the key to generate and store in the vault.\n\t * @param type The type of key to create.\n\t * @returns The public key for the key pair.\n\t */\n\tcreateKey(name: string, type: VaultKeyType): Promise<Uint8Array>;\n\n\t/**\n\t * Add an existing key to the vault.\n\t * @param name The name of the key to add to the vault.\n\t * @param type The type of key to add.\n\t * @param privateKey The private key.\n\t * @param publicKey The public key, can be undefined if the key type is symmetric.\n\t * @returns A promise that resolves when the key has been stored.\n\t */\n\taddKey(\n\t\tname: string,\n\t\ttype: VaultKeyType,\n\t\tprivateKey: Uint8Array,\n\t\tpublicKey?: Uint8Array\n\t): Promise<void>;\n\n\t/**\n\t * Get a key from the vault.\n\t * @param name The name of the key to get from the vault.\n\t * @param components Which key components to return, defaults to \"both\".\n\t * @returns The key, publicKey can be undefined if key is symmetric, privateKey can be undefined if only public was requested.\n\t * @throws GeneralError if \"private\" is requested for a symmetric key.\n\t */\n\tgetKey(\n\t\tname: string,\n\t\tcomponents?: \"public\" | \"private\" | \"both\"\n\t): Promise<{\n\t\t/**\n\t\t * The type of the key e.g. Ed25519.\n\t\t */\n\t\ttype: VaultKeyType;\n\n\t\t/**\n\t\t * The private key, undefined if only public component was requested.\n\t\t */\n\t\tprivateKey?: Uint8Array;\n\n\t\t/**\n\t\t * The public key, which can be undefined if key type is symmetric or only private was requested.\n\t\t */\n\t\tpublicKey?: Uint8Array;\n\t}>;\n\n\t/**\n\t * Check if a key exists in the vault.\n\t * @param name The name of the key to check.\n\t * @returns True if the key exists, false otherwise.\n\t */\n\tkeyExists(name: string): Promise<boolean>;\n\n\t/**\n\t * Get the type of a key from the vault without retrieving the key material.\n\t * @param name The name of the key.\n\t * @returns The key type.\n\t * @throws NotFoundError if the key does not exist.\n\t */\n\tgetKeyType(name: string): Promise<VaultKeyType>;\n\n\t/**\n\t * Rename a key in the vault.\n\t * @param name The name of the key to rename.\n\t * @param newName The new name of the key.\n\t * @returns A promise that resolves when the key has been renamed.\n\t */\n\trenameKey(name: string, newName: string): Promise<void>;\n\n\t/**\n\t * Remove a key from the vault.\n\t * @param name The name of the key to remove from the vault.\n\t * @returns A promise that resolves when the key has been removed.\n\t */\n\tremoveKey(name: string): Promise<void>;\n\n\t/**\n\t * Sign the data using a key in the vault.\n\t * @param name The name of the key to use for signing.\n\t * @param data The data to sign.\n\t * @returns The signature for the data.\n\t */\n\tsign(name: string, data: Uint8Array): Promise<Uint8Array>;\n\n\t/**\n\t * Verify the signature of the data using a key in the vault.\n\t * @param name The name of the key to use for verification.\n\t * @param data The data that was signed.\n\t * @param signature The signature to verify.\n\t * @returns True if the verification is successful.\n\t */\n\tverify(name: string, data: Uint8Array, signature: Uint8Array): Promise<boolean>;\n\n\t/**\n\t * Encrypt the data using a key in the vault.\n\t * @param name The name of the key to use for encryption.\n\t * @param encryptionType The type of encryption to use.\n\t * @param data The data to encrypt.\n\t * @returns The encrypted data.\n\t */\n\tencrypt(name: string, encryptionType: VaultEncryptionType, data: Uint8Array): Promise<Uint8Array>;\n\n\t/**\n\t * Decrypt the data using a key in the vault.\n\t * @param name The name of the key to use for decryption.\n\t * @param encryptionType The type of encryption to use.\n\t * @param encryptedData The data to decrypt.\n\t * @returns The decrypted data.\n\t */\n\tdecrypt(\n\t\tname: string,\n\t\tencryptionType: VaultEncryptionType,\n\t\tencryptedData: Uint8Array\n\t): Promise<Uint8Array>;\n\n\t/**\n\t * Store a secret in the vault.\n\t * @param name The name of the secret in the vault to set.\n\t * @param data The secret to add to the vault.\n\t * @returns A promise that resolves when the secret has been stored.\n\t */\n\tsetSecret<T>(name: string, data: T): Promise<void>;\n\n\t/**\n\t * Check if a secret exists in the vault.\n\t * @param name The name of the secret to check.\n\t * @returns True if the secret exists, false otherwise.\n\t */\n\tsecretExists(name: string): Promise<boolean>;\n\n\t/**\n\t * Get a secret from the vault.\n\t * @param name The name of the secret in the vault to get.\n\t * @returns The secret from the vault.\n\t * @throws Error if the secret is not found.\n\t */\n\tgetSecret<T>(name: string): Promise<T>;\n\n\t/**\n\t * Remove a secret from the vault.\n\t * @param name The name of the secret in the vault to remove.\n\t * @returns A promise that resolves when the secret has been removed.\n\t * @throws Error if the secret is not found.\n\t */\n\tremoveSecret(name: string): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The names of the vault encryption types.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const VaultEncryptionType = {
|
|
8
|
+
/**
|
|
9
|
+
* The ChaCha20Poly1305. (symmetric)
|
|
10
|
+
*/
|
|
11
|
+
ChaCha20Poly1305: 0
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=vaultEncryptionType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultEncryptionType.js","sources":["../../../src/models/vaultEncryptionType.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC;;OAEG;IACH,gBAAgB,EAAE,CAAC;CACV,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The names of the vault encryption types.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VaultEncryptionType = {\n\t/**\n\t * The ChaCha20Poly1305. (symmetric)\n\t */\n\tChaCha20Poly1305: 0\n} as const;\n\n/**\n * Vault encryption types.\n */\nexport type VaultEncryptionType = (typeof VaultEncryptionType)[keyof typeof VaultEncryptionType];\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The names of the vault key types.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const VaultKeyType = {
|
|
8
|
+
/**
|
|
9
|
+
* Ed25519. (asymmetric)
|
|
10
|
+
*/
|
|
11
|
+
Ed25519: 0,
|
|
12
|
+
/**
|
|
13
|
+
* The ChaCha20Poly1305. (symmetric)
|
|
14
|
+
*/
|
|
15
|
+
ChaCha20Poly1305: 2
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=vaultKeyType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultKeyType.js","sources":["../../../src/models/vaultKeyType.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B;;OAEG;IACH,OAAO,EAAE,CAAC;IAEV;;OAEG;IACH,gBAAgB,EAAE,CAAC;CACV,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The names of the vault key types.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VaultKeyType = {\n\t/**\n\t * Ed25519. (asymmetric)\n\t */\n\tEd25519: 0,\n\n\t/**\n\t * The ChaCha20Poly1305. (symmetric)\n\t */\n\tChaCha20Poly1305: 2\n} as const;\n\n/**\n * Vault key types.\n */\nexport type VaultKeyType = (typeof VaultKeyType)[keyof typeof VaultKeyType];\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Guards, UnauthorizedError } from "@3sixty/core";
|
|
4
|
+
import { Jwt } from "@3sixty/web";
|
|
5
|
+
/**
|
|
6
|
+
* Helpers for vault connectors.
|
|
7
|
+
*/
|
|
8
|
+
export class VaultConnectorHelper {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime name for the class.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "VaultConnectorHelper";
|
|
13
|
+
/**
|
|
14
|
+
* Sign a JWT using vault connector.
|
|
15
|
+
* @param vaultConnector The vault connector to use.
|
|
16
|
+
* @param keyName The name of the key to sign with.
|
|
17
|
+
* @param header The header to sign.
|
|
18
|
+
* @param payload The payload to sign.
|
|
19
|
+
* @returns The token.
|
|
20
|
+
*/
|
|
21
|
+
static async jwtSigner(vaultConnector, keyName, header, payload) {
|
|
22
|
+
Guards.object(VaultConnectorHelper.CLASS_NAME, "vaultConnector", vaultConnector);
|
|
23
|
+
Guards.stringValue(VaultConnectorHelper.CLASS_NAME, "keyName", keyName);
|
|
24
|
+
Guards.object(VaultConnectorHelper.CLASS_NAME, "header", header);
|
|
25
|
+
Guards.object(VaultConnectorHelper.CLASS_NAME, "payload", payload);
|
|
26
|
+
const signingBytes = Jwt.toSigningBytes(header, payload);
|
|
27
|
+
const signatureBytes = await vaultConnector.sign(keyName, signingBytes);
|
|
28
|
+
return Jwt.tokenFromBytes(signingBytes, signatureBytes);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Verify a JWT using a vault connector.
|
|
32
|
+
* @param vaultConnector The vault connector to use.
|
|
33
|
+
* @param keyName The name of the key to verify with.
|
|
34
|
+
* @param token The token to verify.
|
|
35
|
+
* @returns The header and payload if verification successful.
|
|
36
|
+
*/
|
|
37
|
+
static async jwtVerifier(vaultConnector, keyName, token) {
|
|
38
|
+
Guards.object(VaultConnectorHelper.CLASS_NAME, "vaultConnector", vaultConnector);
|
|
39
|
+
Guards.stringValue(VaultConnectorHelper.CLASS_NAME, "keyName", keyName);
|
|
40
|
+
Guards.stringValue(VaultConnectorHelper.CLASS_NAME, "token", token);
|
|
41
|
+
const { signingBytes, signature } = Jwt.tokenToBytes(token);
|
|
42
|
+
const verified = await vaultConnector.verify(keyName, signingBytes, signature);
|
|
43
|
+
if (!verified) {
|
|
44
|
+
throw new UnauthorizedError(VaultConnectorHelper.CLASS_NAME, "invalidSignature");
|
|
45
|
+
}
|
|
46
|
+
return Jwt.fromSigningBytes(signingBytes);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build a key name from parts.
|
|
50
|
+
* @param keyParts The parts of the key.
|
|
51
|
+
* @returns The constructed key name.
|
|
52
|
+
*/
|
|
53
|
+
static buildKeyName(...keyParts) {
|
|
54
|
+
return keyParts.join("/");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=vaultConnectorHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultConnectorHelper.js","sources":["../../../src/utils/vaultConnectorHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAqC,MAAM,aAAa,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;OAEG;IACI,MAAM,CAAU,UAAU,GAAW,sBAAsB,CAAC;IAEnE;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAC5B,cAA+B,EAC/B,OAAe,EACf,MAAkB,EAClB,OAAoB;QAEpB,MAAM,CAAC,MAAM,CACZ,oBAAoB,CAAC,UAAU,EAC/B,gBAAgB,EAChB,cAAc,CACd,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAEnE,MAAM,YAAY,GAAG,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzD,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACxE,OAAO,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAC9B,cAA+B,EAC/B,OAAe,EACf,KAAa;QAKb,MAAM,CAAC,MAAM,CACZ,oBAAoB,CAAC,UAAU,EAC/B,gBAAgB,EAChB,cAAc,CACd,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAE5D,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAC/E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAClF,CAAC;QAED,OAAO,GAAG,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,GAAG,QAAkB;QAC/C,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Guards, UnauthorizedError } from \"@3sixty/core\";\n\nimport { Jwt, type IJwtHeader, type IJwtPayload } from \"@3sixty/web\";\nimport type { IVaultConnector } from \"../models/IVaultConnector.js\";\n\n/**\n * Helpers for vault connectors.\n */\nexport class VaultConnectorHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = \"VaultConnectorHelper\";\n\n\t/**\n\t * Sign a JWT using vault connector.\n\t * @param vaultConnector The vault connector to use.\n\t * @param keyName The name of the key to sign with.\n\t * @param header The header to sign.\n\t * @param payload The payload to sign.\n\t * @returns The token.\n\t */\n\tpublic static async jwtSigner(\n\t\tvaultConnector: IVaultConnector,\n\t\tkeyName: string,\n\t\theader: IJwtHeader,\n\t\tpayload: IJwtPayload\n\t): Promise<string> {\n\t\tGuards.object<IVaultConnector>(\n\t\t\tVaultConnectorHelper.CLASS_NAME,\n\t\t\t\"vaultConnector\",\n\t\t\tvaultConnector\n\t\t);\n\t\tGuards.stringValue(VaultConnectorHelper.CLASS_NAME, \"keyName\", keyName);\n\t\tGuards.object(VaultConnectorHelper.CLASS_NAME, \"header\", header);\n\t\tGuards.object(VaultConnectorHelper.CLASS_NAME, \"payload\", payload);\n\n\t\tconst signingBytes = Jwt.toSigningBytes(header, payload);\n\t\tconst signatureBytes = await vaultConnector.sign(keyName, signingBytes);\n\t\treturn Jwt.tokenFromBytes(signingBytes, signatureBytes);\n\t}\n\n\t/**\n\t * Verify a JWT using a vault connector.\n\t * @param vaultConnector The vault connector to use.\n\t * @param keyName The name of the key to verify with.\n\t * @param token The token to verify.\n\t * @returns The header and payload if verification successful.\n\t */\n\tpublic static async jwtVerifier<T extends IJwtHeader, U extends IJwtPayload>(\n\t\tvaultConnector: IVaultConnector,\n\t\tkeyName: string,\n\t\ttoken: string\n\t): Promise<{\n\t\theader: T;\n\t\tpayload: U;\n\t}> {\n\t\tGuards.object<IVaultConnector>(\n\t\t\tVaultConnectorHelper.CLASS_NAME,\n\t\t\t\"vaultConnector\",\n\t\t\tvaultConnector\n\t\t);\n\t\tGuards.stringValue(VaultConnectorHelper.CLASS_NAME, \"keyName\", keyName);\n\t\tGuards.stringValue(VaultConnectorHelper.CLASS_NAME, \"token\", token);\n\n\t\tconst { signingBytes, signature } = Jwt.tokenToBytes(token);\n\n\t\tconst verified = await vaultConnector.verify(keyName, signingBytes, signature);\n\t\tif (!verified) {\n\t\t\tthrow new UnauthorizedError(VaultConnectorHelper.CLASS_NAME, \"invalidSignature\");\n\t\t}\n\n\t\treturn Jwt.fromSigningBytes(signingBytes);\n\t}\n\n\t/**\n\t * Build a key name from parts.\n\t * @param keyParts The parts of the key.\n\t * @returns The constructed key name.\n\t */\n\tpublic static buildKeyName(...keyParts: string[]): string {\n\t\treturn keyParts.join(\"/\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { IComponent } from "@3sixty/core";
|
|
2
|
+
import type { VaultEncryptionType } from "./vaultEncryptionType.js";
|
|
3
|
+
import type { VaultKeyType } from "./vaultKeyType.js";
|
|
4
|
+
/**
|
|
5
|
+
* Interface describing a vault securely storing data.
|
|
6
|
+
*/
|
|
7
|
+
export interface IVaultConnector extends IComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Generate a new key and store it in the vault.
|
|
10
|
+
* @param name The name of the key to generate and store in the vault.
|
|
11
|
+
* @param type The type of key to create.
|
|
12
|
+
* @returns The public key for the key pair.
|
|
13
|
+
*/
|
|
14
|
+
createKey(name: string, type: VaultKeyType): Promise<Uint8Array>;
|
|
15
|
+
/**
|
|
16
|
+
* Add an existing key to the vault.
|
|
17
|
+
* @param name The name of the key to add to the vault.
|
|
18
|
+
* @param type The type of key to add.
|
|
19
|
+
* @param privateKey The private key.
|
|
20
|
+
* @param publicKey The public key, can be undefined if the key type is symmetric.
|
|
21
|
+
* @returns A promise that resolves when the key has been stored.
|
|
22
|
+
*/
|
|
23
|
+
addKey(name: string, type: VaultKeyType, privateKey: Uint8Array, publicKey?: Uint8Array): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get a key from the vault.
|
|
26
|
+
* @param name The name of the key to get from the vault.
|
|
27
|
+
* @param components Which key components to return, defaults to "both".
|
|
28
|
+
* @returns The key, publicKey can be undefined if key is symmetric, privateKey can be undefined if only public was requested.
|
|
29
|
+
* @throws GeneralError if "private" is requested for a symmetric key.
|
|
30
|
+
*/
|
|
31
|
+
getKey(name: string, components?: "public" | "private" | "both"): Promise<{
|
|
32
|
+
/**
|
|
33
|
+
* The type of the key e.g. Ed25519.
|
|
34
|
+
*/
|
|
35
|
+
type: VaultKeyType;
|
|
36
|
+
/**
|
|
37
|
+
* The private key, undefined if only public component was requested.
|
|
38
|
+
*/
|
|
39
|
+
privateKey?: Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* The public key, which can be undefined if key type is symmetric or only private was requested.
|
|
42
|
+
*/
|
|
43
|
+
publicKey?: Uint8Array;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a key exists in the vault.
|
|
47
|
+
* @param name The name of the key to check.
|
|
48
|
+
* @returns True if the key exists, false otherwise.
|
|
49
|
+
*/
|
|
50
|
+
keyExists(name: string): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Get the type of a key from the vault without retrieving the key material.
|
|
53
|
+
* @param name The name of the key.
|
|
54
|
+
* @returns The key type.
|
|
55
|
+
* @throws NotFoundError if the key does not exist.
|
|
56
|
+
*/
|
|
57
|
+
getKeyType(name: string): Promise<VaultKeyType>;
|
|
58
|
+
/**
|
|
59
|
+
* Rename a key in the vault.
|
|
60
|
+
* @param name The name of the key to rename.
|
|
61
|
+
* @param newName The new name of the key.
|
|
62
|
+
* @returns A promise that resolves when the key has been renamed.
|
|
63
|
+
*/
|
|
64
|
+
renameKey(name: string, newName: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Remove a key from the vault.
|
|
67
|
+
* @param name The name of the key to remove from the vault.
|
|
68
|
+
* @returns A promise that resolves when the key has been removed.
|
|
69
|
+
*/
|
|
70
|
+
removeKey(name: string): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Sign the data using a key in the vault.
|
|
73
|
+
* @param name The name of the key to use for signing.
|
|
74
|
+
* @param data The data to sign.
|
|
75
|
+
* @returns The signature for the data.
|
|
76
|
+
*/
|
|
77
|
+
sign(name: string, data: Uint8Array): Promise<Uint8Array>;
|
|
78
|
+
/**
|
|
79
|
+
* Verify the signature of the data using a key in the vault.
|
|
80
|
+
* @param name The name of the key to use for verification.
|
|
81
|
+
* @param data The data that was signed.
|
|
82
|
+
* @param signature The signature to verify.
|
|
83
|
+
* @returns True if the verification is successful.
|
|
84
|
+
*/
|
|
85
|
+
verify(name: string, data: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Encrypt the data using a key in the vault.
|
|
88
|
+
* @param name The name of the key to use for encryption.
|
|
89
|
+
* @param encryptionType The type of encryption to use.
|
|
90
|
+
* @param data The data to encrypt.
|
|
91
|
+
* @returns The encrypted data.
|
|
92
|
+
*/
|
|
93
|
+
encrypt(name: string, encryptionType: VaultEncryptionType, data: Uint8Array): Promise<Uint8Array>;
|
|
94
|
+
/**
|
|
95
|
+
* Decrypt the data using a key in the vault.
|
|
96
|
+
* @param name The name of the key to use for decryption.
|
|
97
|
+
* @param encryptionType The type of encryption to use.
|
|
98
|
+
* @param encryptedData The data to decrypt.
|
|
99
|
+
* @returns The decrypted data.
|
|
100
|
+
*/
|
|
101
|
+
decrypt(name: string, encryptionType: VaultEncryptionType, encryptedData: Uint8Array): Promise<Uint8Array>;
|
|
102
|
+
/**
|
|
103
|
+
* Store a secret in the vault.
|
|
104
|
+
* @param name The name of the secret in the vault to set.
|
|
105
|
+
* @param data The secret to add to the vault.
|
|
106
|
+
* @returns A promise that resolves when the secret has been stored.
|
|
107
|
+
*/
|
|
108
|
+
setSecret<T>(name: string, data: T): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if a secret exists in the vault.
|
|
111
|
+
* @param name The name of the secret to check.
|
|
112
|
+
* @returns True if the secret exists, false otherwise.
|
|
113
|
+
*/
|
|
114
|
+
secretExists(name: string): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Get a secret from the vault.
|
|
117
|
+
* @param name The name of the secret in the vault to get.
|
|
118
|
+
* @returns The secret from the vault.
|
|
119
|
+
* @throws Error if the secret is not found.
|
|
120
|
+
*/
|
|
121
|
+
getSecret<T>(name: string): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Remove a secret from the vault.
|
|
124
|
+
* @param name The name of the secret in the vault to remove.
|
|
125
|
+
* @returns A promise that resolves when the secret has been removed.
|
|
126
|
+
* @throws Error if the secret is not found.
|
|
127
|
+
*/
|
|
128
|
+
removeSecret(name: string): Promise<void>;
|
|
129
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of the vault encryption types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const VaultEncryptionType: {
|
|
5
|
+
/**
|
|
6
|
+
* The ChaCha20Poly1305. (symmetric)
|
|
7
|
+
*/
|
|
8
|
+
readonly ChaCha20Poly1305: 0;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Vault encryption types.
|
|
12
|
+
*/
|
|
13
|
+
export type VaultEncryptionType = (typeof VaultEncryptionType)[keyof typeof VaultEncryptionType];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of the vault key types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const VaultKeyType: {
|
|
5
|
+
/**
|
|
6
|
+
* Ed25519. (asymmetric)
|
|
7
|
+
*/
|
|
8
|
+
readonly Ed25519: 0;
|
|
9
|
+
/**
|
|
10
|
+
* The ChaCha20Poly1305. (symmetric)
|
|
11
|
+
*/
|
|
12
|
+
readonly ChaCha20Poly1305: 2;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Vault key types.
|
|
16
|
+
*/
|
|
17
|
+
export type VaultKeyType = (typeof VaultKeyType)[keyof typeof VaultKeyType];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type IJwtHeader, type IJwtPayload } from "@3sixty/web";
|
|
2
|
+
import type { IVaultConnector } from "../models/IVaultConnector.js";
|
|
3
|
+
/**
|
|
4
|
+
* Helpers for vault connectors.
|
|
5
|
+
*/
|
|
6
|
+
export declare class VaultConnectorHelper {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Sign a JWT using vault connector.
|
|
13
|
+
* @param vaultConnector The vault connector to use.
|
|
14
|
+
* @param keyName The name of the key to sign with.
|
|
15
|
+
* @param header The header to sign.
|
|
16
|
+
* @param payload The payload to sign.
|
|
17
|
+
* @returns The token.
|
|
18
|
+
*/
|
|
19
|
+
static jwtSigner(vaultConnector: IVaultConnector, keyName: string, header: IJwtHeader, payload: IJwtPayload): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Verify a JWT using a vault connector.
|
|
22
|
+
* @param vaultConnector The vault connector to use.
|
|
23
|
+
* @param keyName The name of the key to verify with.
|
|
24
|
+
* @param token The token to verify.
|
|
25
|
+
* @returns The header and payload if verification successful.
|
|
26
|
+
*/
|
|
27
|
+
static jwtVerifier<T extends IJwtHeader, U extends IJwtPayload>(vaultConnector: IVaultConnector, keyName: string, token: string): Promise<{
|
|
28
|
+
header: T;
|
|
29
|
+
payload: U;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Build a key name from parts.
|
|
33
|
+
* @param keyParts The parts of the key.
|
|
34
|
+
* @returns The constructed key name.
|
|
35
|
+
*/
|
|
36
|
+
static buildKeyName(...keyParts: string[]): string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.20.0-next.1](https://github.com/3sixtyglobal/vault/compare/vault-models-v0.20.0-next.0...vault-models-v0.20.0-next.1) (2026-10-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* publish packages under the [@3sixty](https://github.com/3sixty) namespace ([a32b1e0](https://github.com/3sixtyglobal/vault/commit/a32b1e0dfc861076908bb8c9532f37f24cbc6baf))
|
|
9
|
+
* updated ts compile ([77b7687](https://github.com/3sixtyglobal/vault/commit/77b76879092f9be9408b43e3136a29e69f14972c))
|