Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cdab426d5 | ||
|
|
4ff8693875 | ||
|
|
a13b3dd004 | ||
|
|
9062fbef52 | ||
|
|
d9237b1d71 | ||
|
|
2bd04b06a3 | ||
|
|
b13ec265ad | ||
|
|
7413a531d4 | ||
|
|
43601061a5 | ||
|
|
d016e4d81c | ||
|
|
b4ee5822c6 | ||
|
|
c23d9df55e | ||
|
|
0ad94c4a52 | ||
|
|
d35f6c58a6 |
@@ -19,7 +19,7 @@ The value stored inside `file` at key `field`.
|
||||
|
||||
## Example usage
|
||||
```
|
||||
uses: SebRollen/toml-action@v1.0.0
|
||||
uses: SebRollen/toml-action@v1.2.0
|
||||
id: read_toml
|
||||
with:
|
||||
file: 'myfile.toml'
|
||||
|
||||
@@ -14,6 +14,5 @@ outputs:
|
||||
value:
|
||||
description: 'The data stored in `field` inside `file`'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node20'
|
||||
main: 'index.js'
|
||||
|
||||
|
||||
2
index.js
2
index.js
@@ -1,6 +1,6 @@
|
||||
const core = require('@actions/core');
|
||||
const github = require('@actions/github');
|
||||
const toml = require('toml');
|
||||
const toml = require('@iarna/toml');
|
||||
const fs = require('fs');
|
||||
|
||||
try {
|
||||
|
||||
1
node_modules/.bin/uuid
generated
vendored
Symbolic link
1
node_modules/.bin/uuid
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../uuid/dist/bin/uuid
|
||||
240
node_modules/.package-lock.json
generated
vendored
Normal file
240
node_modules/.package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"name": "toml-action",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/github": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.0.tgz",
|
||||
"integrity": "sha512-QvE9eAAfEsS+yOOk0cylLBIO/d6WyWIOvsxxzdrPFaud39G6BOkUwScXZn1iBzQzHyu9SBkkLSWlohDWdsasAQ==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^1.0.11",
|
||||
"@octokit/core": "^3.4.0",
|
||||
"@octokit/plugin-paginate-rest": "^2.13.3",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^5.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@iarna/toml": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "2.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.5.tgz",
|
||||
"integrity": "sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/core": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz",
|
||||
"integrity": "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^2.4.4",
|
||||
"@octokit/graphql": "^4.5.8",
|
||||
"@octokit/request": "^5.6.0",
|
||||
"@octokit/request-error": "^2.0.5",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/endpoint": {
|
||||
"version": "6.0.12",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
|
||||
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/graphql": {
|
||||
"version": "4.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.6.4.tgz",
|
||||
"integrity": "sha512-SWTdXsVheRmlotWNjKzPOb6Js6tjSqA2a8z9+glDJng0Aqjzti8MEWOtuT8ZSu6wHnci7LZNuarE87+WJBG4vg==",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^5.6.0",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/openapi-types": {
|
||||
"version": "7.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-7.3.5.tgz",
|
||||
"integrity": "sha512-6bm5lzGDOeSnWHM5W8OZ86RD2KpchynU+/Qlm5hNEFjfLDhwfAY2lSe68YRUEYFGlxSHe0HmakyhvmtWoD3Zog=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "2.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.5.tgz",
|
||||
"integrity": "sha512-3WSAKBLa1RaR/7GG+LQR/tAZ9fp9H9waE9aPXallidyci9oZsfgsLn5M836d3LuDC6Fcym+2idRTBpssHZePVg==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.13.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=2"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "5.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.3.4.tgz",
|
||||
"integrity": "sha512-2Y2q/FYCsW5tcwIqgnLOgzZXEb3I1VoSQGyHs/Zki/Ufs5H+uT0maPVHatLKw90LQbqK7ON8NpL3Y8IyzG6pNA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.16.7",
|
||||
"deprecation": "^2.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.0.tgz",
|
||||
"integrity": "sha512-4cPp/N+NqmaGQwbh3vUsYqokQIzt7VjsgTYVXiwpUP2pxd5YiZB2XuTedbb0SPtv9XS7nzAKjAuQxmY8/aZkiA==",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^6.0.1",
|
||||
"@octokit/request-error": "^2.1.0",
|
||||
"@octokit/types": "^6.16.1",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request-error": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
|
||||
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "6.16.7",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.16.7.tgz",
|
||||
"integrity": "sha512-OuQELiwIKeDySgNID52vm33wDRc2aaX8lKYgAw9Hmw939ITow1HspT8/AH3M3jgGFUMDmHlMNBNEmH7xV7ggXQ==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^7.3.5"
|
||||
}
|
||||
},
|
||||
"node_modules/before-after-hook": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
|
||||
"integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ=="
|
||||
},
|
||||
"node_modules/deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.7",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||
"engines": {
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-user-agent": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
}
|
||||
}
|
||||
}
|
||||
126
node_modules/@actions/core/README.md
generated
vendored
126
node_modules/@actions/core/README.md
generated
vendored
@@ -92,6 +92,8 @@ try {
|
||||
|
||||
// Do stuff
|
||||
core.info('Output to the actions build log')
|
||||
|
||||
core.notice('This is a message that will also emit an annotation')
|
||||
}
|
||||
catch (err) {
|
||||
core.error(`Error ${err}, action may still succeed though`);
|
||||
@@ -115,6 +117,59 @@ const result = await core.group('Do something async', async () => {
|
||||
})
|
||||
```
|
||||
|
||||
#### Annotations
|
||||
|
||||
This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
|
||||
```js
|
||||
core.error('This is a bad error. This will also fail the build.')
|
||||
|
||||
core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
|
||||
|
||||
core.notice('Something happened that you might want to know about.')
|
||||
```
|
||||
|
||||
These will surface to the UI in the Actions page and on Pull Requests. They look something like this:
|
||||
|
||||

