encryptForThisServer | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...

    Function encryptForThisServer

    • Encrypt data with this server's local key

      Type Parameters

      • S extends string

      Parameters

      • scope: S | (keyof ServerEncryptionScopes)

        Scope for encryption (must be unique for each Encrypt usage so you can't accidentally mix up calls)

      • data: S extends keyof ServerEncryptionScopes ? ServerEncryptionScopes[S<S>] : unknown

        Data to sign and encrypt. Will be encoded as typed JSON if necessary

      Returns string

      Encrypted data, base64url encoded (so safe for direct use in URLs)

      // Set up the data format you will use for TypeScript
      declare module "@webhare/services" {
      interface ServerEncryptionScopes {
      "mymodule:myscope": {
      field: string;
      };
      }
      }

      const enctoken = encryptForThisServer("mymodule:myscope", { field: "value" });