Skip to main content

Class: BaseSecretRouteSQL

Defined in: src/routes/sql/BaseSecretRouteSQL.ts:10

Extends

Constructors

Constructor

new BaseSecretRouteSQL(): BaseSecretRouteSQL

Returns

BaseSecretRouteSQL

Inherited from

BaseSecretRoute.constructor

Properties

aclUtils?

protected optional aclUtils?: ACLUtils

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:102

Inherited from

BaseSecretRoute.aclUtils


cacheClient?

protected optional cacheClient?: Redis

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:104

The redis client that will be used as a 2nd level cache for all cacheable models.

Inherited from

BaseSecretRoute.cacheClient


config?

protected optional config?: any

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:106

The global application configuration.

Inherited from

BaseSecretRoute.config


defaultACLUid

protected defaultACLUid: string

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:108

The unique identifier of the default ACL for the model type.

Inherited from

BaseSecretRoute.defaultACLUid


fido2Config

protected fido2Config: PasskeyConfig

Defined in: src/routes/BaseSecretRoute.ts:54

The relying party configuration used for validating and generating FIDO2 hardware security key (WebAuthn) registration data. Kept separate from passkeyConfig since a hardware key deployment commonly wants a different authenticatorAttachment/residentKey policy — a hardware key is typically registered as a "cross-platform", non-discoverable credential tied to a known account, rather than a discoverable, possibly-synced passkey.

Inherited from

BaseSecretRoute.fido2Config


logger

protected logger: any

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:109

Inherited from

BaseSecretRoute.logger


notificationUtils?

protected optional notificationUtils?: NotificationUtils

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:110

Inherited from

BaseSecretRoute.notificationUtils


objectFactory?

protected optional objectFactory?: ObjectFactory

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:111

Inherited from

BaseSecretRoute.objectFactory


passkeyConfig

protected passkeyConfig: PasskeyConfig

Defined in: src/routes/BaseSecretRoute.ts:40

The relying party configuration used for validating and generating passkey (WebAuthn) registration data.

Inherited from

BaseSecretRoute.passkeyConfig


repoUtils?

protected optional repoUtils?: RepoUtils<SecretSQL>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:115

The repository utility class to use for common operations.

Inherited from

BaseSecretRoute.repoUtils


repoUtilsClass

protected readonly repoUtilsClass: any = RepoUtils

Defined in: src/routes/BaseSecretRoute.ts:34

The class of the RepoUtils to use when instantiating the utility.

Inherited from

BaseSecretRoute.repoUtilsClass


totpConfig

protected totpConfig: TOTPConfig

Defined in: src/routes/BaseSecretRoute.ts:66

The issuer configuration used for validating and generating TOTP (RFC 6238) registration data.

Inherited from

BaseSecretRoute.totpConfig


trackChanges

protected trackChanges: number

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:120

The number of previous document versions to store in the database. A negative value indicates storing all versions, a value of 0 stores no versions.

Inherited from

BaseSecretRoute.trackChanges


trustedRoles

protected trustedRoles: string[]

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:121

Inherited from

BaseSecretRoute.trustedRoles

Accessors

modelClass

Get Signature

get modelClass(): any

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:125

The class type of the model this route is associated with.

Returns

any

Inherited from

BaseSecretRoute.modelClass

Methods

cleanData()

protected cleanData(obj): void

Defined in: src/routes/BaseSecretRoute.ts:77

Removes the data property from the secret(s) to protect sensitive information.

Parameters

obj

SecretSQL | SecretSQL[]

Returns

void

Inherited from

BaseSecretRoute.cleanData


count()

count(params, query, res, user?): Promise<any>

Defined in: src/routes/BaseSecretRoute.ts:91

Parameters

params

any

query

any

res

HttpResponse

user?

JWTUser

Returns

Promise<any>

Inherited from

BaseSecretRoute.count


create()

create(obj, req, user?): Promise<SecretSQL | SecretSQL[]>

Defined in: src/routes/BaseSecretRoute.ts:323

Parameters

obj

SecretSQL | SecretSQL[]

req

HttpRequest

user?

JWTUser

Returns

Promise<SecretSQL | SecretSQL[]>

Inherited from

BaseSecretRoute.create


delete()

delete(id, version, purge, req, user?): Promise<void>

Defined in: src/routes/BaseSecretRoute.ts:350

Parameters

id

string

version

string | undefined

purge

string | undefined

req

HttpRequest

user?

JWTUser

Returns

Promise<void>

Inherited from

BaseSecretRoute.delete


doBulkCreate()

protected doBulkCreate(objs, options): Promise<SecretSQL[]>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:154

Attempts to store a collection of objects provided in options.req.body into the datastore. Upon success, sets the newly persisted object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the client.

Parameters

objs

Partial<SecretSQL>[]

