refactor: refactor of libs
This commit is contained in:
		
							parent
							
								
									b67cddf4eb
								
							
						
					
					
						commit
						40f6ae7f76
					
				| @ -1,4 +1,4 @@ | |||||||
| Copyright (c) 2011, Chris Umbel | Copyright (c) 2023, Chris Umbel, Lisoveliy | ||||||
| 
 | 
 | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
| of this software and associated documentation files (the "Software"), to deal | of this software and associated documentation files (the "Software"), to deal | ||||||
							
								
								
									
										10
									
								
								lib/base32/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/base32/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | # base32 | ||||||
|  | 
 | ||||||
|  | Implementation of RFC 3548 Base32 encoding/decoding for zepp quickjs. | ||||||
|  | 
 | ||||||
|  | ## Usage | ||||||
|  |     import {encode, decode} from 'base32/index.js' | ||||||
|  |     base32.encode('node'); | ||||||
|  |     // output: NZXWIZI= | ||||||
|  |     base32.decode('NZXWIZI='); | ||||||
|  |     //output: node | ||||||
| @ -1,5 +1,5 @@ | |||||||
| /*                                                                               | /*                                                                               | ||||||
| Copyright (c) 2011, Chris Umbel                                                  | Copyright (c) 2023, Chris Umbel, Lisoveliy                                               | ||||||
|                                                                                  |                                                                                  | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy     | Permission is hereby granted, free of charge, to any person obtaining a copy     | ||||||
| of this software and associated documentation files (the "Software"), to deal    | of this software and associated documentation files (the "Software"), to deal    | ||||||
| @ -20,4 +20,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||||
| THE SOFTWARE.                                                                    | THE SOFTWARE.                                                                    | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| export {encode, decode} from './lib/thirty-two/thirty-two.js' | export { encode, decode } from './lib/base32/base32.js' | ||||||
| @ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
| Copyright (c) 2011, Chris Umbel | Copyright (c) 2023, Chris Umbel, Lisoveliy | ||||||
| 
 | 
 | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
| of this software and associated documentation files (the "Software"), to deal | of this software and associated documentation files (the "Software"), to deal | ||||||
| @ -1,13 +1,10 @@ | |||||||
| { | { | ||||||
|   "name": "thirty-two", |   "name": "base32", | ||||||
|   "description": "Implementation RFC 3548 Base32 encoding/decoding for node.", |   "description": "Implementation RFC 3548 Base32 encoding/decoding for node.", | ||||||
|   "version": "1.0.2", |   "version": "1.0.2-zepp", | ||||||
|   "engines": { |  | ||||||
|     "node": ">=0.2.6" |  | ||||||
|   }, |  | ||||||
|   "author": "Chris Umbel <chris@chrisumbel.com>", |   "author": "Chris Umbel <chris@chrisumbel.com>", | ||||||
|   "keywords": ["base32", "encoding"], |   "keywords": ["base32", "encoding"], | ||||||
|   "main": "./lib/thirty-two/index.js", |   "main": "index.js", | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
|     "url": "git://github.com/chrisumbel/thirty-two.git" |     "url": "git://github.com/chrisumbel/thirty-two.git" | ||||||
| @ -1,4 +0,0 @@ | |||||||
| *.kpf |  | ||||||
| *~ |  | ||||||
| \#* |  | ||||||
| node_modules |  | ||||||
| @ -1,24 +0,0 @@ | |||||||
| # Copyright (c) 2011, Chris Umbel
 |  | ||||||
| 
 |  | ||||||
| # 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:
 |  | ||||||
| 
 |  | ||||||
| # The above copyright notice and this permission notice shall be included in
 |  | ||||||
| # all copies or substantial portions of the Software.
 |  | ||||||
| 
 |  | ||||||
| # 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.
 |  | ||||||
| 
 |  | ||||||
| SHELL := /bin/bash |  | ||||||
| 
 |  | ||||||
| test: |  | ||||||
| 	jasmine-node spec/ |  | ||||||
| @ -1,15 +0,0 @@ | |||||||
| # thirty-two |  | ||||||
| 
 |  | ||||||
| Implementation of RFC 3548 Base32 encoding/decoding for node. |  | ||||||
| 
 |  | ||||||
| ## Installation |  | ||||||
|      |  | ||||||
|     npm install thirty-two |  | ||||||
| 
 |  | ||||||
| ## Usage |  | ||||||
|      |  | ||||||
|     var base32 = require('thirty-two'); |  | ||||||
|     base32.encode('node'); |  | ||||||
|     // output: NZXWIZI= |  | ||||||
|     base32.decode('NZXWIZI='); |  | ||||||
|     //output: node |  | ||||||
| @ -1,63 +0,0 @@ | |||||||
| /*                                                                              |  | ||||||
| Copyright (c) 2011, Chris Umbel                                                 |  | ||||||
|                                                                                  |  | ||||||
| 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:                         |  | ||||||
|                                                                                  |  | ||||||
| The above copyright notice and this permission notice shall be included in       |  | ||||||
| all copies or substantial portions of the Software.                              |  | ||||||
|                                                                                  |  | ||||||
| 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.                                                                    |  | ||||||
| */ |  | ||||||
| if(!expect){ |  | ||||||
| 	function expect(a){ |  | ||||||
| 		return { |  | ||||||
| 			toBe: function(b){ |  | ||||||
| 				require('assert').strictEqual(a, b); |  | ||||||
| 			} |  | ||||||
| 		}; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| var base32 = require('../lib/thirty-two/'); |  | ||||||
| 
 |  | ||||||
| describe('thirty-two', function() { |  | ||||||
|     it('should encode', function() { |  | ||||||
|         expect(base32.encode('a').toString()).toBe('ME======'); |  | ||||||
|         expect(base32.encode('be').toString()).toBe('MJSQ===='); |  | ||||||
|         expect(base32.encode('bee').toString()).toBe('MJSWK==='); |  | ||||||
|         expect(base32.encode('beer').toString()).toBe('MJSWK4Q='); |  | ||||||
|         expect(base32.encode('beers').toString()).toBe('MJSWK4TT'); |  | ||||||
|         expect(base32.encode('beers 1').toString()).toBe('MJSWK4TTEAYQ===='); |  | ||||||
|         expect(base32.encode('shockingly dismissed').toString()).toBe('ONUG6Y3LNFXGO3DZEBSGS43NNFZXGZLE');         |  | ||||||
|     }); |  | ||||||
|      |  | ||||||
|      |  | ||||||
|     it('should decode', function() { |  | ||||||
|         expect(base32.decode('ME======').toString()).toBe('a'); |  | ||||||
|         expect(base32.decode('MJSQ====').toString()).toBe('be'); |  | ||||||
|         expect(base32.decode('ONXW4===').toString()).toBe('son'); |  | ||||||
|         expect(base32.decode('MJSWK===').toString()).toBe('bee'); |  | ||||||
|         expect(base32.decode('MJSWK4Q=').toString()).toBe('beer'); |  | ||||||
|         expect(base32.decode('MJSWK4TT').toString()).toBe('beers'); |  | ||||||
|         expect(base32.decode('mjswK4TT').toString()).toBe('beers'); |  | ||||||
|         expect(base32.decode('MJSWK4TTN5XA====').toString()).toBe('beerson'); |  | ||||||
|         expect(base32.decode('MJSWK4TTEAYQ====').toString()).toBe('beers 1'); |  | ||||||
|         expect(base32.decode('ONUG6Y3LNFXGO3DZEBSGS43NNFZXGZLE').toString()).toBe('shockingly dismissed'); |  | ||||||
|     }); |  | ||||||
|      |  | ||||||
|     it('should be binary safe', function() { |  | ||||||
|         expect(base32.decode(base32.encode(new Buffer([0x00, 0xff, 0x88]))).toString('hex')).toBe('00ff88'); |  | ||||||
|     	expect(base32.encode(new Buffer("f61e1f998d69151de8334dbe753ab17ae831c13849a6aecd95d0a4e5dc25", 'hex')).toString()).toBe('6YPB7GMNNEKR32BTJW7HKOVRPLUDDQJYJGTK5TMV2CSOLXBF'); |  | ||||||
|     	expect(base32.decode('6YPB7GMNNEKR32BTJW7HKOVRPLUDDQJYJGTK5TMV2CSOLXBF').toString('hex')).toBe('f61e1f998d69151de8334dbe753ab17ae831c13849a6aecd95d0a4e5dc25'); |  | ||||||
|     }); |  | ||||||
| }); |  | ||||||
| @ -1,3 +0,0 @@ | |||||||
| language: node_js |  | ||||||
| node_js: |  | ||||||
|   - "8" |  | ||||||
| @ -1,5 +0,0 @@ | |||||||
| # totp.js |  | ||||||
| Two-factor authentication implementation in pure javascript. One-time password generator (HOTP/TOTP) with support for Google Authenticator. |  | ||||||
| 
 |  | ||||||
| [](https://travis-ci.org/wuyanxin/totp.js) |  | ||||||
| 
 |  | ||||||
| @ -1,9 +1,2 @@ | |||||||
| /* |  | ||||||
|  * @Author: wuyanxin |  | ||||||
|  * @Date: 2018-03-21 23:12:14 |  | ||||||
|  * @Last Modified by:   wuyanxin |  | ||||||
|  * @Last Modified time: 2018-03-21 23:12:14 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| export { HOTP } from './lib/hotp.js' | export { HOTP } from './lib/hotp.js' | ||||||
| export { TOTP } from './lib/totp.js' | export { TOTP } from './lib/totp.js' | ||||||
|  | |||||||
| @ -1,11 +1,4 @@ | |||||||
| /* | import { encode, decode } from '../../base32/index.js' | ||||||
|  * @Author: wuyanxin |  | ||||||
|  * @Date: 2018-03-21 22:25:37 |  | ||||||
|  * @Last Modified by: wuyanxin |  | ||||||
|  * @Last Modified time: 2018-03-21 22:29:43 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| import {encode, decode} from '../../thirty-two/index.js' |  | ||||||
| import jsSHA from 'jssha' | import jsSHA from 'jssha' | ||||||
| 
 | 
 | ||||||
| export class HOTP { | export class HOTP { | ||||||
|  | |||||||
| @ -1,10 +1,3 @@ | |||||||
| /* |  | ||||||
|  * @Author: wuyanxin |  | ||||||
|  * @Date: 2018-03-21 22:25:42 |  | ||||||
|  * @Last Modified by: wuyanxin |  | ||||||
|  * @Last Modified time: 2018-03-21 22:42:28 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| import { HOTP } from "./hotp.js"; | import { HOTP } from "./hotp.js"; | ||||||
| 
 | 
 | ||||||
| export class TOTP extends HOTP { | export class TOTP extends HOTP { | ||||||
| @ -20,5 +13,4 @@ export class TOTP extends HOTP { | |||||||
|   verify(otp, timeStep = 30, t0 = 0) { |   verify(otp, timeStep = 30, t0 = 0) { | ||||||
|     return otp === this.genOTP(timeStep, t0); |     return otp === this.genOTP(timeStep, t0); | ||||||
|   } |   } | ||||||
| 
 |  | ||||||
| } | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "totp.js", |   "name": "totp.js", | ||||||
|   "version": "0.0.1", |   "version": "1.0.1-zepp", | ||||||
|   "description": "Two-factor authentication implementation in pure javascript. One-time password generator (HOTP/TOTP) with support for Google Authenticator. ", |   "description": "Two-factor authentication implementation in pure javascript. One-time password generator (HOTP/TOTP) with support for Google Authenticator. ", | ||||||
|   "main": "index.js", |   "main": "index.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
| @ -24,8 +24,7 @@ | |||||||
|   }, |   }, | ||||||
|   "homepage": "https://github.com/wuyanxin/totp.js#readme", |   "homepage": "https://github.com/wuyanxin/totp.js#readme", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "jssha": "^2.3.1", |     "jssha": "^2.3.1" | ||||||
|     "thirty-two": "^1.0.2" |  | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "mocha": "^5.0.4" |     "mocha": "^5.0.4" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user