@cardano-sdk/cip30
Advanced tools
Comparing version 0.1.2 to 0.1.3
export * from './errors'; | ||
export * from './Wallet'; | ||
export * from './dataTypes'; | ||
export * from './types'; | ||
export * from './BrowserExtension'; | ||
export * from './injectWindow'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -15,5 +15,5 @@ "use strict"; | ||
__exportStar(require("./Wallet"), exports); | ||
__exportStar(require("./dataTypes"), exports); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./BrowserExtension"), exports); | ||
__exportStar(require("./injectWindow"), exports); | ||
//# sourceMappingURL=index.js.map |
export * from './Wallet'; | ||
export * from './WalletApi'; | ||
export * from './WalletPublic'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -14,4 +14,3 @@ "use strict"; | ||
__exportStar(require("./Wallet"), exports); | ||
__exportStar(require("./WalletApi"), exports); | ||
__exportStar(require("./WalletPublic"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,3 @@ | ||
import { WalletApi } from './WalletApi'; | ||
import { WalletApi } from './types'; | ||
import { Logger } from 'ts-log'; | ||
import { WalletPublic } from './WalletPublic'; | ||
import { WindowMaybeWithCardano } from '../injectWindow'; | ||
@@ -20,3 +19,2 @@ export declare type SpecificationVersion = string; | ||
private requestAccess; | ||
private options?; | ||
readonly version: SpecificationVersion; | ||
@@ -26,4 +24,10 @@ readonly name: WalletName; | ||
private logger; | ||
private readonly options; | ||
constructor(properties: WalletProperties, api: WalletApi, requestAccess: RequestAccess, options?: WalletOptions); | ||
getPublicApi(window: WindowMaybeWithCardano): WalletPublic; | ||
getPublicApi(window: WindowMaybeWithCardano): { | ||
name: string; | ||
version: string; | ||
enable: () => Promise<WalletApi>; | ||
isEnabled: () => Promise<Boolean>; | ||
}; | ||
private getAllowList; | ||
@@ -34,2 +38,3 @@ private allowApplication; | ||
} | ||
export declare type WalletPublic = ReturnType<Wallet['getPublicApi']>; | ||
//# sourceMappingURL=Wallet.d.ts.map |
@@ -6,2 +6,7 @@ "use strict"; | ||
const ts_log_1 = require("ts-log"); | ||
const defaultOptions = { | ||
logger: ts_log_1.dummyLogger, | ||
persistAllowList: false, | ||
storage: window.localStorage | ||
}; | ||
class Wallet { | ||
@@ -11,10 +16,7 @@ constructor(properties, api, requestAccess, options) { | ||
this.requestAccess = requestAccess; | ||
this.options = options; | ||
this.logger = options.logger ?? ts_log_1.dummyLogger; | ||
this.options = { ...defaultOptions, ...options }; | ||
this.name = properties.name; | ||
this.version = properties.version; | ||
if (typeof options.persistAllowList === 'undefined') { | ||
options.persistAllowList = false; | ||
} | ||
this.allowList = this.options.persistAllowList ? this.getAllowList() : []; | ||
this.logger = this.options.logger; | ||
} | ||
@@ -30,3 +32,3 @@ getPublicApi(window) { | ||
getAllowList() { | ||
return JSON.parse(this.options.storage?.getItem(this.name)) || []; | ||
return JSON.parse(this.options.storage.getItem(this.name)) || []; | ||
} | ||
@@ -33,0 +35,0 @@ allowApplication(appName) { |
{ | ||
"name": "@cardano-sdk/cip30", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "TypeScript definitions for the dApp Connector standard CIP30", | ||
@@ -20,3 +20,3 @@ "engines": { | ||
"lint": "eslint --ignore-path ../../.eslintignore \"**/*.ts\"", | ||
"test": "jest -c ./test/jest.config.js", | ||
"test": "jest -c ./jest.config.js", | ||
"coverage": "shx echo No coverage report for this package", | ||
@@ -32,3 +32,3 @@ "test:debug": "DEBUG=true yarn test" | ||
"dependencies": { | ||
"@cardano-ogmios/client": "4.0.0", | ||
"@cardano-ogmios/client": "4.1.0", | ||
"ts-custom-error": "^3.2.0", | ||
@@ -35,0 +35,0 @@ "ts-log": "^2.2.3" |
@@ -18,5 +18,4 @@ import { dummyLogger, Logger } from 'ts-log'; | ||
// eslint-disable-next-line consistent-return | ||
return walletMethod(...msg.arguments); | ||
}); | ||
}; |
export * from './errors'; | ||
export * from './Wallet'; | ||
export * from './dataTypes'; | ||
export * from './types'; | ||
export * from './BrowserExtension'; | ||
export * from './injectWindow'; |
export * from './Wallet'; | ||
export * from './WalletApi'; | ||
export * from './WalletPublic'; | ||
export * from './types'; |
@@ -1,5 +0,4 @@ | ||
import { WalletApi } from './WalletApi'; | ||
import { WalletApi } from './types'; | ||
import { ApiError, APIErrorCode } from '../errors'; | ||
import { dummyLogger, Logger } from 'ts-log'; | ||
import { WalletPublic } from './WalletPublic'; | ||
import { WindowMaybeWithCardano } from '../injectWindow'; | ||
@@ -32,2 +31,8 @@ | ||
const defaultOptions = { | ||
logger: dummyLogger, | ||
persistAllowList: false, | ||
storage: window.localStorage | ||
}; | ||
export class Wallet { | ||
@@ -39,2 +44,3 @@ readonly version: SpecificationVersion; | ||
private logger: Logger; | ||
private readonly options: Required<WalletOptions>; | ||
@@ -45,16 +51,12 @@ constructor( | ||
private requestAccess: RequestAccess, | ||
private options?: WalletOptions | ||
options?: WalletOptions | ||
) { | ||
this.logger = options.logger ?? dummyLogger; | ||
this.options = { ...defaultOptions, ...options }; | ||
this.name = properties.name; | ||
this.version = properties.version; | ||
if (typeof options.persistAllowList === 'undefined') { | ||
options.persistAllowList = false; | ||
} | ||
this.allowList = this.options.persistAllowList ? this.getAllowList() : []; | ||
this.logger = this.options.logger; | ||
} | ||
public getPublicApi(window: WindowMaybeWithCardano): WalletPublic { | ||
public getPublicApi(window: WindowMaybeWithCardano) { | ||
return { | ||
@@ -69,3 +71,4 @@ name: this.name, | ||
private getAllowList(): string[] { | ||
return JSON.parse(this.options.storage?.getItem(this.name)) || []; | ||
// JSON.parse(null) seems to be legit | ||
return JSON.parse(this.options.storage.getItem(this.name)!) || []; | ||
} | ||
@@ -146,1 +149,3 @@ | ||
} | ||
export type WalletPublic = ReturnType<Wallet['getPublicApi']>; |
import { mocks } from 'mock-browser'; | ||
import { Wallet } from '@src/Wallet'; | ||
import { Wallet } from '../src/Wallet'; | ||
import { api, properties, requestAccess } from './testWallet'; | ||
import { injectWindow, WindowMaybeWithCardano } from '@src/injectWindow'; | ||
import { injectWindow, WindowMaybeWithCardano } from '../src/injectWindow'; | ||
@@ -6,0 +6,0 @@ describe('injectWindow', () => { |
@@ -1,2 +0,2 @@ | ||
import { RequestAccess, WalletApi } from '@src/Wallet'; | ||
import { RequestAccess, WalletApi } from '../src/Wallet'; | ||
@@ -3,0 +3,0 @@ export const api = <WalletApi>{ |
/* eslint-disable sonarjs/no-duplicate-string */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { Wallet, WalletApi, WalletOptions } from '@src/Wallet'; | ||
import { Wallet, WalletApi, WalletOptions } from '../src/Wallet'; | ||
import { mocks } from 'mock-browser'; | ||
@@ -49,3 +49,3 @@ import * as testWallet from './testWallet'; | ||
expect(publicApi.name).toEqual('test-wallet'); | ||
expect(await publicApi.isEnabled(window)).toEqual(false); | ||
expect(await publicApi.isEnabled()).toEqual(false); | ||
}); | ||
@@ -64,3 +64,3 @@ | ||
describe('api', () => { | ||
let api: WalletApi | null; | ||
let api: WalletApi; | ||
@@ -67,0 +67,0 @@ beforeAll(async () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149847
97
1109
+ Added@cardano-ogmios/client@4.1.0(transitive)
+ Added@cardano-ogmios/schema@4.1.0(transitive)
- Removed@cardano-ogmios/client@4.0.0(transitive)
- Removed@cardano-ogmios/schema@4.0.0(transitive)
Updated@cardano-ogmios/client@4.1.0