The object(s) to store in the database.

options

CreateRequestOptions

The options to process the request using.

Returns

Promise<SecretSQL[]>

Inherited from

BaseSecretRoute.doBulkCreate


doBulkUpdate()

protected doBulkUpdate(objs, options): Promise<SecretSQL[]>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:206

Attempts to modify a collection of existing data model objects.

Parameters

objs

UpdateObject<SecretSQL>[]

The object(s) to bulk update in the database.

options

UpdateRequestOptions<SecretSQL>

The options to process the request using.

Returns

Promise<SecretSQL[]>

Inherited from

BaseSecretRoute.doBulkUpdate


doCount()

protected doCount(options): Promise<HttpResponse>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:136

Attempts to retrieve the number of data model objects matching the given set of criteria as specified in the request query. Any results that have been found are set to the content-length header of the res argument.

Parameters

options

FindRequestOptions

The options to process the request using.

Returns

Promise<HttpResponse>

Inherited from

BaseSecretRoute.doCount


doCreate()

protected doCreate(obj, options): Promise<SecretSQL | SecretSQL[]>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:163

Attempts to store one or more objects provided in options.req.body into the datastore. Upon success, sets the newly persisted object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the client.

Parameters

obj

Partial<SecretSQL> | Partial<SecretSQL>[]

The object(s) to store in the database.

options

CreateRequestOptions

The options to process the request using.

Returns

Promise<SecretSQL | SecretSQL[]>

Inherited from

BaseSecretRoute.doCreate


doCreateObject()

protected doCreateObject(obj, options): Promise<SecretSQL>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:145

Attempts to store an object provided in options.req.body into the datastore. Upon success, sets the newly persisted object(s) to the result property of the options.res argument, otherwise sends a 400 BAD REQUEST response to the client.

Parameters

obj

Partial<T>

The object to store in the database.

options

CreateRequestOptions

The options to process the request using.

Returns

Promise<SecretSQL>

Inherited from

BaseSecretRoute.doCreateObject


doDelete()

protected doDelete(id, options): Promise<void>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:171

Attempts to delete an existing data model object with a given unique identifier encoded by the URI parameter id.

Parameters

id

string

The unique identifier of the object to delete.

options

DeleteRequestOptions

The options to process the request using.

Returns

Promise<void>

Inherited from

BaseSecretRoute.doDelete


doExists()

protected doExists(id, options): Promise<any>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:178

Attempts to determine if an existing object with the given unique identifier exists.

Parameters

id

string

The unique identifier of the object to verify exists.

options

FindRequestOptions

The options to process the request using.

Returns

Promise<any>

Inherited from

BaseSecretRoute.doExists


doFind()

protected doFind(options): Promise<SecretSQL[]>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:186

Attempts to retrieve all data model objects matching the given set of criteria as specified in the request query. Any results that have been found are set to the result property of the res argument. result is never null.

Parameters

options

FindRequestOptions

The options to process the request using.

Returns

Promise<SecretSQL[]>

Inherited from

BaseSecretRoute.doFind


doFindById()

protected doFindById(id, options): Promise<SecretSQL | null>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:192

Attempts to retrieve a single data model object as identified by the id parameter in the URI.

Parameters

id

string

options

FindRequestOptions

The options to process the request using.

Returns

Promise<SecretSQL | null>

Inherited from

BaseSecretRoute.doFindById


doTruncate()

protected doTruncate(options): Promise<void>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:199

Attempts to remove all entries of the data model type from the datastore matching the given parameters and query.

Parameters

options

TruncateRequestOptions

The options to process the request using.

Returns

Promise<void>

Inherited from

BaseSecretRoute.doTruncate


doUpdate()

protected doUpdate(id, obj, options): Promise<SecretSQL>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:213

Attempts to modify an existing data model object as identified by the id parameter in the URI.

Parameters

id

string

obj

UpdateObject<SecretSQL>

The object to update in the database

options

UpdateRequestOptions<SecretSQL>

The options to process the request using.

Returns

Promise<SecretSQL>

Inherited from

BaseSecretRoute.doUpdate


doUpdateProperty()

protected doUpdateProperty(id, propertyName, value, options): Promise<SecretSQL>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:224

Attempts to modify a single property of an existing data model object as identified by the id parameter in the URI.

Note that this effectively bypasses optimistic locking and can cause unexpected data overwrites. Use with care.

Parameters

id

string

The unique identifier of the object to update.

propertyName

string

The name of the property to update.

value

any

The value of the property to set.

options

UpdateRequestOptions<SecretSQL>

The options to process the request using.

Returns

Promise<SecretSQL>

Inherited from

BaseSecretRoute.doUpdateProperty


exists()

exists(id, query, res, user?): Promise<any>

Defined in: src/routes/BaseSecretRoute.ts:367

