Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/add-typescript-types #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/// <reference types="node" />
declare module "@digipolis/authz" {
export type Source = "authzv2" | "meauthz" | "meauthzv2" | "externalAuthz";
export interface BaseConfig {
debug?: boolean;
disabled?: boolean;
cache?: boolean;
tokenLocation?: string;
source: Source;
sources: {
externalAuthz?: Function;
url?: string;
apiKey?: string;
applicationId?: string;
};
}

export interface Config extends BaseConfig {
debug: boolean;
set: boolean;
disabled: boolean;
tokenLocation: string;
cache: boolean;
}

function checkOneOfPermissions(
authToken: string,
requiredPermissions?: string | string[],
requestedsource?: Source
): void;
function checkPermission(
authToken: string,
requiredPermissions?: string | string[],
requestedsource?: Source
): void;
function config(config: BaseConfig, force?: boolean): Config;
function getConfig(): Config;
function getPermissions(authToken: string, datasource: Source): string[];
function hasOneOfPermissions(
requiredPermissions: string | string[],
source: Source
): Promise<void>;
function hasPermission(
requiredPermissions: string | string[],
source: Source
): Promise<void>;
function hasPermissions(
requiredPermissions: string | string[],
source: Source
): Promise<void>;

export = {
checkOneOfPermissions,
checkPermission,
config,
getConfig,
getPermissions,
hasOneOfPermissions,
hasPermission,
hasPermissions,
};
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@digipolis/authz",
"version": "1.4.1",
"description": "Authorization module which can be used to check the permissions of an authenticated user.",
"types": "index.d.ts",
"scripts": {
"test": "mocha ./test && npm run lint",
"lint": "eslint \"**/*.js\"",
Expand Down