How to use digest method in apimocker

Best JavaScript code snippet using apimocker

ObjectDigestInfo.ta.ts

Source:ObjectDigestInfo.ta.ts Github

copy

Full Screen

1/* eslint-disable */2import {3 ASN1Element as _Element,4 ASN1TagClass as _TagClass,5 BIT_STRING,6 OBJECT_IDENTIFIER,7 OPTIONAL,8} from "asn1-ts";9import * as $ from "asn1-ts/dist/node/functional";10import {11 ObjectDigestInfo_digestedObjectType,12 _decode_ObjectDigestInfo_digestedObjectType,13 _encode_ObjectDigestInfo_digestedObjectType,14 _enum_for_ObjectDigestInfo_digestedObjectType,15} from "../AttributeCertificateDefinitions/ObjectDigestInfo-digestedObjectType.ta";16import {17 AlgorithmIdentifier,18 _decode_AlgorithmIdentifier,19 _encode_AlgorithmIdentifier,20} from "../AuthenticationFramework/AlgorithmIdentifier.ta";21export {22 ObjectDigestInfo_digestedObjectType,23 ObjectDigestInfo_digestedObjectType_otherObjectTypes /* IMPORTED_LONG_ENUMERATION_ITEM */,24 ObjectDigestInfo_digestedObjectType_publicKey /* IMPORTED_LONG_ENUMERATION_ITEM */,25 ObjectDigestInfo_digestedObjectType_publicKeyCert /* IMPORTED_LONG_ENUMERATION_ITEM */,26 otherObjectTypes /* IMPORTED_SHORT_ENUMERATION_ITEM */,27 publicKey /* IMPORTED_SHORT_ENUMERATION_ITEM */,28 publicKeyCert /* IMPORTED_SHORT_ENUMERATION_ITEM */,29 _decode_ObjectDigestInfo_digestedObjectType,30 _encode_ObjectDigestInfo_digestedObjectType,31 _enum_for_ObjectDigestInfo_digestedObjectType,32} from "../AttributeCertificateDefinitions/ObjectDigestInfo-digestedObjectType.ta";33export {34 AlgorithmIdentifier,35 _decode_AlgorithmIdentifier,36 _encode_AlgorithmIdentifier,37} from "../AuthenticationFramework/AlgorithmIdentifier.ta";3839/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo */40/**41 * @summary ObjectDigestInfo42 * @description43 *44 * ### ASN.1 Definition:45 *46 * ```asn147 * ObjectDigestInfo ::= SEQUENCE {48 * digestedObjectType ENUMERATED {49 * publicKey (0),50 * publicKeyCert (1),51 * otherObjectTypes (2)},52 * otherObjectTypeID OBJECT IDENTIFIER OPTIONAL,53 * digestAlgorithm AlgorithmIdentifier{{SupportedAlgorithms}},54 * objectDigest BIT STRING,55 * ... }56 * ```57 *58 * @class59 */60export class ObjectDigestInfo {61 constructor(62 /**63 * @summary `digestedObjectType`.64 * @public65 * @readonly66 */67 readonly digestedObjectType: ObjectDigestInfo_digestedObjectType,68 /**69 * @summary `otherObjectTypeID`.70 * @public71 * @readonly72 */73 readonly otherObjectTypeID: OPTIONAL<OBJECT_IDENTIFIER>,74 /**75 * @summary `digestAlgorithm`.76 * @public77 * @readonly78 */79 readonly digestAlgorithm: AlgorithmIdentifier,80 /**81 * @summary `objectDigest`.82 * @public83 * @readonly84 */85 readonly objectDigest: BIT_STRING,86 /**87 * @summary Extensions that are not recognized.88 * @public89 * @readonly90 */91 readonly _unrecognizedExtensionsList: _Element[] = []92 ) {}9394 /**95 * @summary Restructures an object into a ObjectDigestInfo96 * @description97 *98 * This takes an `object` and converts it to a `ObjectDigestInfo`.99 *100 * @public101 * @static102 * @method103 * @param {Object} _o An object having all of the keys and values of a `ObjectDigestInfo`.104 * @returns {ObjectDigestInfo}105 */106 public static _from_object(107 _o: { [_K in keyof ObjectDigestInfo]: ObjectDigestInfo[_K] }108 ): ObjectDigestInfo {109 return new ObjectDigestInfo(110 _o.digestedObjectType,111 _o.otherObjectTypeID,112 _o.digestAlgorithm,113 _o.objectDigest,114 _o._unrecognizedExtensionsList115 );116 }117118 /**119 * @summary The enum used as the type of the component `digestedObjectType`120 * @public121 * @static122 */123124 public static _enum_for_digestedObjectType = _enum_for_ObjectDigestInfo_digestedObjectType;125}126/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo */127128/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ObjectDigestInfo */129/**130 * @summary The Leading Root Component Types of ObjectDigestInfo131 * @description132 *133 * This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.134 *135 * @constant136 */137export const _root_component_type_list_1_spec_for_ObjectDigestInfo: $.ComponentSpec[] = [138 new $.ComponentSpec(139 "digestedObjectType",140 false,141 $.hasTag(_TagClass.universal, 10),142 undefined,143 undefined144 ),145 new $.ComponentSpec(146 "otherObjectTypeID",147 true,148 $.hasTag(_TagClass.universal, 6),149 undefined,150 undefined151 ),152 new $.ComponentSpec(153 "digestAlgorithm",154 false,155 $.hasTag(_TagClass.universal, 16),156 undefined,157 undefined158 ),159 new $.ComponentSpec(160 "objectDigest",161 false,162 $.hasTag(_TagClass.universal, 3),163 undefined,164 undefined165 ),166];167/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ObjectDigestInfo */168169/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ObjectDigestInfo */170/**171 * @summary The Trailing Root Component Types of ObjectDigestInfo172 * @description173 *174 * This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.175 *176 * @constant177 */178export const _root_component_type_list_2_spec_for_ObjectDigestInfo: $.ComponentSpec[] = [];179/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ObjectDigestInfo */180181/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ObjectDigestInfo */182/**183 * @summary The Extension Addition Component Types of ObjectDigestInfo184 * @description185 *186 * This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.187 *188 * @constant189 */190export const _extension_additions_list_spec_for_ObjectDigestInfo: $.ComponentSpec[] = [];191/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ObjectDigestInfo */192193/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ObjectDigestInfo */194let _cached_decoder_for_ObjectDigestInfo: $.ASN1Decoder<ObjectDigestInfo> | null = null;195/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ObjectDigestInfo */196197/* START_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo */198/**199 * @summary Decodes an ASN.1 element into a(n) ObjectDigestInfo200 * @function201 * @param {_Element} el The element being decoded.202 * @returns {ObjectDigestInfo} The decoded data structure.203 */204export function _decode_ObjectDigestInfo(el: _Element) {205 if (!_cached_decoder_for_ObjectDigestInfo) {206 _cached_decoder_for_ObjectDigestInfo = function (207 el: _Element208 ): ObjectDigestInfo {209 /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */210 let digestedObjectType!: ObjectDigestInfo_digestedObjectType;211 let otherObjectTypeID: OPTIONAL<OBJECT_IDENTIFIER>;212 let digestAlgorithm!: AlgorithmIdentifier;213 let objectDigest!: BIT_STRING;214 let _unrecognizedExtensionsList: _Element[] = [];215 /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */216 /* START_OF_CALLBACKS_MAP */217 const callbacks: $.DecodingMap = {218 digestedObjectType: (_el: _Element): void => {219 digestedObjectType = _decode_ObjectDigestInfo_digestedObjectType(220 _el221 );222 },223 otherObjectTypeID: (_el: _Element): void => {224 otherObjectTypeID = $._decodeObjectIdentifier(_el);225 },226 digestAlgorithm: (_el: _Element): void => {227 digestAlgorithm = _decode_AlgorithmIdentifier(_el);228 },229 objectDigest: (_el: _Element): void => {230 objectDigest = $._decodeBitString(_el);231 },232 };233 /* END_OF_CALLBACKS_MAP */234 $._parse_sequence(235 el,236 callbacks,237 _root_component_type_list_1_spec_for_ObjectDigestInfo,238 _extension_additions_list_spec_for_ObjectDigestInfo,239 _root_component_type_list_2_spec_for_ObjectDigestInfo,240 (ext: _Element): void => {241 _unrecognizedExtensionsList.push(ext);242 }243 );244 return new ObjectDigestInfo(245 /* SEQUENCE_CONSTRUCTOR_CALL */ digestedObjectType,246 otherObjectTypeID,247 digestAlgorithm,248 objectDigest,249 _unrecognizedExtensionsList250 );251 };252 }253 return _cached_decoder_for_ObjectDigestInfo(el);254}255/* END_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo */256257/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ObjectDigestInfo */258let _cached_encoder_for_ObjectDigestInfo: $.ASN1Encoder<ObjectDigestInfo> | null = null;259/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ObjectDigestInfo */260261/* START_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo */262/**263 * @summary Encodes a(n) ObjectDigestInfo into an ASN.1 Element.264 * @function265 * @param {value} el The element being decoded.266 * @param elGetter A function that can be used to get new ASN.1 elements.267 * @returns {_Element} The ObjectDigestInfo, encoded as an ASN.1 Element.268 */269export function _encode_ObjectDigestInfo(270 value: ObjectDigestInfo,271 elGetter: $.ASN1Encoder<ObjectDigestInfo>272) {273 if (!_cached_encoder_for_ObjectDigestInfo) {274 _cached_encoder_for_ObjectDigestInfo = function (275 value: ObjectDigestInfo,276 elGetter: $.ASN1Encoder<ObjectDigestInfo>277 ): _Element {278 return $._encodeSequence(279 ([] as (_Element | undefined)[])280 .concat(281 [282 /* REQUIRED */ _encode_ObjectDigestInfo_digestedObjectType(283 value.digestedObjectType,284 $.BER285 ),286 /* IF_ABSENT */ value.otherObjectTypeID ===287 undefined288 ? undefined289 : $._encodeObjectIdentifier(290 value.otherObjectTypeID,291 $.BER292 ),293 /* REQUIRED */ _encode_AlgorithmIdentifier(294 value.digestAlgorithm,295 $.BER296 ),297 /* REQUIRED */ $._encodeBitString(298 value.objectDigest,299 $.BER300 ),301 ],302 value._unrecognizedExtensionsList303 ? value._unrecognizedExtensionsList304 : []305 )306 .filter((c: _Element | undefined): c is _Element => !!c),307 $.BER308 );309 };310 }311 return _cached_encoder_for_ObjectDigestInfo(value, elGetter);312}313314/* END_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo */315 ...

