alby-js-sdk
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,211 +0,5 @@ | ||
declare type SuccessStatus = 200 | 201; | ||
declare type ResponseType = "application/json"; | ||
interface AuthHeader { | ||
Authorization: string; | ||
} | ||
interface GetTokenResponse { | ||
/** Allows an application to obtain a new access token without prompting the user via the refresh token flow. */ | ||
refresh_token?: string; | ||
/** Access tokens are the token that applications use to make API requests on behalf of a user. */ | ||
access_token?: string; | ||
token_type?: string; | ||
expires_in?: number; | ||
/** Comma-separated list of scopes for the token */ | ||
scope?: string; | ||
} | ||
interface Token extends Omit<GetTokenResponse, "expires_in"> { | ||
/** Date that the access_token will expire at. */ | ||
expires_at?: number; | ||
} | ||
declare type GenerateAuthUrlOptions = { | ||
/** A random string you provide to verify against CSRF attacks. The length of this string can be up to 500 characters. */ | ||
state?: string; | ||
/** Specifies the method you are using to make a request (S256 OR plain). */ | ||
code_challenge_method: "S256"; | ||
} | { | ||
/** A random string you provide to verify against CSRF attacks. The length of this string can be up to 500 characters. */ | ||
state: string; | ||
/** A PKCE parameter, a random secret for each request you make. */ | ||
code_challenge: string; | ||
/** Specifies the method you are using to make a request (S256 OR plain). */ | ||
code_challenge_method?: "plain"; | ||
}; | ||
declare abstract class OAuthClient implements AuthClient { | ||
abstract token?: Token; | ||
abstract generateAuthURL(options: GenerateAuthUrlOptions): string; | ||
abstract requestAccessToken(code?: string): Promise<{ | ||
token: Token; | ||
}>; | ||
abstract getAuthHeader(url?: string, method?: string): Promise<AuthHeader> | AuthHeader; | ||
} | ||
declare abstract class AuthClient { | ||
abstract getAuthHeader(url?: string, method?: string): Promise<AuthHeader> | AuthHeader; | ||
} | ||
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
declare type GetSuccess<T> = { | ||
[K in SuccessStatus & keyof T]: GetContent<T[K]>; | ||
}[SuccessStatus & keyof T]; | ||
declare type AlbyResponse<T> = UnionToIntersection<ExtractAlbyResponse<T>>; | ||
declare type GetContent<T> = "content" extends keyof T ? ResponseType extends keyof T["content"] ? T["content"][ResponseType] : never : never; | ||
declare type ExtractAlbyResponse<T> = "responses" extends keyof T ? GetSuccess<T["responses"]> : never; | ||
declare type InvoiceRequestParams = { | ||
description?: string; | ||
description_hash?: string; | ||
amount: number; | ||
}; | ||
declare type KeysendRequestParams = { | ||
amount: number; | ||
destination: string; | ||
memo?: string; | ||
customRecords?: Record<string, string>; | ||
}; | ||
declare type SendPaymentRequestParams = { | ||
invoice: string; | ||
amount?: number; | ||
}; | ||
type types_SuccessStatus = SuccessStatus; | ||
type types_ResponseType = ResponseType; | ||
type types_AuthHeader = AuthHeader; | ||
type types_GetTokenResponse = GetTokenResponse; | ||
type types_Token = Token; | ||
type types_GenerateAuthUrlOptions = GenerateAuthUrlOptions; | ||
type types_OAuthClient = OAuthClient; | ||
declare const types_OAuthClient: typeof OAuthClient; | ||
type types_AuthClient = AuthClient; | ||
declare const types_AuthClient: typeof AuthClient; | ||
type types_UnionToIntersection<U> = UnionToIntersection<U>; | ||
type types_GetSuccess<T> = GetSuccess<T>; | ||
type types_AlbyResponse<T> = AlbyResponse<T>; | ||
type types_GetContent<T> = GetContent<T>; | ||
type types_ExtractAlbyResponse<T> = ExtractAlbyResponse<T>; | ||
type types_InvoiceRequestParams = InvoiceRequestParams; | ||
type types_KeysendRequestParams = KeysendRequestParams; | ||
type types_SendPaymentRequestParams = SendPaymentRequestParams; | ||
declare namespace types { | ||
export { | ||
types_SuccessStatus as SuccessStatus, | ||
types_ResponseType as ResponseType, | ||
types_AuthHeader as AuthHeader, | ||
types_GetTokenResponse as GetTokenResponse, | ||
types_Token as Token, | ||
types_GenerateAuthUrlOptions as GenerateAuthUrlOptions, | ||
types_OAuthClient as OAuthClient, | ||
types_AuthClient as AuthClient, | ||
types_UnionToIntersection as UnionToIntersection, | ||
types_GetSuccess as GetSuccess, | ||
types_AlbyResponse as AlbyResponse, | ||
types_GetContent as GetContent, | ||
types_ExtractAlbyResponse as ExtractAlbyResponse, | ||
types_InvoiceRequestParams as InvoiceRequestParams, | ||
types_KeysendRequestParams as KeysendRequestParams, | ||
types_SendPaymentRequestParams as SendPaymentRequestParams, | ||
}; | ||
} | ||
interface RequestOptions extends Omit<RequestInit, "body"> { | ||
auth?: AuthClient; | ||
endpoint: string; | ||
params?: Record<string, any>; | ||
request_body?: Record<string, any>; | ||
method?: string; | ||
max_retries?: number; | ||
base_url?: string; | ||
} | ||
declare type OAuth2Scopes = "account:read" | "invoices:create" | "invoices:read" | "transactions:read" | "balance:read" | "payments:send"; | ||
interface OAuth2UserOptions { | ||
client_id: string; | ||
client_secret?: string; | ||
callback: string; | ||
scopes: OAuth2Scopes[]; | ||
request_options?: Partial<RequestOptions>; | ||
token?: Token; | ||
} | ||
declare class OAuth2User implements OAuthClient { | ||
token?: Token; | ||
options: OAuth2UserOptions; | ||
code_verifier?: string; | ||
code_challenge?: string; | ||
constructor(options: OAuth2UserOptions); | ||
/** | ||
* Refresh the access token | ||
*/ | ||
refreshAccessToken(): Promise<{ | ||
token: Token; | ||
}>; | ||
/** | ||
* Check if an access token is expired | ||
*/ | ||
isAccessTokenExpired(): boolean; | ||
/** | ||
* Request an access token | ||
*/ | ||
requestAccessToken(code?: string): Promise<{ | ||
token: Token; | ||
}>; | ||
generateAuthURL(options: GenerateAuthUrlOptions): string; | ||
getAuthHeader(): Promise<AuthHeader>; | ||
} | ||
declare class OAuth2Bearer implements AuthClient { | ||
private bearer_token; | ||
constructor(bearer_token: string); | ||
getAuthHeader(): AuthHeader; | ||
} | ||
type auth_OAuth2Scopes = OAuth2Scopes; | ||
type auth_OAuth2UserOptions = OAuth2UserOptions; | ||
type auth_OAuth2User = OAuth2User; | ||
declare const auth_OAuth2User: typeof OAuth2User; | ||
type auth_OAuth2Bearer = OAuth2Bearer; | ||
declare const auth_OAuth2Bearer: typeof OAuth2Bearer; | ||
declare namespace auth { | ||
export { | ||
auth_OAuth2Scopes as OAuth2Scopes, | ||
auth_OAuth2UserOptions as OAuth2UserOptions, | ||
auth_OAuth2User as OAuth2User, | ||
auth_OAuth2Bearer as OAuth2Bearer, | ||
}; | ||
} | ||
declare class Client { | ||
auth: AuthClient; | ||
defaultRequestOptions?: Partial<RequestOptions>; | ||
constructor(auth: string | AuthClient, requestOptions?: Partial<RequestOptions>); | ||
accountBalance(params: {}, request_options?: Partial<RequestOptions>): Promise<any>; | ||
accountSummary(params: {}, request_options?: Partial<RequestOptions>): Promise<any>; | ||
accountValue4Value(params: {}, request_options?: Partial<RequestOptions>): Promise<any>; | ||
incomingInvoices(params: {}, request_options?: Partial<RequestOptions>): Promise<any>; | ||
outgoingInvoices(params: {}, request_options?: Partial<RequestOptions>): Promise<any>; | ||
getInvoice(paymentHash: string, request_options?: Partial<RequestOptions>): Promise<any>; | ||
createInvoice(invoice: InvoiceRequestParams, request_options?: Partial<RequestOptions>): Promise<any>; | ||
keysend(keysend: KeysendRequestParams, request_options?: Partial<RequestOptions>): Promise<any>; | ||
sendPayment(params: SendPaymentRequestParams, request_options?: Partial<RequestOptions>): Promise<any>; | ||
} | ||
interface RequestInvoiceArgs { | ||
amount: string | number; | ||
defaultMemo?: string; | ||
} | ||
declare class WebLNProvider { | ||
client: Client; | ||
auth: OAuthClient; | ||
constructor(auth: OAuthClient); | ||
openAuthorization(): Promise<unknown>; | ||
enable(): Promise<unknown>; | ||
sendPayment(invoice: string): Promise<{ | ||
preimage: any; | ||
}>; | ||
keysend(params: KeysendRequestParams): Promise<{ | ||
preimage: any; | ||
}>; | ||
getInfo(): Promise<{ | ||
alias: string; | ||
}>; | ||
makeInvoice(params: RequestInvoiceArgs): Promise<{ | ||
paymentRequest: any; | ||
}>; | ||
} | ||
export { Client, WebLNProvider, auth, Client as default, types }; | ||
export * as auth from "./auth"; | ||
export * as types from './types'; | ||
export { Client } from "./client"; | ||
export { WebLNProvider } from "./WeblnProvider"; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "alby-js-sdk", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Alby OAuth2 Client", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"type": "module", | ||
"source": "src/index.ts", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.module.js", | ||
"unpkg": "./dist/index.umd.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
"dist/**/*" | ||
], | ||
"exports": { | ||
"require": "./dist/index.cjs", | ||
"default": "./dist/index.modern.js" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"prebuild": "yarn clean", | ||
"prepublishOnly": "yarn test", | ||
"prebuild": "yarn run clean", | ||
"prepack": "yarn run build", | ||
"test": "echo tests are missing", | ||
"clean": "rm -rf dist" | ||
"clean": "rm -rf dist", | ||
"build": "microbundle", | ||
"dev": "microbundle watch" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"src/index.ts" | ||
], | ||
"splitting": false, | ||
"sourcemap": true, | ||
"dts": true, | ||
"format": [ | ||
"esm", | ||
"cjs" | ||
] | ||
}, | ||
"dependencies": { | ||
@@ -35,6 +31,8 @@ "cross-fetch": "^3.1.5", | ||
"devDependencies": { | ||
"@aws-crypto/sha256-browser": "^2.0.2", | ||
"@rollup/plugin-node-resolve": "^15.0.0", | ||
"@types/crypto-js": "^4.1.1", | ||
"@types/node": "^18.11.0", | ||
"express": "^4.18.2", | ||
"tsup": "^6.2.3", | ||
"microbundle": "^0.15.1", | ||
"typescript": "^4.8.4" | ||
@@ -41,0 +39,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
172709
27
1
7
325
3