- Add optional feature (disabled by default) to enable lookups of pairwise
token records by value. This is useful for applications that need to
quickly resolve a pairwise token to an
internalId
. - Add
tokens.resolvePairwiseToken
to resolve a pairwise token to aninternalId
. - Expose
getPairwiseToken()
andupsertPairwiseToken()
for external use.
- BREAKING: Update index on
registration.creatorHash
to compound index includingmeta.created
. Existing deployments will need to drop the current index.
- Ensure an expired (but still present in the database) document registration record will be updated when a registration attempt using a matching document is attempted.
- Add
documents.getCount({query})
API which retrieves the total count of document records that match the specified query. - Add an index on
registration.creatorHash
field fortokenization-registration
collection.
- Ensure expired pairwise tokens are refreshed and reused if they are found during a resolution process prior to their eviction from the database.
- Ensure pairwise token upsert does not loop because of an expired pairwise
token record. If an expired record has not been removed from the database
when it needs to be used again (during an
upsert
), it will be auto-refreshed. External processes must remove expired pairwise token records if theautoRemoveExpiredRecords
configuration option is not used to cause new pairwise tokens to be generated after expiration.
- BREAKING: Update peer deps:
- Use
@bedrock/did-io@10
. This version requires Node.js 16+. - Use
@bedrock/tokenizer@10
. This version requires Node.js 18+.
- Use
- Update test deps.
- Add
entities.getCount({query})
API which retrieves the total count of entity records that match the specified query. - Add an index on
meta.created
field fortokenization-entity
collection. - Add a compound index on
entity.minAssuranceForResolution
andmeta.created
fields fortokenization-entity
collection.
- BREAKING: Drop support for Node.js 16.
- Add
resolveToEntity
to ensure that when resolving a token to an entity that the token used, if unpinned, has not been invalidated. This helper function is for internal use and does not track resolution of the used token against a particular party. It's primary use case is for obtaining an entity to set itsminAssuranceForResolution
.
- Include
validUntil
in token resolution meta data. This value indicates the lastDate
at which the token that was resolved will be valid.
- BREAKING: Added a config option,
autoRemoveExpiredRecords
, to control whether expired records are automatically removed via built-in MongoDB TTL indexes (true = yes, false = no). This is a breaking change because the option is set tofalse
by default, thereby preserving all records that have expired. Previous behavior automatically removed these records after ~24 hours via built-in MongoDB TTL indexes. If this config option is set tofalse
on a system where it was previously set totrue
, then any instance running with this configuration will NOT delete existing TTL indexes. Setting it totrue
on a system where it was previouslyfalse
will result in the creation of new TTL indexes. These TTL indexes will result in the eventual removal of any records that have expired at least 24 hours ago. Note that upgrading a system that used a previous version will require first upgrading the software and then, if the configuration option is set tofalse
, the manual removal of the existing TTL indexes.
- When new token batches are created for a specific entity, restrict document
registration record refreshes to those records that match the
internalId
associated with the entity. Previous refreshes unnecessarily refreshed registration records that did not match theinternalId
.
- BREAKING: Make default token batch TTL 240 instead of 120 days.
- BREAKING: Use little-endian orders bits in the bitstrings
used to track token resolution. This is implemented by using the default
options via
@digitalbazaar/bitstring@3
. Any deployment using a previous version of this module will need to be manually migrated or drop its databases.
- Add
validUntil
property in token creation results. This property expresses theDate
at which the latest token will expire. Other returns tokens may expire sooner, but the last token in returned will be valid until the givenDate
.
- Mark entity record with the token batch ID associated with the last
failure to resolve a token due to level of assurance not being met. This
tracking is useful in making decisions about whether to lower the minimum
required level of assurance for an entity. For example, an application may
opt not to lower the
minAssuranceForResolution
on an entity if its token batches have been invalidated since the last time a token failed to resolve based on assurance not being met. - Allow full
entity
to be passed tosetMinAssuranceForResolution
to enable the call to returnfalse
if the entity'sbatchInvalidationCount
has changed or if there is no tracked assurance-failed token resolution. This allows the caller to be sure that no batch invalidation events after the last time a token failed resolution because of a level of assurance that was too low. - Allow
lastBatchInvalidationNotAfter
to be passed tosetMinAssuranceForResolution
. This optional parameter prevents an entity'sminAssuranceForResolution
from being set if its unpinned token batches have been invalidated after the passedDate
. The defaultDate
is set to be 15 minutes before system time. This check will only be run when therequireAssuranceFailedTokenResolution
flag is set totrue
(which is also the default). When this flag istrue
, theminAssuranceForResolution
will not be set unless a still-valid assurance-failed token resolution is found and no token batch invalidation has occurred after the specifiedlastBatchInvalidationNotAfter
Date
. This ensures that if a user is known to have provided an unpinned token that failed resolution due to a level of assurance that was too low -- that no other user could have done the same within the specified time limit.
- Add
tokens.updateEntityWithNoValidTokenBatches
to enable setting an entity'sminAssuranceForResolution
and invalidating unpinned token batches that are in the process of being created -- if and only if the entity has no current valid unpinned token batches. This method provides a safe mechanism for updating this value only when no valid unpinned token batches exist even if concurrent other processes are making changes to the entity, including adding new unpinned token batches. The method will throw if the entity's state is modified from the current state and will fail (returnfalse
) if the entity has any valid unpinned token batches.
- BREAKING: Default batch version option
ttl
has been changed from 60 to 120 days. This change will not take affect in existing deployments unless active batch versions are updated in the database. - BREAKING: Ensure batch versions cannot be created without an associated
tokenizerId
. It was invalid to create such batch versions before, but now the API enforces it. - BREAKING: Allow multiple batch versions to be associated with the same
tokenizer ID, without preventing auto-creation of a new batch version when
tokenizer auto-rotation occurs. Existing deployments will have to manually
remove the unique
batchVersion.tokenizerId
index to make it run properly with this new version. - BREAKING: The default grace period for removing records that match a
TTL index value (controlled by the option
expireAfterSeconds
) has been changed from0
to 24 hours. Existing deployments must manually modify the registration, entity, and token batch collection TTL indexes to use this new value or else a conflicting index error will be thrown on startup. - BREAKING: Pairwise tokens are now auto-expired via a TTL index. They will expire based on the TTL associated with the token (more specifically with that token's batch) that was most recently resolved. If a pairwise token already existed for a new token resolution (to the same entity and for the same requester but for a new token batch), then its expiration period will be extended to be at least as long as that new token's TTL.
- BREAKING: Prevent unpinned token batch invalidation via calls to
invalidateTokenBatches
from taking effect if theentity
passed has a value forminAssuranceForResolution
that does not match the value in the database. This ensures that concurrent changes to that value and tobatchInvalidationCount
are bound together and detectable. - BREAKING: Ensure that entity and document registration records are
updated (expiration period extended) when new token batches are created.
This involves storing
externalIdHash
in entity records -- where it was not previously stored. Existing deployments would need users to resubmit document registrations to add these values to entity records to ensure that the new expiration extension code runs and preserves document registration records at least as long as the token batches associated with them.
- Use
@digitalbazaar/[email protected]
to get chacha bug fix.
- BREAKING: Drop support for Node.js < 16. This is in accordance with the
requirements of
@digitalbazaar/minimal-cipher@5
. - BREAKING: Update peer deps:
@bedrock/did-io@9
@bedrock/tokenizer@9
.
- Return additional meta information about a resolved token from
resolve()
including whether it is unpinned and itsminAssuranceForResolution
at resolution time.
- BREAKING: Update peer deps:
@bedrock/core@6
@bedrock/did-io@8
@bedrock/https-agent@4
@bedrock/mongodb@10
@bedrock/tokenizer@8
.
- Ensure that the level of assurance for already-resolved, unpinned tokens is still checked before returning the associated pairwise token.
- Do not pass database write options from config unless database options are modified. Future revisions will remove passing the options from the config entirely if determined correct.
- BREAKING: Rename package to
@bedrock/tokenization
. - BREAKING: Convert to module (ESM).
- BREAKING: Remove default export.
- BREAKING: Require node 14.x.
- BREAKING: Update peer dependencies:
bedrock-tokenizer@6
- BREAKING: Update peer dependencies:
bedrock-tokenizer@5
- BREAKING: Update peer dependencies:
bedrock-tokenizer@4
[email protected]
(non-breaking)
- Improve error messages in
_parseToken
helper function.
- This module was erroneously requiring
bedrock-did-io
as a regular dependency instead of a peer dependency which can lead to broken behavior in some installs. This has been fixed and the version bumped (but both versions are compatible as long as they are installed as peer dependencies).
- Use
bedrock-did-io@6
as a peer dependency. This module is still compatible with version 5, so this is not a breaking change, just a recommendation for using version 6.
- BREAKING: Update peer dependencies.
- Update
bedrock-tokenizer
tov3.0
. - Update
bedrock
tov4.4.3
. - Update
bedrock-mongodb
tov8.4.1
.
- Update
- Use
[email protected]
which uses[email protected]
. - Remove unused package
pako
. - Update test dependencies.
- Add missing packages
base64url-universal
andesm
.
- Added optional
explain
param to get more details about database performance for entities. - Added database tests in order to check database performance for entities.
- Fixed bug with
sort
in the_getNextVersionId()
helper function.
- Added optional
explain
param to get more details about database performance. - Added database tests in order to check database performance.
- Exposed helper functions in order to properly test database calls.
- Do not base64url-decode
hmac.sign
result, the API now returns a Uint8Array already.
- Add tests for
documents._hmacString
.
- Improve internal type checking in API.
- Simplify configuration of test suite.
- BREAKING: Updated
bedrock-tokenizer
tov2.0.0
which nows requires a meter to be configured for use with the WebKMS Service. - BREAKING: Added default
false
flagallowResolvedInvalidatedTokens
toresolve
. Setting this flag to true will allow already resolved but subsequently invalidated tokens to be resolved again. - BREAKING: Updated
minimal-cipher
tov4.0.0
which now uses@digitalbazaar/x25519-verification-key-2020
, changed@digitalbazaar/did-io
tobedrock-did-io
, and removed@digitalbazaar/did-method-key
.
- Added missing return value
internalId
fromresolve
.
- Added
batchInvalidationCount
as a parameter to_createBatch
.
- Added
batchInvalidationCount
as a parameter to_insertBatch
.
- BREAKING: Use latest
cborld
v4 andcit-context
v2.
- Fix case where an entity could be updated to invalidate unpinned token
batches but the process may crash prior (or while) updating unpinned token
batch records to mark them as invalid. Now, unpinned token batches are
immediately invalidated when the entity record is updated, without needing
to update their records. The invalidation state is determined by comparing
the monotonically increasing
batchInvalidationCount
on both the token batch record and the entity record, both of which always have to be retrieved when resolving an unpinned token anyway. So, there is no degradation to performance with this patch. In fact, since token batches no longer need to be updated with aninvalid
flag, performance is significantly improved in the case that batches must be invalidated because only one record is ever needed to be updated (the entity record). Updating token batch records to mark them invalid also involved a scatter-gather approach before so it was especially taxing; this has all been removed.
- BREAKING: Remove now unnecessary index on
tokenBatch.internalId
. This index was used to mark unpinned token batches as invalid and another simpler and more robust mechanism is now used instead. The presence of this index in upgraded systems should not create a logic problem, however, it does degrade performance and take up space, so it should be removed. - BREAKING: Remove
invalid
flag on token batches and replace it with thebatchInvalidationCount
flag copied from the entity at record creation time.
- Added a fix to create entities for existing registrations. This only applies to versions prior to 5.0.0, since new entities are automatically created.
tokens.resolve
now returnsinternalId
along with existingpairwiseToken
. While this is a backwards-compatible change, callers should ensure thatinternalId
is not leaked beyond any important trust boundaries (e.g., not to the party that requested resolution). While this is a backwards-compatible change, callers should ensure thatinternalId
is not leaked beyond any important trust boundaries (e.g., not to the party that requested resolution).
- BREAKING: Implement new required field
levelOfAssurance
in resolve endpoint. - BREAKING: Implement new required field
minAssuranceForResolution
in create endpoint. - Add
minAssuranceForResolution
for token batches. This value indicates the minimum identity assurance level that must be provided for a token to be resolved. This field may be attached to a token batch (this type of batch is referred to as "pinned" to a particularminAssuranceForResolution
) and it is set on the new primitiveentity
(see below). The value onentity
will be inherited by "unpinned" token batches -- such that the tokens issued from these batches always use the value associated withentity
rather than a "pinned" value of their own. This enables token batches to be issued to holders by systems/processes whereby the holder is unable to provide sufficient identity assurance -- but where they should be able to provide it later to another system/via another process. Once provided elsewhere, the token batches that were issued to them previously will inherit a new, lower required assurance allowing for more streamlined token resolution flows. This approach also requires the ability to invalidate any previously created unpinned token batches if new ones are created prior to identity assurance being provided. A newtokens.invalidateTokenBatches
API enables the caller to invalidate these unpinned token batches prior to issuing tokens to a new similarly unverified holder. This ensures that these unpinned tokens will continue to require a high level of identity assurance until the holder is verified -- and that no holder that has not provided that assurance can use the tokens with a reduced level of assurance. - Added new
tokenization-entity
collection. When transitioning to this new version, this collection should be automatically created. If you are working with a sharded database, this collection should be sharded onentity.internalId
, which is the core and unique index for this collection. - Added new
entities
API. This API can be used to retrieve entity records via theinternalId
that uniquely identifies an entity. An entity may have multiple registrations (each a different document) that are all bound byinternalId
. A call toentities.setMinAssuranceForResolution
will set theminAssuranceForResolution
associated with an entity. This value will be inherited by "unpinned" token batches and it will not affect "pinned" token batches.
- BREAKING: Calls to
tokens.create
require a previous call to register the entity associated withinternalId
or parametersregisterPromise
andnewRegistration
that indicate a registration is being performed concurrently.
- BREAKING: Removed
tokenization-openTokenBatch
collection. In order to transition to this new version, this collection can be safely dropped.
- Remove duplicate conditional in the
documents.register
API.
- Use [email protected].
- Implement
recipientChain
param fordocuments.register()
. - Implement
documents.getRegistration()
.
- Update peer deps.
- BREAKING: Changed format for storing token resolutions.
- BREAKING: Use BinData for storing IDs, hashes, and bit strings.
- Use [email protected].
- BREAKING: Updated CIT context, add Ed25519Signature2020 cryptosuite.
- Added core files.
- See git history for changes.