|
||||
|
||||
These annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring.
|
||||
|
||||
These options are:
|
||||
```typescript
|
||||
export interface AnnotationProperties {
|
||||
/**
|
||||
* A title for the annotation.
|
||||
*/
|
||||
title?: string
|
||||
|
||||
/**
|
||||
* The name of the file for which the annotation should be created.
|
||||
*/
|
||||
file?: string
|
||||
|
||||
/**
|
||||
* The start line for the annotation.
|
||||
*/
|
||||
startLine?: number
|
||||
|
||||
/**
|
||||
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
|
||||
*/
|
||||
endLine?: number
|
||||
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
*/
|
||||
startColumn?: number
|
||||
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* Defaults to `startColumn` when `startColumn` is provided.
|
||||
*/
|
||||
endColumn?: number
|
||||
}
|
||||
```
|
||||
|
||||
#### Styling output
|
||||
|
||||
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
|
||||
@@ -207,3 +262,74 @@ var pid = core.getState("pidToKill");
|
||||
|
||||
process.kill(pid);
|
||||
```
|
||||
|
||||
#### OIDC Token
|
||||
|
||||
You can use these methods to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
|
||||
|
||||
**Method Name**: getIDToken()
|
||||
|
||||
**Inputs**
|
||||
|
||||
audience : optional
|
||||
|
||||
**Outputs**
|
||||
|
||||
A [JWT](https://jwt.io/) ID Token
|
||||
|
||||
In action's `main.ts`:
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
async function getIDTokenAction(): Promise<void> {
|
||||
|
||||
const audience = core.getInput('audience', {required: false})
|
||||
|
||||
const id_token1 = await core.getIDToken() // ID Token with default audience
|
||||
const id_token2 = await core.getIDToken(audience) // ID token with custom audience
|
||||
|
||||
// this id_token can be used to get access token from third party cloud providers
|
||||
}
|
||||
getIDTokenAction()
|
||||
```
|
||||
|
||||
In action's `actions.yml`:
|
||||
|
||||
```yaml
|
||||
name: 'GetIDToken'
|
||||
description: 'Get ID token from Github OIDC provider'
|
||||
inputs:
|
||||
audience:
|
||||
description: 'Audience for which the ID token is intended for'
|
||||
required: false
|
||||
outputs:
|
||||
id_token1:
|
||||
description: 'ID token obtained from OIDC provider'
|
||||
id_token2:
|
||||
description: 'ID token obtained from OIDC provider'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
```
|
||||
|
||||
#### Filesystem path helpers
|
||||
|
||||
You can use these methods to manipulate file paths across operating systems.
|
||||
|
||||
The `toPosixPath` function converts input paths to Posix-style (Linux) paths.
|
||||
The `toWin32Path` function converts input paths to Windows-style paths. These
|
||||
functions work independently of the underlying runner operating system.
|
||||
|
||||
```js
|
||||
toPosixPath('\\foo\\bar') // => /foo/bar
|
||||
toWin32Path('/foo/bar') // => \foo\bar
|
||||
```
|
||||
|
||||
The `toPlatformPath` function converts input paths to the expected value on the runner's operating system.
|
||||
|
||||
```js
|
||||
// On a Windows runner.
|
||||
toPlatformPath('/foo/bar') // => \foo\bar
|
||||
|
||||
// On a Linux runner.
|
||||
toPlatformPath('\\foo\\bar') // => /foo/bar
|
||||
```
|
||||
|
||||
3
node_modules/@actions/core/lib/command.d.ts
generated
vendored
3
node_modules/@actions/core/lib/command.d.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
interface CommandProperties {
|
||||
export interface CommandProperties {
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
@@ -13,4 +13,3 @@ interface CommandProperties {
|
||||
*/
|
||||
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
||||
export declare function issue(name: string, message?: string): void;
|
||||
export {};
|
||||
|
||||
58
node_modules/@actions/core/lib/core.d.ts
generated
vendored
58
node_modules/@actions/core/lib/core.d.ts
generated
vendored
@@ -20,6 +20,37 @@ export declare enum ExitCode {
|
||||
*/
|
||||
Failure = 1
|
||||
}
|
||||
/**
|
||||
* Optional properties that can be sent with annotatation commands (notice, error, and warning)
|
||||
* See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
|
||||
*/
|
||||
export interface AnnotationProperties {
|
||||
/**
|
||||
* A title for the annotation.
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* The path of the file for which the annotation should be created.
|
||||
*/
|
||||
file?: string;
|
||||
/**
|
||||
* The start line for the annotation.
|
||||
*/
|
||||
startLine?: number;
|
||||
/**
|
||||
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
|
||||
*/
|
||||
endLine?: number;
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
*/
|
||||
startColumn?: number;
|
||||
/**
|
||||
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||
* Defaults to `startColumn` when `startColumn` is provided.
|
||||
*/
|
||||
endColumn?: number;
|
||||
}
|
||||
/**
|
||||
* Sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
@@ -97,13 +128,21 @@ export declare function debug(message: string): void;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
export declare function error(message: string | Error): void;
|
||||
export declare function error(message: string | Error, properties?: AnnotationProperties): void;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* Adds a warning issue
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
export declare function warning(message: string | Error): void;
|
||||
export declare function warning(message: string | Error, properties?: AnnotationProperties): void;
|
||||
/**
|
||||
* Adds a notice issue
|
||||
* @param message notice issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
export declare function notice(message: string | Error, properties?: AnnotationProperties): void;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
@@ -144,3 +183,16 @@ export declare function saveState(name: string, value: any): void;
|
||||
* @returns string
|
||||
*/
|
||||
export declare function getState(name: string): string;
|
||||
export declare function getIDToken(aud?: string): Promise<string>;
|
||||
/**
|
||||
* Summary exports
|
||||
*/
|
||||
export { summary } from './summary';
|
||||
/**
|
||||
* @deprecated use core.summary
|
||||
*/
|
||||
export { markdownSummary } from './summary';
|
||||
/**
|
||||
* Path exports
|
||||
*/
|
||||
export { toPosixPath, toWin32Path, toPlatformPath } from './path-utils';
|
||||
|
||||
74
node_modules/@actions/core/lib/core.js
generated
vendored
74
node_modules/@actions/core/lib/core.js
generated
vendored
@@ -28,12 +28,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||
const command_1 = require("./command");
|
||||
const file_command_1 = require("./file-command");
|
||||
const utils_1 = require("./utils");
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const oidc_utils_1 = require("./oidc-utils");
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
@@ -62,13 +63,9 @@ function exportVariable(name, val) {
|
||||
process.env[name] = convertedVal;
|
||||
const filePath = process.env['GITHUB_ENV'] || '';
|
||||
if (filePath) {
|
||||
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||
file_command_1.issueCommand('ENV', commandValue);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
||||
}
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
@@ -86,7 +83,7 @@ exports.setSecret = setSecret;
|
||||
function addPath(inputPath) {
|
||||
const filePath = process.env['GITHUB_PATH'] || '';
|
||||
if (filePath) {
|
||||
file_command_1.issueCommand('PATH', inputPath);
|
||||
file_command_1.issueFileCommand('PATH', inputPath);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
@@ -126,7 +123,10 @@ function getMultilineInput(name, options) {
|
||||
const inputs = getInput(name, options)
|
||||
.split('\n')
|
||||
.filter(x => x !== '');
|
||||
return inputs;
|
||||
if (options && options.trimWhitespace === false) {
|
||||
return inputs;
|
||||
}
|
||||
return inputs.map(input => input.trim());
|
||||
}
|
||||
exports.getMultilineInput = getMultilineInput;
|
||||
/**
|
||||
@@ -159,8 +159,12 @@ exports.getBooleanInput = getBooleanInput;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function setOutput(name, value) {
|
||||
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
||||
if (filePath) {
|
||||
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
||||
}
|
||||
process.stdout.write(os.EOL);
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
/**
|
||||
@@ -206,19 +210,30 @@ exports.debug = debug;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
function error(message) {
|
||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||
function error(message, properties = {}) {
|
||||
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.error = error;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* Adds a warning issue
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
function warning(message) {
|
||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||
function warning(message, properties = {}) {
|
||||
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.warning = warning;
|
||||
/**
|
||||
* Adds a notice issue
|
||||
* @param message notice issue message. Errors will be converted to string via toString()
|
||||
* @param properties optional properties to add to the annotation.
|
||||
*/
|
||||
function notice(message, properties = {}) {
|
||||
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.notice = notice;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
@@ -278,7 +293,11 @@ exports.group = group;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function saveState(name, value) {
|
||||
command_1.issueCommand('save-state', { name }, value);
|
||||
const filePath = process.env['GITHUB_STATE'] || '';
|
||||
if (filePath) {
|
||||
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
||||
}
|
||||
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
||||
}
|
||||
exports.saveState = saveState;
|
||||
/**
|
||||
@@ -291,4 +310,27 @@ function getState(name) {
|
||||
return process.env[`STATE_${name}`] || '';
|
||||
}
|
||||
exports.getState = getState;
|
||||
function getIDToken(aud) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
||||
});
|
||||
}
|
||||
exports.getIDToken = getIDToken;
|
||||
/**
|
||||
* Summary exports
|
||||
*/
|
||||
var summary_1 = require("./summary");
|
||||
Object.defineProperty(exports, "summary", { enumerable: true, get: function () { return summary_1.summary; } });
|
||||
/**
|
||||
* @deprecated use core.summary
|
||||
*/
|
||||
var summary_2 = require("./summary");
|
||||
Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function () { return summary_2.markdownSummary; } });
|
||||
/**
|
||||
* Path exports
|
||||
*/
|
||||
var path_utils_1 = require("./path-utils");
|
||||
Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function () { return path_utils_1.toPosixPath; } });
|
||||
Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function () { return path_utils_1.toWin32Path; } });
|
||||
Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function () { return path_utils_1.toPlatformPath; } });
|
||||
//# sourceMappingURL=core.js.map
|
||||
2
node_modules/@actions/core/lib/core.js.map
generated
vendored
2
node_modules/@actions/core/lib/core.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3
node_modules/@actions/core/lib/file-command.d.ts
generated
vendored
3
node_modules/@actions/core/lib/file-command.d.ts
generated
vendored
@@ -1 +1,2 @@
|
||||
export declare function issueCommand(command: string, message: any): void;
|
||||
export declare function issueFileCommand(command: string, message: any): void;
|
||||
export declare function prepareKeyValueMessage(key: string, value: any): string;
|
||||
|
||||
22
node_modules/@actions/core/lib/file-command.js
generated
vendored
22
node_modules/@actions/core/lib/file-command.js
generated
vendored
@@ -20,13 +20,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.issueCommand = void 0;
|
||||
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const uuid_1 = require("uuid");
|
||||
const utils_1 = require("./utils");
|
||||
function issueCommand(command, message) {
|
||||
function issueFileCommand(command, message) {
|
||||
const filePath = process.env[`GITHUB_${command}`];
|
||||
if (!filePath) {
|
||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||
@@ -38,5 +39,20 @@ function issueCommand(command, message) {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
exports.issueCommand = issueCommand;
|
||||
exports.issueFileCommand = issueFileCommand;
|
||||
function prepareKeyValueMessage(key, value) {
|
||||
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||
const convertedValue = utils_1.toCommandValue(value);
|
||||
// These should realistically never happen, but just in case someone finds a
|
||||
// way to exploit uuid generation let's not allow keys or values that contain
|
||||
// the delimiter.
|
||||
if (key.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
if (convertedValue.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||||
}
|
||||
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
||||
}
|
||||
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
||||
//# sourceMappingURL=file-command.js.map
|
||||
2
node_modules/@actions/core/lib/file-command.js.map
generated
vendored
2
node_modules/@actions/core/lib/file-command.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;;;;;;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,mCAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAe,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,oCAcC"}
|
||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;;;;;;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,+BAAiC;AACjC,mCAAsC;AAEtC,SAAgB,gBAAgB,CAAC,OAAe,EAAE,OAAY;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,4CAcC;AAED,SAAgB,sBAAsB,CAAC,GAAW,EAAE,KAAU;IAC5D,MAAM,SAAS,GAAG,gBAAgB,SAAM,EAAE,EAAE,CAAA;IAC5C,MAAM,cAAc,GAAG,sBAAc,CAAC,KAAK,CAAC,CAAA;IAE5C,4EAA4E;IAC5E,6EAA6E;IAC7E,iBAAiB;IACjB,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,4DAA4D,SAAS,GAAG,CACzE,CAAA;KACF;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,6DAA6D,SAAS,GAAG,CAC1E,CAAA;KACF;IAED,OAAO,GAAG,GAAG,KAAK,SAAS,GAAG,EAAE,CAAC,GAAG,GAAG,cAAc,GAAG,EAAE,CAAC,GAAG,GAAG,SAAS,EAAE,CAAA;AAC9E,CAAC;AApBD,wDAoBC"}
|
||||
7
node_modules/@actions/core/lib/oidc-utils.d.ts
generated
vendored
Normal file
7
node_modules/@actions/core/lib/oidc-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare class OidcClient {
|
||||
private static createHttpClient;
|
||||
private static getRequestToken;
|
||||
private static getIDTokenUrl;
|
||||
private static getCall;
|
||||
static getIDToken(audience?: string): Promise<string>;
|
||||
}
|
||||
77
node_modules/@actions/core/lib/oidc-utils.js
generated
vendored
Normal file
77
node_modules/@actions/core/lib/oidc-utils.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OidcClient = void 0;
|
||||
const http_client_1 = require("@actions/http-client");
|
||||
const auth_1 = require("@actions/http-client/lib/auth");
|
||||
const core_1 = require("./core");
|
||||
class OidcClient {
|
||||
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||
const requestOptions = {
|
||||
allowRetries: allowRetry,
|
||||
maxRetries: maxRetry
|
||||
};
|
||||
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
||||
}
|
||||
static getRequestToken() {
|
||||
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
||||
if (!token) {
|
||||
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
static getIDTokenUrl() {
|
||||
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
||||
if (!runtimeUrl) {
|
||||
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
||||
}
|
||||
return runtimeUrl;
|
||||
}
|
||||
static getCall(id_token_url) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpclient = OidcClient.createHttpClient();
|
||||
const res = yield httpclient
|
||||
.getJson(id_token_url)
|
||||
.catch(error => {
|
||||
throw new Error(`Failed to get ID Token. \n
|
||||
Error Code : ${error.statusCode}\n
|
||||
Error Message: ${error.result.message}`);
|
||||
});
|
||||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (!id_token) {
|
||||
throw new Error('Response json body do not have ID Token field');
|
||||
}
|
||||
return id_token;
|
||||
});
|
||||
}
|
||||
static getIDToken(audience) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
// New ID Token is requested from action service
|
||||
let id_token_url = OidcClient.getIDTokenUrl();
|
||||
if (audience) {
|
||||
const encodedAudience = encodeURIComponent(audience);
|
||||
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
||||
}
|
||||
core_1.debug(`ID token url is ${id_token_url}`);
|
||||
const id_token = yield OidcClient.getCall(id_token_url);
|
||||
core_1.setSecret(id_token);
|
||||
return id_token;
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Error message: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.OidcClient = OidcClient;
|
||||
//# sourceMappingURL=oidc-utils.js.map
|
||||
1
node_modules/@actions/core/lib/oidc-utils.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/lib/oidc-utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"oidc-utils.js","sourceRoot":"","sources":["../src/oidc-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,sDAA+C;AAC/C,wDAAqE;AACrE,iCAAuC;AAKvC,MAAa,UAAU;IACb,MAAM,CAAC,gBAAgB,CAC7B,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,EAAE;QAEb,MAAM,cAAc,GAAmB;YACrC,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,QAAQ;SACrB,CAAA;QAED,OAAO,IAAI,wBAAU,CACnB,qBAAqB,EACrB,CAAC,IAAI,8BAAuB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,EAC3D,cAAc,CACf,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,eAAe;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;QAC3D,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;SACF;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,MAAM,CAAC,aAAa;QAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC9D,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;SAC3E;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;IAEO,MAAM,CAAO,OAAO,CAAC,YAAoB;;;YAC/C,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAA;YAEhD,MAAM,GAAG,GAAG,MAAM,UAAU;iBACzB,OAAO,CAAgB,YAAY,CAAC;iBACpC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACb,MAAM,IAAI,KAAK,CACb;uBACa,KAAK,CAAC,UAAU;yBACd,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CACtC,CAAA;YACH,CAAC,CAAC,CAAA;YAEJ,MAAM,QAAQ,SAAG,GAAG,CAAC,MAAM,0CAAE,KAAK,CAAA;YAClC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;aACjE;YACD,OAAO,QAAQ,CAAA;;KAChB;IAED,MAAM,CAAO,UAAU,CAAC,QAAiB;;YACvC,IAAI;gBACF,gDAAgD;gBAChD,IAAI,YAAY,GAAW,UAAU,CAAC,aAAa,EAAE,CAAA;gBACrD,IAAI,QAAQ,EAAE;oBACZ,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;oBACpD,YAAY,GAAG,GAAG,YAAY,aAAa,eAAe,EAAE,CAAA;iBAC7D;gBAED,YAAK,CAAC,mBAAmB,YAAY,EAAE,CAAC,CAAA;gBAExC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;gBACvD,gBAAS,CAAC,QAAQ,CAAC,CAAA;gBACnB,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;aACnD;QACH,CAAC;KAAA;CACF;AAzED,gCAyEC"}
|
||||
25
node_modules/@actions/core/lib/path-utils.d.ts
generated
vendored
Normal file
25
node_modules/@actions/core/lib/path-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
||||
* replaced with /.
|
||||
*
|
||||
* @param pth. Path to transform.
|
||||
* @return string Posix path.
|
||||
*/
|
||||
export declare function toPosixPath(pth: string): string;
|
||||
/**
|
||||
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
||||
* replaced with \\.
|
||||
*
|
||||
* @param pth. Path to transform.
|
||||
* @return string Win32 path.
|
||||
*/
|
||||
export declare function toWin32Path(pth: string): string;
|
||||
/**
|
||||
* toPlatformPath converts the given path to a platform-specific path. It does
|
||||
* this by replacing instances of / and \ with the platform-specific path
|
||||
* separator.
|
||||
*
|
||||
* @param pth The path to platformize.
|
||||
* @return string The platform-specific path.
|
||||
*/
|
||||
export declare function toPlatformPath(pth: string): string;
|
||||
58
node_modules/@actions/core/lib/path-utils.js
generated
vendored
Normal file
58
node_modules/@actions/core/lib/path-utils.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
/**
|
||||
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
||||
* replaced with /.
|
||||
*
|
||||
* @param pth. Path to transform.
|
||||
* @return string Posix path.
|
||||
*/
|
||||
function toPosixPath(pth) {
|
||||
return pth.replace(/[\\]/g, '/');
|
||||
}
|
||||
exports.toPosixPath = toPosixPath;
|
||||
/**
|
||||
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
||||
* replaced with \\.
|
||||
*
|
||||
* @param pth. Path to transform.
|
||||
* @return string Win32 path.
|
||||
*/
|
||||
function toWin32Path(pth) {
|
||||
return pth.replace(/[/]/g, '\\');
|
||||
}
|
||||
exports.toWin32Path = toWin32Path;
|
||||
/**
|
||||
* toPlatformPath converts the given path to a platform-specific path. It does
|
||||
* this by replacing instances of / and \ with the platform-specific path
|
||||
* separator.
|
||||
*
|
||||
* @param pth The path to platformize.
|
||||
* @return string The platform-specific path.
|
||||
*/
|
||||
function toPlatformPath(pth) {
|
||||
return pth.replace(/[/\\]/g, path.sep);
|
||||
}
|
||||
exports.toPlatformPath = toPlatformPath;
|
||||
//# sourceMappingURL=path-utils.js.map
|
||||
1
node_modules/@actions/core/lib/path-utils.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/lib/path-utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAE5B;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAFD,kCAEC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC;AAFD,kCAEC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,wCAEC"}
|
||||
202
node_modules/@actions/core/lib/summary.d.ts
generated
vendored
Normal file
202
node_modules/@actions/core/lib/summary.d.ts
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
export declare const SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
|
||||
export declare const SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
|
||||
export declare type SummaryTableRow = (SummaryTableCell | string)[];
|
||||
export interface SummaryTableCell {
|
||||
/**
|
||||
* Cell content
|
||||
*/
|
||||
data: string;
|
||||
/**
|
||||
* Render cell as header
|
||||
* (optional) default: false
|
||||
*/
|
||||
header?: boolean;
|
||||
/**
|
||||
* Number of columns the cell extends
|
||||
* (optional) default: '1'
|
||||
*/
|
||||
colspan?: string;
|
||||
/**
|
||||
* Number of rows the cell extends
|
||||
* (optional) default: '1'
|
||||
*/
|
||||
rowspan?: string;
|
||||
}
|
||||
export interface SummaryImageOptions {
|
||||
/**
|
||||
* The width of the image in pixels. Must be an integer without a unit.
|
||||
* (optional)
|
||||
*/
|
||||
width?: string;
|
||||
/**
|
||||
* The height of the image in pixels. Must be an integer without a unit.
|
||||
* (optional)
|
||||
*/
|
||||
height?: string;
|
||||
}
|
||||
export interface SummaryWriteOptions {
|
||||
/**
|
||||
* Replace all existing content in summary file with buffer contents
|
||||
* (optional) default: false
|
||||
*/
|
||||
overwrite?: boolean;
|
||||
}
|
||||
declare class Summary {
|
||||
private _buffer;
|
||||
private _filePath?;
|
||||
constructor();
|
||||
/**
|
||||
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
|
||||
* Also checks r/w permissions.
|
||||
*
|
||||
* @returns step summary file path
|
||||
*/
|
||||
private filePath;
|
||||
/**
|
||||
* Wraps content in an HTML tag, adding any HTML attributes
|
||||
*
|
||||
* @param {string} tag HTML tag to wrap
|
||||
* @param {string | null} content content within the tag
|
||||
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
|
||||
*
|
||||
* @returns {string} content wrapped in HTML element
|
||||
*/
|
||||
private wrap;
|
||||
/**
|
||||
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
|
||||
*
|
||||
* @param {SummaryWriteOptions} [options] (optional) options for write operation
|
||||
*
|
||||
* @returns {Promise<Summary>} summary instance
|
||||
*/
|
||||
write(options?: SummaryWriteOptions): Promise<Summary>;
|
||||
/**
|
||||
* Clears the summary buffer and wipes the summary file
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
clear(): Promise<Summary>;
|
||||
/**
|
||||
* Returns the current summary buffer as a string
|
||||
*
|
||||
* @returns {string} string of summary buffer
|
||||
*/
|
||||
stringify(): string;
|
||||
/**
|
||||
* If the summary buffer is empty
|
||||
*
|
||||
* @returns {boolen} true if the buffer is empty
|
||||
*/
|
||||
isEmptyBuffer(): boolean;
|
||||
/**
|
||||
* Resets the summary buffer without writing to summary file
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
emptyBuffer(): Summary;
|
||||
/**
|
||||
* Adds raw text to the summary buffer
|
||||
*
|
||||
* @param {string} text content to add
|
||||
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addRaw(text: string, addEOL?: boolean): Summary;
|
||||
/**
|
||||
* Adds the operating system-specific end-of-line marker to the buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addEOL(): Summary;
|
||||
/**
|
||||
* Adds an HTML codeblock to the summary buffer
|
||||
*
|
||||
* @param {string} code content to render within fenced code block
|
||||
* @param {string} lang (optional) language to syntax highlight code
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addCodeBlock(code: string, lang?: string): Summary;
|
||||
/**
|
||||
* Adds an HTML list to the summary buffer
|
||||
*
|
||||
* @param {string[]} items list of items to render
|
||||
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addList(items: string[], ordered?: boolean): Summary;
|
||||
/**
|
||||
* Adds an HTML table to the summary buffer
|
||||
*
|
||||
* @param {SummaryTableCell[]} rows table rows
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addTable(rows: SummaryTableRow[]): Summary;
|
||||
/**
|
||||
* Adds a collapsable HTML details element to the summary buffer
|
||||
*
|
||||
* @param {string} label text for the closed state
|
||||
* @param {string} content collapsable content
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addDetails(label: string, content: string): Summary;
|
||||
/**
|
||||
* Adds an HTML image tag to the summary buffer
|
||||
*
|
||||
* @param {string} src path to the image you to embed
|
||||
* @param {string} alt text description of the image
|
||||
* @param {SummaryImageOptions} options (optional) addition image attributes
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addImage(src: string, alt: string, options?: SummaryImageOptions): Summary;
|
||||
/**
|
||||
* Adds an HTML section heading element
|
||||
*
|
||||
* @param {string} text heading text
|
||||
* @param {number | string} [level=1] (optional) the heading level, default: 1
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addHeading(text: string, level?: number | string): Summary;
|
||||
/**
|
||||
* Adds an HTML thematic break (<hr>) to the summary buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addSeparator(): Summary;
|
||||
/**
|
||||
* Adds an HTML line break (<br>) to the summary buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addBreak(): Summary;
|
||||
/**
|
||||
* Adds an HTML blockquote to the summary buffer
|
||||
*
|
||||
* @param {string} text quote text
|
||||
* @param {string} cite (optional) citation url
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addQuote(text: string, cite?: string): Summary;
|
||||
/**
|
||||
* Adds an HTML anchor tag to the summary buffer
|
||||
*
|
||||
* @param {string} text link text/content
|
||||
* @param {string} href hyperlink
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addLink(text: string, href: string): Summary;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `core.summary`
|
||||
*/
|
||||
export declare const markdownSummary: Summary;
|
||||
export declare const summary: Summary;
|
||||
export {};
|
||||
283
node_modules/@actions/core/lib/summary.js
generated
vendored
Normal file
283
node_modules/@actions/core/lib/summary.js
generated
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
|
||||
const os_1 = require("os");
|
||||
const fs_1 = require("fs");
|
||||
const { access, appendFile, writeFile } = fs_1.promises;
|
||||
exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY';
|
||||
exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary';
|
||||
class Summary {
|
||||
constructor() {
|
||||
this._buffer = '';
|
||||
}
|
||||
/**
|
||||
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
|
||||
* Also checks r/w permissions.
|
||||
*
|
||||
* @returns step summary file path
|
||||
*/
|
||||
filePath() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this._filePath) {
|
||||
return this._filePath;
|
||||
}
|
||||
const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR];
|
||||
if (!pathFromEnv) {
|
||||
throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
|
||||
}
|
||||
try {
|
||||
yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
|
||||
}
|
||||
catch (_a) {
|
||||
throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
|
||||
}
|
||||
this._filePath = pathFromEnv;
|
||||
return this._filePath;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Wraps content in an HTML tag, adding any HTML attributes
|
||||
*
|
||||
* @param {string} tag HTML tag to wrap
|
||||
* @param {string | null} content content within the tag
|
||||
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
|
||||
*
|
||||
* @returns {string} content wrapped in HTML element
|
||||
*/
|
||||
wrap(tag, content, attrs = {}) {
|
||||
const htmlAttrs = Object.entries(attrs)
|
||||
.map(([key, value]) => ` ${key}="${value}"`)
|
||||
.join('');
|
||||
if (!content) {
|
||||
return `<${tag}${htmlAttrs}>`;
|
||||
}
|
||||
return `<${tag}${htmlAttrs}>${content}</${tag}>`;
|
||||
}
|
||||
/**
|
||||
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
|
||||
*
|
||||
* @param {SummaryWriteOptions} [options] (optional) options for write operation
|
||||
*
|
||||
* @returns {Promise<Summary>} summary instance
|
||||
*/
|
||||
write(options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
||||
const filePath = yield this.filePath();
|
||||
const writeFunc = overwrite ? writeFile : appendFile;
|
||||
yield writeFunc(filePath, this._buffer, { encoding: 'utf8' });
|
||||
return this.emptyBuffer();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Clears the summary buffer and wipes the summary file
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
clear() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.emptyBuffer().write({ overwrite: true });
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the current summary buffer as a string
|
||||
*
|
||||
* @returns {string} string of summary buffer
|
||||
*/
|
||||
stringify() {
|
||||
return this._buffer;
|
||||
}
|
||||
/**
|
||||
* If the summary buffer is empty
|
||||
*
|
||||
* @returns {boolen} true if the buffer is empty
|
||||
*/
|
||||
isEmptyBuffer() {
|
||||
return this._buffer.length === 0;
|
||||
}
|
||||
/**
|
||||
* Resets the summary buffer without writing to summary file
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
emptyBuffer() {
|
||||
this._buffer = '';
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds raw text to the summary buffer
|
||||
*
|
||||
* @param {string} text content to add
|
||||
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addRaw(text, addEOL = false) {
|
||||
this._buffer += text;
|
||||
return addEOL ? this.addEOL() : this;
|
||||
}
|
||||
/**
|
||||
* Adds the operating system-specific end-of-line marker to the buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addEOL() {
|
||||
return this.addRaw(os_1.EOL);
|
||||
}
|
||||
/**
|
||||
* Adds an HTML codeblock to the summary buffer
|
||||
*
|
||||
* @param {string} code content to render within fenced code block
|
||||
* @param {string} lang (optional) language to syntax highlight code
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addCodeBlock(code, lang) {
|
||||
const attrs = Object.assign({}, (lang && { lang }));
|
||||
const element = this.wrap('pre', this.wrap('code', code), attrs);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML list to the summary buffer
|
||||
*
|
||||
* @param {string[]} items list of items to render
|
||||
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addList(items, ordered = false) {
|
||||
const tag = ordered ? 'ol' : 'ul';
|
||||
const listItems = items.map(item => this.wrap('li', item)).join('');
|
||||
const element = this.wrap(tag, listItems);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML table to the summary buffer
|
||||
*
|
||||
* @param {SummaryTableCell[]} rows table rows
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addTable(rows) {
|
||||
const tableBody = rows
|
||||
.map(row => {
|
||||
const cells = row
|
||||
.map(cell => {
|
||||
if (typeof cell === 'string') {
|
||||
return this.wrap('td', cell);
|
||||
}
|
||||
const { header, data, colspan, rowspan } = cell;
|
||||
const tag = header ? 'th' : 'td';
|
||||
const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan }));
|
||||
return this.wrap(tag, data, attrs);
|
||||
})
|
||||
.join('');
|
||||
return this.wrap('tr', cells);
|
||||
})
|
||||
.join('');
|
||||
const element = this.wrap('table', tableBody);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds a collapsable HTML details element to the summary buffer
|
||||
*
|
||||
* @param {string} label text for the closed state
|
||||
* @param {string} content collapsable content
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addDetails(label, content) {
|
||||
const element = this.wrap('details', this.wrap('summary', label) + content);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML image tag to the summary buffer
|
||||
*
|
||||
* @param {string} src path to the image you to embed
|
||||
* @param {string} alt text description of the image
|
||||
* @param {SummaryImageOptions} options (optional) addition image attributes
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addImage(src, alt, options) {
|
||||
const { width, height } = options || {};
|
||||
const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height }));
|
||||
const element = this.wrap('img', null, Object.assign({ src, alt }, attrs));
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML section heading element
|
||||
*
|
||||
* @param {string} text heading text
|
||||
* @param {number | string} [level=1] (optional) the heading level, default: 1
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addHeading(text, level) {
|
||||
const tag = `h${level}`;
|
||||
const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag)
|
||||
? tag
|
||||
: 'h1';
|
||||
const element = this.wrap(allowedTag, text);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML thematic break (<hr>) to the summary buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addSeparator() {
|
||||
const element = this.wrap('hr', null);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML line break (<br>) to the summary buffer
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addBreak() {
|
||||
const element = this.wrap('br', null);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML blockquote to the summary buffer
|
||||
*
|
||||
* @param {string} text quote text
|
||||
* @param {string} cite (optional) citation url
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addQuote(text, cite) {
|
||||
const attrs = Object.assign({}, (cite && { cite }));
|
||||
const element = this.wrap('blockquote', text, attrs);
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
/**
|
||||
* Adds an HTML anchor tag to the summary buffer
|
||||
*
|
||||
* @param {string} text link text/content
|
||||
* @param {string} href hyperlink
|
||||
*
|
||||
* @returns {Summary} summary instance
|
||||
*/
|
||||
addLink(text, href) {
|
||||
const element = this.wrap('a', text, { href });
|
||||
return this.addRaw(element).addEOL();
|
||||
}
|
||||
}
|
||||
const _summary = new Summary();
|
||||
/**
|
||||
* @deprecated use `core.summary`
|
||||
*/
|
||||
exports.markdownSummary = _summary;
|
||||
exports.summary = _summary;
|
||||
//# sourceMappingURL=summary.js.map
|
||||
1
node_modules/@actions/core/lib/summary.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/lib/summary.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/@actions/core/lib/utils.d.ts
generated
vendored
9
node_modules/@actions/core/lib/utils.d.ts
generated
vendored
@@ -1,5 +1,14 @@
|
||||
import { AnnotationProperties } from './core';
|
||||
import { CommandProperties } from './command';
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
export declare function toCommandValue(input: any): string;
|
||||
/**
|
||||
*
|
||||
* @param annotationProperties
|
||||
* @returns The command properties to send with the actual annotation command
|
||||
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||||
*/
|
||||
export declare function toCommandProperties(annotationProperties: AnnotationProperties): CommandProperties;
|
||||
|
||||
22
node_modules/@actions/core/lib/utils.js
generated
vendored
22
node_modules/@actions/core/lib/utils.js
generated
vendored
@@ -2,7 +2,7 @@
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toCommandValue = void 0;
|
||||
exports.toCommandProperties = exports.toCommandValue = void 0;
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
@@ -17,4 +17,24 @@ function toCommandValue(input) {
|
||||
return JSON.stringify(input);
|
||||
}
|
||||
exports.toCommandValue = toCommandValue;
|
||||
/**
|
||||
*
|
||||
* @param annotationProperties
|
||||
* @returns The command properties to send with the actual annotation command
|
||||
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||||
*/
|
||||
function toCommandProperties(annotationProperties) {
|
||||
if (!Object.keys(annotationProperties).length) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
title: annotationProperties.title,
|
||||
file: annotationProperties.file,
|
||||
line: annotationProperties.startLine,
|
||||
endLine: annotationProperties.endLine,
|
||||
col: annotationProperties.startColumn,
|
||||
endColumn: annotationProperties.endColumn
|
||||
};
|
||||
}
|
||||
exports.toCommandProperties = toCommandProperties;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
2
node_modules/@actions/core/lib/utils.js.map
generated
vendored
2
node_modules/@actions/core/lib/utils.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;;AAEvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC"}
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;;AAKvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,oBAA0C;IAE1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE;QAC7C,OAAO,EAAE,CAAA;KACV;IAED,OAAO;QACL,KAAK,EAAE,oBAAoB,CAAC,KAAK;QACjC,IAAI,EAAE,oBAAoB,CAAC,IAAI;QAC/B,IAAI,EAAE,oBAAoB,CAAC,SAAS;QACpC,OAAO,EAAE,oBAAoB,CAAC,OAAO;QACrC,GAAG,EAAE,oBAAoB,CAAC,WAAW;QACrC,SAAS,EAAE,oBAAoB,CAAC,SAAS;KAC1C,CAAA;AACH,CAAC;AAfD,kDAeC"}
|
||||
21
node_modules/@actions/core/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
21
node_modules/@actions/core/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
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.
|
||||
73
node_modules/@actions/core/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
73
node_modules/@actions/core/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# `@actions/http-client`
|
||||
|
||||
A lightweight HTTP client optimized for building actions.
|
||||
|
||||
## Features
|
||||
|
||||
- HTTP client with TypeScript generics and async/await/Promises
|
||||
- Typings included!
|
||||
- [Proxy support](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners#using-a-proxy-server-with-self-hosted-runners) just works with actions and the runner
|
||||
- Targets ES2019 (runner runs actions with node 12+). Only supported on node 12+.
|
||||
- Basic, Bearer and PAT Support out of the box. Extensible handlers for others.
|
||||
- Redirects supported
|
||||
|
||||
Features and releases [here](./RELEASES.md)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install @actions/http-client --save
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
See the [tests](./__tests__) for detailed examples.
|
||||
|
||||
## Errors
|
||||
|
||||
### HTTP
|
||||
|
||||
The HTTP client does not throw unless truly exceptional.
|
||||
|
||||
* A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
|
||||
* Redirects (3xx) will be followed by default.
|
||||
|
||||
See the [tests](./__tests__) for detailed examples.
|
||||
|
||||
## Debugging
|
||||
|
||||
To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:
|
||||
|
||||
```shell
|
||||
export NODE_DEBUG=http
|
||||
```
|
||||
|
||||
## Node support
|
||||
|
||||
The http-client is built using the latest LTS version of Node 12. It may work on previous node LTS versions but it's tested and officially supported on Node12+.
|
||||
|
||||
## Support and Versioning
|
||||
|
||||
We follow semver and will hold compatibility between major versions and increment the minor version with new features and capabilities (while holding compat).
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome PRs. Please create an issue and if applicable, a design before proceeding with code.
|
||||
|
||||
once:
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
To build:
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
To run all tests:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
26
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.d.ts
generated
vendored
Normal file
26
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/// <reference types="node" />
|
||||
import * as http from 'http';
|
||||
import * as ifm from './interfaces';
|
||||
import { HttpClientResponse } from './index';
|
||||
export declare class BasicCredentialHandler implements ifm.RequestHandler {
|
||||
username: string;
|
||||
password: string;
|
||||
constructor(username: string, password: string);
|
||||
prepareRequest(options: http.RequestOptions): void;
|
||||
canHandleAuthentication(): boolean;
|
||||
handleAuthentication(): Promise<HttpClientResponse>;
|
||||
}
|
||||
export declare class BearerCredentialHandler implements ifm.RequestHandler {
|
||||
token: string;
|
||||
constructor(token: string);
|
||||
prepareRequest(options: http.RequestOptions): void;
|
||||
canHandleAuthentication(): boolean;
|
||||
handleAuthentication(): Promise<HttpClientResponse>;
|
||||
}
|
||||
export declare class PersonalAccessTokenCredentialHandler implements ifm.RequestHandler {
|
||||
token: string;
|
||||
constructor(token: string);
|
||||
prepareRequest(options: http.RequestOptions): void;
|
||||
canHandleAuthentication(): boolean;
|
||||
handleAuthentication(): Promise<HttpClientResponse>;
|
||||
}
|
||||
81
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.js
generated
vendored
Normal file
81
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
||||
class BasicCredentialHandler {
|
||||
constructor(username, password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
prepareRequest(options) {
|
||||
if (!options.headers) {
|
||||
throw Error('The request has no headers');
|
||||
}
|
||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication() {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
throw new Error('not implemented');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||
class BearerCredentialHandler {
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
}
|
||||
// currently implements pre-authorization
|
||||
// TODO: support preAuth = false where it hooks on 401
|
||||
prepareRequest(options) {
|
||||
if (!options.headers) {
|
||||
throw Error('The request has no headers');
|
||||
}
|
||||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication() {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
throw new Error('not implemented');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||
class PersonalAccessTokenCredentialHandler {
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
}
|
||||
// currently implements pre-authorization
|
||||
// TODO: support preAuth = false where it hooks on 401
|
||||
prepareRequest(options) {
|
||||
if (!options.headers) {
|
||||
throw Error('The request has no headers');
|
||||
}
|
||||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication() {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
throw new Error('not implemented');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||
//# sourceMappingURL=auth.js.map
|
||||
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,MAAa,sBAAsB;IAIjC,YAAY,QAAgB,EAAE,QAAgB;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,cAAc,CAAC,OAA4B;QACzC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QACD,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,MAAM,CAAC,IAAI,CACrD,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CACpC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;IACxB,CAAC;IAED,iCAAiC;IACjC,uBAAuB;QACrB,OAAO,KAAK,CAAA;IACd,CAAC;IAEK,oBAAoB;;YACxB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACpC,CAAC;KAAA;CACF;AA1BD,wDA0BC;AAED,MAAa,uBAAuB;IAGlC,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,yCAAyC;IACzC,sDAAsD;IACtD,cAAc,CAAC,OAA4B;QACzC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QACD,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,EAAE,CAAA;IAC3D,CAAC;IAED,iCAAiC;IACjC,uBAAuB;QACrB,OAAO,KAAK,CAAA;IACd,CAAC;IAEK,oBAAoB;;YACxB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACpC,CAAC;KAAA;CACF;AAxBD,0DAwBC;AAED,MAAa,oCAAoC;IAI/C,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,yCAAyC;IACzC,sDAAsD;IACtD,cAAc,CAAC,OAA4B;QACzC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QACD,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,MAAM,CAAC,IAAI,CACrD,OAAO,IAAI,CAAC,KAAK,EAAE,CACpB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;IACxB,CAAC;IAED,iCAAiC;IACjC,uBAAuB;QACrB,OAAO,KAAK,CAAA;IACd,CAAC;IAEK,oBAAoB;;YACxB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACpC,CAAC;KAAA;CACF;AA3BD,oFA2BC"}
|
||||
123
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.d.ts
generated
vendored
Normal file
123
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/// <reference types="node" />
|
||||
import * as http from 'http';
|
||||
import * as ifm from './interfaces';
|
||||
export declare enum HttpCodes {
|
||||
OK = 200,
|
||||
MultipleChoices = 300,
|
||||
MovedPermanently = 301,
|
||||
ResourceMoved = 302,
|
||||
SeeOther = 303,
|
||||
NotModified = 304,
|
||||
UseProxy = 305,
|
||||
SwitchProxy = 306,
|
||||
TemporaryRedirect = 307,
|
||||
PermanentRedirect = 308,
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
PaymentRequired = 402,
|
||||
Forbidden = 403,
|
||||
NotFound = 404,
|
||||
MethodNotAllowed = 405,
|
||||
NotAcceptable = 406,
|
||||
ProxyAuthenticationRequired = 407,
|
||||
RequestTimeout = 408,
|
||||
Conflict = 409,
|
||||
Gone = 410,
|
||||
TooManyRequests = 429,
|
||||
InternalServerError = 500,
|
||||
NotImplemented = 501,
|
||||
BadGateway = 502,
|
||||
ServiceUnavailable = 503,
|
||||
GatewayTimeout = 504
|
||||
}
|
||||
export declare enum Headers {
|
||||
Accept = "accept",
|
||||
ContentType = "content-type"
|
||||
}
|
||||
export declare enum MediaTypes {
|
||||
ApplicationJson = "application/json"
|
||||
}
|
||||
/**
|
||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
export declare function getProxyUrl(serverUrl: string): string;
|
||||
export declare class HttpClientError extends Error {
|
||||
constructor(message: string, statusCode: number);
|
||||
statusCode: number;
|
||||
result?: any;
|
||||
}
|
||||
export declare class HttpClientResponse {
|
||||
constructor(message: http.IncomingMessage);
|
||||
message: http.IncomingMessage;
|
||||
readBody(): Promise<string>;
|
||||
}
|
||||
export declare function isHttps(requestUrl: string): boolean;
|
||||
export declare class HttpClient {
|
||||
userAgent: string | undefined;
|
||||
handlers: ifm.RequestHandler[];
|
||||
requestOptions: ifm.RequestOptions | undefined;
|
||||
private _ignoreSslError;
|
||||
private _socketTimeout;
|
||||
private _allowRedirects;
|
||||
private _allowRedirectDowngrade;
|
||||
private _maxRedirects;
|
||||
private _allowRetries;
|
||||
private _maxRetries;
|
||||
private _agent;
|
||||
private _proxyAgent;
|
||||
private _keepAlive;
|
||||
private _disposed;
|
||||
constructor(userAgent?: string, handlers?: ifm.RequestHandler[], requestOptions?: ifm.RequestOptions);
|
||||
options(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
get(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
del(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
post(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
patch(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
put(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
head(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
/**
|
||||
* Gets a typed object from an endpoint
|
||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||
*/
|
||||
getJson<T>(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<ifm.TypedResponse<T>>;
|
||||
postJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<ifm.TypedResponse<T>>;
|
||||
putJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<ifm.TypedResponse<T>>;
|
||||
patchJson<T>(requestUrl: string, obj: any, additionalHeaders?: http.OutgoingHttpHeaders): Promise<ifm.TypedResponse<T>>;
|
||||
/**
|
||||
* Makes a raw http request.
|
||||
* All other methods such as get, post, patch, and request ultimately call this.
|
||||
* Prefer get, del, post and patch
|
||||
*/
|
||||
request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream | null, headers?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
/**
|
||||
* Needs to be called if keepAlive is set to true in request options.
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* Raw request.
|
||||
* @param info
|
||||
* @param data
|
||||
*/
|
||||
requestRaw(info: ifm.RequestInfo, data: string | NodeJS.ReadableStream | null): Promise<HttpClientResponse>;
|
||||
/**
|
||||
* Raw request with callback.
|
||||
* @param info
|
||||
* @param data
|
||||
* @param onResult
|
||||
*/
|
||||
requestRawWithCallback(info: ifm.RequestInfo, data: string | NodeJS.ReadableStream | null, onResult: (err?: Error, res?: HttpClientResponse) => void): void;
|
||||
/**
|
||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl: string): http.Agent;
|
||||
private _prepareRequest;
|
||||
private _mergeHeaders;
|
||||
private _getExistingOrDefaultHeader;
|
||||
private _getAgent;
|
||||
private _performExponentialBackoff;
|
||||
private _processResponse;
|
||||
}
|
||||
605
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js
generated
vendored
Normal file
605
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,605 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
||||
const http = __importStar(require("http"));
|
||||
const https = __importStar(require("https"));
|
||||
const pm = __importStar(require("./proxy"));
|
||||
const tunnel = __importStar(require("tunnel"));
|
||||
var HttpCodes;
|
||||
(function (HttpCodes) {
|
||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
||||
var Headers;
|
||||
(function (Headers) {
|
||||
Headers["Accept"] = "accept";
|
||||
Headers["ContentType"] = "content-type";
|
||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
||||
var MediaTypes;
|
||||
(function (MediaTypes) {
|
||||
MediaTypes["ApplicationJson"] = "application/json";
|
||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
||||
/**
|
||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
function getProxyUrl(serverUrl) {
|
||||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||
return proxyUrl ? proxyUrl.href : '';
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
const HttpRedirectCodes = [
|
||||
HttpCodes.MovedPermanently,
|
||||
HttpCodes.ResourceMoved,
|
||||
HttpCodes.SeeOther,
|
||||
HttpCodes.TemporaryRedirect,
|
||||
HttpCodes.PermanentRedirect
|
||||
];
|
||||
const HttpResponseRetryCodes = [
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
HttpCodes.GatewayTimeout
|
||||
];
|
||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||
const ExponentialBackoffCeiling = 10;
|
||||
const ExponentialBackoffTimeSlice = 5;
|
||||
class HttpClientError extends Error {
|
||||
constructor(message, statusCode) {
|
||||
super(message);
|
||||
this.name = 'HttpClientError';
|
||||
this.statusCode = statusCode;
|
||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||||
}
|
||||
}
|
||||
exports.HttpClientError = HttpClientError;
|
||||
class HttpClientResponse {
|
||||
constructor(message) {
|
||||
this.message = message;
|
||||
}
|
||||
readBody() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||||
let output = Buffer.alloc(0);
|
||||
this.message.on('data', (chunk) => {
|
||||
output = Buffer.concat([output, chunk]);
|
||||
});
|
||||
this.message.on('end', () => {
|
||||
resolve(output.toString());
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.HttpClientResponse = HttpClientResponse;
|
||||
function isHttps(requestUrl) {
|
||||
const parsedUrl = new URL(requestUrl);
|
||||
return parsedUrl.protocol === 'https:';
|
||||
}
|
||||
exports.isHttps = isHttps;
|
||||
class HttpClient {
|
||||
constructor(userAgent, handlers, requestOptions) {
|
||||
this._ignoreSslError = false;
|
||||
this._allowRedirects = true;
|
||||
this._allowRedirectDowngrade = false;
|
||||
this._maxRedirects = 50;
|
||||
this._allowRetries = false;
|
||||
this._maxRetries = 1;
|
||||
this._keepAlive = false;
|
||||
this._disposed = false;
|
||||
this.userAgent = userAgent;
|
||||
this.handlers = handlers || [];
|
||||
this.requestOptions = requestOptions;
|
||||
if (requestOptions) {
|
||||
if (requestOptions.ignoreSslError != null) {
|
||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
||||
}
|
||||
this._socketTimeout = requestOptions.socketTimeout;
|
||||
if (requestOptions.allowRedirects != null) {
|
||||
this._allowRedirects = requestOptions.allowRedirects;
|
||||
}
|
||||
if (requestOptions.allowRedirectDowngrade != null) {
|
||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
||||
}
|
||||
if (requestOptions.maxRedirects != null) {
|
||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
||||
}
|
||||
if (requestOptions.keepAlive != null) {
|
||||
this._keepAlive = requestOptions.keepAlive;
|
||||
}
|
||||
if (requestOptions.allowRetries != null) {
|
||||
this._allowRetries = requestOptions.allowRetries;
|
||||
}
|
||||
if (requestOptions.maxRetries != null) {
|
||||
this._maxRetries = requestOptions.maxRetries;
|
||||
}
|
||||
}
|
||||
}
|
||||
options(requestUrl, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
get(requestUrl, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
del(requestUrl, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
post(requestUrl, data, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
patch(requestUrl, data, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
put(requestUrl, data, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
head(requestUrl, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||
});
|
||||
}
|
||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets a typed object from an endpoint
|
||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||
*/
|
||||
getJson(requestUrl, additionalHeaders = {}) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
const res = yield this.get(requestUrl, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
});
|
||||
}
|
||||
postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
});
|
||||
}
|
||||
putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
});
|
||||
}
|
||||
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Makes a raw http request.
|
||||
* All other methods such as get, post, patch, and request ultimately call this.
|
||||
* Prefer get, del, post and patch
|
||||
*/
|
||||
request(verb, requestUrl, data, headers) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this._disposed) {
|
||||
throw new Error('Client has already been disposed.');
|
||||
}
|
||||
const parsedUrl = new URL(requestUrl);
|
||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||
// Only perform retries on reads since writes may not be idempotent.
|
||||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
||||
? this._maxRetries + 1
|
||||
: 1;
|
||||
let numTries = 0;
|
||||
let response;
|
||||
do {
|
||||
response = yield this.requestRaw(info, data);
|
||||
// Check if it's an authentication challenge
|
||||
if (response &&
|
||||
response.message &&
|
||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
let authenticationHandler;
|
||||
for (const handler of this.handlers) {
|
||||
if (handler.canHandleAuthentication(response)) {
|
||||
authenticationHandler = handler;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (authenticationHandler) {
|
||||
return authenticationHandler.handleAuthentication(this, info, data);
|
||||
}
|
||||
else {
|
||||
// We have received an unauthorized response but have no handlers to handle it.
|
||||
// Let the response return to the caller.
|
||||
return response;
|
||||
}
|
||||
}
|
||||
let redirectsRemaining = this._maxRedirects;
|
||||
while (response.message.statusCode &&
|
||||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
||||
this._allowRedirects &&
|
||||
redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers['location'];
|
||||
if (!redirectUrl) {
|
||||
// if there's no location to redirect to, we won't
|
||||
break;
|
||||
}
|
||||
const parsedRedirectUrl = new URL(redirectUrl);
|
||||
if (parsedUrl.protocol === 'https:' &&
|
||||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
||||
!this._allowRedirectDowngrade) {
|
||||
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
||||
}
|
||||
// we need to finish reading the response before reassigning response
|
||||
// which will leak the open socket.
|
||||
yield response.readBody();
|
||||
// strip authorization header if redirected to a different hostname
|
||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||
for (const header in headers) {
|
||||
// header names are case insensitive
|
||||
if (header.toLowerCase() === 'authorization') {
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
}
|
||||
// let's make the request with the new redirectUrl
|
||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||
response = yield this.requestRaw(info, data);
|
||||
redirectsRemaining--;
|
||||
}
|
||||
if (!response.message.statusCode ||
|
||||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
||||
// If not a retry code, return immediately instead of retrying
|
||||
return response;
|
||||
}
|
||||
numTries += 1;
|
||||
if (numTries < maxTries) {
|
||||
yield response.readBody();
|
||||
yield this._performExponentialBackoff(numTries);
|
||||
}
|
||||
} while (numTries < maxTries);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Needs to be called if keepAlive is set to true in request options.
|
||||
*/
|
||||
dispose() {
|
||||
if (this._agent) {
|
||||
this._agent.destroy();
|
||||
}
|
||||
this._disposed = true;
|
||||
}
|
||||
/**
|
||||
* Raw request.
|
||||
* @param info
|
||||
* @param data
|
||||
*/
|
||||
requestRaw(info, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
function callbackForResult(err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else if (!res) {
|
||||
// If `err` is not passed, then `res` must be passed.
|
||||
reject(new Error('Unknown error'));
|
||||
}
|
||||
else {
|
||||
resolve(res);
|
||||
}
|
||||
}
|
||||
this.requestRawWithCallback(info, data, callbackForResult);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Raw request with callback.
|
||||
* @param info
|
||||
* @param data
|
||||
* @param onResult
|
||||
*/
|
||||
requestRawWithCallback(info, data, onResult) {
|
||||
if (typeof data === 'string') {
|
||||
if (!info.options.headers) {
|
||||
info.options.headers = {};
|
||||
}
|
||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||
}
|
||||
let callbackCalled = false;
|
||||
function handleResult(err, res) {
|
||||
if (!callbackCalled) {
|
||||
callbackCalled = true;
|
||||
onResult(err, res);
|
||||
}
|
||||
}
|
||||
const req = info.httpModule.request(info.options, (msg) => {
|
||||
const res = new HttpClientResponse(msg);
|
||||
handleResult(undefined, res);
|
||||
});
|
||||
let socket;
|
||||
req.on('socket', sock => {
|
||||
socket = sock;
|
||||
});
|
||||
// If we ever get disconnected, we want the socket to timeout eventually
|
||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
||||
if (socket) {
|
||||
socket.end();
|
||||
}
|
||||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
||||
});
|
||||
req.on('error', function (err) {
|
||||
// err has statusCode property
|
||||
// res should have headers
|
||||
handleResult(err);
|
||||
});
|
||||
if (data && typeof data === 'string') {
|
||||
req.write(data, 'utf8');
|
||||
}
|
||||
if (data && typeof data !== 'string') {
|
||||
data.on('close', function () {
|
||||
req.end();
|
||||
});
|
||||
data.pipe(req);
|
||||
}
|
||||
else {
|
||||
req.end();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl) {
|
||||
const parsedUrl = new URL(serverUrl);
|
||||
return this._getAgent(parsedUrl);
|
||||
}
|
||||
_prepareRequest(method, requestUrl, headers) {
|
||||
const info = {};
|
||||
info.parsedUrl = requestUrl;
|
||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
||||
info.httpModule = usingSsl ? https : http;
|
||||
const defaultPort = usingSsl ? 443 : 80;
|
||||
info.options = {};
|
||||
info.options.host = info.parsedUrl.hostname;
|
||||
info.options.port = info.parsedUrl.port
|
||||
? parseInt(info.parsedUrl.port)
|
||||
: defaultPort;
|
||||
info.options.path =
|
||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||
info.options.method = method;
|
||||
info.options.headers = this._mergeHeaders(headers);
|
||||
if (this.userAgent != null) {
|
||||
info.options.headers['user-agent'] = this.userAgent;
|
||||
}
|
||||
info.options.agent = this._getAgent(info.parsedUrl);
|
||||
// gives handlers an opportunity to participate
|
||||
if (this.handlers) {
|
||||
for (const handler of this.handlers) {
|
||||
handler.prepareRequest(info.options);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
_mergeHeaders(headers) {
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
||||
}
|
||||
return lowercaseKeys(headers || {});
|
||||
}
|
||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||
let clientHeader;
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||
}
|
||||
return additionalHeaders[header] || clientHeader || _default;
|
||||
}
|
||||
_getAgent(parsedUrl) {
|
||||
let agent;
|
||||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||
const useProxy = proxyUrl && proxyUrl.hostname;
|
||||
if (this._keepAlive && useProxy) {
|
||||
agent = this._proxyAgent;
|
||||
}
|
||||
if (this._keepAlive && !useProxy) {
|
||||
agent = this._agent;
|
||||
}
|
||||
// if agent is already assigned use that agent.
|
||||
if (agent) {
|
||||
return agent;
|
||||
}
|
||||
const usingSsl = parsedUrl.protocol === 'https:';
|
||||
let maxSockets = 100;
|
||||
if (this.requestOptions) {
|
||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||
}
|
||||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
||||
if (proxyUrl && proxyUrl.hostname) {
|
||||
const agentOptions = {
|
||||
maxSockets,
|
||||
keepAlive: this._keepAlive,
|
||||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
||||
};
|
||||
let tunnelAgent;
|
||||
const overHttps = proxyUrl.protocol === 'https:';
|
||||
if (usingSsl) {
|
||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
||||
}
|
||||
else {
|
||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
||||
}
|
||||
agent = tunnelAgent(agentOptions);
|
||||
this._proxyAgent = agent;
|
||||
}
|
||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||
if (this._keepAlive && !agent) {
|
||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||
this._agent = agent;
|
||||
}
|
||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
||||
if (!agent) {
|
||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
||||
}
|
||||
if (usingSsl && this._ignoreSslError) {
|
||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||
// we have to cast it to any and change it directly
|
||||
agent.options = Object.assign(agent.options || {}, {
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
_performExponentialBackoff(retryNumber) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||
});
|
||||
}
|
||||
_processResponse(res, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||
const statusCode = res.message.statusCode || 0;
|
||||
const response = {
|
||||
statusCode,
|
||||
result: null,
|
||||
headers: {}
|
||||
};
|
||||
// not found leads to null obj returned
|
||||
if (statusCode === HttpCodes.NotFound) {
|
||||
resolve(response);
|
||||
}
|
||||
// get the result from the body
|
||||
function dateTimeDeserializer(key, value) {
|
||||
if (typeof value === 'string') {
|
||||
const a = new Date(value);
|
||||
if (!isNaN(a.valueOf())) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
let obj;
|
||||
let contents;
|
||||
try {
|
||||
contents = yield res.readBody();
|
||||
if (contents && contents.length > 0) {
|
||||
if (options && options.deserializeDates) {
|
||||
obj = JSON.parse(contents, dateTimeDeserializer);
|
||||
}
|
||||
else {
|
||||
obj = JSON.parse(contents);
|
||||
}
|
||||
response.result = obj;
|
||||
}
|
||||
response.headers = res.message.headers;
|
||||
}
|
||||
catch (err) {
|
||||
// Invalid resource (contents not json); leaving result obj null
|
||||
}
|
||||
// note that 3xx redirects are handled by the http layer.
|
||||
if (statusCode > 299) {
|
||||
let msg;
|
||||
// if exception/error in body, attempt to get better error
|
||||
if (obj && obj.message) {
|
||||
msg = obj.message;
|
||||
}
|
||||
else if (contents && contents.length > 0) {
|
||||
// it may be the case that the exception is in the body message as string
|
||||
msg = contents;
|
||||
}
|
||||
else {
|
||||
msg = `Failed request: (${statusCode})`;
|
||||
}
|
||||
const err = new HttpClientError(msg, statusCode);
|
||||
err.result = response.result;
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(response);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.HttpClient = HttpClient;
|
||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.d.ts
generated
vendored
Normal file
44
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/// <reference types="node" />
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import { HttpClientResponse } from './index';
|
||||
export interface HttpClient {
|
||||
options(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
get(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
del(requestUrl: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
post(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
patch(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
put(requestUrl: string, data: string, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream, headers: http.OutgoingHttpHeaders): Promise<HttpClientResponse>;
|
||||
requestRaw(info: RequestInfo, data: string | NodeJS.ReadableStream): Promise<HttpClientResponse>;
|
||||
requestRawWithCallback(info: RequestInfo, data: string | NodeJS.ReadableStream, onResult: (err?: Error, res?: HttpClientResponse) => void): void;
|
||||
}
|
||||
export interface RequestHandler {
|
||||
prepareRequest(options: http.RequestOptions): void;
|
||||
canHandleAuthentication(response: HttpClientResponse): boolean;
|
||||
handleAuthentication(httpClient: HttpClient, requestInfo: RequestInfo, data: string | NodeJS.ReadableStream | null): Promise<HttpClientResponse>;
|
||||
}
|
||||
export interface RequestInfo {
|
||||
options: http.RequestOptions;
|
||||
parsedUrl: URL;
|
||||
httpModule: typeof http | typeof https;
|
||||
}
|
||||
export interface RequestOptions {
|
||||
headers?: http.OutgoingHttpHeaders;
|
||||
socketTimeout?: number;
|
||||
ignoreSslError?: boolean;
|
||||
allowRedirects?: boolean;
|
||||
allowRedirectDowngrade?: boolean;
|
||||
maxRedirects?: number;
|
||||
maxSockets?: number;
|
||||
keepAlive?: boolean;
|
||||
deserializeDates?: boolean;
|
||||
allowRetries?: boolean;
|
||||
maxRetries?: number;
|
||||
}
|
||||
export interface TypedResponse<T> {
|
||||
statusCode: number;
|
||||
result: T | null;
|
||||
headers: http.IncomingHttpHeaders;
|
||||
}
|
||||
3
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.js
generated
vendored
Normal file
3
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=interfaces.js.map
|
||||
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/interfaces.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
||||
2
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.d.ts
generated
vendored
Normal file
2
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function getProxyUrl(reqUrl: URL): URL | undefined;
|
||||
export declare function checkBypass(reqUrl: URL): boolean;
|
||||
61
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.js
generated
vendored
Normal file
61
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkBypass = exports.getProxyUrl = void 0;
|
||||
function getProxyUrl(reqUrl) {
|
||||
const usingSsl = reqUrl.protocol === 'https:';
|
||||
if (checkBypass(reqUrl)) {
|
||||
return undefined;
|
||||
}
|
||||
const proxyVar = (() => {
|
||||
if (usingSsl) {
|
||||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||
}
|
||||
else {
|
||||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||
}
|
||||
})();
|
||||
if (proxyVar) {
|
||||
return new URL(proxyVar);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
function checkBypass(reqUrl) {
|
||||
if (!reqUrl.hostname) {
|
||||
return false;
|
||||
}
|
||||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||
if (!noProxy) {
|
||||
return false;
|
||||
}
|
||||
// Determine the request port
|
||||
let reqPort;
|
||||
if (reqUrl.port) {
|
||||
reqPort = Number(reqUrl.port);
|
||||
}
|
||||
else if (reqUrl.protocol === 'http:') {
|
||||
reqPort = 80;
|
||||
}
|
||||
else if (reqUrl.protocol === 'https:') {
|
||||
reqPort = 443;
|
||||
}
|
||||
// Format the request hostname and hostname with port
|
||||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||
if (typeof reqPort === 'number') {
|
||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||
}
|
||||
// Compare request host against noproxy
|
||||
for (const upperNoProxyItem of noProxy
|
||||
.split(',')
|
||||
.map(x => x.trim().toUpperCase())
|
||||
.filter(x => x)) {
|
||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.checkBypass = checkBypass;
|
||||
//# sourceMappingURL=proxy.js.map
|
||||
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,MAAW;IACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAA;IAE7C,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;QACvB,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE;QACrB,IAAI,QAAQ,EAAE;YACZ,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;SAChE;aAAM;YACL,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;SAC9D;IACH,CAAC,CAAC,EAAE,CAAA;IAEJ,IAAI,QAAQ,EAAE;QACZ,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;KACzB;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AApBD,kCAoBC;AAED,SAAgB,WAAW,CAAC,MAAW;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,OAAO,KAAK,CAAA;KACb;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;IACxE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,KAAK,CAAA;KACb;IAED,6BAA6B;IAC7B,IAAI,OAA2B,CAAA;IAC/B,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;KAC9B;SAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE;QACtC,OAAO,GAAG,EAAE,CAAA;KACb;SAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACvC,OAAO,GAAG,GAAG,CAAA;KACd;IAED,qDAAqD;IACrD,MAAM,aAAa,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAA;KACrD;IAED,uCAAuC;IACvC,KAAK,MAAM,gBAAgB,IAAI,OAAO;SACnC,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAChC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACjB,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,gBAAgB,CAAC,EAAE;YACnD,OAAO,IAAI,CAAA;SACZ;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AArCD,kCAqCC"}
|
||||
48
node_modules/@actions/core/node_modules/@actions/http-client/package.json
generated
vendored
Normal file
48
node_modules/@actions/core/node_modules/@actions/http-client/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "@actions/http-client",
|
||||
"version": "2.0.1",
|
||||
"description": "Actions Http Client",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"http"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/http-client",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"!.DS_Store"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/toolkit.git",
|
||||
"directory": "packages/http-client"
|
||||
},
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"build": "tsc",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/tunnel": "0.0.3",
|
||||
"proxy": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
}
|
||||
9
node_modules/@actions/core/package.json
generated
vendored
9
node_modules/@actions/core/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@actions/core",
|
||||
"version": "1.4.0",
|
||||
"version": "1.10.0",
|
||||
"description": "Actions core lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
@@ -35,7 +35,12 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.2"
|
||||
"@types/node": "^12.0.2",
|
||||
"@types/uuid": "^8.3.4"
|
||||
}
|
||||
}
|
||||
|
||||
278
node_modules/@iarna/toml/CHANGELOG.md
generated
vendored
Executable file
278
node_modules/@iarna/toml/CHANGELOG.md
generated
vendored
Executable file
@@ -0,0 +1,278 @@
|
||||
# 2.2.5
|
||||
|
||||
* Docs: Updated benchmark results. Add fast-toml to result list. Improved benchmark layout.
|
||||
* Update @sgarciac/bombadil and @ltd/j-toml in benchmarks and compliance tests.
|
||||
* Dev: Some dev dep updates that shouldn't have any impact.
|
||||
|
||||
# 2.2.4
|
||||
|
||||
* Bug fix: Plain date literals (not datetime) immediately followed by another statement (no whitespace or blank line) would crash. Fixes [#19](https://github.com/iarna/iarna-toml/issues/19) and [#23](https://github.com/iarna/iarna-toml/issues/23), thank you [@arnau](https://github.com/arnau) and [@jschaf](https://github.com/jschaf) for reporting this!
|
||||
* Bug fix: Hex literals with lowercase Es would throw errors. (Thank you [@DaeCatt](https://github.com/DaeCatt) for this fix!) Fixed [#20](https://github.com/iarna/iarna-toml/issues/20)
|
||||
* Some minor doc tweaks
|
||||
* Added Node 12 and 13 to Travis. (Node 6 is failing there now, mysteriously. It works on my machine™, shipping anyway. 🙃)
|
||||
|
||||
# 2.2.3
|
||||
|
||||
This release just updates the spec compliance tests and benchmark data to
|
||||
better represent @ltd/j-toml.
|
||||
|
||||
# 2.2.2
|
||||
|
||||
## Fixes
|
||||
|
||||
* Support parsing and stringifying objects with `__proto__` properties. ([@LongTengDao](https://github.com/LongTengDao))
|
||||
|
||||
## Misc
|
||||
|
||||
* Updates for spec compliance and benchmarking:
|
||||
* @sgarciac/bombadil -> 2.1.0
|
||||
* toml -> 3.0.0
|
||||
* Added spec compliance and benchmarking for:
|
||||
* @ltd/j-toml
|
||||
|
||||
# 2.2.1
|
||||
|
||||
## Fixes
|
||||
|
||||
* Fix bug where keys with names matching javascript Object methods would
|
||||
error. Thanks [@LongTengDao](https://github.com/LongTengDao) for finding this!
|
||||
* Fix bug where a bundled version would fail if `util.inspect` wasn't
|
||||
provided. This was supposed to be guarded against, but there was a bug in
|
||||
the guard. Thanks [@agriffis](https://github.com/agriffis) for finding and fixing this!
|
||||
|
||||
## Misc
|
||||
|
||||
* Update the version of bombadil for spec compliance and benchmarking purposes to 2.0.0
|
||||
|
||||
## Did you know?
|
||||
|
||||
Node 6 and 8 are measurably slower than Node 6, 10 and 11, at least when it comes to parsing TOML!
|
||||
|
||||

|
||||
|
||||
# 2.2.0
|
||||
|
||||
## Features
|
||||
|
||||
* Typescript: Lots of improvements to our type definitions, many many to
|
||||
[@jorgegonzalez](https://github.com/jorgegonzalez) and [@momocow](https://github.com/momocow) for working through these.
|
||||
|
||||
## Fixes
|
||||
|
||||
* Very large integers (>52bit) are stored as BigInts on runtimes that
|
||||
support them. BigInts are 128bits, but the TOML spec limits its integers
|
||||
to 64bits. We now limit our integers to 64bits
|
||||
as well.
|
||||
* Fix a bug in stringify where control characters were being emitted as unicode chars and not escape sequences.
|
||||
|
||||
## Misc
|
||||
|
||||
* Moved our spec tests out to an external repo
|
||||
* Improved the styling of the spec compliance comparison
|
||||
|
||||
# 2.1.1
|
||||
|
||||
## Fixes
|
||||
|
||||
* Oops, type defs didn't end up in the tarball, ty [@jorgegonzalez](https://github.com/jorgegonzalez)‼
|
||||
|
||||
# 2.1.0
|
||||
|
||||
## Features
|
||||
|
||||
* Types for typescript support, thank you [@momocow](https://github.com/momocow)!
|
||||
|
||||
## Fixes
|
||||
|
||||
* stringify: always strip invalid dates. This fixes a bug where an
|
||||
invalid date in an inline array would not be removed and would instead
|
||||
result in an error.
|
||||
* stringify: if an invalid type is found make sure it's thrown as an
|
||||
error object. Previously the type name was, unhelpfully, being thrown.
|
||||
* stringify: Multiline strings ending in a quote would generate invalid TOML.
|
||||
* parse: Error if a signed integer has a leading zero, eg, `-01` or `+01`.
|
||||
* parse: Error if \_ appears at the end of the integer part of a float, eg `1_.0`. \_ is only valid between _digits_.
|
||||
|
||||
## Fun
|
||||
|
||||
* BurntSushi's comprehensive TOML 0.4.0 test suite is now used in addition to our existing test suite.
|
||||
* You can see exactly how the other JS TOML libraries stack up in testing
|
||||
against both BurntSushi's tests and my own in the new
|
||||
[TOML-SPEC-SUPPORT](TOML-SPEC-SUPPORT.md) doc.
|
||||
|
||||
# 2.0.0
|
||||
|
||||
With 2.0.0, @iarna/toml supports the TOML v0.5.0 specification. TOML 0.5.0
|
||||
brings some changes:
|
||||
|
||||
* Delete characters (U+007F) are not allowed in plain strings. You can include them with
|
||||
escaped unicode characters, eg `\u007f`.
|
||||
* Integers are specified as being 64bit unsigned values. These are
|
||||
supported using `BigInt`s if you are using Node 10 or later.
|
||||
* Keys may be literal strings, that is, you can use single quoted strings to
|
||||
quote key names, so the following is now valid:
|
||||
'a"b"c' = 123
|
||||
* The floating point values `nan`, `inf` and `-inf` are supported. The stringifier will no
|
||||
longer strip NaN, Infinity and -Infinity, instead serializing them as these new values..
|
||||
* Datetimes can separate the date and time with a space instead of a T, so
|
||||
`2017-12-01T00:00:00Z` can be written as `2017-12-01 00:00:00Z`.
|
||||
* Datetimes can be floating, that is, they can be represented without a timezone.
|
||||
These are represented in javascript as Date objects whose `isFloating` property is true and
|
||||
whose `toISOString` method will return a representation without a timezone.
|
||||
* Dates without times are now supported. Dates do not have timezones. Dates
|
||||
are represented in javascript as a Date object whose `isDate` property is true and
|
||||
whose `toISOString` method returns just the date.
|
||||
* Times without dates are now supported. Times do not have timezones. Times
|
||||
are represented in javascript as a Date object whose `isTime` property is true and
|
||||
whose `toISOString` method returns just the time.
|
||||
* Keys can now include dots to directly address deeper structures, so `a.b = 23` is
|
||||
the equivalent of `a = {b = 23}` or ```[a]
|
||||
b = 23```. These can be used both as keys to regular tables and inline tables.
|
||||
* Integers can now be specified in binary, octal and hexadecimal by prefixing the
|
||||
number with `0b`, `0o` and `0x` respectively. It is now illegal to left
|
||||
pad a decimal value with zeros.
|
||||
|
||||
Some parser details were also fixed:
|
||||
|
||||
* Negative zero (`-0.0`) and positive zero (`0.0`) are distinct floating point values.
|
||||
* Negative integer zero (`-0`) is not distinguished from positive zero (`0`).
|
||||
|
||||
# 1.7.1
|
||||
|
||||
Another 18% speed boost on our overall benchmarks! This time it came from
|
||||
switching from string comparisons to integer by converting each character to
|
||||
its respective code point. This also necessitated rewriting the boolean
|
||||
parser to actually parse character-by-character as it should. End-of-stream
|
||||
is now marked with a numeric value outside of the Unicode range, rather than
|
||||
a Symbol, meaning that the parser's char property is now monomorphic.
|
||||
|
||||
Bug fix, previously, `'abc''def'''` was accepted (as the value: `abcdef`).
|
||||
Now it will correctly raise an error.
|
||||
|
||||
Spec tests now run against bombadil as well (it fails some, which is unsurprising
|
||||
given its incomplete state).
|
||||
|
||||
# 1.7.0
|
||||
|
||||
This release features an overall 15% speed boost on our benchmarks. This
|
||||
came from a few things:
|
||||
|
||||
* Date parsing was rewritten to not use regexps, resulting in a huge speed increase.
|
||||
* Strings of all kinds and bare keywords now use tight loops to collect characters when this will help.
|
||||
* Regexps in general were mostly removed. This didn't result in a speed
|
||||
change, but it did allow refactoring the parser to be a lot easier to
|
||||
follow.
|
||||
* The internal state tracking now uses a class and is constructed with a
|
||||
fixed set of properties, allowing v8's optimizer to be more effective.
|
||||
|
||||
In the land of new features:
|
||||
|
||||
* Errors in the syntax of your TOML will now have the `fromTOML` property
|
||||
set to true. This is in addition to the `line`, `col` and `pos`
|
||||
properties they already have.
|
||||
|
||||
The main use of this is to make it possible to distinguish between errors
|
||||
in the TOML and errors in the parser code itself. This is of particular utility
|
||||
when testing parse errors.
|
||||
|
||||
# 1.6.0
|
||||
|
||||
**FIXES**
|
||||
|
||||
* TOML.stringify: Allow toJSON properties that aren't functions, to align with JSON.stringify's behavior.
|
||||
* TOML.stringify: Don't use ever render keys as literal strings.
|
||||
* TOML.stringify: Don't try to escape control characters in literal strings.
|
||||
|
||||
**FEATURES**
|
||||
|
||||
* New Export: TOML.stringify.value, for encoding a stand alone inline value as TOML would. This produces
|
||||
a TOML fragment, not a complete valid document.
|
||||
|
||||
# 1.5.6
|
||||
|
||||
* String literals are NOT supported as key names.
|
||||
* Accessing a shallower table after accessing it more deeply is ok and no longer crashes, eg:
|
||||
```toml
|
||||
[a.b]
|
||||
[a]
|
||||
```
|
||||
* Unicode characters in the reserved range now crash.
|
||||
* Empty bare keys, eg `[.abc]` or `[]` now crash.
|
||||
* Multiline backslash trimming supports CRs.
|
||||
* Multiline post quote trimming supports CRs.
|
||||
* Strings may not contain bare control chars (0x00-0x1f), except for \n, \r and \t.
|
||||
|
||||
# 1.5.5
|
||||
|
||||
* Yet MORE README fixes. 🙃
|
||||
|
||||
# 1.5.4
|
||||
|
||||
* README fix
|
||||
|
||||
# 1.5.3
|
||||
|
||||
* Benchmarks!
|
||||
* More tests!
|
||||
* More complete LICENSE information (some dev files are from other, MIT
|
||||
licensed, projects, this is now more explicitly documented.)
|
||||
|
||||
# 1.5.2
|
||||
|
||||
* parse: Arrays with mixed types now throw errors, per the spec.
|
||||
* parse: Fix a parser bug that would result in errors when trying to parse arrays of numbers or dates
|
||||
that were not separated by a space from the closing ].
|
||||
* parse: Fix a bug in the error pretty printer that resulted in errors on
|
||||
the first line not getting the pretty print treatment.
|
||||
* stringify: Fix long standing bug where an array of Numbers, some of which required
|
||||
decimals, would be emitted in a way that parsers would treat as mixed
|
||||
Integer and Float values. Now if any Numbers in an array must be
|
||||
represented with a decimal then all will be emitted such that parsers will
|
||||
understand them to be Float.
|
||||
|
||||
# 1.5.1
|
||||
|
||||
* README fix
|
||||
|
||||
# 1.5.0
|
||||
|
||||
* A brand new TOML parser, from scratch, that performs like `toml-j0.4`
|
||||
without the crashes and with vastly better error messages.
|
||||
* 100% test coverage for both the new parser and the existing stringifier. Some subtle bugs squashed!
|
||||
|
||||
# v1.4.2
|
||||
|
||||
* Revert fallback due to its having issues with the same files. (New plan
|
||||
will be to write my own.)
|
||||
|
||||
# v1.4.1
|
||||
|
||||
* Depend on both `toml` and `toml-j0.4` with fallback from the latter to the
|
||||
former when the latter crashes.
|
||||
|
||||
# v1.4.0
|
||||
|
||||
* Ducktype dates to make them compatible with `moment` and other `Date` replacements.
|
||||
|
||||
# v1.3.1
|
||||
|
||||
* Update docs with new toml module.
|
||||
|
||||
# v1.3.0
|
||||
|
||||
* Switch from `toml` to `toml-j0.4`, which is between 20x and 200x faster.
|
||||
(The larger the input, the faster it is compared to `toml`).
|
||||
|
||||
# v1.2.0
|
||||
|
||||
* Return null when passed in null as the top level object.
|
||||
* Detect and skip invalid dates and numbers
|
||||
|
||||
# v1.1.0
|
||||
|
||||
* toJSON transformations are now honored (for everything except Date objects, as JSON represents them as strings).
|
||||
* Undefined/null values no longer result in exceptions, they now just result in the associated key being elided.
|
||||
|
||||
# v1.0.1
|
||||
|
||||
* Initial release
|
||||
14
node_modules/@iarna/toml/LICENSE
generated
vendored
Executable file
14
node_modules/@iarna/toml/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
Copyright (c) 2016, Rebecca Turner <me@re-becca.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
301
node_modules/@iarna/toml/README.md
generated
vendored
Executable file
301
node_modules/@iarna/toml/README.md
generated
vendored
Executable file
@@ -0,0 +1,301 @@
|
||||
# @iarna/toml
|
||||
|
||||
Better TOML parsing and stringifying all in that familiar JSON interface.
|
||||
|
||||
[](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
# ** TOML 0.5.0 **
|
||||
|
||||
### TOML Spec Support
|
||||
|
||||
The most recent version as of 2018-07-26: [v0.5.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.5.0.md)
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
const TOML = require('@iarna/toml')
|
||||
const obj = TOML.parse(`[abc]
|
||||
foo = 123
|
||||
bar = [1,2,3]`)
|
||||
/* obj =
|
||||
{abc: {foo: 123, bar: [1,2,3]}}
|
||||
*/
|
||||
const str = TOML.stringify(obj)
|
||||
/* str =
|
||||
[abc]
|
||||
foo = 123
|
||||
bar = [ 1, 2, 3 ]
|
||||
*/
|
||||
```
|
||||
|
||||
Visit the project github [for more examples](https://github.com/iarna/iarna-toml/tree/latest/examples)!
|
||||
|
||||
|
||||
## Why @iarna/toml
|
||||
|
||||
* See [TOML-SPEC-SUPPORT](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html)
|
||||
for a comparison of which TOML features are supported by the various
|
||||
Node.js TOML parsers.
|
||||
* BigInt support on Node 10!
|
||||
* 100% test coverage.
|
||||
* Fast parsing. It's as much as 100 times
|
||||
faster than `toml` and 3 times faster than `toml-j0.4`. However a recent
|
||||
newcomer [`@ltd/j-toml`](https://www.npmjs.com/package/@ltd/j-toml) has
|
||||
appeared with 0.5 support and astoundingly fast parsing speeds for large
|
||||
text blocks. All I can say is you'll have to test your specific work loads
|
||||
if you want to know which of @iarna/toml and @ltd/j-toml is faster for
|
||||
you, as we currently excell in different areas.
|
||||
* Careful adherence to spec. Tests go beyond simple coverage.
|
||||
* Smallest parser bundle (if you use `@iarna/toml/parse-string`).
|
||||
* No deps.
|
||||
* Detailed and easy to read error messages‼
|
||||
|
||||
```console
|
||||
> TOML.parse(src)
|
||||
Error: Unexpected character, expecting string, number, datetime, boolean, inline array or inline table at row 6, col 5, pos 87:
|
||||
5: "abc\"" = { abc=123,def="abc" }
|
||||
6> foo=sdkfj
|
||||
^
|
||||
7:
|
||||
```
|
||||
|
||||
## TOML.parse(str) → Object [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-string')`
|
||||
|
||||
Synchronously parse a TOML string and return an object.
|
||||
|
||||
|
||||
## TOML.stringify(obj) → String [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/stringify.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify)`
|
||||
|
||||
Serialize an object as TOML.
|
||||
|
||||
## [your-object].toJSON
|
||||
|
||||
If an object `TOML.stringify` is serializing has a `toJSON` method then it
|
||||
will call it to transform the object before serializing it. This matches
|
||||
the behavior of `JSON.stringify`.
|
||||
|
||||
The one exception to this is that `toJSON` is not called for `Date` objects
|
||||
because `JSON` represents dates as strings and TOML can represent them natively.
|
||||
|
||||
[`moment`](https://www.npmjs.com/package/moment) objects are treated the
|
||||
same as native `Date` objects, in this respect.
|
||||
|
||||
## TOML.stringify.value(obj) -> String
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify').value`
|
||||
|
||||
Serialize a value as TOML would. This is a fragment and not a complete
|
||||
valid TOML document.
|
||||
|
||||
## Promises and Streaming
|
||||
|
||||
The parser provides alternative async and streaming interfaces, for times
|
||||
that you're working with really absurdly big TOML files and don't want to
|
||||
tie-up the event loop while it parses.
|
||||
|
||||
### TOML.parse.async(str[, opts]) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-async.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-async')`
|
||||
|
||||
`opts.blocksize` is the amount text to parser per pass through the event loop. Defaults to 40kb.
|
||||
|
||||
Asynchronously parse a TOML string and return a promise of the resulting object.
|
||||
|
||||
### TOML.parse.stream(readable) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-readable.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
|
||||
|
||||
### readable.pipe(TOML.parse.stream()) → Transform [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-through.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Returns a transform stream in object mode. When it completes, emit the
|
||||
resulting object. Only one object will ever be emitted.
|
||||
|
||||
## Lowlevel Interface [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel.js) [(example w/ parser debugging)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel-debug.js)
|
||||
|
||||
You construct a parser object, per TOML file you want to process:
|
||||
|
||||
```js
|
||||
const TOMLParser = require('@iarna/toml/lib/toml-parser.js')
|
||||
const parser = new TOMLParser()
|
||||
```
|
||||
|
||||
Then you call the `parse` method for each chunk as you read them, or in a
|
||||
single call:
|
||||
|
||||
```js
|
||||
parser.parse(`hello = 'world'`)
|
||||
```
|
||||
|
||||
And finally, you call the `finish` method to complete parsing and retrieve
|
||||
the resulting object.
|
||||
|
||||
```js
|
||||
const data = parser.finish()
|
||||
```
|
||||
|
||||
Both the `parse` method and `finish` method will throw if they find a
|
||||
problem with the string they were given. Error objects thrown from the
|
||||
parser have `pos`, `line` and `col` attributes. `TOML.parse` adds a visual
|
||||
summary of where in the source string there were issues using
|
||||
`parse-pretty-error` and you can too:
|
||||
|
||||
```js
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
const newErr = prettyError(err, sourceString)
|
||||
```
|
||||
|
||||
## What's Different
|
||||
|
||||
Version 2 of this module supports TOML 0.5.0. Other modules currently
|
||||
published to the npm registry support 0.4.0. 0.5.0 is mostly backwards
|
||||
compatible with 0.4.0, but if you have need, you can install @iarna/toml@1
|
||||
to get a version of this module that supports 0.4.0. Please see the
|
||||
[CHANGELOG](CHANGELOG.md#2.0.0) for details on exactly whats changed.
|
||||
|
||||
## TOML we can't do
|
||||
|
||||
* `-nan` is a valid TOML value and is converted into `NaN`. There is no way to
|
||||
produce `-nan` when stringifying. Stringification will produce positive `nan`.
|
||||
* Detecting and erroring on invalid utf8 documents: This is because Node's
|
||||
UTF8 processing converts invalid sequences into the placeholder character
|
||||
and does not have facilities for reporting these as errors instead. We
|
||||
_can_ detect the placeholder character, but it's valid to intentionally
|
||||
include them in documents, so erroring on them is not great.
|
||||
* On versions of Node < 10, very large Integer values will lose precision.
|
||||
On Node >=10, bigints are used.
|
||||
* Floating/local dates and times are still represented by JavaScript Date
|
||||
objects, which don't actually support these concepts. The objects
|
||||
returned have been modified so that you can determine what kind of thing
|
||||
they are (with `isFloating`, `isDate`, `isTime` properties) and that
|
||||
their ISO representation (via `toISOString`) is representative of their
|
||||
TOML value. They will correctly round trip if you pass them to
|
||||
`TOML.stringify`.
|
||||
* Binary, hexadecimal and octal values are converted to ordinary integers and
|
||||
will be decimal if you stringify them.
|
||||
|
||||
## Changes
|
||||
|
||||
I write a by hand, honest-to-god,
|
||||
[CHANGELOG](https://github.com/iarna/iarna-toml/blob/latest/CHANGELOG.md)
|
||||
for this project. It's a description of what went into a release that you
|
||||
the consumer of the module could care about, not a list of git commits, so
|
||||
please check it out!
|
||||
|
||||
## Benchmarks
|
||||
|
||||
You can run them yourself with:
|
||||
|
||||
```console
|
||||
$ npm run benchmark
|
||||
```
|
||||
|
||||
The results below are from my desktop using Node 13.13.0. The library
|
||||
versions tested were `@iarna/toml@2.2.4`, `toml-j0.4@1.1.1`, `toml@3.0.0`,
|
||||
`@sgarciac/bombadil@2.3.0`, `@ltd/j-toml@0.5.107`, and `fast-toml@0.5.4`. The speed value is
|
||||
megabytes-per-second that the parser can process of that document type.
|
||||
Bigger is better. The percentage after average results is the margin of error.
|
||||
|
||||
New here is fast-toml. fast-toml is very fast, for some datatypes, but it
|
||||
also is missing most error checking demanded by the spec. For 0.4, it is
|
||||
complete except for detail of multiline strings caught by the compliance
|
||||
tests. Its support for 0.5 is incomplete. Check out the
|
||||
[spec compliance](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html) doc
|
||||
for details.
|
||||
|
||||
As this table is getting a little wide, with how npm and github display it,
|
||||
you can also view it seperately in the
|
||||
[BENCHMARK](https://shared.by.re-becca.org/misc/BENCHMARK.html) document.
|
||||
|
||||
| | @iarna/<wbr>toml | toml-j0.4 | toml | @sgarciac/<wbr>bombadil | @ltd/<wbr>j-toml | fast-toml |
|
||||
| - | :---------: | :-------: | :--: | :----------------: | :---------: | :-------: |
|
||||
| **Overall** | 28MB/sec<br><small>0.35%</small> | 6.5MB/sec<br><small>0.25%</small> | 0.2MB/sec<br><small>0.70%</small> | - | 35MB/sec<br><small>0.23%</small> | - |
|
||||
| **Spec Example: v0.4.0** | 26MB/sec<br><small>0.37%</small> | 10MB/sec<br><small>0.27%</small> | 1MB/sec<br><small>0.42%</small> | 1.2MB/sec<br><small>0.95%</small> | 28MB/sec<br><small>0.31%</small> | - |
|
||||
| **Spec Example: Hard Unicode** | 64MB/sec<br><small>0.59%</small> | 18MB/sec<br><small>0.12%</small> | 2MB/sec<br><small>0.20%</small> | 0.6MB/sec<br><small>0.53%</small> | 68MB/sec<br><small>0.31%</small> | 78MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Array, Inline** | 7.3MB/sec<br><small>0.60%</small> | 4MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>0.91%</small> | 1.3MB/sec<br><small>0.81%</small> | 10MB/sec<br><small>0.35%</small> | 9MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Array** | 6.8MB/sec<br><small>0.19%</small> | 6.7MB/sec<br><small>0.15%</small> | 0.2MB/sec<br><small>0.79%</small> | 1.2MB/sec<br><small>0.93%</small> | 8.8MB/sec<br><small>0.47%</small> | 27MB/sec<br><small>0.21%</small> |
|
||||
| **Types: Boolean,** | 21MB/sec<br><small>0.20%</small> | 9.4MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>0.96%</small> | 1.8MB/sec<br><small>0.70%</small> | 16MB/sec<br><small>0.20%</small> | 8.4MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Datetime** | 18MB/sec<br><small>0.14%</small> | 11MB/sec<br><small>0.15%</small> | 0.3MB/sec<br><small>0.85%</small> | 1.6MB/sec<br><small>0.45%</small> | 9.8MB/sec<br><small>0.48%</small> | 6.5MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Float** | 8.8MB/sec<br><small>0.09%</small> | 5.9MB/sec<br><small>0.14%</small> | 0.2MB/sec<br><small>0.51%</small> | 2.1MB/sec<br><small>0.82%</small> | 14MB/sec<br><small>0.15%</small> | 7.9MB/sec<br><small>0.14%</small> |
|
||||
| **Types: Int** | 5.9MB/sec<br><small>0.11%</small> | 4.5MB/sec<br><small>0.28%</small> | 0.1MB/sec<br><small>0.78%</small> | 1.5MB/sec<br><small>0.64%</small> | 10MB/sec<br><small>0.14%</small> | 8MB/sec<br><small>0.17%</small> |
|
||||
| **Types: Literal String, 7 char** | 26MB/sec<br><small>0.29%</small> | 8.5MB/sec<br><small>0.32%</small> | 0.3MB/sec<br><small>0.84%</small> | 2.3MB/sec<br><small>1.02%</small> | 23MB/sec<br><small>0.15%</small> | 13MB/sec<br><small>0.15%</small> |
|
||||
| **Types: Literal String, 92 char** | 46MB/sec<br><small>0.19%</small> | 11MB/sec<br><small>0.20%</small> | 0.3MB/sec<br><small>0.56%</small> | 12MB/sec<br><small>0.92%</small> | 101MB/sec<br><small>0.17%</small> | 75MB/sec<br><small>0.29%</small> |
|
||||
| **Types: Literal String, Multiline, 1079 char** | 22MB/sec<br><small>0.42%</small> | 6.7MB/sec<br><small>0.55%</small> | 0.9MB/sec<br><small>0.78%</small> | 44MB/sec<br><small>1.00%</small> | 350MB/sec<br><small>0.16%</small> | 636MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Basic String, 7 char** | 25MB/sec<br><small>0.15%</small> | 7.3MB/sec<br><small>0.18%</small> | 0.2MB/sec<br><small>0.96%</small> | 2.2MB/sec<br><small>1.09%</small> | 14MB/sec<br><small>0.16%</small> | 12MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Basic String, 92 char** | 43MB/sec<br><small>0.30%</small> | 7.2MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>4.04%</small> | 12MB/sec<br><small>1.33%</small> | 71MB/sec<br><small>0.19%</small> | 70MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Basic String, 1079 char** | 24MB/sec<br><small>0.45%</small> | 5.8MB/sec<br><small>0.17%</small> | 0.1MB/sec<br><small>3.64%</small> | 44MB/sec<br><small>1.05%</small> | 93MB/sec<br><small>0.29%</small> | 635MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Table, Inline** | 9.7MB/sec<br><small>0.10%</small> | 5.5MB/sec<br><small>0.22%</small> | 0.1MB/sec<br><small>0.87%</small> | 1.4MB/sec<br><small>1.18%</small> | 8.7MB/sec<br><small>0.60%</small> | 8.7MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Table** | 7.1MB/sec<br><small>0.14%</small> | 5.6MB/sec<br><small>0.42%</small> | 0.1MB/sec<br><small>0.65%</small> | 1.4MB/sec<br><small>1.11%</small> | 7.4MB/sec<br><small>0.70%</small> | 18MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Array, Inline, 1000 elements** | 40MB/sec<br><small>0.21%</small> | 2.4MB/sec<br><small>0.19%</small> | 0.1MB/sec<br><small>0.35%</small> | 1.6MB/sec<br><small>1.02%</small> | 17MB/sec<br><small>0.15%</small> | 32MB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Array, Nested, 1000 deep** | 2MB/sec<br><small>0.15%</small> | 1.7MB/sec<br><small>0.26%</small> | 0.3MB/sec<br><small>0.58%</small> | - | 1.8MB/sec<br><small>0.74%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Literal String, 40kb** | 61MB/sec<br><small>0.18%</small> | 10MB/sec<br><small>0.15%</small> | 3MB/sec<br><small>0.84%</small> | 12MB/sec<br><small>0.51%</small> | 551MB/sec<br><small>0.44%</small> | 19kMB/sec<br><small>0.19%</small> |
|
||||
| **Scaling: Literal String, Multiline, 40kb** | 62MB/sec<br><small>0.16%</small> | 5MB/sec<br><small>0.45%</small> | 0.2MB/sec<br><small>1.70%</small> | 11MB/sec<br><small>0.74%</small> | 291MB/sec<br><small>0.24%</small> | 21kMB/sec<br><small>0.22%</small> |
|
||||
| **Scaling: Basic String, Multiline, 40kb** | 62MB/sec<br><small>0.18%</small> | 5.8MB/sec<br><small>0.38%</small> | 2.9MB/sec<br><small>0.86%</small> | 11MB/sec<br><small>0.41%</small> | 949MB/sec<br><small>0.44%</small> | 26kMB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Basic String, 40kb** | 59MB/sec<br><small>0.20%</small> | 6.3MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>1.95%</small> | 12MB/sec<br><small>0.44%</small> | 508MB/sec<br><small>0.35%</small> | 18kMB/sec<br><small>0.15%</small> |
|
||||
| **Scaling: Table, Inline, 1000 elements** | 28MB/sec<br><small>0.12%</small> | 8.2MB/sec<br><small>0.19%</small> | 0.3MB/sec<br><small>0.89%</small> | 2.3MB/sec<br><small>1.14%</small> | 5.3MB/sec<br><small>0.24%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Table, Inline, Nested, 1000 deep** | 7.8MB/sec<br><small>0.28%</small> | 5MB/sec<br><small>0.20%</small> | 0.1MB/sec<br><small>0.84%</small> | - | 3.2MB/sec<br><small>0.52%</small> | 10MB/sec<br><small>0.23%</small> |
|
||||
|
||||
## Tests
|
||||
|
||||
The test suite is maintained at 100% coverage: [](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
The spec was carefully hand converted into a series of test framework
|
||||
independent (and mostly language independent) assertions, as pairs of TOML
|
||||
and YAML files. You can find those files here:
|
||||
[spec-test](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test/).
|
||||
A number of examples of invalid Unicode were also written, but are difficult
|
||||
to make use of in Node.js where Unicode errors are silently hidden. You can
|
||||
find those here: [spec-test-disabled](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test-disabled/).
|
||||
|
||||
Further tests were written to increase coverage to 100%, these may be more
|
||||
implementation specific, but they can be found in [coverage](https://github.com/iarna/iarna-toml/blob/latest/test/coverage.js) and
|
||||
[coverage-error](https://github.com/iarna/iarna-toml/blob/latest/test/coverage-error.js).
|
||||
|
||||
I've also written some quality assurance style tests, which don't contribute
|
||||
to coverage but do cover scenarios that could easily be problematic for some
|
||||
implementations can be found in:
|
||||
[test/qa.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa.js) and
|
||||
[test/qa-error.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa-error.js).
|
||||
|
||||
All of the official example files from the TOML spec are run through this
|
||||
parser and compared to the official YAML files when available. These files are from the TOML spec as of:
|
||||
[357a4ba6](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc)
|
||||
and specifically are:
|
||||
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/examples](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/examples)
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/tests](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/tests)
|
||||
|
||||
The stringifier is tested by round-tripping these same files, asserting that
|
||||
`TOML.parse(sourcefile)` deepEqual
|
||||
`TOML.parse(TOML.stringify(TOML.parse(sourcefile))`. This is done in
|
||||
[test/roundtrip-examples.js](https://github.com/iarna/iarna-toml/blob/latest/test/round-tripping.js)
|
||||
There are also some tests written to complete coverage from stringification in:
|
||||
[test/stringify.js](https://github.com/iarna/iarna-toml/blob/latest/test/stringify.js)
|
||||
|
||||
Tests for the async and streaming interfaces are in [test/async.js](https://github.com/iarna/iarna-toml/blob/latest/test/async.js) and [test/stream.js](https://github.com/iarna/iarna-toml/blob/latest/test/stream.js) respectively.
|
||||
|
||||
Tests for the parsers debugging mode live in [test/devel.js](https://github.com/iarna/iarna-toml/blob/latest/test/devel.js).
|
||||
|
||||
And finally, many more stringification tests were borrowed from [@othiym23](https://github.com/othiym23)'s
|
||||
[toml-stream](https://npmjs.com/package/toml-stream) module. They were fetched as of
|
||||
[b6f1e26b572d49742d49fa6a6d11524d003441fa](https://github.com/othiym23/toml-stream/tree/b6f1e26b572d49742d49fa6a6d11524d003441fa/test) and live in
|
||||
[test/toml-stream](https://github.com/iarna/iarna-toml/blob/latest/test/toml-stream/).
|
||||
|
||||
## Improvements to make
|
||||
|
||||
* In stringify:
|
||||
* Any way to produce comments. As a JSON stand-in I'm not too worried
|
||||
about this. That said, a document orientated fork is something I'd like
|
||||
to look at eventually…
|
||||
* Stringification could use some work on its error reporting. It reports
|
||||
_what's_ wrong, but not where in your data structure it was.
|
||||
* Further optimize the parser:
|
||||
* There are some debugging assertions left in the main parser, these should be moved to a subclass.
|
||||
* Make the whole debugging parser thing work as a mixin instead of as a superclass.
|
||||
57
node_modules/@iarna/toml/index.d.ts
generated
vendored
Executable file
57
node_modules/@iarna/toml/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,57 @@
|
||||
import { Transform } from "stream";
|
||||
|
||||
type JsonArray = boolean[] | number[] | string[] | JsonMap[] | Date[]
|
||||
type AnyJson = boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]
|
||||
|
||||
interface JsonMap {
|
||||
[key: string]: AnyJson;
|
||||
}
|
||||
|
||||
interface ParseOptions {
|
||||
/**
|
||||
* The amount text to parser per pass through the event loop. Defaults to 40kb (`40000`).
|
||||
*/
|
||||
blocksize: number
|
||||
}
|
||||
|
||||
interface FuncParse {
|
||||
/**
|
||||
* Synchronously parse a TOML string and return an object.
|
||||
*/
|
||||
(toml: string): JsonMap
|
||||
|
||||
/**
|
||||
* Asynchronously parse a TOML string and return a promise of the resulting object.
|
||||
*/
|
||||
async (toml: string, options?: ParseOptions): Promise<JsonMap>
|
||||
|
||||
/**
|
||||
* Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
|
||||
*/
|
||||
stream (readable: NodeJS.ReadableStream): Promise<JsonMap>
|
||||
stream (): Transform
|
||||
}
|
||||
|
||||
interface FuncStringify {
|
||||
/**
|
||||
* Serialize an object as TOML.
|
||||
*
|
||||
* If an object `TOML.stringify` is serializing has a `toJSON` method
|
||||
* then it will call it to transform the object before serializing it.
|
||||
* This matches the behavior of JSON.stringify.
|
||||
*
|
||||
* The one exception to this is that `toJSON` is not called for `Date` objects
|
||||
* because JSON represents dates as strings and TOML can represent them natively.
|
||||
*
|
||||
* `moment` objects are treated the same as native `Date` objects, in this respect.
|
||||
*/
|
||||
(obj: JsonMap): string
|
||||
|
||||
/**
|
||||
* Serialize a value as TOML would. This is a fragment and not a complete valid TOML document.
|
||||
*/
|
||||
value (any: AnyJson): string
|
||||
}
|
||||
|
||||
export const parse: FuncParse
|
||||
export const stringify: FuncStringify
|
||||
23
node_modules/@iarna/toml/lib/create-date.js
generated
vendored
Executable file
23
node_modules/@iarna/toml/lib/create-date.js
generated
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
const DateTime = global.Date
|
||||
|
||||
class Date extends DateTime {
|
||||
constructor (value) {
|
||||
super(value)
|
||||
this.isDate = true
|
||||
}
|
||||
toISOString () {
|
||||
return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new Date(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
24
node_modules/@iarna/toml/lib/create-datetime-float.js
generated
vendored
Executable file
24
node_modules/@iarna/toml/lib/create-datetime-float.js
generated
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
|
||||
class FloatingDateTime extends Date {
|
||||
constructor (value) {
|
||||
super(value + 'Z')
|
||||
this.isFloating = true
|
||||
}
|
||||
toISOString () {
|
||||
const date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
|
||||
const time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
|
||||
return `${date}T${time}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new FloatingDateTime(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
10
node_modules/@iarna/toml/lib/create-datetime.js
generated
vendored
Executable file
10
node_modules/@iarna/toml/lib/create-datetime.js
generated
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
'use strict'
|
||||
module.exports = value => {
|
||||
const date = new Date(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
22
node_modules/@iarna/toml/lib/create-time.js
generated
vendored
Executable file
22
node_modules/@iarna/toml/lib/create-time.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
|
||||
class Time extends Date {
|
||||
constructor (value) {
|
||||
super(`0000-01-01T${value}Z`)
|
||||
this.isTime = true
|
||||
}
|
||||
toISOString () {
|
||||
return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new Time(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
6
node_modules/@iarna/toml/lib/format-num.js
generated
vendored
Executable file
6
node_modules/@iarna/toml/lib/format-num.js
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
module.exports = (d, num) => {
|
||||
num = String(num)
|
||||
while (num.length < d) num = '0' + num
|
||||
return num
|
||||
}
|
||||
60
node_modules/@iarna/toml/lib/parser-debug.js
generated
vendored
Executable file
60
node_modules/@iarna/toml/lib/parser-debug.js
generated
vendored
Executable file
@@ -0,0 +1,60 @@
|
||||
'use strict'
|
||||
const Parser = require('./parser.js')
|
||||
const util = require('util')
|
||||
|
||||
const dump = _ => util.inspect(_, {colors: true, depth: 10, breakLength: Infinity})
|
||||
class DebugParser extends Parser {
|
||||
stateName (state) {
|
||||
// istanbul ignore next
|
||||
return (state.parser && state.parser.name) || state.name || ('anonymous')
|
||||
}
|
||||
runOne () {
|
||||
const callStack = this.stack.concat(this.state).map(_ => this.stateName(_)).join(' <- ')
|
||||
console.log('RUN', callStack, dump({line: this.line, col: this.col, char: this.char, ret: this.state.returned}))
|
||||
return super.runOne()
|
||||
}
|
||||
finish () {
|
||||
const obj = super.finish()
|
||||
// istanbul ignore if
|
||||
if (this.stack.length !== 0) {
|
||||
throw new Parser.Error('All states did not return by end of stream')
|
||||
}
|
||||
return obj
|
||||
}
|
||||
callStack () {
|
||||
const callStack = this.stack.map(_ => this.stateName(_)).join(' ').replace(/\S/g, ' ')
|
||||
return callStack ? callStack + ' ' : ''
|
||||
}
|
||||
next (fn) {
|
||||
console.log(' ', this.callStack(), 'NEXT', this.stateName(fn))
|
||||
return super.next(fn)
|
||||
}
|
||||
goto (fn) {
|
||||
console.log(' ', this.callStack(), 'GOTO', this.stateName(fn))
|
||||
super.next(fn)
|
||||
return false
|
||||
}
|
||||
call (fn, returnWith) {
|
||||
console.log(' ', this.callStack(), 'CALL', fn.name, returnWith ? '-> ' + returnWith.name : '')
|
||||
if (returnWith) super.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = {parser: fn, buf: '', returned: null}
|
||||
}
|
||||
callNow (fn, returnWith) {
|
||||
console.log(' ', this.callStack(), 'CALLNOW', fn.name, returnWith ? '-> ' + returnWith.name : '')
|
||||
if (returnWith) super.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = {parser: fn, buf: '', returned: null}
|
||||
return false
|
||||
}
|
||||
return (value) {
|
||||
console.log(' ', this.callStack(), 'RETURN')
|
||||
return super.return(value)
|
||||
}
|
||||
returnNow (value) {
|
||||
console.log(' ', this.callStack(), 'RETURNNOW')
|
||||
super.return(value)
|
||||
return false
|
||||
}
|
||||
}
|
||||
module.exports = DebugParser
|
||||
127
node_modules/@iarna/toml/lib/parser.js
generated
vendored
Executable file
127
node_modules/@iarna/toml/lib/parser.js
generated
vendored
Executable file
@@ -0,0 +1,127 @@
|
||||
'use strict'
|
||||
const ParserEND = 0x110000
|
||||
class ParserError extends Error {
|
||||
/* istanbul ignore next */
|
||||
constructor (msg, filename, linenumber) {
|
||||
super('[ParserError] ' + msg, filename, linenumber)
|
||||
this.name = 'ParserError'
|
||||
this.code = 'ParserError'
|
||||
if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError)
|
||||
}
|
||||
}
|
||||
class State {
|
||||
constructor (parser) {
|
||||
this.parser = parser
|
||||
this.buf = ''
|
||||
this.returned = null
|
||||
this.result = null
|
||||
this.resultTable = null
|
||||
this.resultArr = null
|
||||
}
|
||||
}
|
||||
class Parser {
|
||||
constructor () {
|
||||
this.pos = 0
|
||||
this.col = 0
|
||||
this.line = 0
|
||||
this.obj = {}
|
||||
this.ctx = this.obj
|
||||
this.stack = []
|
||||
this._buf = ''
|
||||
this.char = null
|
||||
this.ii = 0
|
||||
this.state = new State(this.parseStart)
|
||||
}
|
||||
|
||||
parse (str) {
|
||||
/* istanbul ignore next */
|
||||
if (str.length === 0 || str.length == null) return
|
||||
|
||||
this._buf = String(str)
|
||||
this.ii = -1
|
||||
this.char = -1
|
||||
let getNext
|
||||
while (getNext === false || this.nextChar()) {
|
||||
getNext = this.runOne()
|
||||
}
|
||||
this._buf = null
|
||||
}
|
||||
nextChar () {
|
||||
if (this.char === 0x0A) {
|
||||
++this.line
|
||||
this.col = -1
|
||||
}
|
||||
++this.ii
|
||||
this.char = this._buf.codePointAt(this.ii)
|
||||
++this.pos
|
||||
++this.col
|
||||
return this.haveBuffer()
|
||||
}
|
||||
haveBuffer () {
|
||||
return this.ii < this._buf.length
|
||||
}
|
||||
runOne () {
|
||||
return this.state.parser.call(this, this.state.returned)
|
||||
}
|
||||
finish () {
|
||||
this.char = ParserEND
|
||||
let last
|
||||
do {
|
||||
last = this.state.parser
|
||||
this.runOne()
|
||||
} while (this.state.parser !== last)
|
||||
|
||||
this.ctx = null
|
||||
this.state = null
|
||||
this._buf = null
|
||||
|
||||
return this.obj
|
||||
}
|
||||
next (fn) {
|
||||
/* istanbul ignore next */
|
||||
if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn))
|
||||
this.state.parser = fn
|
||||
}
|
||||
goto (fn) {
|
||||
this.next(fn)
|
||||
return this.runOne()
|
||||
}
|
||||
call (fn, returnWith) {
|
||||
if (returnWith) this.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = new State(fn)
|
||||
}
|
||||
callNow (fn, returnWith) {
|
||||
this.call(fn, returnWith)
|
||||
return this.runOne()
|
||||
}
|
||||
return (value) {
|
||||
/* istanbul ignore next */
|
||||
if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'))
|
||||
if (value === undefined) value = this.state.buf
|
||||
this.state = this.stack.pop()
|
||||
this.state.returned = value
|
||||
}
|
||||
returnNow (value) {
|
||||
this.return(value)
|
||||
return this.runOne()
|
||||
}
|
||||
consume () {
|
||||
/* istanbul ignore next */
|
||||
if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'))
|
||||
this.state.buf += this._buf[this.ii]
|
||||
}
|
||||
error (err) {
|
||||
err.line = this.line
|
||||
err.col = this.col
|
||||
err.pos = this.pos
|
||||
return err
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
parseStart () {
|
||||
throw new ParserError('Must declare a parseStart method')
|
||||
}
|
||||
}
|
||||
Parser.END = ParserEND
|
||||
Parser.Error = ParserError
|
||||
module.exports = Parser
|
||||
1379
node_modules/@iarna/toml/lib/toml-parser.js
generated
vendored
Executable file
1379
node_modules/@iarna/toml/lib/toml-parser.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
82
node_modules/@iarna/toml/package.json
generated
vendored
Executable file
82
node_modules/@iarna/toml/package.json
generated
vendored
Executable file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "@iarna/toml",
|
||||
"version": "2.2.5",
|
||||
"main": "toml.js",
|
||||
"scripts": {
|
||||
"test": "tap -J --100 test/*.js test/toml-stream/*.js",
|
||||
"benchmark": "node benchmark.js && node benchmark-per-file.js && node results2table.js",
|
||||
"prerelease": "npm t",
|
||||
"prepack": "rm -f *~",
|
||||
"postpublish": "git push --follow-tags",
|
||||
"pretest": "iarna-standard",
|
||||
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
|
||||
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'",
|
||||
"setup-burntsushi-toml-suite": "[ -d test/burntsushi-toml-test ] || (git clone https://github.com/BurntSushi/toml-test test/burntsushi-toml-test; rimraf test/burntsushi-toml-test/.git/hooks/*); cd test/burntsushi-toml-test; git pull",
|
||||
"setup-iarna-toml-suite": "[ -d test/spec-test ] || (git clone https://github.com/iarna/toml-spec-tests -b 0.5.0 test/spec-test; rimraf test/spec-test/.git/hooks/*); cd test/spec-test; git pull",
|
||||
"prepare": "npm run setup-burntsushi-toml-suite && npm run setup-iarna-toml-suite"
|
||||
},
|
||||
"keywords": [
|
||||
"toml",
|
||||
"toml-parser",
|
||||
"toml-stringifier",
|
||||
"parser",
|
||||
"stringifer",
|
||||
"emitter",
|
||||
"ini",
|
||||
"tomlify",
|
||||
"encoder",
|
||||
"decoder"
|
||||
],
|
||||
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org/)",
|
||||
"license": "ISC",
|
||||
"description": "Better TOML parsing and stringifying all in that familiar JSON interface.",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@iarna/standard": "^2.0.2",
|
||||
"@ltd/j-toml": "^0.5.107",
|
||||
"@perl/qx": "^1.1.0",
|
||||
"@sgarciac/bombadil": "^2.3.0",
|
||||
"ansi": "^0.3.1",
|
||||
"approximate-number": "^2.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"fast-toml": "^0.5.4",
|
||||
"funstream": "^4.2.0",
|
||||
"glob": "^7.1.6",
|
||||
"js-yaml": "^3.13.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"tap": "^12.0.1",
|
||||
"toml": "^3.0.0",
|
||||
"toml-j0.4": "^1.1.1",
|
||||
"weallbehave": "*",
|
||||
"weallcontribute": "*"
|
||||
},
|
||||
"files": [
|
||||
"toml.js",
|
||||
"stringify.js",
|
||||
"parse.js",
|
||||
"parse-string.js",
|
||||
"parse-stream.js",
|
||||
"parse-async.js",
|
||||
"parse-pretty-error.js",
|
||||
"lib/parser.js",
|
||||
"lib/parser-debug.js",
|
||||
"lib/toml-parser.js",
|
||||
"lib/create-datetime.js",
|
||||
"lib/create-date.js",
|
||||
"lib/create-datetime-float.js",
|
||||
"lib/create-time.js",
|
||||
"lib/format-num.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/iarna/iarna-toml.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/iarna/iarna-toml/issues"
|
||||
},
|
||||
"homepage": "https://github.com/iarna/iarna-toml#readme"
|
||||
}
|
||||
30
node_modules/@iarna/toml/parse-async.js
generated
vendored
Executable file
30
node_modules/@iarna/toml/parse-async.js
generated
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
'use strict'
|
||||
module.exports = parseAsync
|
||||
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
|
||||
function parseAsync (str, opts) {
|
||||
if (!opts) opts = {}
|
||||
const index = 0
|
||||
const blocksize = opts.blocksize || 40960
|
||||
const parser = new TOMLParser()
|
||||
return new Promise((resolve, reject) => {
|
||||
setImmediate(parseAsyncNext, index, blocksize, resolve, reject)
|
||||
})
|
||||
function parseAsyncNext (index, blocksize, resolve, reject) {
|
||||
if (index >= str.length) {
|
||||
try {
|
||||
return resolve(parser.finish())
|
||||
} catch (err) {
|
||||
return reject(prettyError(err, str))
|
||||
}
|
||||
}
|
||||
try {
|
||||
parser.parse(str.slice(index, index + blocksize))
|
||||
setImmediate(parseAsyncNext, index + blocksize, blocksize, resolve, reject)
|
||||
} catch (err) {
|
||||
reject(prettyError(err, str))
|
||||
}
|
||||
}
|
||||
}
|
||||
33
node_modules/@iarna/toml/parse-pretty-error.js
generated
vendored
Executable file
33
node_modules/@iarna/toml/parse-pretty-error.js
generated
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
module.exports = prettyError
|
||||
|
||||
function prettyError (err, buf) {
|
||||
/* istanbul ignore if */
|
||||
if (err.pos == null || err.line == null) return err
|
||||
let msg = err.message
|
||||
msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (buf && buf.split) {
|
||||
const lines = buf.split(/\n/)
|
||||
const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length
|
||||
let linePadding = ' '
|
||||
while (linePadding.length < lineNumWidth) linePadding += ' '
|
||||
for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
|
||||
let lineNum = String(ii + 1)
|
||||
if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum
|
||||
if (err.line === ii) {
|
||||
msg += lineNum + '> ' + lines[ii] + '\n'
|
||||
msg += linePadding + ' '
|
||||
for (let hh = 0; hh < err.col; ++hh) {
|
||||
msg += ' '
|
||||
}
|
||||
msg += '^\n'
|
||||
} else {
|
||||
msg += lineNum + ': ' + lines[ii] + '\n'
|
||||
}
|
||||
}
|
||||
}
|
||||
err.message = msg + '\n'
|
||||
return err
|
||||
}
|
||||
80
node_modules/@iarna/toml/parse-stream.js
generated
vendored
Executable file
80
node_modules/@iarna/toml/parse-stream.js
generated
vendored
Executable file
@@ -0,0 +1,80 @@
|
||||
'use strict'
|
||||
module.exports = parseStream
|
||||
|
||||
const stream = require('stream')
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
|
||||
function parseStream (stm) {
|
||||
if (stm) {
|
||||
return parseReadable(stm)
|
||||
} else {
|
||||
return parseTransform(stm)
|
||||
}
|
||||
}
|
||||
|
||||
function parseReadable (stm) {
|
||||
const parser = new TOMLParser()
|
||||
stm.setEncoding('utf8')
|
||||
return new Promise((resolve, reject) => {
|
||||
let readable
|
||||
let ended = false
|
||||
let errored = false
|
||||
function finish () {
|
||||
ended = true
|
||||
if (readable) return
|
||||
try {
|
||||
resolve(parser.finish())
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
}
|
||||
function error (err) {
|
||||
errored = true
|
||||
reject(err)
|
||||
}
|
||||
stm.once('end', finish)
|
||||
stm.once('error', error)
|
||||
readNext()
|
||||
|
||||
function readNext () {
|
||||
readable = true
|
||||
let data
|
||||
while ((data = stm.read()) !== null) {
|
||||
try {
|
||||
parser.parse(data)
|
||||
} catch (err) {
|
||||
return error(err)
|
||||
}
|
||||
}
|
||||
readable = false
|
||||
/* istanbul ignore if */
|
||||
if (ended) return finish()
|
||||
/* istanbul ignore if */
|
||||
if (errored) return
|
||||
stm.once('readable', readNext)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function parseTransform () {
|
||||
const parser = new TOMLParser()
|
||||
return new stream.Transform({
|
||||
objectMode: true,
|
||||
transform (chunk, encoding, cb) {
|
||||
try {
|
||||
parser.parse(chunk.toString(encoding))
|
||||
} catch (err) {
|
||||
this.emit('error', err)
|
||||
}
|
||||
cb()
|
||||
},
|
||||
flush (cb) {
|
||||
try {
|
||||
this.push(parser.finish())
|
||||
} catch (err) {
|
||||
this.emit('error', err)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
})
|
||||
}
|
||||
18
node_modules/@iarna/toml/parse-string.js
generated
vendored
Executable file
18
node_modules/@iarna/toml/parse-string.js
generated
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
module.exports = parseString
|
||||
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
|
||||
function parseString (str) {
|
||||
if (global.Buffer && global.Buffer.isBuffer(str)) {
|
||||
str = str.toString('utf8')
|
||||
}
|
||||
const parser = new TOMLParser()
|
||||
try {
|
||||
parser.parse(str)
|
||||
return parser.finish()
|
||||
} catch (err) {
|
||||
throw prettyError(err, str)
|
||||
}
|
||||
}
|
||||
5
node_modules/@iarna/toml/parse.js
generated
vendored
Executable file
5
node_modules/@iarna/toml/parse.js
generated
vendored
Executable file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
module.exports = require('./parse-string.js')
|
||||
module.exports.async = require('./parse-async.js')
|
||||
module.exports.stream = require('./parse-stream.js')
|
||||
module.exports.prettyError = require('./parse-pretty-error.js')
|
||||
296
node_modules/@iarna/toml/stringify.js
generated
vendored
Executable file
296
node_modules/@iarna/toml/stringify.js
generated
vendored
Executable file
@@ -0,0 +1,296 @@
|
||||
'use strict'
|
||||
module.exports = stringify
|
||||
module.exports.value = stringifyInline
|
||||
|
||||
function stringify (obj) {
|
||||
if (obj === null) throw typeError('null')
|
||||
if (obj === void (0)) throw typeError('undefined')
|
||||
if (typeof obj !== 'object') throw typeError(typeof obj)
|
||||
|
||||
if (typeof obj.toJSON === 'function') obj = obj.toJSON()
|
||||
if (obj == null) return null
|
||||
const type = tomlType(obj)
|
||||
if (type !== 'table') throw typeError(type)
|
||||
return stringifyObject('', '', obj)
|
||||
}
|
||||
|
||||
function typeError (type) {
|
||||
return new Error('Can only stringify objects, not ' + type)
|
||||
}
|
||||
|
||||
function arrayOneTypeError () {
|
||||
return new Error("Array values can't have mixed types")
|
||||
}
|
||||
|
||||
function getInlineKeys (obj) {
|
||||
return Object.keys(obj).filter(key => isInline(obj[key]))
|
||||
}
|
||||
function getComplexKeys (obj) {
|
||||
return Object.keys(obj).filter(key => !isInline(obj[key]))
|
||||
}
|
||||
|
||||
function toJSON (obj) {
|
||||
let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, '__proto__') ? {['__proto__']: undefined} : {}
|
||||
for (let prop of Object.keys(obj)) {
|
||||
if (obj[prop] && typeof obj[prop].toJSON === 'function' && !('toISOString' in obj[prop])) {
|
||||
nobj[prop] = obj[prop].toJSON()
|
||||
} else {
|
||||
nobj[prop] = obj[prop]
|
||||
}
|
||||
}
|
||||
return nobj
|
||||
}
|
||||
|
||||
function stringifyObject (prefix, indent, obj) {
|
||||
obj = toJSON(obj)
|
||||
var inlineKeys
|
||||
var complexKeys
|
||||
inlineKeys = getInlineKeys(obj)
|
||||
complexKeys = getComplexKeys(obj)
|
||||
var result = []
|
||||
var inlineIndent = indent || ''
|
||||
inlineKeys.forEach(key => {
|
||||
var type = tomlType(obj[key])
|
||||
if (type !== 'undefined' && type !== 'null') {
|
||||
result.push(inlineIndent + stringifyKey(key) + ' = ' + stringifyAnyInline(obj[key], true))
|
||||
}
|
||||
})
|
||||
if (result.length > 0) result.push('')
|
||||
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
|
||||
complexKeys.forEach(key => {
|
||||
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
|
||||
})
|
||||
return result.join('\n')
|
||||
}
|
||||
|
||||
function isInline (value) {
|
||||
switch (tomlType(value)) {
|
||||
case 'undefined':
|
||||
case 'null':
|
||||
case 'integer':
|
||||
case 'nan':
|
||||
case 'float':
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'datetime':
|
||||
return true
|
||||
case 'array':
|
||||
return value.length === 0 || tomlType(value[0]) !== 'table'
|
||||
case 'table':
|
||||
return Object.keys(value).length === 0
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function tomlType (value) {
|
||||
if (value === undefined) {
|
||||
return 'undefined'
|
||||
} else if (value === null) {
|
||||
return 'null'
|
||||
/* eslint-disable valid-typeof */
|
||||
} else if (typeof value === 'bigint' || (Number.isInteger(value) && !Object.is(value, -0))) {
|
||||
return 'integer'
|
||||
} else if (typeof value === 'number') {
|
||||
return 'float'
|
||||
} else if (typeof value === 'boolean') {
|
||||
return 'boolean'
|
||||
} else if (typeof value === 'string') {
|
||||
return 'string'
|
||||
} else if ('toISOString' in value) {
|
||||
return isNaN(value) ? 'undefined' : 'datetime'
|
||||
} else if (Array.isArray(value)) {
|
||||
return 'array'
|
||||
} else {
|
||||
return 'table'
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyKey (key) {
|
||||
var keyStr = String(key)
|
||||
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
|
||||
return keyStr
|
||||
} else {
|
||||
return stringifyBasicString(keyStr)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyBasicString (str) {
|
||||
return '"' + escapeString(str).replace(/"/g, '\\"') + '"'
|
||||
}
|
||||
|
||||
function stringifyLiteralString (str) {
|
||||
return "'" + str + "'"
|
||||
}
|
||||
|
||||
function numpad (num, str) {
|
||||
while (str.length < num) str = '0' + str
|
||||
return str
|
||||
}
|
||||
|
||||
function escapeString (str) {
|
||||
return str.replace(/\\/g, '\\\\')
|
||||
.replace(/[\b]/g, '\\b')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\f/g, '\\f')
|
||||
.replace(/\r/g, '\\r')
|
||||
/* eslint-disable no-control-regex */
|
||||
.replace(/([\u0000-\u001f\u007f])/, c => '\\u' + numpad(4, c.codePointAt(0).toString(16)))
|
||||
/* eslint-enable no-control-regex */
|
||||
}
|
||||
|
||||
function stringifyMultilineString (str) {
|
||||
let escaped = str.split(/\n/).map(str => {
|
||||
return escapeString(str).replace(/"(?="")/g, '\\"')
|
||||
}).join('\n')
|
||||
if (escaped.slice(-1) === '"') escaped += '\\\n'
|
||||
return '"""\n' + escaped + '"""'
|
||||
}
|
||||
|
||||
function stringifyAnyInline (value, multilineOk) {
|
||||
let type = tomlType(value)
|
||||
if (type === 'string') {
|
||||
if (multilineOk && /\n/.test(value)) {
|
||||
type = 'string-multiline'
|
||||
} else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) {
|
||||
type = 'string-literal'
|
||||
}
|
||||
}
|
||||
return stringifyInline(value, type)
|
||||
}
|
||||
|
||||
function stringifyInline (value, type) {
|
||||
/* istanbul ignore if */
|
||||
if (!type) type = tomlType(value)
|
||||
switch (type) {
|
||||
case 'string-multiline':
|
||||
return stringifyMultilineString(value)
|
||||
case 'string':
|
||||
return stringifyBasicString(value)
|
||||
case 'string-literal':
|
||||
return stringifyLiteralString(value)
|
||||
case 'integer':
|
||||
return stringifyInteger(value)
|
||||
case 'float':
|
||||
return stringifyFloat(value)
|
||||
case 'boolean':
|
||||
return stringifyBoolean(value)
|
||||
case 'datetime':
|
||||
return stringifyDatetime(value)
|
||||
case 'array':
|
||||
return stringifyInlineArray(value.filter(_ => tomlType(_) !== 'null' && tomlType(_) !== 'undefined' && tomlType(_) !== 'nan'))
|
||||
case 'table':
|
||||
return stringifyInlineTable(value)
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw typeError(type)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyInteger (value) {
|
||||
/* eslint-disable security/detect-unsafe-regex */
|
||||
return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, '_')
|
||||
}
|
||||
|
||||
function stringifyFloat (value) {
|
||||
if (value === Infinity) {
|
||||
return 'inf'
|
||||
} else if (value === -Infinity) {
|
||||
return '-inf'
|
||||
} else if (Object.is(value, NaN)) {
|
||||
return 'nan'
|
||||
} else if (Object.is(value, -0)) {
|
||||
return '-0.0'
|
||||
}
|
||||
var chunks = String(value).split('.')
|
||||
var int = chunks[0]
|
||||
var dec = chunks[1] || 0
|
||||
return stringifyInteger(int) + '.' + dec
|
||||
}
|
||||
|
||||
function stringifyBoolean (value) {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function stringifyDatetime (value) {
|
||||
return value.toISOString()
|
||||
}
|
||||
|
||||
function isNumber (type) {
|
||||
return type === 'float' || type === 'integer'
|
||||
}
|
||||
function arrayType (values) {
|
||||
var contentType = tomlType(values[0])
|
||||
if (values.every(_ => tomlType(_) === contentType)) return contentType
|
||||
// mixed integer/float, emit as floats
|
||||
if (values.every(_ => isNumber(tomlType(_)))) return 'float'
|
||||
return 'mixed'
|
||||
}
|
||||
function validateArray (values) {
|
||||
const type = arrayType(values)
|
||||
if (type === 'mixed') {
|
||||
throw arrayOneTypeError()
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
function stringifyInlineArray (values) {
|
||||
values = toJSON(values)
|
||||
const type = validateArray(values)
|
||||
var result = '['
|
||||
var stringified = values.map(_ => stringifyInline(_, type))
|
||||
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
|
||||
result += '\n ' + stringified.join(',\n ') + '\n'
|
||||
} else {
|
||||
result += ' ' + stringified.join(', ') + (stringified.length > 0 ? ' ' : '')
|
||||
}
|
||||
return result + ']'
|
||||
}
|
||||
|
||||
function stringifyInlineTable (value) {
|
||||
value = toJSON(value)
|
||||
var result = []
|
||||
Object.keys(value).forEach(key => {
|
||||
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
|
||||
})
|
||||
return '{ ' + result.join(', ') + (result.length > 0 ? ' ' : '') + '}'
|
||||
}
|
||||
|
||||
function stringifyComplex (prefix, indent, key, value) {
|
||||
var valueType = tomlType(value)
|
||||
/* istanbul ignore else */
|
||||
if (valueType === 'array') {
|
||||
return stringifyArrayOfTables(prefix, indent, key, value)
|
||||
} else if (valueType === 'table') {
|
||||
return stringifyComplexTable(prefix, indent, key, value)
|
||||
} else {
|
||||
throw typeError(valueType)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyArrayOfTables (prefix, indent, key, values) {
|
||||
values = toJSON(values)
|
||||
validateArray(values)
|
||||
var firstValueType = tomlType(values[0])
|
||||
/* istanbul ignore if */
|
||||
if (firstValueType !== 'table') throw typeError(firstValueType)
|
||||
var fullKey = prefix + stringifyKey(key)
|
||||
var result = ''
|
||||
values.forEach(table => {
|
||||
if (result.length > 0) result += '\n'
|
||||
result += indent + '[[' + fullKey + ']]\n'
|
||||
result += stringifyObject(fullKey + '.', indent, table)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
function stringifyComplexTable (prefix, indent, key, value) {
|
||||
var fullKey = prefix + stringifyKey(key)
|
||||
var result = ''
|
||||
if (getInlineKeys(value).length > 0) {
|
||||
result += indent + '[' + fullKey + ']\n'
|
||||
}
|
||||
return result + stringifyObject(fullKey + '.', indent, value)
|
||||
}
|
||||
3
node_modules/@iarna/toml/toml.js
generated
vendored
Executable file
3
node_modules/@iarna/toml/toml.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
exports.parse = require('./parse.js')
|
||||
exports.stringify = require('./stringify.js')
|
||||
272
node_modules/node-fetch/CHANGELOG.md
generated
vendored
272
node_modules/node-fetch/CHANGELOG.md
generated
vendored
@@ -1,272 +0,0 @@
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
|
||||
# 2.x release
|
||||
|
||||
## v2.6.1
|
||||
|
||||
**This is an important security release. It is strongly recommended to update as soon as possible.**
|
||||
|
||||
- Fix: honor the `size` option after following a redirect.
|
||||
|
||||
## v2.6.0
|
||||
|
||||
- Enhance: `options.agent`, it now accepts a function that returns custom http(s).Agent instance based on current URL, see readme for more information.
|
||||
- Fix: incorrect `Content-Length` was returned for stream body in 2.5.0 release; note that `node-fetch` doesn't calculate content length for stream body.
|
||||
- Fix: `Response.url` should return empty string instead of `null` by default.
|
||||
|
||||
## v2.5.0
|
||||
|
||||
- Enhance: `Response` object now includes `redirected` property.
|
||||
- Enhance: `fetch()` now accepts third-party `Blob` implementation as body.
|
||||
- Other: disable `package-lock.json` generation as we never commit them.
|
||||
- Other: dev dependency update.
|
||||
- Other: readme update.
|
||||
|
||||
## v2.4.1
|
||||
|
||||
- Fix: `Blob` import rule for node < 10, as `Readable` isn't a named export.
|
||||
|
||||
## v2.4.0
|
||||
|
||||
- Enhance: added `Brotli` compression support (using node's zlib).
|
||||
- Enhance: updated `Blob` implementation per spec.
|
||||
- Fix: set content type automatically for `URLSearchParams`.
|
||||
- Fix: `Headers` now reject empty header names.
|
||||
- Fix: test cases, as node 12+ no longer accepts invalid header response.
|
||||
|
||||
## v2.3.0
|
||||
|
||||
- Enhance: added `AbortSignal` support, with README example.
|
||||
- Enhance: handle invalid `Location` header during redirect by rejecting them explicitly with `FetchError`.
|
||||
- Fix: update `browser.js` to support react-native environment, where `self` isn't available globally.
|
||||
|
||||
## v2.2.1
|
||||
|
||||
- Fix: `compress` flag shouldn't overwrite existing `Accept-Encoding` header.
|
||||
- Fix: multiple `import` rules, where `PassThrough` etc. doesn't have a named export when using node <10 and `--exerimental-modules` flag.
|
||||
- Other: Better README.
|
||||
|
||||
## v2.2.0
|
||||
|
||||
- Enhance: Support all `ArrayBuffer` view types
|
||||
- Enhance: Support Web Workers
|
||||
- Enhance: Support Node.js' `--experimental-modules` mode; deprecate `.es.js` file
|
||||
- Fix: Add `__esModule` property to the exports object
|
||||
- Other: Better example in README for writing response to a file
|
||||
- Other: More tests for Agent
|
||||
|
||||
## v2.1.2
|
||||
|
||||
- Fix: allow `Body` methods to work on `ArrayBuffer`-backed `Body` objects
|
||||
- Fix: reject promise returned by `Body` methods when the accumulated `Buffer` exceeds the maximum size
|
||||
- Fix: support custom `Host` headers with any casing
|
||||
- Fix: support importing `fetch()` from TypeScript in `browser.js`
|
||||
- Fix: handle the redirect response body properly
|
||||
|
||||
## v2.1.1
|
||||
|
||||
Fix packaging errors in v2.1.0.
|
||||
|
||||
## v2.1.0
|
||||
|
||||
- Enhance: allow using ArrayBuffer as the `body` of a `fetch()` or `Request`
|
||||
- Fix: store HTTP headers of a `Headers` object internally with the given case, for compatibility with older servers that incorrectly treated header names in a case-sensitive manner
|
||||
- Fix: silently ignore invalid HTTP headers
|
||||
- Fix: handle HTTP redirect responses without a `Location` header just like non-redirect responses
|
||||
- Fix: include bodies when following a redirection when appropriate
|
||||
|
||||
## v2.0.0
|
||||
|
||||
This is a major release. Check [our upgrade guide](https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md) for an overview on some key differences between v1 and v2.
|
||||
|
||||
### General changes
|
||||
|
||||
- Major: Node.js 0.10.x and 0.12.x support is dropped
|
||||
- Major: `require('node-fetch/lib/response')` etc. is now unsupported; use `require('node-fetch').Response` or ES6 module imports
|
||||
- Enhance: start testing on Node.js v4.x, v6.x, v8.x LTS, as well as v9.x stable
|
||||
- Enhance: use Rollup to produce a distributed bundle (less memory overhead and faster startup)
|
||||
- Enhance: make `Object.prototype.toString()` on Headers, Requests, and Responses return correct class strings
|
||||
- Other: rewrite in ES2015 using Babel
|
||||
- Other: use Codecov for code coverage tracking
|
||||
- Other: update package.json script for npm 5
|
||||
- Other: `encoding` module is now optional (alpha.7)
|
||||
- Other: expose browser.js through package.json, avoid bundling mishaps (alpha.9)
|
||||
- Other: allow TypeScript to `import` node-fetch by exposing default (alpha.9)
|
||||
|
||||
### HTTP requests
|
||||
|
||||
- Major: overwrite user's `Content-Length` if we can be sure our information is correct (per spec)
|
||||
- Fix: errors in a response are caught before the body is accessed
|
||||
- Fix: support WHATWG URL objects, created by `whatwg-url` package or `require('url').URL` in Node.js 7+
|
||||
|
||||
### Response and Request classes
|
||||
|
||||
- Major: `response.text()` no longer attempts to detect encoding, instead always opting for UTF-8 (per spec); use `response.textConverted()` for the v1 behavior
|
||||
- Major: make `response.json()` throw error instead of returning an empty object on 204 no-content respose (per spec; reverts behavior changed in v1.6.2)
|
||||
- Major: internal methods are no longer exposed
|
||||
- Major: throw error when a `GET` or `HEAD` Request is constructed with a non-null body (per spec)
|
||||
- Enhance: add `response.arrayBuffer()` (also applies to Requests)
|
||||
- Enhance: add experimental `response.blob()` (also applies to Requests)
|
||||
- Enhance: `URLSearchParams` is now accepted as a body
|
||||
- Enhance: wrap `response.json()` json parsing error as `FetchError`
|
||||
- Fix: fix Request and Response with `null` body
|
||||
|
||||
### Headers class
|
||||
|
||||
- Major: remove `headers.getAll()`; make `get()` return all headers delimited by commas (per spec)
|
||||
- Enhance: make Headers iterable
|
||||
- Enhance: make Headers constructor accept an array of tuples
|
||||
- Enhance: make sure header names and values are valid in HTTP
|
||||
- Fix: coerce Headers prototype function parameters to strings, where applicable
|
||||
|
||||
### Documentation
|
||||
|
||||
- Enhance: more comprehensive API docs
|
||||
- Enhance: add a list of default headers in README
|
||||
|
||||
|
||||
# 1.x release
|
||||
|
||||
## backport releases (v1.7.0 and beyond)
|
||||
|
||||
See [changelog on 1.x branch](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) for details.
|
||||
|
||||
## v1.6.3
|
||||
|
||||
- Enhance: error handling document to explain `FetchError` design
|
||||
- Fix: support `form-data` 2.x releases (requires `form-data` >= 2.1.0)
|
||||
|
||||
## v1.6.2
|
||||
|
||||
- Enhance: minor document update
|
||||
- Fix: response.json() returns empty object on 204 no-content response instead of throwing a syntax error
|
||||
|
||||
## v1.6.1
|
||||
|
||||
- Fix: if `res.body` is a non-stream non-formdata object, we will call `body.toString` and send it as a string
|
||||
- Fix: `counter` value is incorrectly set to `follow` value when wrapping Request instance
|
||||
- Fix: documentation update
|
||||
|
||||
## v1.6.0
|
||||
|
||||
- Enhance: added `res.buffer()` api for convenience, it returns body as a Node.js buffer
|
||||
- Enhance: better old server support by handling raw deflate response
|
||||
- Enhance: skip encoding detection for non-HTML/XML response
|
||||
- Enhance: minor document update
|
||||
- Fix: HEAD request doesn't need decompression, as body is empty
|
||||
- Fix: `req.body` now accepts a Node.js buffer
|
||||
|
||||
## v1.5.3
|
||||
|
||||
- Fix: handle 204 and 304 responses when body is empty but content-encoding is gzip/deflate
|
||||
- Fix: allow resolving response and cloned response in any order
|
||||
- Fix: avoid setting `content-length` when `form-data` body use streams
|
||||
- Fix: send DELETE request with content-length when body is present
|
||||
- Fix: allow any url when calling new Request, but still reject non-http(s) url in fetch
|
||||
|
||||
## v1.5.2
|
||||
|
||||
- Fix: allow node.js core to handle keep-alive connection pool when passing a custom agent
|
||||
|
||||
## v1.5.1
|
||||
|
||||
- Fix: redirect mode `manual` should work even when there is no redirection or broken redirection
|
||||
|
||||
## v1.5.0
|
||||
|
||||
- Enhance: rejected promise now use custom `Error` (thx to @pekeler)
|
||||
- Enhance: `FetchError` contains `err.type` and `err.code`, allows for better error handling (thx to @pekeler)
|
||||
- Enhance: basic support for redirect mode `manual` and `error`, allows for location header extraction (thx to @jimmywarting for the initial PR)
|
||||
|
||||
## v1.4.1
|
||||
|
||||
- Fix: wrapping Request instance with FormData body again should preserve the body as-is
|
||||
|
||||
## v1.4.0
|
||||
|
||||
- Enhance: Request and Response now have `clone` method (thx to @kirill-konshin for the initial PR)
|
||||
- Enhance: Request and Response now have proper string and buffer body support (thx to @kirill-konshin)
|
||||
- Enhance: Body constructor has been refactored out (thx to @kirill-konshin)
|
||||
- Enhance: Headers now has `forEach` method (thx to @tricoder42)
|
||||
- Enhance: back to 100% code coverage
|
||||
- Fix: better form-data support (thx to @item4)
|
||||
- Fix: better character encoding detection under chunked encoding (thx to @dsuket for the initial PR)
|
||||
|
||||
## v1.3.3
|
||||
|
||||
- Fix: make sure `Content-Length` header is set when body is string for POST/PUT/PATCH requests
|
||||
- Fix: handle body stream error, for cases such as incorrect `Content-Encoding` header
|
||||
- Fix: when following certain redirects, use `GET` on subsequent request per Fetch Spec
|
||||
- Fix: `Request` and `Response` constructors now parse headers input using `Headers`
|
||||
|
||||
## v1.3.2
|
||||
|
||||
- Enhance: allow auto detect of form-data input (no `FormData` spec on node.js, this is form-data specific feature)
|
||||
|
||||
## v1.3.1
|
||||
|
||||
- Enhance: allow custom host header to be set (server-side only feature, as it's a forbidden header on client-side)
|
||||
|
||||
## v1.3.0
|
||||
|
||||
- Enhance: now `fetch.Request` is exposed as well
|
||||
|
||||
## v1.2.1
|
||||
|
||||
- Enhance: `Headers` now normalized `Number` value to `String`, prevent common mistakes
|
||||
|
||||
## v1.2.0
|
||||
|
||||
- Enhance: now fetch.Headers and fetch.Response are exposed, making testing easier
|
||||
|
||||
## v1.1.2
|
||||
|
||||
- Fix: `Headers` should only support `String` and `Array` properties, and ignore others
|
||||
|
||||
## v1.1.1
|
||||
|
||||
- Enhance: now req.headers accept both plain object and `Headers` instance
|
||||
|
||||
## v1.1.0
|
||||
|
||||
- Enhance: timeout now also applies to response body (in case of slow response)
|
||||
- Fix: timeout is now cleared properly when fetch is done/has failed
|
||||
|
||||
## v1.0.6
|
||||
|
||||
- Fix: less greedy content-type charset matching
|
||||
|
||||
## v1.0.5
|
||||
|
||||
- Fix: when `follow = 0`, fetch should not follow redirect
|
||||
- Enhance: update tests for better coverage
|
||||
- Enhance: code formatting
|
||||
- Enhance: clean up doc
|
||||
|
||||
## v1.0.4
|
||||
|
||||
- Enhance: test iojs support
|
||||
- Enhance: timeout attached to socket event only fire once per redirect
|
||||
|
||||
## v1.0.3
|
||||
|
||||
- Fix: response size limit should reject large chunk
|
||||
- Enhance: added character encoding detection for xml, such as rss/atom feed (encoding in DTD)
|
||||
|
||||
## v1.0.2
|
||||
|
||||
- Fix: added res.ok per spec change
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Enhance: better test coverage and doc
|
||||
|
||||
|
||||
# 0.x release
|
||||
|
||||
## v0.1
|
||||
|
||||
- Major: initial public release
|
||||
58
node_modules/node-fetch/lib/index.es.js
generated
vendored
58
node_modules/node-fetch/lib/index.es.js
generated
vendored
@@ -3,6 +3,7 @@ process.emitWarning("The .es.js file is deprecated. Use .mjs instead.");
|
||||
import Stream from 'stream';
|
||||
import http from 'http';
|
||||
import Url from 'url';
|
||||
import whatwgUrl from 'whatwg-url';
|
||||
import https from 'https';
|
||||
import zlib from 'zlib';
|
||||
|
||||
@@ -1137,11 +1138,32 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
|
||||
});
|
||||
|
||||
const INTERNALS$2 = Symbol('Request internals');
|
||||
const URL = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "format", "parse" aren't a named export for node <10
|
||||
const parse_url = Url.parse;
|
||||
const format_url = Url.format;
|
||||
|
||||
/**
|
||||
* Wrapper around `new URL` to handle arbitrary URLs
|
||||
*
|
||||
* @param {string} urlStr
|
||||
* @return {void}
|
||||
*/
|
||||
function parseURL(urlStr) {
|
||||
/*
|
||||
Check whether the URL is absolute or not
|
||||
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
||||
*/
|
||||
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
|
||||
urlStr = new URL(urlStr).toString();
|
||||
}
|
||||
|
||||
// Fallback to old implementation for arbitrary URLs
|
||||
return parse_url(urlStr);
|
||||
}
|
||||
|
||||
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
|
||||
|
||||
/**
|
||||
@@ -1178,14 +1200,14 @@ class Request {
|
||||
// in order to support Node.js' Url objects; though WHATWG's URL objects
|
||||
// will fall into this branch also (since their `toString()` will return
|
||||
// `href` property anyway)
|
||||
parsedURL = parse_url(input.href);
|
||||
parsedURL = parseURL(input.href);
|
||||
} else {
|
||||
// coerce input to a string before attempting to parse
|
||||
parsedURL = parse_url(`${input}`);
|
||||
parsedURL = parseURL(`${input}`);
|
||||
}
|
||||
input = {};
|
||||
} else {
|
||||
parsedURL = parse_url(input.url);
|
||||
parsedURL = parseURL(input.url);
|
||||
}
|
||||
|
||||
let method = init.method || input.method || 'GET';
|
||||
@@ -1379,9 +1401,17 @@ AbortError.prototype = Object.create(Error.prototype);
|
||||
AbortError.prototype.constructor = AbortError;
|
||||
AbortError.prototype.name = 'AbortError';
|
||||
|
||||
const URL$1 = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
||||
const PassThrough$1 = Stream.PassThrough;
|
||||
const resolve_url = Url.resolve;
|
||||
|
||||
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
||||
const orig = new URL$1(original).hostname;
|
||||
const dest = new URL$1(destination).hostname;
|
||||
|
||||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
@@ -1469,7 +1499,19 @@ function fetch(url, opts) {
|
||||
const location = headers.get('Location');
|
||||
|
||||
// HTTP fetch step 5.3
|
||||
const locationURL = location === null ? null : resolve_url(request.url, location);
|
||||
let locationURL = null;
|
||||
try {
|
||||
locationURL = location === null ? null : new URL$1(location, request.url).toString();
|
||||
} catch (err) {
|
||||
// error here can only be invalid URL in Location: header
|
||||
// do not throw when options.redirect == manual
|
||||
// let the user extract the errorneous redirect URL
|
||||
if (request.redirect !== 'manual') {
|
||||
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP fetch step 5.5
|
||||
switch (request.redirect) {
|
||||
@@ -1517,6 +1559,12 @@ function fetch(url, opts) {
|
||||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 9
|
||||
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
||||
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
||||
|
||||
58
node_modules/node-fetch/lib/index.js
generated
vendored
58
node_modules/node-fetch/lib/index.js
generated
vendored
@@ -7,6 +7,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
||||
var Stream = _interopDefault(require('stream'));
|
||||
var http = _interopDefault(require('http'));
|
||||
var Url = _interopDefault(require('url'));
|
||||
var whatwgUrl = _interopDefault(require('whatwg-url'));
|
||||
var https = _interopDefault(require('https'));
|
||||
var zlib = _interopDefault(require('zlib'));
|
||||
|
||||
@@ -1141,11 +1142,32 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
|
||||
});
|
||||
|
||||
const INTERNALS$2 = Symbol('Request internals');
|
||||
const URL = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "format", "parse" aren't a named export for node <10
|
||||
const parse_url = Url.parse;
|
||||
const format_url = Url.format;
|
||||
|
||||
/**
|
||||
* Wrapper around `new URL` to handle arbitrary URLs
|
||||
*
|
||||
* @param {string} urlStr
|
||||
* @return {void}
|
||||
*/
|
||||
function parseURL(urlStr) {
|
||||
/*
|
||||
Check whether the URL is absolute or not
|
||||
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
||||
*/
|
||||
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
|
||||
urlStr = new URL(urlStr).toString();
|
||||
}
|
||||
|
||||
// Fallback to old implementation for arbitrary URLs
|
||||
return parse_url(urlStr);
|
||||
}
|
||||
|
||||
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
|
||||
|
||||
/**
|
||||
@@ -1182,14 +1204,14 @@ class Request {
|
||||
// in order to support Node.js' Url objects; though WHATWG's URL objects
|
||||
// will fall into this branch also (since their `toString()` will return
|
||||
// `href` property anyway)
|
||||
parsedURL = parse_url(input.href);
|
||||
parsedURL = parseURL(input.href);
|
||||
} else {
|
||||
// coerce input to a string before attempting to parse
|
||||
parsedURL = parse_url(`${input}`);
|
||||
parsedURL = parseURL(`${input}`);
|
||||
}
|
||||
input = {};
|
||||
} else {
|
||||
parsedURL = parse_url(input.url);
|
||||
parsedURL = parseURL(input.url);
|
||||
}
|
||||
|
||||
let method = init.method || input.method || 'GET';
|
||||
@@ -1383,9 +1405,17 @@ AbortError.prototype = Object.create(Error.prototype);
|
||||
AbortError.prototype.constructor = AbortError;
|
||||
AbortError.prototype.name = 'AbortError';
|
||||
|
||||
const URL$1 = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
||||
const PassThrough$1 = Stream.PassThrough;
|
||||
const resolve_url = Url.resolve;
|
||||
|
||||
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
||||
const orig = new URL$1(original).hostname;
|
||||
const dest = new URL$1(destination).hostname;
|
||||
|
||||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
@@ -1473,7 +1503,19 @@ function fetch(url, opts) {
|
||||
const location = headers.get('Location');
|
||||
|
||||
// HTTP fetch step 5.3
|
||||
const locationURL = location === null ? null : resolve_url(request.url, location);
|
||||
let locationURL = null;
|
||||
try {
|
||||
locationURL = location === null ? null : new URL$1(location, request.url).toString();
|
||||
} catch (err) {
|
||||
// error here can only be invalid URL in Location: header
|
||||
// do not throw when options.redirect == manual
|
||||
// let the user extract the errorneous redirect URL
|
||||
if (request.redirect !== 'manual') {
|
||||
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP fetch step 5.5
|
||||
switch (request.redirect) {
|
||||
@@ -1521,6 +1563,12 @@ function fetch(url, opts) {
|
||||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 9
|
||||
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
||||
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
||||
|
||||
58
node_modules/node-fetch/lib/index.mjs
generated
vendored
58
node_modules/node-fetch/lib/index.mjs
generated
vendored
@@ -1,6 +1,7 @@
|
||||
import Stream from 'stream';
|
||||
import http from 'http';
|
||||
import Url from 'url';
|
||||
import whatwgUrl from 'whatwg-url';
|
||||
import https from 'https';
|
||||
import zlib from 'zlib';
|
||||
|
||||
@@ -1135,11 +1136,32 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
|
||||
});
|
||||
|
||||
const INTERNALS$2 = Symbol('Request internals');
|
||||
const URL = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "format", "parse" aren't a named export for node <10
|
||||
const parse_url = Url.parse;
|
||||
const format_url = Url.format;
|
||||
|
||||
/**
|
||||
* Wrapper around `new URL` to handle arbitrary URLs
|
||||
*
|
||||
* @param {string} urlStr
|
||||
* @return {void}
|
||||
*/
|
||||
function parseURL(urlStr) {
|
||||
/*
|
||||
Check whether the URL is absolute or not
|
||||
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
||||
*/
|
||||
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
|
||||
urlStr = new URL(urlStr).toString();
|
||||
}
|
||||
|
||||
// Fallback to old implementation for arbitrary URLs
|
||||
return parse_url(urlStr);
|
||||
}
|
||||
|
||||
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
|
||||
|
||||
/**
|
||||
@@ -1176,14 +1198,14 @@ class Request {
|
||||
// in order to support Node.js' Url objects; though WHATWG's URL objects
|
||||
// will fall into this branch also (since their `toString()` will return
|
||||
// `href` property anyway)
|
||||
parsedURL = parse_url(input.href);
|
||||
parsedURL = parseURL(input.href);
|
||||
} else {
|
||||
// coerce input to a string before attempting to parse
|
||||
parsedURL = parse_url(`${input}`);
|
||||
parsedURL = parseURL(`${input}`);
|
||||
}
|
||||
input = {};
|
||||
} else {
|
||||
parsedURL = parse_url(input.url);
|
||||
parsedURL = parseURL(input.url);
|
||||
}
|
||||
|
||||
let method = init.method || input.method || 'GET';
|
||||
@@ -1377,9 +1399,17 @@ AbortError.prototype = Object.create(Error.prototype);
|
||||
AbortError.prototype.constructor = AbortError;
|
||||
AbortError.prototype.name = 'AbortError';
|
||||
|
||||
const URL$1 = Url.URL || whatwgUrl.URL;
|
||||
|
||||
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
||||
const PassThrough$1 = Stream.PassThrough;
|
||||
const resolve_url = Url.resolve;
|
||||
|
||||
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
||||
const orig = new URL$1(original).hostname;
|
||||
const dest = new URL$1(destination).hostname;
|
||||
|
||||
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
@@ -1467,7 +1497,19 @@ function fetch(url, opts) {
|
||||
const location = headers.get('Location');
|
||||
|
||||
// HTTP fetch step 5.3
|
||||
const locationURL = location === null ? null : resolve_url(request.url, location);
|
||||
let locationURL = null;
|
||||
try {
|
||||
locationURL = location === null ? null : new URL$1(location, request.url).toString();
|
||||
} catch (err) {
|
||||
// error here can only be invalid URL in Location: header
|
||||
// do not throw when options.redirect == manual
|
||||
// let the user extract the errorneous redirect URL
|
||||
if (request.redirect !== 'manual') {
|
||||
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP fetch step 5.5
|
||||
switch (request.redirect) {
|
||||
@@ -1515,6 +1557,12 @@ function fetch(url, opts) {
|
||||
size: request.size
|
||||
};
|
||||
|
||||
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||
requestOpts.headers.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 9
|
||||
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
||||
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
||||
|
||||
22
node_modules/node-fetch/package.json
generated
vendored
22
node_modules/node-fetch/package.json
generated
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "node-fetch",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.7",
|
||||
"description": "A light-weight module that brings window.fetch to node.js",
|
||||
"main": "lib/index",
|
||||
"main": "lib/index.js",
|
||||
"browser": "./browser.js",
|
||||
"module": "lib/index.mjs",
|
||||
"files": [
|
||||
@@ -36,6 +36,17 @@
|
||||
"url": "https://github.com/bitinn/node-fetch/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bitinn/node-fetch",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ungap/url-search-params": "^0.1.2",
|
||||
"abort-controller": "^1.1.0",
|
||||
@@ -48,7 +59,7 @@
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-iterator": "^1.1.1",
|
||||
"chai-string": "~1.3.0",
|
||||
"codecov": "^3.3.0",
|
||||
"codecov": "3.3.0",
|
||||
"cross-env": "^5.2.0",
|
||||
"form-data": "^2.3.3",
|
||||
"is-builtin-module": "^1.0.0",
|
||||
@@ -60,7 +71,6 @@
|
||||
"rollup": "^0.63.4",
|
||||
"rollup-plugin-babel": "^3.0.7",
|
||||
"string-to-arraybuffer": "^1.0.2",
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
"teeny-request": "3.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
18
node_modules/toml/.jshintrc
generated
vendored
18
node_modules/toml/.jshintrc
generated
vendored
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"browserify": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"eqnull": false,
|
||||
"latedef": "nofunc",
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"undef": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"indent": 2,
|
||||
"quotmark": true,
|
||||
"laxbreak": true
|
||||
}
|
||||
7
node_modules/toml/.travis.yml
generated
vendored
7
node_modules/toml/.travis.yml
generated
vendored
@@ -1,7 +0,0 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.1"
|
||||
- "4.0"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
116
node_modules/toml/CHANGELOG.md
generated
vendored
116
node_modules/toml/CHANGELOG.md
generated
vendored
@@ -1,116 +0,0 @@
|
||||
2.3.0 - July 13 2015
|
||||
====================
|
||||
|
||||
* Correctly handle quoted keys ([#21](https://github.com/BinaryMuse/toml-node/issues/21))
|
||||
|
||||
2.2.3 - June 8 2015
|
||||
===================
|
||||
|
||||
* Support empty inline tables ([#24](https://github.com/BinaryMuse/toml-node/issues/24))
|
||||
* Do not allow implicit table definitions to replace value ([#23](https://github.com/BinaryMuse/toml-node/issues/23))
|
||||
* Don't allow tables to replace inline tables ([#25](https://github.com/BinaryMuse/toml-node/issues/25))
|
||||
|
||||
2.2.2 - April 3 2015
|
||||
====================
|
||||
|
||||
* Correctly handle newlines at beginning of string ([#22](https://github.com/BinaryMuse/toml-node/issues/22))
|
||||
|
||||
2.2.1 - March 17 2015
|
||||
=====================
|
||||
|
||||
* Parse dates generated by Date#toISOString() ([#20](https://github.com/BinaryMuse/toml-node/issues/20))
|
||||
|
||||
2.2.0 - Feb 26 2015
|
||||
===================
|
||||
|
||||
* Support TOML spec v0.4.0
|
||||
|
||||
2.1.0 - Jan 7 2015
|
||||
==================
|
||||
|
||||
* Support TOML spec v0.3.1
|
||||
|
||||
2.0.6 - May 23 2014
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix support for empty arrays with newlines ([#13](https://github.com/BinaryMuse/toml-node/issues/13))
|
||||
|
||||
2.0.5 - May 5 2014
|
||||
==================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix loop iteration leak, by [sebmck](https://github.com/sebmck) ([#12](https://github.com/BinaryMuse/toml-node/pull/12))
|
||||
|
||||
### Development
|
||||
|
||||
* Tests now run JSHint on `lib/compiler.js`
|
||||
|
||||
2.0.4 - Mar 9 2014
|
||||
==================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix failure on duplicate table name inside table array ([#11](https://github.com/BinaryMuse/toml-node/issues/11))
|
||||
|
||||
2.0.2 - Feb 23 2014
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix absence of errors when table path starts or ends with period
|
||||
|
||||
2.0.1 - Feb 23 2014
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix incorrect messaging in array type errors
|
||||
* Fix missing error when overwriting key with table array
|
||||
|
||||
2.0.0 - Feb 23 2014
|
||||
===================
|
||||
|
||||
### Features
|
||||
|
||||
* Add support for [version 0.2 of the TOML spec](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) ([#9](https://github.com/BinaryMuse/toml-node/issues/9))
|
||||
|
||||
### Internals
|
||||
|
||||
* Upgrade to PEG.js v0.8 and rewrite compiler; parser is now considerably faster (from ~7000ms to ~1000ms to parse `example.toml` 1000 times on Node.js v0.10)
|
||||
|
||||
1.0.4 - Aug 17 2013
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix support for empty arrays
|
||||
|
||||
1.0.3 - Aug 17 2013
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix typo in array type error message
|
||||
* Fix single-element arrays with no trailing commas
|
||||
|
||||
1.0.2 - Aug 17 2013
|
||||
===================
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix errors on lines that contain only whitespace ([#7](https://github.com/BinaryMuse/toml-node/issues/7))
|
||||
|
||||
1.0.1 - Aug 17 2013
|
||||
===================
|
||||
|
||||
### Internals
|
||||
|
||||
* Remove old code remaining from the remove streaming API
|
||||
|
||||
1.0.0 - Aug 17 2013
|
||||
===================
|
||||
|
||||
Initial stable release
|
||||
22
node_modules/toml/LICENSE
generated
vendored
22
node_modules/toml/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
||||
Copyright (c) 2012 Michelle Tilley
|
||||
|
||||
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.
|
||||
93
node_modules/toml/README.md
generated
vendored
93
node_modules/toml/README.md
generated
vendored
@@ -1,93 +0,0 @@
|
||||
TOML Parser for Node.js
|
||||
=======================
|
||||
|
||||
[](https://travis-ci.org/BinaryMuse/toml-node)
|
||||
|
||||
[](https://nodei.co/npm/toml/)
|
||||
|
||||
If you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://github.com/mojombo/toml) Back? Good.
|
||||
|
||||
TOML Spec Support
|
||||
-----------------
|
||||
|
||||
toml-node supports version 0.4.0 the TOML spec as specified by [mojombo/toml@v0.4.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.4.0.md)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
toml-node is available via npm.
|
||||
|
||||
npm install toml
|
||||
|
||||
toml-node also works with browser module bundlers like Browserify and webpack.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### Standalone
|
||||
|
||||
Say you have some awesome TOML in a variable called `someTomlString`. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.
|
||||
|
||||
```javascript
|
||||
var toml = require('toml');
|
||||
var data = toml.parse(someTomlString);
|
||||
console.dir(data);
|
||||
```
|
||||
|
||||
`toml.parse` throws an exception in the case of a parsing error; such exceptions have a `line` and `column` property on them to help identify the offending text.
|
||||
|
||||
```javascript
|
||||
try {
|
||||
toml.parse(someCrazyKnuckleHeadedTrblToml);
|
||||
} catch (e) {
|
||||
console.error("Parsing error on line " + e.line + ", column " + e.column +
|
||||
": " + e.message);
|
||||
}
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like [concat-stream](https://npmjs.org/package/concat-stream):
|
||||
|
||||
```javascript
|
||||
var toml = require('toml');
|
||||
var concat = require('concat-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) {
|
||||
var parsed = toml.parse(data);
|
||||
}));
|
||||
```
|
||||
|
||||
Thanks [@ForbesLindesay](https://github.com/ForbesLindesay) for the suggestion.
|
||||
|
||||
### Requiring with Node.js
|
||||
|
||||
You can use the [toml-require package](https://github.com/BinaryMuse/toml-require) to `require()` your `.toml` files with Node.js
|
||||
|
||||
Live Demo
|
||||
---------
|
||||
|
||||
You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.
|
||||
|
||||
Building & Testing
|
||||
------------------
|
||||
|
||||
toml-node uses [the PEG.js parser generator](http://pegjs.majda.cz/).
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
npm test
|
||||
|
||||
Any changes to `src/toml.peg` requires a regeneration of the parser with `npm run build`.
|
||||
|
||||
toml-node is tested on Travis CI and is tested against:
|
||||
|
||||
* Node 0.10
|
||||
* Node 0.12
|
||||
* Latest stable io.js
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.
|
||||
12
node_modules/toml/benchmark.js
generated
vendored
12
node_modules/toml/benchmark.js
generated
vendored
@@ -1,12 +0,0 @@
|
||||
var toml = require('./index');
|
||||
var fs = require('fs');
|
||||
var data = fs.readFileSync('./test/example.toml', 'utf8');
|
||||
|
||||
var iterations = 1000;
|
||||
|
||||
var start = new Date();
|
||||
for(var i = 0; i < iterations; i++) {
|
||||
toml.parse(data);
|
||||
}
|
||||
var end = new Date();
|
||||
console.log("%s iterations in %sms", iterations, end - start);
|
||||
3
node_modules/toml/index.d.ts
generated
vendored
3
node_modules/toml/index.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
declare module 'toml' {
|
||||
export function parse(input: string): any;
|
||||
}
|
||||
9
node_modules/toml/index.js
generated
vendored
9
node_modules/toml/index.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
var parser = require('./lib/parser');
|
||||
var compiler = require('./lib/compiler');
|
||||
|
||||
module.exports = {
|
||||
parse: function(input) {
|
||||
var nodes = parser.parse(input.toString());
|
||||
return compiler.compile(nodes);
|
||||
}
|
||||
};
|
||||
195
node_modules/toml/lib/compiler.js
generated
vendored
195
node_modules/toml/lib/compiler.js
generated
vendored
@@ -1,195 +0,0 @@
|
||||
"use strict";
|
||||
function compile(nodes) {
|
||||
var assignedPaths = [];
|
||||
var valueAssignments = [];
|
||||
var currentPath = "";
|
||||
var data = Object.create(null);
|
||||
var context = data;
|
||||
var arrayMode = false;
|
||||
|
||||
return reduce(nodes);
|
||||
|
||||
function reduce(nodes) {
|
||||
var node;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
node = nodes[i];
|
||||
switch (node.type) {
|
||||
case "Assign":
|
||||
assign(node);
|
||||
break;
|
||||
case "ObjectPath":
|
||||
setPath(node);
|
||||
break;
|
||||
case "ArrayPath":
|
||||
addTableArray(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function genError(err, line, col) {
|
||||
var ex = new Error(err);
|
||||
ex.line = line;
|
||||
ex.column = col;
|
||||
throw ex;
|
||||
}
|
||||
|
||||
function assign(node) {
|
||||
var key = node.key;
|
||||
var value = node.value;
|
||||
var line = node.line;
|
||||
var column = node.column;
|
||||
|
||||
var fullPath;
|
||||
if (currentPath) {
|
||||
fullPath = currentPath + "." + key;
|
||||
} else {
|
||||
fullPath = key;
|
||||
}
|
||||
if (typeof context[key] !== "undefined") {
|
||||
genError("Cannot redefine existing key '" + fullPath + "'.", line, column);
|
||||
}
|
||||
|
||||
context[key] = reduceValueNode(value);
|
||||
|
||||
if (!pathAssigned(fullPath)) {
|
||||
assignedPaths.push(fullPath);
|
||||
valueAssignments.push(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pathAssigned(path) {
|
||||
return assignedPaths.indexOf(path) !== -1;
|
||||
}
|
||||
|
||||
function reduceValueNode(node) {
|
||||
if (node.type === "Array") {
|
||||
return reduceArrayWithTypeChecking(node.value);
|
||||
} else if (node.type === "InlineTable") {
|
||||
return reduceInlineTableNode(node.value);
|
||||
} else {
|
||||
return node.value;
|
||||
}
|
||||
}
|
||||
|
||||
function reduceInlineTableNode(values) {
|
||||
var obj = Object.create(null);
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
var val = values[i];
|
||||
if (val.value.type === "InlineTable") {
|
||||
obj[val.key] = reduceInlineTableNode(val.value.value);
|
||||
} else if (val.type === "InlineTableValue") {
|
||||
obj[val.key] = reduceValueNode(val.value);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function setPath(node) {
|
||||
var path = node.value;
|
||||
var quotedPath = path.map(quoteDottedString).join(".");
|
||||
var line = node.line;
|
||||
var column = node.column;
|
||||
|
||||
if (pathAssigned(quotedPath)) {
|
||||
genError("Cannot redefine existing key '" + path + "'.", line, column);
|
||||
}
|
||||
assignedPaths.push(quotedPath);
|
||||
context = deepRef(data, path, Object.create(null), line, column);
|
||||
currentPath = path;
|
||||
}
|
||||
|
||||
function addTableArray(node) {
|
||||
var path = node.value;
|
||||
var quotedPath = path.map(quoteDottedString).join(".");
|
||||
var line = node.line;
|
||||
var column = node.column;
|
||||
|
||||
if (!pathAssigned(quotedPath)) {
|
||||
assignedPaths.push(quotedPath);
|
||||
}
|
||||
assignedPaths = assignedPaths.filter(function(p) {
|
||||
return p.indexOf(quotedPath) !== 0;
|
||||
});
|
||||
assignedPaths.push(quotedPath);
|
||||
context = deepRef(data, path, [], line, column);
|
||||
currentPath = quotedPath;
|
||||
|
||||
if (context instanceof Array) {
|
||||
var newObj = Object.create(null);
|
||||
context.push(newObj);
|
||||
context = newObj;
|
||||
} else {
|
||||
genError("Cannot redefine existing key '" + path + "'.", line, column);
|
||||
}
|
||||
}
|
||||
|
||||
// Given a path 'a.b.c', create (as necessary) `start.a`,
|
||||
// `start.a.b`, and `start.a.b.c`, assigning `value` to `start.a.b.c`.
|
||||
// If `a` or `b` are arrays and have items in them, the last item in the
|
||||
// array is used as the context for the next sub-path.
|
||||
function deepRef(start, keys, value, line, column) {
|
||||
var traversed = [];
|
||||
var traversedPath = "";
|
||||
var path = keys.join(".");
|
||||
var ctx = start;
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
traversed.push(key);
|
||||
traversedPath = traversed.join(".");
|
||||
if (typeof ctx[key] === "undefined") {
|
||||
if (i === keys.length - 1) {
|
||||
ctx[key] = value;
|
||||
} else {
|
||||
ctx[key] = Object.create(null);
|
||||
}
|
||||
} else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) {
|
||||
// already a non-object value at key, can't be used as part of a new path
|
||||
genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
|
||||
}
|
||||
|
||||
ctx = ctx[key];
|
||||
if (ctx instanceof Array && ctx.length && i < keys.length - 1) {
|
||||
ctx = ctx[ctx.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
function reduceArrayWithTypeChecking(array) {
|
||||
// Ensure that all items in the array are of the same type
|
||||
var firstType = null;
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var node = array[i];
|
||||
if (firstType === null) {
|
||||
firstType = node.type;
|
||||
} else {
|
||||
if (node.type !== firstType) {
|
||||
genError("Cannot add value of type " + node.type + " to array of type " +
|
||||
firstType + ".", node.line, node.column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively reduce array of nodes into array of the nodes' values
|
||||
return array.map(reduceValueNode);
|
||||
}
|
||||
|
||||
function quoteDottedString(str) {
|
||||
if (str.indexOf(".") > -1) {
|
||||
return "\"" + str + "\"";
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
compile: compile
|
||||
};
|
||||
3841
node_modules/toml/lib/parser.js
generated
vendored
3841
node_modules/toml/lib/parser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
24
node_modules/toml/package.json
generated
vendored
24
node_modules/toml/package.json
generated
vendored
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "toml",
|
||||
"version": "3.0.0",
|
||||
"description": "TOML parser for Node.js (parses TOML spec v0.4.0)",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"build": "pegjs --cache src/toml.pegjs lib/parser.js",
|
||||
"test": "jshint lib/compiler.js && nodeunit test/test_*.js",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"repository": "git://github.com/BinaryMuse/toml-node.git",
|
||||
"keywords": [
|
||||
"toml",
|
||||
"parser"
|
||||
],
|
||||
"author": "Michelle Tilley <michelle@michelletilley.net>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"jshint": "*",
|
||||
"nodeunit": "~0.9.0",
|
||||
"pegjs": "~0.8.0"
|
||||
}
|
||||
}
|
||||
231
node_modules/toml/src/toml.pegjs
generated
vendored
231
node_modules/toml/src/toml.pegjs
generated
vendored
@@ -1,231 +0,0 @@
|
||||
{
|
||||
var nodes = [];
|
||||
|
||||
function genError(err, line, col) {
|
||||
var ex = new Error(err);
|
||||
ex.line = line;
|
||||
ex.column = col;
|
||||
throw ex;
|
||||
}
|
||||
|
||||
function addNode(node) {
|
||||
nodes.push(node);
|
||||
}
|
||||
|
||||
function node(type, value, line, column, key) {
|
||||
var obj = { type: type, value: value, line: line(), column: column() };
|
||||
if (key) obj.key = key;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function convertCodePoint(str, line, col) {
|
||||
var num = parseInt("0x" + str);
|
||||
|
||||
if (
|
||||
!isFinite(num) ||
|
||||
Math.floor(num) != num ||
|
||||
num < 0 ||
|
||||
num > 0x10FFFF ||
|
||||
(num > 0xD7FF && num < 0xE000)
|
||||
) {
|
||||
genError("Invalid Unicode escape code: " + str, line, col);
|
||||
} else {
|
||||
return fromCodePoint(num);
|
||||
}
|
||||
}
|
||||
|
||||
function fromCodePoint() {
|
||||
var MAX_SIZE = 0x4000;
|
||||
var codeUnits = [];
|
||||
var highSurrogate;
|
||||
var lowSurrogate;
|
||||
var index = -1;
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return '';
|
||||
}
|
||||
var result = '';
|
||||
while (++index < length) {
|
||||
var codePoint = Number(arguments[index]);
|
||||
if (codePoint <= 0xFFFF) { // BMP code point
|
||||
codeUnits.push(codePoint);
|
||||
} else { // Astral code point; split in surrogate halves
|
||||
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
codePoint -= 0x10000;
|
||||
highSurrogate = (codePoint >> 10) + 0xD800;
|
||||
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
||||
codeUnits.push(highSurrogate, lowSurrogate);
|
||||
}
|
||||
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
||||
result += String.fromCharCode.apply(null, codeUnits);
|
||||
codeUnits.length = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
start
|
||||
= line* { return nodes }
|
||||
|
||||
line
|
||||
= S* expr:expression S* comment* (NL+ / EOF)
|
||||
/ S+ (NL+ / EOF)
|
||||
/ NL
|
||||
|
||||
expression
|
||||
= comment / path / tablearray / assignment
|
||||
|
||||
comment
|
||||
= '#' (!(NL / EOF) .)*
|
||||
|
||||
path
|
||||
= '[' S* name:table_key S* ']' { addNode(node('ObjectPath', name, line, column)) }
|
||||
|
||||
tablearray
|
||||
= '[' '[' S* name:table_key S* ']' ']' { addNode(node('ArrayPath', name, line, column)) }
|
||||
|
||||
table_key
|
||||
= parts:dot_ended_table_key_part+ name:table_key_part { return parts.concat(name) }
|
||||
/ name:table_key_part { return [name] }
|
||||
|
||||
table_key_part
|
||||
= S* name:key S* { return name }
|
||||
/ S* name:quoted_key S* { return name }
|
||||
|
||||
dot_ended_table_key_part
|
||||
= S* name:key S* '.' S* { return name }
|
||||
/ S* name:quoted_key S* '.' S* { return name }
|
||||
|
||||
assignment
|
||||
= key:key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
|
||||
/ key:quoted_key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
|
||||
|
||||
key
|
||||
= chars:ASCII_BASIC+ { return chars.join('') }
|
||||
|
||||
quoted_key
|
||||
= node:double_quoted_single_line_string { return node.value }
|
||||
/ node:single_quoted_single_line_string { return node.value }
|
||||
|
||||
value
|
||||
= string / datetime / float / integer / boolean / array / inline_table
|
||||
|
||||
string
|
||||
= double_quoted_multiline_string
|
||||
/ double_quoted_single_line_string
|
||||
/ single_quoted_multiline_string
|
||||
/ single_quoted_single_line_string
|
||||
|
||||
double_quoted_multiline_string
|
||||
= '"""' NL? chars:multiline_string_char* '"""' { return node('String', chars.join(''), line, column) }
|
||||
double_quoted_single_line_string
|
||||
= '"' chars:string_char* '"' { return node('String', chars.join(''), line, column) }
|
||||
single_quoted_multiline_string
|
||||
= "'''" NL? chars:multiline_literal_char* "'''" { return node('String', chars.join(''), line, column) }
|
||||
single_quoted_single_line_string
|
||||
= "'" chars:literal_char* "'" { return node('String', chars.join(''), line, column) }
|
||||
|
||||
string_char
|
||||
= ESCAPED / (!'"' char:. { return char })
|
||||
|
||||
literal_char
|
||||
= (!"'" char:. { return char })
|
||||
|
||||
multiline_string_char
|
||||
= ESCAPED / multiline_string_delim / (!'"""' char:. { return char})
|
||||
|
||||
multiline_string_delim
|
||||
= '\\' NL NLS* { return '' }
|
||||
|
||||
multiline_literal_char
|
||||
= (!"'''" char:. { return char })
|
||||
|
||||
float
|
||||
= left:(float_text / integer_text) ('e' / 'E') right:integer_text { return node('Float', parseFloat(left + 'e' + right), line, column) }
|
||||
/ text:float_text { return node('Float', parseFloat(text), line, column) }
|
||||
|
||||
float_text
|
||||
= '+'? digits:(DIGITS '.' DIGITS) { return digits.join('') }
|
||||
/ '-' digits:(DIGITS '.' DIGITS) { return '-' + digits.join('') }
|
||||
|
||||
integer
|
||||
= text:integer_text { return node('Integer', parseInt(text, 10), line, column) }
|
||||
|
||||
integer_text
|
||||
= '+'? digits:DIGIT+ !'.' { return digits.join('') }
|
||||
/ '-' digits:DIGIT+ !'.' { return '-' + digits.join('') }
|
||||
|
||||
boolean
|
||||
= 'true' { return node('Boolean', true, line, column) }
|
||||
/ 'false' { return node('Boolean', false, line, column) }
|
||||
|
||||
array
|
||||
= '[' array_sep* ']' { return node('Array', [], line, column) }
|
||||
/ '[' value:array_value? ']' { return node('Array', value ? [value] : [], line, column) }
|
||||
/ '[' values:array_value_list+ ']' { return node('Array', values, line, column) }
|
||||
/ '[' values:array_value_list+ value:array_value ']' { return node('Array', values.concat(value), line, column) }
|
||||
|
||||
array_value
|
||||
= array_sep* value:value array_sep* { return value }
|
||||
|
||||
array_value_list
|
||||
= array_sep* value:value array_sep* ',' array_sep* { return value }
|
||||
|
||||
array_sep
|
||||
= S / NL / comment
|
||||
|
||||
inline_table
|
||||
= '{' S* values:inline_table_assignment* S* '}' { return node('InlineTable', values, line, column) }
|
||||
|
||||
inline_table_assignment
|
||||
= S* key:key S* '=' S* value:value S* ',' S* { return node('InlineTableValue', value, line, column, key) }
|
||||
/ S* key:key S* '=' S* value:value { return node('InlineTableValue', value, line, column, key) }
|
||||
|
||||
secfragment
|
||||
= '.' digits:DIGITS { return "." + digits }
|
||||
|
||||
date
|
||||
= date:(
|
||||
DIGIT DIGIT DIGIT DIGIT
|
||||
'-'
|
||||
DIGIT DIGIT
|
||||
'-'
|
||||
DIGIT DIGIT
|
||||
) { return date.join('') }
|
||||
|
||||
time
|
||||
= time:(DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?) { return time.join('') }
|
||||
|
||||
time_with_offset
|
||||
= time:(
|
||||
DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?
|
||||
('-' / '+')
|
||||
DIGIT DIGIT ':' DIGIT DIGIT
|
||||
) { return time.join('') }
|
||||
|
||||
datetime
|
||||
= date:date 'T' time:time 'Z' { return node('Date', new Date(date + "T" + time + "Z"), line, column) }
|
||||
/ date:date 'T' time:time_with_offset { return node('Date', new Date(date + "T" + time), line, column) }
|
||||
|
||||
|
||||
S = [ \t]
|
||||
NL = "\n" / "\r" "\n"
|
||||
NLS = NL / S
|
||||
EOF = !.
|
||||
HEX = [0-9a-f]i
|
||||
DIGIT = DIGIT_OR_UNDER
|
||||
DIGIT_OR_UNDER = [0-9]
|
||||
/ '_' { return "" }
|
||||
ASCII_BASIC = [A-Za-z0-9_\-]
|
||||
DIGITS = d:DIGIT_OR_UNDER+ { return d.join('') }
|
||||
ESCAPED = '\\"' { return '"' }
|
||||
/ '\\\\' { return '\\' }
|
||||
/ '\\b' { return '\b' }
|
||||
/ '\\t' { return '\t' }
|
||||
/ '\\n' { return '\n' }
|
||||
/ '\\f' { return '\f' }
|
||||
/ '\\r' { return '\r' }
|
||||
/ ESCAPED_UNICODE
|
||||
ESCAPED_UNICODE = "\\U" digits:(HEX HEX HEX HEX HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }
|
||||
/ "\\u" digits:(HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }
|
||||
5
node_modules/toml/test/bad.toml
generated
vendored
5
node_modules/toml/test/bad.toml
generated
vendored
@@ -1,5 +0,0 @@
|
||||
[something]
|
||||
awesome = "this is"
|
||||
|
||||
[something.awesome]
|
||||
this = "isn't"
|
||||
32
node_modules/toml/test/example.toml
generated
vendored
32
node_modules/toml/test/example.toml
generated
vendored
@@ -1,32 +0,0 @@
|
||||
# This is a TOML document. Boom.
|
||||
|
||||
title = "TOML Example"
|
||||
|
||||
[owner]
|
||||
name = "Tom Preston-Werner"
|
||||
organization = "GitHub"
|
||||
bio = "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\"
|
||||
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
|
||||
|
||||
[database]
|
||||
server = "192.168.1.1"
|
||||
ports = [ 8001, 8001, 8003 ]
|
||||
connection_max = 5000
|
||||
connection_min = -2 # Don't ask me how
|
||||
max_temp = 87.1 # It's a float
|
||||
min_temp = -17.76
|
||||
enabled = true
|
||||
|
||||
[servers]
|
||||
|
||||
# You can indent as you please. Tabs or spaces. TOML don't care.
|
||||
[servers.alpha]
|
||||
ip = "10.0.0.1"
|
||||
dc = "eqdc10"
|
||||
|
||||
[servers.beta]
|
||||
ip = "10.0.0.2"
|
||||
dc = "eqdc10"
|
||||
|
||||
[clients]
|
||||
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
|
||||
33
node_modules/toml/test/hard_example.toml
generated
vendored
33
node_modules/toml/test/hard_example.toml
generated
vendored
@@ -1,33 +0,0 @@
|
||||
# Test file for TOML
|
||||
# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate
|
||||
# This part you'll really hate
|
||||
|
||||
[the]
|
||||
test_string = "You'll hate me after this - #" # " Annoying, isn't it?
|
||||
|
||||
[the.hard]
|
||||
test_array = [ "] ", " # "] # ] There you go, parse this!
|
||||
test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ]
|
||||
# You didn't think it'd as easy as chucking out the last #, did you?
|
||||
another_test_string = " Same thing, but with a string #"
|
||||
harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too"
|
||||
# Things will get harder
|
||||
|
||||
[the.hard."bit#"]
|
||||
"what?" = "You don't think some user won't do that?"
|
||||
multi_line_array = [
|
||||
"]",
|
||||
# ] Oh yes I did
|
||||
]
|
||||
|
||||
# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test
|
||||
|
||||
#[error] if you didn't catch this, your parser is broken
|
||||
#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this
|
||||
#array = [
|
||||
# "This might most likely happen in multiline arrays",
|
||||
# Like here,
|
||||
# "or here,
|
||||
# and here"
|
||||
# ] End of array comment, forgot the #
|
||||
#number = 3.14 pi <--again forgot the #
|
||||
10
node_modules/toml/test/inline_tables.toml
generated
vendored
10
node_modules/toml/test/inline_tables.toml
generated
vendored
@@ -1,10 +0,0 @@
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
nested = { x = { a = { b = 3 } } }
|
||||
|
||||
points = [ { x = 1, y = 2, z = 3 },
|
||||
{ x = 7, y = 8, z = 9 },
|
||||
{ x = 2, y = 4, z = 8 } ]
|
||||
|
||||
arrays = [ { x = [1, 2, 3], y = [4, 5, 6] },
|
||||
{ x = [7, 8, 9], y = [0, 1, 2] } ]
|
||||
5
node_modules/toml/test/literal_strings.toml
generated
vendored
5
node_modules/toml/test/literal_strings.toml
generated
vendored
@@ -1,5 +0,0 @@
|
||||
# What you see is what you get.
|
||||
winpath = 'C:\Users\nodejs\templates'
|
||||
winpath2 = '\\ServerX\admin$\system32\'
|
||||
quoted = 'Tom "Dubs" Preston-Werner'
|
||||
regex = '<\i\c*\s*>'
|
||||
15
node_modules/toml/test/multiline_eat_whitespace.toml
generated
vendored
15
node_modules/toml/test/multiline_eat_whitespace.toml
generated
vendored
@@ -1,15 +0,0 @@
|
||||
# The following strings are byte-for-byte equivalent:
|
||||
key1 = "The quick brown fox jumps over the lazy dog."
|
||||
|
||||
key2 = """
|
||||
The quick brown \
|
||||
|
||||
|
||||
fox jumps over \
|
||||
the lazy dog."""
|
||||
|
||||
key3 = """\
|
||||
The quick brown \
|
||||
fox jumps over \
|
||||
the lazy dog.\
|
||||
"""
|
||||
7
node_modules/toml/test/multiline_literal_strings.toml
generated
vendored
7
node_modules/toml/test/multiline_literal_strings.toml
generated
vendored
@@ -1,7 +0,0 @@
|
||||
regex2 = '''I [dw]on't need \d{2} apples'''
|
||||
lines = '''
|
||||
The first newline is
|
||||
trimmed in raw strings.
|
||||
All other whitespace
|
||||
is preserved.
|
||||
'''
|
||||
6
node_modules/toml/test/multiline_strings.toml
generated
vendored
6
node_modules/toml/test/multiline_strings.toml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
# The following strings are byte-for-byte equivalent:
|
||||
key1 = "One\nTwo"
|
||||
key2 = """One\nTwo"""
|
||||
key3 = """
|
||||
One
|
||||
Two"""
|
||||
22
node_modules/toml/test/smoke.js
generated
vendored
22
node_modules/toml/test/smoke.js
generated
vendored
@@ -1,22 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var parser = require('../index');
|
||||
|
||||
var codes = [
|
||||
"# test\n my.key=\"value\"\nother = 101\nthird = -37",
|
||||
"first = 1.2\nsecond = -56.02\nth = true\nfth = false",
|
||||
"time = 1979-05-27T07:32:00Z",
|
||||
"test = [\"one\", ]",
|
||||
"test = [[1, 2,], [true, false,],]",
|
||||
"[my.sub.path]\nkey = true\nother = -15.3\n[my.sub]\nkey=false",
|
||||
"arry = [\"one\", \"two\",\"thr\nee\", \"\\u03EA\"]",
|
||||
fs.readFileSync(__dirname + '/example.toml', 'utf8'),
|
||||
fs.readFileSync(__dirname + '/hard_example.toml', 'utf8')
|
||||
]
|
||||
|
||||
console.log("=============================================");
|
||||
for(i in codes) {
|
||||
var code = codes[i];
|
||||
console.log(code + "\n");
|
||||
console.log(JSON.stringify(parser.parse(code)));
|
||||
console.log("=============================================");
|
||||
}
|
||||
10
node_modules/toml/test/table_arrays_easy.toml
generated
vendored
10
node_modules/toml/test/table_arrays_easy.toml
generated
vendored
@@ -1,10 +0,0 @@
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
31
node_modules/toml/test/table_arrays_hard.toml
generated
vendored
31
node_modules/toml/test/table_arrays_hard.toml
generated
vendored
@@ -1,31 +0,0 @@
|
||||
[[fruit]]
|
||||
name = "durian"
|
||||
variety = []
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
|
||||
[[fruit]]
|
||||
name = "orange"
|
||||
|
||||
[fruit.physical]
|
||||
color = "orange"
|
||||
shape = "round"
|
||||
596
node_modules/toml/test/test_toml.js
generated
vendored
596
node_modules/toml/test/test_toml.js
generated
vendored
@@ -1,596 +0,0 @@
|
||||
var toml = require('../');
|
||||
var fs = require('fs');
|
||||
|
||||
var assert = require("nodeunit").assert;
|
||||
|
||||
assert.parsesToml = function(tomlStr, expected) {
|
||||
try {
|
||||
var actual = toml.parse(tomlStr);
|
||||
} catch (e) {
|
||||
var errInfo = "line: " + e.line + ", column: " + e.column;
|
||||
return assert.fail("TOML parse error: " + e.message, errInfo, null, "at", assert.parsesToml);
|
||||
}
|
||||
return assert.deepEqual(actual, expected);
|
||||
};
|
||||
|
||||
var exampleExpected = {
|
||||
title: "TOML Example",
|
||||
owner: {
|
||||
name: "Tom Preston-Werner",
|
||||
organization: "GitHub",
|
||||
bio: "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\",
|
||||
dob: new Date("1979-05-27T07:32:00Z")
|
||||
},
|
||||
database: {
|
||||
server: "192.168.1.1",
|
||||
ports: [8001, 8001, 8003],
|
||||
connection_max: 5000,
|
||||
connection_min: -2,
|
||||
max_temp: 87.1,
|
||||
min_temp: -17.76,
|
||||
enabled: true
|
||||
},
|
||||
servers: {
|
||||
alpha: {
|
||||
ip: "10.0.0.1",
|
||||
dc: "eqdc10"
|
||||
},
|
||||
beta: {
|
||||
ip: "10.0.0.2",
|
||||
dc: "eqdc10"
|
||||
}
|
||||
},
|
||||
clients: {
|
||||
data: [ ["gamma", "delta"], [1, 2] ]
|
||||
}
|
||||
};
|
||||
|
||||
var hardExampleExpected = {
|
||||
the: {
|
||||
hard: {
|
||||
another_test_string: ' Same thing, but with a string #',
|
||||
'bit#': {
|
||||
multi_line_array: [']'],
|
||||
'what?': "You don't think some user won't do that?"
|
||||
},
|
||||
harder_test_string: " And when \"'s are in the string, along with # \"",
|
||||
test_array: ['] ', ' # '],
|
||||
test_array2: ['Test #11 ]proved that', 'Experiment #9 was a success']
|
||||
},
|
||||
test_string: "You'll hate me after this - #"
|
||||
}
|
||||
};
|
||||
|
||||
var easyTableArrayExpected = {
|
||||
"products": [
|
||||
{ "name": "Hammer", "sku": 738594937 },
|
||||
{ },
|
||||
{ "name": "Nail", "sku": 284758393, "color": "gray" }
|
||||
]
|
||||
};
|
||||
|
||||
var hardTableArrayExpected = {
|
||||
"fruit": [
|
||||
{
|
||||
"name": "durian",
|
||||
"variety": []
|
||||
},
|
||||
{
|
||||
"name": "apple",
|
||||
"physical": {
|
||||
"color": "red",
|
||||
"shape": "round"
|
||||
},
|
||||
"variety": [
|
||||
{ "name": "red delicious" },
|
||||
{ "name": "granny smith" }
|
||||
]
|
||||
},
|
||||
{},
|
||||
{
|
||||
"name": "banana",
|
||||
"variety": [
|
||||
{ "name": "plantain" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "orange",
|
||||
"physical": {
|
||||
"color": "orange",
|
||||
"shape": "round"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
var badInputs = [
|
||||
'[error] if you didn\'t catch this, your parser is broken',
|
||||
'string = "Anything other than tabs, spaces and newline after a table or key value pair has ended should produce an error unless it is a comment" like this',
|
||||
'array = [\n \"This might most likely happen in multiline arrays\",\n Like here,\n \"or here,\n and here\"\n ] End of array comment, forgot the #',
|
||||
'number = 3.14 pi <--again forgot the #'
|
||||
];
|
||||
|
||||
exports.testParsesExample = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/example.toml", 'utf-8')
|
||||
test.parsesToml(str, exampleExpected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testParsesHardExample = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/hard_example.toml", 'utf-8')
|
||||
test.parsesToml(str, hardExampleExpected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testEasyTableArrays = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/table_arrays_easy.toml", 'utf8')
|
||||
test.parsesToml(str, easyTableArrayExpected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testHarderTableArrays = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/table_arrays_hard.toml", 'utf8')
|
||||
test.parsesToml(str, hardTableArrayExpected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testSupportsTrailingCommasInArrays = function(test) {
|
||||
var str = 'arr = [1, 2, 3,]';
|
||||
var expected = { arr: [1, 2, 3] };
|
||||
test.parsesToml(str, expected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testSingleElementArrayWithNoTrailingComma = function(test) {
|
||||
var str = "a = [1]";
|
||||
test.parsesToml(str, {
|
||||
a: [1]
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testEmptyArray = function(test) {
|
||||
var str = "a = []";
|
||||
test.parsesToml(str, {
|
||||
a: []
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testArrayWithWhitespace = function(test) {
|
||||
var str = "[versions]\nfiles = [\n 3, \n 5 \n\n ]";
|
||||
test.parsesToml(str, {
|
||||
versions: {
|
||||
files: [3, 5]
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testEmptyArrayWithWhitespace = function(test) {
|
||||
var str = "[versions]\nfiles = [\n \n ]";
|
||||
test.parsesToml(str, {
|
||||
versions: {
|
||||
files: []
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testDefineOnSuperkey = function(test) {
|
||||
var str = "[a.b]\nc = 1\n\n[a]\nd = 2";
|
||||
var expected = {
|
||||
a: {
|
||||
b: {
|
||||
c: 1
|
||||
},
|
||||
d: 2
|
||||
}
|
||||
};
|
||||
test.parsesToml(str, expected);
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testWhitespace = function(test) {
|
||||
var str = "a = 1\n \n b = 2 ";
|
||||
test.parsesToml(str, {
|
||||
a: 1, b: 2
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testUnicode = function(test) {
|
||||
var str = "str = \"My name is Jos\\u00E9\"";
|
||||
test.parsesToml(str, {
|
||||
str: "My name is Jos\u00E9"
|
||||
});
|
||||
|
||||
var str = "str = \"My name is Jos\\U000000E9\"";
|
||||
test.parsesToml(str, {
|
||||
str: "My name is Jos\u00E9"
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testMultilineStrings = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/multiline_strings.toml", 'utf8');
|
||||
test.parsesToml(str, {
|
||||
key1: "One\nTwo",
|
||||
key2: "One\nTwo",
|
||||
key3: "One\nTwo"
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testMultilineEatWhitespace = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/multiline_eat_whitespace.toml", 'utf8');
|
||||
test.parsesToml(str, {
|
||||
key1: "The quick brown fox jumps over the lazy dog.",
|
||||
key2: "The quick brown fox jumps over the lazy dog.",
|
||||
key3: "The quick brown fox jumps over the lazy dog."
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testLiteralStrings = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/literal_strings.toml", 'utf8');
|
||||
test.parsesToml(str, {
|
||||
winpath: "C:\\Users\\nodejs\\templates",
|
||||
winpath2: "\\\\ServerX\\admin$\\system32\\",
|
||||
quoted: "Tom \"Dubs\" Preston-Werner",
|
||||
regex: "<\\i\\c*\\s*>"
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testMultilineLiteralStrings = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/multiline_literal_strings.toml", 'utf8');
|
||||
test.parsesToml(str, {
|
||||
regex2: "I [dw]on't need \\d{2} apples",
|
||||
lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testIntegerFormats = function(test) {
|
||||
var str = "a = +99\nb = 42\nc = 0\nd = -17\ne = 1_000_001\nf = 1_2_3_4_5 # why u do dis";
|
||||
test.parsesToml(str, {
|
||||
a: 99,
|
||||
b: 42,
|
||||
c: 0,
|
||||
d: -17,
|
||||
e: 1000001,
|
||||
f: 12345
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testFloatFormats = function(test) {
|
||||
var str = "a = +1.0\nb = 3.1415\nc = -0.01\n" +
|
||||
"d = 5e+22\ne = 1e6\nf = -2E-2\n" +
|
||||
"g = 6.626e-34\n" +
|
||||
"h = 9_224_617.445_991_228_313\n" +
|
||||
"i = 1e1_000";
|
||||
test.parsesToml(str, {
|
||||
a: 1.0,
|
||||
b: 3.1415,
|
||||
c: -0.01,
|
||||
d: 5e22,
|
||||
e: 1e6,
|
||||
f: -2e-2,
|
||||
g: 6.626e-34,
|
||||
h: 9224617.445991228313,
|
||||
i: 1e1000
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testDate = function(test) {
|
||||
var date = new Date("1979-05-27T07:32:00Z");
|
||||
test.parsesToml("a = 1979-05-27T07:32:00Z", {
|
||||
a: date
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testDateWithOffset = function(test) {
|
||||
var date1 = new Date("1979-05-27T07:32:00-07:00"),
|
||||
date2 = new Date("1979-05-27T07:32:00+02:00");
|
||||
test.parsesToml("a = 1979-05-27T07:32:00-07:00\nb = 1979-05-27T07:32:00+02:00", {
|
||||
a: date1,
|
||||
b: date2
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testDateWithSecondFraction = function(test) {
|
||||
var date = new Date("1979-05-27T00:32:00.999999-07:00");
|
||||
test.parsesToml("a = 1979-05-27T00:32:00.999999-07:00", {
|
||||
a: date
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testDateFromIsoString = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/20
|
||||
var date = new Date(),
|
||||
dateStr = date.toISOString(),
|
||||
tomlStr = "a = " + dateStr;
|
||||
|
||||
test.parsesToml(tomlStr, {
|
||||
a: date
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testLeadingNewlines = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/22
|
||||
var str = "\ntest = \"ing\"";
|
||||
test.parsesToml(str, {
|
||||
test: "ing"
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testInlineTables = function(test) {
|
||||
var str = fs.readFileSync(__dirname + "/inline_tables.toml", 'utf8');
|
||||
test.parsesToml(str, {
|
||||
name: {
|
||||
first: "Tom",
|
||||
last: "Preston-Werner"
|
||||
},
|
||||
point: {
|
||||
x: 1,
|
||||
y: 2
|
||||
},
|
||||
nested: {
|
||||
x: {
|
||||
a: {
|
||||
b: 3
|
||||
}
|
||||
}
|
||||
},
|
||||
points: [
|
||||
{ x: 1, y: 2, z: 3 },
|
||||
{ x: 7, y: 8, z: 9 },
|
||||
{ x: 2, y: 4, z: 8 }
|
||||
],
|
||||
arrays: [
|
||||
{ x: [1, 2, 3], y: [4, 5, 6] },
|
||||
{ x: [7, 8, 9], y: [0, 1, 2] }
|
||||
]
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testEmptyInlineTables = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/24
|
||||
var str = "a = { }";
|
||||
test.parsesToml(str, {
|
||||
a: {}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testKeyNamesWithWhitespaceAroundStartAndFinish = function(test) {
|
||||
var str = "[ a ]\nb = 1";
|
||||
test.parsesToml(str, {
|
||||
a: {
|
||||
b: 1
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testKeyNamesWithWhitespaceAroundDots = function(test) {
|
||||
var str = "[ a . b . c]\nd = 1";
|
||||
test.parsesToml(str, {
|
||||
a: {
|
||||
b: {
|
||||
c: {
|
||||
d: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testSimpleQuotedKeyNames = function(test) {
|
||||
var str = "[\"ʞ\"]\na = 1";
|
||||
test.parsesToml(str, {
|
||||
"ʞ": {
|
||||
a: 1
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testComplexQuotedKeyNames = function(test) {
|
||||
var str = "[ a . \"ʞ\" . c ]\nd = 1";
|
||||
test.parsesToml(str, {
|
||||
a: {
|
||||
"ʞ": {
|
||||
c: {
|
||||
d: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testEscapedQuotesInQuotedKeyNames = function(test) {
|
||||
test.parsesToml("[\"the \\\"thing\\\"\"]\na = true", {
|
||||
'the "thing"': {
|
||||
a: true
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testMoreComplexQuotedKeyNames = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/21
|
||||
test.parsesToml('["the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
|
||||
"the\\ key": {
|
||||
one: "one",
|
||||
two: 2,
|
||||
three: false
|
||||
}
|
||||
});
|
||||
test.parsesToml('[a."the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
|
||||
a: {
|
||||
"the\\ key": {
|
||||
one: "one",
|
||||
two: 2,
|
||||
three: false
|
||||
}
|
||||
}
|
||||
});
|
||||
test.parsesToml('[a."the-key"]\n\none = "one"\ntwo = 2\nthree = false', {
|
||||
a: {
|
||||
"the-key": {
|
||||
one: "one",
|
||||
two: 2,
|
||||
three: false
|
||||
}
|
||||
}
|
||||
});
|
||||
test.parsesToml('[a."the.key"]\n\none = "one"\ntwo = 2\nthree = false', {
|
||||
a: {
|
||||
"the.key": {
|
||||
one: "one",
|
||||
two: 2,
|
||||
three: false
|
||||
}
|
||||
}
|
||||
});
|
||||
// https://github.com/BinaryMuse/toml-node/issues/34
|
||||
test.parsesToml('[table]\n\'a "quoted value"\' = "value"', {
|
||||
table: {
|
||||
'a "quoted value"': "value"
|
||||
}
|
||||
});
|
||||
// https://github.com/BinaryMuse/toml-node/issues/33
|
||||
test.parsesToml('[module]\n"foo=bar" = "zzz"', {
|
||||
module: {
|
||||
"foo=bar": "zzz"
|
||||
}
|
||||
});
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorOnBadUnicode = function(test) {
|
||||
var str = "str = \"My name is Jos\\uD800\"";
|
||||
test.throws(function() {
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorOnDotAtStartOfKey = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[.a]\nb = 1";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnDotAtEndOfKey = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[.a]\nb = 1";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnTableOverride = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[a]\nb = 1\n\n[a]\nc = 2";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnKeyOverride = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[a]\nb = 1\n[a.b]\nc = 2";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnKeyOverrideWithNested = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/23
|
||||
test.throws(function() {
|
||||
var str = "[a]\nb = \"a\"\n[a.b.c]";
|
||||
toml.parse(str);
|
||||
}, "existing key 'a.b'");
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorOnKeyOverrideWithArrayTable = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[a]\nb = 1\n[[a]]\nc = 2";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnKeyReplace = function(test) {
|
||||
test.throws(function() {
|
||||
var str = "[a]\nb = 1\nb = 2";
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done()
|
||||
};
|
||||
|
||||
exports.testErrorOnInlineTableReplace = function(test) {
|
||||
// https://github.com/BinaryMuse/toml-node/issues/25
|
||||
test.throws(function() {
|
||||
var str = "a = { b = 1 }\n[a]\nc = 2";
|
||||
toml.parse(str);
|
||||
}, "existing key 'a'");
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorOnArrayMismatch = function(test) {
|
||||
test.throws(function() {
|
||||
var str = 'data = [1, 2, "test"]'
|
||||
toml.parse(str);
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorOnBadInputs = function(test) {
|
||||
var count = 0;
|
||||
for (i in badInputs) {
|
||||
(function(num) {
|
||||
test.throws(function() {
|
||||
toml.parse(badInputs[num]);
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports.testErrorsHaveCorrectLineAndColumn = function(test) {
|
||||
var str = "[a]\nb = 1\n [a.b]\nc = 2";
|
||||
try { toml.parse(str); }
|
||||
catch (e) {
|
||||
test.equal(e.line, 3);
|
||||
test.equal(e.column, 2);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
|
||||
exports.testUsingConstructorAsKey = function(test) {
|
||||
test.parsesToml("[empty]\n[emptier]\n[constructor]\nconstructor = 1\n[emptiest]", {
|
||||
"empty": {},
|
||||
"emptier": {},
|
||||
"constructor": { "constructor": 1 },
|
||||
"emptiest": {}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
4
node_modules/tr46/.npmignore
generated
vendored
Normal file
4
node_modules/tr46/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
scripts/
|
||||
test/
|
||||
|
||||
!lib/mapping_table.json
|
||||
193
node_modules/tr46/index.js
generated
vendored
Normal file
193
node_modules/tr46/index.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
"use strict";
|
||||
|
||||
var punycode = require("punycode");
|
||||
var mappingTable = require("./lib/mappingTable.json");
|
||||
|
||||
var PROCESSING_OPTIONS = {
|
||||
TRANSITIONAL: 0,
|
||||
NONTRANSITIONAL: 1
|
||||
};
|
||||
|
||||
function normalize(str) { // fix bug in v8
|
||||
return str.split('\u0000').map(function (s) { return s.normalize('NFC'); }).join('\u0000');
|
||||
}
|
||||
|
||||
function findStatus(val) {
|
||||
var start = 0;
|
||||
var end = mappingTable.length - 1;
|
||||
|
||||
while (start <= end) {
|
||||
var mid = Math.floor((start + end) / 2);
|
||||
|
||||
var target = mappingTable[mid];
|
||||
if (target[0][0] <= val && target[0][1] >= val) {
|
||||
return target;
|
||||
} else if (target[0][0] > val) {
|
||||
end = mid - 1;
|
||||
} else {
|
||||
start = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
||||
|
||||
function countSymbols(string) {
|
||||
return string
|
||||
// replace every surrogate pair with a BMP symbol
|
||||
.replace(regexAstralSymbols, '_')
|
||||
// then get the length
|
||||
.length;
|
||||
}
|
||||
|
||||
function mapChars(domain_name, useSTD3, processing_option) {
|
||||
var hasError = false;
|
||||
var processed = "";
|
||||
|
||||
var len = countSymbols(domain_name);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var codePoint = domain_name.codePointAt(i);
|
||||
var status = findStatus(codePoint);
|
||||
|
||||
switch (status[1]) {
|
||||
case "disallowed":
|
||||
hasError = true;
|
||||
processed += String.fromCodePoint(codePoint);
|
||||
break;
|
||||
case "ignored":
|
||||
break;
|
||||
case "mapped":
|
||||
processed += String.fromCodePoint.apply(String, status[2]);
|
||||
break;
|
||||
case "deviation":
|
||||
if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) {
|
||||
processed += String.fromCodePoint.apply(String, status[2]);
|
||||
} else {
|
||||
processed += String.fromCodePoint(codePoint);
|
||||
}
|
||||
break;
|
||||
case "valid":
|
||||
processed += String.fromCodePoint(codePoint);
|
||||
break;
|
||||
case "disallowed_STD3_mapped":
|
||||
if (useSTD3) {
|
||||
hasError = true;
|
||||
processed += String.fromCodePoint(codePoint);
|
||||
} else {
|
||||
processed += String.fromCodePoint.apply(String, status[2]);
|
||||
}
|
||||
break;
|
||||
case "disallowed_STD3_valid":
|
||||
if (useSTD3) {
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
processed += String.fromCodePoint(codePoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
string: processed,
|
||||
error: hasError
|
||||
};
|
||||
}
|
||||
|
||||
var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC7F-\uDC82\uDCB0-\uDCBA\uDD00-\uDD02\uDD27-\uDD34\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDE2C-\uDE37\uDEDF-\uDEEA\uDF01-\uDF03\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDE30-\uDE40\uDEAB-\uDEB7]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF51-\uDF7E\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD83A[\uDCD0-\uDCD6]|\uDB40[\uDD00-\uDDEF]/;
|
||||
|
||||
function validateLabel(label, processing_option) {
|
||||
if (label.substr(0, 4) === "xn--") {
|
||||
label = punycode.toUnicode(label);
|
||||
processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL;
|
||||
}
|
||||
|
||||
var error = false;
|
||||
|
||||
if (normalize(label) !== label ||
|
||||
(label[3] === "-" && label[4] === "-") ||
|
||||
label[0] === "-" || label[label.length - 1] === "-" ||
|
||||
label.indexOf(".") !== -1 ||
|
||||
label.search(combiningMarksRegex) === 0) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
var len = countSymbols(label);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var status = findStatus(label.codePointAt(i));
|
||||
if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== "valid") ||
|
||||
(processing === PROCESSING_OPTIONS.NONTRANSITIONAL &&
|
||||
status[1] !== "valid" && status[1] !== "deviation")) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
label: label,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
|
||||
function processing(domain_name, useSTD3, processing_option) {
|
||||
var result = mapChars(domain_name, useSTD3, processing_option);
|
||||
result.string = normalize(result.string);
|
||||
|
||||
var labels = result.string.split(".");
|
||||
for (var i = 0; i < labels.length; ++i) {
|
||||
try {
|
||||
var validation = validateLabel(labels[i]);
|
||||
labels[i] = validation.label;
|
||||
result.error = result.error || validation.error;
|
||||
} catch(e) {
|
||||
result.error = true;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
string: labels.join("."),
|
||||
error: result.error
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) {
|
||||
var result = processing(domain_name, useSTD3, processing_option);
|
||||
var labels = result.string.split(".");
|
||||
labels = labels.map(function(l) {
|
||||
try {
|
||||
return punycode.toASCII(l);
|
||||
} catch(e) {
|
||||
result.error = true;
|
||||
return l;
|
||||
}
|
||||
});
|
||||
|
||||
if (verifyDnsLength) {
|
||||
var total = labels.slice(0, labels.length - 1).join(".").length;
|
||||
if (total.length > 253 || total.length === 0) {
|
||||
result.error = true;
|
||||
}
|
||||
|
||||
for (var i=0; i < labels.length; ++i) {
|
||||
if (labels.length > 63 || labels.length === 0) {
|
||||
result.error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.error) return null;
|
||||
return labels.join(".");
|
||||
};
|
||||
|
||||
module.exports.toUnicode = function(domain_name, useSTD3) {
|
||||
var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL);
|
||||
|
||||
return {
|
||||
domain: result.string,
|
||||
error: result.error
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS;
|
||||
0
node_modules/tr46/lib/.gitkeep
generated
vendored
Normal file
0
node_modules/tr46/lib/.gitkeep
generated
vendored
Normal file
1
node_modules/tr46/lib/mappingTable.json
generated
vendored
Normal file
1
node_modules/tr46/lib/mappingTable.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
node_modules/tr46/package.json
generated
vendored
Normal file
31
node_modules/tr46/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "tr46",
|
||||
"version": "0.0.3",
|
||||
"description": "An implementation of the Unicode TR46 spec",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"pretest": "node scripts/getLatestUnicodeTests.js",
|
||||
"prepublish": "node scripts/generateMappingTable.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Sebmaster/tr46.js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"tr46",
|
||||
"url",
|
||||
"whatwg"
|
||||
],
|
||||
"author": "Sebastian Mayr <npm@smayr.name>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Sebmaster/tr46.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Sebmaster/tr46.js#readme",
|
||||
"devDependencies": {
|
||||
"mocha": "^2.2.5",
|
||||
"request": "^2.57.0"
|
||||
}
|
||||
}
|
||||
229
node_modules/uuid/CHANGELOG.md
generated
vendored
Normal file
229
node_modules/uuid/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [8.3.2](https://github.com/uuidjs/uuid/compare/v8.3.1...v8.3.2) (2020-12-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- lazy load getRandomValues ([#537](https://github.com/uuidjs/uuid/issues/537)) ([16c8f6d](https://github.com/uuidjs/uuid/commit/16c8f6df2f6b09b4d6235602d6a591188320a82e)), closes [#536](https://github.com/uuidjs/uuid/issues/536)
|
||||
|
||||
### [8.3.1](https://github.com/uuidjs/uuid/compare/v8.3.0...v8.3.1) (2020-10-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- support expo>=39.0.0 ([#515](https://github.com/uuidjs/uuid/issues/515)) ([c65a0f3](https://github.com/uuidjs/uuid/commit/c65a0f3fa73b901959d638d1e3591dfacdbed867)), closes [#375](https://github.com/uuidjs/uuid/issues/375)
|
||||
|
||||
## [8.3.0](https://github.com/uuidjs/uuid/compare/v8.2.0...v8.3.0) (2020-07-27)
|
||||
|
||||
### Features
|
||||
|
||||
- add parse/stringify/validate/version/NIL APIs ([#479](https://github.com/uuidjs/uuid/issues/479)) ([0e6c10b](https://github.com/uuidjs/uuid/commit/0e6c10ba1bf9517796ff23c052fc0468eedfd5f4)), closes [#475](https://github.com/uuidjs/uuid/issues/475) [#478](https://github.com/uuidjs/uuid/issues/478) [#480](https://github.com/uuidjs/uuid/issues/480) [#481](https://github.com/uuidjs/uuid/issues/481) [#180](https://github.com/uuidjs/uuid/issues/180)
|
||||
|
||||
## [8.2.0](https://github.com/uuidjs/uuid/compare/v8.1.0...v8.2.0) (2020-06-23)
|
||||
|
||||
### Features
|
||||
|
||||
- improve performance of v1 string representation ([#453](https://github.com/uuidjs/uuid/issues/453)) ([0ee0b67](https://github.com/uuidjs/uuid/commit/0ee0b67c37846529c66089880414d29f3ae132d5))
|
||||
- remove deprecated v4 string parameter ([#454](https://github.com/uuidjs/uuid/issues/454)) ([88ce3ca](https://github.com/uuidjs/uuid/commit/88ce3ca0ba046f60856de62c7ce03f7ba98ba46c)), closes [#437](https://github.com/uuidjs/uuid/issues/437)
|
||||
- support jspm ([#473](https://github.com/uuidjs/uuid/issues/473)) ([e9f2587](https://github.com/uuidjs/uuid/commit/e9f2587a92575cac31bc1d4ae944e17c09756659))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- prepare package exports for webpack 5 ([#468](https://github.com/uuidjs/uuid/issues/468)) ([8d6e6a5](https://github.com/uuidjs/uuid/commit/8d6e6a5f8965ca9575eb4d92e99a43435f4a58a8))
|
||||
|
||||
## [8.1.0](https://github.com/uuidjs/uuid/compare/v8.0.0...v8.1.0) (2020-05-20)
|
||||
|
||||
### Features
|
||||
|
||||
- improve v4 performance by reusing random number array ([#435](https://github.com/uuidjs/uuid/issues/435)) ([bf4af0d](https://github.com/uuidjs/uuid/commit/bf4af0d711b4d2ed03d1f74fd12ad0baa87dc79d))
|
||||
- optimize V8 performance of bytesToUuid ([#434](https://github.com/uuidjs/uuid/issues/434)) ([e156415](https://github.com/uuidjs/uuid/commit/e156415448ec1af2351fa0b6660cfb22581971f2))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- export package.json required by react-native and bundlers ([#449](https://github.com/uuidjs/uuid/issues/449)) ([be1c8fe](https://github.com/uuidjs/uuid/commit/be1c8fe9a3206c358e0059b52fafd7213aa48a52)), closes [ai/nanoevents#44](https://github.com/ai/nanoevents/issues/44#issuecomment-602010343) [#444](https://github.com/uuidjs/uuid/issues/444)
|
||||
|
||||
## [8.0.0](https://github.com/uuidjs/uuid/compare/v7.0.3...v8.0.0) (2020-04-29)
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
- For native ECMAScript Module (ESM) usage in Node.js only named exports are exposed, there is no more default export.
|
||||
|
||||
```diff
|
||||
-import uuid from 'uuid';
|
||||
-console.log(uuid.v4()); // -> 'cd6c3b08-0adc-4f4b-a6ef-36087a1c9869'
|
||||
+import { v4 as uuidv4 } from 'uuid';
|
||||
+uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
|
||||
```
|
||||
|
||||
- Deep requiring specific algorithms of this library like `require('uuid/v4')`, which has been deprecated in `uuid@7`, is no longer supported.
|
||||
|
||||
Instead use the named exports that this module exports.
|
||||
|
||||
For ECMAScript Modules (ESM):
|
||||
|
||||
```diff
|
||||
-import uuidv4 from 'uuid/v4';
|
||||
+import { v4 as uuidv4 } from 'uuid';
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
For CommonJS:
|
||||
|
||||
```diff
|
||||
-const uuidv4 = require('uuid/v4');
|
||||
+const { v4: uuidv4 } = require('uuid');
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
- native Node.js ES Modules (wrapper approach) ([#423](https://github.com/uuidjs/uuid/issues/423)) ([2d9f590](https://github.com/uuidjs/uuid/commit/2d9f590ad9701d692625c07ed62f0a0f91227991)), closes [#245](https://github.com/uuidjs/uuid/issues/245) [#419](https://github.com/uuidjs/uuid/issues/419) [#342](https://github.com/uuidjs/uuid/issues/342)
|
||||
- remove deep requires ([#426](https://github.com/uuidjs/uuid/issues/426)) ([daf72b8](https://github.com/uuidjs/uuid/commit/daf72b84ceb20272a81bb5fbddb05dd95922cbba))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add CommonJS syntax example to README quickstart section ([#417](https://github.com/uuidjs/uuid/issues/417)) ([e0ec840](https://github.com/uuidjs/uuid/commit/e0ec8402c7ad44b7ef0453036c612f5db513fda0))
|
||||
|
||||
### [7.0.3](https://github.com/uuidjs/uuid/compare/v7.0.2...v7.0.3) (2020-03-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- make deep require deprecation warning work in browsers ([#409](https://github.com/uuidjs/uuid/issues/409)) ([4b71107](https://github.com/uuidjs/uuid/commit/4b71107d8c0d2ef56861ede6403fc9dc35a1e6bf)), closes [#408](https://github.com/uuidjs/uuid/issues/408)
|
||||
|
||||
### [7.0.2](https://github.com/uuidjs/uuid/compare/v7.0.1...v7.0.2) (2020-03-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- make access to msCrypto consistent ([#393](https://github.com/uuidjs/uuid/issues/393)) ([8bf2a20](https://github.com/uuidjs/uuid/commit/8bf2a20f3565df743da7215eebdbada9d2df118c))
|
||||
- simplify link in deprecation warning ([#391](https://github.com/uuidjs/uuid/issues/391)) ([bb2c8e4](https://github.com/uuidjs/uuid/commit/bb2c8e4e9f4c5f9c1eaaf3ea59710c633cd90cb7))
|
||||
- update links to match content in readme ([#386](https://github.com/uuidjs/uuid/issues/386)) ([44f2f86](https://github.com/uuidjs/uuid/commit/44f2f86e9d2bbf14ee5f0f00f72a3db1292666d4))
|
||||
|
||||
### [7.0.1](https://github.com/uuidjs/uuid/compare/v7.0.0...v7.0.1) (2020-02-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- clean up esm builds for node and browser ([#383](https://github.com/uuidjs/uuid/issues/383)) ([59e6a49](https://github.com/uuidjs/uuid/commit/59e6a49e7ce7b3e8fb0f3ee52b9daae72af467dc))
|
||||
- provide browser versions independent from module system ([#380](https://github.com/uuidjs/uuid/issues/380)) ([4344a22](https://github.com/uuidjs/uuid/commit/4344a22e7aed33be8627eeaaf05360f256a21753)), closes [#378](https://github.com/uuidjs/uuid/issues/378)
|
||||
|
||||
## [7.0.0](https://github.com/uuidjs/uuid/compare/v3.4.0...v7.0.0) (2020-02-24)
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
- The default export, which used to be the v4() method but which was already discouraged in v3.x of this library, has been removed.
|
||||
- Explicitly note that deep imports of the different uuid version functions are deprecated and no longer encouraged and that ECMAScript module named imports should be used instead. Emit a deprecation warning for people who deep-require the different algorithm variants.
|
||||
- Remove builtin support for insecure random number generators in the browser. Users who want that will have to supply their own random number generator function.
|
||||
- Remove support for generating v3 and v5 UUIDs in Node.js<4.x
|
||||
- Convert code base to ECMAScript Modules (ESM) and release CommonJS build for node and ESM build for browser bundlers.
|
||||
|
||||
### Features
|
||||
|
||||
- add UMD build to npm package ([#357](https://github.com/uuidjs/uuid/issues/357)) ([4e75adf](https://github.com/uuidjs/uuid/commit/4e75adf435196f28e3fbbe0185d654b5ded7ca2c)), closes [#345](https://github.com/uuidjs/uuid/issues/345)
|
||||
- add various es module and CommonJS examples ([b238510](https://github.com/uuidjs/uuid/commit/b238510bf352463521f74bab175a3af9b7a42555))
|
||||
- ensure that docs are up-to-date in CI ([ee5e77d](https://github.com/uuidjs/uuid/commit/ee5e77db547474f5a8f23d6c857a6d399209986b))
|
||||
- hybrid CommonJS & ECMAScript modules build ([a3f078f](https://github.com/uuidjs/uuid/commit/a3f078faa0baff69ab41aed08e041f8f9c8993d0))
|
||||
- remove insecure fallback random number generator ([3a5842b](https://github.com/uuidjs/uuid/commit/3a5842b141a6e5de0ae338f391661e6b84b167c9)), closes [#173](https://github.com/uuidjs/uuid/issues/173)
|
||||
- remove support for pre Node.js v4 Buffer API ([#356](https://github.com/uuidjs/uuid/issues/356)) ([b59b5c5](https://github.com/uuidjs/uuid/commit/b59b5c5ecad271c5453f1a156f011671f6d35627))
|
||||
- rename repository to github:uuidjs/uuid ([#351](https://github.com/uuidjs/uuid/issues/351)) ([c37a518](https://github.com/uuidjs/uuid/commit/c37a518e367ac4b6d0aa62dba1bc6ce9e85020f7)), closes [#338](https://github.com/uuidjs/uuid/issues/338)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add deep-require proxies for local testing and adjust tests ([#365](https://github.com/uuidjs/uuid/issues/365)) ([7fedc79](https://github.com/uuidjs/uuid/commit/7fedc79ac8fda4bfd1c566c7f05ef4ac13b2db48))
|
||||
- add note about removal of default export ([#372](https://github.com/uuidjs/uuid/issues/372)) ([12749b7](https://github.com/uuidjs/uuid/commit/12749b700eb49db8a9759fd306d8be05dbfbd58c)), closes [#370](https://github.com/uuidjs/uuid/issues/370)
|
||||
- deprecated deep requiring of the different algorithm versions ([#361](https://github.com/uuidjs/uuid/issues/361)) ([c0bdf15](https://github.com/uuidjs/uuid/commit/c0bdf15e417639b1aeb0b247b2fb11f7a0a26b23))
|
||||
|
||||
## [3.4.0](https://github.com/uuidjs/uuid/compare/v3.3.3...v3.4.0) (2020-01-16)
|
||||
|
||||
### Features
|
||||
|
||||
- rename repository to github:uuidjs/uuid ([#351](https://github.com/uuidjs/uuid/issues/351)) ([e2d7314](https://github.com/uuidjs/uuid/commit/e2d7314)), closes [#338](https://github.com/uuidjs/uuid/issues/338)
|
||||
|
||||
## [3.3.3](https://github.com/uuidjs/uuid/compare/v3.3.2...v3.3.3) (2019-08-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- no longer run ci tests on node v4
|
||||
- upgrade dependencies
|
||||
|
||||
## [3.3.2](https://github.com/uuidjs/uuid/compare/v3.3.1...v3.3.2) (2018-06-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- typo ([305d877](https://github.com/uuidjs/uuid/commit/305d877))
|
||||
|
||||
## [3.3.1](https://github.com/uuidjs/uuid/compare/v3.3.0...v3.3.1) (2018-06-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- fix [#284](https://github.com/uuidjs/uuid/issues/284) by setting function name in try-catch ([f2a60f2](https://github.com/uuidjs/uuid/commit/f2a60f2))
|
||||
|
||||
# [3.3.0](https://github.com/uuidjs/uuid/compare/v3.2.1...v3.3.0) (2018-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- assignment to readonly property to allow running in strict mode ([#270](https://github.com/uuidjs/uuid/issues/270)) ([d062fdc](https://github.com/uuidjs/uuid/commit/d062fdc))
|
||||
- fix [#229](https://github.com/uuidjs/uuid/issues/229) ([c9684d4](https://github.com/uuidjs/uuid/commit/c9684d4))
|
||||
- Get correct version of IE11 crypto ([#274](https://github.com/uuidjs/uuid/issues/274)) ([153d331](https://github.com/uuidjs/uuid/commit/153d331))
|
||||
- mem issue when generating uuid ([#267](https://github.com/uuidjs/uuid/issues/267)) ([c47702c](https://github.com/uuidjs/uuid/commit/c47702c))
|
||||
|
||||
### Features
|
||||
|
||||
- enforce Conventional Commit style commit messages ([#282](https://github.com/uuidjs/uuid/issues/282)) ([cc9a182](https://github.com/uuidjs/uuid/commit/cc9a182))
|
||||
|
||||
## [3.2.1](https://github.com/uuidjs/uuid/compare/v3.2.0...v3.2.1) (2018-01-16)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- use msCrypto if available. Fixes [#241](https://github.com/uuidjs/uuid/issues/241) ([#247](https://github.com/uuidjs/uuid/issues/247)) ([1fef18b](https://github.com/uuidjs/uuid/commit/1fef18b))
|
||||
|
||||
# [3.2.0](https://github.com/uuidjs/uuid/compare/v3.1.0...v3.2.0) (2018-01-16)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- remove mistakenly added typescript dependency, rollback version (standard-version will auto-increment) ([09fa824](https://github.com/uuidjs/uuid/commit/09fa824))
|
||||
- use msCrypto if available. Fixes [#241](https://github.com/uuidjs/uuid/issues/241) ([#247](https://github.com/uuidjs/uuid/issues/247)) ([1fef18b](https://github.com/uuidjs/uuid/commit/1fef18b))
|
||||
|
||||
### Features
|
||||
|
||||
- Add v3 Support ([#217](https://github.com/uuidjs/uuid/issues/217)) ([d94f726](https://github.com/uuidjs/uuid/commit/d94f726))
|
||||
|
||||
# [3.1.0](https://github.com/uuidjs/uuid/compare/v3.1.0...v3.0.1) (2017-06-17)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- (fix) Add .npmignore file to exclude test/ and other non-essential files from packing. (#183)
|
||||
- Fix typo (#178)
|
||||
- Simple typo fix (#165)
|
||||
|
||||
### Features
|
||||
|
||||
- v5 support in CLI (#197)
|
||||
- V5 support (#188)
|
||||
|
||||
# 3.0.1 (2016-11-28)
|
||||
|
||||
- split uuid versions into separate files
|
||||
|
||||
# 3.0.0 (2016-11-17)
|
||||
|
||||
- remove .parse and .unparse
|
||||
|
||||
# 2.0.0
|
||||
|
||||
- Removed uuid.BufferClass
|
||||
|
||||
# 1.4.0
|
||||
|
||||
- Improved module context detection
|
||||
- Removed public RNG functions
|
||||
|
||||
# 1.3.2
|
||||
|
||||
- Improve tests and handling of v1() options (Issue #24)
|
||||
- Expose RNG option to allow for perf testing with different generators
|
||||
|
||||
# 1.3.0
|
||||
|
||||
- Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
|
||||
- Support for node.js crypto API
|
||||
- De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
|
||||
18
node_modules/uuid/CONTRIBUTING.md
generated
vendored
Normal file
18
node_modules/uuid/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Contributing
|
||||
|
||||
Please feel free to file GitHub Issues or propose Pull Requests. We're always happy to discuss improvements to this library!
|
||||
|
||||
## Testing
|
||||
|
||||
```shell
|
||||
npm test
|
||||
```
|
||||
|
||||
## Releasing
|
||||
|
||||
Releases are supposed to be done from master, version bumping is automated through [`standard-version`](https://github.com/conventional-changelog/standard-version):
|
||||
|
||||
```shell
|
||||
npm run release -- --dry-run # verify output manually
|
||||
npm run release # follow the instructions from the output of this command
|
||||
```
|
||||
9
node_modules/uuid/LICENSE.md
generated
vendored
Normal file
9
node_modules/uuid/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
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.
|
||||
505
node_modules/uuid/README.md
generated
vendored
Normal file
505
node_modules/uuid/README.md
generated
vendored
Normal file
@@ -0,0 +1,505 @@
|
||||
<!--
|
||||
-- This file is auto-generated from README_js.md. Changes should be made there.
|
||||
-->
|
||||
|
||||
# uuid [](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [](https://github.com/uuidjs/uuid/actions?query=workflow%3ABrowser)
|
||||
|
||||
For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
|
||||
|
||||
- **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs
|
||||
- **Cross-platform** - Support for ...
|
||||
- CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds)
|
||||
- Node 8, 10, 12, 14
|
||||
- Chrome, Safari, Firefox, Edge, IE 11 browsers
|
||||
- Webpack and rollup.js module bundlers
|
||||
- [React Native / Expo](#react-native--expo)
|
||||
- **Secure** - Cryptographically-strong random values
|
||||
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
|
||||
- **CLI** - Includes the [`uuid` command line](#command-line) utility
|
||||
|
||||
**Upgrading from `uuid@3.x`?** Your code is probably okay, but check out [Upgrading From `uuid@3.x`](#upgrading-from-uuid3x) for details.
|
||||
|
||||
## Quickstart
|
||||
|
||||
To create a random UUID...
|
||||
|
||||
**1. Install**
|
||||
|
||||
```shell
|
||||
npm install uuid
|
||||
```
|
||||
|
||||
**2. Create a UUID** (ES6 module syntax)
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
|
||||
```
|
||||
|
||||
... or using CommonJS syntax:
|
||||
|
||||
```javascript
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
|
||||
```
|
||||
|
||||
For timestamp UUIDs, namespace UUIDs, and other options read on ...
|
||||
|
||||
## API Summary
|
||||
|
||||
| | | |
|
||||
| --- | --- | --- |
|
||||
| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
|
||||
| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
|
||||
| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
|
||||
| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
|
||||
| [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | |
|
||||
| [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | |
|
||||
| [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | |
|
||||
| [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` |
|
||||
| [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` |
|
||||
|
||||
## API
|
||||
|
||||
### uuid.NIL
|
||||
|
||||
The nil UUID string (all zeros).
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { NIL as NIL_UUID } from 'uuid';
|
||||
|
||||
NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000'
|
||||
```
|
||||
|
||||
### uuid.parse(str)
|
||||
|
||||
Convert UUID string to array of bytes
|
||||
|
||||
| | |
|
||||
| --------- | ---------------------------------------- |
|
||||
| `str` | A valid UUID `String` |
|
||||
| _returns_ | `Uint8Array[16]` |
|
||||
| _throws_ | `TypeError` if `str` is not a valid UUID |
|
||||
|
||||
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { parse as uuidParse } from 'uuid';
|
||||
|
||||
// Parse a UUID
|
||||
const bytes = uuidParse('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b');
|
||||
|
||||
// Convert to hex strings to show byte order (for documentation purposes)
|
||||
[...bytes].map((v) => v.toString(16).padStart(2, '0')); // ⇨
|
||||
// [
|
||||
// '6e', 'c0', 'bd', '7f',
|
||||
// '11', 'c0', '43', 'da',
|
||||
// '97', '5e', '2a', '8a',
|
||||
// 'd9', 'eb', 'ae', '0b'
|
||||
// ]
|
||||
```
|
||||
|
||||
### uuid.stringify(arr[, offset])
|
||||
|
||||
Convert array of bytes to UUID string
|
||||
|
||||
| | |
|
||||
| -------------- | ---------------------------------------------------------------------------- |
|
||||
| `arr` | `Array`-like collection of 16 values (starting from `offset`) between 0-255. |
|
||||
| [`offset` = 0] | `Number` Starting index in the Array |
|
||||
| _returns_ | `String` |
|
||||
| _throws_ | `TypeError` if a valid UUID string cannot be generated |
|
||||
|
||||
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { stringify as uuidStringify } from 'uuid';
|
||||
|
||||
const uuidBytes = [
|
||||
0x6e,
|
||||
0xc0,
|
||||
0xbd,
|
||||
0x7f,
|
||||
0x11,
|
||||
0xc0,
|
||||
0x43,
|
||||
0xda,
|
||||
0x97,
|
||||
0x5e,
|
||||
0x2a,
|
||||
0x8a,
|
||||
0xd9,
|
||||
0xeb,
|
||||
0xae,
|
||||
0x0b,
|
||||
];
|
||||
|
||||
uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'
|
||||
```
|
||||
|
||||
### uuid.v1([options[, buffer[, offset]]])
|
||||
|
||||
Create an RFC version 1 (timestamp) UUID
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| [`options`] | `Object` with one or more of the following properties: |
|
||||
| [`options.node` ] | RFC "node" field as an `Array[6]` of byte values (per 4.1.6) |
|
||||
| [`options.clockseq`] | RFC "clock sequence" as a `Number` between 0 - 0x3fff |
|
||||
| [`options.msecs`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
|
||||
| [`options.nsecs`] | RFC "timestamp" field (`Number` of nanseconds to add to `msecs`, should be 0-10,000) |
|
||||
| [`options.random`] | `Array` of 16 random bytes (0-255) |
|
||||
| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
|
||||
| [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
|
||||
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
|
||||
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
|
||||
| _throws_ | `Error` if more than 10M UUIDs/sec are requested |
|
||||
|
||||
Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
|
||||
|
||||
Note: `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { v1 as uuidv1 } from 'uuid';
|
||||
|
||||
uuidv1(); // ⇨ '2c5ea4c0-4067-11e9-8bad-9b1deb4d3b7d'
|
||||
```
|
||||
|
||||
Example using `options`:
|
||||
|
||||
```javascript
|
||||
import { v1 as uuidv1 } from 'uuid';
|
||||
|
||||
const v1options = {
|
||||
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
|
||||
clockseq: 0x1234,
|
||||
msecs: new Date('2011-11-01').getTime(),
|
||||
nsecs: 5678,
|
||||
};
|
||||
uuidv1(v1options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
|
||||
```
|
||||
|
||||
### uuid.v3(name, namespace[, buffer[, offset]])
|
||||
|
||||
Create an RFC version 3 (namespace w/ MD5) UUID
|
||||
|
||||
API is identical to `v5()`, but uses "v3" instead.
|
||||
|
||||
⚠️ Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
|
||||
|
||||
### uuid.v4([options[, buffer[, offset]]])
|
||||
|
||||
Create an RFC version 4 (random) UUID
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| [`options`] | `Object` with one or more of the following properties: |
|
||||
| [`options.random`] | `Array` of 16 random bytes (0-255) |
|
||||
| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
|
||||
| [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
|
||||
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
|
||||
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
|
||||
```
|
||||
|
||||
Example using predefined `random` values:
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const v4options = {
|
||||
random: [
|
||||
0x10,
|
||||
0x91,
|
||||
0x56,
|
||||
0xbe,
|
||||
0xc4,
|
||||
0xfb,
|
||||
0xc1,
|
||||
0xea,
|
||||
0x71,
|
||||
0xb4,
|
||||
0xef,
|
||||
0xe1,
|
||||
0x67,
|
||||
0x1c,
|
||||
0x58,
|
||||
0x36,
|
||||
],
|
||||
};
|
||||
uuidv4(v4options); // ⇨ '109156be-c4fb-41ea-b1b4-efe1671c5836'
|
||||
```
|
||||
|
||||
### uuid.v5(name, namespace[, buffer[, offset]])
|
||||
|
||||
Create an RFC version 5 (namespace w/ SHA-1) UUID
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| `name` | `String \| Array` |
|
||||
| `namespace` | `String \| Array[16]` Namespace UUID |
|
||||
| [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
|
||||
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
|
||||
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
|
||||
|
||||
Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
|
||||
|
||||
Example with custom namespace:
|
||||
|
||||
```javascript
|
||||
import { v5 as uuidv5 } from 'uuid';
|
||||
|
||||
// Define a custom namespace. Readers, create your own using something like
|
||||
// https://www.uuidgenerator.net/
|
||||
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
|
||||
|
||||
uuidv5('Hello, World!', MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681'
|
||||
```
|
||||
|
||||
Example with RFC `URL` namespace:
|
||||
|
||||
```javascript
|
||||
import { v5 as uuidv5 } from 'uuid';
|
||||
|
||||
uuidv5('https://www.w3.org/', uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1'
|
||||
```
|
||||
|
||||
### uuid.validate(str)
|
||||
|
||||
Test a string to see if it is a valid UUID
|
||||
|
||||
| | |
|
||||
| --------- | --------------------------------------------------- |
|
||||
| `str` | `String` to validate |
|
||||
| _returns_ | `true` if string is a valid UUID, `false` otherwise |
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { validate as uuidValidate } from 'uuid';
|
||||
|
||||
uuidValidate('not a UUID'); // ⇨ false
|
||||
uuidValidate('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ true
|
||||
```
|
||||
|
||||
Using `validate` and `version` together it is possible to do per-version validation, e.g. validate for only v4 UUIds.
|
||||
|
||||
```javascript
|
||||
import { version as uuidVersion } from 'uuid';
|
||||
import { validate as uuidValidate } from 'uuid';
|
||||
|
||||
function uuidValidateV4(uuid) {
|
||||
return uuidValidate(uuid) && uuidVersion(uuid) === 4;
|
||||
}
|
||||
|
||||
const v1Uuid = 'd9428888-122b-11e1-b85c-61cd3cbb3210';
|
||||
const v4Uuid = '109156be-c4fb-41ea-b1b4-efe1671c5836';
|
||||
|
||||
uuidValidateV4(v4Uuid); // ⇨ true
|
||||
uuidValidateV4(v1Uuid); // ⇨ false
|
||||
```
|
||||
|
||||
### uuid.version(str)
|
||||
|
||||
Detect RFC version of a UUID
|
||||
|
||||
| | |
|
||||
| --------- | ---------------------------------------- |
|
||||
| `str` | A valid UUID `String` |
|
||||
| _returns_ | `Number` The RFC version of the UUID |
|
||||
| _throws_ | `TypeError` if `str` is not a valid UUID |
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
import { version as uuidVersion } from 'uuid';
|
||||
|
||||
uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // ⇨ 1
|
||||
uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4
|
||||
```
|
||||
|
||||
## Command Line
|
||||
|
||||
UUIDs can be generated from the command line using `uuid`.
|
||||
|
||||
```shell
|
||||
$ uuid
|
||||
ddeb27fb-d9a0-4624-be4d-4615062daed4
|
||||
```
|
||||
|
||||
The default is to generate version 4 UUIDS, however the other versions are supported. Type `uuid --help` for details:
|
||||
|
||||
```shell
|
||||
$ uuid --help
|
||||
|
||||
Usage:
|
||||
uuid
|
||||
uuid v1
|
||||
uuid v3 <name> <namespace uuid>
|
||||
uuid v4
|
||||
uuid v5 <name> <namespace uuid>
|
||||
uuid --help
|
||||
|
||||
Note: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs
|
||||
defined by RFC4122
|
||||
```
|
||||
|
||||
## ECMAScript Modules
|
||||
|
||||
This library comes with [ECMAScript Modules](https://www.ecma-international.org/ecma-262/6.0/#sec-modules) (ESM) support for Node.js versions that support it ([example](./examples/node-esmodules/)) as well as bundlers like [rollup.js](https://rollupjs.org/guide/en/#tree-shaking) ([example](./examples/browser-rollup/)) and [webpack](https://webpack.js.org/guides/tree-shaking/) ([example](./examples/browser-webpack/)) (targeting both, Node.js and browser environments).
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
|
||||
```
|
||||
|
||||
To run the examples you must first create a dist build of this library in the module root:
|
||||
|
||||
```shell
|
||||
npm run build
|
||||
```
|
||||
|
||||
## CDN Builds
|
||||
|
||||
### ECMAScript Modules
|
||||
|
||||
To load this module directly into modern browsers that [support loading ECMAScript Modules](https://caniuse.com/#feat=es6-module) you can make use of [jspm](https://jspm.org/):
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { v4 as uuidv4 } from 'https://jspm.dev/uuid';
|
||||
console.log(uuidv4()); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
|
||||
</script>
|
||||
```
|
||||
|
||||
### UMD
|
||||
|
||||
To load this module directly into older browsers you can use the [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds from any of the following CDNs:
|
||||
|
||||
**Using [UNPKG](https://unpkg.com/uuid@latest/dist/umd/)**:
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"></script>
|
||||
```
|
||||
|
||||
**Using [jsDelivr](https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/)**:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
|
||||
```
|
||||
|
||||
**Using [cdnjs](https://cdnjs.com/libraries/uuid)**:
|
||||
|
||||
```html
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
|
||||
```
|
||||
|
||||
These CDNs all provide the same [`uuidv4()`](#uuidv4options-buffer-offset) method:
|
||||
|
||||
```html
|
||||
<script>
|
||||
uuidv4(); // ⇨ '55af1e37-0734-46d8-b070-a1e42e4fc392'
|
||||
</script>
|
||||
```
|
||||
|
||||
Methods for the other algorithms ([`uuidv1()`](#uuidv1options-buffer-offset), [`uuidv3()`](#uuidv3name-namespace-buffer-offset) and [`uuidv5()`](#uuidv5name-namespace-buffer-offset)) are available from the files `uuidv1.min.js`, `uuidv3.min.js` and `uuidv5.min.js` respectively.
|
||||
|
||||
## "getRandomValues() not supported"
|
||||
|
||||
This error occurs in environments where the standard [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) API is not supported. This issue can be resolved by adding an appropriate polyfill:
|
||||
|
||||
### React Native / Expo
|
||||
|
||||
1. Install [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme)
|
||||
1. Import it _before_ `uuid`. Since `uuid` might also appear as a transitive dependency of some other imports it's safest to just import `react-native-get-random-values` as the very first thing in your entry point:
|
||||
|
||||
```javascript
|
||||
import 'react-native-get-random-values';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
```
|
||||
|
||||
Note: If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
|
||||
|
||||
### Web Workers / Service Workers (Edge <= 18)
|
||||
|
||||
[In Edge <= 18, Web Crypto is not supported in Web Workers or Service Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if you find one, please).
|
||||
|
||||
## Upgrading From `uuid@7.x`
|
||||
|
||||
### Only Named Exports Supported When Using with Node.js ESM
|
||||
|
||||
`uuid@7.x` did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in Node.js ESM consequently imported the CommonJS source with a default export. This library now comes with true Node.js ESM support and only provides named exports.
|
||||
|
||||
Instead of doing:
|
||||
|
||||
```javascript
|
||||
import uuid from 'uuid';
|
||||
uuid.v4();
|
||||
```
|
||||
|
||||
you will now have to use the named exports:
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
### Deep Requires No Longer Supported
|
||||
|
||||
Deep requires like `require('uuid/v4')` [which have been deprecated in `uuid@7.x`](#deep-requires-now-deprecated) are no longer supported.
|
||||
|
||||
## Upgrading From `uuid@3.x`
|
||||
|
||||
"_Wait... what happened to `uuid@4.x` - `uuid@6.x`?!?_"
|
||||
|
||||
In order to avoid confusion with RFC [version 4](#uuidv4options-buffer-offset) and [version 5](#uuidv5name-namespace-buffer-offset) UUIDs, and a possible [version 6](http://gh.peabody.io/uuidv6/), releases 4 thru 6 of this module have been skipped.
|
||||
|
||||
### Deep Requires Now Deprecated
|
||||
|
||||
`uuid@3.x` encouraged the use of deep requires to minimize the bundle size of browser builds:
|
||||
|
||||
```javascript
|
||||
const uuidv4 = require('uuid/v4'); // <== NOW DEPRECATED!
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
As of `uuid@7.x` this library now provides ECMAScript modules builds, which allow packagers like Webpack and Rollup to do "tree-shaking" to remove dead code. Instead, use the `import` syntax:
|
||||
|
||||
```javascript
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
... or for CommonJS:
|
||||
|
||||
```javascript
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
uuidv4();
|
||||
```
|
||||
|
||||
### Default Export Removed
|
||||
|
||||
`uuid@3.x` was exporting the Version 4 UUID method as a default export:
|
||||
|
||||
```javascript
|
||||
const uuid = require('uuid'); // <== REMOVED!
|
||||
```
|
||||
|
||||
This usage pattern was already discouraged in `uuid@3.x` and has been removed in `uuid@7.x`.
|
||||
|
||||
----
|
||||
Markdown generated from [README_js.md](README_js.md) by [](https://github.com/broofa/runmd)
|
||||
2
node_modules/uuid/dist/bin/uuid
generated
vendored
Executable file
2
node_modules/uuid/dist/bin/uuid
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../uuid-bin');
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user