Skip to content

Commit

Permalink
Add @types/chrome extension
Browse files Browse the repository at this point in the history
  • Loading branch information
WebGL3D committed Jun 25, 2023
1 parent 934f45e commit a6a8880
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/type-extensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @types/chrome extensions

This needs to be polished, and submitted to [@types/chrome](https://www.npmjs.com/package/@types/chrome) at some point.

See also: [DefinitelyTyped#65809](https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65809)
32 changes: 32 additions & 0 deletions libs/type-extensions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
////////////////////
// InstanceID
// THIS IS NEW, BASED ON https://developer.chrome.com/docs/extensions/reference/instanceID
////////////////////
/**
* The chrome.instanceID namespace exists to access the instance ID service, in chrome.
* Availability: Since Chrome 44.
*/
declare namespace chrome.instanceID {
export interface TokenRefreshEvent
extends chrome.events.Event<(token: string) => void> {}

/**
* Return a token that allows the authorized entity to access the service defined by scope.
* @param getTokenParams Parameters for getToken.
* @param callback The callback parameter looks like:
* function(token: string) {...};
* Parameter token: A token assigned by the requested service.
*/
export function getToken(
getTokenParams: {
authorizedEntity: string;
scope: string;
},
callback: (token: string) => void
): void;

/**
* Fired when all the granted tokens need to be refreshed.
*/
export var onTokenRefresh: TokenRefreshEvent;
}
13 changes: 13 additions & 0 deletions libs/type-extensions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@tix-factory/type-extensions",
"version": "0.0.237",
"description": "Additions that should really be in @types/chrome",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
"main": "",
"types": "index.d.ts",
"scripts": {},
"dependencies": {
"@types/chrome": "0.0.237"
},
"typeScriptVersion": "4.3"
}

0 comments on commit a6a8880

Please sign in to comment.