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 initial askar package #1211

Merged
merged 20 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
31 changes: 31 additions & 0 deletions packages/askar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<p align="center">
<br />
<img
alt="Hyperledger Aries logo"
src="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/aa31131825e3331dc93694bc58414d955dcb1129/images/aries-logo.png"
height="250px"
/>
</p>
<h1 align="center"><b>Aries Framework JavaScript Askar Module</b></h1>
<p align="center">
<a
href="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/main/LICENSE"
><img
alt="License"
src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
/></a>
<a href="https://www.typescriptlang.org/"
><img
alt="typescript"
src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"
/></a>
<a href="https://www.npmjs.com/package/@aries-framework/askar"
><img
alt="@aries-framework/askar version"
src="https://img.shields.io/npm/v/@aries-framework/askar"
/></a>

</p>
<br />

Askar module for [Aries Framework JavaScript](https://github.com/hyperledger/aries-framework-javascript.git).
14 changes: 14 additions & 0 deletions packages/askar/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Config } from '@jest/types'

import base from '../../jest.config.base'

import packageJson from './package.json'

const config: Config.InitialOptions = {
...base,
name: packageJson.name,
displayName: packageJson.name,
// setupFilesAfterEnv: ['./tests/setup.ts'],
}

export default config
41 changes: 41 additions & 0 deletions packages/askar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@aries-framework/askar",
"main": "build/index",
"types": "build/index",
"version": "0.3.2",
genaris marked this conversation as resolved.
Show resolved Hide resolved
"private": true,
"files": [
"build"
],
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"homepage": "https://github.com/hyperledger/aries-framework-javascript/tree/main/packages/askar",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/aries-framework-javascript",
"directory": "packages/askar"
},
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf ./build",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build",
"test": "jest"
},
"dependencies": {
"@aries-framework/core": "0.3.2",
"aries-askar-test-shared": "^0.1.0-dev.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"rxjs": "^7.2.0",
"tsyringe": "^4.7.0"
},
"devDependencies": {
"aries-askar-test-nodejs": "^0.1.0-dev.4",
"@aries-framework/node": "0.3.2",
"rimraf": "^4.0.7",
"typescript": "~4.9.4"
}
}
21 changes: 21 additions & 0 deletions packages/askar/src/AskarModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { AskarModuleConfigOptions } from './AskarModuleConfig'
import type { DependencyManager, Module } from '@aries-framework/core'

import { registerAriesAskar } from 'aries-askar-test-shared'

import { AskarModuleConfig } from './AskarModuleConfig'
import { AskarSymbol } from './types'

export class AskarModule implements Module {
public readonly config: AskarModuleConfig

public constructor(config: AskarModuleConfigOptions) {
this.config = new AskarModuleConfig(config)
}

public register(dependencyManager: DependencyManager) {
registerAriesAskar({ askar: this.config.askar })

dependencyManager.registerInstance(AskarSymbol, this.config.askar)
}
}
44 changes: 44 additions & 0 deletions packages/askar/src/AskarModuleConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { AriesAskar } from './types'

/**
* AskarModuleConfigOptions defines the interface for the options of the AskarModuleConfig class.
*/
export interface AskarModuleConfigOptions {
/**
* Implementation of the Askar interface according to aries-askar JavaScript wrapper.
*
*
* ## Node.JS
*
* ```ts
* import { NodeJSAriesAskar } from 'aries-askar-nodejs'
*
* const askarModule = new AskarModule({
* askar: new NodeJSAriesAskar()
* })
* ```
*
* ## React Native
*
* ```ts
* import { ReactNativeAriesAskar } from 'aries-askar-react-native'
*
* const askarModule = new AskarModule({
* askar: new ReactNativeAriesAskar()
* })
* ```
*/
askar: AriesAskar
}

export class AskarModuleConfig {
private options: AskarModuleConfigOptions

public constructor(options: AskarModuleConfigOptions) {
this.options = options
}

public get askar() {
return this.options.askar
}
}
9 changes: 9 additions & 0 deletions packages/askar/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Wallet
export { AskarWallet } from './wallet'

// Storage
export { AskarStorageService } from './storage'

// Module
export { AskarModule } from './AskarModule'
export { AskarModuleConfig } from './AskarModuleConfig'
Loading