Full Screen

Full Screen

ObjectDigestInfo-digestedObjectType.ta.ts

Source:ObjectDigestInfo-digestedObjectType.ta.ts Github

copy

Full Screen

1/* eslint-disable */2import { ASN1Element as _Element } from "asn1-ts";3import * as $ from "asn1-ts/dist/node/functional";45/* START_OF_SYMBOL_DEFINITION _enum_for_ObjectDigestInfo_digestedObjectType */6/**7 * @summary ObjectDigestInfo_digestedObjectType8 * @description9 *10 * ### ASN.1 Definition:11 *12 * ```asn113 * ObjectDigestInfo-digestedObjectType ::= ENUMERATED { -- REMOVED_FROM_UNNESTING -- }14 * ```@enum {number}15 */16export enum _enum_for_ObjectDigestInfo_digestedObjectType {17 publicKey = 0,18 publicKeyCert = 1,19 otherObjectTypes = 2,20}21/* END_OF_SYMBOL_DEFINITION _enum_for_ObjectDigestInfo_digestedObjectType */2223/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType */24/**25 * @summary ObjectDigestInfo_digestedObjectType26 * @description27 *28 * ### ASN.1 Definition:29 *30 * ```asn131 * ObjectDigestInfo-digestedObjectType ::= ENUMERATED { -- REMOVED_FROM_UNNESTING -- }32 * ```@enum {number}33 */34export type ObjectDigestInfo_digestedObjectType = _enum_for_ObjectDigestInfo_digestedObjectType;35/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType */3637/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType */38/**39 * @summary ObjectDigestInfo_digestedObjectType40 * @description41 *42 * ### ASN.1 Definition:43 *44 * ```asn145 * ObjectDigestInfo-digestedObjectType ::= ENUMERATED { -- REMOVED_FROM_UNNESTING -- }46 * ```@enum {number}47 */48export const ObjectDigestInfo_digestedObjectType = _enum_for_ObjectDigestInfo_digestedObjectType;49/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType */5051/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_publicKey */52/**53 * @summary ObjectDigestInfo_digestedObjectType_publicKey54 * @constant55 * @type {number}56 */57export const ObjectDigestInfo_digestedObjectType_publicKey: ObjectDigestInfo_digestedObjectType =58 ObjectDigestInfo_digestedObjectType.publicKey; /* LONG_NAMED_ENUMERATED_VALUE */59/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_publicKey */6061/* START_OF_SYMBOL_DEFINITION publicKey */62/**63 * @summary publicKey64 * @constant65 * @type {number}66 */67export const publicKey: ObjectDigestInfo_digestedObjectType =68 ObjectDigestInfo_digestedObjectType.publicKey; /* SHORT_NAMED_ENUMERATED_VALUE */69/* END_OF_SYMBOL_DEFINITION publicKey */7071/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_publicKeyCert */72/**73 * @summary ObjectDigestInfo_digestedObjectType_publicKeyCert74 * @constant75 * @type {number}76 */77export const ObjectDigestInfo_digestedObjectType_publicKeyCert: ObjectDigestInfo_digestedObjectType =78 ObjectDigestInfo_digestedObjectType.publicKeyCert; /* LONG_NAMED_ENUMERATED_VALUE */79/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_publicKeyCert */8081/* START_OF_SYMBOL_DEFINITION publicKeyCert */82/**83 * @summary publicKeyCert84 * @constant85 * @type {number}86 */87export const publicKeyCert: ObjectDigestInfo_digestedObjectType =88 ObjectDigestInfo_digestedObjectType.publicKeyCert; /* SHORT_NAMED_ENUMERATED_VALUE */89/* END_OF_SYMBOL_DEFINITION publicKeyCert */9091/* START_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_otherObjectTypes */92/**93 * @summary ObjectDigestInfo_digestedObjectType_otherObjectTypes94 * @constant95 * @type {number}96 */97export const ObjectDigestInfo_digestedObjectType_otherObjectTypes: ObjectDigestInfo_digestedObjectType =98 ObjectDigestInfo_digestedObjectType.otherObjectTypes; /* LONG_NAMED_ENUMERATED_VALUE */99/* END_OF_SYMBOL_DEFINITION ObjectDigestInfo_digestedObjectType_otherObjectTypes */100101/* START_OF_SYMBOL_DEFINITION otherObjectTypes */102/**103 * @summary otherObjectTypes104 * @constant105 * @type {number}106 */107export const otherObjectTypes: ObjectDigestInfo_digestedObjectType =108 ObjectDigestInfo_digestedObjectType.otherObjectTypes; /* SHORT_NAMED_ENUMERATED_VALUE */109/* END_OF_SYMBOL_DEFINITION otherObjectTypes */110111/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ObjectDigestInfo_digestedObjectType */112let _cached_decoder_for_ObjectDigestInfo_digestedObjectType: $.ASN1Decoder<ObjectDigestInfo_digestedObjectType> | null = null;113/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ObjectDigestInfo_digestedObjectType */114115/* START_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo_digestedObjectType */116/**117 * @summary Decodes an ASN.1 element into a(n) ObjectDigestInfo_digestedObjectType118 * @function119 * @param {_Element} el The element being decoded.120 * @returns {ObjectDigestInfo_digestedObjectType} The decoded data structure.121 */122export function _decode_ObjectDigestInfo_digestedObjectType(el: _Element) {123 if (!_cached_decoder_for_ObjectDigestInfo_digestedObjectType) {124 _cached_decoder_for_ObjectDigestInfo_digestedObjectType =125 $._decodeEnumerated;126 }127 return _cached_decoder_for_ObjectDigestInfo_digestedObjectType(el);128}129/* END_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo_digestedObjectType */130131/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ObjectDigestInfo_digestedObjectType */132let _cached_encoder_for_ObjectDigestInfo_digestedObjectType: $.ASN1Encoder<ObjectDigestInfo_digestedObjectType> | null = null;133/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ObjectDigestInfo_digestedObjectType */134135/* START_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo_digestedObjectType */136/**137 * @summary Encodes a(n) ObjectDigestInfo_digestedObjectType into an ASN.1 Element.138 * @function139 * @param {value} el The element being decoded.140 * @param elGetter A function that can be used to get new ASN.1 elements.141 * @returns {_Element} The ObjectDigestInfo_digestedObjectType, encoded as an ASN.1 Element.142 */143export function _encode_ObjectDigestInfo_digestedObjectType(144 value: ObjectDigestInfo_digestedObjectType,145 elGetter: $.ASN1Encoder<ObjectDigestInfo_digestedObjectType>146) {147 if (!_cached_encoder_for_ObjectDigestInfo_digestedObjectType) {148 _cached_encoder_for_ObjectDigestInfo_digestedObjectType =149 $._encodeEnumerated;150 }151 return _cached_encoder_for_ObjectDigestInfo_digestedObjectType(152 value,153 elGetter154 );155}156157/* END_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo_digestedObjectType */158 ...

