@twin.org/immutable-proof-rest-client 0.0.2-next.2 → 0.0.3-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,29 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { Guards, NotSupportedError } from '@twin.org/core';
3
- import { HeaderTypes, MimeTypes } from '@twin.org/web';
4
-
5
1
  // Copyright 2024 IOTA Stiftung.
6
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { Guards, NotSupportedError } from "@twin.org/core";
5
+ import { HeaderTypes, MimeTypes } from "@twin.org/web";
7
6
  /**
8
7
  * Client for performing immutable proof through to REST endpoints.
9
8
  */
10
- class ImmutableProofClient extends BaseRestClient {
9
+ export class ImmutableProofRestClient extends BaseRestClient {
11
10
  /**
12
11
  * Runtime name for the class.
13
12
  */
14
- CLASS_NAME = "ImmutableProofClient";
13
+ static CLASS_NAME = "ImmutableProofRestClient";
15
14
  /**
16
- * Create a new instance of ImmutableProofClient.
15
+ * Create a new instance of ImmutableProofRestClient.
17
16
  * @param config The configuration for the client.
18
17
  */
19
18
  constructor(config) {
20
- super("ImmutableProofClient", config, "immutable-proof");
19
+ super("ImmutableProofRestClient", config, "immutable-proof");
20
+ }
21
+ /**
22
+ * Returns the class name of the component.
23
+ * @returns The class name of the component.
24
+ */
25
+ className() {
26
+ return ImmutableProofRestClient.CLASS_NAME;
21
27
  }
22
28
  /**
23
29
  * Create a new proof.
@@ -25,7 +31,7 @@ class ImmutableProofClient extends BaseRestClient {
25
31
  * @returns The id of the new proof.
26
32
  */
27
33
  async create(document) {
28
- Guards.object(this.CLASS_NAME, "document", document);
34
+ Guards.object(ImmutableProofRestClient.CLASS_NAME, "document", document);
29
35
  const response = await this.fetch("/", "POST", {
30
36
  body: {
31
37
  document
@@ -40,7 +46,7 @@ class ImmutableProofClient extends BaseRestClient {
40
46
  * @throws NotFoundError if the proof is not found.
41
47
  */
42
48
  async get(id) {
43
- Guards.stringValue(this.CLASS_NAME, "id", id);
49
+ Guards.stringValue(ImmutableProofRestClient.CLASS_NAME, "id", id);
44
50
  const response = await this.fetch("/:id", "GET", {
45
51
  headers: {
46
52
  [HeaderTypes.Accept]: MimeTypes.JsonLd
@@ -58,7 +64,7 @@ class ImmutableProofClient extends BaseRestClient {
58
64
  * @throws NotFoundError if the proof is not found.
59
65
  */
60
66
  async verify(id) {
61
- Guards.stringValue(this.CLASS_NAME, "id", id);
67
+ Guards.stringValue(ImmutableProofRestClient.CLASS_NAME, "id", id);
62
68
  const response = await this.fetch("/:id/verify", "GET", {
63
69
  headers: {
64
70
  [HeaderTypes.Accept]: MimeTypes.JsonLd
@@ -76,8 +82,9 @@ class ImmutableProofClient extends BaseRestClient {
76
82
  * @throws NotFoundError if the proof is not found.
77
83
  */
78
84
  async removeVerifiable(id) {
79
- throw new NotSupportedError(this.CLASS_NAME, "removeVerifiable");
85
+ throw new NotSupportedError(ImmutableProofRestClient.CLASS_NAME, "notSupportedOnClient", {
86
+ methodName: "removeVerifiable"
87
+ });
80
88
  }
81
89
  }
82
-
83
- export { ImmutableProofClient };
90
+ //# sourceMappingURL=immutableProofRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immutableProofRestClient.js","sourceRoot":"","sources":["../../src/immutableProofRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAa3D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IAC3D;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,6BAAqC,MAAM,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ED;;;;;OAKG;IACI,KAAK,CAAC,gBAAgB,CAAC,EAAU;QACvC,MAAM,IAAI,iBAAiB,CAAC,wBAAwB,CAAC,UAAU,EAAE,sBAAsB,EAAE;YACxF,UAAU,EAAE,kBAAkB;SAC9B,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, ICreatedResponse } from \"@twin.org/api-models\";\nimport { Guards, NotSupportedError } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type {\n\tIImmutableProof,\n\tIImmutableProofComponent,\n\tIImmutableProofCreateRequest,\n\tIImmutableProofGetRequest,\n\tIImmutableProofGetResponse,\n\tIImmutableProofVerification,\n\tIImmutableProofVerifyRequest,\n\tIImmutableProofVerifyResponse\n} from \"@twin.org/immutable-proof-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderTypes, MimeTypes } from \"@twin.org/web\";\n\n/**\n * Client for performing immutable proof through to REST endpoints.\n */\nexport class ImmutableProofRestClient extends BaseRestClient implements IImmutableProofComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ImmutableProofRestClient>();\n\n\t/**\n\t * Create a new instance of ImmutableProofRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<ImmutableProofRestClient>(), config, \"immutable-proof\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ImmutableProofRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new proof.\n\t * @param document The document to create the proof for.\n\t * @returns The id of the new proof.\n\t */\n\tpublic async create(document: IJsonLdNodeObject): Promise<string> {\n\t\tGuards.object(ImmutableProofRestClient.CLASS_NAME, nameof(document), document);\n\n\t\tconst response = await this.fetch<IImmutableProofCreateRequest, ICreatedResponse>(\"/\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\tdocument\n\t\t\t}\n\t\t});\n\n\t\treturn response.headers[HeaderTypes.Location];\n\t}\n\n\t/**\n\t * Get a proof.\n\t * @param id The id of the proof to get.\n\t * @returns The proof.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async get(id: string): Promise<IImmutableProof> {\n\t\tGuards.stringValue(ImmutableProofRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IImmutableProofGetRequest, IImmutableProofGetResponse>(\n\t\t\t\"/:id\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a proof.\n\t * @param id The id of the proof to verify.\n\t * @returns The result of the verification and any failures.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async verify(id: string): Promise<IImmutableProofVerification> {\n\t\tGuards.stringValue(ImmutableProofRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IImmutableProofVerifyRequest, IImmutableProofVerifyResponse>(\n\t\t\t\"/:id/verify\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove the verifiable storage for the proof.\n\t * @param id The id of the proof to remove the storage from.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async removeVerifiable(id: string): Promise<void> {\n\t\tthrow new NotSupportedError(ImmutableProofRestClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"removeVerifiable\"\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./immutableProofRestClient.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,+BAA+B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./immutableProofRestClient.js\";\n"]}
@@ -5,16 +5,21 @@ import type { IImmutableProof, IImmutableProofComponent, IImmutableProofVerifica
5
5
  /**
6
6
  * Client for performing immutable proof through to REST endpoints.
7
7
  */
8
- export declare class ImmutableProofClient extends BaseRestClient implements IImmutableProofComponent {
8
+ export declare class ImmutableProofRestClient extends BaseRestClient implements IImmutableProofComponent {
9
9
  /**
10
10
  * Runtime name for the class.
11
11
  */
12
- readonly CLASS_NAME: string;
12
+ static readonly CLASS_NAME: string;
13
13
  /**
14
- * Create a new instance of ImmutableProofClient.
14
+ * Create a new instance of ImmutableProofRestClient.
15
15
  * @param config The configuration for the client.
16
16
  */
17
17
  constructor(config: IBaseRestClientConfig);
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className(): string;
18
23
  /**
19
24
  * Create a new proof.
20
25
  * @param document The document to create the proof for.
@@ -1 +1 @@
1
- export * from "./immutableProofClient";
1
+ export * from "./immutableProofRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @twin.org/immutable-proof-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/immutable-proof/compare/immutable-proof-rest-client-v0.0.3-next.0...immutable-proof-rest-client-v0.0.3-next.1) (2025-11-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#14](https://github.com/twinfoundation/immutable-proof/issues/14)) ([ed5a594](https://github.com/twinfoundation/immutable-proof/commit/ed5a594eaa7d50f74b1c09a7a560d48b33a4ecd1))
9
+ * add validate-locales ([d6a7c07](https://github.com/twinfoundation/immutable-proof/commit/d6a7c0794a1922981a42f56cc24724d7cee727f6))
10
+ * eslint migration to flat config ([c8536f2](https://github.com/twinfoundation/immutable-proof/commit/c8536f219c7709c6c08b9266e537831f9054dda9))
11
+ * update dependencies ([7d6b321](https://github.com/twinfoundation/immutable-proof/commit/7d6b321928ca0434ee530816b1440f1687b94a6e))
12
+ * update framework core ([e708d4d](https://github.com/twinfoundation/immutable-proof/commit/e708d4dd3febcfbcd64663d5be004eab1d26c0fb))
13
+ * use shared store mechanism ([#3](https://github.com/twinfoundation/immutable-proof/issues/3)) ([7042a40](https://github.com/twinfoundation/immutable-proof/commit/7042a40f0ef8b01463f07aeb1efae4f417162fa1))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @twin.org/immutable-proof-models bumped from 0.0.3-next.0 to 0.0.3-next.1
21
+
22
+ ## [0.0.2-next.3](https://github.com/twinfoundation/immutable-proof/compare/immutable-proof-rest-client-v0.0.2-next.2...immutable-proof-rest-client-v0.0.2-next.3) (2025-10-09)
23
+
24
+
25
+ ### Features
26
+
27
+ * add validate-locales ([d6a7c07](https://github.com/twinfoundation/immutable-proof/commit/d6a7c0794a1922981a42f56cc24724d7cee727f6))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @twin.org/immutable-proof-models bumped from 0.0.2-next.2 to 0.0.2-next.3
35
+
3
36
  ## [0.0.2-next.2](https://github.com/twinfoundation/immutable-proof/compare/immutable-proof-rest-client-v0.0.2-next.1...immutable-proof-rest-client-v0.0.2-next.2) (2025-08-29)
4
37
 
5
38
 
@@ -1,4 +1,4 @@
1
- # Class: ImmutableProofClient
1
+ # Class: ImmutableProofRestClient
2
2
 
3
3
  Client for performing immutable proof through to REST endpoints.
4
4
 
@@ -14,9 +14,9 @@ Client for performing immutable proof through to REST endpoints.
14
14
 
15
15
  ### Constructor
16
16
 
17
- > **new ImmutableProofClient**(`config`): `ImmutableProofClient`
17
+ > **new ImmutableProofRestClient**(`config`): `ImmutableProofRestClient`
18
18
 
19
- Create a new instance of ImmutableProofClient.
19
+ Create a new instance of ImmutableProofRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -28,7 +28,7 @@ The configuration for the client.
28
28
 
29
29
  #### Returns
30
30
 
31
- `ImmutableProofClient`
31
+ `ImmutableProofRestClient`
32
32
 
33
33
  #### Overrides
34
34
 
@@ -38,15 +38,29 @@ The configuration for the client.
38
38
 
39
39
  ### CLASS\_NAME
40
40
 
41
- > `readonly` **CLASS\_NAME**: `string`
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
43
43
  Runtime name for the class.
44
44
 
45
+ ## Methods
46
+
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
45
59
  #### Implementation of
46
60
 
47
- `IImmutableProofComponent.CLASS_NAME`
61
+ `IImmutableProofComponent.className`
48
62
 
49
- ## Methods
63
+ ***
50
64
 
51
65
  ### create()
52
66
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## Classes
4
4
 
5
- - [ImmutableProofClient](classes/ImmutableProofClient.md)
5
+ - [ImmutableProofRestClient](classes/ImmutableProofRestClient.md)
package/locales/en.json CHANGED
@@ -1 +1,7 @@
1
- {}
1
+ {
2
+ "error": {
3
+ "immutableProofRestClient": {
4
+ "notSupportedOnClient": "The method \"{methodName}\" is not supported on the REST client, it can only be used on a server side component"
5
+ }
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/immutable-proof-rest-client",
3
- "version": "0.0.2-next.2",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Immutable Proof contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,26 +19,36 @@
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/data-json-ld": "next",
21
21
  "@twin.org/entity": "next",
22
- "@twin.org/immutable-proof-models": "0.0.2-next.2",
22
+ "@twin.org/immutable-proof-models": "0.0.3-next.1",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/web": "next"
25
25
  },
26
- "main": "./dist/cjs/index.cjs",
27
- "module": "./dist/esm/index.mjs",
26
+ "main": "./dist/es/index.js",
28
27
  "types": "./dist/types/index.d.ts",
29
28
  "exports": {
30
29
  ".": {
31
30
  "types": "./dist/types/index.d.ts",
32
- "require": "./dist/cjs/index.cjs",
33
- "import": "./dist/esm/index.mjs"
31
+ "import": "./dist/es/index.js",
32
+ "default": "./dist/es/index.js"
34
33
  },
35
34
  "./locales/*.json": "./locales/*.json"
36
35
  },
37
36
  "files": [
38
- "dist/cjs",
39
- "dist/esm",
37
+ "dist/es",
40
38
  "dist/types",
41
39
  "locales",
42
40
  "docs"
43
- ]
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "immutable-proof"
49
+ ],
50
+ "bugs": {
51
+ "url": "git+https://github.com/twinfoundation/immutable-proof/issues"
52
+ },
53
+ "homepage": "https://twindev.org"
44
54
  }
@@ -1,85 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var core = require('@twin.org/core');
5
- var web = require('@twin.org/web');
6
-
7
- // Copyright 2024 IOTA Stiftung.
8
- // SPDX-License-Identifier: Apache-2.0.
9
- /**
10
- * Client for performing immutable proof through to REST endpoints.
11
- */
12
- class ImmutableProofClient extends apiCore.BaseRestClient {
13
- /**
14
- * Runtime name for the class.
15
- */
16
- CLASS_NAME = "ImmutableProofClient";
17
- /**
18
- * Create a new instance of ImmutableProofClient.
19
- * @param config The configuration for the client.
20
- */
21
- constructor(config) {
22
- super("ImmutableProofClient", config, "immutable-proof");
23
- }
24
- /**
25
- * Create a new proof.
26
- * @param document The document to create the proof for.
27
- * @returns The id of the new proof.
28
- */
29
- async create(document) {
30
- core.Guards.object(this.CLASS_NAME, "document", document);
31
- const response = await this.fetch("/", "POST", {
32
- body: {
33
- document
34
- }
35
- });
36
- return response.headers[web.HeaderTypes.Location];
37
- }
38
- /**
39
- * Get a proof.
40
- * @param id The id of the proof to get.
41
- * @returns The proof.
42
- * @throws NotFoundError if the proof is not found.
43
- */
44
- async get(id) {
45
- core.Guards.stringValue(this.CLASS_NAME, "id", id);
46
- const response = await this.fetch("/:id", "GET", {
47
- headers: {
48
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
49
- },
50
- pathParams: {
51
- id
52
- }
53
- });
54
- return response.body;
55
- }
56
- /**
57
- * Verify a proof.
58
- * @param id The id of the proof to verify.
59
- * @returns The result of the verification and any failures.
60
- * @throws NotFoundError if the proof is not found.
61
- */
62
- async verify(id) {
63
- core.Guards.stringValue(this.CLASS_NAME, "id", id);
64
- const response = await this.fetch("/:id/verify", "GET", {
65
- headers: {
66
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
67
- },
68
- pathParams: {
69
- id
70
- }
71
- });
72
- return response.body;
73
- }
74
- /**
75
- * Remove the verifiable storage for the proof.
76
- * @param id The id of the proof to remove the storage from.
77
- * @returns Nothing.
78
- * @throws NotFoundError if the proof is not found.
79
- */
80
- async removeVerifiable(id) {
81
- throw new core.NotSupportedError(this.CLASS_NAME, "removeVerifiable");
82
- }
83
- }
84
-
85
- exports.ImmutableProofClient = ImmutableProofClient;