How to use _logger method in root

Best JavaScript code snippet using root

app-build.js

Source:app-build.js Github

copy

Full Screen

1importPackage(com.sencha.tools.compressors.yui);2importPackage(com.sencha.tools.compressors.closure);3importPackage(com.sencha.tools.external);4importPackage(com.sencha.tools.compiler.jsb.statements);5var _logger = SenchaLogManager.getLogger("app-build");6function runAppBuild(proj) {7 var basedir = proj.getProperty("framework.config.dir"),8 appPath = proj.getProperty("args.path"),9 envArg = proj.getProperty("args.environment"),10 ignores = proj.getProperty("framework.ignores"),11 options = proj.getProperty("build.options"),12 cssCompression = proj.getProperty("build.compress.css"),13 config = readConfig(resolvePath(appPath, "app.json")),14 environment = (envArg == "native") ? 'package' : envArg,15 destination = 16 (proj.getProperty("args.destination") + '') ||17 (proj.getProperty("build.dir") + '') ||18 (proj.getProperty("app.build.dir") + ''),19 operations = toJS(proj.getProperty("build.operations")),20 v2deps = !!(proj.getProperty("v2deps") == "true"),21 src = appPath,22 sdk = proj.getProperty("framework.dir"),23 archive = 24 (proj.getProperty("args.archive") + '') || 25 (config.archivePath) || 26 "archive",27 nativePackaging = !!(envArg == 'native'),28 indexHtmlPath = config.indexHtmlPath || 'index.html',29 appUrl = config.url || resolvePath(src, indexHtmlPath),30 jsAssets = config.js || [],31 cssAssets = config.css || [],32 appCache = config.appCache,33 ignore = config.ignore,34 remoteAssets = [],35 extras = config.extras || config.resources,36 appJs, sdkJs, sdkIsAll, assets, processIndex;37 destination = joinPath(destination, environment);38 39 if(!PathUtil.isAbsolute(archive)) {40 archive = resolvePath(appPath, archive);41 }42 43 if (operations) {44 operations = operations.split('\n');45 } else {46 operations = [];47 }48 49 if (appUrl.indexOf("file:") != 0 && appUrl.indexOf("http:") != 0) {50 appUrl = 'file:///' + StringUtil.replace(resolvePath(appUrl), '\\', '/');51 }52 // check for build dir being immediate child of application dir53 // native packager can get in to infinite looping when scanning files54 // under this scenario55 var canonicalAppPath = new File(appPath).getCanonicalPath(),56 canonicalDestPath = new File(destination).getCanonicalPath(),57 parent = new File(canonicalDestPath).getParentFile();58 if(parent && parent.getCanonicalPath() == canonicalAppPath) {59 _logger.error("Application : {}", canonicalAppPath);60 _logger.error("Destination : {}", canonicalDestPath);61 _logger.error("Destination path cannot reside one level under the Application directory")62 throw "Destination path cannot reside one level under the Application directory";63 }64 _logger.info("Deploying your application to " + destination);65 PathUtil.ensurePathExists(resolvePath(destination));66 jsAssets = each(67 map(jsAssets, function (asset) {68 if (typeof asset == 'string') {69 asset = { path:asset };70 }71 asset.type = 'js';72 return asset;73 }),74 function (jsAsset) {75 if (jsAsset.bundle) {76 appJs = jsAsset.path;77 }78 });79 if (!appJs) {80 appJs = 'app.js';81 }82 appJs = resolvePath(destination, appJs);83 cssAssets = map(cssAssets, function (asset) {84 if (typeof asset == 'string') {85 asset = { path:asset };86 }87 asset.type = 'css';88 return asset;89 });90 assets = filter(concat(jsAssets, cssAssets), function (asset) {91 return !asset.shared || (environment != 'production');92 });93 _logger.debug("copying all assets");94 each(assets, function (asset) {95 if (asset.remote) {96 asset.bundle = false;97 asset.update = false;98 remoteAssets.push(asset);99 } else {100 file = asset.path;101 // if not in testing mode, and using the new compiler, and this is102 // one of the sencha-touch files, don't copy to output directory103 if( asset.type === 'js' &&104 !v2deps &&105 file.indexOf("sencha-touch") != -1) {106 asset['x-bootstrap'] = true;107 108 // only skip the sdk code in the bundle if the bundle flag109 // on the sdk asset is explicitly set to false110 if(('bundle' in asset) && asset.bundle === false) {111 sdkJs = asset.path;112 sdkIsAll = sdkJs.indexOf("-all.js") >= 0;113 asset.isSdk = true;114 }115 }116 if (asset['x-bootstrap'] && !asset.isSdk) {117 return;118 }119 _logger.debug("copying file {}", resolvePath(src, file));120 var srcPath = resolvePath(src, file),121 dstPath = resolvePath(destination, stripSpecialDirNames(file));122 if(srcPath != dstPath) {123 PathUtil.ensurePathExists(dstPath);124 copy(srcPath, dstPath);125 _logger.info("Copied {} to {}", srcPath, dstPath);126 }127 }128 });129 var ignoreFilter = Filter.getFileNameFilter(130 new RegexFilter(ignore).setInclusive(false));131 _logger.debug("copying all extras");132 each(extras, function (extra) {133 var from = resolvePath(src, extra),134 to = resolvePath(destination, extra);135 _logger.debug("Copying from {} to {}", from, to);136 if (new File(from).exists()) {137 PathUtil.ensurePathExists(to);138 copy(from, to, ignoreFilter);139 _logger.info("Copied {}", from);140 } else {141 _logger.warn("File or folder {} not found", from);142 }143 });144 // build the app145 processIndex = function () {146 _logger.debug("processing page : index.html");147 jsAssets = filter(jsAssets, function(asset){148 return !(asset['x-bootstrap'] && !asset.isSdk);149 });150 var appJson = jsonEncode({151 id:config.id,152 js:jsAssets,153 css:cssAssets154 }),155 indexHtml, content, compressor, remotes, microloader;156 writeFileContent(new File(destination, 'app.json'), appJson);157 _logger.info("Generated app.json");158 indexHtml = readFileContent(new File(src, indexHtmlPath));159 if (environment == 'production' && appCache) {160 indexHtml = StringUtil.replace(161 indexHtml,162 '<html manifest=""',163 '<html manifest="cache.appcache"');164 }165 compressor = new ClosureCompressor();166 microloader = (environment == 'production'167 ? 'production'168 : 'testing') +169 '.js';170 _logger.debug("using microloader : {}", microloader);171 content = readFileContent(joinPath(sdk, "microloader", microloader));172 content = compressor.compress(content);173 remotes = [174 '<script type="text/javascript">' +175 content + ';Ext.blink(' +176 (environment == 'production' ? jsonEncode({177 id:config.id178 }) : appJson) + ')' +179 '</script>'180 ];181 each(remoteAssets, function (asset) {182 var uri = asset.path;183 if (asset.type === 'js') {184 remotes.push(185 '<script type="text/javascript" src="' +186 uri +187 '"></script>');188 } else if (asset.type === 'css') {189 remotes.push(190 '<link rel="stylesheet" type="text/css" href="' +191 uri +192 '" />');193 }194 });195 indexHtml = ('' + indexHtml).replace(196 /<script id="microloader"([^<]+)<\/script>/,197 remotes.join(''));198 _logger.debug("generating new built index.html");199 writeFileContent(resolvePath(destination, indexHtmlPath), indexHtml);200 _logger.info("Embedded microloader into " + indexHtmlPath);201 };202 _logger.info("Resolving your application dependencies (" + appUrl + ")");203 var preprocessor = new Parser(),204 jsCompressor = new YuiJavascriptCompressor(),205 cssCompressor = new YuiCssCompressor(),206 phantomRunner = new PhantomJsRunner(),207 processedAssetCount = 0,208 assetsCount, dependencies, files, file,209 destinationFile, compressor,210 cleanFile, cleanDestinationFile;211 if(v2deps) {212 // if v2deps, use the sencha command 2 sytle dependency resolution mechanism213 // by running the phantomjs dependencies.js script214 var phantomOut = phantomRunner.run([215 resolvePath(basedir, "dependencies.js"),216 appUrl217 ]),218 exitCode = phantomOut.getExitCode(),219 stdout = phantomOut.getOutput(),220 buffer = new StringBuilder();221 if (exitCode > 0) {222 _logger.error("dependencies.js exited with non-zero code : " + exitCode);223 _logger.error(stdout);224 throw new ExBuild("failed gathering dependencies").raise();225 }226 dependencies = jsonDecode(stdout);227 _logger.info("Found " + dependencies.length + " dependencies. Concatenating all into '" + appJs + "'");228 files = map(dependencies, function (dependency) {229 return resolvePath(src, dependency.path);230 });231 files.push(appJs);232 each(files, function (file) {233 buffer.append(FileUtil.readUnicodeFile(resolvePath(file))).append('\n');234 });235 writeFileContent(appJs, buffer.toString());236 // clear the buffer to free memory237 buffer.setLength(0);238 } else {239 var sdkTag = sdkIsAll ? 'framework' : 'core',240 sdkFile = sdkJs,241 sdkJsArgs = [242 '--options=' + options,243 'union',244 '-tag',245 sdkTag,246 'and',247 'concat',248 '-out=' + resolvePath(destination, sdkFile)249 ],250 appJsArgs = [251 '-options=' + options,252 'restore',253 'app-all',254 'and',255 'exclude',256 '-tag',257 sdkTag,258 'and',259 'concatenate',260 '-out=' + appJs,261 ''],262 compilerId = proj.getProperty("compiler.ref.id"),263 compiler = proj.getReference(compilerId);264 if(sdkJs) {265 _logger.info("Compiling " + sdkFile + " and dependencies");266 _logger.debug("running compiler with options : '{}'", sdkJsArgs.join(' '));267 compiler.dispatchArgs(sdkJsArgs);268 _logger.info("Compiling app.js and dependencies");269 _logger.debug("running compiler with options : '{}'", appJsArgs.join(' '));270 compiler.dispatchArgs(appJsArgs);271 _logger.info("Completed compilation.");272 } else {273 appJsArgs = [274 '-options=' + options,275 'restore',276 'app-all',277 'and',278 'concatenate',279 '-out=' + appJs,280 ''];281 _logger.debug("running compiler with options : '{}'", appJsArgs.join(' '));282 compiler.dispatchArgs(appJsArgs);283 _logger.info("Completed compilation."); 284 }285 }286 for (var name in config.buildOptions) {287 if (config.buildOptions.hasOwnProperty(name)) {288 preprocessor.setParam(name, config.buildOptions[name]);289 }290 }291 assetsCount = assets.length;292 each(assets, function (asset) {293 if(!asset.remote) {294 file = asset.path;295 destinationFile = resolvePath(destination, file),296 cleanFile = stripSpecialDirNames(file),297 cleanDestinationFile = resolvePath(destination, cleanFile);298 // adjust the asset path to use the cleaned filename299 asset.path = cleanFile;300 }301 _logger.debug("Assets => Processed : {} Total : {}",302 processedAssetCount, assetsCount);303 if (asset.type == 'js') {304 if (!asset.remote && !(asset['x-bootstrap'] && !asset.isSdk)) {305 _logger.debug("running preprocessor for file {}", cleanDestinationFile);306 writeFileContent(307 cleanDestinationFile,308 preprocessor.parse(readFileContent(cleanDestinationFile)));309 _logger.info('Processed local file ' + asset.path);310 } else {311 _logger.info('Processed remote file ' + asset.path);312 }313 }314 if (environment == 'testing') {315 return;316 }317 if (asset.remote || (asset['x-bootstrap'] && !asset.isSdk)) {318 ++processedAssetCount;319 } else {320 _logger.debug("Minifying " + file);321 if(asset.type == 'js') {322 writeFileContent(323 cleanDestinationFile,324 jsCompressor.compress(readFileContent(cleanDestinationFile)));325 _logger.info("Minified " + file);326 } else if (cssCompression == "true") {327 writeFileContent(328 cleanDestinationFile,329 cssCompressor.compress(readFileContent(cleanDestinationFile)));330 _logger.info("Minified " + file);331 }332 if (environment == 'production') {333 var content = readFileContent(cleanDestinationFile),334 version = '' + FileUtil.createChecksum(content);335 asset.version = version;336 _logger.debug("prepending checksum on {}", cleanDestinationFile);337 writeFileContent(338 cleanDestinationFile,339 "/*" + version + "*/" + content);340 content = "";341 _logger.debug("copying destination to archive");342 PathUtil.ensurePathExists(resolvePath(archive, cleanFile, version));343 copy(cleanDestinationFile, resolvePath(archive, cleanFile, version));344 if (asset.update == 'delta') {345 // generate all the deltas to the other archived versions346 _logger.debug("generating file deltas");347 var archivedVersions = new File(joinPath(archive, cleanFile))348 .listFiles();349 each(archivedVersions, function (archivedVersion) {350 if(archivedVersion.isDirectory()) {351 return;352 }353 354 archivedVersion = archivedVersion.name;355 if (archivedVersion == version) {356 return;357 }358 var deltaFile = joinPath(359 destination,360 'deltas',361 cleanFile,362 archivedVersion + '.json');363 writeFileContent(deltaFile, '');364 _logger.debug("Generating delta from {} to {}",365 archivedVersion,366 version);367 var runner = new VcDiffRunner(),368 args = [369 'encode',370 '-json',371 '-dictionary',372 joinPath(archive, cleanFile, archivedVersion),373 '-target',374 cleanDestinationFile,375 '-delta',376 resolvePath(deltaFile),377 '--stats'378 ],379 runnerOut = runner.run(args),380 exitCode = runnerOut.getExitCode(),381 stdout = runnerOut.getOutput();382 383 if (exitCode > 0) {384 _logger.error("failed generating diff from {} to {}",385 archivedVersion,386 version);387 _logger.error(stdout);388 throw new ExBuild("failed generating diff from {0} to {1}",389 archivedVersion,390 version).raise();391 }392 393 // fixup malformed vcdiff content394 var deltaFilePath = resolvePath(deltaFile),395 content = FileUtil.readFile(deltaFilePath);396 if(content.endsWith(",]")) {397 _logger.debug("Correcting trailing comma issue in vcdiff output");398 FileUtil.writeFile(deltaFilePath, content.substring(0, content.length() - 2) + "]");399 }400 401 content = null;402 403 _logger.info(404 "Generated delta for: {} from hash: '{}' to hash: '{}'",405 [cleanFile, archivedVersion, version]);406 });407 }408 }409 if (++processedAssetCount == assetsCount) {410 _logger.debug("processed all assets, finalizing build...");411 processIndex();412 if (environment == 'production' && appCache) {413 _logger.info("Generating appcache");414 appCache.cache = map(appCache.cache, function (cache) {415 var checksum = '';416 if (!/^(\/|(.*):\/\/)/.test(cache)) {417 _logger.info(418 "Generating checksum for appCache item: {}",419 cache);420 checksum = FileUtil.createChecksum(421 readFileData(joinPath(destination, cache)));422 }423 return {424 uri:cache,425 checksum:checksum426 }427 });428 writeAppCache(appCache, joinPath(destination, 'cache.appcache'));429 }430 if (nativePackaging) {431 _logger.info("Generating native package");432 var packagerConfig = readConfig(433 joinPath(src, 'packager.json'));434 if (packagerConfig.platform.match(/iOS/)) {435 copy(436 resolvePath(joinPath(src, 'resources', 'icons')),437 resolvePath(destination),438 ignoreFilter);439 copy(440 resolvePath(joinPath(src, 'resources', 'loading')),441 resolvePath(destination),442 ignoreFilter);443 }444 // add '' here to coerce to javascript string instead of java string445 // for json encoding later...446 packagerConfig.inputPath = destination + '';447 448 var origDestination = proj.getProperty("args.destination"), 449 nativePackagePath = proj.getProperty("native.build.dir") ||450 joinPath(origDestination, "native");451 452 packagerConfig.outputPath = resolvePath(nativePackagePath) + '';453 454 PathUtil.ensurePathExists(packagerConfig.outputPath);455 writeFileContent(456 joinPath(src, 'packager.temp.json'),457 jsonEncode(packagerConfig, true));458 _logger.info(459 "Packaging your application as a native app to {} ...", 460 packagerConfig.outputPath);461 var stbuildRunner = new StBuildRunner(),462 args = ['package', resolvePath(src, 'packager.temp.json')],463 stbuildOut = stbuildRunner.run(args),464 exitCode = stbuildOut.getExitCode(),465 stdout = stbuildOut.getOutput();466 if (exitCode > 0) {467 _logger.error("failed running native packager");468 _logger.error(stdout);469 throw new ExBuild("failed running native packager")470 .raise();471 } else {472 _logger.info("Successfully packaged native application");473 _logger.info(474 "Package may be run with 'sencha package run -p {}", 475 joinPath(src, 'packager.temp.json'))476 }477 } else {478 _logger.debug("skipping native packaging");479 }480 }481 }482 });483 if (environment == 'testing') {484 processIndex();485 }486 487 _logger.info("Successfully deployed your application to " + destination);488};489function writeAppCache(appCache, outfile) {490 _logger.debug("generating appcache manifest...");491 // build the appCache file492 var builder = new StringBuilder();493 builder.append("CACHE MANIFEST\n");494 each(appCache.cache, function (cache) {495 builder.append("# " + cache.checksum + "\n");496 builder.append(cache.uri + "\n");497 });498 builder.append("\n\nFALLBACK:\n");499 each(appCache.fallback, function (fallback) {500 builder.append(fallback + '\n');501 });502 builder.append("\n\nNETWORK:\n");503 each(appCache.network, function (network) {504 builder.append(network + '\n');505 });506 writeFileContent(507 outfile,508 builder.toString());509 builder.setLength(0);510};511(function (proj) {512 _logger.info("building application");513 runAppBuild(proj);...

Full Screen

Full Screen

ResponseValidator.ts

Source:ResponseValidator.ts Github

copy

Full Screen

1// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.2// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.3import { Logger, JwtUtils, JwtPayload } from "./utils";4import type { MetadataService } from "./MetadataService";5import { UserInfoService } from "./UserInfoService";6import { TokenClient } from "./TokenClient";7import { ErrorResponse } from "./ErrorResponse";8import type { OidcClientSettingsStore } from "./OidcClientSettings";9import type { SigninState } from "./SigninState";10import type { SigninResponse } from "./SigninResponse";11import type { State } from "./State";12import type { SignoutResponse } from "./SignoutResponse";13import type { UserProfile } from "./User";14import type { RefreshState } from "./RefreshState";15/**16 * Derived from the following sets of claims:17 * - {@link https://datatracker.ietf.org/doc/html/rfc7519.html#section-4.1}18 * - {@link https://openid.net/specs/openid-connect-core-1_0.html#IDToken}19 * - {@link https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken}20 *21 * @internal22 */23const ProtocolClaims = [24 "iss",25 // "sub" should never be excluded, we need access to it internally26 "aud",27 "exp",28 "nbf",29 "iat",30 "jti",31 "auth_time",32 "nonce",33 "acr",34 "amr",35 "azp",36 // https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken37 "at_hash",38] as const;39/**40 * @internal41 */42export class ResponseValidator {43 protected readonly _logger = new Logger("ResponseValidator");44 protected readonly _userInfoService = new UserInfoService(this._metadataService);45 protected readonly _tokenClient = new TokenClient(this._settings, this._metadataService);46 public constructor(47 protected readonly _settings: OidcClientSettingsStore,48 protected readonly _metadataService: MetadataService,49 ) {}50 public async validateSigninResponse(response: SigninResponse, state: SigninState): Promise<void> {51 this._logger.debug("validateSigninResponse");52 this._processSigninState(response, state);53 this._logger.debug("validateSigninResponse: state processed");54 await this._processCode(response, state);55 this._logger.debug("validateSigninResponse: code processed");56 if (response.isOpenId) {57 this._validateIdTokenAttributes(response);58 }59 this._logger.debug("validateSigninResponse: tokens validated");60 await this._processClaims(response, state?.skipUserInfo);61 this._logger.debug("validateSigninResponse: claims processed");62 }63 public async validateRefreshResponse(response: SigninResponse, state: RefreshState): Promise<void> {64 this._logger.debug("validateRefreshResponse");65 response.userState = state.data;66 // if there's no scope on the response, then assume all scopes granted (per-spec) and copy over scopes from original request67 response.scope ??= state.scope;68 if (response.isOpenId) {69 this._validateIdTokenAttributes(response, state.id_token);70 }71 this._logger.debug("validateSigninResponse: tokens validated");72 await this._processClaims(response);73 this._logger.debug("validateSigninResponse: claims processed");74 }75 public validateSignoutResponse(response: SignoutResponse, state: State): void {76 if (state.id !== response.state) {77 this._logger.error("validateSignoutResponse: State does not match");78 throw new Error("State does not match");79 }80 // now that we know the state matches, take the stored data81 // and set it into the response so callers can get their state82 // this is important for both success & error outcomes83 this._logger.debug("validateSignoutResponse: state validated");84 response.userState = state.data;85 if (response.error) {86 this._logger.warn("validateSignoutResponse: Response was error", response.error);87 throw new ErrorResponse(response);88 }89 }90 protected _processSigninState(response: SigninResponse, state: SigninState): void {91 if (state.id !== response.state) {92 this._logger.error("_processSigninState: State does not match");93 throw new Error("State does not match");94 }95 if (!state.client_id) {96 this._logger.error("_processSigninState: No client_id on state");97 throw new Error("No client_id on state");98 }99 if (!state.authority) {100 this._logger.error("_processSigninState: No authority on state");101 throw new Error("No authority on state");102 }103 // ensure we're using the correct authority104 if (this._settings.authority !== state.authority) {105 this._logger.error("_processSigninState: authority mismatch on settings vs. signin state");106 throw new Error("authority mismatch on settings vs. signin state");107 }108 if (this._settings.client_id && this._settings.client_id !== state.client_id) {109 this._logger.error("_processSigninState: client_id mismatch on settings vs. signin state");110 throw new Error("client_id mismatch on settings vs. signin state");111 }112 // now that we know the state matches, take the stored data113 // and set it into the response so callers can get their state114 // this is important for both success & error outcomes115 this._logger.debug("_processSigninState: state validated");116 response.userState = state.data;117 // if there's no scope on the response, then assume all scopes granted (per-spec) and copy over scopes from original request118 response.scope ??= state.scope;119 if (response.error) {120 this._logger.warn("_processSigninState: Response was error", response.error);121 throw new ErrorResponse(response);122 }123 if (state.code_verifier && !response.code) {124 this._logger.error("_processSigninState: Expecting code in response");125 throw new Error("No code in response");126 }127 if (!state.code_verifier && response.code) {128 this._logger.error("_processSigninState: Not expecting code in response");129 throw new Error("Unexpected code in response");130 }131 }132 protected async _processClaims(response: SigninResponse, skipUserInfo = false): Promise<void> {133 if (!response.isOpenId) {134 this._logger.debug("_processClaims: response is not OIDC, not processing claims");135 return;136 }137 this._logger.debug("_processClaims: response is OIDC, processing claims");138 response.profile = this._filterProtocolClaims(response.profile);139 if (skipUserInfo || !this._settings.loadUserInfo || !response.access_token) {140 this._logger.debug("_processClaims: not loading user info");141 return;142 }143 this._logger.debug("_processClaims: loading user info");144 const claims = await this._userInfoService.getClaims(response.access_token);145 this._logger.debug("_processClaims: user info claims received from user info endpoint");146 if (claims.sub !== response.profile.sub) {147 this._logger.error("_processClaims: subject from UserInfo response does not match subject in ID Token");148 throw new Error("subject from UserInfo response does not match subject in ID Token");149 }150 response.profile = this._mergeClaims(response.profile, this._filterProtocolClaims(claims));151 this._logger.debug("_processClaims: user info claims received, updated profile:", response.profile);152 }153 protected _mergeClaims(claims1: UserProfile, claims2: JwtPayload): UserProfile {154 const result = { ...claims1 };155 for (const [claim, values] of Object.entries(claims2)) {156 for (const value of Array.isArray(values) ? values : [values]) {157 const previousValue = result[claim];158 if (!previousValue) {159 result[claim] = value;160 }161 else if (Array.isArray(previousValue)) {162 if (!previousValue.includes(value)) {163 previousValue.push(value);164 }165 }166 else if (result[claim] !== value) {167 if (typeof value === "object" && this._settings.mergeClaims) {168 result[claim] = this._mergeClaims(previousValue as UserProfile, value);169 }170 else {171 result[claim] = [previousValue, value];172 }173 }174 }175 }176 return result;177 }178 protected _filterProtocolClaims(claims: UserProfile): UserProfile {179 this._logger.debug("_filterProtocolClaims, incoming claims:", claims);180 const result = { ...claims };181 if (this._settings.filterProtocolClaims) {182 for (const type of ProtocolClaims) {183 delete result[type];184 }185 this._logger.debug("_filterProtocolClaims: protocol claims filtered:", result);186 }187 else {188 this._logger.debug("_filterProtocolClaims: protocol claims not filtered");189 }190 return result;191 }192 protected async _processCode(response: SigninResponse, state: SigninState): Promise<void> {193 if (response.code) {194 this._logger.debug("_processCode: Validating code");195 const tokenResponse = await this._tokenClient.exchangeCode({196 client_id: state.client_id,197 client_secret: state.client_secret,198 code: response.code,199 redirect_uri: state.redirect_uri,200 code_verifier: state.code_verifier,201 ...state.extraTokenParams,202 });203 Object.assign(response, tokenResponse);204 } else {205 this._logger.debug("_processCode: No code to process");206 }207 }208 protected _validateIdTokenAttributes(response: SigninResponse, currentToken?: string): void {209 this._logger.debug("_validateIdTokenAttributes: Decoding JWT attributes");210 const profile = JwtUtils.decode(response.id_token ?? "");211 if (!profile.sub) {212 this._logger.error("_validateIdTokenAttributes: No subject present in ID Token");213 throw new Error("No subject is present in ID Token");214 }215 if (currentToken) {216 const current = JwtUtils.decode(currentToken);217 if (current.sub !== profile.sub) {218 this._logger.error("_validateIdTokenFromTokenRefreshToken: sub in id_token does not match current sub");219 throw new Error("sub in id_token does not match current sub");220 }221 if (current.auth_time && current.auth_time !== profile.auth_time) {222 this._logger.error("_validateIdTokenFromTokenRefreshToken: auth_time in id_token does not match original auth_time");223 throw new Error("auth_time in id_token does not match original auth_time");224 }225 if (current.azp && current.azp !== profile.azp) {226 this._logger.error("_validateIdTokenFromTokenRefreshToken: azp in id_token does not match original azp");227 throw new Error("azp in id_token does not match original azp");228 }229 if (!current.azp && profile.azp) {230 this._logger.error("_validateIdTokenFromTokenRefreshToken: azp not in id_token, but present in original id_token");231 throw new Error("azp not in id_token, but present in original id_token");232 }233 }234 response.profile = profile;235 }...

Full Screen

Full Screen

logger.ts

Source:logger.ts Github

copy

Full Screen

1import winston from 'winston'2import Transport from 'winston-transport'3import { Loggly } from 'winston-loggly-bulk'4let _logger5export let init = (loggly = null) => {6 _logger = winston.createLogger({7 level: 'debug',8 format: winston.format.simple(),9 })10 _logger.add(new winston.transports.Console());11 if (loggly && loggly.subdomain) {12 _logger.add(13 new Loggly({14 level: loggly.level,15 token: loggly.token,16 subdomain: loggly.subdomain,17 json: true,18 tags: [process.env.LOGGLY_TAG],19 })20 )21 }22 _logger.info('logger initialized')23}24export let info = (...args) => _logger.info.apply(_logger, args)25export let debug = (...args) => _logger.debug.apply(_logger, args)26export let error = (...args) => _logger.error.apply(_logger, args)27export let warn = (...args) => _logger.warn.apply(_logger, args)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('root');2root._logger.info('hello world');3root._logger.debug('hello world');4root._logger.warn('hello world');5root._logger.error('hello world');6root._logger.fatal('hello world');7var root = require('root');8root._logger.info('hello world');9root._logger.debug('hello world');10root._logger.warn('hello world');11root._logger.error('hello world');12root._logger.fatal('hello world');13var root = require('root');14root._logger.info('hello world');15root._logger.debug('hello world');16root._logger.warn('hello world');17root._logger.error('hello world');18root._logger.fatal('hello world');19var root = require('root');20root._logger.info('hello world');21root._logger.debug('hello world');22root._logger.warn('hello world');23root._logger.error('hello world');24root._logger.fatal('hello world');25var root = require('root');26root._logger.info('hello world');27root._logger.debug('hello world');28root._logger.warn('hello world');29root._logger.error('hello world');30root._logger.fatal('hello world');31var root = require('root');32root._logger.info('hello world');33root._logger.debug('hello world');34root._logger.warn('hello world');35root._logger.error('hello world');36root._logger.fatal('hello world');37var root = require('root');38root._logger.info('hello world');39root._logger.debug('hello world');40root._logger.warn('hello world');41root._logger.error('hello world');42root._logger.fatal('hello world');43var root = require('root');44root._logger.info('hello world');45root._logger.debug('hello world');46root._logger.warn('hello world');

Full Screen

Using AI Code Generation

copy

Full Screen

1_logger.debug("debug message");2_logger.info("info message");3_logger.warn("warn message");4_logger.error("error message");5_logger.fatal("fatal message");6_logger.child("child").debug("debug message");7_logger.child("child").info("info message");8_logger.child("child").warn("warn message");9_logger.child("child").error("error message");10_logger.child("child").fatal("fatal message");

Full Screen

Using AI Code Generation

copy

Full Screen

1var logger = require('log4js').getLogger();2logger.info('Hello World');3var logger = require('log4js').getLogger('child');4logger.info('Hello World');5var logger = require('log4js').getLogger();6logger.info('Hello World');7var logger = require('log4js').getLogger('child');8logger.info('Hello World');9var logger = require('log4js').getLogger();10logger.info('Hello World');11var logger = require('log4js').getLogger('child');12logger.info('Hello World');13var logger = require('log4js').getLogger();14logger.info('Hello World');15var logger = require('log4js').getLogger('child');16logger.info('Hello World');17var logger = require('log4js').getLogger();18logger.info('Hello World');19var logger = require('log4js').getLogger('child');20logger.info('Hello World');21var logger = require('log4js').getLogger();22logger.info('Hello World');23var logger = require('log4js').getLogger('child');24logger.info('Hello World');25var logger = require('log4js').getLogger();26logger.info('Hello World');27var logger = require('log4js').getLogger('child');28logger.info('Hello World');29var logger = require('log4js').getLogger();30logger.info('Hello World');

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('root-module');2var logger = root._logger('test');3logger.info('test');4var root = require('root-module');5var logger = root._logger('test2');6logger.info('test2');7var root = require('root-module');8var logger = root._logger('test2');9logger.info('test2');10var root = require('root-module');11var logger = root._logger('test');12logger.info('test');13var logger2 = logger.child({label: 'test2'});14logger2.info('test2');15var root = require('root-module');16var logger = root._logger('test2');17logger.info('test2');18var root = require('root-module');19var logger = root._logger('test');20logger.info('test');21var logger2 = logger.child({label: 'test2'});22logger2.info('test2');23var root = require('root-module');24var logger = root._logger('test2');25logger.info('test2');

Full Screen

Using AI Code Generation

copy

Full Screen

1const root = require('root-path');2const logger = root._logger;3logger.info('Hello World');4logger.debug('Hello World');5logger.error('Hello World');6logger.warn('Hello World');7logger.trace('Hello World');8logger.fatal('Hello World');9logger.silly('Hello World');10const root = require('root-path');11const logger = root._logger;12logger.info('Hello World');13logger.debug('Hello World');14logger.error('Hello World');15logger.warn('Hello World');16logger.trace('Hello World');17logger.fatal('Hello World');18logger.silly('Hello World');19const root = require('root-path');20const logger = root._logger;21logger.info('Hello World');22logger.debug('Hello World');23logger.error('Hello World');24logger.warn('Hello World');25logger.trace('Hello World');26logger.fatal('Hello World');27logger.silly('Hello World');28const root = require('root-path');29const logger = root._logger;30logger.info('Hello World');31logger.debug('Hello World');32logger.error('Hello World');33logger.warn('Hello World');34logger.trace('Hello World');35logger.fatal('Hello World');36logger.silly('Hello World');37const root = require('root-path');38const logger = root._logger;39logger.info('Hello World');40logger.debug('Hello World');41logger.error('Hello World');42logger.warn('Hello World');43logger.trace('Hello World');44logger.fatal('Hello World');45logger.silly('Hello World');46const root = require('root-path');47const logger = root._logger;48logger.info('Hello World');49logger.debug('Hello World');50logger.error('Hello World');51logger.warn('Hello World');52logger.trace('Hello World');53logger.fatal('Hello World');54logger.silly('Hello World');55const root = require('root-path');56const logger = root._logger;57logger.info('Hello World');58logger.debug('Hello World');59logger.error('Hello World');60logger.warn('Hello World');

Full Screen

Using AI Code Generation

copy

Full Screen

1var logger = require('..')('_logger');2logger('Logging from test.js');3var logger = require('..')('_logger');4logger('Logging from test2.js');5var logger = require('..')('_logger');6logger('Logging from test3.js');7var logger = require('..')('_logger');8logger('Logging from test4.js');9var logger = require('..')('_logger');10logger('Logging from test5.js');11var logger = require('..')('_logger');12logger('Logging from test6.js');13var logger = require('..')('_logger');14logger('Logging from test7.js');15var logger = require('..')('_logger');16logger('Logging from test8.js');17var logger = require('..')('_logger');18logger('Logging from test9.js');19var logger = require('..')('_logger');20logger('Logging from test10.js');21var logger = require('..')('_logger');22logger('Logging from test11.js');23var logger = require('..')('_logger');24logger('Logging from test12.js');25var logger = require('..')('_logger');26logger('Logging from test13.js');27var logger = require('..')('_logger');28logger('Logging from test14.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('./test2');2test();3const logger = require('logger')._logger;4module.exports = function () {5 logger.info('Hello World!');6}

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 root 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