How to use the @aws-crypto/serialize.Maximum.MESSAGES_PER_CACHED_KEY_LIMIT function in @aws-crypto/serialize

To help you get started, we’ve selected a few @aws-crypto/serialize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-encryption-sdk-javascript / modules / cache-material / src / caching_cryptographic_materials_decorators.ts View on Github external
export function decorateProperties<s> (
  obj: CachingMaterialsManager<s>,
  input: CachingMaterialsManagerDecorateInput<s>
) {
  const { cache, backingMaterialsManager, maxAge, maxBytesEncrypted, maxMessagesEncrypted, partition } = input

  /* Precondition: A caching material manager needs a cache. */
  needs(cache, 'You must provide a cache.')
  /* Precondition: A caching material manager needs a way to get material. */
  needs(backingMaterialsManager, 'You must provide a backing material source.')
  /* Precondition: You *can not* cache something forever. */
  needs(maxAge &gt; 0, 'You must configure a maxAge')
  /* Precondition: maxBytesEncrypted must be inside bounds.  i.e. positive and not more than the maximum. */
  needs(!maxBytesEncrypted || (maxBytesEncrypted &gt; 0 &amp;&amp; Maximum.BYTES_PER_CACHED_KEY_LIMIT &gt;= maxBytesEncrypted), 'maxBytesEncrypted is outside of bounds.')
  /* Precondition: maxMessagesEncrypted must be inside bounds.  i.e. positive and not more than the maximum. */
  needs(!maxMessagesEncrypted || (maxMessagesEncrypted &gt; 0 &amp;&amp; Maximum.MESSAGES_PER_CACHED_KEY_LIMIT &gt;= maxMessagesEncrypted), 'maxMessagesEncrypted is outside of bounds.')
  /* Precondition: partition must be a string. */
  needs(partition &amp;&amp; typeof partition === 'string', 'partition must be a string.')

  readOnlyProperty(obj, '_cache', cache)
  readOnlyProperty(obj, '_backingMaterialsManager', backingMaterialsManager)
  readOnlyProperty(obj, '_maxAge', maxAge)
  readOnlyProperty(obj, '_maxBytesEncrypted', maxBytesEncrypted || Maximum.BYTES_PER_CACHED_KEY_LIMIT)
  readOnlyProperty(obj, '_maxMessagesEncrypted', maxMessagesEncrypted || Maximum.MESSAGES_PER_CACHED_KEY_LIMIT)
  readOnlyProperty(obj, '_partition', partition)
}
</s></s></s>
github aws / aws-encryption-sdk-javascript / modules / cache-material / src / caching_cryptographic_materials_decorators.ts View on Github external
/* Precondition: A caching material manager needs a way to get material. */
  needs(backingMaterialsManager, 'You must provide a backing material source.')
  /* Precondition: You *can not* cache something forever. */
  needs(maxAge > 0, 'You must configure a maxAge')
  /* Precondition: maxBytesEncrypted must be inside bounds.  i.e. positive and not more than the maximum. */
  needs(!maxBytesEncrypted || (maxBytesEncrypted > 0 && Maximum.BYTES_PER_CACHED_KEY_LIMIT >= maxBytesEncrypted), 'maxBytesEncrypted is outside of bounds.')
  /* Precondition: maxMessagesEncrypted must be inside bounds.  i.e. positive and not more than the maximum. */
  needs(!maxMessagesEncrypted || (maxMessagesEncrypted > 0 && Maximum.MESSAGES_PER_CACHED_KEY_LIMIT >= maxMessagesEncrypted), 'maxMessagesEncrypted is outside of bounds.')
  /* Precondition: partition must be a string. */
  needs(partition && typeof partition === 'string', 'partition must be a string.')

  readOnlyProperty(obj, '_cache', cache)
  readOnlyProperty(obj, '_backingMaterialsManager', backingMaterialsManager)
  readOnlyProperty(obj, '_maxAge', maxAge)
  readOnlyProperty(obj, '_maxBytesEncrypted', maxBytesEncrypted || Maximum.BYTES_PER_CACHED_KEY_LIMIT)
  readOnlyProperty(obj, '_maxMessagesEncrypted', maxMessagesEncrypted || Maximum.MESSAGES_PER_CACHED_KEY_LIMIT)
  readOnlyProperty(obj, '_partition', partition)
}