Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+35
View File
@@ -0,0 +1,35 @@
# TypeScript/JavaScript SDK for `did:ion`
- This SDK allows you to create `did:ion` operations that are ready to be submitted to an ION node.
- You can also use the SDK to create long-form ION DIDs.
- This SDK is compatible with both node.js and browser.
Code Coverage
![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-100%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=flat)
```
npm i @decentralized-identity/ion-sdk --save
```
## Additional Setup
This package depends on the [`@noble/ed25519`](https://github.com/paulmillr/noble-ed25519#usage) and [`@noble/secp256k1`](https://github.com/paulmillr/noble-secp256k1#usage) v2, thus additional steps are needed for some environments:
```ts
// node.js 18 and earlier, needs globalThis.crypto polyfill
import { webcrypto } from 'node:crypto';
// @ts-ignore
if (!globalThis.crypto) globalThis.crypto = webcrypto;
// React Native needs crypto.getRandomValues polyfill and sha256 for `@noble/secp256k1`
import 'react-native-get-random-values';
import { hmac } from '@noble/hashes/hmac';
import { sha256 } from '@noble/hashes/sha256';
secp.etc.hmacSha256Sync = (k, ...m) => hmac(sha256, k, secp.etc.concatBytes(...m));
secp.etc.hmacSha256Async = (k, ...m) => Promise.resolve(secp.etc.hmacSha256Sync(k, ...m));
// React Native needs crypto.getRandomValues polyfill and sha512 for `@noble/ed25519`
import 'react-native-get-random-values';
import { sha512 } from '@noble/hashes/sha512';
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
ed.etc.sha512Async = (...m) => Promise.resolve(ed.etc.sha512Sync(...m));
```
@@ -0,0 +1,31 @@
/**
* Class that encodes binary blobs into strings.
* Note that the encode/decode methods may change underlying encoding scheme.
*/
export default class Encoder {
/**
* Encodes given bytes into a Base64URL string.
*/
static encode(content: Uint8Array): string;
/**
* Decodes the given Base64URL string into bytes.
*/
static decodeAsBytes(encodedContent: string, inputContextForErrorLogging: string): Uint8Array;
/**
* Decodes the given Base64URL string into the original string.
*/
static decodeAsString(encodedContent: string, inputContextForErrorLogging: string): string;
/**
* Tests if the given string is a Base64URL string.
*/
static isBase64UrlString(input: string): boolean;
/**
* Converts input string to bytes.
*/
static stringToBytes(input: string): Uint8Array;
/**
* Converts bytes to string.
*/
static bytesToString(input: Uint8Array): string;
}
//# sourceMappingURL=Encoder.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"Encoder.d.ts","sourceRoot":"","sources":["../../lib/Encoder.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B;;OAEG;WACW,MAAM,CAAE,OAAO,EAAE,UAAU,GAAG,MAAM;IAKlD;;OAEG;WACW,aAAa,CAAE,cAAc,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,GAAG,UAAU;IAQrG;;OAEG;WACW,cAAc,CAAE,cAAc,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,GAAG,MAAM;IAMlG;;OAEG;WACW,iBAAiB,CAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAUxD;;OAEG;WACW,aAAa,CAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAKvD;;OAEG;WACW,aAAa,CAAE,KAAK,EAAE,UAAU,GAAG,MAAM;CAIxD"}
@@ -0,0 +1,59 @@
import ErrorCode from './ErrorCode.js';
import IonError from './IonError.js';
import { base64url } from 'multiformats/bases/base64';
/**
* Class that encodes binary blobs into strings.
* Note that the encode/decode methods may change underlying encoding scheme.
*/
export default class Encoder {
/**
* Encodes given bytes into a Base64URL string.
*/
static encode(content) {
const encodedContent = base64url.baseEncode(content);
return encodedContent;
}
/**
* Decodes the given Base64URL string into bytes.
*/
static decodeAsBytes(encodedContent, inputContextForErrorLogging) {
if (!Encoder.isBase64UrlString(encodedContent)) {
throw new IonError(ErrorCode.EncodedStringIncorrectEncoding, `Given ${inputContextForErrorLogging} must be base64url string.`);
}
return base64url.baseDecode(encodedContent);
}
/**
* Decodes the given Base64URL string into the original string.
*/
static decodeAsString(encodedContent, inputContextForErrorLogging) {
const rawBytes = Encoder.decodeAsBytes(encodedContent, inputContextForErrorLogging);
return Encoder.bytesToString(rawBytes);
}
/**
* Tests if the given string is a Base64URL string.
*/
static isBase64UrlString(input) {
// NOTE:
// /<expression>/ denotes regex.
// ^ denotes beginning of string.
// $ denotes end of string.
// + denotes one or more characters.
const isBase64UrlString = /^[A-Za-z0-9_-]+$/.test(input);
return isBase64UrlString;
}
/**
* Converts input string to bytes.
*/
static stringToBytes(input) {
const bytes = new TextEncoder().encode(input);
return bytes;
}
/**
* Converts bytes to string.
*/
static bytesToString(input) {
const output = new TextDecoder().decode(input);
return output;
}
}
//# sourceMappingURL=Encoder.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Encoder.js","sourceRoot":"","sources":["../../lib/Encoder.ts"],"names":[],"mappings":"AAAA,OAAO,SA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AEG;IACI,MAAM,CAAC,aAAa,CAAE,KAAiB;QAC5C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,27 @@
/**
* ION SDK error codes.
*/
declare const _default: {
DeltaExceedsMaximumSize: string;
DidDocumentPublicKeyIdDuplicated: string;
DidDocumentPublicKeyMissingOrIncorrectType: string;
DidDocumentServiceIdDuplicated: string;
DidSuffixIncorrectLength: string;
EncodedStringIncorrectEncoding: string;
IdNotUsingBase64UrlCharacterSet: string;
IdTooLong: string;
JwkEs256kMissingOrInvalidCrv: string;
JwkEs256kMissingOrInvalidKty: string;
JwkEs256kHasIncorrectLengthOfX: string;
JwkEs256kHasIncorrectLengthOfY: string;
JwkEs256kHasIncorrectLengthOfD: string;
MultihashStringNotAMultihash: string;
MultihashUnsupportedHashAlgorithm: string;
PublicKeyJwkEs256kHasUnexpectedProperty: string;
PublicKeyPurposeDuplicated: string;
ServiceEndpointCannotBeAnArray: string;
ServiceEndpointStringNotValidUri: string;
ServiceTypeTooLong: string;
};
export default _default;
//# sourceMappingURL=ErrorCode.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"ErrorCode.d.ts","sourceRoot":"","sources":["../../lib/ErrorCode.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAqBE"}
@@ -0,0 +1,26 @@
/**
* ION SDK error codes.
*/
export default {
DeltaExceedsMaximumSize: 'DeltaExceedsMaximumSize',
DidDocumentPublicKeyIdDuplicated: 'DidDocumentPublicKeyIdDuplicated',
DidDocumentPublicKeyMissingOrIncorrectType: 'DidDocumentPublicKeyMissingOrIncorrectType',
DidDocumentServiceIdDuplicated: 'DidDocumentServiceIdDuplicated',
DidSuffixIncorrectLength: 'DidSuffixIncorrectLength',
EncodedStringIncorrectEncoding: 'EncodedStringIncorrectEncoding',
IdNotUsingBase64UrlCharacterSet: 'IdNotUsingBase64UrlCharacterSet',
IdTooLong: 'IdTooLong',
JwkEs256kMissingOrInvalidCrv: 'JwkEs256kMissingOrInvalidCrv',
JwkEs256kMissingOrInvalidKty: 'JwkEs256kMissingOrInvalidKty',
JwkEs256kHasIncorrectLengthOfX: 'JwkEs256kHasIncorrectLengthOfX',
JwkEs256kHasIncorrectLengthOfY: 'JwkEs256kHasIncorrectLengthOfY',
JwkEs256kHasIncorrectLengthOfD: 'JwkEs256kHasIncorrectLengthOfD',
MultihashStringNotAMultihash: 'MultihashStringNotAMultihash',
MultihashUnsupportedHashAlgorithm: 'MultihashUnsupportedHashAlgorithm',
PublicKeyJwkEs256kHasUnexpectedProperty: 'PublicKeyJwkEs256kHasUnexpectedProperty',
PublicKeyPurposeDuplicated: 'PublicKeyPurposeDuplicated',
ServiceEndpointCannotBeAnArray: 'ServiceEndpointCannotBeAnArray',
ServiceEndpointStringNotValidUri: 'ServiceEndpointStringNotValidUri',
ServiceTypeTooLong: 'ServiceTypeTooLong'
};
//# sourceMappingURL=ErrorCode.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ErrorCode.js","sourceRoot":"","sources":["../../lib/ErrorCode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAe;IACb,uBAAuB,EAAE,yBAAyB;IAClD,gCAAgC,EAAE,kCAAkC;IACpE,0CAA0C,EAAE,4CAA4C;IACxF,8BAA8B,EAAE,gCAAgC;IAChE,wBAAwB,EAAE,0BAA0B;IACpD,8BAA8B,EAAE,gCAAgC;IAChE,+BAA+B,EAAE,iCAAiC;IAClE,SAAS,EAAE,WAAW;IACtB,4BAA4B,EAAE,8BAA8B;IAC5D,4BAA4B,EAAE,8BAA8B;IAC5D,8BAA8B,EAAE,gCAAgC;IAChE,8BAA8B,EAAE,gCAAgC;IAChE,8BAA8B,EAAE,gCAAgC;IAChE,4BAA4B,EAAE,8BAA8B;IAC5D,iCAAiC,EAAE,mCAAmC;IACtE,uCAAuC,EAAE,yCAAyC;IAClF,0BAA0B,EAAE,4BAA4B;IACxD,8BAA8B,EAAE,gCAAgC;IAChE,gCAAgC,EAAE,kCAAkC;IACpE,kBAAkB,EAAE,oBAAoB;CACzC,CAAC"}
@@ -0,0 +1,21 @@
import IonPublicKeyPurpose from './enums/IonPublicKeyPurpose.js';
import JwkEs256k from './models/JwkEs256k.js';
import OperationKeyType from './enums/OperationKeyType.js';
/**
* Class containing input validation methods.
*/
export default class InputValidator {
/**
* Validates the schema of a ES256K JWK key.
*/
static validateEs256kOperationKey(operationKeyJwk: JwkEs256k, operationKeyType: OperationKeyType): void;
/**
* Validates an `id` property (in `IonPublicKeyModel` and `IonServiceModel`).
*/
static validateId(id: string): void;
/**
* Validates the given public key purposes.
*/
static validatePublicKeyPurposes(purposes?: IonPublicKeyPurpose[]): void;
}
//# sourceMappingURL=InputValidator.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"InputValidator.d.ts","sourceRoot":"","sources":["../../lib/InputValidator.ts"],"names":[],"mappings":"AAGA,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AACjE,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC;;OAEG;WACW,0BAA0B,CAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB;IAiCxG;;OAEG;WACW,UAAU,CAAE,EAAE,EAAE,MAAM;IAWpC;;OAEG;WACW,yBAAyB,CAAE,QAAQ,CAAC,EAAE,mBAAmB,EAAE;CAe1E"}
@@ -0,0 +1,69 @@
import Encoder from './Encoder.js';
import ErrorCode from './ErrorCode.js';
import IonError from './IonError.js';
import OperationKeyType from './enums/OperationKeyType.js';
/**
* Class containing input validation methods.
*/
export default class InputValidator {
/**
* Validates the schema of a ES256K JWK key.
*/
static validateEs256kOperationKey(operationKeyJwk, operationKeyType) {
const allowedProperties = new Set(['kty', 'crv', 'x', 'y']);
if (operationKeyType === OperationKeyType.Private) {
allowedProperties.add('d');
}
for (const property in operationKeyJwk) {
if (!allowedProperties.has(property)) {
throw new IonError(ErrorCode.PublicKeyJwkEs256kHasUnexpectedProperty, `SECP256K1 JWK key has unexpected property '${property}'.`);
}
}
if (operationKeyJwk.crv !== 'secp256k1') {
throw new IonError(ErrorCode.JwkEs256kMissingOrInvalidCrv, `SECP256K1 JWK 'crv' property must be 'secp256k1' but got '${operationKeyJwk.crv}.'`);
}
if (operationKeyJwk.kty !== 'EC') {
throw new IonError(ErrorCode.JwkEs256kMissingOrInvalidKty, `SECP256K1 JWK 'kty' property must be 'EC' but got '${operationKeyJwk.kty}.'`);
}
// `x` and `y` need 43 Base64URL encoded bytes to contain 256 bits.
if (operationKeyJwk.x.length !== 43) {
throw new IonError(ErrorCode.JwkEs256kHasIncorrectLengthOfX, `SECP256K1 JWK 'x' property must be 43 bytes.`);
}
if (operationKeyJwk.y.length !== 43) {
throw new IonError(ErrorCode.JwkEs256kHasIncorrectLengthOfY, `SECP256K1 JWK 'y' property must be 43 bytes.`);
}
if (operationKeyType === OperationKeyType.Private && (operationKeyJwk.d === undefined || operationKeyJwk.d.length !== 43)) {
throw new IonError(ErrorCode.JwkEs256kHasIncorrectLengthOfD, `SECP256K1 JWK 'd' property must be 43 bytes.`);
}
}
/**
* Validates an `id` property (in `IonPublicKeyModel` and `IonServiceModel`).
*/
static validateId(id) {
const maxIdLength = 50;
if (id.length > maxIdLength) {
throw new IonError(ErrorCode.IdTooLong, `Key ID length ${id.length} exceed max allowed length of ${maxIdLength}.`);
}
if (!Encoder.isBase64UrlString(id)) {
throw new IonError(ErrorCode.IdNotUsingBase64UrlCharacterSet, `Key ID '${id}' is not a Base64URL string.`);
}
}
/**
* Validates the given public key purposes.
*/
static validatePublicKeyPurposes(purposes) {
// Nothing to validate if `purposes` is undefined.
if (purposes === undefined) {
return;
}
// Validate that all purposes are be unique.
const processedPurposes = new Set();
for (const purpose of purposes) {
if (processedPurposes.has(purpose)) {
throw new IonError(ErrorCode.PublicKeyPurposeDuplicated, `Public key purpose '${purpose}' already specified.`);
}
processedPurposes.add(purpose);
}
}
}
//# sourceMappingURL=InputValidator.js.map
@@ -0,0 +1 @@
{"version":3,"file":"InputValidator.js","sourceRoot":"","sources":["../../lib/InputValidator.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,QAAQ,MAAM,eAAe,CAAC;AAGrC,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC;;OAEG;IACI,MAAM,CAAC,0BAA0B,CAAE,eAA0B,EAAE,gBAAkC;QACtG,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC5D,IAAI,gBAAgB,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAClD,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,uCAAuC,EAAE,8CAA8C,QAAQ,IAAI,CAAC,CAAC;YACpI,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,GAAG,KAAK,WAAW,EAAE,CAAC;YACxC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,4BAA4B,EAAE,6DAA6D,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;QACnJ,CAAC;QAED,IAAI,eAAe,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,4BAA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AED,4CAA4C;QAC5C,MAAM,iBAAiB,GAA6B,IAAI,GAAG,EAAE,CAAC;QAC9D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,0BAA0B,EAAE,uBAAuB,OAAO,sBAAsB,CAAC,CAAC;YACjH,CAAC;YACD,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
import IonDocumentModel from './models/IonDocumentModel.js';
import JwkEs256k from './models/JwkEs256k.js';
/**
* Class containing DID related operations.
*/
export default class IonDid {
/**
* Creates a long-form DID.
* @param input.document The initial state to be associate with the ION DID to be created using a `replace` document patch action.
*/
static createLongFormDid(input: {
recoveryKey: JwkEs256k;
updateKey: JwkEs256k;
document: IonDocumentModel;
}): Promise<string>;
/**
* Computes the DID unique suffix given the encoded suffix data string.
*/
private static computeDidUniqueSuffix;
}
//# sourceMappingURL=IonDid.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonDid.d.ts","sourceRoot":"","sources":["../../lib/IonDid.ts"],"names":[],"mappings":"AAEA,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAI5D,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAG9C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB;;;OAGG;WACiB,iBAAiB,CAAE,KAAK,EAAE;QAC5C,WAAW,EAAE,SAAS,CAAC;QACvB,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,MAAM,CAAC;IA0BnB;;OAEG;mBACkB,sBAAsB;CAM5C"}
@@ -0,0 +1,58 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import Encoder from './Encoder.js';
import IonRequest from './IonRequest.js';
import IonSdkConfig from './IonSdkConfig.js';
import JsonCanonicalizer from './JsonCanonicalizer.js';
import Multihash from './Multihash.js';
/**
* Class containing DID related operations.
*/
export default class IonDid {
/**
* Creates a long-form DID.
* @param input.document The initial state to be associate with the ION DID to be created using a `replace` document patch action.
*/
static createLongFormDid(input) {
return __awaiter(this, void 0, void 0, function* () {
const createRequest = yield IonRequest.createCreateRequest(input);
const didUniqueSuffix = yield IonDid.computeDidUniqueSuffix(createRequest.suffixData);
// Add the network portion if not configured for mainnet.
let shortFormDid;
if (IonSdkConfig.network === undefined || IonSdkConfig.network === 'mainnet') {
shortFormDid = `did:ion:${didUniqueSuffix}`;
}
else {
shortFormDid = `did:ion:${IonSdkConfig.network}:${didUniqueSuffix}`;
}
const initialState = {
suffixData: createRequest.suffixData,
delta: createRequest.delta
};
// Initial state must be canonicalized as per spec.
const canonicalizedInitialStateBytes = JsonCanonicalizer.canonicalizeAsBytes(initialState);
const encodedCanonicalizedInitialStateString = Encoder.encode(canonicalizedInitialStateBytes);
const longFormDid = `${shortFormDid}:${encodedCanonicalizedInitialStateString}`;
return longFormDid;
});
}
/**
* Computes the DID unique suffix given the encoded suffix data string.
*/
static computeDidUniqueSuffix(suffixData) {
return __awaiter(this, void 0, void 0, function* () {
const canonicalizedStringBytes = JsonCanonicalizer.canonicalizeAsBytes(suffixData);
const multihash = yield Multihash.hash(canonicalizedStringBytes, IonSdkConfig.hashAlgorithmInMultihashCode);
const encodedMultihash = Encoder.encode(multihash);
return encodedMultihash;
});
}
}
//# sourceMappingURL=IonDid.js.map
@@ -0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AAsB,CAAE,UAA+C;;YAC1F,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACnF,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,YAAY,CAAC,4BAA4B,CAAC,CAAC;YAC5G,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACnD,OAAO,gBAAgB,CAAC;QAC1B,CAAC;KAAA;CACF"}
@@ -0,0 +1,8 @@
/**
* A class that represents an ION error.
*/
export default class IonError extends Error {
code: string;
constructor(code: string, message: string);
}
//# sourceMappingURL=IonError.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonError.d.ts","sourceRoot":"","sources":["../../lib/IonError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK;IACrB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAOlD"}
@@ -0,0 +1,13 @@
/**
* A class that represents an ION error.
*/
export default class IonError extends Error {
constructor(code, message) {
super(`${code}: ${message}`);
this.code = code;
// NOTE: Extending 'Error' breaks prototype chain since TypeScript 2.1.
// The following line restores prototype chain.
Object.setPrototypeOf(this, new.target.prototype);
}
}
//# sourceMappingURL=IonError.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonError.js","sourceRoot":"","sources":["../../lib/IonError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK;IACzC,YAAoB,IAAY,EAAE,OAAe;QAC/C,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QADX,SAAI,GAAJ,IAAI,CAAQ;QAG9B,uEAAuE;QACvE,+CAA+C;QAC/C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,42 @@
import IonPublicKeyModel from './models/IonPublicKeyModel.js';
import IonPublicKeyPurpose from './enums/IonPublicKeyPurpose.js';
import JwkEd25519 from './models/JwkEd25519.js';
import JwkEs256k from './models/JwkEs256k.js';
/**
* Class containing operations related to keys used in ION.
*/
export default class IonKey {
/**
* Generates SECP256K1 key pair to be used in an operation.
* Mainly used for testing.
* @returns [publicKey, privateKey]
*/
static generateEs256kDidDocumentKeyPair(input: {
id: string;
purposes?: IonPublicKeyPurpose[];
}): Promise<[IonPublicKeyModel, JwkEs256k]>;
/**
* Generates SECP256K1 key pair for ION operation use.
* @returns [publicKey, privateKey]
*/
static generateEs256kOperationKeyPair(): Promise<[JwkEs256k, JwkEs256k]>;
private static generateEs256kKeyPair;
/**
* Generates Ed25519 key pair to be used in an operation.
* Mainly used for testing.
* @returns [publicKey, privateKey]
*/
static generateEd25519DidDocumentKeyPair(input: {
id: string;
purposes?: IonPublicKeyPurpose[];
}): Promise<[IonPublicKeyModel, JwkEd25519]>;
/**
* Generates Ed25519 key pair for ION operation use.
* @returns [publicKey, privateKey]
*/
static generateEd25519OperationKeyPair(): Promise<[JwkEd25519, JwkEd25519]>;
private static generateEd25519KeyPair;
static isJwkEs256k(key: JwkEs256k | JwkEd25519): key is JwkEs256k;
static isJwkEd25519(key: JwkEs256k | JwkEd25519): key is JwkEd25519;
}
//# sourceMappingURL=IonKey.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonKey.d.ts","sourceRoot":"","sources":["../../lib/IonKey.ts"],"names":[],"mappings":"AAGA,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AACjE,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAG9C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB;;;;OAIG;WACiB,gCAAgC,CAAE,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;IAsBvJ;;;OAGG;WACiB,8BAA8B,IAAK,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;mBAKjE,qBAAqB;IA6B1C;;;;OAIG;WACiB,iCAAiC,CAAE,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAsBzJ;;;OAGG;WACiB,+BAA+B,IAAK,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;mBAKpE,sBAAsB;WAmB7B,WAAW,CAAE,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,GAAG,IAAI,SAAS;WAI3D,YAAY,CAAE,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,GAAG,IAAI,UAAU;CAG5E"}
@@ -0,0 +1,138 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as Ed25519 from '@noble/ed25519';
import * as Secp256k1 from '@noble/secp256k1';
import InputValidator from './InputValidator.js';
import { base64url } from 'multiformats/bases/base64';
/**
* Class containing operations related to keys used in ION.
*/
export default class IonKey {
/**
* Generates SECP256K1 key pair to be used in an operation.
* Mainly used for testing.
* @returns [publicKey, privateKey]
*/
static generateEs256kDidDocumentKeyPair(input) {
return __awaiter(this, void 0, void 0, function* () {
const id = input.id;
const purposes = input.purposes;
InputValidator.validateId(id);
InputValidator.validatePublicKeyPurposes(purposes);
const [publicKey, privateKey] = yield IonKey.generateEs256kKeyPair();
const publicKeyModel = {
id,
type: 'EcdsaSecp256k1VerificationKey2019',
publicKeyJwk: publicKey
};
// Only add the `purposes` property If given `purposes` array has at least an entry.
if (purposes !== undefined && purposes.length > 0) {
publicKeyModel.purposes = purposes;
}
return [publicKeyModel, privateKey];
});
}
/**
* Generates SECP256K1 key pair for ION operation use.
* @returns [publicKey, privateKey]
*/
static generateEs256kOperationKeyPair() {
return __awaiter(this, void 0, void 0, function* () {
const keyPair = yield IonKey.generateEs256kKeyPair();
return keyPair;
});
}
static generateEs256kKeyPair() {
return __awaiter(this, void 0, void 0, function* () {
const privateKeyBytes = Secp256k1.utils.randomPrivateKey();
const compressedPublicKeyBytes = Secp256k1.getPublicKey(privateKeyBytes);
const compressedPublicKeyHex = Secp256k1.etc.bytesToHex(compressedPublicKeyBytes);
const curvePoints = Secp256k1.ProjectivePoint.fromHex(compressedPublicKeyHex);
const uncompressedPublicKeyBytes = curvePoints.toRawBytes(false); // false = uncompressed
// we need uncompressed public key so that it contains both the x and y values for the JWK format:
// the first byte is a header that indicates whether the key is uncompressed (0x04 if uncompressed).
// bytes 1 - 32 represent X
// bytes 33 - 64 represent Y
const d = base64url.baseEncode(privateKeyBytes);
// skip the first byte because it's used as a header to indicate whether the key is uncompressed
const x = base64url.baseEncode(uncompressedPublicKeyBytes.subarray(1, 33));
const y = base64url.baseEncode(uncompressedPublicKeyBytes.subarray(33, 65));
const publicJwk = {
// alg: 'ES256K',
kty: 'EC',
crv: 'secp256k1',
x,
y
};
const privateJwk = Object.assign(Object.assign({}, publicJwk), { d });
return [publicJwk, privateJwk];
});
}
/**
* Generates Ed25519 key pair to be used in an operation.
* Mainly used for testing.
* @returns [publicKey, privateKey]
*/
static generateEd25519DidDocumentKeyPair(input) {
return __awaiter(this, void 0, void 0, function* () {
const id = input.id;
const purposes = input.purposes;
InputValidator.validateId(id);
InputValidator.validatePublicKeyPurposes(purposes);
const [publicKey, privateKey] = yield IonKey.generateEd25519KeyPair();
const publicKeyModel = {
id,
type: 'JsonWebKey2020',
publicKeyJwk: publicKey
};
// Only add the `purposes` property If given `purposes` array has at least an entry.
if (purposes !== undefined && purposes.length > 0) {
publicKeyModel.purposes = purposes;
}
return [publicKeyModel, privateKey];
});
}
/**
* Generates Ed25519 key pair for ION operation use.
* @returns [publicKey, privateKey]
*/
static generateEd25519OperationKeyPair() {
return __awaiter(this, void 0, void 0, function* () {
const keyPair = yield IonKey.generateEd25519KeyPair();
return keyPair;
});
}
static generateEd25519KeyPair() {
return __awaiter(this, void 0, void 0, function* () {
const privateKeyBytes = Ed25519.utils.randomPrivateKey();
const privateKeyHex = Ed25519.etc.bytesToHex(privateKeyBytes);
const publicKeyBytes = yield Ed25519.getPublicKeyAsync(privateKeyHex);
const d = base64url.baseEncode(privateKeyBytes);
const x = base64url.baseEncode(publicKeyBytes);
const publicJwk = {
// alg: 'EdDSA',
kty: 'OKP',
crv: 'Ed25519',
x
};
const privateJwk = Object.assign(Object.assign({}, publicJwk), { d });
return [publicJwk, privateJwk];
});
}
static isJwkEs256k(key) {
return key.crv === 'secp256k1' && key.kty === 'EC';
}
;
static isJwkEd25519(key) {
return key.crv === 'Ed25519' && key.kty === 'OKP';
}
;
}
//# sourceMappingURL=IonKey.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonKey.js","sourceRoot":"","sources":["../../lib/IonKey.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAKjD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,M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c,EAAE,UAAU,CAAC,CAAC;QACtC,CAAC;KAAA;IAED;;;OAGG;IACI,MAAM,CAAO,+BAA+B;;YACjD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,sBAAsB,EAAE,CAAC;YACtD,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;IAEO,MAAM,CAAO,sBAAsB;;YACzC,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;YACzD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC9D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YAEtE,MAAM,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAChD,MAAM,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YAE/C,MAAM,SAAS,GAAG;gBAChB,gBAAgB;gBAChB,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE,SAAS;gBACd,CAAC;aACF,CAAC;YACF,MAAM,UAAU,mCAAQ,SAAS,KAAE,CAAC,GAAE,CAAC;YAEvC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACjC,CAAC;KAAA;IAEM,MAAM,CAAC,WAAW,CAAE,GAA2B;QACpD,OAAO,GAAG,CAAC,GAAG,KAAK,WAAW,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC;IACrD,CAAC;IAAA,CAAC;IAEK,MAAM,CAAC,YAAY,CAAE,GAA2B;QACrD,OAAO,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,KAAK,CAAC;IACpD,CAAC;IAAA,CAAC;CACH"}
@@ -0,0 +1,52 @@
import ISigner from './interfaces/ISigner.js';
import IonCreateRequestModel from './models/IonCreateRequestModel.js';
import IonDeactivateRequestModel from './models/IonDeactivateRequestModel.js';
import IonDocumentModel from './models/IonDocumentModel.js';
import IonPublicKeyModel from './models/IonPublicKeyModel.js';
import IonRecoverRequestModel from './models/IonRecoverRequestModel.js';
import IonServiceModel from './models/IonServiceModel.js';
import IonUpdateRequestModel from './models/IonUpdateRequestModel.js';
import JwkEs256k from './models/JwkEs256k.js';
/**
* Class containing operations related to ION requests.
*/
export default class IonRequest {
/**
* Creates an ION DID create request.
* @param input.document The initial state to be associate with the ION DID to be created using a `replace` document patch action.
*/
static createCreateRequest(input: {
recoveryKey: JwkEs256k;
updateKey: JwkEs256k;
document: IonDocumentModel;
}): Promise<IonCreateRequestModel>;
static createDeactivateRequest(input: {
didSuffix: string;
recoveryPublicKey: JwkEs256k;
signer: ISigner;
}): Promise<IonDeactivateRequestModel>;
static createRecoverRequest(input: {
didSuffix: string;
recoveryPublicKey: JwkEs256k;
nextRecoveryPublicKey: JwkEs256k;
nextUpdatePublicKey: JwkEs256k;
document: IonDocumentModel;
signer: ISigner;
}): Promise<IonRecoverRequestModel>;
static createUpdateRequest(input: {
didSuffix: string;
updatePublicKey: JwkEs256k;
nextUpdatePublicKey: JwkEs256k;
signer: ISigner;
servicesToAdd?: IonServiceModel[];
idsOfServicesToRemove?: string[];
publicKeysToAdd?: IonPublicKeyModel[];
idsOfPublicKeysToRemove?: string[];
}): Promise<IonUpdateRequestModel>;
private static validateDidSuffix;
private static validateDidDocumentKeys;
private static validateServices;
private static validateService;
private static validateDeltaSize;
}
//# sourceMappingURL=IonRequest.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonRequest.d.ts","sourceRoot":"","sources":["../../lib/IonRequest.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAE9C,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,yBAAyB,MAAM,uCAAuC,CAAC;AAC9E,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,sBAA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hC,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAwBtC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAa/B,OAAO,CAAC,MAAM,CAAC,eAAe;IAuB9B,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAOjC"}
@@ -0,0 +1,271 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as URI from 'uri-js';
import ErrorCode from './ErrorCode.js';
import InputValidator from './InputValidator.js';
import IonError from './IonError.js';
import IonSdkConfig from './IonSdkConfig.js';
import JsonCanonicalizer from './JsonCanonicalizer.js';
import Multihash from './Multihash.js';
import OperationKeyType from './enums/OperationKeyType.js';
import OperationType from './enums/OperationType.js';
import PatchAction from './enums/PatchAction.js';
/**
* Class containing operations related to ION requests.
*/
export default class IonRequest {
/**
* Creates an ION DID create request.
* @param input.document The initial state to be associate with the ION DID to be created using a `replace` document patch action.
*/
static createCreateRequest(input) {
return __awaiter(this, void 0, void 0, function* () {
const recoveryKey = input.recoveryKey;
const updateKey = input.updateKey;
const didDocumentKeys = input.document.publicKeys;
const services = input.document.services;
// Validate recovery and update public keys.
InputValidator.validateEs256kOperationKey(recoveryKey, OperationKeyType.Public);
InputValidator.validateEs256kOperationKey(updateKey, OperationKeyType.Public);
// Validate all given DID Document keys.
IonRequest.validateDidDocumentKeys(didDocumentKeys);
// Validate all given service.
IonRequest.validateServices(services);
const hashAlgorithmInMultihashCode = IonSdkConfig.hashAlgorithmInMultihashCode;
const patches = [{
action: PatchAction.Replace,
document: input.document
}];
const delta = {
updateCommitment: yield Multihash.canonicalizeThenDoubleHashThenEncode(updateKey, hashAlgorithmInMultihashCode),
patches
};
IonRequest.validateDeltaSize(delta);
const deltaHash = yield Multihash.canonicalizeThenHashThenEncode(delta, hashAlgorithmInMultihashCode);
const suffixData = {
deltaHash,
recoveryCommitment: yield Multihash.canonicalizeThenDoubleHashThenEncode(recoveryKey, hashAlgorithmInMultihashCode)
};
const operationRequest = {
type: OperationType.Create,
suffixData: suffixData,
delta: delta
};
return operationRequest;
});
}
static createDeactivateRequest(input) {
return __awaiter(this, void 0, void 0, function* () {
// Validate DID suffix
IonRequest.validateDidSuffix(input.didSuffix);
// Validates recovery public key
InputValidator.validateEs256kOperationKey(input.recoveryPublicKey, OperationKeyType.Public);
const hashAlgorithmInMultihashCode = IonSdkConfig.hashAlgorithmInMultihashCode;
const revealValue = yield Multihash.canonicalizeThenHashThenEncode(input.recoveryPublicKey, hashAlgorithmInMultihashCode);
const dataToBeSigned = {
didSuffix: input.didSuffix,
recoveryKey: input.recoveryPublicKey
};
const compactJws = yield input.signer.sign({ alg: 'ES256K' }, dataToBeSigned);
return {
type: OperationType.Deactivate,
didSuffix: input.didSuffix,
revealValue: revealValue,
signedData: compactJws
};
});
}
static createRecoverRequest(input) {
return __awaiter(this, void 0, void 0, function* () {
// Validate DID suffix
IonRequest.validateDidSuffix(input.didSuffix);
// Validate recovery public key
InputValidator.validateEs256kOperationKey(input.recoveryPublicKey, OperationKeyType.Public);
// Validate next recovery public key
InputValidator.validateEs256kOperationKey(input.nextRecoveryPublicKey, OperationKeyType.Public);
// Validate next update public key
InputValidator.validateEs256kOperationKey(input.nextUpdatePublicKey, OperationKeyType.Public);
// Validate all given DID Document keys.
IonRequest.validateDidDocumentKeys(input.document.publicKeys);
// Validate all given service.
IonRequest.validateServices(input.document.services);
const hashAlgorithmInMultihashCode = IonSdkConfig.hashAlgorithmInMultihashCode;
const revealValue = yield Multihash.canonicalizeThenHashThenEncode(input.recoveryPublicKey, hashAlgorithmInMultihashCode);
const patches = [{
action: PatchAction.Replace,
document: input.document
}];
const nextUpdateCommitmentHash = yield Multihash.canonicalizeThenDoubleHashThenEncode(input.nextUpdatePublicKey, hashAlgorithmInMultihashCode);
const delta = {
patches,
updateCommitment: nextUpdateCommitmentHash
};
const deltaHash = yield Multihash.canonicalizeThenHashThenEncode(delta, hashAlgorithmInMultihashCode);
const nextRecoveryCommitmentHash = yield Multihash.canonicalizeThenDoubleHashThenEncode(input.nextRecoveryPublicKey, hashAlgorithmInMultihashCode);
const dataToBeSigned = {
recoveryCommitment: nextRecoveryCommitmentHash,
recoveryKey: input.recoveryPublicKey,
deltaHash: deltaHash
};
const compactJws = yield input.signer.sign({ alg: 'ES256K' }, dataToBeSigned);
return {
type: OperationType.Recover,
didSuffix: input.didSuffix,
revealValue: revealValue,
delta: delta,
signedData: compactJws
};
});
}
static createUpdateRequest(input) {
return __awaiter(this, void 0, void 0, function* () {
// Validate DID suffix
IonRequest.validateDidSuffix(input.didSuffix);
// Validate update public key
InputValidator.validateEs256kOperationKey(input.updatePublicKey, OperationKeyType.Public);
// Validate next update public key
InputValidator.validateEs256kOperationKey(input.nextUpdatePublicKey, OperationKeyType.Public);
// Validate all given service.
IonRequest.validateServices(input.servicesToAdd);
// Validate all given DID Document keys.
IonRequest.validateDidDocumentKeys(input.publicKeysToAdd);
// Validate all given service id to remove.
if (input.idsOfServicesToRemove !== undefined) {
for (const id of input.idsOfServicesToRemove) {
InputValidator.validateId(id);
}
}
// Validate all given public key id to remove.
if (input.idsOfPublicKeysToRemove !== undefined) {
for (const id of input.idsOfPublicKeysToRemove) {
InputValidator.validateId(id);
}
}
const patches = [];
// Create patches for add services
const servicesToAdd = input.servicesToAdd;
if (servicesToAdd !== undefined && servicesToAdd.length > 0) {
const patch = {
action: PatchAction.AddServices,
services: servicesToAdd
};
patches.push(patch);
}
// Create patches for remove services
const idsOfServicesToRemove = input.idsOfServicesToRemove;
if (idsOfServicesToRemove !== undefined && idsOfServicesToRemove.length > 0) {
const patch = {
action: PatchAction.RemoveServices,
ids: idsOfServicesToRemove
};
patches.push(patch);
}
// Create patches for adding public keys
const publicKeysToAdd = input.publicKeysToAdd;
if (publicKeysToAdd !== undefined && publicKeysToAdd.length > 0) {
const patch = {
action: PatchAction.AddPublicKeys,
publicKeys: publicKeysToAdd
};
patches.push(patch);
}
// Create patch for removing public keys
const idsOfPublicKeysToRemove = input.idsOfPublicKeysToRemove;
if (idsOfPublicKeysToRemove !== undefined && idsOfPublicKeysToRemove.length > 0) {
const patch = {
action: PatchAction.RemovePublicKeys,
ids: idsOfPublicKeysToRemove
};
patches.push(patch);
}
const hashAlgorithmInMultihashCode = IonSdkConfig.hashAlgorithmInMultihashCode;
const revealValue = yield Multihash.canonicalizeThenHashThenEncode(input.updatePublicKey, hashAlgorithmInMultihashCode);
const nextUpdateCommitmentHash = yield Multihash.canonicalizeThenDoubleHashThenEncode(input.nextUpdatePublicKey, hashAlgorithmInMultihashCode);
const delta = {
patches,
updateCommitment: nextUpdateCommitmentHash
};
const deltaHash = yield Multihash.canonicalizeThenHashThenEncode(delta, hashAlgorithmInMultihashCode);
const dataToBeSigned = {
updateKey: input.updatePublicKey,
deltaHash
};
const compactJws = yield input.signer.sign({ alg: 'ES256K' }, dataToBeSigned);
return {
type: OperationType.Update,
didSuffix: input.didSuffix,
revealValue,
delta,
signedData: compactJws
};
});
}
static validateDidSuffix(didSuffix) {
Multihash.validateEncodedHashComputedUsingSupportedHashAlgorithm(didSuffix, 'didSuffix');
}
static validateDidDocumentKeys(publicKeys) {
if (publicKeys === undefined) {
return;
}
// Validate each public key.
const publicKeyIdSet = new Set();
for (const publicKey of publicKeys) {
if (Array.isArray(publicKey.publicKeyJwk)) {
throw new IonError(ErrorCode.DidDocumentPublicKeyMissingOrIncorrectType, `DID Document key 'publicKeyJwk' property is not a non-array object.`);
}
InputValidator.validateId(publicKey.id);
// 'id' must be unique across all given keys.
if (publicKeyIdSet.has(publicKey.id)) {
throw new IonError(ErrorCode.DidDocumentPublicKeyIdDuplicated, `DID Document key with ID '${publicKey.id}' already exists.`);
}
publicKeyIdSet.add(publicKey.id);
InputValidator.validatePublicKeyPurposes(publicKey.purposes);
}
}
static validateServices(services) {
if (services !== undefined && services.length !== 0) {
const serviceIdSet = new Set();
for (const service of services) {
IonRequest.validateService(service);
if (serviceIdSet.has(service.id)) {
throw new IonError(ErrorCode.DidDocumentServiceIdDuplicated, 'Service id has to be unique');
}
serviceIdSet.add(service.id);
}
}
}
static validateService(service) {
InputValidator.validateId(service.id);
const maxTypeLength = 30;
if (service.type.length > maxTypeLength) {
const errorMessage = `Service endpoint type length ${service.type.length} exceeds max allowed length of ${maxTypeLength}.`;
throw new IonError(ErrorCode.ServiceTypeTooLong, errorMessage);
}
// Throw error if `serviceEndpoint` is an array.
if (Array.isArray(service.serviceEndpoint)) {
const errorMessage = 'Service endpoint value cannot be an array.';
throw new IonError(ErrorCode.ServiceEndpointCannotBeAnArray, errorMessage);
}
if (typeof service.serviceEndpoint === 'string') {
const uri = URI.parse(service.serviceEndpoint);
if (uri.error !== undefined) {
throw new IonError(ErrorCode.ServiceEndpointStringNotValidUri, `Service endpoint string '${service.serviceEndpoint}' is not a URI.`);
}
}
}
static validateDeltaSize(delta) {
const deltaBytes = JsonCanonicalizer.canonicalizeAsBytes(delta);
if (deltaBytes.length > IonSdkConfig.maxCanonicalizedDeltaSizeInBytes) {
const errorMessage = `Delta of ${deltaBytes.length} bytes exceeded limit of ${IonSdkConfig.maxCanonicalizedDeltaSizeInBytes} bytes.`;
throw new IonError(ErrorCode.DeltaExceedsMaximumSize, errorMessage);
}
}
}
//# sourceMappingURL=IonRequest.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,19 @@
import IonNetwork from './enums/IonNetwork.js';
/**
* Global configuration of the SDK.
*/
export default class IonSdkConfig {
/**
* Default hash algorithm used when hashing is performed.
*/
static hashAlgorithmInMultihashCode: number;
/**
* Maximum bytes for canonicalized delta.
*/
static maxCanonicalizedDeltaSizeInBytes: number;
/**
* Network name in ION DID, okay to leave as `undefined` if mainnet.
*/
static network: IonNetwork | undefined;
}
//# sourceMappingURL=IonSdkConfig.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonSdkConfig.d.ts","sourceRoot":"","sources":["../../lib/IonSdkConfig.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B;;OAEG;IACH,OAAc,4BAA4B,SAAM;IAEhD;;OAEG;IACH,OAAc,gCAAgC,EAAE,MAAM,CAAQ;IAE9D;;OAEG;IACH,OAAc,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC;CAC/C"}
@@ -0,0 +1,15 @@
/**
* Global configuration of the SDK.
*/
class IonSdkConfig {
}
/**
* Default hash algorithm used when hashing is performed.
*/
IonSdkConfig.hashAlgorithmInMultihashCode = 18; // 0x12 or SHA256
/**
* Maximum bytes for canonicalized delta.
*/
IonSdkConfig.maxCanonicalizedDeltaSizeInBytes = 1000;
export default IonSdkConfig;
//# sourceMappingURL=IonSdkConfig.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonSdkConfig.js","sourceRoot":"","sources":["../../lib/IonSdkConfig.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAqB,YAAY;;AAC/B;;GAEG;AACW,yCAA4B,GAAG,EAAE,CAAC,CAAC,iBAAiB;AAElE;;GAEG;AACW,6CAAgC,GAAW,IAAI,CAAC;eAT3C,YAAY"}
@@ -0,0 +1,14 @@
/**
* Class containing reusable JSON canonicalization operations using JSON Canonicalization Scheme (JCS).
*/
export default class JsonCanonicalizer {
/**
* Canonicalizes the given content as bytes.
*/
static canonicalizeAsBytes(content: object): Uint8Array;
/**
* Removes all properties within the given object with `undefined` as value.
*/
private static removeAllUndefinedProperties;
}
//# sourceMappingURL=JsonCanonicalizer.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"JsonCanonicalizer.d.ts","sourceRoot":"","sources":["../../lib/JsonCanonicalizer.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;WACW,mBAAmB,CAAE,OAAO,EAAE,MAAM,GAAG,UAAU;IAS/D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;CAW5C"}
@@ -0,0 +1,33 @@
import * as canonicalize from 'canonicalize';
import Encoder from './Encoder.js';
/**
* Class containing reusable JSON canonicalization operations using JSON Canonicalization Scheme (JCS).
*/
export default class JsonCanonicalizer {
/**
* Canonicalizes the given content as bytes.
*/
static canonicalizeAsBytes(content) {
// We need to remove all properties with `undefined` as value so that JCS canonicalization will not produce invalid JSON.
const contentWithoutUndefinedProperties = JsonCanonicalizer.removeAllUndefinedProperties(content);
// @ts-expect-error because its a cjs package
const canonicalizedString = canonicalize.default(contentWithoutUndefinedProperties);
const contentBytes = Encoder.stringToBytes(canonicalizedString);
return contentBytes;
}
/**
* Removes all properties within the given object with `undefined` as value.
*/
static removeAllUndefinedProperties(content) {
for (const key in content) {
if (typeof content[key] === 'object') {
JsonCanonicalizer.removeAllUndefinedProperties(content[key]);
}
else if (content[key] === undefined) {
delete content[key];
}
}
return content;
}
}
//# sourceMappingURL=JsonCanonicalizer.js.map
@@ -0,0 +1 @@
{"version":3,"file":"JsonCanonicalizer.js","sourceRoot":"","sources":["../../lib/JsonCanonicalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAAE,OAAe;QAChD,yHAAyH;QACzH,MAAM,iCAAiC,GAAG,iBAAiB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAClG,6CAA6C;QAC7C,MAAM,mBAAmB,GAAW,YAAY,CAAC,OAAO,CAAC,iCAAiC,CAAE,CAAC;QAC7F,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;QAChE,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,4BAA4B,CAAE,OAAY;QACvD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACrC,iBAAiB,CAAC,4BAA4B,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,CAAC;iBAAM,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,15 @@
import ISigner from './interfaces/ISigner.js';
import JwkEs256k from './models/JwkEs256k.js';
/**
* An ISigner implementation that uses a given local private key.
*/
export default class LocalSigner implements ISigner {
private privateKey;
/**
* Creates a new local signer using the given private key.
*/
static create(privateKey: JwkEs256k): ISigner;
private constructor();
sign(header: object, content: object): Promise<string>;
}
//# sourceMappingURL=LocalSigner.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"LocalSigner.d.ts","sourceRoot":"","sources":["../../lib/LocalSigner.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAE9C,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAK9C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,YAAW,OAAO;IAQ5B,OAAO,CAAC,UAAU;IAPvC;;OAEG;WACW,MAAM,CAAE,UAAU,EAAE,SAAS,GAAG,OAAO;IAIrD,OAAO;IAIM,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBrE"}
@@ -0,0 +1,50 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as Secp256k1 from '@noble/secp256k1';
import Encoder from './Encoder.js';
import InputValidator from './InputValidator.js';
import OperationKeyType from './enums/OperationKeyType.js';
import { base64url } from 'multiformats/bases/base64';
import { sha256 } from 'multiformats/hashes/sha2';
/**
* An ISigner implementation that uses a given local private key.
*/
export default class LocalSigner {
/**
* Creates a new local signer using the given private key.
*/
static create(privateKey) {
return new LocalSigner(privateKey);
}
constructor(privateKey) {
this.privateKey = privateKey;
InputValidator.validateEs256kOperationKey(privateKey, OperationKeyType.Private);
}
sign(header, content) {
return __awaiter(this, void 0, void 0, function* () {
const headerString = JSON.stringify(header);
const headerBytes = Encoder.stringToBytes(headerString);
const encodedHeader = base64url.baseEncode(headerBytes);
const payloadString = JSON.stringify(content);
const payloadBytes = Encoder.stringToBytes(payloadString);
const encodedPayload = base64url.baseEncode(payloadBytes);
const signingContentString = `${encodedHeader}.${encodedPayload}`;
const signingContentBytes = Encoder.stringToBytes(signingContentString);
const contentHash = yield sha256.encode(signingContentBytes);
const privateKeyBytes = base64url.baseDecode(this.privateKey.d);
const signature = yield Secp256k1.signAsync(contentHash, privateKeyBytes);
const signatureBytes = signature.toCompactRawBytes();
const encodedSignature = base64url.baseEncode(signatureBytes);
const compactJws = `${encodedHeader}.${encodedPayload}.${encodedSignature}`;
return compactJws;
});
}
}
//# sourceMappingURL=LocalSigner.js.map
@@ -0,0 +1 @@
{"version":3,"file":"LocalSigner.js","sourceRoot":"","sources":["../../lib/LocalSigner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OA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,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAE,CAAC,CAAC;YACjE,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;YAC1E,MAAM,cAAc,GAAG,SAAS,CAAC,iBAAiB,EAAE,CAAC;YAErD,MAAM,gBAAgB,GAAG,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YAE9D,MAAM,UAAU,GAAG,GAAG,aAAa,IAAI,cAAc,IAAI,gBAAgB,EAAE,CAAC;YAC5E,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;CACF"}
@@ -0,0 +1,38 @@
/**
* Class that performs hashing operations using the multihash format.
*/
export default class Multihash {
/**
* Multihashes the content using the hashing algorithm specified.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
* @returns A multihash of the content.
*/
static hash(content: Uint8Array, hashAlgorithmInMultihashCode: number): Promise<Uint8Array>;
/**
* Hashes the content using the hashing algorithm specified as a generic (non-multihash) hash.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
* @returns A multihash bytes.
*/
static hashAsNonMultihashBytes(content: Uint8Array, hashAlgorithmInMultihashCode: number): Promise<Uint8Array>;
/**
* Canonicalize the given content, then double hashes the result using the latest supported hash algorithm, then encodes the multihash.
* Mainly used for testing purposes.
*/
static canonicalizeThenHashThenEncode(content: object, hashAlgorithmInMultihashCode: number): Promise<string>;
/**
* Canonicalize the given content, then double hashes the result using the latest supported hash algorithm, then encodes the multihash.
* Mainly used for testing purposes.
*/
static canonicalizeThenDoubleHashThenEncode(content: object, hashAlgorithmInMultihashCode: number): Promise<string>;
/**
* Hashes the content using the hashing algorithm specified then encodes the multihash bytes as string.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
*/
static hashThenEncode(content: Uint8Array, hashAlgorithmInMultihashCode: number): Promise<string>;
/**
* Checks if the given encoded hash is a multihash computed using the configured hashing algorithm.
*/
static validateEncodedHashComputedUsingSupportedHashAlgorithm(encodedMultihash: string, // didSuffix
inputContextForErrorLogging: string): void;
}
//# sourceMappingURL=Multihash.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"Multihash.d.ts","sourceRoot":"","sources":["../../lib/Multihash.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B;;;;OAIG;WACiB,IAAI,CAAE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAiBzG;;;;OAIG;WACiB,uBAAuB,CAAE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAgB5H;;;OAGG;WACiB,8BAA8B,CAAE,OAAO,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3H;;;OAGG;WACiB,oCAAoC,CAAE,OAAO,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASjI;;;OAGG;WACiB,cAAc,CAAE,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM/G;;OAEG;WACW,sDAAsD,CAClE,gBAAgB,EAAE,MAAM,EAAE,YAAY;IACtC,2BAA2B,EAAE,MAAM;CAsBtC"}
@@ -0,0 +1,113 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import Encoder from './Encoder.js';
import ErrorCode from './ErrorCode.js';
import IonError from './IonError.js';
import IonSdkConfig from './IonSdkConfig.js';
import JsonCanonicalizer from './JsonCanonicalizer.js';
import { decode } from 'multiformats/hashes/digest';
import { sha256 } from 'multiformats/hashes/sha2';
/**
* Class that performs hashing operations using the multihash format.
*/
export default class Multihash {
/**
* Multihashes the content using the hashing algorithm specified.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
* @returns A multihash of the content.
*/
static hash(content, hashAlgorithmInMultihashCode) {
return __awaiter(this, void 0, void 0, function* () {
let multihash;
switch (hashAlgorithmInMultihashCode) {
case 18: // SHA256
let hasher = yield sha256.digest(content);
multihash = hasher.bytes;
break;
default:
throw new IonError(ErrorCode.MultihashUnsupportedHashAlgorithm, `Hash algorithm defined in multihash code ${hashAlgorithmInMultihashCode} is not supported.`);
}
return multihash;
});
}
/**
* Hashes the content using the hashing algorithm specified as a generic (non-multihash) hash.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
* @returns A multihash bytes.
*/
static hashAsNonMultihashBytes(content, hashAlgorithmInMultihashCode) {
return __awaiter(this, void 0, void 0, function* () {
let hash;
switch (hashAlgorithmInMultihashCode) {
case 18: // SHA256
hash = yield sha256.encode(content);
break;
default:
throw new IonError(ErrorCode.MultihashUnsupportedHashAlgorithm, `Hash algorithm defined in multihash code ${hashAlgorithmInMultihashCode} is not supported.`);
}
return hash;
});
}
/**
* Canonicalize the given content, then double hashes the result using the latest supported hash algorithm, then encodes the multihash.
* Mainly used for testing purposes.
*/
static canonicalizeThenHashThenEncode(content, hashAlgorithmInMultihashCode) {
return __awaiter(this, void 0, void 0, function* () {
const canonicalizedStringBytes = JsonCanonicalizer.canonicalizeAsBytes(content);
const multihashEncodedString = yield Multihash.hashThenEncode(canonicalizedStringBytes, hashAlgorithmInMultihashCode);
return multihashEncodedString;
});
}
/**
* Canonicalize the given content, then double hashes the result using the latest supported hash algorithm, then encodes the multihash.
* Mainly used for testing purposes.
*/
static canonicalizeThenDoubleHashThenEncode(content, hashAlgorithmInMultihashCode) {
return __awaiter(this, void 0, void 0, function* () {
const contentBytes = JsonCanonicalizer.canonicalizeAsBytes(content);
// Double hash.
const intermediateHashBytes = yield Multihash.hashAsNonMultihashBytes(contentBytes, hashAlgorithmInMultihashCode);
const multihashEncodedString = yield Multihash.hashThenEncode(intermediateHashBytes, hashAlgorithmInMultihashCode);
return multihashEncodedString;
});
}
/**
* Hashes the content using the hashing algorithm specified then encodes the multihash bytes as string.
* @param hashAlgorithmInMultihashCode The hashing algorithm to use.
*/
static hashThenEncode(content, hashAlgorithmInMultihashCode) {
return __awaiter(this, void 0, void 0, function* () {
const multihashBytes = yield Multihash.hash(content, hashAlgorithmInMultihashCode);
const multihashEncodedString = Encoder.encode(multihashBytes);
return multihashEncodedString;
});
}
/**
* Checks if the given encoded hash is a multihash computed using the configured hashing algorithm.
*/
static validateEncodedHashComputedUsingSupportedHashAlgorithm(encodedMultihash, // didSuffix
inputContextForErrorLogging) {
let multihash;
const multihashBytes = Encoder.decodeAsBytes(encodedMultihash, inputContextForErrorLogging);
try {
multihash = decode(multihashBytes);
}
catch (_a) {
throw new IonError(ErrorCode.MultihashStringNotAMultihash, `Given ${inputContextForErrorLogging} string '${encodedMultihash}' is not a multihash after decoding.`);
}
const hashAlgorithmInMultihashCode = IonSdkConfig.hashAlgorithmInMultihashCode;
if (hashAlgorithmInMultihashCode !== multihash.code) {
throw new IonError(ErrorCode.MultihashUnsupportedHashAlgorithm, `Given ${inputContextForErrorLogging} uses unsupported multihash algorithm with code ${multihash.code}, ` +
`should use ${hashAlgorithmInMultihashCode} or change IonSdkConfig to desired hashing algorithm.`);
}
}
}
//# sourceMappingURL=Multihash.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Multihash.js","sourceRoot":"","sources":["../../lib/Multihash.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OA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S,CAAC,IAAI,EAAE,CAAC;YACpD,MAAM,IAAI,QAAQ,CAChB,SAAS,CAAC,iCAAiC,EAC3C,SAAS,2BAA2B,mDAAmD,SAAS,CAAC,IAAI,IAAI;gBACzG,cAAc,4BAA4B,uDAAuD,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,9 @@
/**
* Supported ION networks.
*/
declare enum IonNetwork {
Mainnet = "mainnet",
Testnet = "test"
}
export default IonNetwork;
//# sourceMappingURL=IonNetwork.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonNetwork.d.ts","sourceRoot":"","sources":["../../../lib/enums/IonNetwork.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,UAAU;IACb,OAAO,YAAY;IACnB,OAAO,SAAS;CACjB;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,10 @@
/**
* Supported ION networks.
*/
var IonNetwork;
(function (IonNetwork) {
IonNetwork["Mainnet"] = "mainnet";
IonNetwork["Testnet"] = "test";
})(IonNetwork || (IonNetwork = {}));
export default IonNetwork;
//# sourceMappingURL=IonNetwork.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonNetwork.js","sourceRoot":"","sources":["../../../lib/enums/IonNetwork.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAK,UAGJ;AAHD,WAAK,UAAU;IACb,iCAAmB,CAAA;IACnB,8BAAgB,CAAA;AAClB,CAAC,EAHI,UAAU,KAAV,UAAU,QAGd;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,12 @@
/**
* DID Document key purpose.
*/
declare enum IonPublicKeyPurpose {
Authentication = "authentication",
AssertionMethod = "assertionMethod",
CapabilityInvocation = "capabilityInvocation",
CapabilityDelegation = "capabilityDelegation",
KeyAgreement = "keyAgreement"
}
export default IonPublicKeyPurpose;
//# sourceMappingURL=IonPublicKeyPurpose.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonPublicKeyPurpose.d.ts","sourceRoot":"","sources":["../../../lib/enums/IonPublicKeyPurpose.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,mBAAmB;IACtB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,YAAY,iBAAiB;CAC9B;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
/**
* DID Document key purpose.
*/
var IonPublicKeyPurpose;
(function (IonPublicKeyPurpose) {
IonPublicKeyPurpose["Authentication"] = "authentication";
IonPublicKeyPurpose["AssertionMethod"] = "assertionMethod";
IonPublicKeyPurpose["CapabilityInvocation"] = "capabilityInvocation";
IonPublicKeyPurpose["CapabilityDelegation"] = "capabilityDelegation";
IonPublicKeyPurpose["KeyAgreement"] = "keyAgreement";
})(IonPublicKeyPurpose || (IonPublicKeyPurpose = {}));
export default IonPublicKeyPurpose;
//# sourceMappingURL=IonPublicKeyPurpose.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonPublicKeyPurpose.js","sourceRoot":"","sources":["../../../lib/enums/IonPublicKeyPurpose.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAK,mBAMJ;AAND,WAAK,mBAAmB;IACtB,wDAAiC,CAAA;IACjC,0DAAmC,CAAA;IACnC,oEAA6C,CAAA;IAC7C,oEAA6C,CAAA;IAC7C,oDAA6B,CAAA;AAC/B,CAAC,EANI,mBAAmB,KAAnB,mBAAmB,QAMvB;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,9 @@
/**
* Operation key type, indicates if a key is a public or private key.
*/
declare enum OperationKeyType {
Public = "public",
Private = "private"
}
export default OperationKeyType;
//# sourceMappingURL=OperationKeyType.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"OperationKeyType.d.ts","sourceRoot":"","sources":["../../../lib/enums/OperationKeyType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,gBAAgB;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAEH,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,10 @@
/**
* Operation key type, indicates if a key is a public or private key.
*/
var OperationKeyType;
(function (OperationKeyType) {
OperationKeyType["Public"] = "public";
OperationKeyType["Private"] = "private";
})(OperationKeyType || (OperationKeyType = {}));
export default OperationKeyType;
//# sourceMappingURL=OperationKeyType.js.map
@@ -0,0 +1 @@
{"version":3,"file":"OperationKeyType.js","sourceRoot":"","sources":["../../../lib/enums/OperationKeyType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAK,gBAGF;AAHH,WAAK,gBAAgB;IACjB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAHE,gBAAgB,KAAhB,gBAAgB,QAGlB;AAEH,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
/**
* ION operation types.
*/
declare enum OperationType {
Create = "create",
Update = "update",
Deactivate = "deactivate",
Recover = "recover"
}
export default OperationType;
//# sourceMappingURL=OperationType.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"OperationType.d.ts","sourceRoot":"","sources":["../../../lib/enums/OperationType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,aAAa;IAChB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,12 @@
/**
* ION operation types.
*/
var OperationType;
(function (OperationType) {
OperationType["Create"] = "create";
OperationType["Update"] = "update";
OperationType["Deactivate"] = "deactivate";
OperationType["Recover"] = "recover";
})(OperationType || (OperationType = {}));
export default OperationType;
//# sourceMappingURL=OperationType.js.map
@@ -0,0 +1 @@
{"version":3,"file":"OperationType.js","sourceRoot":"","sources":["../../../lib/enums/OperationType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAK,aAKJ;AALD,WAAK,aAAa;IAChB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,oCAAmB,CAAA;AACrB,CAAC,EALI,aAAa,KAAb,aAAa,QAKjB;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,12 @@
/**
* Sidetree patch actions. These are the valid values in the action property of a patch.
*/
declare enum PatchAction {
Replace = "replace",
AddPublicKeys = "add-public-keys",
RemovePublicKeys = "remove-public-keys",
AddServices = "add-services",
RemoveServices = "remove-services"
}
export default PatchAction;
//# sourceMappingURL=PatchAction.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"PatchAction.d.ts","sourceRoot":"","sources":["../../../lib/enums/PatchAction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,WAAW;IACZ,OAAO,YAAY;IACnB,aAAa,oBAAoB;IACjC,gBAAgB,uBAAuB;IACvC,WAAW,iBAAiB;IAC5B,cAAc,oBAAoB;CACrC;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,13 @@
/**
* Sidetree patch actions. These are the valid values in the action property of a patch.
*/
var PatchAction;
(function (PatchAction) {
PatchAction["Replace"] = "replace";
PatchAction["AddPublicKeys"] = "add-public-keys";
PatchAction["RemovePublicKeys"] = "remove-public-keys";
PatchAction["AddServices"] = "add-services";
PatchAction["RemoveServices"] = "remove-services";
})(PatchAction || (PatchAction = {}));
export default PatchAction;
//# sourceMappingURL=PatchAction.js.map
@@ -0,0 +1 @@
{"version":3,"file":"PatchAction.js","sourceRoot":"","sources":["../../../lib/enums/PatchAction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,IAAK,WAMJ;AAND,WAAK,WAAW;IACZ,kCAAmB,CAAA;IACnB,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,2CAA4B,CAAA;IAC5B,iDAAkC,CAAA;AACtC,CAAC,EANI,WAAW,KAAX,WAAW,QAMf;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,15 @@
import ISigner from './interfaces/ISigner.js';
import IonDid from './IonDid.js';
import IonDocumentModel from './models/IonDocumentModel.js';
import IonKey from './IonKey.js';
import IonNetwork from './enums/IonNetwork.js';
import IonPublicKeyModel from './models/IonPublicKeyModel.js';
import IonPublicKeyPurpose from './enums/IonPublicKeyPurpose.js';
import IonRequest from './IonRequest.js';
import IonSdkConfig from './IonSdkConfig.js';
import IonServiceModel from './models/IonServiceModel.js';
import JwkEd25519 from './models/JwkEd25519.js';
import JwkEs256k from './models/JwkEs256k.js';
import LocalSigner from './LocalSigner.js';
export { ISigner, IonDid, IonDocumentModel, IonKey, IonNetwork, IonPublicKeyModel, IonPublicKeyPurpose, IonRequest, IonSdkConfig, IonServiceModel, JwkEd25519, JwkEs256k, LocalSigner };
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AACjE,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,UAAU,EACV,SAAS,EACT,WAAW,EACZ,CAAC"}
@@ -0,0 +1,10 @@
// NOTE: Aliases to classes and interfaces are used for external consumption.
import IonDid from './IonDid.js';
import IonKey from './IonKey.js';
import IonNetwork from './enums/IonNetwork.js';
import IonPublicKeyPurpose from './enums/IonPublicKeyPurpose.js';
import IonRequest from './IonRequest.js';
import IonSdkConfig from './IonSdkConfig.js';
import LocalSigner from './LocalSigner.js';
export { IonDid, IonKey, IonNetwork, IonPublicKeyPurpose, IonRequest, IonSdkConfig, LocalSigner };
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAI7E,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AACjE,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAI7C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAEL,MAAM,EAEN,MAAM,EACN,UAAU,EAEV,mBAAmB,EACnB,UAAU,EACV,YAAY,EAIZ,WAAW,EACZ,CAAC"}
@@ -0,0 +1,10 @@
/**
* Interface for signing an arbitrary object.
*/
export default interface ISigner {
/**
* Signs the given content as a compact JWS string.
*/
sign(header: object, content: object): Promise<string>;
}
//# sourceMappingURL=ISigner.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"ISigner.d.ts","sourceRoot":"","sources":["../../../lib/interfaces/ISigner.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,OAAO;IAC9B;;OAEG;IACH,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzD"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ISigner.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ISigner.js","sourceRoot":"","sources":["../../../lib/interfaces/ISigner.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
import IonPublicKeyModel from './IonPublicKeyModel.js';
export default interface IonAddPublicKeysActionModel {
action: string;
publicKeys: IonPublicKeyModel[];
}
//# sourceMappingURL=IonAddPublicKeysActionModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonAddPublicKeysActionModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonAddPublicKeysActionModel.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,OAAO,WAAW,2BAA2B;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,iBAAiB,EAAE,CAAC;CACnC"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IonAddPublicKeysActionModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonAddPublicKeysActionModel.js","sourceRoot":"","sources":["../../../lib/models/IonAddPublicKeysActionModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
import IonServiceModel from './IonServiceModel.js';
export default interface IonAddServicesActionModel {
action: string;
services: IonServiceModel[];
}
//# sourceMappingURL=IonAddServicesActionModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonAddServicesActionModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonAddServicesActionModel.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,WAAW,yBAAyB;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IonAddServicesActionModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonAddServicesActionModel.js","sourceRoot":"","sources":["../../../lib/models/IonAddServicesActionModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
import IonDocumentModel from './IonDocumentModel.js';
import OperationType from '../enums/OperationType.js';
/**
* Data model representing a public key in the DID Document.
*/
export default interface IonCreateRequestModel {
type: OperationType;
suffixData: {
deltaHash: string;
recoveryCommitment: string;
};
delta: {
updateCommitment: string;
patches: {
action: string;
document: IonDocumentModel;
}[];
};
}
//# sourceMappingURL=IonCreateRequestModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonCreateRequestModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonCreateRequestModel.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,qBAAqB;IAC5C,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,KAAK,EAAE;QACL,gBAAgB,EAAE,MAAM,CAAC;QACzB,OAAO,EAAE;YACP,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,gBAAgB,CAAC;SAC5B,EAAE,CAAC;KACL,CAAA;CACF"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IonCreateRequestModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonCreateRequestModel.js","sourceRoot":"","sources":["../../../lib/models/IonCreateRequestModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
import OperationType from '../enums/OperationType.js';
/**
* Data model representing a public key in the DID Document.
*/
export default interface IonDeactivateRequestModel {
type: OperationType;
didSuffix: string;
revealValue: string;
signedData: string;
}
//# sourceMappingURL=IonDeactivateRequestModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonDeactivateRequestModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonDeactivateRequestModel.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,yBAAyB;IAChD,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,3 @@
;
export {};
//# sourceMappingURL=IonDeactivateRequestModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonDeactivateRequestModel.js","sourceRoot":"","sources":["../../../lib/models/IonDeactivateRequestModel.ts"],"names":[],"mappings":"AAUC,CAAC"}
@@ -0,0 +1,10 @@
import IonPublicKeyModel from './IonPublicKeyModel.js';
import IonServiceModel from './IonServiceModel.js';
/**
* Defines the document structure used by ION.
*/
export default interface IonDocumentModel {
publicKeys?: IonPublicKeyModel[];
services?: IonServiceModel[];
}
//# sourceMappingURL=IonDocumentModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonDocumentModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonDocumentModel.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,gBAAgB;IACvC,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IonDocumentModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonDocumentModel.js","sourceRoot":"","sources":["../../../lib/models/IonDocumentModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
import IonPublicKeyPurpose from '../enums/IonPublicKeyPurpose.js';
/**
* Data model representing a public key in the DID Document.
*/
export default interface IonPublicKeyModel {
id: string;
type: string;
publicKeyJwk: object;
purposes?: IonPublicKeyPurpose[];
}
//# sourceMappingURL=IonPublicKeyModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonPublicKeyModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonPublicKeyModel.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,iCAAiC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAClC"}
@@ -0,0 +1,3 @@
;
export {};
//# sourceMappingURL=IonPublicKeyModel.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IonPublicKeyModel.js","sourceRoot":"","sources":["../../../lib/models/IonPublicKeyModel.ts"],"names":[],"mappings":"AAUC,CAAC"}
@@ -0,0 +1,19 @@
import IonDocumentModel from './IonDocumentModel.js';
import OperationType from '../enums/OperationType.js';
/**
* Data model representing a public key in the DID Document.
*/
export default interface IonRecoverRequestModel {
type: OperationType;
didSuffix: string;
revealValue: string;
delta: {
updateCommitment: string;
patches: {
action: string;
document: IonDocumentModel;
}[];
};
signedData: string;
}
//# sourceMappingURL=IonRecoverRequestModel.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"IonRecoverRequestModel.d.ts","sourceRoot":"","sources":["../../../lib/models/IonRecoverRequestModel.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,sBAAsB;IAC7C,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE;QACL,gBAAgB,EAAE,MAAM,CAAC;QACzB,OAAO,EAAE;YACL,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,gBAAgB,CAAC;SAC9B,EAAE,CAAA;KACJ,CAAC;IACF,UAAU,EAAE,MAAM,CAAA;CACnB"}

Some files were not shown because too many files have changed in this diff Show More