@did-btcr2/method 0.16.0 → 0.17.0
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/dist/browser.js +101 -121
- package/dist/browser.mjs +101 -121
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +1 -1
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/cjs/core/crud/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +7 -19
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/did-document.js +61 -13
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js +1 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/esm/core/crud/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +7 -19
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/did-document.js +61 -13
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/crud/update.d.ts +10 -0
- package/dist/types/core/crud/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +14 -4
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +25 -10
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/beacon/aggregation/protocol/nostr.ts +1 -1
- package/src/core/crud/update.ts +12 -0
- package/src/did-btcr2.ts +23 -24
- package/src/index.ts +0 -1
- package/src/utils/did-document.ts +72 -16
- package/dist/cjs/core/crud/create.js +0 -102
- package/dist/cjs/core/crud/create.js.map +0 -1
- package/dist/esm/core/crud/create.js +0 -102
- package/dist/esm/core/crud/create.js.map +0 -1
- package/dist/types/core/crud/create.d.ts +0 -92
- package/dist/types/core/crud/create.d.ts.map +0 -1
- package/src/core/crud/create.ts +0 -160
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,EACV,QAAQ,EAET,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAc,WAAW,IAAI,aAAa,EAAE,qBAAqB,IAAI,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,SAAS,QAAuD,CAAC;AAE9E,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACjD,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IACvD,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IACxD,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IAC7D,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IAC7D,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CAC9B,CAAA;AACD,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IACvD,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IACxD,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IA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AAC,MAAM,CAAC,eAAe;IAI9B;;;;;OAKG;WACW,gCAAgC,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IA6BjF;;;;OAIG;WACW,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB,GAAG,WAAW;IAWvF;;;OAGG;IACI,oBAAoB,IAAI,OAAO;IAyBtC;;;OAGG;IACI,cAAc,IAAI,uBAAuB;CAMjD;AAED;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,WAAW;gBAC1C,QAAQ,EAAE,UAAU;IAIhC;;;;OAIG;IACI,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;IAO9C;;;;OAIG;WACW,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB;IAKhF;;;;;;OAMG;WACW,MAAM,CAClB,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAChD,aAAa,EAAE,yBAAyB,EACxC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAC5B,uBAAuB;IAK1B;;;;OAIG;WACW,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,uBAAuB;IA6B1F;;;;OAIG;WACW,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,uBAAuB;CAGpE;AAED,qBAAa,QAAQ;WACL,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB,GAAG,OAAO;CAGnF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/method",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Javascript/TypeScript reference implementation of did:btcr2 method, a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. Core package of the did-btcr2-js monorepo.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"multiformats": "^13.3.1",
|
|
84
84
|
"nostr-tools": "^2.15.0",
|
|
85
85
|
"tiny-secp256k1": "^2.2.3",
|
|
86
|
-
"@did-btcr2/bitcoin": "0.3.
|
|
86
|
+
"@did-btcr2/bitcoin": "0.3.1",
|
|
87
87
|
"@did-btcr2/common": "2.2.0",
|
|
88
88
|
"@did-btcr2/cryptosuite": "3.2.0",
|
|
89
|
-
"@did-btcr2/keypair": "0.
|
|
89
|
+
"@did-btcr2/keypair": "0.7.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@eslint/js": "^9.22.0",
|
|
@@ -67,7 +67,7 @@ export class NostrAdapter implements ProtocolService {
|
|
|
67
67
|
*/
|
|
68
68
|
public generateIdentity(): string {
|
|
69
69
|
this.config.keys.secret = Secp256k1SecretKey.random();
|
|
70
|
-
this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret);
|
|
70
|
+
this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
|
|
71
71
|
this.config.did = Identifier.encode(
|
|
72
72
|
{
|
|
73
73
|
idType : this.config.components.idType || 'KEY',
|
package/src/core/crud/update.ts
CHANGED
|
@@ -21,6 +21,18 @@ import { DidDocument, DidVerificationMethod } from '../../utils/did-document.js'
|
|
|
21
21
|
import { BeaconFactory } from '../beacon/factory.js';
|
|
22
22
|
import { KeyManager } from '../key-manager/index.js';
|
|
23
23
|
|
|
24
|
+
export interface ConstructUpdateParams {
|
|
25
|
+
identifier: string;
|
|
26
|
+
sourceDocument: DidDocument;
|
|
27
|
+
sourceVersionId: number;
|
|
28
|
+
patch: PatchOperation[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UpdateParams extends ConstructUpdateParams {
|
|
32
|
+
verificationMethodId: string;
|
|
33
|
+
beaconIds: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
export type InvokePayloadParams = {
|
|
25
37
|
identifier: string;
|
|
26
38
|
didUpdatePayload: DidUpdatePayload;
|
package/src/did-btcr2.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
IdentifierTypes,
|
|
4
|
-
INVALID_DID,
|
|
2
|
+
DocumentBytes,
|
|
5
3
|
INVALID_DID_DOCUMENT,
|
|
4
|
+
KeyBytes,
|
|
6
5
|
METHOD_NOT_SUPPORTED,
|
|
6
|
+
MethodError,
|
|
7
7
|
PatchOperation,
|
|
8
8
|
W3C_DID_RESOLUTION_V1
|
|
9
9
|
} from '@did-btcr2/common';
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '@web5/dids';
|
|
18
18
|
import { initEccLib } from 'bitcoinjs-lib';
|
|
19
19
|
import * as tinysecp from 'tiny-secp256k1';
|
|
20
|
-
import { Create, CreateParams, CreateResponse } from './core/crud/create.js';
|
|
21
20
|
import { Resolve } from './core/crud/read.js';
|
|
22
21
|
import { Update } from './core/crud/update.js';
|
|
23
22
|
import { DidResolutionOptions } from './interfaces/crud.js';
|
|
@@ -25,6 +24,15 @@ import { Appendix } from './utils/appendix.js';
|
|
|
25
24
|
import { DidDocument, DidVerificationMethod } from './utils/did-document.js';
|
|
26
25
|
import { Identifier } from './utils/identifier.js';
|
|
27
26
|
|
|
27
|
+
export type Btcr2Identifier = string;
|
|
28
|
+
|
|
29
|
+
export interface DidCreateOptions {
|
|
30
|
+
/** DID BTCR2 Version Number */
|
|
31
|
+
version?: number;
|
|
32
|
+
/** Bitcoin Network */
|
|
33
|
+
network?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
/** Initialize tiny secp256k1 */
|
|
29
37
|
initEccLib(tinysecp);
|
|
30
38
|
|
|
@@ -37,7 +45,7 @@ initEccLib(tinysecp);
|
|
|
37
45
|
*
|
|
38
46
|
* @class DidBtcr2
|
|
39
47
|
* @type {DidBtcr2}
|
|
40
|
-
*
|
|
48
|
+
* @implements {DidMethod}
|
|
41
49
|
*/
|
|
42
50
|
export class DidBtcr2 implements DidMethod {
|
|
43
51
|
/** @type {string} Name of the DID method, as defined in the DID BTCR2 specification */
|
|
@@ -61,30 +69,21 @@ export class DidBtcr2 implements DidMethod {
|
|
|
61
69
|
* @returns {Promise<CreateResponse>} Promise resolving to a CreateResponse object.
|
|
62
70
|
* @throws {DidBtcr2Error} if any of the checks fail
|
|
63
71
|
*/
|
|
64
|
-
public static async create(params:
|
|
72
|
+
public static async create(params: {
|
|
73
|
+
idType: 'KEY' | 'EXTERNAL';
|
|
74
|
+
genesisBytes: KeyBytes | DocumentBytes;
|
|
75
|
+
options?: DidCreateOptions;
|
|
76
|
+
}): Promise<Btcr2Identifier> {
|
|
65
77
|
// Deconstruct the idType and options from the params
|
|
66
78
|
const { idType, options = {} } = params;
|
|
67
79
|
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
// Deconstruct the pubKeyBytes from the params
|
|
71
|
-
const { pubKeyBytes } = params;
|
|
80
|
+
// Deconstruct the version and network from the options, setting defaults if not given
|
|
81
|
+
const { version = 1, network = 'bitcoin' } = options;
|
|
72
82
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// If idType is external, call Create.external
|
|
78
|
-
if(idType === IdentifierTypes.EXTERNAL) {
|
|
79
|
-
// Deconstruct the intermediateDocument from the params
|
|
80
|
-
const { intermediateDocument } = params;
|
|
81
|
-
|
|
82
|
-
// Return call to Create.external
|
|
83
|
-
return await Create.external({ intermediateDocument, options });
|
|
84
|
-
}
|
|
83
|
+
// Set the genesisBytes from the params
|
|
84
|
+
const genesisBytes = params.genesisBytes;
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
throw new MethodError('Invalid idType: expected "KEY" or "EXTERNAL"', INVALID_DID, params);
|
|
86
|
+
return Identifier.encode({ idType, genesisBytes, version, network });
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
/**
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './core/beacon/factory.js';
|
|
|
3
3
|
export * from './core/beacon/singleton.js';
|
|
4
4
|
export * from './core/beacon/smt-aggregate.js';
|
|
5
5
|
|
|
6
|
-
export * from './core/crud/create.js';
|
|
7
6
|
export * from './core/crud/deactivate.js';
|
|
8
7
|
export * from './core/crud/read.js';
|
|
9
8
|
export * from './core/crud/update.js';
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
1
2
|
import {
|
|
2
3
|
BTCR2_DID_DOCUMENT_CONTEXT,
|
|
3
|
-
IdentifierTypes,
|
|
4
4
|
DidDocumentError,
|
|
5
5
|
ID_PLACEHOLDER_VALUE,
|
|
6
|
+
IdentifierTypes,
|
|
6
7
|
INVALID_DID_DOCUMENT,
|
|
7
8
|
JSONObject,
|
|
9
|
+
KeyBytes,
|
|
8
10
|
Logger
|
|
9
11
|
} from '@did-btcr2/common';
|
|
10
|
-
import {
|
|
12
|
+
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
13
|
+
import { DidService, DidDocument as IIDidDocument, DidVerificationMethod as IIDidVerificationMethod } from '@web5/dids';
|
|
11
14
|
import { BeaconService } from '../interfaces/ibeacon.js';
|
|
12
15
|
import { Appendix } from './appendix.js';
|
|
13
16
|
import { BeaconUtils } from './beacons.js';
|
|
@@ -120,6 +123,7 @@ export class DidDocument implements IDidDocument {
|
|
|
120
123
|
service: Array<BeaconService>;
|
|
121
124
|
|
|
122
125
|
constructor(document: IDidDocument) {
|
|
126
|
+
console.log('Constructing DidDocument with document:', document);
|
|
123
127
|
// Set the ID and ID type
|
|
124
128
|
const idType = document.id.includes('k1')
|
|
125
129
|
? IdentifierTypes.KEY
|
|
@@ -388,7 +392,7 @@ export class DidDocument implements IDidDocument {
|
|
|
388
392
|
* Validate the IntermediateDidDocument.
|
|
389
393
|
* @returns {boolean} True if the IntermediateDidDocument is valid.
|
|
390
394
|
*/
|
|
391
|
-
public validateIntermediate():
|
|
395
|
+
public validateIntermediate(): boolean {
|
|
392
396
|
// Validate the id
|
|
393
397
|
if(this.id !== ID_PLACEHOLDER_VALUE) {
|
|
394
398
|
throw new DidDocumentError('Invalid IntermediateDidDocument ID', INVALID_DID_DOCUMENT, this);
|
|
@@ -409,6 +413,8 @@ export class DidDocument implements IDidDocument {
|
|
|
409
413
|
// Return true if all validations pass
|
|
410
414
|
throw new DidDocumentError('Invalid IntermediateDidDocument assertionMethod', INVALID_DID_DOCUMENT, this);
|
|
411
415
|
}
|
|
416
|
+
|
|
417
|
+
return true;
|
|
412
418
|
}
|
|
413
419
|
|
|
414
420
|
/**
|
|
@@ -431,9 +437,30 @@ export class DidDocument implements IDidDocument {
|
|
|
431
437
|
* @extends {DidDocument}
|
|
432
438
|
*/
|
|
433
439
|
export class IntermediateDidDocument extends DidDocument {
|
|
434
|
-
constructor(document:
|
|
435
|
-
|
|
436
|
-
|
|
440
|
+
constructor(document: JSONObject) {
|
|
441
|
+
super(document as IDidDocument);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Convert the IntermediateDidDocument to a DidDocument by replacing the placeholder value with the provided DID.
|
|
446
|
+
* @param did The DID to replace the placeholder value in the document.
|
|
447
|
+
* @returns {DidDocument} A new DidDocument with the placeholder value replaced by the provided DID.
|
|
448
|
+
*/
|
|
449
|
+
public toDidDocument(did: string): DidDocument {
|
|
450
|
+
const stringThis = JSON.stringify(this).replaceAll(ID_PLACEHOLDER_VALUE, did);
|
|
451
|
+
const parseThis = JSON.parse(stringThis) as IDidDocument;
|
|
452
|
+
return new DidDocument(parseThis);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Create an IntermediateDidDocument from a DidDocument by replacing the DID with a placeholder value.
|
|
458
|
+
* @param {DidDocument} didDocument The DidDocument to convert.
|
|
459
|
+
* @returns {IntermediateDidDocument} The IntermediateDidDocument representation of the DidDocument.
|
|
460
|
+
*/
|
|
461
|
+
public static fromDidDocument(didDocument: DidDocument): IntermediateDidDocument {
|
|
462
|
+
const intermediateDocument = JSON.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE) as IDidDocument;
|
|
463
|
+
return new IntermediateDidDocument(intermediateDocument);
|
|
437
464
|
}
|
|
438
465
|
|
|
439
466
|
/**
|
|
@@ -453,22 +480,51 @@ export class IntermediateDidDocument extends DidDocument {
|
|
|
453
480
|
}
|
|
454
481
|
|
|
455
482
|
/**
|
|
456
|
-
*
|
|
457
|
-
* @param
|
|
458
|
-
* @returns {
|
|
483
|
+
* Create a minimal IntermediateDidDocument from a public key.
|
|
484
|
+
* @param {KeyBytes} publicKey The public key in bytes format.
|
|
485
|
+
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
459
486
|
*/
|
|
460
|
-
public
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
|
|
487
|
+
public static fromPublicKey(publicKey: KeyBytes, network: string): IntermediateDidDocument {
|
|
488
|
+
const pk = new CompressedSecp256k1PublicKey(publicKey);
|
|
489
|
+
const id = ID_PLACEHOLDER_VALUE;
|
|
490
|
+
const service = BeaconUtils.generateBeaconService({
|
|
491
|
+
id : `${id}#key-0`,
|
|
492
|
+
publicKey : pk.compressed,
|
|
493
|
+
network : getNetwork(network),
|
|
494
|
+
addressType : 'p2pkh',
|
|
495
|
+
type : 'SingletonBeacon',
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
const relationships = {
|
|
499
|
+
authentication : [`${id}#key-0`],
|
|
500
|
+
assertionMethod : [`${id}#key-0`],
|
|
501
|
+
capabilityInvocation : [`${id}#key-0`],
|
|
502
|
+
capabilityDelegation : [`${id}#key-0`]
|
|
503
|
+
};
|
|
504
|
+
const verificationMethod = [
|
|
505
|
+
{
|
|
506
|
+
id : `${id}#key-0`,
|
|
507
|
+
type : 'Multikey',
|
|
508
|
+
controller : id,
|
|
509
|
+
publicKeyMultibase : pk.multibase.encoded,
|
|
510
|
+
}
|
|
511
|
+
];
|
|
512
|
+
|
|
513
|
+
return IntermediateDidDocument.create(verificationMethod, relationships, [service]);
|
|
464
514
|
}
|
|
465
515
|
|
|
466
516
|
/**
|
|
467
|
-
*
|
|
517
|
+
* Taken an object, convert it to an IntermediateDocuemnt and then to a DidDocument.
|
|
468
518
|
* @param {JSONObject} object The JSON object to convert.
|
|
469
519
|
* @returns {DidDocument} The created DidDocument.
|
|
470
520
|
*/
|
|
471
|
-
public static
|
|
472
|
-
return new IntermediateDidDocument(object as IDidDocument)
|
|
521
|
+
public static fromJSON(object: JSONObject): IntermediateDidDocument {
|
|
522
|
+
return new IntermediateDidDocument(object as IDidDocument);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export class Document {
|
|
527
|
+
public static isValid(didDocument: DidDocument | IntermediateDidDocument): boolean {
|
|
528
|
+
return new DidDocument(didDocument).validateIntermediate();
|
|
473
529
|
}
|
|
474
530
|
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { IdentifierTypes } from '@did-btcr2/common';
|
|
2
|
-
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
3
|
-
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
4
|
-
import { BeaconUtils } from '../../utils/beacons.js';
|
|
5
|
-
import { DidDocument } from '../../utils/did-document.js';
|
|
6
|
-
import { Identifier } from '../../utils/identifier.js';
|
|
7
|
-
/**
|
|
8
|
-
* Implements section {@link https://dcdpr.github.io/did-btcr2/#create | 4.1 Create}.
|
|
9
|
-
*
|
|
10
|
-
* A did:btcr2 identifier and associated DID document can either be created deterministically from a cryptographic seed,
|
|
11
|
-
* or it can be created from an arbitrary genesis intermediate DID document representation. In both cases, DID creation
|
|
12
|
-
* can be undertaken in an offline manner, i.e., the DID controller does not need to interact with the Bitcoin network
|
|
13
|
-
* to create their DID.
|
|
14
|
-
*
|
|
15
|
-
* @class Create
|
|
16
|
-
* @type {Create}
|
|
17
|
-
*/
|
|
18
|
-
export class Create {
|
|
19
|
-
/**
|
|
20
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#deterministic-key-based-creation | 4.1.1 Deterministic Key-Based Creation}.
|
|
21
|
-
*
|
|
22
|
-
* For deterministic key-based creation, the did:btcr2 identifier encodes a secp256k1 public key. The key is then used
|
|
23
|
-
* to deterministically generate the initial DID document.
|
|
24
|
-
*
|
|
25
|
-
* @param {CreateKeyParams} params See {@link CreateKeyParams} for details.
|
|
26
|
-
* @param {number} params.version did-btcr2 identifier version.
|
|
27
|
-
* @param {string} params.network did-btcr2 bitcoin network.
|
|
28
|
-
* @param {KeyBytes} params.pubKeyBytes public key bytes for id creation.
|
|
29
|
-
* @returns {CreateResponse} A response object of type {@link CreateResponse}.
|
|
30
|
-
* @throws {DidError} if the public key is missing or invalid.
|
|
31
|
-
*/
|
|
32
|
-
static deterministic({ pubKeyBytes, options }) {
|
|
33
|
-
// Deconstruct options and set the default values
|
|
34
|
-
const { version = 1, network = 'bitcoin' } = options;
|
|
35
|
-
// Set idType to "KEY"
|
|
36
|
-
const idType = IdentifierTypes.KEY;
|
|
37
|
-
// Call the the did:btcr2 Identifier Encoding algorithm
|
|
38
|
-
const identifier = Identifier.encode({ version, network, idType, genesisBytes: pubKeyBytes });
|
|
39
|
-
// Instantiate CompressedSecp256k1PublicKey object and get the multibase formatted publicKey
|
|
40
|
-
const { compressed: publicKey, multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(pubKeyBytes);
|
|
41
|
-
// Generate the service field for the DID Document
|
|
42
|
-
const service = BeaconUtils.generateBeaconServices({
|
|
43
|
-
identifier,
|
|
44
|
-
publicKey,
|
|
45
|
-
network: getNetwork(network),
|
|
46
|
-
type: 'SingletonBeacon',
|
|
47
|
-
});
|
|
48
|
-
// Create initialDocument ensuring conformant to spec as DidDocument
|
|
49
|
-
const initialDocument = new DidDocument({
|
|
50
|
-
id: identifier,
|
|
51
|
-
controller: [identifier],
|
|
52
|
-
verificationMethod: [{
|
|
53
|
-
id: `${identifier}#initialKey`,
|
|
54
|
-
type: 'Multikey',
|
|
55
|
-
controller: identifier,
|
|
56
|
-
publicKeyMultibase: publicKeyMultibase.encoded,
|
|
57
|
-
}],
|
|
58
|
-
service,
|
|
59
|
-
});
|
|
60
|
-
// Return did & initialDocument
|
|
61
|
-
return { did: identifier, initialDocument };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#external-initial-document-creation | 4.1.2 External Initial Document Creation}.
|
|
65
|
-
*
|
|
66
|
-
* Creates a did:btcr2 identifier from some initiating arbitrary DID document. This allows for more complex
|
|
67
|
-
* initial DID documents, including the ability to include Service Endpoints and Beacons that support aggregation.
|
|
68
|
-
* Inputs include `intermediateDocument`, optional version and network returning initialDidDocument. The
|
|
69
|
-
* intermediateDocument should be a valid DID document except all places where the DID document requires the use of
|
|
70
|
-
* the identifier (e.g. the id field). These fields should use placeholder value
|
|
71
|
-
* `did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. The intermediateDocument should include at
|
|
72
|
-
* least one verificationMethod and service of the type SingletonBeacon.
|
|
73
|
-
*
|
|
74
|
-
* @param {CreateExternalParams} params See {@link CreateExternalParams} for details.
|
|
75
|
-
* @param {number} params.version Identifier version.
|
|
76
|
-
* @param {string} params.network Identifier network name.
|
|
77
|
-
* @param {string} params.documentBytes Intermediate DID Document bytes.
|
|
78
|
-
* @returns {CreateResponse} A Promise resolving to {@link CreateResponses}.
|
|
79
|
-
* @throws {DidError} if the verificationMethod or service objects are missing required properties
|
|
80
|
-
*/
|
|
81
|
-
static async external({ intermediateDocument, options }) {
|
|
82
|
-
// 1. Set idType to "EXTERNAL"
|
|
83
|
-
const idType = IdentifierTypes.EXTERNAL;
|
|
84
|
-
// 2. Set version to 1
|
|
85
|
-
// 3. Set network to the desired network.
|
|
86
|
-
const { version = 1, network = 'bitcoin' } = options;
|
|
87
|
-
// Validate intermediateDocument
|
|
88
|
-
intermediateDocument.validateIntermediate();
|
|
89
|
-
// 4. Set genesisBytes to the result of passing intermediateDocument into the JSON Canonicalization and Hash
|
|
90
|
-
// algorithm.
|
|
91
|
-
const genesisBytes = await JSON.canonicalization.canonicalhash(intermediateDocument);
|
|
92
|
-
// 5. Pass idType, version, network, and genesisBytes to the did:btcr2 Identifier Encoding algorithm, retrieving id.
|
|
93
|
-
// 6. Set did to id
|
|
94
|
-
const did = Identifier.encode({ idType, genesisBytes, version, network });
|
|
95
|
-
// 7. Set initialDocument to a copy of the intermediateDocument.
|
|
96
|
-
// 8. Replace all did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx values in the initialDocument with the did.
|
|
97
|
-
const initialDocument = intermediateDocument.toDidDocument(did);
|
|
98
|
-
// Return DID & DID Document.
|
|
99
|
-
return { did, initialDocument };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/core/crud/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA4B,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAO,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAA2B,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAwCvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,MAAM;IACjB;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,OAAO,EAGjD;QACC,iDAAiD;QACjD,MAAM,EAAE,OAAO,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AAG,SAAS,EAAE,GAAG,OAAO,CAAC;QAErD,gCAAgC;QAChC,oBAAoB,CAAC,oBAAoB,EAAE,CAAC;QAE5C,4GAA4G;QAC5G,gBAAgB;QAChB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;QAErF,oHAAoH;QACpH,mBAAmB;QACnB,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAE1E,gEAAgE;QAChE,oIAAoI;QACpI,MAAM,eAAe,GAAG,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAEhE,6BAA6B;QAC7B,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { IdentifierTypes } from '@did-btcr2/common';
|
|
2
|
-
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
3
|
-
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
4
|
-
import { BeaconUtils } from '../../utils/beacons.js';
|
|
5
|
-
import { DidDocument } from '../../utils/did-document.js';
|
|
6
|
-
import { Identifier } from '../../utils/identifier.js';
|
|
7
|
-
/**
|
|
8
|
-
* Implements section {@link https://dcdpr.github.io/did-btcr2/#create | 4.1 Create}.
|
|
9
|
-
*
|
|
10
|
-
* A did:btcr2 identifier and associated DID document can either be created deterministically from a cryptographic seed,
|
|
11
|
-
* or it can be created from an arbitrary genesis intermediate DID document representation. In both cases, DID creation
|
|
12
|
-
* can be undertaken in an offline manner, i.e., the DID controller does not need to interact with the Bitcoin network
|
|
13
|
-
* to create their DID.
|
|
14
|
-
*
|
|
15
|
-
* @class Create
|
|
16
|
-
* @type {Create}
|
|
17
|
-
*/
|
|
18
|
-
export class Create {
|
|
19
|
-
/**
|
|
20
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#deterministic-key-based-creation | 4.1.1 Deterministic Key-Based Creation}.
|
|
21
|
-
*
|
|
22
|
-
* For deterministic key-based creation, the did:btcr2 identifier encodes a secp256k1 public key. The key is then used
|
|
23
|
-
* to deterministically generate the initial DID document.
|
|
24
|
-
*
|
|
25
|
-
* @param {CreateKeyParams} params See {@link CreateKeyParams} for details.
|
|
26
|
-
* @param {number} params.version did-btcr2 identifier version.
|
|
27
|
-
* @param {string} params.network did-btcr2 bitcoin network.
|
|
28
|
-
* @param {KeyBytes} params.pubKeyBytes public key bytes for id creation.
|
|
29
|
-
* @returns {CreateResponse} A response object of type {@link CreateResponse}.
|
|
30
|
-
* @throws {DidError} if the public key is missing or invalid.
|
|
31
|
-
*/
|
|
32
|
-
static deterministic({ pubKeyBytes, options }) {
|
|
33
|
-
// Deconstruct options and set the default values
|
|
34
|
-
const { version = 1, network = 'bitcoin' } = options;
|
|
35
|
-
// Set idType to "KEY"
|
|
36
|
-
const idType = IdentifierTypes.KEY;
|
|
37
|
-
// Call the the did:btcr2 Identifier Encoding algorithm
|
|
38
|
-
const identifier = Identifier.encode({ version, network, idType, genesisBytes: pubKeyBytes });
|
|
39
|
-
// Instantiate CompressedSecp256k1PublicKey object and get the multibase formatted publicKey
|
|
40
|
-
const { compressed: publicKey, multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(pubKeyBytes);
|
|
41
|
-
// Generate the service field for the DID Document
|
|
42
|
-
const service = BeaconUtils.generateBeaconServices({
|
|
43
|
-
identifier,
|
|
44
|
-
publicKey,
|
|
45
|
-
network: getNetwork(network),
|
|
46
|
-
type: 'SingletonBeacon',
|
|
47
|
-
});
|
|
48
|
-
// Create initialDocument ensuring conformant to spec as DidDocument
|
|
49
|
-
const initialDocument = new DidDocument({
|
|
50
|
-
id: identifier,
|
|
51
|
-
controller: [identifier],
|
|
52
|
-
verificationMethod: [{
|
|
53
|
-
id: `${identifier}#initialKey`,
|
|
54
|
-
type: 'Multikey',
|
|
55
|
-
controller: identifier,
|
|
56
|
-
publicKeyMultibase: publicKeyMultibase.encoded,
|
|
57
|
-
}],
|
|
58
|
-
service,
|
|
59
|
-
});
|
|
60
|
-
// Return did & initialDocument
|
|
61
|
-
return { did: identifier, initialDocument };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#external-initial-document-creation | 4.1.2 External Initial Document Creation}.
|
|
65
|
-
*
|
|
66
|
-
* Creates a did:btcr2 identifier from some initiating arbitrary DID document. This allows for more complex
|
|
67
|
-
* initial DID documents, including the ability to include Service Endpoints and Beacons that support aggregation.
|
|
68
|
-
* Inputs include `intermediateDocument`, optional version and network returning initialDidDocument. The
|
|
69
|
-
* intermediateDocument should be a valid DID document except all places where the DID document requires the use of
|
|
70
|
-
* the identifier (e.g. the id field). These fields should use placeholder value
|
|
71
|
-
* `did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. The intermediateDocument should include at
|
|
72
|
-
* least one verificationMethod and service of the type SingletonBeacon.
|
|
73
|
-
*
|
|
74
|
-
* @param {CreateExternalParams} params See {@link CreateExternalParams} for details.
|
|
75
|
-
* @param {number} params.version Identifier version.
|
|
76
|
-
* @param {string} params.network Identifier network name.
|
|
77
|
-
* @param {string} params.documentBytes Intermediate DID Document bytes.
|
|
78
|
-
* @returns {CreateResponse} A Promise resolving to {@link CreateResponses}.
|
|
79
|
-
* @throws {DidError} if the verificationMethod or service objects are missing required properties
|
|
80
|
-
*/
|
|
81
|
-
static async external({ intermediateDocument, options }) {
|
|
82
|
-
// 1. Set idType to "EXTERNAL"
|
|
83
|
-
const idType = IdentifierTypes.EXTERNAL;
|
|
84
|
-
// 2. Set version to 1
|
|
85
|
-
// 3. Set network to the desired network.
|
|
86
|
-
const { version = 1, network = 'bitcoin' } = options;
|
|
87
|
-
// Validate intermediateDocument
|
|
88
|
-
intermediateDocument.validateIntermediate();
|
|
89
|
-
// 4. Set genesisBytes to the result of passing intermediateDocument into the JSON Canonicalization and Hash
|
|
90
|
-
// algorithm.
|
|
91
|
-
const genesisBytes = await JSON.canonicalization.canonicalhash(intermediateDocument);
|
|
92
|
-
// 5. Pass idType, version, network, and genesisBytes to the did:btcr2 Identifier Encoding algorithm, retrieving id.
|
|
93
|
-
// 6. Set did to id
|
|
94
|
-
const did = Identifier.encode({ idType, genesisBytes, version, network });
|
|
95
|
-
// 7. Set initialDocument to a copy of the intermediateDocument.
|
|
96
|
-
// 8. Replace all did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx values in the initialDocument with the did.
|
|
97
|
-
const initialDocument = intermediateDocument.toDidDocument(did);
|
|
98
|
-
// Return DID & DID Document.
|
|
99
|
-
return { did, initialDocument };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/core/crud/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA4B,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAO,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAA2B,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAwCvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,MAAM;IACjB;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,OAAO,EAGjD;QACC,iDAAiD;QACjD,MAAM,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC;Q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B,CAAC,oBAAoB,EAAE,CAAC;QAE5C,4GAA4G;QAC5G,gBAAgB;QAChB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;QAErF,oHAAoH;QACpH,mBAAmB;QACnB,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAE1E,gEAAgE;QAChE,oIAAoI;QACpI,MAAM,eAAe,GAAG,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAEhE,6BAA6B;QAC7B,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { KeyBytes, PatchOperation } from '@did-btcr2/common';
|
|
2
|
-
import { DidCreateOptions as IDidCreateOptions } from '@web5/dids';
|
|
3
|
-
import { DidDocument, IntermediateDidDocument } from '../../utils/did-document.js';
|
|
4
|
-
import { KeyManager } from '../key-manager/index.js';
|
|
5
|
-
export type CreateParams = CreateKeyParams | CreateExternalParams;
|
|
6
|
-
export interface CreateIdentifierParams {
|
|
7
|
-
genesisBytes: Uint8Array;
|
|
8
|
-
newtork?: string;
|
|
9
|
-
version?: string;
|
|
10
|
-
}
|
|
11
|
-
export type CreateResponse = {
|
|
12
|
-
did: string;
|
|
13
|
-
initialDocument: DidDocument;
|
|
14
|
-
};
|
|
15
|
-
export interface ConstructUpdateParams {
|
|
16
|
-
identifier: string;
|
|
17
|
-
sourceDocument: DidDocument;
|
|
18
|
-
sourceVersionId: number;
|
|
19
|
-
patch: PatchOperation[];
|
|
20
|
-
}
|
|
21
|
-
export interface UpdateParams extends ConstructUpdateParams {
|
|
22
|
-
verificationMethodId: string;
|
|
23
|
-
beaconIds: string[];
|
|
24
|
-
}
|
|
25
|
-
export interface DidCreateOptions extends IDidCreateOptions<KeyManager> {
|
|
26
|
-
/** DID BTCR2 Version Number */
|
|
27
|
-
version?: number;
|
|
28
|
-
/** Bitcoin Network */
|
|
29
|
-
network?: string;
|
|
30
|
-
}
|
|
31
|
-
export type CreateKeyParams = {
|
|
32
|
-
idType: 'KEY';
|
|
33
|
-
pubKeyBytes: KeyBytes;
|
|
34
|
-
options?: DidCreateOptions;
|
|
35
|
-
};
|
|
36
|
-
export type CreateExternalParams = {
|
|
37
|
-
idType: 'EXTERNAL';
|
|
38
|
-
intermediateDocument: IntermediateDidDocument;
|
|
39
|
-
options?: DidCreateOptions;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Implements section {@link https://dcdpr.github.io/did-btcr2/#create | 4.1 Create}.
|
|
43
|
-
*
|
|
44
|
-
* A did:btcr2 identifier and associated DID document can either be created deterministically from a cryptographic seed,
|
|
45
|
-
* or it can be created from an arbitrary genesis intermediate DID document representation. In both cases, DID creation
|
|
46
|
-
* can be undertaken in an offline manner, i.e., the DID controller does not need to interact with the Bitcoin network
|
|
47
|
-
* to create their DID.
|
|
48
|
-
*
|
|
49
|
-
* @class Create
|
|
50
|
-
* @type {Create}
|
|
51
|
-
*/
|
|
52
|
-
export declare class Create {
|
|
53
|
-
/**
|
|
54
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#deterministic-key-based-creation | 4.1.1 Deterministic Key-Based Creation}.
|
|
55
|
-
*
|
|
56
|
-
* For deterministic key-based creation, the did:btcr2 identifier encodes a secp256k1 public key. The key is then used
|
|
57
|
-
* to deterministically generate the initial DID document.
|
|
58
|
-
*
|
|
59
|
-
* @param {CreateKeyParams} params See {@link CreateKeyParams} for details.
|
|
60
|
-
* @param {number} params.version did-btcr2 identifier version.
|
|
61
|
-
* @param {string} params.network did-btcr2 bitcoin network.
|
|
62
|
-
* @param {KeyBytes} params.pubKeyBytes public key bytes for id creation.
|
|
63
|
-
* @returns {CreateResponse} A response object of type {@link CreateResponse}.
|
|
64
|
-
* @throws {DidError} if the public key is missing or invalid.
|
|
65
|
-
*/
|
|
66
|
-
static deterministic({ pubKeyBytes, options }: {
|
|
67
|
-
pubKeyBytes: KeyBytes;
|
|
68
|
-
options: DidCreateOptions;
|
|
69
|
-
}): CreateResponse;
|
|
70
|
-
/**
|
|
71
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/#external-initial-document-creation | 4.1.2 External Initial Document Creation}.
|
|
72
|
-
*
|
|
73
|
-
* Creates a did:btcr2 identifier from some initiating arbitrary DID document. This allows for more complex
|
|
74
|
-
* initial DID documents, including the ability to include Service Endpoints and Beacons that support aggregation.
|
|
75
|
-
* Inputs include `intermediateDocument`, optional version and network returning initialDidDocument. The
|
|
76
|
-
* intermediateDocument should be a valid DID document except all places where the DID document requires the use of
|
|
77
|
-
* the identifier (e.g. the id field). These fields should use placeholder value
|
|
78
|
-
* `did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. The intermediateDocument should include at
|
|
79
|
-
* least one verificationMethod and service of the type SingletonBeacon.
|
|
80
|
-
*
|
|
81
|
-
* @param {CreateExternalParams} params See {@link CreateExternalParams} for details.
|
|
82
|
-
* @param {number} params.version Identifier version.
|
|
83
|
-
* @param {string} params.network Identifier network name.
|
|
84
|
-
* @param {string} params.documentBytes Intermediate DID Document bytes.
|
|
85
|
-
* @returns {CreateResponse} A Promise resolving to {@link CreateResponses}.
|
|
86
|
-
* @throws {DidError} if the verificationMethod or service objects are missing required properties
|
|
87
|
-
*/
|
|
88
|
-
static external({ intermediateDocument, options }: {
|
|
89
|
-
intermediateDocument: IntermediateDidDocument;
|
|
90
|
-
options: DidCreateOptions;
|
|
91
|
-
}): Promise<CreateResponse>;
|
|
92
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/core/crud/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,cAAc,EAAE,MAAM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