Parameters

id

string

query

any

res

HttpResponse

user?

JWTUser

Returns

Promise<any>

Inherited from

BaseSecretRoute.exists


fido2RegistrationOptions()

fido2RegistrationOptions(req, user?): Promise<any>

Defined in: src/routes/BaseSecretRoute.ts:306

Parameters

req

HttpRequest

user?

JWTUser

Returns

Promise<any>

Inherited from

BaseSecretRoute.fido2RegistrationOptions


find()

find(params, query, user?): Promise<SecretSQL[]>

Defined in: src/routes/BaseSecretRoute.ts:380

Parameters

params

any

query

any

user?

JWTUser

Returns

Promise<SecretSQL[]>

Inherited from

BaseSecretRoute.find


findById()

findById(id, query, user?): Promise<SecretSQL | null>

Defined in: src/routes/BaseSecretRoute.ts:390

Parameters

id

string

query

any

user?

JWTUser

Returns

Promise<SecretSQL | null>

Inherited from

BaseSecretRoute.findById


passkeyRegistrationOptions()

passkeyRegistrationOptions(req, user?): Promise<any>

Defined in: src/routes/BaseSecretRoute.ts:290

Parameters

req

HttpRequest

user?

JWTUser

Returns

Promise<any>

Inherited from

BaseSecretRoute.passkeyRegistrationOptions


truncate()

truncate(params, query, user?): Promise<void>

Defined in: src/routes/BaseSecretRoute.ts:402

Parameters

params

any

query

any

user?

JWTUser

Returns

Promise<void>

Inherited from

BaseSecretRoute.truncate


validate()

validate(objs, options?): Promise<void>

Defined in: node_modules/@rapidrest/service-core/dist/types/routes/ModelRoute.d.ts:228

Calls repoUtils.validate() to validate the object(s) provided.

Parameters

objs

Partial<SecretSQL> | Partial<SecretSQL>[]

options?

CreateRequestOptions | UpdateRequestOptions<SecretSQL>

Returns

Promise<void>

Inherited from

BaseSecretRoute.validate


validateCreate()

protected validateCreate(obj, req, user?): Promise<void>

Defined in: src/routes/BaseSecretRoute.ts:100

Parameters

obj

Partial<SecretSQL> | Partial<SecretSQL>[]

req

HttpRequest

user?

JWTUser

Returns

Promise<void>

Inherited from

BaseSecretRoute.validateCreate


validateTOTPCreate()

protected validateTOTPCreate(obj): Promise<void>

Defined in: src/routes/BaseSecretRoute.ts:219

Validates (or generates) the secret for a new totp secret per RFC 6238/RFC 4226.

The client may either bring their own Base32-encoded secret (e.g. one generated on a different server for migration purposes) or, more commonly, omit data entirely and have one generated here. Either way, the secret's token parameters (digits/period/algorithm) are captured onto the stored TOTPSecret alongside it, rather than left to always defer to totpConfig, so verification keeps working for this secret even if the configured defaults change later.

Parameters

obj

Partial<T>

The secret being created. If data is a string, it's used as the caller-supplied secret; otherwise a new one is generated.

Returns

Promise<void>

Inherited from

BaseSecretRoute.validateTOTPCreate


validateWebAuthnCreate()

protected validateWebAuthnCreate(obj, req, config): Promise<void>

Defined in: src/routes/BaseSecretRoute.ts:156

Verifies a client-submitted WebAuthn RegistrationResponseJSON (as produced by navigator.credentials.create() using the options from generatePasskeyRegistrationOptions()) against the challenge stored in the session, and replaces obj.data with the resulting StoredPasskeyCredential.

Shared by both passkey and fido2 secrets — the two differ only in relying party configuration (see passkeyConfig/fido2Config) and which SecretType they're persisted under, not in the underlying WebAuthn ceremony.

Per the WebAuthn registration ceremony (https://www.w3.org/TR/webauthn-2/#sctn-registering-a-new-credential), the credential ID must be unique across all accounts known to this relying party. Rather than duplicate that check here, the credential ID is used directly as this secret's own uid so that ModelRoute's existing create-time identifier check rejects the request should the ID already be registered to any account. This also lets a login ceremony, which only has the credential ID to go on, look the secret up directly by its primary key (see BaseAuthPasskeyRoute/BaseAuthFIDO2Route's getCredentialById/updateCredentialCounter).

Parameters

obj

Partial<T>

The secret being created. Its data property must be a RegistrationResponseJSON.

req

HttpRequest

The source HTTP request, used to retrieve the challenge stored in the session by a prior call to generatePasskeyRegistrationOptions().

config

PasskeyConfig

The relying party configuration to verify the response against.

Returns

Promise<void>

Inherited from

BaseSecretRoute.validateWebAuthnCreate