File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -52,19 +52,33 @@ export async function fetchWrappedKey(
52
52
53
53
export type KasPublicKeyAlgorithm = 'ec:secp256r1' | 'rsa:2048' ;
54
54
55
+ /**
56
+ * Information about one of a KAS's published public keys.
57
+ * A KAS may publish multiple keys with a given algorithm type.
58
+ */
55
59
export type KasPublicKeyInfo = {
60
+ /** The locator to the given KAS associated with this key */
56
61
url : string ;
62
+
63
+ /** The encryption algorithm the key is to be used with. */
57
64
algorithm : KasPublicKeyAlgorithm ;
65
+
66
+ /** If present, an identifier which is tied to this specific key. */
58
67
kid ?: string ;
68
+
69
+ /** The key value, encoded within a PEM envelope */
59
70
publicKey : string ;
71
+
72
+ /** A subtle crypto version of the key.
73
+ * This can be used for wrapping key data for key access objects (with RSA)
74
+ * or to derive key data (with EC keys). */
60
75
key : Promise < CryptoKey > ;
61
76
} ;
62
77
63
78
/**
64
79
* If we have KAS url but not public key we can fetch it from KAS, fetching
65
80
* the value from `${kas}/kas_public_key`.
66
81
*/
67
-
68
82
export async function fetchECKasPubKey ( kasEndpoint : string ) : Promise < KasPublicKeyInfo > {
69
83
validateSecureUrl ( kasEndpoint ) ;
70
84
const pkUrlV2 = `${ kasEndpoint } /v2/kas_public_key?algorithm=ec:secp256r1&v=2` ;
Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ export default class ResourceLocator {
36
36
readonly idType : ResourceLocatorIdentifierEnum = ResourceLocatorIdentifierEnum . None
37
37
) { }
38
38
39
+ /**
40
+ * Construct a new URL or URL + identifier pair, for use with NanoTDF envelopes.
41
+ * @param url The URL to encrypt; `http` and `https` schemes are supported
42
+ * @param identifier An optional identifier.
43
+ * For KAS URLs, this is usually a public key identifier (kid). Limit 32 characters
44
+ * @returns a value representing the URL and identifier, if present.
45
+ * This method throws an Error if the URL is invalid or of the wrong schema,
46
+ * or if the identifier is an unsupported value.
47
+ */
39
48
static fromURL ( url : string , identifier ?: string ) : ResourceLocator {
40
49
const [ protocolStr , body ] = url . split ( '://' ) ;
41
50
You can’t perform that action at this time.
0 commit comments