This repository has been archived on 2026-03-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw-extensions/wecom/node_modules/@aws-sdk/middleware-websocket/dist-es/WebsocketSignatureV4.js
T

31 lines
1010 B
JavaScript

import { HttpRequest } from "@smithy/protocol-http";
import { isWebSocketRequest } from "./utils";
export class WebsocketSignatureV4 {
signer;
constructor(options) {
this.signer = options.signer;
}
presign(originalRequest, options = {}) {
return this.signer.presign(originalRequest, options);
}
async sign(toSign, options) {
if (HttpRequest.isInstance(toSign) && isWebSocketRequest(toSign)) {
const signedRequest = await this.signer.presign({ ...toSign, body: "" }, {
...options,
expiresIn: 60,
unsignableHeaders: new Set(Object.keys(toSign.headers).filter((header) => header !== "host")),
});
return {
...signedRequest,
body: toSign.body,
};
}
else {
return this.signer.sign(toSign, options);
}
}
signMessage(message, args) {
return this.signer.signMessage(message, args);
}
}