bsv-bap 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +20 -0
- package/.eslintrc +46 -0
- package/LICENSE +25 -0
- package/README.md +819 -0
- package/babel.config.js +6 -0
- package/bun.lockb +0 -0
- package/coverage/clover.xml +6 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/constants.ts.html +113 -0
- package/coverage/lcov-report/src/id.ts.html +2207 -0
- package/coverage/lcov-report/src/index.html +156 -0
- package/coverage/lcov-report/src/index.ts.html +1877 -0
- package/coverage/lcov-report/src/utils.ts.html +404 -0
- package/coverage/lcov-report/tests/data/index.html +111 -0
- package/coverage/lcov-report/tests/data/keys.js.html +86 -0
- package/coverage/lcov.info +0 -0
- package/dist/jest.config.d.ts +8 -0
- package/dist/src/constants.d.ts +8 -0
- package/dist/src/id.d.ts +295 -0
- package/dist/src/index.d.ts +238 -0
- package/dist/src/interface.d.ts +23 -0
- package/dist/src/poa.d.ts +6 -0
- package/dist/src/utils.d.ts +54 -0
- package/dist/typescript-npm-package.cjs.d.ts +554 -0
- package/dist/typescript-npm-package.cjs.js +1320 -0
- package/dist/typescript-npm-package.cjs.js.map +1 -0
- package/dist/typescript-npm-package.esm.d.ts +554 -0
- package/dist/typescript-npm-package.esm.js +1312 -0
- package/dist/typescript-npm-package.esm.js.map +1 -0
- package/dist/typescript-npm-package.umd.d.ts +554 -0
- package/dist/typescript-npm-package.umd.js +110193 -0
- package/dist/typescript-npm-package.umd.js.map +1 -0
- package/jest.config.ts +196 -0
- package/jsdoc.json +16 -0
- package/package.json +80 -0
- package/rollup.config.js +64 -0
- package/setup-jest.js +1 -0
- package/src/README.md +80 -0
- package/src/attributes.json +119 -0
- package/src/constants.ts +11 -0
- package/src/id.ts +783 -0
- package/src/index.ts +631 -0
- package/src/interface.ts +26 -0
- package/src/poa.ts +9 -0
- package/src/utils.ts +111 -0
- package/tests/data/ids.json +30 -0
- package/tests/data/keys.js +2 -0
- package/tests/data/old-ids.json +25 -0
- package/tests/data/test-vectors.json +122 -0
- package/tests/id.test.js +286 -0
- package/tests/index.test.js +335 -0
- package/tests/regression.test.js +28 -0
- package/tests/utils.test.js +27 -0
- package/tsconfig.json +17 -0
package/jest.config.ts
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
/*
|
2
|
+
* For a detailed explanation regarding each configuration property and type check, visit:
|
3
|
+
* https://jestjs.io/docs/configuration
|
4
|
+
*/
|
5
|
+
|
6
|
+
export default {
|
7
|
+
// All imported modules in your tests should be mocked automatically
|
8
|
+
automock: false,
|
9
|
+
|
10
|
+
// Stop running tests after `n` failures
|
11
|
+
// bail: 0,
|
12
|
+
|
13
|
+
// The directory where Jest should store its cached dependency information
|
14
|
+
// cacheDirectory: "/private/var/folders/9k/tb80d9g96wddlz7zqg43nhwm0000gp/T/jest_dy",
|
15
|
+
|
16
|
+
// Automatically clear mock calls, instances and results before every test
|
17
|
+
clearMocks: true,
|
18
|
+
|
19
|
+
// Indicates whether the coverage information should be collected while executing the test
|
20
|
+
collectCoverage: true,
|
21
|
+
|
22
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
23
|
+
// collectCoverageFrom: undefined,
|
24
|
+
|
25
|
+
// The directory where Jest should output its coverage files
|
26
|
+
coverageDirectory: "coverage",
|
27
|
+
|
28
|
+
// An array of regexp pattern strings used to skip coverage collection
|
29
|
+
// coveragePathIgnorePatterns: [
|
30
|
+
// "/node_modules/"
|
31
|
+
// ],
|
32
|
+
|
33
|
+
// Indicates which provider should be used to instrument code for coverage
|
34
|
+
// coverageProvider: "babel",
|
35
|
+
|
36
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
37
|
+
// coverageReporters: [
|
38
|
+
// "json",
|
39
|
+
// "text",
|
40
|
+
// "lcov",
|
41
|
+
// "clover"
|
42
|
+
// ],
|
43
|
+
|
44
|
+
// An object that configures minimum threshold enforcement for coverage results
|
45
|
+
// coverageThreshold: undefined,
|
46
|
+
|
47
|
+
// A path to a custom dependency extractor
|
48
|
+
// dependencyExtractor: undefined,
|
49
|
+
|
50
|
+
// Make calling deprecated APIs throw helpful error messages
|
51
|
+
// errorOnDeprecated: false,
|
52
|
+
|
53
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
54
|
+
// forceCoverageMatch: [],
|
55
|
+
|
56
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
57
|
+
// globalSetup: undefined,
|
58
|
+
|
59
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
60
|
+
// globalTeardown: undefined,
|
61
|
+
|
62
|
+
// A set of global variables that need to be available in all test environments
|
63
|
+
// globals: {},
|
64
|
+
|
65
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
66
|
+
// maxWorkers: "50%",
|
67
|
+
|
68
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
69
|
+
// moduleDirectories: [
|
70
|
+
// "node_modules"
|
71
|
+
// ],
|
72
|
+
|
73
|
+
// An array of file extensions your modules use
|
74
|
+
// moduleFileExtensions: [
|
75
|
+
// "js",
|
76
|
+
// "jsx",
|
77
|
+
// "ts",
|
78
|
+
// "tsx",
|
79
|
+
// "json",
|
80
|
+
// "node"
|
81
|
+
// ],
|
82
|
+
|
83
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
84
|
+
// moduleNameMapper: {},
|
85
|
+
|
86
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
87
|
+
// modulePathIgnorePatterns: [],
|
88
|
+
|
89
|
+
// Activates notifications for test results
|
90
|
+
// notify: false,
|
91
|
+
|
92
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
93
|
+
// notifyMode: "failure-change",
|
94
|
+
|
95
|
+
// A preset that is used as a base for Jest's configuration
|
96
|
+
// preset: undefined,
|
97
|
+
|
98
|
+
// Run tests from one or more projects
|
99
|
+
// projects: undefined,
|
100
|
+
|
101
|
+
// Use this configuration option to add custom reporters to Jest
|
102
|
+
// reporters: undefined,
|
103
|
+
|
104
|
+
// Automatically reset mock state before every test
|
105
|
+
// resetMocks: false,
|
106
|
+
|
107
|
+
// Reset the module registry before running each individual test
|
108
|
+
// resetModules: false,
|
109
|
+
|
110
|
+
// A path to a custom resolver
|
111
|
+
// resolver: undefined,
|
112
|
+
|
113
|
+
// Automatically restore mock state and implementation before every test
|
114
|
+
// restoreMocks: false,
|
115
|
+
|
116
|
+
// The root directory that Jest should scan for tests and modules within
|
117
|
+
// rootDir: undefined,
|
118
|
+
|
119
|
+
// A list of paths to directories that Jest should use to search for files in
|
120
|
+
// roots: [
|
121
|
+
// "<rootDir>"
|
122
|
+
// ],
|
123
|
+
|
124
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
125
|
+
// runner: "jest-runner",
|
126
|
+
|
127
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
128
|
+
setupFiles: [
|
129
|
+
"./setup-jest.js",
|
130
|
+
],
|
131
|
+
|
132
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
133
|
+
// setupFilesAfterEnv: [],
|
134
|
+
|
135
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
136
|
+
// slowTestThreshold: 5,
|
137
|
+
|
138
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
139
|
+
// snapshotSerializers: [],
|
140
|
+
|
141
|
+
// The test environment that will be used for testing
|
142
|
+
// testEnvironment: "jest-environment-node",
|
143
|
+
|
144
|
+
// Options that will be passed to the testEnvironment
|
145
|
+
// testEnvironmentOptions: {},
|
146
|
+
|
147
|
+
// Adds a location field to test results
|
148
|
+
// testLocationInResults: false,
|
149
|
+
|
150
|
+
// The glob patterns Jest uses to detect test files
|
151
|
+
// testMatch: [
|
152
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
153
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
154
|
+
// ],
|
155
|
+
|
156
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
157
|
+
// testPathIgnorePatterns: [
|
158
|
+
// "/node_modules/"
|
159
|
+
// ],
|
160
|
+
|
161
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
162
|
+
// testRegex: [],
|
163
|
+
|
164
|
+
// This option allows the use of a custom results processor
|
165
|
+
// testResultsProcessor: undefined,
|
166
|
+
|
167
|
+
// This option allows use of a custom test runner
|
168
|
+
// testRunner: "jest-circus/runner",
|
169
|
+
|
170
|
+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
171
|
+
// testURL: "http://localhost",
|
172
|
+
|
173
|
+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
174
|
+
// timers: "real",
|
175
|
+
|
176
|
+
// A map from regular expressions to paths to transformers
|
177
|
+
// transform: undefined,
|
178
|
+
|
179
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
180
|
+
// transformIgnorePatterns: [
|
181
|
+
// "/node_modules/",
|
182
|
+
// "\\.pnp\\.[^\\/]+$"
|
183
|
+
// ],
|
184
|
+
|
185
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
186
|
+
// unmockedModulePathPatterns: undefined,
|
187
|
+
|
188
|
+
// Indicates whether each individual test should be reported during the run
|
189
|
+
// verbose: undefined,
|
190
|
+
|
191
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
192
|
+
// watchPathIgnorePatterns: [],
|
193
|
+
|
194
|
+
// Whether to use watchman for file crawling
|
195
|
+
// watchman: true,
|
196
|
+
};
|
package/jsdoc.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"title": "Bux Javascript client",
|
3
|
+
"source": {
|
4
|
+
"includePattern": ".+\\.ts(doc|x)?$",
|
5
|
+
"excludePattern": ".+\\.(test|spec).ts"
|
6
|
+
},
|
7
|
+
"plugins": [
|
8
|
+
"node_modules/better-docs/typescript"
|
9
|
+
],
|
10
|
+
"tags": {
|
11
|
+
"allowUnknownTags": ["optional"]
|
12
|
+
},
|
13
|
+
"opts": {
|
14
|
+
"template": "node_modules/better-docs"
|
15
|
+
}
|
16
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
{
|
2
|
+
"name": "bsv-bap",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "BAP npm module",
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "https://github.com/BitcoinSchema/bap.git"
|
8
|
+
},
|
9
|
+
"license": "Open BSV",
|
10
|
+
"precommit": "test",
|
11
|
+
"main": "dist/typescript-npm-package.cjs.js",
|
12
|
+
"module": "dist/typescript-npm-package.esm.js",
|
13
|
+
"browser": "dist/typescript-npm-package.umd.js",
|
14
|
+
"scripts": {
|
15
|
+
"build": "rollup -c",
|
16
|
+
"build:types": "tsc -p ./tsconfig.json --outDir build --declaration true && api-extractor run",
|
17
|
+
"clean": "rimraf ./build ./dist ./docs",
|
18
|
+
"deploy": "bun run pub --access public",
|
19
|
+
"dev": "rollup -c -w",
|
20
|
+
"docs": "rimraf ./docs && jsdoc src -r -c jsdoc.json -d docs",
|
21
|
+
"prebuild:types": "rimraf ./build",
|
22
|
+
"predocs": "rimraf ./docs",
|
23
|
+
"pub": "bun run build && bun run publish",
|
24
|
+
"lint": "eslint ./src",
|
25
|
+
"lintfix": "eslint ./src --fix",
|
26
|
+
"testquiet": "jest --detectOpenHandles --forceExit --silent",
|
27
|
+
"testwatch": "jest --watchAll --collectCoverage --logHeapUsage --detectOpenHandles",
|
28
|
+
"test": "bun run lint && bun test",
|
29
|
+
"test-watch": "bun run testwatch",
|
30
|
+
"check": "./node_modules/.bin/npm-check -u",
|
31
|
+
"prepare": "bun run clean && bun run lint && bun test && bun run build"
|
32
|
+
},
|
33
|
+
"devDependencies": {
|
34
|
+
"@babel/core": "^7.17.5",
|
35
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
36
|
+
"@babel/preset-env": "^7.16.11",
|
37
|
+
"@babel/preset-typescript": "^7.16.7",
|
38
|
+
"@rollup/plugin-babel": "^5.3.1",
|
39
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
40
|
+
"@rollup/plugin-json": "^4.1.0",
|
41
|
+
"@rollup/plugin-node-resolve": "^14.0.0",
|
42
|
+
"@rollup/plugin-typescript": "^8.3.1",
|
43
|
+
"@types/bsv": "github:chainbow/bsv-types",
|
44
|
+
"@types/jest": "^29.0.0",
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
46
|
+
"@typescript-eslint/parser": "^5.38.1",
|
47
|
+
"babel-jest": "^29.0.0",
|
48
|
+
"bsv": "^1.5.6",
|
49
|
+
"eslint": "^8.24.0",
|
50
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
51
|
+
"eslint-plugin-import": "^2.22.1",
|
52
|
+
"jest": "^26.6.3",
|
53
|
+
"jest-cli": "^26.6.3",
|
54
|
+
"jest-fetch-mock": "^3.0.3",
|
55
|
+
"jest-slow-test-reporter": "^1.0.0",
|
56
|
+
"npm-check": "5.9.2",
|
57
|
+
"pre-commit": "^1.2.2",
|
58
|
+
"regenerator-runtime": "^0.13.7",
|
59
|
+
"rimraf": "3.0.2",
|
60
|
+
"rollup": "^2.70.0",
|
61
|
+
"rollup-plugin-dts": "^4.2.0",
|
62
|
+
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
|
63
|
+
"rollup-plugin-node-builtins": "^2.1.2",
|
64
|
+
"rollup-plugin-polyfill-node": "^0.10.0",
|
65
|
+
"run-sequence": "2.2.1",
|
66
|
+
"ts-node": "^10.4.0",
|
67
|
+
"tslib": "^2.3.1",
|
68
|
+
"typedoc": "^0.23.1",
|
69
|
+
"typescript": "^4.6.2"
|
70
|
+
},
|
71
|
+
"dependencies": {
|
72
|
+
"@bsv/sdk": "^1.1.19",
|
73
|
+
"@types/randombytes": "^2.0.3",
|
74
|
+
"node-fetch": "^2.6.1",
|
75
|
+
"randombytes": "^2.1.0"
|
76
|
+
},
|
77
|
+
"peerDependencies": {
|
78
|
+
"bsv": "^1.5.6"
|
79
|
+
}
|
80
|
+
}
|
package/rollup.config.js
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
import resolve from "@rollup/plugin-node-resolve";
|
2
|
+
import commonjs from "@rollup/plugin-commonjs";
|
3
|
+
import typescript from "@rollup/plugin-typescript";
|
4
|
+
import json from "@rollup/plugin-json";
|
5
|
+
import nodePolyfills from 'rollup-plugin-polyfill-node';
|
6
|
+
import excludeDependenciesFromBundle from "rollup-plugin-exclude-dependencies-from-bundle";
|
7
|
+
import dts from 'rollup-plugin-dts';
|
8
|
+
import builtins from 'rollup-plugin-node-builtins';
|
9
|
+
import pkg from "./package.json";
|
10
|
+
|
11
|
+
export default [
|
12
|
+
// browser-friendly UMD build
|
13
|
+
{
|
14
|
+
input: "src/index.ts",
|
15
|
+
output: {
|
16
|
+
name: "typescriptNpmPackage",
|
17
|
+
file: pkg.browser,
|
18
|
+
format: "umd",
|
19
|
+
sourcemap: true,
|
20
|
+
},
|
21
|
+
external: ['bsv'],
|
22
|
+
plugins: [
|
23
|
+
builtins(),
|
24
|
+
resolve({
|
25
|
+
skip: ['bsv'],
|
26
|
+
browser: true,
|
27
|
+
preferBuiltins: true,
|
28
|
+
}),
|
29
|
+
commonjs(),
|
30
|
+
json(),
|
31
|
+
typescript({tsconfig: "./tsconfig.json", sourceMap: false}),
|
32
|
+
nodePolyfills(),
|
33
|
+
],
|
34
|
+
},
|
35
|
+
|
36
|
+
// CommonJS (for Node) and ES module (for bundlers) build.
|
37
|
+
// (We could have three entries in the configuration array
|
38
|
+
// instead of two, but it's quicker to generate multiple
|
39
|
+
// builds from a single configuration where possible, using
|
40
|
+
// an array for the `output` option, where we can specify
|
41
|
+
// `file` and `format` for each target)
|
42
|
+
{
|
43
|
+
input: "src/index.ts",
|
44
|
+
output: [
|
45
|
+
{file: pkg.main, format: "cjs", sourcemap: true},
|
46
|
+
{file: pkg.module, format: "es", sourcemap: true},
|
47
|
+
],
|
48
|
+
plugins: [
|
49
|
+
typescript({tsconfig: "./tsconfig.json", sourceMap: false}),
|
50
|
+
excludeDependenciesFromBundle({peerDependencies: true}),
|
51
|
+
],
|
52
|
+
},
|
53
|
+
|
54
|
+
{
|
55
|
+
// path to your declaration files root
|
56
|
+
input: './dist/src/index.d.ts',
|
57
|
+
output: [
|
58
|
+
{file: 'dist/typescript-npm-package.cjs.d.ts', format: 'es'},
|
59
|
+
{file: 'dist/typescript-npm-package.esm.d.ts', format: 'es'},
|
60
|
+
{file: 'dist/typescript-npm-package.umd.d.ts', format: 'es'}
|
61
|
+
],
|
62
|
+
plugins: [dts()],
|
63
|
+
},
|
64
|
+
];
|
package/setup-jest.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require('jest-fetch-mock').enableMocks()
|
package/src/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Bitcoin Attestation Protocol - BAP
|
2
|
+
> A simple protocol to create a chain of trust for any kind of information on the Bitcoin blockchain
|
3
|
+
|
4
|
+
Javascript classes for working with identities and attestations.
|
5
|
+
|
6
|
+
**NOTE: This is work in progress and more documentation will follow.**
|
7
|
+
|
8
|
+
# BAP
|
9
|
+
|
10
|
+
The BAP class is a wrapper around all BAP functions, including managing IDs and attestations.
|
11
|
+
|
12
|
+
```shell
|
13
|
+
npm install bitcoin-bap --save
|
14
|
+
```
|
15
|
+
|
16
|
+
Example creating a new ID:
|
17
|
+
```javascript
|
18
|
+
const HDPrivateKey = 'xprv...';
|
19
|
+
const bap = new BAP(HDPrivateKey);
|
20
|
+
|
21
|
+
// Create a new identity
|
22
|
+
const newId = bap.newId();
|
23
|
+
// set the name of the ID
|
24
|
+
newId.name = 'Social media identity';
|
25
|
+
// set a description for this ID
|
26
|
+
newId.description = 'Pseudonymous identity to use on social media sites';
|
27
|
+
// set identity attributes
|
28
|
+
newId.addAttribute('name', 'John Doe');
|
29
|
+
newId.addAttribute('email', 'john@doe.com');
|
30
|
+
|
31
|
+
// export the identities for storage
|
32
|
+
const encryptedExport = bap.exportIds();
|
33
|
+
```
|
34
|
+
|
35
|
+
Signing:
|
36
|
+
```javascript
|
37
|
+
const HDPrivateKey = 'xprv...';
|
38
|
+
const bap = new BAP(HDPrivateKey);
|
39
|
+
const identity = bap.getId("<identityKey>");
|
40
|
+
|
41
|
+
// B protocol data
|
42
|
+
const opReturn = [
|
43
|
+
Buffer.from('19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut').toString('hex'),
|
44
|
+
Buffer.from('Hello World!').toString('hex'),
|
45
|
+
Buffer.from('text/plain').toString('hex'),
|
46
|
+
Buffer.from('utf8').toString('hex'),
|
47
|
+
];
|
48
|
+
// signOpReturnWithAIP expects and returns hex values
|
49
|
+
const signedOpReturn = identity.signOpReturnWithAIP(opReturn);
|
50
|
+
```
|
51
|
+
|
52
|
+
Encryption, every identity has a separate encryption/decryption key:
|
53
|
+
```javascript
|
54
|
+
const HDPrivateKey = 'xprv...';
|
55
|
+
const bap = new BAP(HDPrivateKey);
|
56
|
+
const identity = bap.getId("<identityKey>");
|
57
|
+
|
58
|
+
const publicKey = identity.getEncryptionPublicKey();
|
59
|
+
|
60
|
+
const cipherText = identity.encrypt('Hello World!');
|
61
|
+
|
62
|
+
const text = identity.decrypt(cipherText);
|
63
|
+
```
|
64
|
+
|
65
|
+
The encryption uses `ECIES` from the `@bsv/sdk` library:
|
66
|
+
```javascript
|
67
|
+
import { ECIES, Utils } from '@bsv/sdk'
|
68
|
+
const { toArray, toBase64 } = Utils;
|
69
|
+
|
70
|
+
return toBase64(bitcoreEncrypt(toArray(stringData)));
|
71
|
+
```
|
72
|
+
|
73
|
+
Other examples:
|
74
|
+
```javascript
|
75
|
+
// List the identity keys of all id's
|
76
|
+
const idKeys = bap.listIds();
|
77
|
+
|
78
|
+
// get a certain id
|
79
|
+
const id = bap.getId(idKeys[0]);
|
80
|
+
```
|
@@ -0,0 +1,119 @@
|
|
1
|
+
// https://schema.org/Person
|
2
|
+
{
|
3
|
+
"name": {
|
4
|
+
"type": "string",
|
5
|
+
"description": "Full name of user"
|
6
|
+
},
|
7
|
+
"givenName": {
|
8
|
+
"type": "string",
|
9
|
+
"description": "Given name as shown in official documents"
|
10
|
+
},
|
11
|
+
"familyName": {
|
12
|
+
"type": "string",
|
13
|
+
"description": "Family name as shown in official documents"
|
14
|
+
},
|
15
|
+
"alternateName": {
|
16
|
+
"type": "string",
|
17
|
+
"description": "A self chosen nickname"
|
18
|
+
},
|
19
|
+
"gender": {
|
20
|
+
"type": "string",
|
21
|
+
"description": "Male / Female / other / ... - https://schema.org/GenderType"
|
22
|
+
},
|
23
|
+
"birthDate": {
|
24
|
+
"type": "string",
|
25
|
+
"description": "Birthday of the user - YYYY-MM-DD - https://schema.org/Date"
|
26
|
+
},
|
27
|
+
"email": {
|
28
|
+
"type": "string",
|
29
|
+
"description": "Email address of the the user"
|
30
|
+
},
|
31
|
+
"telephone": {
|
32
|
+
"type": "string",
|
33
|
+
"description": "Phone number of the user - international format +14255551212 (https://www.itu.int/rec/T-REC-E.164-201011-I/en)"
|
34
|
+
},
|
35
|
+
"mobile": {
|
36
|
+
"type": "string",
|
37
|
+
"description": "Mobile phone number of the user - international format +14255551212 (https://www.itu.int/rec/T-REC-E.164-201011-I/en) - NOTE, not defined in schema.org"
|
38
|
+
},
|
39
|
+
"address": {
|
40
|
+
"type": "string",
|
41
|
+
"description": "Address of the user - to be verified the address should be the full address as shown on local postage, from authorities - new lines allowed - https://schema.org/address"
|
42
|
+
},
|
43
|
+
"country": {
|
44
|
+
"type": "string",
|
45
|
+
"description": "ISO 3166-1 3-letter country code of the users residence"
|
46
|
+
},
|
47
|
+
"nationality": {
|
48
|
+
"type": "string",
|
49
|
+
"description": "ISO 3166-1 3-letter country code of the users nationality"
|
50
|
+
},
|
51
|
+
"website": {
|
52
|
+
"type": "string",
|
53
|
+
"description": "Website address of the the user - not defined at schema.org"
|
54
|
+
},
|
55
|
+
"avatar": {
|
56
|
+
"type": "string",
|
57
|
+
"description": "URL of the users avatar - can be a base64 URI - not defined at schema.org"
|
58
|
+
},
|
59
|
+
"passportNr": {
|
60
|
+
"type": "string",
|
61
|
+
"description": "Document number of the passport of the user - not defined at schema.org"
|
62
|
+
},
|
63
|
+
"passportExpiration": {
|
64
|
+
"type": "string",
|
65
|
+
"description": "Passport expiration date - YYYY-MM-DD - not defined at schema.org"
|
66
|
+
},
|
67
|
+
"passportCountry": {
|
68
|
+
"type": "string",
|
69
|
+
"description": "ISO 3166-1 3-letter country code of the passport issuer - not defined at schema.org"
|
70
|
+
},
|
71
|
+
"driversLicenseNr": {
|
72
|
+
"type": "string",
|
73
|
+
"description": "Document number of the drivers license of the user - not defined at schema.org"
|
74
|
+
},
|
75
|
+
"driversLicenseExpiration": {
|
76
|
+
"type": "string",
|
77
|
+
"description": "Expiration date of the drivers license of the user - not defined at schema.org"
|
78
|
+
},
|
79
|
+
"driversLicenseCountry": {
|
80
|
+
"type": "string",
|
81
|
+
"description": "ISO 3166-1 3-letter country code of the passport issuer - not defined at schema.org"
|
82
|
+
},
|
83
|
+
"socialSecurityNr": {
|
84
|
+
"type": "string",
|
85
|
+
"description": "Social security number of the user - not defined at schema.org"
|
86
|
+
},
|
87
|
+
"uniKey": {
|
88
|
+
"type": "string",
|
89
|
+
"description": "A hash of all the attributes of a persons passport, to create a deterministic unique id for the user that can be used across identities - not defined at schema.org"
|
90
|
+
},
|
91
|
+
"uniKeyExpirationDate": {
|
92
|
+
"type": "string",
|
93
|
+
"description": "The expiration date of the document used to create the uniKey - the nonce of the uniKeyExpirationDate should be the uniKey hash"
|
94
|
+
},
|
95
|
+
"isHuman": {
|
96
|
+
"type": "number",
|
97
|
+
"description": "Whether this ID is a real human - this can be used to attest this is not a bot - not defined at schema.org"
|
98
|
+
},
|
99
|
+
"over18": {
|
100
|
+
"type": "number",
|
101
|
+
"description": "1 if the user is over 18 - not defined at schema.org"
|
102
|
+
},
|
103
|
+
"over19": {
|
104
|
+
"type": "number",
|
105
|
+
"description": "1 if the user is over 19 - not defined at schema.org"
|
106
|
+
},
|
107
|
+
"over20": {
|
108
|
+
"type": "number",
|
109
|
+
"description": "1 if the user is over 20 - not defined at schema.org"
|
110
|
+
},
|
111
|
+
"over21": {
|
112
|
+
"type": "number",
|
113
|
+
"description": "1 if the user is over 21 - not defined at schema.org"
|
114
|
+
},
|
115
|
+
"over25": {
|
116
|
+
"type": "number",
|
117
|
+
"description": "1 if the user is over 25 - not defined at schema.org"
|
118
|
+
}
|
119
|
+
}
|
package/src/constants.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export const BAP_BITCOM_ADDRESS = '1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT';
|
2
|
+
export const BAP_BITCOM_ADDRESS_HEX = `0x${Buffer.from(BAP_BITCOM_ADDRESS).toString('hex')}`;
|
3
|
+
export const AIP_BITCOM_ADDRESS = '15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva';
|
4
|
+
export const AIP_BITCOM_ADDRESS_HEX = `0x${Buffer.from(AIP_BITCOM_ADDRESS).toString('hex')}`;
|
5
|
+
export const BAP_SERVER = 'https://bap.network/api/v1';
|
6
|
+
export const MAX_INT = 2147483648 - 1; // 0x80000000
|
7
|
+
|
8
|
+
// This is just a choice for this library and could be anything else if so needed/wanted
|
9
|
+
// but it is advisable to use the same derivation between libraries for compatibility
|
10
|
+
export const SIGNING_PATH_PREFIX = 'm/424150\'/0\'/0\''; // BAP in hex
|
11
|
+
export const ENCRYPTION_PATH = `m/424150'/${MAX_INT}'/${MAX_INT}'`;
|