Full Screen

Full Screen

DigestInfo.ts

Source:DigestInfo.ts Github

copy

Full Screen

1import * as asn1js from "asn1js";2import * as pvutils from "pvutils";3import { AlgorithmIdentifier, AlgorithmIdentifierJson, AlgorithmIdentifierSchema } from "./AlgorithmIdentifier";4import { EMPTY_STRING } from "./constants";5import { AsnError } from "./errors";6import { PkiObject, PkiObjectParameters } from "./PkiObject";7import * as Schema from "./Schema";8const DIGEST_ALGORITHM = "digestAlgorithm";9const DIGEST = "digest";10const CLEAR_PROPS = [11 DIGEST_ALGORITHM,12 DIGEST13];14export interface IDigestInfo {15 digestAlgorithm: AlgorithmIdentifier;16 digest: asn1js.OctetString;17}18export interface DigestInfoJson {19 digestAlgorithm: AlgorithmIdentifierJson;20 digest: asn1js.OctetStringJson;21}22export type DigestInfoParameters = PkiObjectParameters & Partial<IDigestInfo>;23export type DigestInfoSchema = Schema.SchemaParameters<{24 digestAlgorithm?: AlgorithmIdentifierSchema;25 digest?: string;26}>;27/**28 * Represents the DigestInfo structure described in [RFC3447](https://datatracker.ietf.org/doc/html/rfc3447)29 */30export class DigestInfo extends PkiObject implements IDigestInfo {31 public static override CLASS_NAME = "DigestInfo";32 public digestAlgorithm!: AlgorithmIdentifier;33 public digest!: asn1js.OctetString;34 /**35 * Initializes a new instance of the {@link DigestInfo} class36 * @param parameters Initialization parameters37 */38 constructor(parameters: DigestInfoParameters = {}) {39 super();40 this.digestAlgorithm = pvutils.getParametersValue(parameters, DIGEST_ALGORITHM, DigestInfo.defaultValues(DIGEST_ALGORITHM));41 this.digest = pvutils.getParametersValue(parameters, DIGEST, DigestInfo.defaultValues(DIGEST));42 if (parameters.schema) {43 this.fromSchema(parameters.schema);44 }45 }46 /**47 * Returns default values for all class members48 * @param memberName String name for a class member49 * @returns Default value50 */51 public static override defaultValues(memberName: typeof DIGEST_ALGORITHM): AlgorithmIdentifier;52 public static override defaultValues(memberName: typeof DIGEST): asn1js.OctetString;53 public static override defaultValues(memberName: string): any {54 switch (memberName) {55 case DIGEST_ALGORITHM:56 return new AlgorithmIdentifier();57 case DIGEST:58 return new asn1js.OctetString();59 default:60 return super.defaultValues(memberName);61 }62 }63 /**64 * Compare values with default values for all class members65 * @param memberName String name for a class member66 * @param memberValue Value to compare with default value67 */68 public static compareWithDefault(memberName: string, memberValue: any): boolean {69 switch (memberName) {70 case DIGEST_ALGORITHM:71 return ((AlgorithmIdentifier.compareWithDefault("algorithmId", memberValue.algorithmId)) &&72 (("algorithmParams" in memberValue) === false));73 case DIGEST:74 return (memberValue.isEqual(DigestInfo.defaultValues(memberName)));75 default:76 return super.defaultValues(memberName);77 }78 }79 /**80 * @inheritdoc81 * @asn ASN.1 schema82 * ```asn83 * DigestInfo ::= SEQUENCE {84 * digestAlgorithm DigestAlgorithmIdentifier,85 * digest Digest }86 *87 * Digest ::= OCTET STRING88 *```89 */90 public static override schema(parameters: DigestInfoSchema = {}): Schema.SchemaType {91 const names = pvutils.getParametersValue<NonNullable<typeof parameters.names>>(parameters, "names", {});92 return (new asn1js.Sequence({93 name: (names.blockName || EMPTY_STRING),94 value: [95 AlgorithmIdentifier.schema(names.digestAlgorithm || {96 names: {97 blockName: DIGEST_ALGORITHM98 }99 }),100 new asn1js.OctetString({ name: (names.digest || DIGEST) })101 ]102 }));103 }104 public fromSchema(schema: Schema.SchemaType): void {105 // Clear input data first106 pvutils.clearProps(schema, CLEAR_PROPS);107 // Check the schema is valid108 const asn1 = asn1js.compareSchema(schema,109 schema,110 DigestInfo.schema({111 names: {112 digestAlgorithm: {113 names: {114 blockName: DIGEST_ALGORITHM115 }116 },117 digest: DIGEST118 }119 })120 );121 AsnError.assertSchema(asn1, this.className);122 // Get internal properties from parsed schema123 this.digestAlgorithm = new AlgorithmIdentifier({ schema: asn1.result.digestAlgorithm });124 this.digest = asn1.result.digest;125 }126 public toSchema(): asn1js.Sequence {127 // Construct and return new ASN.1 schema for this object128 return (new asn1js.Sequence({129 value: [130 this.digestAlgorithm.toSchema(),131 this.digest132 ]133 }));134 }135 public toJSON(): DigestInfoJson {136 return {137 digestAlgorithm: this.digestAlgorithm.toJSON(),138 digest: this.digest.toJSON(),139 };140 }...

Full Screen

Full Screen

pbkdf2.js

Source:pbkdf2.js Github

copy

Full Screen

1'use strict';2const { AsyncWrap, Providers } = internalBinding('async_wrap');3const { Buffer } = require('buffer');4const { pbkdf2: _pbkdf2 } = internalBinding('crypto');5const { validateUint32 } = require('internal/validators');6const { deprecate } = require('internal/util');7const {8 ERR_CRYPTO_INVALID_DIGEST,9 ERR_CRYPTO_PBKDF2_ERROR,10 ERR_INVALID_ARG_TYPE,11 ERR_INVALID_CALLBACK,12} = require('internal/errors').codes;13const {14 getDefaultEncoding,15 getArrayBufferView,16} = require('internal/crypto/util');17function pbkdf2(password, salt, iterations, keylen, digest, callback) {18 if (typeof digest === 'function') {19 callback = digest;20 digest = undefined;21 }22 ({ password, salt, iterations, keylen, digest } =23 check(password, salt, iterations, keylen, digest));24 if (typeof callback !== 'function')25 throw new ERR_INVALID_CALLBACK(callback);26 const encoding = getDefaultEncoding();27 const keybuf = Buffer.alloc(keylen);28 const wrap = new AsyncWrap(Providers.PBKDF2REQUEST);29 wrap.ondone = (ok) => { // Retains keybuf while request is in flight.30 if (!ok) return callback.call(wrap, new ERR_CRYPTO_PBKDF2_ERROR());31 if (encoding === 'buffer') return callback.call(wrap, null, keybuf);32 callback.call(wrap, null, keybuf.toString(encoding));33 };34 handleError(_pbkdf2(keybuf, password, salt, iterations, digest, wrap),35 digest);36}37function pbkdf2Sync(password, salt, iterations, keylen, digest) {38 ({ password, salt, iterations, keylen, digest } =39 check(password, salt, iterations, keylen, digest));40 const keybuf = Buffer.alloc(keylen);41 handleError(_pbkdf2(keybuf, password, salt, iterations, digest), digest);42 const encoding = getDefaultEncoding();43 if (encoding === 'buffer') return keybuf;44 return keybuf.toString(encoding);45}46const defaultDigest = deprecate(() => 'sha1',47 'Calling pbkdf2 or pbkdf2Sync with "digest" ' +48 'set to null is deprecated.',49 'DEP0009');50function check(password, salt, iterations, keylen, digest) {51 if (typeof digest !== 'string') {52 if (digest !== null)53 throw new ERR_INVALID_ARG_TYPE('digest', ['string', 'null'], digest);54 digest = defaultDigest();55 }56 password = getArrayBufferView(password, 'password');57 salt = getArrayBufferView(salt, 'salt');58 validateUint32(iterations, 'iterations');59 validateUint32(keylen, 'keylen');60 return { password, salt, iterations, keylen, digest };61}62function handleError(rc, digest) {63 if (rc === -1)64 throw new ERR_CRYPTO_INVALID_DIGEST(digest);65 if (rc === false)66 throw new ERR_CRYPTO_PBKDF2_ERROR();67}68module.exports = {69 pbkdf2,70 pbkdf2Sync...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var digest = require('apimocker/lib/digest');2var app = require('express')();3var http = require('http').Server(app);4var io = require('socket.io')(http);5var apimocker = require('apimocker');6var config = {7 "server": {8 },9 {10 },11 {12 },13 {14 },15 {16 },17 {18 }19 {20 "request": {21 "headers": {22 }23 },24 "response": {25 "headers": {26 }27 }28 },29 {30 "request": {31 "headers": {32 }33 },34 "response": {35 "headers": {36 }37 }38 },39 {40 "request": {41 "headers": {42 }43 },44 "response": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var apimocker = require('apimocker');2var express = require('express');3var app = express();4app.use(apimocker.middleware);5app.listen(8080);6console.log('listening on port 8080');7{8 {9 },10 {11 }12}13{14}15{16}17{18}19{20}21### apimocker.middleware(options)

Full Screen

Using AI Code Generation

copy

Full Screen

1var digest = require('apimocker').digest;2var request = require('request');3var path = require('path');4var fs = require('fs');5var express = require('express');6var app = express();7var port = 3000;8var host = 'localhost';9var api = require('./api.json');10var mockPath = path.join(__dirname, 'mocks');11var options = {12};13var mocker = require('apimocker').mocker(options);14mocker.listen(function() {15 console.log('API mock server listening at ' + url);16 console.log('Press Ctrl+C to stop.');17});18var digest = require('apimocker').digest;19var request = require('request');20var path = require('path');21var fs = require('fs');22var express = require('express');23var app = express();24var port = 3000;25var host = 'localhost';26var api = require('./api.json');27var mockPath = path.join(__dirname, 'mocks');28var options = {29};30var mocker = require('apimocker').mocker(options);31mocker.listen(function() {32 console.log('API mock server listening at ' + url);33 console.log('Press Ctrl+C to stop.');34});

Full Screen

Using AI Code Generation

copy

Full Screen

1const digest = require('apimocker/digest');2const path = require('path');3const options = {4 src: path.join(__dirname, '/src'),5 dest: path.join(__dirname, '/dest'),6};7digest(options);

Full Screen

Using AI Code Generation

copy

Full Screen

1var mock = require('apimocker/mock');2var mockServer = mock.server;3var mockApp = mock.app;4var mockConfig = mock.config;5var mockMiddleware = mock.middleware;6var config = mockConfig.load({7 configDir: path.join(__dirname, 'mocks'),8});9var app = mockApp(config);10app.use(mockMiddleware);11mockServer(app, 3000);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run apimocker automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful