-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6834c56
commit c51ee5f
Showing
13 changed files
with
153 additions
and
94 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
lib/platform/DefaultPlatformFunctions.js → lib/platform/PlatformFunctions.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import EventEmitter = require('events'); | ||
import StripeEmitter = require('../StripeEmitter'); | ||
import PlatformFunctions = require('./PlatformFunctions'); | ||
|
||
/** | ||
* Specializes WebPlatformFunctions using APIs available in Web workers. | ||
*/ | ||
class WebPlatformFunctions extends PlatformFunctions { | ||
/** @override */ | ||
getUname(): Promise<string | null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
/** @override */ | ||
uuid4(): string { | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { | ||
const r = (Math.random() * 16) | 0; | ||
const v = c === 'x' ? r : (r & 0x3) | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
|
||
/** @override */ | ||
secureCompare(a: string, b: string): boolean { | ||
// return early here if buffer lengths are not equal | ||
if (a.length !== b.length) { | ||
return false; | ||
} | ||
|
||
const len = a.length; | ||
let result = 0; | ||
|
||
for (let i = 0; i < len; ++i) { | ||
result |= a.charCodeAt(i) ^ b.charCodeAt(i); | ||
} | ||
return result === 0; | ||
} | ||
|
||
/** @override */ | ||
createEmitter(): StripeEmitter | EventEmitter { | ||
return new StripeEmitter(new EventTarget()); | ||
} | ||
} | ||
|
||
export = WebPlatformFunctions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.