@maxim_mazurok/gapi.client.safebrowsing-v5 0.0.20230923
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +98 -0
- package/package.json +20 -0
- package/readme.md +52 -0
- package/tests.ts +22 -0
- package/tsconfig.json +18 -0
- package/tslint.json +6 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* Type definitions for non-npm package Safe Browsing API v5 0.0 */
|
|
2
|
+
// Project: https://developers.google.com/safe-browsing/
|
|
3
|
+
// Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
|
|
4
|
+
// Nick Amoscato <https://github.com/namoscato>
|
|
5
|
+
// Declan Vong <https://github.com/declanvong>
|
|
6
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
7
|
+
|
|
8
|
+
// IMPORTANT
|
|
9
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
10
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
11
|
+
// Generated from: https://safebrowsing.googleapis.com/$discovery/rest?version=v5
|
|
12
|
+
// Revision: 20230923
|
|
13
|
+
|
|
14
|
+
/// <reference types="gapi.client" />
|
|
15
|
+
|
|
16
|
+
declare namespace gapi.client {
|
|
17
|
+
/** Load Safe Browsing API v5 */
|
|
18
|
+
function load(urlOrObject: "https://safebrowsing.googleapis.com/$discovery/rest?version=v5"): Promise<void>;
|
|
19
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
20
|
+
function load(name: "safebrowsing", version: "v5"): Promise<void>;
|
|
21
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
22
|
+
function load(name: "safebrowsing", version: "v5", callback: () => any): void;
|
|
23
|
+
|
|
24
|
+
namespace safebrowsing {
|
|
25
|
+
interface GoogleSecuritySafebrowsingV5FullHash {
|
|
26
|
+
/** The matching full hash. This is the SHA256 hash. The length will be exactly 32 bytes. */
|
|
27
|
+
fullHash?:
|
|
28
|
+
string;
|
|
29
|
+
/** Unordered list. A repeated field identifying the details relevant to this full hash. */
|
|
30
|
+
fullHashDetails?:
|
|
31
|
+
GoogleSecuritySafebrowsingV5FullHashFullHashDetail[];
|
|
32
|
+
}
|
|
33
|
+
interface GoogleSecuritySafebrowsingV5FullHashFullHashDetail {
|
|
34
|
+
/** Unordered list. Additional attributes about those full hashes. This may be empty. */
|
|
35
|
+
attributes?:
|
|
36
|
+
string[];
|
|
37
|
+
/** The type of threat. This field will never be empty. */
|
|
38
|
+
threatType?:
|
|
39
|
+
string;
|
|
40
|
+
}
|
|
41
|
+
interface GoogleSecuritySafebrowsingV5SearchHashesResponse {
|
|
42
|
+
/**
|
|
43
|
+
* The client-side cache duration. The client shall add this duration to the current time to determine the expiration time. The expiration time then applies to every hash prefix
|
|
44
|
+
* queried by the client in the request, regardless of how many full hashes are returned in the response. Even if the server returns no full hashes for a particular hash prefix, this
|
|
45
|
+
* fact should also be cached by the client. Important: the client must not assume that the server will return the same cache duration for all responses. The server may choose
|
|
46
|
+
* different cache durations for different responses depending on the situation.
|
|
47
|
+
*/
|
|
48
|
+
cacheDuration?:
|
|
49
|
+
string;
|
|
50
|
+
/** Unordered list. The unordered list of full hashes found. */
|
|
51
|
+
fullHashes?:
|
|
52
|
+
GoogleSecuritySafebrowsingV5FullHash[];
|
|
53
|
+
}
|
|
54
|
+
interface HashesResource {
|
|
55
|
+
/** Search for full hashes matching the specified prefixes. This is a custom method as described by guidance at https://google.aip.dev/136 */
|
|
56
|
+
search(request?: {
|
|
57
|
+
/** V1 error format. */
|
|
58
|
+
"$.xgafv"?:
|
|
59
|
+
string;
|
|
60
|
+
/** OAuth access token. */
|
|
61
|
+
access_token?:
|
|
62
|
+
string;
|
|
63
|
+
/** Data format for response. */
|
|
64
|
+
alt?:
|
|
65
|
+
string;
|
|
66
|
+
/** JSONP */
|
|
67
|
+
callback?:
|
|
68
|
+
string;
|
|
69
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
70
|
+
fields?:
|
|
71
|
+
string;
|
|
72
|
+
/** Required. The hash prefixes to be looked up. */
|
|
73
|
+
hashPrefixes?:
|
|
74
|
+
string | string[];
|
|
75
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
76
|
+
key?:
|
|
77
|
+
string;
|
|
78
|
+
/** OAuth 2.0 token for the current user. */
|
|
79
|
+
oauth_token?:
|
|
80
|
+
string;
|
|
81
|
+
/** Returns response with indentations and line breaks. */
|
|
82
|
+
prettyPrint?:
|
|
83
|
+
boolean;
|
|
84
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
85
|
+
quotaUser?:
|
|
86
|
+
string;
|
|
87
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
88
|
+
upload_protocol?:
|
|
89
|
+
string;
|
|
90
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
91
|
+
uploadType?:
|
|
92
|
+
string;
|
|
93
|
+
}): Request<GoogleSecuritySafebrowsingV5SearchHashesResponse>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const hashes: HashesResource;
|
|
97
|
+
}
|
|
98
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.safebrowsing-v5",
|
|
3
|
+
"version": "0.0.20230923",
|
|
4
|
+
"description": "TypeScript typings for Safe Browsing API v5",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"email": "maxim@mazurok.com",
|
|
8
|
+
"name": "Maxim Mazurok",
|
|
9
|
+
"url": "https://maxim.mazurok.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery-v1": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# TypeScript typings for Safe Browsing API v5
|
|
2
|
+
|
|
3
|
+
Enables client applications to check web resources (most commonly URLs) against Google-generated lists of unsafe web resources. The Safe Browsing APIs are for non-commercial use only. If you need to use APIs to detect malicious URLs for commercial purposes – meaning “for sale or revenue-generating purposes” – please refer to the Web Risk API.
|
|
4
|
+
For detailed description please check [documentation](https://developers.google.com/safe-browsing/).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for Safe Browsing API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.safebrowsing-v5 --save-dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
You need to initialize Google API client in your code:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
gapi.load('client', () => {
|
|
20
|
+
// now we can use gapi.client
|
|
21
|
+
// ...
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then load api client wrapper:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
gapi.client.load('https://safebrowsing.googleapis.com/$discovery/rest?version=v5', () => {
|
|
29
|
+
// now we can use:
|
|
30
|
+
// gapi.client.safebrowsing
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
36
|
+
gapi.client.load('safebrowsing', 'v5', () => {
|
|
37
|
+
// now we can use:
|
|
38
|
+
// gapi.client.safebrowsing
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
After that you can use Safe Browsing API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
Search for full hashes matching the specified prefixes. This is a custom method as described by guidance at https://google.aip.dev/136
|
|
50
|
+
*/
|
|
51
|
+
await gapi.client.safebrowsing.hashes.search({ });
|
|
52
|
+
```
|
package/tests.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* This is stub file for gapi.client.safebrowsing-v5 definition tests */
|
|
2
|
+
// IMPORTANT
|
|
3
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
4
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
5
|
+
|
|
6
|
+
// Revision: 20230923
|
|
7
|
+
|
|
8
|
+
gapi.load('client', async () => {
|
|
9
|
+
/** now we can use gapi.client */
|
|
10
|
+
|
|
11
|
+
await gapi.client.load('https://safebrowsing.googleapis.com/$discovery/rest?version=v5');
|
|
12
|
+
/** now we can use gapi.client.safebrowsing */
|
|
13
|
+
|
|
14
|
+
run();
|
|
15
|
+
|
|
16
|
+
async function run() {
|
|
17
|
+
/** Search for full hashes matching the specified prefixes. This is a custom method as described by guidance at https://google.aip.dev/136 */
|
|
18
|
+
await gapi.client.safebrowsing.hashes.search({
|
|
19
|
+
hashPrefixes: "Test string",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": ["es6", "dom"],
|
|
5
|
+
"noImplicitAny": true,
|
|
6
|
+
"noImplicitThis": true,
|
|
7
|
+
"strictNullChecks": true,
|
|
8
|
+
"baseUrl": "../",
|
|
9
|
+
"typeRoots": [
|
|
10
|
+
"../"
|
|
11
|
+
],
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"strictFunctionTypes": true
|
|
16
|
+
},
|
|
17
|
+
"files": ["index.d.ts", "tests.ts"]
|
|
18
|
+
}
|