Member Junction
    Preparing search index...

    Generic, abstract base class for any scenario where we want to use a Singleton pattern. This base class abstracts away the complexity of ensuring a truly global singleton instance across multiple code paths in a deployed application. It uses a Global Object Store to ensure that only one instance of the class exists in the application even if the class has code imported into multiple execution paths (which is not optimal, of course, but can occur in some situations).

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get GlobalKey(): string

      Returns string

    Methods

    • Layers 2, 3, & 4:

      • Verifies hashes and the envelope sender signature (required for an authenticated sender, with the envelope's senderKeyId equal to the authenticated key)
      • With DecryptOnIngest: AEAD-decrypts, runs VerifyBundleArchive() and the malware scanner, indexes manifest & findings. Without it: checks the header only and keeps the envelope encrypted
      • Promotes from Quarantine to Verified MJStorage (or deletes from Quarantine on failure)
      • Saves the received bundle row and invokes OnBundleReceivedHook

      Parameters

      Returns Promise<IntakeCompleteResponse>

    • Sets intake options. contextUser with provider (or the default provider) lets the intake read sender registrations and save received bundle rows. maxRecordsInMemory (default 200) caps the records kept in memory; maxOpenIntakesPerSender (default 5) caps the Receiving records of one install. The four limit options must be positive integers, otherwise it throws.

      Parameters

      • options: {
            contextUser?: UserInfo;
            decryptOnIngest?: boolean;
            enabled?: boolean;
            malwareScanner?: IDiagnosticMalwareScanner;
            maxFailedAttemptsPerMinute?: number;
            maxOpenIntakesPerSender?: number;
            maxRecordsInMemory?: number;
            maxRequestsPerMinute?: number;
            onBundleReceivedHook?: OnBundleReceivedHook;
            provider?: IMetadataProvider;
            retentionDays?: number;
            storageBridge?: IDiagnosticStorageBridge;
        }

      Returns void

    • The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.

      Returns GlobalObjectStore

    • Returns the active recipient key, signed by the signing key when one is registered.

      Returns Promise<
          {
              algorithm: "X25519";
              keyId: string;
              publicKey: string;
              signature?: string;
          },
      >

    • Registers a sender's Ed25519 public key in memory (no database row), for a self-hosted hub, the local loopback or tests. maxBundlesPerDay 0 means no daily limit.

      Parameters

      • installId: string
      • keyId: string
      • publicKeyBase64: string
      • maxBundlesPerDay: number = 0

      Returns void

    • Holds one daily-quota slot for the sender before the bundle count is read, so concurrent creates in this process cannot all pass the check. Open records without a bundle row and other held slots count as used. Returns null (and holds nothing) when the quota is used up. The caller releases the slot once the intake record exists or the request has failed. Creates on other collector processes are not counted.

      Parameters

      Returns Promise<DailyQuotaReservation>

    • True when the sender has not used up its MaxBundlesPerDay. Open records of the sender that have no bundle row yet count as used, except the record referenceId.

      Parameters

      Returns Promise<boolean>

    • Removes Receiving records whose upload window has passed, and rejects and removes Quarantined records past their complete deadline (quarantine object deleted, row marked Failed). A record whose complete is running is skipped. The records leave the map at once.

      Parameters

      • nowMs: number = ...

      Returns Promise<void>

    • Layer 1 & Quarantine Staging: Inspects the MJDB envelope header in <1ms before accepting the payload into Quarantine storage. sender must be the sender the record is bound to.

      Parameters

      • referenceId: string
      • payloadBytes: Uint8Array
      • Optionalsender: SenderIdentity

      Returns Promise<{ accepted: boolean; reason?: string; reasonCode?: string }>

    • Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.

      Type Parameters

      Parameters

      • this: new () => T
      • OptionalclassName: string

      Returns T