forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#71166 Added types for salling-group__auth by
@HaayanchandravatSr Co-authored-by: Arjuna Enait <[email protected]>
- Loading branch information
1 parent
ae0319b
commit ca297b2
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!**/*.d.ts | ||
!**/*.d.cts | ||
!**/*.d.mts | ||
!**/*.d.*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { AxiosInstance } from "axios"; | ||
|
||
export interface AuthOptions { | ||
/** The type of authentication. */ | ||
type: "jwt" | "bearer"; | ||
|
||
/** The issuer used for JWT. */ | ||
issuer?: string; | ||
|
||
/** The secret used for JWT. */ | ||
secret?: string; | ||
|
||
/** The token used for Bearer. */ | ||
token?: string; | ||
} | ||
|
||
export interface InstanceOptions { | ||
/** Credentials for the instance */ | ||
auth: AuthOptions; | ||
|
||
/** | ||
* The name of the application which will use this instance. | ||
* This will be sent in the user-agent header. | ||
*/ | ||
applicationName?: string; | ||
|
||
/** The base name. (For internal use.) */ | ||
baseName?: string; | ||
} | ||
|
||
/** | ||
* Create a new Axios instance with Salling Group API support. | ||
* This automatically injects authorization and sets the base URL. | ||
* Furthermore, it also wraps API errors into a designated error type. | ||
* The instance can be used directly on resources (e.g. 'instance.get('/v1/stores/')'). | ||
* | ||
* @param options Options for the instance | ||
* | ||
* @returns An Axios instance that can access the Salling Group API. | ||
*/ | ||
export function createInstance(options: InstanceOptions): AxiosInstance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"private": true, | ||
"name": "@types/salling-group__auth", | ||
"version": "1.0.9999", | ||
"projects": [ | ||
"https://github.com/DanskSupermarked/sg-npm-auth" | ||
], | ||
"owners": [ | ||
{ | ||
"name": "Arjuna Enait", | ||
"githubUsername": "HaayanchandravatSr" | ||
} | ||
], | ||
"dependencies": { | ||
"axios": "^1.7.7" | ||
}, | ||
"devDependencies": { | ||
"@types/salling-group__auth": "workspace:." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createInstance } from "salling-group__auth"; | ||
|
||
createInstance({ | ||
auth: { | ||
type: "jwt", | ||
issuer: "issuer", | ||
secret: "secret", | ||
token: "token", | ||
}, | ||
applicationName: "app", | ||
baseName: "base", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "node16", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"salling-group__auth.tests.ts" | ||
] | ||
} |