kyubumJang

ADD README.md, DELETE readME.txt

Showing 1000 changed files with 4836 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +오답노트 생성 홈페이지
2 +OSS_AUTO_INCORRECT_NOTE:
3 +작성자: 장규범
4 +2020년 6월 18일
5 +진행: wix api를 사용하여 홈페이지 구성
6 +https://jkb2221.wixsite.com/incorrect-note
7 + 오답노트 자동생성(LEET, psat, 자격증 시험(정보처리기사) 등 각종 시험 기출문제)
8 +
9 +목적
10 +시험 공부를 하다보면 틀린 문제를 한 곳에 모아서 다시 한 번 보거나 자주 틀리는 문제유형을 구분해서 보고 싶은 경우가 있다. 하나하나 손으로 문제 풀이한 것을 찾아볼 필요없이 OMR입력하는 것처럼 입력만 하면 답지에 의한 채점과 문제에 해당하는 카테고리끼리 묶어, 틀린문제들 모아서 시험지처럼 만들기(하나의 PDF), 해설서에 있는 답지 뒤에 붙여주는 기능을 제공하는 것이 목적이다.
11 +목표
12 +오답노트를 간단하고 편리하게 만들 수 있도록 각종 기능을 제공하는 것
13 +기능
14 +주요 시험의 기출 문제에 대한 자동채점
15 +오답노트 자동생성
16 +문제에 해당하는 카테고리 끼리 묶어서 생성
17 +틀린 문제 전부 번호 오름차순으로 모아서 생성
18 +시험문제 1개에 해당하는 것만이 아닌 시험 보고 난 뒤 틀린 문제
19 +추가적으로 애매하거나 한 번 더 볼 필요성이 있는 문제들
20 +사진으로 찍어서 인식할 수 있는지 여부도 확인
21 +난이도 별로 나누기
22 +소제- 문제유형 별로 나누기
23 +
24 +추가기능(있으면 좋고 없어도 괜찮은 기능)
25 +문제집 사진 찍어서 웹 페이지에 올리면 pdf로 문제집 형식으로 구성되어 자동으로 만들어 지게 하는 기능
26 +구현
27 +wix API를 사용하여 홈페이지 구현, 각종 기능들은 추가적인 API를 통해서 구현할 예정, 파파고 API를 통해 라인을 통해 사진을 전송하면 사진 속 글자를 인식해서PDF파일에 포함할 수 있게 구현할 예정
28 +
29 +프로젝트 개요
30 +http://www.pxd.co.kr
31 +웹페이지 만들기
32 +
33 +흐름도
34 +웹페이지 만들기
35 +목록: PDF 변환, 오답노트 생성(카테고리 별 생성, 기출문제 연도별 생성, 각 난이도 별 생성), 데이터 제공(틀린 유형, 기출 문제별 점수, 난이도 별 틀린 문제)
36 +문제 데이터베이스 모으기
37 +구글 클라우드 API 사용하여 각각의 공부하고 있는 것(리트, PSAT, 토익 문제 각각에 대해서 폴더로 구분되어 있고) 각각의 문제에 대한 PDF 업로드 되어서 클라우드에 있는 데이터를 홈페이지로 받기
38 +홈페이지에서 어떤 과목의 몇 회 기출문제를 자동채점할 건지 생성
39 +EX) 리트의 2019년도 기출문제 자동채점 누르면 -> OMR 자동채점으로 이동
40 +OMR 통한 자동채점 page
41 +OMR 서식 들고와서 포인터로 선택 OR 그냥 번호에 맞게 서식 주고 쭉 넘어가게 Google form 형식으로 다음 누르면
42 +-> 자동채점되고 점수 출력, 유형별 , 난이도별,
43 +오답노트 구현 page
44 +각 번호를 선정해서 오답노트로 만들어서 구현하는 것(OMR 자동채점 건너뛰고 자기가 원하는 것만 모아서 PDF로 만들기)
45 +오답노트 서식에 번호 붙어서 합쳐서 PDF 파일로 저장
46 +사진찍어서 PDF로 바꿀수 있게 구현(라인 또는 카카오 톡으로 보내면, 서버에서 받아서 웹페이지로 전송, 웹페이지에서 PDF 변환)
47 +
48 +
49 +바로 프린트할 수 있게 구현할 수 있는지 여부 확인, 가능하면 구현
50 +
51 +
1 +var passport = require('passport');
2 +var LocalStrategy = require('passport-local').Strategy;
3 +var User = require('../models/User');
4 +
5 +// serialize & deserialize User
6 +passport.serializeUser(function(user, done) {
7 + done(null, user.id);
8 +});
9 +passport.deserializeUser(function(id, done) {
10 + User.findOne({_id:id}, function(err, user) {
11 + done(err, user);
12 + });
13 +});
14 +
15 +// local strategy
16 +passport.use('local-login',
17 + new LocalStrategy({
18 + usernameField : 'username',
19 + passwordField : 'password',
20 + passReqToCallback : true
21 + },
22 + function(req, username, password, done) {
23 + User.findOne({username:username})
24 + .select({password:1})
25 + .exec(function(err, user) {
26 + if (err) return done(err);
27 +
28 + if (user && user.authenticate(password)){
29 + return done(null, user);
30 + }
31 + else {
32 + req.flash('username', username);
33 + req.flash('errors', {login:'The username or password is incorrect.'});
34 + return done(null, false);
35 + }
36 + });
37 + }
38 + )
39 +);
40 +
41 +module.exports = passport;
letsencrypt @ 24c5fab8
1 +Subproject commit 24c5fab8b6373b9711fc4b71279baac2a8b98440
1 +var mongoose = require('mongoose');
2 +
3 +// schema
4 +var commentSchema = mongoose.Schema({
5 + post:{type:mongoose.Schema.Types.ObjectId, ref:'post', required:true},
6 + author:{type:mongoose.Schema.Types.ObjectId, ref:'user', required:true},
7 + parentComment:{type:mongoose.Schema.Types.ObjectId, ref:'comment'},
8 + text:{type:String, required:[true,'text is required!']},
9 + isDeleted:{type:Boolean},
10 + createdAt:{type:Date, default:Date.now},
11 + updatedAt:{type:Date},
12 +},{
13 + toObject:{virtuals:true}
14 +});
15 +
16 +commentSchema.virtual('childComments')
17 + .get(function(){ return this._childComments; })
18 + .set(function(value){ this._childComments=value; });
19 +
20 +// model & export
21 +var Comment = mongoose.model('comment',commentSchema);
22 +module.exports = Comment;
1 +var mongoose = require('mongoose');
2 +
3 +// schema
4 +var counterSchema = mongoose.Schema({
5 + name:{type:String, required:true},
6 + count:{type:Number, default:0},
7 +});
8 +
9 +// model & export
10 +var Counter = mongoose.model('counter', counterSchema);
11 +module.exports = Counter;
1 +//box cloud로 api 사용하여 파일업로드 다운로드 하려 했으나 댓글로 S3파일로 임시 다운
2 +var mongoose = require('mongoose');
3 +var fs = require('fs');
4 +var path = require('path');
5 +
6 +// Box client setting
7 +var BoxSDK = require('box-node-sdk');
8 +var client;
9 +//env 설정, 보안화 해야됨..
10 +var boxClientId = 'auvirglnn48navml8zc7a79cfddczl6x';
11 +var boxAppToken = '3cVBrpHhIFPFuMVj9bAsX7uKOkntLhF3';
12 +var isBoxEnabled = boxClientId && boxAppToken;
13 +
14 +if(isBoxEnabled){
15 + var sdk = new BoxSDK({
16 + clientID: boxClientId,
17 + clientSecret: ''
18 + });
19 + client = sdk.getBasicClient(boxAppToken);
20 +}
21 +//console.log(isBoxEnabled);
22 +
23 +// schema
24 +var fileSchema = mongoose.Schema({
25 + originalFileName:{type:String},
26 + serverFileId:{type:String},
27 + serverFileName:{type:String},
28 + size:{type:Number},
29 + uploadedBy:{type:mongoose.Schema.Types.ObjectId, ref:'user', required:true},
30 + postId:{type:mongoose.Schema.Types.ObjectId, ref:'post'},
31 + isDeleted:{type:Boolean, default:false},
32 +});
33 +
34 +// instance methods
35 +fileSchema.methods.processDelete = function(){
36 + this.isDeleted = true;
37 + this.save();
38 +};
39 +
40 +fileSchema.methods.getFileStream = async function(){
41 + if(isBoxEnabled){ // using box.com
42 + try{
43 + var stream = await client.files.getReadStream(this.serverFileId);
44 + }
45 + catch(err){
46 + if(err.statusCode == 404){
47 + this.processDelete();
48 + }
49 + throw(err.statusCode);
50 + }
51 + return stream;
52 + }
53 + else { // using server file system
54 + var stream;
55 + var filePath = path.join(__dirname,'..','uploadedFiles',this.serverFileName);
56 + var fileExists = fs.existsSync(filePath);
57 + if(fileExists){
58 + stream = fs.createReadStream(filePath);
59 + }
60 + else {
61 + this.processDelete();
62 + }
63 + return stream;
64 + }
65 +};
66 +
67 +// model & export
68 +var File = mongoose.model('file', fileSchema);
69 +
70 +// model methods
71 +File.createNewInstance = async function(file, uploadedBy, postId){
72 + if(isBoxEnabled){ // using box.com
73 + var filePath = path.join(__dirname,'..','uploadedFiles',file.filename);
74 + var stream = fs.createReadStream(filePath);
75 + var boxResponse = await client.files.uploadFile('0', `${file.filename}_${file.originalname}`, stream);
76 + var uploadedFile = boxResponse.entries[0];
77 +
78 + return await File.create({
79 + originalFileName:file.originalname,
80 + serverFileName:file.filename,
81 + serverFileId:uploadedFile.id,
82 + size:file.size,
83 + uploadedBy:uploadedBy,
84 + postId:postId,
85 + });
86 + }
87 + else { // using server file system
88 + return await File.create({
89 + originalFileName:file.originalname,
90 + serverFileName:file.filename,
91 + size:file.size,
92 + uploadedBy:uploadedBy,
93 + postId:postId,
94 + });
95 + }
96 +};
97 +
98 +module.exports = File;
1 +var mongoose = require('mongoose');
2 +var Counter = require('./Counter');
3 +
4 +// schema
5 +var postSchema = mongoose.Schema({
6 + title:{type:String, required:[true,'Title is required!']},
7 + body:{type:String, required:[true,'Body is required!']},
8 + author:{type:mongoose.Schema.Types.ObjectId, ref:'user', required:true},
9 + views:{type:Number, default:0},
10 + numId:{type:Number},
11 + attachment:{type:mongoose.Schema.Types.ObjectId, ref:'file'},
12 + createdAt:{type:Date, default:Date.now},
13 + updatedAt:{type:Date},
14 +});
15 +
16 +postSchema.pre('save', async function (next){
17 + var post = this;
18 + if(post.isNew){
19 + counter = await Counter.findOne({name:'posts'}).exec();
20 + if(!counter) counter = await Counter.create({name:'posts'});
21 + counter.count++;
22 + counter.save();
23 + post.numId = counter.count;
24 + }
25 + return next();
26 +});
27 +
28 +// model & export
29 +var Post = mongoose.model('post', postSchema);
30 +module.exports = Post;
1 +var mongoose = require('mongoose');
2 +var bcrypt = require('bcryptjs');
3 +
4 +// schema
5 +var userSchema = mongoose.Schema({
6 + username:{
7 + type:String,
8 + required:[true,'Username is required!'],
9 + match:[/^.{4,12}$/,'Should be 4-12 characters!'],
10 + trim:true,
11 + unique:true
12 + },
13 + password:{
14 + type:String,
15 + required:[true,'Password is required!'],
16 + select:false
17 + },
18 + name:{
19 + type:String,
20 + required:[true,'Name is required!'],
21 + match:[/^.{4,12}$/,'Should be 4-12 characters!'],
22 + trim:true
23 + },
24 + email:{
25 + type:String,
26 + match:[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,'Should be a vaild email address!'],
27 + trim:true
28 + }
29 +},{
30 + toObject:{virtuals:true}
31 +});
32 +
33 +// virtuals
34 +userSchema.virtual('passwordConfirmation')
35 + .get(function(){ return this._passwordConfirmation; })
36 + .set(function(value){ this._passwordConfirmation=value; });
37 +
38 +userSchema.virtual('originalPassword')
39 + .get(function(){ return this._originalPassword; })
40 + .set(function(value){ this._originalPassword=value; });
41 +
42 +userSchema.virtual('currentPassword')
43 + .get(function(){ return this._currentPassword; })
44 + .set(function(value){ this._currentPassword=value; });
45 +
46 +userSchema.virtual('newPassword')
47 + .get(function(){ return this._newPassword; })
48 + .set(function(value){ this._newPassword=value; });
49 +
50 +// password validation
51 +var passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/;
52 +var passwordRegexErrorMessage = 'Should be minimum 8 characters of alphabet and number combination!';
53 +userSchema.path('password').validate(function(v) {
54 + var user = this;
55 +
56 + // create user
57 + if(user.isNew){
58 + if(!user.passwordConfirmation){
59 + user.invalidate('passwordConfirmation', 'Password Confirmation is required.');
60 + }
61 +
62 + if(!passwordRegex.test(user.password)){
63 + user.invalidate('password', passwordRegexErrorMessage);
64 + }
65 + else if(user.password !== user.passwordConfirmation) {
66 + user.invalidate('passwordConfirmation', 'Password Confirmation does not matched!');
67 + }
68 + }
69 +
70 + // update user
71 + if(!user.isNew){
72 + if(!user.currentPassword){
73 + user.invalidate('currentPassword', 'Current Password is required!');
74 + }
75 + else if(!bcrypt.compareSync(user.currentPassword, user.originalPassword)){
76 + user.invalidate('currentPassword', 'Current Password is invalid!');
77 + }
78 +
79 + if(user.newPassword && !passwordRegex.test(user.newPassword)){
80 + user.invalidate("newPassword", passwordRegexErrorMessage);
81 + }
82 + else if(user.newPassword !== user.passwordConfirmation) {
83 + user.invalidate('passwordConfirmation', 'Password Confirmation does not matched!');
84 + }
85 + }
86 +});
87 +
88 +// hash password
89 +userSchema.pre('save', function (next){
90 + var user = this;
91 + if(!user.isModified('password')){
92 + return next();
93 + }
94 + else {
95 + user.password = bcrypt.hashSync(user.password);
96 + return next();
97 + }
98 +});
99 +
100 +// model methods
101 +userSchema.methods.authenticate = function (password) {
102 + var user = this;
103 + return bcrypt.compareSync(password,user.password);
104 +};
105 +
106 +// model & export
107 +var User = mongoose.model('user',userSchema);
108 +module.exports = User;
1 +var mongoose = require('mongoose');
2 +var Schema = mongoose.Schema;
3 +
4 +var bookSchema = new Schema({
5 + title: String,
6 + author: String,
7 + published_date: { type: Date, default: Date.now }
8 +});
9 +
10 +module.exports = mongoose.model('book', bookSchema);
...\ No newline at end of file ...\ No newline at end of file
1 +#!/usr/bin/env node
2 +/*
3 + * EJS Embedded JavaScript templates
4 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5 + *
6 + * Licensed under the Apache License, Version 2.0 (the "License");
7 + * you may not use this file except in compliance with the License.
8 + * You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing, software
13 + * distributed under the License is distributed on an "AS IS" BASIS,
14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + * See the License for the specific language governing permissions and
16 + * limitations under the License.
17 + *
18 +*/
19 +
20 +
21 +let program = require('jake').program;
22 +delete global.jake; // NO NOT WANT
23 +program.setTaskNames = function (n) { this.taskNames = n; };
24 +
25 +let ejs = require('../lib/ejs');
26 +let fs = require('fs');
27 +let args = process.argv.slice(2);
28 +let usage = fs.readFileSync(`${__dirname}/../usage.txt`).toString();
29 +
30 +const CLI_OPTS = [
31 + { full: 'output-file',
32 + abbr: 'o',
33 + expectValue: true,
34 + },
35 + { full: 'data-file',
36 + abbr: 'f',
37 + expectValue: true,
38 + },
39 + { full: 'data-input',
40 + abbr: 'i',
41 + expectValue: true,
42 + },
43 + { full: 'delimiter',
44 + abbr: 'm',
45 + expectValue: true,
46 + passThrough: true,
47 + },
48 + { full: 'open-delimiter',
49 + abbr: 'p',
50 + expectValue: true,
51 + passThrough: true,
52 + },
53 + { full: 'close-delimiter',
54 + abbr: 'c',
55 + expectValue: true,
56 + passThrough: true,
57 + },
58 + { full: 'strict',
59 + abbr: 's',
60 + expectValue: false,
61 + allowValue: false,
62 + passThrough: true,
63 + },
64 + { full: 'no-with',
65 + abbr: 'n',
66 + expectValue: false,
67 + allowValue: false,
68 + },
69 + { full: 'locals-name',
70 + abbr: 'l',
71 + expectValue: true,
72 + passThrough: true,
73 + },
74 + { full: 'rm-whitespace',
75 + abbr: 'w',
76 + expectValue: false,
77 + allowValue: false,
78 + passThrough: true,
79 + },
80 + { full: 'debug',
81 + abbr: 'd',
82 + expectValue: false,
83 + allowValue: false,
84 + passThrough: true,
85 + },
86 + { full: 'help',
87 + abbr: 'h',
88 + passThrough: true,
89 + },
90 + { full: 'version',
91 + abbr: 'V',
92 + passThrough: true,
93 + },
94 + // Alias lowercase v
95 + { full: 'version',
96 + abbr: 'v',
97 + passThrough: true,
98 + },
99 +];
100 +
101 +let preempts = {
102 + version: function () {
103 + program.die(ejs.VERSION);
104 + },
105 + help: function () {
106 + program.die(usage);
107 + }
108 +};
109 +
110 +let stdin = '';
111 +process.stdin.setEncoding('utf8');
112 +process.stdin.on('readable', () => {
113 + let chunk;
114 + while ((chunk = process.stdin.read()) !== null) {
115 + stdin += chunk;
116 + }
117 +});
118 +
119 +function run() {
120 +
121 + program.availableOpts = CLI_OPTS;
122 + program.parseArgs(args);
123 +
124 + let templatePath = program.taskNames[0];
125 + let pVals = program.envVars;
126 + let pOpts = {};
127 +
128 + for (let p in program.opts) {
129 + let name = p.replace(/-[a-z]/g, (match) => { return match[1].toUpperCase(); });
130 + pOpts[name] = program.opts[p];
131 + }
132 +
133 + let opts = {};
134 + let vals = {};
135 +
136 + // Same-named 'passthrough' opts
137 + CLI_OPTS.forEach((opt) => {
138 + let optName = opt.full;
139 + if (opt.passThrough && typeof pOpts[optName] != 'undefined') {
140 + opts[optName] = pOpts[optName];
141 + }
142 + });
143 +
144 + // Bail out for help/version
145 + for (let p in opts) {
146 + if (preempts[p]) {
147 + return preempts[p]();
148 + }
149 + }
150 +
151 + // Ensure there's a template to render
152 + if (!templatePath) {
153 + throw new Error('Please provide a template path. (Run ejs -h for help)');
154 + }
155 +
156 + if (opts.strict) {
157 + pOpts.noWith = true;
158 + }
159 + if (pOpts.noWith) {
160 + opts._with = false;
161 + }
162 +
163 + // Grab and parse any input data, in order of precedence:
164 + // 1. Stdin
165 + // 2. CLI arg via -i
166 + // 3. Data file via -f
167 + // Any individual vals passed at the end (e.g., foo=bar) will override
168 + // any vals previously set
169 + let input;
170 + let err = new Error('Please do not pass data multiple ways. Pick one of stdin, -f, or -i.');
171 + if (stdin) {
172 + input = stdin;
173 + }
174 + else if (pOpts.dataInput) {
175 + if (input) {
176 + throw err;
177 + }
178 + input = decodeURIComponent(pOpts.dataInput);
179 + }
180 + else if (pOpts.dataFile) {
181 + if (input) {
182 + throw err;
183 + }
184 + input = fs.readFileSync(pOpts.dataFile).toString();
185 + }
186 +
187 + if (input) {
188 + vals = JSON.parse(input);
189 + }
190 +
191 + // Override / set any individual values passed from the command line
192 + for (let p in pVals) {
193 + vals[p] = pVals[p];
194 + }
195 +
196 + let template = fs.readFileSync(templatePath).toString();
197 + let output = ejs.render(template, vals, opts);
198 + if (pOpts.outputFile) {
199 + fs.writeFileSync(pOpts.outputFile, output);
200 + }
201 + else {
202 + process.stdout.write(output);
203 + }
204 + process.exit();
205 +}
206 +
207 +// Defer execution so that stdin can be read if necessary
208 +setImmediate(run);
1 +#!/usr/bin/env node
2 +'use strict'
3 +
4 +process.exit(require('./') ? 0 : 1)
1 +#!/usr/bin/env node
2 +/*
3 + * Jake JavaScript build tool
4 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5 + *
6 + * Licensed under the Apache License, Version 2.0 (the "License");
7 + * you may not use this file except in compliance with the License.
8 + * You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing, software
13 + * distributed under the License is distributed on an "AS IS" BASIS,
14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + * See the License for the specific language governing permissions and
16 + * limitations under the License.
17 + *
18 +*/
19 +
20 +// Try to load a local jake
21 +try {
22 + require(`${ process.cwd() }/node_modules/jake`);
23 +}
24 +// If that fails, likely running globally
25 +catch(e) {
26 + require('../lib/jake');
27 +}
28 +
29 +var args = process.argv.slice(2);
30 +
31 +jake.run.apply(jake, args);
1 +#!/usr/bin/env node
2 +
3 +var mime = require('./mime.js');
4 +var file = process.argv[2];
5 +var type = mime.lookup(file);
6 +
7 +process.stdout.write(type + '\n');
8 +
1 +#!/usr/bin/env node
2 +
3 +var mkdirp = require('../');
4 +var minimist = require('minimist');
5 +var fs = require('fs');
6 +
7 +var argv = minimist(process.argv.slice(2), {
8 + alias: { m: 'mode', h: 'help' },
9 + string: [ 'mode' ]
10 +});
11 +if (argv.help) {
12 + fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
13 + return;
14 +}
15 +
16 +var paths = argv._.slice();
17 +var mode = argv.mode ? parseInt(argv.mode, 8) : undefined;
18 +
19 +(function next () {
20 + if (paths.length === 0) return;
21 + var p = paths.shift();
22 +
23 + if (mode === undefined) mkdirp(p, cb)
24 + else mkdirp(p, mode, cb)
25 +
26 + function cb (err) {
27 + if (err) {
28 + console.error(err.message);
29 + process.exit(1);
30 + }
31 + else next();
32 + }
33 +})();
1 +#!/usr/bin/env node
2 +
3 +const cli = require('../lib/cli');
4 +const nodemon = require('../lib/');
5 +const options = cli.parse(process.argv);
6 +
7 +nodemon(options);
8 +
9 +const fs = require('fs');
10 +
11 +// checks for available update and returns an instance
12 +const pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));
13 +
14 +if (pkg.version.indexOf('0.0.0') !== 0 && options.noUpdateNotifier !== true) {
15 + require('update-notifier')({ pkg }).notify();
16 +}
1 +#!/usr/bin/env node
2 +const touch = require("../index.js")
3 +
4 +const usage = code => {
5 + console[code ? 'error' : 'log'](
6 + 'usage:\n' +
7 + 'touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...'
8 + )
9 + process.exit(code)
10 +}
11 +
12 +const singleFlags = {
13 + a: 'atime',
14 + m: 'mtime',
15 + c: 'nocreate',
16 + f: 'force'
17 +}
18 +
19 +const singleOpts = {
20 + r: 'ref',
21 + t: 'time'
22 +}
23 +
24 +const files = []
25 +const args = process.argv.slice(2)
26 +const options = {}
27 +for (let i = 0; i < args.length; i++) {
28 + const arg = args[i]
29 + if (!arg.match(/^-/)) {
30 + files.push(arg)
31 + continue
32 + }
33 +
34 + // expand shorthands
35 + if (arg.charAt(1) !== '-') {
36 + const expand = []
37 + for (let f = 1; f < arg.length; f++) {
38 + const fc = arg.charAt(f)
39 + const sf = singleFlags[fc]
40 + const so = singleOpts[fc]
41 + if (sf)
42 + expand.push('--' + sf)
43 + else if (so) {
44 + const soslice = arg.slice(f + 1)
45 + const soval = soslice.charAt(0) === '=' ? soslice : '=' + soslice
46 + expand.push('--' + so + soval)
47 + f = arg.length
48 + } else if (arg !== '-' + fc)
49 + expand.push('-' + fc)
50 + }
51 + if (expand.length) {
52 + args.splice.apply(args, [i, 1].concat(expand))
53 + i--
54 + continue
55 + }
56 + }
57 +
58 + const argsplit = arg.split('=')
59 + const key = argsplit.shift().replace(/^\-\-/, '')
60 + const val = argsplit.length ? argsplit.join('=') : null
61 +
62 + switch (key) {
63 + case 'time':
64 + const timestr = val || args[++i]
65 + // [-t [[CC]YY]MMDDhhmm[.SS]]
66 + const parsedtime = timestr.match(
67 + /^(([0-9]{2})?([0-9]{2}))?([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})(\.([0-9]{2}))?$/
68 + )
69 + if (!parsedtime) {
70 + console.error('touch: out of range or illegal ' +
71 + 'time specification: ' +
72 + '[[CC]YY]MMDDhhmm[.SS]')
73 + process.exit(1)
74 + } else {
75 + const y = +parsedtime[1]
76 + const year = parsedtime[2] ? y
77 + : y <= 68 ? 2000 + y
78 + : 1900 + y
79 +
80 + const MM = +parsedtime[4] - 1
81 + const dd = +parsedtime[5]
82 + const hh = +parsedtime[6]
83 + const mm = +parsedtime[7]
84 + const ss = +parsedtime[8]
85 +
86 + options.time = new Date(Date.UTC(year, MM, dd, hh, mm, ss))
87 + }
88 + continue
89 +
90 + case 'ref':
91 + options.ref = val || args[++i]
92 + continue
93 +
94 + case 'mtime':
95 + case 'nocreate':
96 + case 'atime':
97 + case 'force':
98 + options[key] = true
99 + continue
100 +
101 + default:
102 + console.error('touch: illegal option -- ' + arg)
103 + usage(1)
104 + }
105 +}
106 +
107 +if (!files.length)
108 + usage()
109 +
110 +process.exitCode = 0
111 +Promise.all(files.map(f => touch(f, options)))
112 + .catch(er => process.exitCode = 1)
1 +#!/usr/bin/env node
2 +var nopt = require("../lib/nopt")
3 + , types = { num: Number
4 + , bool: Boolean
5 + , help: Boolean
6 + , list: Array
7 + , "num-list": [Number, Array]
8 + , "str-list": [String, Array]
9 + , "bool-list": [Boolean, Array]
10 + , str: String }
11 + , shorthands = { s: [ "--str", "astring" ]
12 + , b: [ "--bool" ]
13 + , nb: [ "--no-bool" ]
14 + , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ]
15 + , "?": ["--help"]
16 + , h: ["--help"]
17 + , H: ["--help"]
18 + , n: [ "--num", "125" ] }
19 + , parsed = nopt( types
20 + , shorthands
21 + , process.argv
22 + , 2 )
23 +
24 +console.log("parsed", parsed)
25 +
26 +if (parsed.help) {
27 + console.log("")
28 + console.log("nopt cli tester")
29 + console.log("")
30 + console.log("types")
31 + console.log(Object.keys(types).map(function M (t) {
32 + var type = types[t]
33 + if (Array.isArray(type)) {
34 + return [t, type.map(function (type) { return type.name })]
35 + }
36 + return [t, type && type.name]
37 + }).reduce(function (s, i) {
38 + s[i[0]] = i[1]
39 + return s
40 + }, {}))
41 + console.log("")
42 + console.log("shorthands")
43 + console.log(shorthands)
44 +}
1 +#! /usr/bin/env node
2 +var rc = require('./index')
3 +
4 +console.log(JSON.stringify(rc(process.argv[2]), false, 2))
1 +#!/usr/bin/env node
2 +// Standalone semver comparison program.
3 +// Exits successfully and prints matching version(s) if
4 +// any supplied version is valid and passes all tests.
5 +
6 +var argv = process.argv.slice(2)
7 +
8 +var versions = []
9 +
10 +var range = []
11 +
12 +var inc = null
13 +
14 +var version = require('../package.json').version
15 +
16 +var loose = false
17 +
18 +var includePrerelease = false
19 +
20 +var coerce = false
21 +
22 +var identifier
23 +
24 +var semver = require('../semver')
25 +
26 +var reverse = false
27 +
28 +var options = {}
29 +
30 +main()
31 +
32 +function main () {
33 + if (!argv.length) return help()
34 + while (argv.length) {
35 + var a = argv.shift()
36 + var indexOfEqualSign = a.indexOf('=')
37 + if (indexOfEqualSign !== -1) {
38 + a = a.slice(0, indexOfEqualSign)
39 + argv.unshift(a.slice(indexOfEqualSign + 1))
40 + }
41 + switch (a) {
42 + case '-rv': case '-rev': case '--rev': case '--reverse':
43 + reverse = true
44 + break
45 + case '-l': case '--loose':
46 + loose = true
47 + break
48 + case '-p': case '--include-prerelease':
49 + includePrerelease = true
50 + break
51 + case '-v': case '--version':
52 + versions.push(argv.shift())
53 + break
54 + case '-i': case '--inc': case '--increment':
55 + switch (argv[0]) {
56 + case 'major': case 'minor': case 'patch': case 'prerelease':
57 + case 'premajor': case 'preminor': case 'prepatch':
58 + inc = argv.shift()
59 + break
60 + default:
61 + inc = 'patch'
62 + break
63 + }
64 + break
65 + case '--preid':
66 + identifier = argv.shift()
67 + break
68 + case '-r': case '--range':
69 + range.push(argv.shift())
70 + break
71 + case '-c': case '--coerce':
72 + coerce = true
73 + break
74 + case '-h': case '--help': case '-?':
75 + return help()
76 + default:
77 + versions.push(a)
78 + break
79 + }
80 + }
81 +
82 + var options = { loose: loose, includePrerelease: includePrerelease }
83 +
84 + versions = versions.map(function (v) {
85 + return coerce ? (semver.coerce(v) || { version: v }).version : v
86 + }).filter(function (v) {
87 + return semver.valid(v)
88 + })
89 + if (!versions.length) return fail()
90 + if (inc && (versions.length !== 1 || range.length)) { return failInc() }
91 +
92 + for (var i = 0, l = range.length; i < l; i++) {
93 + versions = versions.filter(function (v) {
94 + return semver.satisfies(v, range[i], options)
95 + })
96 + if (!versions.length) return fail()
97 + }
98 + return success(versions)
99 +}
100 +
101 +function failInc () {
102 + console.error('--inc can only be used on a single version with no range')
103 + fail()
104 +}
105 +
106 +function fail () { process.exit(1) }
107 +
108 +function success () {
109 + var compare = reverse ? 'rcompare' : 'compare'
110 + versions.sort(function (a, b) {
111 + return semver[compare](a, b, options)
112 + }).map(function (v) {
113 + return semver.clean(v, options)
114 + }).map(function (v) {
115 + return inc ? semver.inc(v, inc, options, identifier) : v
116 + }).forEach(function (v, i, _) { console.log(v) })
117 +}
118 +
119 +function help () {
120 + console.log(['SemVer ' + version,
121 + '',
122 + 'A JavaScript implementation of the https://semver.org/ specification',
123 + 'Copyright Isaac Z. Schlueter',
124 + '',
125 + 'Usage: semver [options] <version> [<version> [...]]',
126 + 'Prints valid versions sorted by SemVer precedence',
127 + '',
128 + 'Options:',
129 + '-r --range <range>',
130 + ' Print versions that match the specified range.',
131 + '',
132 + '-i --increment [<level>]',
133 + ' Increment a version by the specified level. Level can',
134 + ' be one of: major, minor, patch, premajor, preminor,',
135 + " prepatch, or prerelease. Default level is 'patch'.",
136 + ' Only one version may be specified.',
137 + '',
138 + '--preid <identifier>',
139 + ' Identifier to be used to prefix premajor, preminor,',
140 + ' prepatch or prerelease version increments.',
141 + '',
142 + '-l --loose',
143 + ' Interpret versions and ranges loosely',
144 + '',
145 + '-p --include-prerelease',
146 + ' Always include prerelease versions in range matching',
147 + '',
148 + '-c --coerce',
149 + ' Coerce a string into SemVer if possible',
150 + ' (does not imply --loose)',
151 + '',
152 + 'Program exits successfully if any valid version satisfies',
153 + 'all supplied ranges, and prints all satisfying versions.',
154 + '',
155 + 'If no satisfying versions are found, then exits failure.',
156 + '',
157 + 'Versions are printed in ascending order, so supplying',
158 + 'multiple versions to the utility will just sort them.'
159 + ].join('\n'))
160 +}
1 +#!/usr/bin/env node
2 +// -*- mode: js -*-
3 +// vim: set filetype=javascript :
4 +// Copyright 2018 Joyent, Inc. All rights reserved.
5 +
6 +var dashdash = require('dashdash');
7 +var sshpk = require('../lib/index');
8 +var fs = require('fs');
9 +var path = require('path');
10 +var tty = require('tty');
11 +var readline = require('readline');
12 +var getPassword = require('getpass').getPass;
13 +
14 +var options = [
15 + {
16 + names: ['outformat', 't'],
17 + type: 'string',
18 + help: 'Output format'
19 + },
20 + {
21 + names: ['informat', 'T'],
22 + type: 'string',
23 + help: 'Input format'
24 + },
25 + {
26 + names: ['file', 'f'],
27 + type: 'string',
28 + help: 'Input file name (default stdin)'
29 + },
30 + {
31 + names: ['out', 'o'],
32 + type: 'string',
33 + help: 'Output file name (default stdout)'
34 + },
35 + {
36 + names: ['private', 'p'],
37 + type: 'bool',
38 + help: 'Produce a private key as output'
39 + },
40 + {
41 + names: ['derive', 'd'],
42 + type: 'string',
43 + help: 'Output a new key derived from this one, with given algo'
44 + },
45 + {
46 + names: ['identify', 'i'],
47 + type: 'bool',
48 + help: 'Print key metadata instead of converting'
49 + },
50 + {
51 + names: ['fingerprint', 'F'],
52 + type: 'bool',
53 + help: 'Output key fingerprint'
54 + },
55 + {
56 + names: ['hash', 'H'],
57 + type: 'string',
58 + help: 'Hash function to use for key fingeprint with -F'
59 + },
60 + {
61 + names: ['spki', 's'],
62 + type: 'bool',
63 + help: 'With -F, generates an SPKI fingerprint instead of SSH'
64 + },
65 + {
66 + names: ['comment', 'c'],
67 + type: 'string',
68 + help: 'Set key comment, if output format supports'
69 + },
70 + {
71 + names: ['help', 'h'],
72 + type: 'bool',
73 + help: 'Shows this help text'
74 + }
75 +];
76 +
77 +if (require.main === module) {
78 + var parser = dashdash.createParser({
79 + options: options
80 + });
81 +
82 + try {
83 + var opts = parser.parse(process.argv);
84 + } catch (e) {
85 + console.error('sshpk-conv: error: %s', e.message);
86 + process.exit(1);
87 + }
88 +
89 + if (opts.help || opts._args.length > 1) {
90 + var help = parser.help({}).trimRight();
91 + console.error('sshpk-conv: converts between SSH key formats\n');
92 + console.error(help);
93 + console.error('\navailable key formats:');
94 + console.error(' - pem, pkcs1 eg id_rsa');
95 + console.error(' - ssh eg id_rsa.pub');
96 + console.error(' - pkcs8 format you want for openssl');
97 + console.error(' - openssh like output of ssh-keygen -o');
98 + console.error(' - rfc4253 raw OpenSSH wire format');
99 + console.error(' - dnssec dnssec-keygen format');
100 + console.error(' - putty PuTTY ppk format');
101 + console.error('\navailable fingerprint formats:');
102 + console.error(' - hex colon-separated hex for SSH');
103 + console.error(' straight hex for SPKI');
104 + console.error(' - base64 SHA256:* format from OpenSSH');
105 + process.exit(1);
106 + }
107 +
108 + /*
109 + * Key derivation can only be done on private keys, so use of the -d
110 + * option necessarily implies -p.
111 + */
112 + if (opts.derive)
113 + opts.private = true;
114 +
115 + var inFile = process.stdin;
116 + var inFileName = 'stdin';
117 +
118 + var inFilePath;
119 + if (opts.file) {
120 + inFilePath = opts.file;
121 + } else if (opts._args.length === 1) {
122 + inFilePath = opts._args[0];
123 + }
124 +
125 + if (inFilePath)
126 + inFileName = path.basename(inFilePath);
127 +
128 + try {
129 + if (inFilePath) {
130 + fs.accessSync(inFilePath, fs.R_OK);
131 + inFile = fs.createReadStream(inFilePath);
132 + }
133 + } catch (e) {
134 + ifError(e, 'error opening input file');
135 + }
136 +
137 + var outFile = process.stdout;
138 +
139 + try {
140 + if (opts.out && !opts.identify) {
141 + fs.accessSync(path.dirname(opts.out), fs.W_OK);
142 + outFile = fs.createWriteStream(opts.out);
143 + }
144 + } catch (e) {
145 + ifError(e, 'error opening output file');
146 + }
147 +
148 + var bufs = [];
149 + inFile.on('readable', function () {
150 + var data;
151 + while ((data = inFile.read()))
152 + bufs.push(data);
153 + });
154 + var parseOpts = {};
155 + parseOpts.filename = inFileName;
156 + inFile.on('end', function processKey() {
157 + var buf = Buffer.concat(bufs);
158 + var fmt = 'auto';
159 + if (opts.informat)
160 + fmt = opts.informat;
161 + var f = sshpk.parseKey;
162 + if (opts.private)
163 + f = sshpk.parsePrivateKey;
164 + try {
165 + var key = f(buf, fmt, parseOpts);
166 + } catch (e) {
167 + if (e.name === 'KeyEncryptedError') {
168 + getPassword(function (err, pw) {
169 + if (err)
170 + ifError(err);
171 + parseOpts.passphrase = pw;
172 + processKey();
173 + });
174 + return;
175 + }
176 + ifError(e);
177 + }
178 +
179 + if (opts.derive)
180 + key = key.derive(opts.derive);
181 +
182 + if (opts.comment)
183 + key.comment = opts.comment;
184 +
185 + if (opts.identify) {
186 + var kind = 'public';
187 + if (sshpk.PrivateKey.isPrivateKey(key))
188 + kind = 'private';
189 + console.log('%s: a %d bit %s %s key', inFileName,
190 + key.size, key.type.toUpperCase(), kind);
191 + if (key.type === 'ecdsa')
192 + console.log('ECDSA curve: %s', key.curve);
193 + if (key.comment)
194 + console.log('Comment: %s', key.comment);
195 + console.log('SHA256 fingerprint: ' +
196 + key.fingerprint('sha256').toString());
197 + console.log('MD5 fingerprint: ' +
198 + key.fingerprint('md5').toString());
199 + console.log('SPKI-SHA256 fingerprint: ' +
200 + key.fingerprint('sha256', 'spki').toString());
201 + process.exit(0);
202 + return;
203 + }
204 +
205 + if (opts.fingerprint) {
206 + var hash = opts.hash;
207 + var type = opts.spki ? 'spki' : 'ssh';
208 + var format = opts.outformat;
209 + var fp = key.fingerprint(hash, type).toString(format);
210 + outFile.write(fp);
211 + outFile.write('\n');
212 + outFile.once('drain', function () {
213 + process.exit(0);
214 + });
215 + return;
216 + }
217 +
218 + fmt = undefined;
219 + if (opts.outformat)
220 + fmt = opts.outformat;
221 + outFile.write(key.toBuffer(fmt));
222 + if (fmt === 'ssh' ||
223 + (!opts.private && fmt === undefined))
224 + outFile.write('\n');
225 + outFile.once('drain', function () {
226 + process.exit(0);
227 + });
228 + });
229 +}
230 +
231 +function ifError(e, txt) {
232 + if (txt)
233 + txt = txt + ': ';
234 + else
235 + txt = '';
236 + console.error('sshpk-conv: ' + txt + e.name + ': ' + e.message);
237 + if (process.env['DEBUG'] || process.env['V']) {
238 + console.error(e.stack);
239 + if (e.innerErr)
240 + console.error(e.innerErr.stack);
241 + }
242 + process.exit(1);
243 +}
1 +#!/usr/bin/env node
2 +// -*- mode: js -*-
3 +// vim: set filetype=javascript :
4 +// Copyright 2015 Joyent, Inc. All rights reserved.
5 +
6 +var dashdash = require('dashdash');
7 +var sshpk = require('../lib/index');
8 +var fs = require('fs');
9 +var path = require('path');
10 +var getPassword = require('getpass').getPass;
11 +
12 +var options = [
13 + {
14 + names: ['hash', 'H'],
15 + type: 'string',
16 + help: 'Hash algorithm (sha1, sha256, sha384, sha512)'
17 + },
18 + {
19 + names: ['verbose', 'v'],
20 + type: 'bool',
21 + help: 'Display verbose info about key and hash used'
22 + },
23 + {
24 + names: ['identity', 'i'],
25 + type: 'string',
26 + help: 'Path to key to use'
27 + },
28 + {
29 + names: ['file', 'f'],
30 + type: 'string',
31 + help: 'Input filename'
32 + },
33 + {
34 + names: ['out', 'o'],
35 + type: 'string',
36 + help: 'Output filename'
37 + },
38 + {
39 + names: ['format', 't'],
40 + type: 'string',
41 + help: 'Signature format (asn1, ssh, raw)'
42 + },
43 + {
44 + names: ['binary', 'b'],
45 + type: 'bool',
46 + help: 'Output raw binary instead of base64'
47 + },
48 + {
49 + names: ['help', 'h'],
50 + type: 'bool',
51 + help: 'Shows this help text'
52 + }
53 +];
54 +
55 +var parseOpts = {};
56 +
57 +if (require.main === module) {
58 + var parser = dashdash.createParser({
59 + options: options
60 + });
61 +
62 + try {
63 + var opts = parser.parse(process.argv);
64 + } catch (e) {
65 + console.error('sshpk-sign: error: %s', e.message);
66 + process.exit(1);
67 + }
68 +
69 + if (opts.help || opts._args.length > 1) {
70 + var help = parser.help({}).trimRight();
71 + console.error('sshpk-sign: sign data using an SSH key\n');
72 + console.error(help);
73 + process.exit(1);
74 + }
75 +
76 + if (!opts.identity) {
77 + var help = parser.help({}).trimRight();
78 + console.error('sshpk-sign: the -i or --identity option ' +
79 + 'is required\n');
80 + console.error(help);
81 + process.exit(1);
82 + }
83 +
84 + var keyData = fs.readFileSync(opts.identity);
85 + parseOpts.filename = opts.identity;
86 +
87 + run();
88 +}
89 +
90 +function run() {
91 + var key;
92 + try {
93 + key = sshpk.parsePrivateKey(keyData, 'auto', parseOpts);
94 + } catch (e) {
95 + if (e.name === 'KeyEncryptedError') {
96 + getPassword(function (err, pw) {
97 + parseOpts.passphrase = pw;
98 + run();
99 + });
100 + return;
101 + }
102 + console.error('sshpk-sign: error loading private key "' +
103 + opts.identity + '": ' + e.name + ': ' + e.message);
104 + process.exit(1);
105 + }
106 +
107 + var hash = opts.hash || key.defaultHashAlgorithm();
108 +
109 + var signer;
110 + try {
111 + signer = key.createSign(hash);
112 + } catch (e) {
113 + console.error('sshpk-sign: error creating signer: ' +
114 + e.name + ': ' + e.message);
115 + process.exit(1);
116 + }
117 +
118 + if (opts.verbose) {
119 + console.error('sshpk-sign: using %s-%s with a %d bit key',
120 + key.type, hash, key.size);
121 + }
122 +
123 + var inFile = process.stdin;
124 + var inFileName = 'stdin';
125 +
126 + var inFilePath;
127 + if (opts.file) {
128 + inFilePath = opts.file;
129 + } else if (opts._args.length === 1) {
130 + inFilePath = opts._args[0];
131 + }
132 +
133 + if (inFilePath)
134 + inFileName = path.basename(inFilePath);
135 +
136 + try {
137 + if (inFilePath) {
138 + fs.accessSync(inFilePath, fs.R_OK);
139 + inFile = fs.createReadStream(inFilePath);
140 + }
141 + } catch (e) {
142 + console.error('sshpk-sign: error opening input file' +
143 + ': ' + e.name + ': ' + e.message);
144 + process.exit(1);
145 + }
146 +
147 + var outFile = process.stdout;
148 +
149 + try {
150 + if (opts.out && !opts.identify) {
151 + fs.accessSync(path.dirname(opts.out), fs.W_OK);
152 + outFile = fs.createWriteStream(opts.out);
153 + }
154 + } catch (e) {
155 + console.error('sshpk-sign: error opening output file' +
156 + ': ' + e.name + ': ' + e.message);
157 + process.exit(1);
158 + }
159 +
160 + inFile.pipe(signer);
161 + inFile.on('end', function () {
162 + var sig;
163 + try {
164 + sig = signer.sign();
165 + } catch (e) {
166 + console.error('sshpk-sign: error signing data: ' +
167 + e.name + ': ' + e.message);
168 + process.exit(1);
169 + }
170 +
171 + var fmt = opts.format || 'asn1';
172 + var output;
173 + try {
174 + output = sig.toBuffer(fmt);
175 + if (!opts.binary)
176 + output = output.toString('base64');
177 + } catch (e) {
178 + console.error('sshpk-sign: error converting signature' +
179 + ' to ' + fmt + ' format: ' + e.name + ': ' +
180 + e.message);
181 + process.exit(1);
182 + }
183 +
184 + outFile.write(output);
185 + if (!opts.binary)
186 + outFile.write('\n');
187 + outFile.once('drain', function () {
188 + process.exit(0);
189 + });
190 + });
191 +}
1 +#!/usr/bin/env node
2 +// -*- mode: js -*-
3 +// vim: set filetype=javascript :
4 +// Copyright 2015 Joyent, Inc. All rights reserved.
5 +
6 +var dashdash = require('dashdash');
7 +var sshpk = require('../lib/index');
8 +var fs = require('fs');
9 +var path = require('path');
10 +var Buffer = require('safer-buffer').Buffer;
11 +
12 +var options = [
13 + {
14 + names: ['hash', 'H'],
15 + type: 'string',
16 + help: 'Hash algorithm (sha1, sha256, sha384, sha512)'
17 + },
18 + {
19 + names: ['verbose', 'v'],
20 + type: 'bool',
21 + help: 'Display verbose info about key and hash used'
22 + },
23 + {
24 + names: ['identity', 'i'],
25 + type: 'string',
26 + help: 'Path to (public) key to use'
27 + },
28 + {
29 + names: ['file', 'f'],
30 + type: 'string',
31 + help: 'Input filename'
32 + },
33 + {
34 + names: ['format', 't'],
35 + type: 'string',
36 + help: 'Signature format (asn1, ssh, raw)'
37 + },
38 + {
39 + names: ['signature', 's'],
40 + type: 'string',
41 + help: 'base64-encoded signature data'
42 + },
43 + {
44 + names: ['help', 'h'],
45 + type: 'bool',
46 + help: 'Shows this help text'
47 + }
48 +];
49 +
50 +if (require.main === module) {
51 + var parser = dashdash.createParser({
52 + options: options
53 + });
54 +
55 + try {
56 + var opts = parser.parse(process.argv);
57 + } catch (e) {
58 + console.error('sshpk-verify: error: %s', e.message);
59 + process.exit(3);
60 + }
61 +
62 + if (opts.help || opts._args.length > 1) {
63 + var help = parser.help({}).trimRight();
64 + console.error('sshpk-verify: sign data using an SSH key\n');
65 + console.error(help);
66 + process.exit(3);
67 + }
68 +
69 + if (!opts.identity) {
70 + var help = parser.help({}).trimRight();
71 + console.error('sshpk-verify: the -i or --identity option ' +
72 + 'is required\n');
73 + console.error(help);
74 + process.exit(3);
75 + }
76 +
77 + if (!opts.signature) {
78 + var help = parser.help({}).trimRight();
79 + console.error('sshpk-verify: the -s or --signature option ' +
80 + 'is required\n');
81 + console.error(help);
82 + process.exit(3);
83 + }
84 +
85 + var keyData = fs.readFileSync(opts.identity);
86 +
87 + var key;
88 + try {
89 + key = sshpk.parseKey(keyData);
90 + } catch (e) {
91 + console.error('sshpk-verify: error loading key "' +
92 + opts.identity + '": ' + e.name + ': ' + e.message);
93 + process.exit(2);
94 + }
95 +
96 + var fmt = opts.format || 'asn1';
97 + var sigData = Buffer.from(opts.signature, 'base64');
98 +
99 + var sig;
100 + try {
101 + sig = sshpk.parseSignature(sigData, key.type, fmt);
102 + } catch (e) {
103 + console.error('sshpk-verify: error parsing signature: ' +
104 + e.name + ': ' + e.message);
105 + process.exit(2);
106 + }
107 +
108 + var hash = opts.hash || key.defaultHashAlgorithm();
109 +
110 + var verifier;
111 + try {
112 + verifier = key.createVerify(hash);
113 + } catch (e) {
114 + console.error('sshpk-verify: error creating verifier: ' +
115 + e.name + ': ' + e.message);
116 + process.exit(2);
117 + }
118 +
119 + if (opts.verbose) {
120 + console.error('sshpk-verify: using %s-%s with a %d bit key',
121 + key.type, hash, key.size);
122 + }
123 +
124 + var inFile = process.stdin;
125 + var inFileName = 'stdin';
126 +
127 + var inFilePath;
128 + if (opts.file) {
129 + inFilePath = opts.file;
130 + } else if (opts._args.length === 1) {
131 + inFilePath = opts._args[0];
132 + }
133 +
134 + if (inFilePath)
135 + inFileName = path.basename(inFilePath);
136 +
137 + try {
138 + if (inFilePath) {
139 + fs.accessSync(inFilePath, fs.R_OK);
140 + inFile = fs.createReadStream(inFilePath);
141 + }
142 + } catch (e) {
143 + console.error('sshpk-verify: error opening input file' +
144 + ': ' + e.name + ': ' + e.message);
145 + process.exit(2);
146 + }
147 +
148 + inFile.pipe(verifier);
149 + inFile.on('end', function () {
150 + var ret;
151 + try {
152 + ret = verifier.verify(sig);
153 + } catch (e) {
154 + console.error('sshpk-verify: error verifying data: ' +
155 + e.name + ': ' + e.message);
156 + process.exit(1);
157 + }
158 +
159 + if (ret) {
160 + console.error('OK');
161 + process.exit(0);
162 + }
163 +
164 + console.error('NOT OK');
165 + process.exit(1);
166 + });
167 +}
1 +#!/usr/bin/env node
2 +var assert = require('assert');
3 +
4 +function usage() {
5 + console.log('Usage:');
6 + console.log(' uuid');
7 + console.log(' uuid v1');
8 + console.log(' uuid v3 <name> <namespace uuid>');
9 + console.log(' uuid v4');
10 + console.log(' uuid v5 <name> <namespace uuid>');
11 + console.log(' uuid --help');
12 + console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC4122');
13 +}
14 +
15 +var args = process.argv.slice(2);
16 +
17 +if (args.indexOf('--help') >= 0) {
18 + usage();
19 + process.exit(0);
20 +}
21 +var version = args.shift() || 'v4';
22 +
23 +switch (version) {
24 + case 'v1':
25 + var uuidV1 = require('../v1');
26 + console.log(uuidV1());
27 + break;
28 +
29 + case 'v3':
30 + var uuidV3 = require('../v3');
31 +
32 + var name = args.shift();
33 + var namespace = args.shift();
34 + assert(name != null, 'v3 name not specified');
35 + assert(namespace != null, 'v3 namespace not specified');
36 +
37 + if (namespace == 'URL') namespace = uuidV3.URL;
38 + if (namespace == 'DNS') namespace = uuidV3.DNS;
39 +
40 + console.log(uuidV3(name, namespace));
41 + break;
42 +
43 + case 'v4':
44 + var uuidV4 = require('../v4');
45 + console.log(uuidV4());
46 + break;
47 +
48 + case 'v5':
49 + var uuidV5 = require('../v5');
50 +
51 + var name = args.shift();
52 + var namespace = args.shift();
53 + assert(name != null, 'v5 name not specified');
54 + assert(namespace != null, 'v5 namespace not specified');
55 +
56 + if (namespace == 'URL') namespace = uuidV5.URL;
57 + if (namespace == 'DNS') namespace = uuidV5.DNS;
58 +
59 + console.log(uuidV5(name, namespace));
60 + break;
61 +
62 + default:
63 + usage();
64 + process.exit(1);
65 +}
1 +/// <reference types="node" />
2 +/// <reference lib="es2016" />
3 +/// <reference lib="es2017.sharedmemory" />
4 +/// <reference lib="esnext.asynciterable" />
5 +/// <reference lib="dom" />
6 +declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
7 +declare type Primitive = null | undefined | string | number | boolean | Symbol;
8 +export interface ArrayLike {
9 + length: number;
10 +}
11 +export interface Class<T = unknown> {
12 + new (...args: any[]): T;
13 +}
14 +declare type DomElement = object & {
15 + nodeType: 1;
16 + nodeName: string;
17 +};
18 +declare type NodeStream = object & {
19 + pipe: Function;
20 +};
21 +export declare const enum TypeName {
22 + null = "null",
23 + boolean = "boolean",
24 + undefined = "undefined",
25 + string = "string",
26 + number = "number",
27 + symbol = "symbol",
28 + Function = "Function",
29 + GeneratorFunction = "GeneratorFunction",
30 + AsyncFunction = "AsyncFunction",
31 + Observable = "Observable",
32 + Array = "Array",
33 + Buffer = "Buffer",
34 + Object = "Object",
35 + RegExp = "RegExp",
36 + Date = "Date",
37 + Error = "Error",
38 + Map = "Map",
39 + Set = "Set",
40 + WeakMap = "WeakMap",
41 + WeakSet = "WeakSet",
42 + Int8Array = "Int8Array",
43 + Uint8Array = "Uint8Array",
44 + Uint8ClampedArray = "Uint8ClampedArray",
45 + Int16Array = "Int16Array",
46 + Uint16Array = "Uint16Array",
47 + Int32Array = "Int32Array",
48 + Uint32Array = "Uint32Array",
49 + Float32Array = "Float32Array",
50 + Float64Array = "Float64Array",
51 + ArrayBuffer = "ArrayBuffer",
52 + SharedArrayBuffer = "SharedArrayBuffer",
53 + DataView = "DataView",
54 + Promise = "Promise",
55 + URL = "URL"
56 +}
57 +declare function is(value: unknown): TypeName;
58 +declare namespace is {
59 + const undefined: (value: unknown) => value is undefined;
60 + const string: (value: unknown) => value is string;
61 + const number: (value: unknown) => value is number;
62 + const function_: (value: unknown) => value is Function;
63 + const null_: (value: unknown) => value is null;
64 + const class_: (value: unknown) => value is Class<unknown>;
65 + const boolean: (value: unknown) => value is boolean;
66 + const symbol: (value: unknown) => value is Symbol;
67 + const numericString: (value: unknown) => boolean;
68 + const array: (arg: any) => arg is any[];
69 + const buffer: (input: unknown) => input is Buffer;
70 + const nullOrUndefined: (value: unknown) => value is null | undefined;
71 + const object: (value: unknown) => value is object;
72 + const iterable: (value: unknown) => value is IterableIterator<unknown>;
73 + const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
74 + const generator: (value: unknown) => value is Generator;
75 + const nativePromise: (value: unknown) => value is Promise<unknown>;
76 + const promise: (value: unknown) => value is Promise<unknown>;
77 + const generatorFunction: (value: unknown) => value is GeneratorFunction;
78 + const asyncFunction: (value: unknown) => value is Function;
79 + const boundFunction: (value: unknown) => value is Function;
80 + const regExp: (value: unknown) => value is RegExp;
81 + const date: (value: unknown) => value is Date;
82 + const error: (value: unknown) => value is Error;
83 + const map: (value: unknown) => value is Map<unknown, unknown>;
84 + const set: (value: unknown) => value is Set<unknown>;
85 + const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
86 + const weakSet: (value: unknown) => value is WeakSet<object>;
87 + const int8Array: (value: unknown) => value is Int8Array;
88 + const uint8Array: (value: unknown) => value is Uint8Array;
89 + const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
90 + const int16Array: (value: unknown) => value is Int16Array;
91 + const uint16Array: (value: unknown) => value is Uint16Array;
92 + const int32Array: (value: unknown) => value is Int32Array;
93 + const uint32Array: (value: unknown) => value is Uint32Array;
94 + const float32Array: (value: unknown) => value is Float32Array;
95 + const float64Array: (value: unknown) => value is Float64Array;
96 + const arrayBuffer: (value: unknown) => value is ArrayBuffer;
97 + const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
98 + const dataView: (value: unknown) => value is DataView;
99 + const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
100 + const urlInstance: (value: unknown) => value is URL;
101 + const urlString: (value: unknown) => boolean;
102 + const truthy: (value: unknown) => boolean;
103 + const falsy: (value: unknown) => boolean;
104 + const nan: (value: unknown) => boolean;
105 + const primitive: (value: unknown) => value is Primitive;
106 + const integer: (value: unknown) => value is number;
107 + const safeInteger: (value: unknown) => value is number;
108 + const plainObject: (value: unknown) => boolean;
109 + const typedArray: (value: unknown) => value is TypedArray;
110 + const arrayLike: (value: unknown) => value is ArrayLike;
111 + const inRange: (value: number, range: number | number[]) => boolean;
112 + const domElement: (value: unknown) => value is DomElement;
113 + const observable: (value: unknown) => boolean;
114 + const nodeStream: (value: unknown) => value is NodeStream;
115 + const infinite: (value: unknown) => boolean;
116 + const even: (value: number) => boolean;
117 + const odd: (value: number) => boolean;
118 + const emptyArray: (value: unknown) => boolean;
119 + const nonEmptyArray: (value: unknown) => boolean;
120 + const emptyString: (value: unknown) => boolean;
121 + const nonEmptyString: (value: unknown) => boolean;
122 + const emptyStringOrWhitespace: (value: unknown) => boolean;
123 + const emptyObject: (value: unknown) => boolean;
124 + const nonEmptyObject: (value: unknown) => boolean;
125 + const emptySet: (value: unknown) => boolean;
126 + const nonEmptySet: (value: unknown) => boolean;
127 + const emptyMap: (value: unknown) => boolean;
128 + const nonEmptyMap: (value: unknown) => boolean;
129 + const any: (predicate: unknown, ...values: unknown[]) => boolean;
130 + const all: (predicate: unknown, ...values: unknown[]) => boolean;
131 +}
132 +export default is;
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +{
2 + "_from": "@sindresorhus/is@^0.14.0",
3 + "_id": "@sindresorhus/is@0.14.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==",
6 + "_location": "/@sindresorhus/is",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@sindresorhus/is@^0.14.0",
12 + "name": "@sindresorhus/is",
13 + "escapedName": "@sindresorhus%2fis",
14 + "scope": "@sindresorhus",
15 + "rawSpec": "^0.14.0",
16 + "saveSpec": null,
17 + "fetchSpec": "^0.14.0"
18 + },
19 + "_requiredBy": [
20 + "/got"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
23 + "_shasum": "9fb3a3cf3132328151f353de4632e01e52102bea",
24 + "_spec": "@sindresorhus/is@^0.14.0",
25 + "_where": "/home/ubuntu/incorrect-note/node_modules/got",
26 + "author": {
27 + "name": "Sindre Sorhus",
28 + "email": "sindresorhus@gmail.com",
29 + "url": "sindresorhus.com"
30 + },
31 + "bugs": {
32 + "url": "https://github.com/sindresorhus/is/issues"
33 + },
34 + "bundleDependencies": false,
35 + "deprecated": false,
36 + "description": "Type check values: `is.string('🦄') //=> true`",
37 + "devDependencies": {
38 + "@sindresorhus/tsconfig": "^0.1.0",
39 + "@types/jsdom": "^11.12.0",
40 + "@types/node": "^10.12.10",
41 + "@types/tempy": "^0.2.0",
42 + "@types/zen-observable": "^0.8.0",
43 + "ava": "^0.25.0",
44 + "del-cli": "^1.1.0",
45 + "jsdom": "^11.6.2",
46 + "rxjs": "^6.3.3",
47 + "tempy": "^0.2.1",
48 + "tslint": "^5.9.1",
49 + "tslint-xo": "^0.10.0",
50 + "typescript": "^3.2.1",
51 + "zen-observable": "^0.8.8"
52 + },
53 + "engines": {
54 + "node": ">=6"
55 + },
56 + "files": [
57 + "dist"
58 + ],
59 + "homepage": "https://github.com/sindresorhus/is#readme",
60 + "keywords": [
61 + "type",
62 + "types",
63 + "is",
64 + "check",
65 + "checking",
66 + "validate",
67 + "validation",
68 + "utility",
69 + "util",
70 + "typeof",
71 + "instanceof",
72 + "object",
73 + "assert",
74 + "assertion",
75 + "test",
76 + "kind",
77 + "primitive",
78 + "verify",
79 + "compare"
80 + ],
81 + "license": "MIT",
82 + "main": "dist/index.js",
83 + "name": "@sindresorhus/is",
84 + "repository": {
85 + "type": "git",
86 + "url": "git+https://github.com/sindresorhus/is.git"
87 + },
88 + "scripts": {
89 + "build": "del dist && tsc",
90 + "lint": "tslint --format stylish --project .",
91 + "prepublish": "npm run build && del dist/tests",
92 + "test": "npm run lint && npm run build && ava dist/tests"
93 + },
94 + "types": "dist/index.d.ts",
95 + "version": "0.14.0"
96 +}
This diff is collapsed. Click to expand it.
1 +MIT License
2 +
3 +Copyright (c) 2018 Szymon Marczak
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +# http-timer
2 +> Timings for HTTP requests
3 +
4 +[![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)
5 +[![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)
6 +[![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
7 +
8 +Inspired by the [`request` package](https://github.com/request/request).
9 +
10 +## Usage
11 +```js
12 +'use strict';
13 +const https = require('https');
14 +const timer = require('@szmarczak/http-timer');
15 +
16 +const request = https.get('https://httpbin.org/anything');
17 +const timings = timer(request);
18 +
19 +request.on('response', response => {
20 + response.on('data', () => {}); // Consume the data somehow
21 + response.on('end', () => {
22 + console.log(timings);
23 + });
24 +});
25 +
26 +// { start: 1535708511443,
27 +// socket: 1535708511444,
28 +// lookup: 1535708511444,
29 +// connect: 1535708511582,
30 +// upload: 1535708511887,
31 +// response: 1535708512037,
32 +// end: 1535708512040,
33 +// phases:
34 +// { wait: 1,
35 +// dns: 0,
36 +// tcp: 138,
37 +// request: 305,
38 +// firstByte: 150,
39 +// download: 3,
40 +// total: 597 } }
41 +```
42 +
43 +## API
44 +
45 +### timer(request)
46 +
47 +Returns: `Object`
48 +
49 +- `start` - Time when the request started.
50 +- `socket` - Time when a socket was assigned to the request.
51 +- `lookup` - Time when the DNS lookup finished.
52 +- `connect` - Time when the socket successfully connected.
53 +- `upload` - Time when the request finished uploading.
54 +- `response` - Time when the request fired the `response` event.
55 +- `end` - Time when the response fired the `end` event.
56 +- `error` - Time when the request fired the `error` event.
57 +- `phases`
58 + - `wait` - `timings.socket - timings.start`
59 + - `dns` - `timings.lookup - timings.socket`
60 + - `tcp` - `timings.connect - timings.lookup`
61 + - `request` - `timings.upload - timings.connect`
62 + - `firstByte` - `timings.response - timings.upload`
63 + - `download` - `timings.end - timings.response`
64 + - `total` - `timings.end - timings.start` or `timings.error - timings.start`
65 +
66 +**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
67 +
68 +## License
69 +
70 +MIT
1 +{
2 + "_from": "@szmarczak/http-timer@^1.1.2",
3 + "_id": "@szmarczak/http-timer@1.1.2",
4 + "_inBundle": false,
5 + "_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==",
6 + "_location": "/@szmarczak/http-timer",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@szmarczak/http-timer@^1.1.2",
12 + "name": "@szmarczak/http-timer",
13 + "escapedName": "@szmarczak%2fhttp-timer",
14 + "scope": "@szmarczak",
15 + "rawSpec": "^1.1.2",
16 + "saveSpec": null,
17 + "fetchSpec": "^1.1.2"
18 + },
19 + "_requiredBy": [
20 + "/got"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
23 + "_shasum": "b1665e2c461a2cd92f4c1bbf50d5454de0d4b421",
24 + "_spec": "@szmarczak/http-timer@^1.1.2",
25 + "_where": "/home/ubuntu/incorrect-note/node_modules/got",
26 + "author": {
27 + "name": "Szymon Marczak"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/szmarczak/http-timer/issues"
31 + },
32 + "bundleDependencies": false,
33 + "dependencies": {
34 + "defer-to-connect": "^1.0.1"
35 + },
36 + "deprecated": false,
37 + "description": "Timings for HTTP requests",
38 + "devDependencies": {
39 + "ava": "^0.25.0",
40 + "coveralls": "^3.0.2",
41 + "nyc": "^12.0.2",
42 + "p-event": "^2.1.0",
43 + "xo": "^0.22.0"
44 + },
45 + "engines": {
46 + "node": ">=6"
47 + },
48 + "files": [
49 + "source"
50 + ],
51 + "homepage": "https://github.com/szmarczak/http-timer#readme",
52 + "keywords": [
53 + "http",
54 + "https",
55 + "timer",
56 + "timings"
57 + ],
58 + "license": "MIT",
59 + "main": "source",
60 + "name": "@szmarczak/http-timer",
61 + "repository": {
62 + "type": "git",
63 + "url": "git+https://github.com/szmarczak/http-timer.git"
64 + },
65 + "scripts": {
66 + "coveralls": "nyc report --reporter=text-lcov | coveralls",
67 + "test": "xo && nyc ava"
68 + },
69 + "version": "1.1.2",
70 + "xo": {
71 + "rules": {
72 + "unicorn/filename-case": "camelCase"
73 + }
74 + }
75 +}
1 +'use strict';
2 +const deferToConnect = require('defer-to-connect');
3 +
4 +module.exports = request => {
5 + const timings = {
6 + start: Date.now(),
7 + socket: null,
8 + lookup: null,
9 + connect: null,
10 + upload: null,
11 + response: null,
12 + end: null,
13 + error: null,
14 + phases: {
15 + wait: null,
16 + dns: null,
17 + tcp: null,
18 + request: null,
19 + firstByte: null,
20 + download: null,
21 + total: null
22 + }
23 + };
24 +
25 + const handleError = origin => {
26 + const emit = origin.emit.bind(origin);
27 + origin.emit = (event, ...args) => {
28 + // Catches the `error` event
29 + if (event === 'error') {
30 + timings.error = Date.now();
31 + timings.phases.total = timings.error - timings.start;
32 +
33 + origin.emit = emit;
34 + }
35 +
36 + // Saves the original behavior
37 + return emit(event, ...args);
38 + };
39 + };
40 +
41 + let uploadFinished = false;
42 + const onUpload = () => {
43 + timings.upload = Date.now();
44 + timings.phases.request = timings.upload - timings.connect;
45 + };
46 +
47 + handleError(request);
48 +
49 + request.once('socket', socket => {
50 + timings.socket = Date.now();
51 + timings.phases.wait = timings.socket - timings.start;
52 +
53 + const lookupListener = () => {
54 + timings.lookup = Date.now();
55 + timings.phases.dns = timings.lookup - timings.socket;
56 + };
57 +
58 + socket.once('lookup', lookupListener);
59 +
60 + deferToConnect(socket, () => {
61 + timings.connect = Date.now();
62 +
63 + if (timings.lookup === null) {
64 + socket.removeListener('lookup', lookupListener);
65 + timings.lookup = timings.connect;
66 + timings.phases.dns = timings.lookup - timings.socket;
67 + }
68 +
69 + timings.phases.tcp = timings.connect - timings.lookup;
70 +
71 + if (uploadFinished && !timings.upload) {
72 + onUpload();
73 + }
74 + });
75 + });
76 +
77 + request.once('finish', () => {
78 + uploadFinished = true;
79 +
80 + if (timings.connect) {
81 + onUpload();
82 + }
83 + });
84 +
85 + request.once('response', response => {
86 + timings.response = Date.now();
87 + timings.phases.firstByte = timings.response - timings.upload;
88 +
89 + handleError(response);
90 +
91 + response.once('end', () => {
92 + timings.end = Date.now();
93 + timings.phases.download = timings.end - timings.response;
94 + timings.phases.total = timings.end - timings.start;
95 + });
96 + });
97 +
98 + return timings;
99 +};
1 + MIT License
2 +
3 + Copyright (c) Microsoft Corporation. All rights reserved.
4 +
5 + Permission is hereby granted, free of charge, to any person obtaining a copy
6 + of this software and associated documentation files (the "Software"), to deal
7 + in the Software without restriction, including without limitation the rights
8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 + copies of the Software, and to permit persons to whom the Software is
10 + furnished to do so, subject to the following conditions:
11 +
12 + The above copyright notice and this permission notice shall be included in all
13 + copies or substantial portions of the Software.
14 +
15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 + SOFTWARE
1 +# Installation
2 +> `npm install --save @types/color-name`
3 +
4 +# Summary
5 +This package contains type definitions for color-name ( https://github.com/colorjs/color-name ).
6 +
7 +# Details
8 +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/color-name
9 +
10 +Additional Details
11 + * Last updated: Wed, 13 Feb 2019 16:16:48 GMT
12 + * Dependencies: none
13 + * Global values: none
14 +
15 +# Credits
16 +These definitions were written by Junyoung Clare Jang <https://github.com/Ailrun>.
1 +// Type definitions for color-name 1.1
2 +// Project: https://github.com/colorjs/color-name
3 +// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
4 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5 +
6 +/**
7 + * Tuple of Red, Green, and Blue
8 + * @example
9 + * // Red = 55, Green = 70, Blue = 0
10 + * const rgb: RGB = [55, 70, 0];
11 + */
12 +export type RGB = [number, number, number];
13 +
14 +export const aliceblue: RGB;
15 +export const antiquewhite: RGB;
16 +export const aqua: RGB;
17 +export const aquamarine: RGB;
18 +export const azure: RGB;
19 +export const beige: RGB;
20 +export const bisque: RGB;
21 +export const black: RGB;
22 +export const blanchedalmond: RGB;
23 +export const blue: RGB;
24 +export const blueviolet: RGB;
25 +export const brown: RGB;
26 +export const burlywood: RGB;
27 +export const cadetblue: RGB;
28 +export const chartreuse: RGB;
29 +export const chocolate: RGB;
30 +export const coral: RGB;
31 +export const cornflowerblue: RGB;
32 +export const cornsilk: RGB;
33 +export const crimson: RGB;
34 +export const cyan: RGB;
35 +export const darkblue: RGB;
36 +export const darkcyan: RGB;
37 +export const darkgoldenrod: RGB;
38 +export const darkgray: RGB;
39 +export const darkgreen: RGB;
40 +export const darkgrey: RGB;
41 +export const darkkhaki: RGB;
42 +export const darkmagenta: RGB;
43 +export const darkolivegreen: RGB;
44 +export const darkorange: RGB;
45 +export const darkorchid: RGB;
46 +export const darkred: RGB;
47 +export const darksalmon: RGB;
48 +export const darkseagreen: RGB;
49 +export const darkslateblue: RGB;
50 +export const darkslategray: RGB;
51 +export const darkslategrey: RGB;
52 +export const darkturquoise: RGB;
53 +export const darkviolet: RGB;
54 +export const deeppink: RGB;
55 +export const deepskyblue: RGB;
56 +export const dimgray: RGB;
57 +export const dimgrey: RGB;
58 +export const dodgerblue: RGB;
59 +export const firebrick: RGB;
60 +export const floralwhite: RGB;
61 +export const forestgreen: RGB;
62 +export const fuchsia: RGB;
63 +export const gainsboro: RGB;
64 +export const ghostwhite: RGB;
65 +export const gold: RGB;
66 +export const goldenrod: RGB;
67 +export const gray: RGB;
68 +export const green: RGB;
69 +export const greenyellow: RGB;
70 +export const grey: RGB;
71 +export const honeydew: RGB;
72 +export const hotpink: RGB;
73 +export const indianred: RGB;
74 +export const indigo: RGB;
75 +export const ivory: RGB;
76 +export const khaki: RGB;
77 +export const lavender: RGB;
78 +export const lavenderblush: RGB;
79 +export const lawngreen: RGB;
80 +export const lemonchiffon: RGB;
81 +export const lightblue: RGB;
82 +export const lightcoral: RGB;
83 +export const lightcyan: RGB;
84 +export const lightgoldenrodyellow: RGB;
85 +export const lightgray: RGB;
86 +export const lightgreen: RGB;
87 +export const lightgrey: RGB;
88 +export const lightpink: RGB;
89 +export const lightsalmon: RGB;
90 +export const lightseagreen: RGB;
91 +export const lightskyblue: RGB;
92 +export const lightslategray: RGB;
93 +export const lightslategrey: RGB;
94 +export const lightsteelblue: RGB;
95 +export const lightyellow: RGB;
96 +export const lime: RGB;
97 +export const limegreen: RGB;
98 +export const linen: RGB;
99 +export const magenta: RGB;
100 +export const maroon: RGB;
101 +export const mediumaquamarine: RGB;
102 +export const mediumblue: RGB;
103 +export const mediumorchid: RGB;
104 +export const mediumpurple: RGB;
105 +export const mediumseagreen: RGB;
106 +export const mediumslateblue: RGB;
107 +export const mediumspringgreen: RGB;
108 +export const mediumturquoise: RGB;
109 +export const mediumvioletred: RGB;
110 +export const midnightblue: RGB;
111 +export const mintcream: RGB;
112 +export const mistyrose: RGB;
113 +export const moccasin: RGB;
114 +export const navajowhite: RGB;
115 +export const navy: RGB;
116 +export const oldlace: RGB;
117 +export const olive: RGB;
118 +export const olivedrab: RGB;
119 +export const orange: RGB;
120 +export const orangered: RGB;
121 +export const orchid: RGB;
122 +export const palegoldenrod: RGB;
123 +export const palegreen: RGB;
124 +export const paleturquoise: RGB;
125 +export const palevioletred: RGB;
126 +export const papayawhip: RGB;
127 +export const peachpuff: RGB;
128 +export const peru: RGB;
129 +export const pink: RGB;
130 +export const plum: RGB;
131 +export const powderblue: RGB;
132 +export const purple: RGB;
133 +export const rebeccapurple: RGB;
134 +export const red: RGB;
135 +export const rosybrown: RGB;
136 +export const royalblue: RGB;
137 +export const saddlebrown: RGB;
138 +export const salmon: RGB;
139 +export const sandybrown: RGB;
140 +export const seagreen: RGB;
141 +export const seashell: RGB;
142 +export const sienna: RGB;
143 +export const silver: RGB;
144 +export const skyblue: RGB;
145 +export const slateblue: RGB;
146 +export const slategray: RGB;
147 +export const slategrey: RGB;
148 +export const snow: RGB;
149 +export const springgreen: RGB;
150 +export const steelblue: RGB;
151 +export const tan: RGB;
152 +export const teal: RGB;
153 +export const thistle: RGB;
154 +export const tomato: RGB;
155 +export const turquoise: RGB;
156 +export const violet: RGB;
157 +export const wheat: RGB;
158 +export const white: RGB;
159 +export const whitesmoke: RGB;
160 +export const yellow: RGB;
161 +export const yellowgreen: RGB;
1 +{
2 + "_from": "@types/color-name@^1.1.1",
3 + "_id": "@types/color-name@1.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
6 + "_location": "/@types/color-name",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@types/color-name@^1.1.1",
12 + "name": "@types/color-name",
13 + "escapedName": "@types%2fcolor-name",
14 + "scope": "@types",
15 + "rawSpec": "^1.1.1",
16 + "saveSpec": null,
17 + "fetchSpec": "^1.1.1"
18 + },
19 + "_requiredBy": [
20 + "/boxen/ansi-styles",
21 + "/update-notifier/ansi-styles"
22 + ],
23 + "_resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
24 + "_shasum": "1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0",
25 + "_spec": "@types/color-name@^1.1.1",
26 + "_where": "/home/ubuntu/incorrect-note/node_modules/boxen/node_modules/ansi-styles",
27 + "bugs": {
28 + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
29 + },
30 + "bundleDependencies": false,
31 + "contributors": [
32 + {
33 + "name": "Junyoung Clare Jang",
34 + "url": "https://github.com/Ailrun"
35 + }
36 + ],
37 + "dependencies": {},
38 + "deprecated": false,
39 + "description": "TypeScript definitions for color-name",
40 + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
41 + "license": "MIT",
42 + "main": "",
43 + "name": "@types/color-name",
44 + "repository": {
45 + "type": "git",
46 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
47 + },
48 + "scripts": {},
49 + "typeScriptVersion": "2.0",
50 + "types": "index",
51 + "typesPublisherContentHash": "e22c6881e2dcf766e32142cbb82d9acf9c08258bdf0da8e76c8a448d1be44ac7",
52 + "version": "1.1.1"
53 +}
1 +This software is dual-licensed under the ISC and MIT licenses.
2 +You may use this software under EITHER of the following licenses.
3 +
4 +----------
5 +
6 +The ISC License
7 +
8 +Copyright (c) Isaac Z. Schlueter and Contributors
9 +
10 +Permission to use, copy, modify, and/or distribute this software for any
11 +purpose with or without fee is hereby granted, provided that the above
12 +copyright notice and this permission notice appear in all copies.
13 +
14 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
20 +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 +
22 +----------
23 +
24 +Copyright Isaac Z. Schlueter and Contributors
25 +All rights reserved.
26 +
27 +Permission is hereby granted, free of charge, to any person
28 +obtaining a copy of this software and associated documentation
29 +files (the "Software"), to deal in the Software without
30 +restriction, including without limitation the rights to use,
31 +copy, modify, merge, publish, distribute, sublicense, and/or sell
32 +copies of the Software, and to permit persons to whom the
33 +Software is furnished to do so, subject to the following
34 +conditions:
35 +
36 +The above copyright notice and this permission notice shall be
37 +included in all copies or substantial portions of the Software.
38 +
39 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
41 +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
43 +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
44 +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
45 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
46 +OTHER DEALINGS IN THE SOFTWARE.
1 +# abbrev-js
2 +
3 +Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).
4 +
5 +Usage:
6 +
7 + var abbrev = require("abbrev");
8 + abbrev("foo", "fool", "folding", "flop");
9 +
10 + // returns:
11 + { fl: 'flop'
12 + , flo: 'flop'
13 + , flop: 'flop'
14 + , fol: 'folding'
15 + , fold: 'folding'
16 + , foldi: 'folding'
17 + , foldin: 'folding'
18 + , folding: 'folding'
19 + , foo: 'foo'
20 + , fool: 'fool'
21 + }
22 +
23 +This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.
1 +module.exports = exports = abbrev.abbrev = abbrev
2 +
3 +abbrev.monkeyPatch = monkeyPatch
4 +
5 +function monkeyPatch () {
6 + Object.defineProperty(Array.prototype, 'abbrev', {
7 + value: function () { return abbrev(this) },
8 + enumerable: false, configurable: true, writable: true
9 + })
10 +
11 + Object.defineProperty(Object.prototype, 'abbrev', {
12 + value: function () { return abbrev(Object.keys(this)) },
13 + enumerable: false, configurable: true, writable: true
14 + })
15 +}
16 +
17 +function abbrev (list) {
18 + if (arguments.length !== 1 || !Array.isArray(list)) {
19 + list = Array.prototype.slice.call(arguments, 0)
20 + }
21 + for (var i = 0, l = list.length, args = [] ; i < l ; i ++) {
22 + args[i] = typeof list[i] === "string" ? list[i] : String(list[i])
23 + }
24 +
25 + // sort them lexicographically, so that they're next to their nearest kin
26 + args = args.sort(lexSort)
27 +
28 + // walk through each, seeing how much it has in common with the next and previous
29 + var abbrevs = {}
30 + , prev = ""
31 + for (var i = 0, l = args.length ; i < l ; i ++) {
32 + var current = args[i]
33 + , next = args[i + 1] || ""
34 + , nextMatches = true
35 + , prevMatches = true
36 + if (current === next) continue
37 + for (var j = 0, cl = current.length ; j < cl ; j ++) {
38 + var curChar = current.charAt(j)
39 + nextMatches = nextMatches && curChar === next.charAt(j)
40 + prevMatches = prevMatches && curChar === prev.charAt(j)
41 + if (!nextMatches && !prevMatches) {
42 + j ++
43 + break
44 + }
45 + }
46 + prev = current
47 + if (j === cl) {
48 + abbrevs[current] = current
49 + continue
50 + }
51 + for (var a = current.substr(0, j) ; j <= cl ; j ++) {
52 + abbrevs[a] = current
53 + a += current.charAt(j)
54 + }
55 + }
56 + return abbrevs
57 +}
58 +
59 +function lexSort (a, b) {
60 + return a === b ? 0 : a > b ? 1 : -1
61 +}
1 +{
2 + "_from": "abbrev@1",
3 + "_id": "abbrev@1.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
6 + "_location": "/abbrev",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "abbrev@1",
12 + "name": "abbrev",
13 + "escapedName": "abbrev",
14 + "rawSpec": "1",
15 + "saveSpec": null,
16 + "fetchSpec": "1"
17 + },
18 + "_requiredBy": [
19 + "/nopt"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
22 + "_shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8",
23 + "_spec": "abbrev@1",
24 + "_where": "/home/ubuntu/incorrect-note/node_modules/nopt",
25 + "author": {
26 + "name": "Isaac Z. Schlueter",
27 + "email": "i@izs.me"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/isaacs/abbrev-js/issues"
31 + },
32 + "bundleDependencies": false,
33 + "deprecated": false,
34 + "description": "Like ruby's abbrev module, but in js",
35 + "devDependencies": {
36 + "tap": "^10.1"
37 + },
38 + "files": [
39 + "abbrev.js"
40 + ],
41 + "homepage": "https://github.com/isaacs/abbrev-js#readme",
42 + "license": "ISC",
43 + "main": "abbrev.js",
44 + "name": "abbrev",
45 + "repository": {
46 + "type": "git",
47 + "url": "git+ssh://git@github.com/isaacs/abbrev-js.git"
48 + },
49 + "scripts": {
50 + "postpublish": "git push origin --all; git push origin --tags",
51 + "postversion": "npm publish",
52 + "preversion": "npm test",
53 + "test": "tap test.js --100"
54 + },
55 + "version": "1.1.1"
56 +}
1 +1.3.7 / 2019-04-29
2 +==================
3 +
4 + * deps: negotiator@0.6.2
5 + - Fix sorting charset, encoding, and language with extra parameters
6 +
7 +1.3.6 / 2019-04-28
8 +==================
9 +
10 + * deps: mime-types@~2.1.24
11 + - deps: mime-db@~1.40.0
12 +
13 +1.3.5 / 2018-02-28
14 +==================
15 +
16 + * deps: mime-types@~2.1.18
17 + - deps: mime-db@~1.33.0
18 +
19 +1.3.4 / 2017-08-22
20 +==================
21 +
22 + * deps: mime-types@~2.1.16
23 + - deps: mime-db@~1.29.0
24 +
25 +1.3.3 / 2016-05-02
26 +==================
27 +
28 + * deps: mime-types@~2.1.11
29 + - deps: mime-db@~1.23.0
30 + * deps: negotiator@0.6.1
31 + - perf: improve `Accept` parsing speed
32 + - perf: improve `Accept-Charset` parsing speed
33 + - perf: improve `Accept-Encoding` parsing speed
34 + - perf: improve `Accept-Language` parsing speed
35 +
36 +1.3.2 / 2016-03-08
37 +==================
38 +
39 + * deps: mime-types@~2.1.10
40 + - Fix extension of `application/dash+xml`
41 + - Update primary extension for `audio/mp4`
42 + - deps: mime-db@~1.22.0
43 +
44 +1.3.1 / 2016-01-19
45 +==================
46 +
47 + * deps: mime-types@~2.1.9
48 + - deps: mime-db@~1.21.0
49 +
50 +1.3.0 / 2015-09-29
51 +==================
52 +
53 + * deps: mime-types@~2.1.7
54 + - deps: mime-db@~1.19.0
55 + * deps: negotiator@0.6.0
56 + - Fix including type extensions in parameters in `Accept` parsing
57 + - Fix parsing `Accept` parameters with quoted equals
58 + - Fix parsing `Accept` parameters with quoted semicolons
59 + - Lazy-load modules from main entry point
60 + - perf: delay type concatenation until needed
61 + - perf: enable strict mode
62 + - perf: hoist regular expressions
63 + - perf: remove closures getting spec properties
64 + - perf: remove a closure from media type parsing
65 + - perf: remove property delete from media type parsing
66 +
67 +1.2.13 / 2015-09-06
68 +===================
69 +
70 + * deps: mime-types@~2.1.6
71 + - deps: mime-db@~1.18.0
72 +
73 +1.2.12 / 2015-07-30
74 +===================
75 +
76 + * deps: mime-types@~2.1.4
77 + - deps: mime-db@~1.16.0
78 +
79 +1.2.11 / 2015-07-16
80 +===================
81 +
82 + * deps: mime-types@~2.1.3
83 + - deps: mime-db@~1.15.0
84 +
85 +1.2.10 / 2015-07-01
86 +===================
87 +
88 + * deps: mime-types@~2.1.2
89 + - deps: mime-db@~1.14.0
90 +
91 +1.2.9 / 2015-06-08
92 +==================
93 +
94 + * deps: mime-types@~2.1.1
95 + - perf: fix deopt during mapping
96 +
97 +1.2.8 / 2015-06-07
98 +==================
99 +
100 + * deps: mime-types@~2.1.0
101 + - deps: mime-db@~1.13.0
102 + * perf: avoid argument reassignment & argument slice
103 + * perf: avoid negotiator recursive construction
104 + * perf: enable strict mode
105 + * perf: remove unnecessary bitwise operator
106 +
107 +1.2.7 / 2015-05-10
108 +==================
109 +
110 + * deps: negotiator@0.5.3
111 + - Fix media type parameter matching to be case-insensitive
112 +
113 +1.2.6 / 2015-05-07
114 +==================
115 +
116 + * deps: mime-types@~2.0.11
117 + - deps: mime-db@~1.9.1
118 + * deps: negotiator@0.5.2
119 + - Fix comparing media types with quoted values
120 + - Fix splitting media types with quoted commas
121 +
122 +1.2.5 / 2015-03-13
123 +==================
124 +
125 + * deps: mime-types@~2.0.10
126 + - deps: mime-db@~1.8.0
127 +
128 +1.2.4 / 2015-02-14
129 +==================
130 +
131 + * Support Node.js 0.6
132 + * deps: mime-types@~2.0.9
133 + - deps: mime-db@~1.7.0
134 + * deps: negotiator@0.5.1
135 + - Fix preference sorting to be stable for long acceptable lists
136 +
137 +1.2.3 / 2015-01-31
138 +==================
139 +
140 + * deps: mime-types@~2.0.8
141 + - deps: mime-db@~1.6.0
142 +
143 +1.2.2 / 2014-12-30
144 +==================
145 +
146 + * deps: mime-types@~2.0.7
147 + - deps: mime-db@~1.5.0
148 +
149 +1.2.1 / 2014-12-30
150 +==================
151 +
152 + * deps: mime-types@~2.0.5
153 + - deps: mime-db@~1.3.1
154 +
155 +1.2.0 / 2014-12-19
156 +==================
157 +
158 + * deps: negotiator@0.5.0
159 + - Fix list return order when large accepted list
160 + - Fix missing identity encoding when q=0 exists
161 + - Remove dynamic building of Negotiator class
162 +
163 +1.1.4 / 2014-12-10
164 +==================
165 +
166 + * deps: mime-types@~2.0.4
167 + - deps: mime-db@~1.3.0
168 +
169 +1.1.3 / 2014-11-09
170 +==================
171 +
172 + * deps: mime-types@~2.0.3
173 + - deps: mime-db@~1.2.0
174 +
175 +1.1.2 / 2014-10-14
176 +==================
177 +
178 + * deps: negotiator@0.4.9
179 + - Fix error when media type has invalid parameter
180 +
181 +1.1.1 / 2014-09-28
182 +==================
183 +
184 + * deps: mime-types@~2.0.2
185 + - deps: mime-db@~1.1.0
186 + * deps: negotiator@0.4.8
187 + - Fix all negotiations to be case-insensitive
188 + - Stable sort preferences of same quality according to client order
189 +
190 +1.1.0 / 2014-09-02
191 +==================
192 +
193 + * update `mime-types`
194 +
195 +1.0.7 / 2014-07-04
196 +==================
197 +
198 + * Fix wrong type returned from `type` when match after unknown extension
199 +
200 +1.0.6 / 2014-06-24
201 +==================
202 +
203 + * deps: negotiator@0.4.7
204 +
205 +1.0.5 / 2014-06-20
206 +==================
207 +
208 + * fix crash when unknown extension given
209 +
210 +1.0.4 / 2014-06-19
211 +==================
212 +
213 + * use `mime-types`
214 +
215 +1.0.3 / 2014-06-11
216 +==================
217 +
218 + * deps: negotiator@0.4.6
219 + - Order by specificity when quality is the same
220 +
221 +1.0.2 / 2014-05-29
222 +==================
223 +
224 + * Fix interpretation when header not in request
225 + * deps: pin negotiator@0.4.5
226 +
227 +1.0.1 / 2014-01-18
228 +==================
229 +
230 + * Identity encoding isn't always acceptable
231 + * deps: negotiator@~0.4.0
232 +
233 +1.0.0 / 2013-12-27
234 +==================
235 +
236 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
135 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
136 +[node-version-image]: https://badgen.net/npm/node/accepts
137 +[node-version-url]: https://nodejs.org/en/download
138 +[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 +[npm-url]: https://npmjs.org/package/accepts
140 +[npm-version-image]: https://badgen.net/npm/v/accepts
141 +[travis-image]: https://badgen.net/travis/jshttp/accepts/master
142 +[travis-url]: https://travis-ci.org/jshttp/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "_from": "accepts@~1.3.7",
3 + "_id": "accepts@1.3.7",
4 + "_inBundle": false,
5 + "_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
6 + "_location": "/accepts",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "accepts@~1.3.7",
12 + "name": "accepts",
13 + "escapedName": "accepts",
14 + "rawSpec": "~1.3.7",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.3.7"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
22 + "_shasum": "531bc726517a3b2b41f850021c6cc15eaab507cd",
23 + "_spec": "accepts@~1.3.7",
24 + "_where": "/home/ubuntu/incorrect-note/node_modules/express",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/accepts/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Douglas Christopher Wilson",
32 + "email": "doug@somethingdoug.com"
33 + },
34 + {
35 + "name": "Jonathan Ong",
36 + "email": "me@jongleberry.com",
37 + "url": "http://jongleberry.com"
38 + }
39 + ],
40 + "dependencies": {
41 + "mime-types": "~2.1.24",
42 + "negotiator": "0.6.2"
43 + },
44 + "deprecated": false,
45 + "description": "Higher-level content negotiation",
46 + "devDependencies": {
47 + "deep-equal": "1.0.1",
48 + "eslint": "5.16.0",
49 + "eslint-config-standard": "12.0.0",
50 + "eslint-plugin-import": "2.17.2",
51 + "eslint-plugin-markdown": "1.0.0",
52 + "eslint-plugin-node": "8.0.1",
53 + "eslint-plugin-promise": "4.1.1",
54 + "eslint-plugin-standard": "4.0.0",
55 + "mocha": "6.1.4",
56 + "nyc": "14.0.0"
57 + },
58 + "engines": {
59 + "node": ">= 0.6"
60 + },
61 + "files": [
62 + "LICENSE",
63 + "HISTORY.md",
64 + "index.js"
65 + ],
66 + "homepage": "https://github.com/jshttp/accepts#readme",
67 + "keywords": [
68 + "content",
69 + "negotiation",
70 + "accept",
71 + "accepts"
72 + ],
73 + "license": "MIT",
74 + "name": "accepts",
75 + "repository": {
76 + "type": "git",
77 + "url": "git+https://github.com/jshttp/accepts.git"
78 + },
79 + "scripts": {
80 + "lint": "eslint --plugin markdown --ext js,md .",
81 + "test": "mocha --reporter spec --check-leaks --bail test/",
82 + "test-cov": "nyc --reporter=html --reporter=text npm test",
83 + "test-travis": "nyc --reporter=text npm test"
84 + },
85 + "version": "1.3.7"
86 +}
1 +var Ajv = require('ajv');
2 +var ajv = new Ajv({allErrors: true});
3 +
4 +var schema = {
5 + "properties": {
6 + "foo": { "type": "string" },
7 + "bar": { "type": "number", "maximum": 3 }
8 + }
9 +};
10 +
11 +var validate = ajv.compile(schema);
12 +
13 +test({"foo": "abc", "bar": 2});
14 +test({"foo": 2, "bar": 4});
15 +
16 +function test(data) {
17 + var valid = validate(data);
18 + if (valid) console.log('Valid!');
19 + else console.log('Invalid: ' + ajv.errorsText(validate.errors));
20 +}
...\ No newline at end of file ...\ No newline at end of file
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2015-2017 Evgeny Poberezkin
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
22 +
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +
4 +var Cache = module.exports = function Cache() {
5 + this._cache = {};
6 +};
7 +
8 +
9 +Cache.prototype.put = function Cache_put(key, value) {
10 + this._cache[key] = value;
11 +};
12 +
13 +
14 +Cache.prototype.get = function Cache_get(key) {
15 + return this._cache[key];
16 +};
17 +
18 +
19 +Cache.prototype.del = function Cache_del(key) {
20 + delete this._cache[key];
21 +};
22 +
23 +
24 +Cache.prototype.clear = function Cache_clear() {
25 + this._cache = {};
26 +};
1 +'use strict';
2 +
3 +var MissingRefError = require('./error_classes').MissingRef;
4 +
5 +module.exports = compileAsync;
6 +
7 +
8 +/**
9 + * Creates validating function for passed schema with asynchronous loading of missing schemas.
10 + * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
11 + * @this Ajv
12 + * @param {Object} schema schema object
13 + * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
14 + * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
15 + * @return {Promise} promise that resolves with a validating function.
16 + */
17 +function compileAsync(schema, meta, callback) {
18 + /* eslint no-shadow: 0 */
19 + /* global Promise */
20 + /* jshint validthis: true */
21 + var self = this;
22 + if (typeof this._opts.loadSchema != 'function')
23 + throw new Error('options.loadSchema should be a function');
24 +
25 + if (typeof meta == 'function') {
26 + callback = meta;
27 + meta = undefined;
28 + }
29 +
30 + var p = loadMetaSchemaOf(schema).then(function () {
31 + var schemaObj = self._addSchema(schema, undefined, meta);
32 + return schemaObj.validate || _compileAsync(schemaObj);
33 + });
34 +
35 + if (callback) {
36 + p.then(
37 + function(v) { callback(null, v); },
38 + callback
39 + );
40 + }
41 +
42 + return p;
43 +
44 +
45 + function loadMetaSchemaOf(sch) {
46 + var $schema = sch.$schema;
47 + return $schema && !self.getSchema($schema)
48 + ? compileAsync.call(self, { $ref: $schema }, true)
49 + : Promise.resolve();
50 + }
51 +
52 +
53 + function _compileAsync(schemaObj) {
54 + try { return self._compile(schemaObj); }
55 + catch(e) {
56 + if (e instanceof MissingRefError) return loadMissingSchema(e);
57 + throw e;
58 + }
59 +
60 +
61 + function loadMissingSchema(e) {
62 + var ref = e.missingSchema;
63 + if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
64 +
65 + var schemaPromise = self._loadingSchemas[ref];
66 + if (!schemaPromise) {
67 + schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
68 + schemaPromise.then(removePromise, removePromise);
69 + }
70 +
71 + return schemaPromise.then(function (sch) {
72 + if (!added(ref)) {
73 + return loadMetaSchemaOf(sch).then(function () {
74 + if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
75 + });
76 + }
77 + }).then(function() {
78 + return _compileAsync(schemaObj);
79 + });
80 +
81 + function removePromise() {
82 + delete self._loadingSchemas[ref];
83 + }
84 +
85 + function added(ref) {
86 + return self._refs[ref] || self._schemas[ref];
87 + }
88 + }
89 + }
90 +}
1 +'use strict';
2 +
3 +// do NOT remove this file - it would break pre-compiled schemas
4 +// https://github.com/epoberezkin/ajv/issues/889
5 +module.exports = require('fast-deep-equal');
1 +'use strict';
2 +
3 +var resolve = require('./resolve');
4 +
5 +module.exports = {
6 + Validation: errorSubclass(ValidationError),
7 + MissingRef: errorSubclass(MissingRefError)
8 +};
9 +
10 +
11 +function ValidationError(errors) {
12 + this.message = 'validation failed';
13 + this.errors = errors;
14 + this.ajv = this.validation = true;
15 +}
16 +
17 +
18 +MissingRefError.message = function (baseId, ref) {
19 + return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
20 +};
21 +
22 +
23 +function MissingRefError(baseId, ref, message) {
24 + this.message = message || MissingRefError.message(baseId, ref);
25 + this.missingRef = resolve.url(baseId, ref);
26 + this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
27 +}
28 +
29 +
30 +function errorSubclass(Subclass) {
31 + Subclass.prototype = Object.create(Error.prototype);
32 + Subclass.prototype.constructor = Subclass;
33 + return Subclass;
34 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +var URI = require('uri-js')
4 + , equal = require('fast-deep-equal')
5 + , util = require('./util')
6 + , SchemaObject = require('./schema_obj')
7 + , traverse = require('json-schema-traverse');
8 +
9 +module.exports = resolve;
10 +
11 +resolve.normalizeId = normalizeId;
12 +resolve.fullPath = getFullPath;
13 +resolve.url = resolveUrl;
14 +resolve.ids = resolveIds;
15 +resolve.inlineRef = inlineRef;
16 +resolve.schema = resolveSchema;
17 +
18 +/**
19 + * [resolve and compile the references ($ref)]
20 + * @this Ajv
21 + * @param {Function} compile reference to schema compilation funciton (localCompile)
22 + * @param {Object} root object with information about the root schema for the current schema
23 + * @param {String} ref reference to resolve
24 + * @return {Object|Function} schema object (if the schema can be inlined) or validation function
25 + */
26 +function resolve(compile, root, ref) {
27 + /* jshint validthis: true */
28 + var refVal = this._refs[ref];
29 + if (typeof refVal == 'string') {
30 + if (this._refs[refVal]) refVal = this._refs[refVal];
31 + else return resolve.call(this, compile, root, refVal);
32 + }
33 +
34 + refVal = refVal || this._schemas[ref];
35 + if (refVal instanceof SchemaObject) {
36 + return inlineRef(refVal.schema, this._opts.inlineRefs)
37 + ? refVal.schema
38 + : refVal.validate || this._compile(refVal);
39 + }
40 +
41 + var res = resolveSchema.call(this, root, ref);
42 + var schema, v, baseId;
43 + if (res) {
44 + schema = res.schema;
45 + root = res.root;
46 + baseId = res.baseId;
47 + }
48 +
49 + if (schema instanceof SchemaObject) {
50 + v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
51 + } else if (schema !== undefined) {
52 + v = inlineRef(schema, this._opts.inlineRefs)
53 + ? schema
54 + : compile.call(this, schema, root, undefined, baseId);
55 + }
56 +
57 + return v;
58 +}
59 +
60 +
61 +/**
62 + * Resolve schema, its root and baseId
63 + * @this Ajv
64 + * @param {Object} root root object with properties schema, refVal, refs
65 + * @param {String} ref reference to resolve
66 + * @return {Object} object with properties schema, root, baseId
67 + */
68 +function resolveSchema(root, ref) {
69 + /* jshint validthis: true */
70 + var p = URI.parse(ref)
71 + , refPath = _getFullPath(p)
72 + , baseId = getFullPath(this._getId(root.schema));
73 + if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
74 + var id = normalizeId(refPath);
75 + var refVal = this._refs[id];
76 + if (typeof refVal == 'string') {
77 + return resolveRecursive.call(this, root, refVal, p);
78 + } else if (refVal instanceof SchemaObject) {
79 + if (!refVal.validate) this._compile(refVal);
80 + root = refVal;
81 + } else {
82 + refVal = this._schemas[id];
83 + if (refVal instanceof SchemaObject) {
84 + if (!refVal.validate) this._compile(refVal);
85 + if (id == normalizeId(ref))
86 + return { schema: refVal, root: root, baseId: baseId };
87 + root = refVal;
88 + } else {
89 + return;
90 + }
91 + }
92 + if (!root.schema) return;
93 + baseId = getFullPath(this._getId(root.schema));
94 + }
95 + return getJsonPointer.call(this, p, baseId, root.schema, root);
96 +}
97 +
98 +
99 +/* @this Ajv */
100 +function resolveRecursive(root, ref, parsedRef) {
101 + /* jshint validthis: true */
102 + var res = resolveSchema.call(this, root, ref);
103 + if (res) {
104 + var schema = res.schema;
105 + var baseId = res.baseId;
106 + root = res.root;
107 + var id = this._getId(schema);
108 + if (id) baseId = resolveUrl(baseId, id);
109 + return getJsonPointer.call(this, parsedRef, baseId, schema, root);
110 + }
111 +}
112 +
113 +
114 +var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
115 +/* @this Ajv */
116 +function getJsonPointer(parsedRef, baseId, schema, root) {
117 + /* jshint validthis: true */
118 + parsedRef.fragment = parsedRef.fragment || '';
119 + if (parsedRef.fragment.slice(0,1) != '/') return;
120 + var parts = parsedRef.fragment.split('/');
121 +
122 + for (var i = 1; i < parts.length; i++) {
123 + var part = parts[i];
124 + if (part) {
125 + part = util.unescapeFragment(part);
126 + schema = schema[part];
127 + if (schema === undefined) break;
128 + var id;
129 + if (!PREVENT_SCOPE_CHANGE[part]) {
130 + id = this._getId(schema);
131 + if (id) baseId = resolveUrl(baseId, id);
132 + if (schema.$ref) {
133 + var $ref = resolveUrl(baseId, schema.$ref);
134 + var res = resolveSchema.call(this, root, $ref);
135 + if (res) {
136 + schema = res.schema;
137 + root = res.root;
138 + baseId = res.baseId;
139 + }
140 + }
141 + }
142 + }
143 + }
144 + if (schema !== undefined && schema !== root.schema)
145 + return { schema: schema, root: root, baseId: baseId };
146 +}
147 +
148 +
149 +var SIMPLE_INLINED = util.toHash([
150 + 'type', 'format', 'pattern',
151 + 'maxLength', 'minLength',
152 + 'maxProperties', 'minProperties',
153 + 'maxItems', 'minItems',
154 + 'maximum', 'minimum',
155 + 'uniqueItems', 'multipleOf',
156 + 'required', 'enum'
157 +]);
158 +function inlineRef(schema, limit) {
159 + if (limit === false) return false;
160 + if (limit === undefined || limit === true) return checkNoRef(schema);
161 + else if (limit) return countKeys(schema) <= limit;
162 +}
163 +
164 +
165 +function checkNoRef(schema) {
166 + var item;
167 + if (Array.isArray(schema)) {
168 + for (var i=0; i<schema.length; i++) {
169 + item = schema[i];
170 + if (typeof item == 'object' && !checkNoRef(item)) return false;
171 + }
172 + } else {
173 + for (var key in schema) {
174 + if (key == '$ref') return false;
175 + item = schema[key];
176 + if (typeof item == 'object' && !checkNoRef(item)) return false;
177 + }
178 + }
179 + return true;
180 +}
181 +
182 +
183 +function countKeys(schema) {
184 + var count = 0, item;
185 + if (Array.isArray(schema)) {
186 + for (var i=0; i<schema.length; i++) {
187 + item = schema[i];
188 + if (typeof item == 'object') count += countKeys(item);
189 + if (count == Infinity) return Infinity;
190 + }
191 + } else {
192 + for (var key in schema) {
193 + if (key == '$ref') return Infinity;
194 + if (SIMPLE_INLINED[key]) {
195 + count++;
196 + } else {
197 + item = schema[key];
198 + if (typeof item == 'object') count += countKeys(item) + 1;
199 + if (count == Infinity) return Infinity;
200 + }
201 + }
202 + }
203 + return count;
204 +}
205 +
206 +
207 +function getFullPath(id, normalize) {
208 + if (normalize !== false) id = normalizeId(id);
209 + var p = URI.parse(id);
210 + return _getFullPath(p);
211 +}
212 +
213 +
214 +function _getFullPath(p) {
215 + return URI.serialize(p).split('#')[0] + '#';
216 +}
217 +
218 +
219 +var TRAILING_SLASH_HASH = /#\/?$/;
220 +function normalizeId(id) {
221 + return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
222 +}
223 +
224 +
225 +function resolveUrl(baseId, id) {
226 + id = normalizeId(id);
227 + return URI.resolve(baseId, id);
228 +}
229 +
230 +
231 +/* @this Ajv */
232 +function resolveIds(schema) {
233 + var schemaId = normalizeId(this._getId(schema));
234 + var baseIds = {'': schemaId};
235 + var fullPaths = {'': getFullPath(schemaId, false)};
236 + var localRefs = {};
237 + var self = this;
238 +
239 + traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
240 + if (jsonPtr === '') return;
241 + var id = self._getId(sch);
242 + var baseId = baseIds[parentJsonPtr];
243 + var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
244 + if (keyIndex !== undefined)
245 + fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
246 +
247 + if (typeof id == 'string') {
248 + id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
249 +
250 + var refVal = self._refs[id];
251 + if (typeof refVal == 'string') refVal = self._refs[refVal];
252 + if (refVal && refVal.schema) {
253 + if (!equal(sch, refVal.schema))
254 + throw new Error('id "' + id + '" resolves to more than one schema');
255 + } else if (id != normalizeId(fullPath)) {
256 + if (id[0] == '#') {
257 + if (localRefs[id] && !equal(sch, localRefs[id]))
258 + throw new Error('id "' + id + '" resolves to more than one schema');
259 + localRefs[id] = sch;
260 + } else {
261 + self._refs[id] = fullPath;
262 + }
263 + }
264 + }
265 + baseIds[jsonPtr] = baseId;
266 + fullPaths[jsonPtr] = fullPath;
267 + });
268 +
269 + return localRefs;
270 +}
1 +'use strict';
2 +
3 +var ruleModules = require('../dotjs')
4 + , toHash = require('./util').toHash;
5 +
6 +module.exports = function rules() {
7 + var RULES = [
8 + { type: 'number',
9 + rules: [ { 'maximum': ['exclusiveMaximum'] },
10 + { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
11 + { type: 'string',
12 + rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
13 + { type: 'array',
14 + rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
15 + { type: 'object',
16 + rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
17 + { 'properties': ['additionalProperties', 'patternProperties'] } ] },
18 + { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
19 + ];
20 +
21 + var ALL = [ 'type', '$comment' ];
22 + var KEYWORDS = [
23 + '$schema', '$id', 'id', '$data', '$async', 'title',
24 + 'description', 'default', 'definitions',
25 + 'examples', 'readOnly', 'writeOnly',
26 + 'contentMediaType', 'contentEncoding',
27 + 'additionalItems', 'then', 'else'
28 + ];
29 + var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
30 + RULES.all = toHash(ALL);
31 + RULES.types = toHash(TYPES);
32 +
33 + RULES.forEach(function (group) {
34 + group.rules = group.rules.map(function (keyword) {
35 + var implKeywords;
36 + if (typeof keyword == 'object') {
37 + var key = Object.keys(keyword)[0];
38 + implKeywords = keyword[key];
39 + keyword = key;
40 + implKeywords.forEach(function (k) {
41 + ALL.push(k);
42 + RULES.all[k] = true;
43 + });
44 + }
45 + ALL.push(keyword);
46 + var rule = RULES.all[keyword] = {
47 + keyword: keyword,
48 + code: ruleModules[keyword],
49 + implements: implKeywords
50 + };
51 + return rule;
52 + });
53 +
54 + RULES.all.$comment = {
55 + keyword: '$comment',
56 + code: ruleModules.$comment
57 + };
58 +
59 + if (group.type) RULES.types[group.type] = group;
60 + });
61 +
62 + RULES.keywords = toHash(ALL.concat(KEYWORDS));
63 + RULES.custom = {};
64 +
65 + return RULES;
66 +};
1 +'use strict';
2 +
3 +var util = require('./util');
4 +
5 +module.exports = SchemaObject;
6 +
7 +function SchemaObject(obj) {
8 + util.copy(obj, this);
9 +}
1 +'use strict';
2 +
3 +// https://mathiasbynens.be/notes/javascript-encoding
4 +// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5 +module.exports = function ucs2length(str) {
6 + var length = 0
7 + , len = str.length
8 + , pos = 0
9 + , value;
10 + while (pos < len) {
11 + length++;
12 + value = str.charCodeAt(pos++);
13 + if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
14 + // high surrogate, and there is a next character
15 + value = str.charCodeAt(pos);
16 + if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
17 + }
18 + }
19 + return length;
20 +};
1 +'use strict';
2 +
3 +
4 +module.exports = {
5 + copy: copy,
6 + checkDataType: checkDataType,
7 + checkDataTypes: checkDataTypes,
8 + coerceToTypes: coerceToTypes,
9 + toHash: toHash,
10 + getProperty: getProperty,
11 + escapeQuotes: escapeQuotes,
12 + equal: require('fast-deep-equal'),
13 + ucs2length: require('./ucs2length'),
14 + varOccurences: varOccurences,
15 + varReplace: varReplace,
16 + cleanUpCode: cleanUpCode,
17 + finalCleanUpCode: finalCleanUpCode,
18 + schemaHasRules: schemaHasRules,
19 + schemaHasRulesExcept: schemaHasRulesExcept,
20 + schemaUnknownRules: schemaUnknownRules,
21 + toQuotedString: toQuotedString,
22 + getPathExpr: getPathExpr,
23 + getPath: getPath,
24 + getData: getData,
25 + unescapeFragment: unescapeFragment,
26 + unescapeJsonPointer: unescapeJsonPointer,
27 + escapeFragment: escapeFragment,
28 + escapeJsonPointer: escapeJsonPointer
29 +};
30 +
31 +
32 +function copy(o, to) {
33 + to = to || {};
34 + for (var key in o) to[key] = o[key];
35 + return to;
36 +}
37 +
38 +
39 +function checkDataType(dataType, data, negate) {
40 + var EQUAL = negate ? ' !== ' : ' === '
41 + , AND = negate ? ' || ' : ' && '
42 + , OK = negate ? '!' : ''
43 + , NOT = negate ? '' : '!';
44 + switch (dataType) {
45 + case 'null': return data + EQUAL + 'null';
46 + case 'array': return OK + 'Array.isArray(' + data + ')';
47 + case 'object': return '(' + OK + data + AND +
48 + 'typeof ' + data + EQUAL + '"object"' + AND +
49 + NOT + 'Array.isArray(' + data + '))';
50 + case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
51 + NOT + '(' + data + ' % 1)' +
52 + AND + data + EQUAL + data + ')';
53 + default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
54 + }
55 +}
56 +
57 +
58 +function checkDataTypes(dataTypes, data) {
59 + switch (dataTypes.length) {
60 + case 1: return checkDataType(dataTypes[0], data, true);
61 + default:
62 + var code = '';
63 + var types = toHash(dataTypes);
64 + if (types.array && types.object) {
65 + code = types.null ? '(': '(!' + data + ' || ';
66 + code += 'typeof ' + data + ' !== "object")';
67 + delete types.null;
68 + delete types.array;
69 + delete types.object;
70 + }
71 + if (types.number) delete types.integer;
72 + for (var t in types)
73 + code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
74 +
75 + return code;
76 + }
77 +}
78 +
79 +
80 +var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
81 +function coerceToTypes(optionCoerceTypes, dataTypes) {
82 + if (Array.isArray(dataTypes)) {
83 + var types = [];
84 + for (var i=0; i<dataTypes.length; i++) {
85 + var t = dataTypes[i];
86 + if (COERCE_TO_TYPES[t]) types[types.length] = t;
87 + else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
88 + }
89 + if (types.length) return types;
90 + } else if (COERCE_TO_TYPES[dataTypes]) {
91 + return [dataTypes];
92 + } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
93 + return ['array'];
94 + }
95 +}
96 +
97 +
98 +function toHash(arr) {
99 + var hash = {};
100 + for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
101 + return hash;
102 +}
103 +
104 +
105 +var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
106 +var SINGLE_QUOTE = /'|\\/g;
107 +function getProperty(key) {
108 + return typeof key == 'number'
109 + ? '[' + key + ']'
110 + : IDENTIFIER.test(key)
111 + ? '.' + key
112 + : "['" + escapeQuotes(key) + "']";
113 +}
114 +
115 +
116 +function escapeQuotes(str) {
117 + return str.replace(SINGLE_QUOTE, '\\$&')
118 + .replace(/\n/g, '\\n')
119 + .replace(/\r/g, '\\r')
120 + .replace(/\f/g, '\\f')
121 + .replace(/\t/g, '\\t');
122 +}
123 +
124 +
125 +function varOccurences(str, dataVar) {
126 + dataVar += '[^0-9]';
127 + var matches = str.match(new RegExp(dataVar, 'g'));
128 + return matches ? matches.length : 0;
129 +}
130 +
131 +
132 +function varReplace(str, dataVar, expr) {
133 + dataVar += '([^0-9])';
134 + expr = expr.replace(/\$/g, '$$$$');
135 + return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
136 +}
137 +
138 +
139 +var EMPTY_ELSE = /else\s*{\s*}/g
140 + , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
141 + , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
142 +function cleanUpCode(out) {
143 + return out.replace(EMPTY_ELSE, '')
144 + .replace(EMPTY_IF_NO_ELSE, '')
145 + .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
146 +}
147 +
148 +
149 +var ERRORS_REGEXP = /[^v.]errors/g
150 + , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
151 + , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
152 + , RETURN_VALID = 'return errors === 0;'
153 + , RETURN_TRUE = 'validate.errors = null; return true;'
154 + , RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
155 + , RETURN_DATA_ASYNC = 'return data;'
156 + , ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
157 + , REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
158 +
159 +function finalCleanUpCode(out, async) {
160 + var matches = out.match(ERRORS_REGEXP);
161 + if (matches && matches.length == 2) {
162 + out = async
163 + ? out.replace(REMOVE_ERRORS_ASYNC, '')
164 + .replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
165 + : out.replace(REMOVE_ERRORS, '')
166 + .replace(RETURN_VALID, RETURN_TRUE);
167 + }
168 +
169 + matches = out.match(ROOTDATA_REGEXP);
170 + if (!matches || matches.length !== 3) return out;
171 + return out.replace(REMOVE_ROOTDATA, '');
172 +}
173 +
174 +
175 +function schemaHasRules(schema, rules) {
176 + if (typeof schema == 'boolean') return !schema;
177 + for (var key in schema) if (rules[key]) return true;
178 +}
179 +
180 +
181 +function schemaHasRulesExcept(schema, rules, exceptKeyword) {
182 + if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
183 + for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
184 +}
185 +
186 +
187 +function schemaUnknownRules(schema, rules) {
188 + if (typeof schema == 'boolean') return;
189 + for (var key in schema) if (!rules[key]) return key;
190 +}
191 +
192 +
193 +function toQuotedString(str) {
194 + return '\'' + escapeQuotes(str) + '\'';
195 +}
196 +
197 +
198 +function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
199 + var path = jsonPointers // false by default
200 + ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
201 + : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
202 + return joinPaths(currentPath, path);
203 +}
204 +
205 +
206 +function getPath(currentPath, prop, jsonPointers) {
207 + var path = jsonPointers // false by default
208 + ? toQuotedString('/' + escapeJsonPointer(prop))
209 + : toQuotedString(getProperty(prop));
210 + return joinPaths(currentPath, path);
211 +}
212 +
213 +
214 +var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
215 +var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
216 +function getData($data, lvl, paths) {
217 + var up, jsonPointer, data, matches;
218 + if ($data === '') return 'rootData';
219 + if ($data[0] == '/') {
220 + if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
221 + jsonPointer = $data;
222 + data = 'rootData';
223 + } else {
224 + matches = $data.match(RELATIVE_JSON_POINTER);
225 + if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
226 + up = +matches[1];
227 + jsonPointer = matches[2];
228 + if (jsonPointer == '#') {
229 + if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
230 + return paths[lvl - up];
231 + }
232 +
233 + if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
234 + data = 'data' + ((lvl - up) || '');
235 + if (!jsonPointer) return data;
236 + }
237 +
238 + var expr = data;
239 + var segments = jsonPointer.split('/');
240 + for (var i=0; i<segments.length; i++) {
241 + var segment = segments[i];
242 + if (segment) {
243 + data += getProperty(unescapeJsonPointer(segment));
244 + expr += ' && ' + data;
245 + }
246 + }
247 + return expr;
248 +}
249 +
250 +
251 +function joinPaths (a, b) {
252 + if (a == '""') return b;
253 + return (a + ' + ' + b).replace(/' \+ '/g, '');
254 +}
255 +
256 +
257 +function unescapeFragment(str) {
258 + return unescapeJsonPointer(decodeURIComponent(str));
259 +}
260 +
261 +
262 +function escapeFragment(str) {
263 + return encodeURIComponent(escapeJsonPointer(str));
264 +}
265 +
266 +
267 +function escapeJsonPointer(str) {
268 + return str.replace(/~/g, '~0').replace(/\//g, '~1');
269 +}
270 +
271 +
272 +function unescapeJsonPointer(str) {
273 + return str.replace(/~1/g, '/').replace(/~0/g, '~');
274 +}
1 +'use strict';
2 +
3 +var KEYWORDS = [
4 + 'multipleOf',
5 + 'maximum',
6 + 'exclusiveMaximum',
7 + 'minimum',
8 + 'exclusiveMinimum',
9 + 'maxLength',
10 + 'minLength',
11 + 'pattern',
12 + 'additionalItems',
13 + 'maxItems',
14 + 'minItems',
15 + 'uniqueItems',
16 + 'maxProperties',
17 + 'minProperties',
18 + 'required',
19 + 'additionalProperties',
20 + 'enum',
21 + 'format',
22 + 'const'
23 +];
24 +
25 +module.exports = function (metaSchema, keywordsJsonPointers) {
26 + for (var i=0; i<keywordsJsonPointers.length; i++) {
27 + metaSchema = JSON.parse(JSON.stringify(metaSchema));
28 + var segments = keywordsJsonPointers[i].split('/');
29 + var keywords = metaSchema;
30 + var j;
31 + for (j=1; j<segments.length; j++)
32 + keywords = keywords[segments[j]];
33 +
34 + for (j=0; j<KEYWORDS.length; j++) {
35 + var key = KEYWORDS[j];
36 + var schema = keywords[key];
37 + if (schema) {
38 + keywords[key] = {
39 + anyOf: [
40 + schema,
41 + { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }
42 + ]
43 + };
44 + }
45 + }
46 + }
47 +
48 + return metaSchema;
49 +};
1 +'use strict';
2 +
3 +var metaSchema = require('./refs/json-schema-draft-07.json');
4 +
5 +module.exports = {
6 + $id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js',
7 + definitions: {
8 + simpleTypes: metaSchema.definitions.simpleTypes
9 + },
10 + type: 'object',
11 + dependencies: {
12 + schema: ['validate'],
13 + $data: ['validate'],
14 + statements: ['inline'],
15 + valid: {not: {required: ['macro']}}
16 + },
17 + properties: {
18 + type: metaSchema.properties.type,
19 + schema: {type: 'boolean'},
20 + statements: {type: 'boolean'},
21 + dependencies: {
22 + type: 'array',
23 + items: {type: 'string'}
24 + },
25 + metaSchema: {type: 'object'},
26 + modifying: {type: 'boolean'},
27 + valid: {type: 'boolean'},
28 + $data: {type: 'boolean'},
29 + async: {type: 'boolean'},
30 + errors: {
31 + anyOf: [
32 + {type: 'boolean'},
33 + {const: 'full'}
34 + ]
35 + }
36 + }
37 +};
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{## def.setExclusiveLimit:
7 + $exclusive = true;
8 + $errorKeyword = $exclusiveKeyword;
9 + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
10 +#}}
11 +
12 +{{
13 + var $isMax = $keyword == 'maximum'
14 + , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
15 + , $schemaExcl = it.schema[$exclusiveKeyword]
16 + , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
17 + , $op = $isMax ? '<' : '>'
18 + , $notOp = $isMax ? '>' : '<'
19 + , $errorKeyword = undefined;
20 +}}
21 +
22 +{{? $isDataExcl }}
23 + {{
24 + var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
25 + , $exclusive = 'exclusive' + $lvl
26 + , $exclType = 'exclType' + $lvl
27 + , $exclIsNumber = 'exclIsNumber' + $lvl
28 + , $opExpr = 'op' + $lvl
29 + , $opStr = '\' + ' + $opExpr + ' + \'';
30 + }}
31 + var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
32 + {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
33 +
34 + var {{=$exclusive}};
35 + var {{=$exclType}} = typeof {{=$schemaValueExcl}};
36 + if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
37 + {{ var $errorKeyword = $exclusiveKeyword; }}
38 + {{# def.error:'_exclusiveLimit' }}
39 + } else if ({{# def.$dataNotType:'number' }}
40 + {{=$exclType}} == 'number'
41 + ? (
42 + ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
43 + ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
44 + : {{=$data}} {{=$notOp}} {{=$schemaValue}}
45 + )
46 + : (
47 + ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
48 + ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
49 + : {{=$data}} {{=$notOp}} {{=$schemaValue}}
50 + )
51 + || {{=$data}} !== {{=$data}}) {
52 + var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
53 + {{
54 + if ($schema === undefined) {
55 + $errorKeyword = $exclusiveKeyword;
56 + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
57 + $schemaValue = $schemaValueExcl;
58 + $isData = $isDataExcl;
59 + }
60 + }}
61 +{{??}}
62 + {{
63 + var $exclIsNumber = typeof $schemaExcl == 'number'
64 + , $opStr = $op; /*used in error*/
65 + }}
66 +
67 + {{? $exclIsNumber && $isData }}
68 + {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
69 + if ({{# def.$dataNotType:'number' }}
70 + ( {{=$schemaValue}} === undefined
71 + || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
72 + ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
73 + : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
74 + || {{=$data}} !== {{=$data}}) {
75 + {{??}}
76 + {{
77 + if ($exclIsNumber && $schema === undefined) {
78 + {{# def.setExclusiveLimit }}
79 + $schemaValue = $schemaExcl;
80 + $notOp += '=';
81 + } else {
82 + if ($exclIsNumber)
83 + $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
84 +
85 + if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
86 + {{# def.setExclusiveLimit }}
87 + $notOp += '=';
88 + } else {
89 + $exclusive = false;
90 + $opStr += '=';
91 + }
92 + }
93 +
94 + var $opExpr = '\'' + $opStr + '\''; /*used in error*/
95 + }}
96 +
97 + if ({{# def.$dataNotType:'number' }}
98 + {{=$data}} {{=$notOp}} {{=$schemaValue}}
99 + || {{=$data}} !== {{=$data}}) {
100 + {{?}}
101 +{{?}}
102 + {{ $errorKeyword = $errorKeyword || $keyword; }}
103 + {{# def.error:'_limit' }}
104 + } {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitItems' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitLength' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
7 +if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
8 + {{ var $errorKeyword = $keyword; }}
9 + {{# def.error:'_limitProperties' }}
10 +} {{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +{{
7 + var $currentBaseId = $it.baseId
8 + , $allSchemasEmpty = true;
9 +}}
10 +
11 +{{~ $schema:$sch:$i }}
12 + {{? {{# def.nonEmptySchema:$sch }} }}
13 + {{
14 + $allSchemasEmpty = false;
15 + $it.schema = $sch;
16 + $it.schemaPath = $schemaPath + '[' + $i + ']';
17 + $it.errSchemaPath = $errSchemaPath + '/' + $i;
18 + }}
19 +
20 + {{# def.insertSubschemaCode }}
21 +
22 + {{# def.ifResultValid }}
23 + {{?}}
24 +{{~}}
25 +
26 +{{? $breakOnError }}
27 + {{? $allSchemasEmpty }}
28 + if (true) {
29 + {{??}}
30 + {{= $closingBraces.slice(0,-1) }}
31 + {{?}}
32 +{{?}}
33 +
34 +{{# def.cleanUp }}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +{{
7 + var $noEmptySchema = $schema.every(function($sch) {
8 + return {{# def.nonEmptySchema:$sch }};
9 + });
10 +}}
11 +{{? $noEmptySchema }}
12 + {{ var $currentBaseId = $it.baseId; }}
13 + var {{=$errs}} = errors;
14 + var {{=$valid}} = false;
15 +
16 + {{# def.setCompositeRule }}
17 +
18 + {{~ $schema:$sch:$i }}
19 + {{
20 + $it.schema = $sch;
21 + $it.schemaPath = $schemaPath + '[' + $i + ']';
22 + $it.errSchemaPath = $errSchemaPath + '/' + $i;
23 + }}
24 +
25 + {{# def.insertSubschemaCode }}
26 +
27 + {{=$valid}} = {{=$valid}} || {{=$nextValid}};
28 +
29 + if (!{{=$valid}}) {
30 + {{ $closingBraces += '}'; }}
31 + {{~}}
32 +
33 + {{# def.resetCompositeRule }}
34 +
35 + {{= $closingBraces }}
36 +
37 + if (!{{=$valid}}) {
38 + {{# def.extraError:'anyOf' }}
39 + } else {
40 + {{# def.resetErrors }}
41 + {{? it.opts.allErrors }} } {{?}}
42 +
43 + {{# def.cleanUp }}
44 +{{??}}
45 + {{? $breakOnError }}
46 + if (true) {
47 + {{?}}
48 +{{?}}
1 +{{## def.coerceType:
2 + {{
3 + var $dataType = 'dataType' + $lvl
4 + , $coerced = 'coerced' + $lvl;
5 + }}
6 + var {{=$dataType}} = typeof {{=$data}};
7 + {{? it.opts.coerceTypes == 'array'}}
8 + if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';
9 + {{?}}
10 +
11 + var {{=$coerced}} = undefined;
12 +
13 + {{ var $bracesCoercion = ''; }}
14 + {{~ $coerceToTypes:$type:$i }}
15 + {{? $i }}
16 + if ({{=$coerced}} === undefined) {
17 + {{ $bracesCoercion += '}'; }}
18 + {{?}}
19 +
20 + {{? it.opts.coerceTypes == 'array' && $type != 'array' }}
21 + if ({{=$dataType}} == 'array' && {{=$data}}.length == 1) {
22 + {{=$coerced}} = {{=$data}} = {{=$data}}[0];
23 + {{=$dataType}} = typeof {{=$data}};
24 + /*if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';*/
25 + }
26 + {{?}}
27 +
28 + {{? $type == 'string' }}
29 + if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
30 + {{=$coerced}} = '' + {{=$data}};
31 + else if ({{=$data}} === null) {{=$coerced}} = '';
32 + {{?? $type == 'number' || $type == 'integer' }}
33 + if ({{=$dataType}} == 'boolean' || {{=$data}} === null
34 + || ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
35 + {{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
36 + {{=$coerced}} = +{{=$data}};
37 + {{?? $type == 'boolean' }}
38 + if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
39 + {{=$coerced}} = false;
40 + else if ({{=$data}} === 'true' || {{=$data}} === 1)
41 + {{=$coerced}} = true;
42 + {{?? $type == 'null' }}
43 + if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
44 + {{=$coerced}} = null;
45 + {{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
46 + if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
47 + {{=$coerced}} = [{{=$data}}];
48 + {{?}}
49 + {{~}}
50 +
51 + {{= $bracesCoercion }}
52 +
53 + if ({{=$coerced}} === undefined) {
54 + {{# def.error:'type' }}
55 + } else {
56 + {{# def.setParentData }}
57 + {{=$data}} = {{=$coerced}};
58 + {{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
59 + {{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
60 + }
61 +#}}
1 +{{# def.definitions }}
2 +{{# def.setupKeyword }}
3 +
4 +{{ var $comment = it.util.toQuotedString($schema); }}
5 +{{? it.opts.$comment === true }}
6 + console.log({{=$comment}});
7 +{{?? typeof it.opts.$comment == 'function' }}
8 + self._opts.$comment({{=$comment}}, {{=it.util.toQuotedString($errSchemaPath)}}, validate.root.schema);
9 +{{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{? !$isData }}
7 + var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
8 +{{?}}
9 +var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
10 +{{# def.checkError:'const' }}
11 +{{? $breakOnError }} else { {{?}}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.setupNextLevel }}
5 +
6 +
7 +{{
8 + var $idx = 'i' + $lvl
9 + , $dataNxt = $it.dataLevel = it.dataLevel + 1
10 + , $nextData = 'data' + $dataNxt
11 + , $currentBaseId = it.baseId
12 + , $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
13 +}}
14 +
15 +var {{=$errs}} = errors;
16 +var {{=$valid}};
17 +
18 +{{? $nonEmptySchema }}
19 + {{# def.setCompositeRule }}
20 +
21 + {{
22 + $it.schema = $schema;
23 + $it.schemaPath = $schemaPath;
24 + $it.errSchemaPath = $errSchemaPath;
25 + }}
26 +
27 + var {{=$nextValid}} = false;
28 +
29 + for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
30 + {{
31 + $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
32 + var $passData = $data + '[' + $idx + ']';
33 + $it.dataPathArr[$dataNxt] = $idx;
34 + }}
35 +
36 + {{# def.generateSubschemaCode }}
37 + {{# def.optimizeValidate }}
38 +
39 + if ({{=$nextValid}}) break;
40 + }
41 +
42 + {{# def.resetCompositeRule }}
43 + {{= $closingBraces }}
44 +
45 + if (!{{=$nextValid}}) {
46 +{{??}}
47 + if ({{=$data}}.length == 0) {
48 +{{?}}
49 +
50 + {{# def.error:'contains' }}
51 + } else {
52 + {{? $nonEmptySchema }}
53 + {{# def.resetErrors }}
54 + {{?}}
55 + {{? it.opts.allErrors }} } {{?}}
56 +
57 +{{# def.cleanUp }}
1 +{{# def.definitions }}
2 +{{# def.errors }}
3 +{{# def.setupKeyword }}
4 +{{# def.$data }}
5 +
6 +{{
7 + var $rule = this
8 + , $definition = 'definition' + $lvl
9 + , $rDef = $rule.definition
10 + , $closingBraces = '';
11 + var $validate = $rDef.validate;
12 + var $compile, $inline, $macro, $ruleValidate, $validateCode;
13 +}}
14 +
15 +{{? $isData && $rDef.$data }}
16 + {{
17 + $validateCode = 'keywordValidate' + $lvl;
18 + var $validateSchema = $rDef.validateSchema;
19 + }}
20 + var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
21 + var {{=$validateCode}} = {{=$definition}}.validate;
22 +{{??}}
23 + {{
24 + $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
25 + if (!$ruleValidate) return;
26 + $schemaValue = 'validate.schema' + $schemaPath;
27 + $validateCode = $ruleValidate.code;
28 + $compile = $rDef.compile;
29 + $inline = $rDef.inline;
30 + $macro = $rDef.macro;
31 + }}
32 +{{?}}
33 +
34 +{{
35 + var $ruleErrs = $validateCode + '.errors'
36 + , $i = 'i' + $lvl
37 + , $ruleErr = 'ruleErr' + $lvl
38 + , $asyncKeyword = $rDef.async;
39 +
40 + if ($asyncKeyword && !it.async)
41 + throw new Error('async keyword in sync schema');
42 +}}
43 +
44 +
45 +{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
46 +var {{=$errs}} = errors;
47 +var {{=$valid}};
48 +
49 +{{## def.callRuleValidate:
50 + {{=$validateCode}}.call(
51 + {{? it.opts.passContext }}this{{??}}self{{?}}
52 + {{? $compile || $rDef.schema === false }}
53 + , {{=$data}}
54 + {{??}}
55 + , {{=$schemaValue}}
56 + , {{=$data}}
57 + , validate.schema{{=it.schemaPath}}
58 + {{?}}
59 + , {{# def.dataPath }}
60 + {{# def.passParentData }}
61 + , rootData
62 + )
63 +#}}
64 +
65 +{{## def.extendErrors:_inline:
66 + for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
67 + var {{=$ruleErr}} = vErrors[{{=$i}}];
68 + if ({{=$ruleErr}}.dataPath === undefined)
69 + {{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
70 + {{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
71 + {{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
72 + {{# _inline ? '}' : '' }}
73 + {{? it.opts.verbose }}
74 + {{=$ruleErr}}.schema = {{=$schemaValue}};
75 + {{=$ruleErr}}.data = {{=$data}};
76 + {{?}}
77 + }
78 +#}}
79 +
80 +
81 +{{? $isData && $rDef.$data }}
82 + {{ $closingBraces += '}'; }}
83 + if ({{=$schemaValue}} === undefined) {
84 + {{=$valid}} = true;
85 + } else {
86 + {{? $validateSchema }}
87 + {{ $closingBraces += '}'; }}
88 + {{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
89 + if ({{=$valid}}) {
90 + {{?}}
91 +{{?}}
92 +
93 +{{? $inline }}
94 + {{? $rDef.statements }}
95 + {{= $ruleValidate.validate }}
96 + {{??}}
97 + {{=$valid}} = {{= $ruleValidate.validate }};
98 + {{?}}
99 +{{?? $macro }}
100 + {{# def.setupNextLevel }}
101 + {{
102 + $it.schema = $ruleValidate.validate;
103 + $it.schemaPath = '';
104 + }}
105 + {{# def.setCompositeRule }}
106 + {{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
107 + {{# def.resetCompositeRule }}
108 + {{= $code }}
109 +{{??}}
110 + {{# def.beginDefOut}}
111 + {{# def.callRuleValidate }}
112 + {{# def.storeDefOut:def_callRuleValidate }}
113 +
114 + {{? $rDef.errors === false }}
115 + {{=$valid}} = {{? $asyncKeyword }}await {{?}}{{= def_callRuleValidate }};
116 + {{??}}
117 + {{? $asyncKeyword }}
118 + {{ $ruleErrs = 'customErrors' + $lvl; }}
119 + var {{=$ruleErrs}} = null;
120 + try {
121 + {{=$valid}} = await {{= def_callRuleValidate }};
122 + } catch (e) {
123 + {{=$valid}} = false;
124 + if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
125 + else throw e;
126 + }
127 + {{??}}
128 + {{=$ruleErrs}} = null;
129 + {{=$valid}} = {{= def_callRuleValidate }};
130 + {{?}}
131 + {{?}}
132 +{{?}}
133 +
134 +{{? $rDef.modifying }}
135 + if ({{=$parentData}}) {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
136 +{{?}}
137 +
138 +{{= $closingBraces }}
139 +
140 +{{## def.notValidationResult:
141 + {{? $rDef.valid === undefined }}
142 + !{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
143 + {{??}}
144 + {{= !$rDef.valid }}
145 + {{?}}
146 +#}}
147 +
148 +{{? $rDef.valid }}
149 + {{? $breakOnError }} if (true) { {{?}}
150 +{{??}}
151 + if ({{# def.notValidationResult }}) {
152 + {{ $errorKeyword = $rule.keyword; }}
153 + {{# def.beginDefOut}}
154 + {{# def.error:'custom' }}
155 + {{# def.storeDefOut:def_customError }}
156 +
157 + {{? $inline }}
158 + {{? $rDef.errors }}
159 + {{? $rDef.errors != 'full' }}
160 + {{# def.extendErrors:true }}
161 + {{?}}
162 + {{??}}
163 + {{? $rDef.errors === false}}
164 + {{= def_customError }}
165 + {{??}}
166 + if ({{=$errs}} == errors) {
167 + {{= def_customError }}
168 + } else {
169 + {{# def.extendErrors:true }}
170 + }
171 + {{?}}
172 + {{?}}
173 + {{?? $macro }}
174 + {{# def.extraError:'custom' }}
175 + {{??}}
176 + {{? $rDef.errors === false}}
177 + {{= def_customError }}
178 + {{??}}
179 + if (Array.isArray({{=$ruleErrs}})) {
180 + if (vErrors === null) vErrors = {{=$ruleErrs}};
181 + else vErrors = vErrors.concat({{=$ruleErrs}});
182 + errors = vErrors.length;
183 + {{# def.extendErrors:false }}
184 + } else {
185 + {{= def_customError }}
186 + }
187 + {{?}}
188 + {{?}}
189 +
190 + } {{? $breakOnError }} else { {{?}}
191 +{{?}}
1 +{{## def.assignDefault:
2 + {{? it.compositeRule }}
3 + {{
4 + if (it.opts.strictDefaults) {
5 + var $defaultMsg = 'default is ignored for: ' + $passData;
6 + if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
7 + else throw new Error($defaultMsg);
8 + }
9 + }}
10 + {{??}}
11 + if ({{=$passData}} === undefined
12 + {{? it.opts.useDefaults == 'empty' }}
13 + || {{=$passData}} === null
14 + || {{=$passData}} === ''
15 + {{?}}
16 + )
17 + {{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
18 + {{= it.useDefault($sch.default) }}
19 + {{??}}
20 + {{= JSON.stringify($sch.default) }}
21 + {{?}};
22 + {{?}}
23 +#}}
24 +
25 +
26 +{{## def.defaultProperties:
27 + {{
28 + var $schema = it.schema.properties
29 + , $schemaKeys = Object.keys($schema); }}
30 + {{~ $schemaKeys:$propertyKey }}
31 + {{ var $sch = $schema[$propertyKey]; }}
32 + {{? $sch.default !== undefined }}
33 + {{ var $passData = $data + it.util.getProperty($propertyKey); }}
34 + {{# def.assignDefault }}
35 + {{?}}
36 + {{~}}
37 +#}}
38 +
39 +
40 +{{## def.defaultItems:
41 + {{~ it.schema.items:$sch:$i }}
42 + {{? $sch.default !== undefined }}
43 + {{ var $passData = $data + '[' + $i + ']'; }}
44 + {{# def.assignDefault }}
45 + {{?}}
46 + {{~}}
47 +#}}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.