How to use the node-opcua-types.ChannelSecurityToken.schema function in node-opcua-types

To help you get started, we’ve selected a few node-opcua-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-service-secure-channel / source / index.ts View on Github external
ResponseHeader,
    RequestHeader,
    SignatureData,
    MessageSecurityMode,
    _enumerationMessageSecurityMode,
    UserTokenPolicy
} from "node-opcua-types";

export { AsymmetricAlgorithmSecurityHeader } from "./AsymmetricAlgorithmSecurityHeader";
export { SymmetricAlgorithmSecurityHeader } from "./SymmetricAlgorithmSecurityHeader";
export * from "./message_security_mode";

// createdAt
ChannelSecurityToken.schema.fields[2].defaultValue =  () => new Date();
// revisedLifetime
ChannelSecurityToken.schema.fields[3].defaultValue =  () => 30000;

export function hasTokenExpired(token: ChannelSecurityToken): boolean {

    return (token.createdAt !== null)
        && (token.createdAt.getTime() + token.revisedLifetime) < Date.now();
}

Object.defineProperty(ChannelSecurityToken.prototype, "expired", {
    get() { return hasTokenExpired(this as ChannelSecurityToken); },
    configurable: true,
    enumerable: true,
});

// ErrorMessage
// "Error",  "UInt32","The numeric code for the error. This shall be one of the values listed in Table 40."
// "Reason","String", "A more verbose description of the error.This string shall not be more than 4096 characters."
github node-opcua / node-opcua / packages / node-opcua-service-secure-channel / source / index.ts View on Github external
SecurityTokenRequestType,
    ResponseHeader,
    RequestHeader,
    SignatureData,
    MessageSecurityMode,
    _enumerationMessageSecurityMode,
    UserTokenPolicy
} from "node-opcua-types";

export { AsymmetricAlgorithmSecurityHeader } from "./AsymmetricAlgorithmSecurityHeader";
export { SymmetricAlgorithmSecurityHeader } from "./SymmetricAlgorithmSecurityHeader";
export * from "./message_security_mode";

// createdAt
ChannelSecurityToken.schema.fields[2].defaultValue =  () => new Date();
// revisedLifetime
ChannelSecurityToken.schema.fields[3].defaultValue =  () => 30000;

export function hasTokenExpired(token: ChannelSecurityToken): boolean {

    return (token.createdAt !== null)
        && (token.createdAt.getTime() + token.revisedLifetime) < Date.now();
}

Object.defineProperty(ChannelSecurityToken.prototype, "expired", {
    get() { return hasTokenExpired(this as ChannelSecurityToken); },
    configurable: true,
    enumerable: true,
});

// ErrorMessage