@twin.org/api-auth-entity-storage-rest-client 0.0.2-next.9 → 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,22 +1,26 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var core = require('@twin.org/core');
5
-
1
+ import { BaseRestClient } from "@twin.org/api-core";
2
+ import { Guards } from "@twin.org/core";
6
3
  /**
7
4
  * The client to connect to the authentication service.
8
5
  */
9
- class EntityStorageAuthenticationClient extends apiCore.BaseRestClient {
6
+ export class EntityStorageAuthenticationRestClient extends BaseRestClient {
10
7
  /**
11
8
  * Runtime name for the class.
12
9
  */
13
- CLASS_NAME = "EntityStorageAuthenticationClient";
10
+ static CLASS_NAME = "EntityStorageAuthenticationRestClient";
14
11
  /**
15
- * Create a new instance of EntityStorageAuthenticationClient.
12
+ * Create a new instance of EntityStorageAuthenticationRestClient.
16
13
  * @param config The configuration for the client.
17
14
  */
18
15
  constructor(config) {
19
- super("EntityStorageAuthenticationClient", config, "authentication");
16
+ super("EntityStorageAuthenticationRestClient", config, "authentication");
17
+ }
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className() {
23
+ return EntityStorageAuthenticationRestClient.CLASS_NAME;
20
24
  }
21
25
  /**
22
26
  * Perform a login for the user.
@@ -25,8 +29,8 @@ class EntityStorageAuthenticationClient extends apiCore.BaseRestClient {
25
29
  * @returns The authentication token for the user, if it uses a mechanism with public access.
26
30
  */
27
31
  async login(email, password) {
28
- core.Guards.stringValue(this.CLASS_NAME, "email", email);
29
- core.Guards.stringValue(this.CLASS_NAME, "password", password);
32
+ Guards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, "email", email);
33
+ Guards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, "password", password);
30
34
  const response = await this.fetch("/login", "POST", {
31
35
  body: {
32
36
  email,
@@ -68,9 +72,9 @@ class EntityStorageAuthenticationClient extends apiCore.BaseRestClient {
68
72
  * @returns Nothing.
69
73
  */
70
74
  async updatePassword(email, currentPassword, newPassword) {
71
- core.Guards.stringValue(this.CLASS_NAME, "email", email);
72
- core.Guards.stringValue(this.CLASS_NAME, "currentPassword", currentPassword);
73
- core.Guards.stringValue(this.CLASS_NAME, "newPassword", newPassword);
75
+ Guards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, "email", email);
76
+ Guards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, "currentPassword", currentPassword);
77
+ Guards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, "newPassword", newPassword);
74
78
  await this.fetch("/:email/password", "PUT", {
75
79
  pathParams: {
76
80
  email
@@ -82,5 +86,4 @@ class EntityStorageAuthenticationClient extends apiCore.BaseRestClient {
82
86
  });
83
87
  }
84
88
  }
85
-
86
- exports.EntityStorageAuthenticationClient = EntityStorageAuthenticationClient;
89
+ //# sourceMappingURL=entityStorageAuthenticationRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageAuthenticationRestClient.js","sourceRoot":"","sources":["../../src/entityStorageAuthenticationRestClient.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,qCACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,0CAAkD,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CACjB,KAAa,EACb,QAAgB;QAKhB,MAAM,CAAC,WAAW,CAAC,qCAAqC,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3F,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,cAEhD,QAAQ,CACR,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAgC,QAAQ,EAAE,MAAM,EAAE;YAClF,IAAI,EAAE;gBACL,KAAK;gBACL,QAAQ;aACR;SACD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,KAAc;QACjC,MAAM,IAAI,CAAC,KAAK,CAAqC,SAAS,EAAE,KAAK,EAAE;YACtE,KAAK,EAAE;gBACN,KAAK;aACL;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAC,KAAc;QAIlC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,UAAU,EACV,KAAK,EACL;YACC,KAAK,EAAE;gBACN,KAAK;aACL;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAC1B,KAAa,EACb,eAAuB,EACvB,WAAmB;QAEnB,MAAM,CAAC,WAAW,CAAC,qCAAqC,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3F,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,qBAEhD,eAAe,CACf,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,iBAEhD,WAAW,CACX,CAAC;QAEF,MAAM,IAAI,CAAC,KAAK,CAA6C,kBAAkB,EAAE,KAAK,EAAE;YACvF,UAAU,EAAE;gBACX,KAAK;aACL;YACD,IAAI,EAAE;gBACL,eAAe;gBACf,WAAW;aACX;SACD,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationComponent,\n\tILoginRequest,\n\tILoginResponse,\n\tILogoutRequest,\n\tIRefreshTokenRequest,\n\tIRefreshTokenResponse,\n\tIUpdatePasswordRequest\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * The client to connect to the authentication service.\n */\nexport class EntityStorageAuthenticationRestClient\n\textends BaseRestClient\n\timplements IAuthenticationComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageAuthenticationRestClient>();\n\n\t/**\n\t * Create a new instance of EntityStorageAuthenticationRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<EntityStorageAuthenticationRestClient>(), config, \"authentication\");\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 EntityStorageAuthenticationRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Perform a login for the user.\n\t * @param email The email address for the user.\n\t * @param password The password for the user.\n\t * @returns The authentication token for the user, if it uses a mechanism with public access.\n\t */\n\tpublic async login(\n\t\temail: string,\n\t\tpassword: string\n\t): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\tGuards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, nameof(email), email);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageAuthenticationRestClient.CLASS_NAME,\n\t\t\tnameof(password),\n\t\t\tpassword\n\t\t);\n\n\t\tconst response = await this.fetch<ILoginRequest, ILoginResponse>(\"/login\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\temail,\n\t\t\t\tpassword\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Logout the current user.\n\t * @param token The token to logout, if it uses a mechanism with public access.\n\t * @returns Nothing.\n\t */\n\tpublic async logout(token?: string): Promise<void> {\n\t\tawait this.fetch<ILogoutRequest, INoContentResponse>(\"/logout\", \"GET\", {\n\t\t\tquery: {\n\t\t\t\ttoken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Refresh the token.\n\t * @param token The token to refresh, if it uses a mechanism with public access.\n\t * @returns The refreshed token, if it uses a mechanism with public access.\n\t */\n\tpublic async refresh(token?: string): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\tconst response = await this.fetch<IRefreshTokenRequest, IRefreshTokenResponse>(\n\t\t\t\"/refresh\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\ttoken\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 * Update the user's password.\n\t * @param email The email address of the user to update.\n\t * @param currentPassword The current password for the user.\n\t * @param newPassword The new password for the user.\n\t * @returns Nothing.\n\t */\n\tpublic async updatePassword(\n\t\temail: string,\n\t\tcurrentPassword: string,\n\t\tnewPassword: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageAuthenticationRestClient.CLASS_NAME, nameof(email), email);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageAuthenticationRestClient.CLASS_NAME,\n\t\t\tnameof(currentPassword),\n\t\t\tcurrentPassword\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageAuthenticationRestClient.CLASS_NAME,\n\t\t\tnameof(newPassword),\n\t\t\tnewPassword\n\t\t);\n\n\t\tawait this.fetch<IUpdatePasswordRequest, INoContentResponse>(\"/:email/password\", \"PUT\", {\n\t\t\tpathParams: {\n\t\t\t\temail\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcurrentPassword,\n\t\t\t\tnewPassword\n\t\t\t}\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 "./entityStorageAuthenticationRestClient.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,4CAA4C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entityStorageAuthenticationRestClient.js\";\n"]}
@@ -4,16 +4,21 @@ import type { IBaseRestClientConfig } from "@twin.org/api-models";
4
4
  /**
5
5
  * The client to connect to the authentication service.
6
6
  */
7
- export declare class EntityStorageAuthenticationClient extends BaseRestClient implements IAuthenticationComponent {
7
+ export declare class EntityStorageAuthenticationRestClient extends BaseRestClient implements IAuthenticationComponent {
8
8
  /**
9
9
  * Runtime name for the class.
10
10
  */
11
- readonly CLASS_NAME: string;
11
+ static readonly CLASS_NAME: string;
12
12
  /**
13
- * Create a new instance of EntityStorageAuthenticationClient.
13
+ * Create a new instance of EntityStorageAuthenticationRestClient.
14
14
  * @param config The configuration for the client.
15
15
  */
16
16
  constructor(config: IBaseRestClientConfig);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
17
22
  /**
18
23
  * Perform a login for the user.
19
24
  * @param email The email address for the user.
@@ -1 +1 @@
1
- export * from "./clients/entityStorageAuthenticationClient";
1
+ export * from "./entityStorageAuthenticationRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # @twin.org/api-auth-entity-storage-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.3-next.0...api-auth-entity-storage-rest-client-v0.0.3-next.1) (2025-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
9
+ * add json-ld mime type processor and auth admin component ([8861791](https://github.com/twinfoundation/api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
10
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
11
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
12
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
13
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
14
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
15
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * use correct format for log messaging ([44bc2a4](https://github.com/twinfoundation/api/commit/44bc2a4f7cf1f9c38a7e8c6f90ccb2424c958de9))
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
28
+ * @twin.org/api-core bumped from 0.0.3-next.0 to 0.0.3-next.1
29
+ * @twin.org/api-models bumped from 0.0.3-next.0 to 0.0.3-next.1
30
+
31
+ ## [0.0.2-next.13](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.2-next.12...api-auth-entity-storage-rest-client-v0.0.2-next.13) (2025-10-09)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **api-auth-entity-storage-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.2-next.12 to 0.0.2-next.13
44
+ * @twin.org/api-core bumped from 0.0.2-next.12 to 0.0.2-next.13
45
+ * @twin.org/api-models bumped from 0.0.2-next.12 to 0.0.2-next.13
46
+
47
+ ## [0.0.2-next.12](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.2-next.11...api-auth-entity-storage-rest-client-v0.0.2-next.12) (2025-10-09)
48
+
49
+
50
+ ### Features
51
+
52
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
53
+
54
+
55
+ ### Dependencies
56
+
57
+ * The following workspace dependencies were updated
58
+ * dependencies
59
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.2-next.11 to 0.0.2-next.12
60
+ * @twin.org/api-core bumped from 0.0.2-next.11 to 0.0.2-next.12
61
+ * @twin.org/api-models bumped from 0.0.2-next.11 to 0.0.2-next.12
62
+
63
+ ## [0.0.2-next.11](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.2-next.10...api-auth-entity-storage-rest-client-v0.0.2-next.11) (2025-09-29)
64
+
65
+
66
+ ### Features
67
+
68
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
69
+
70
+
71
+ ### Dependencies
72
+
73
+ * The following workspace dependencies were updated
74
+ * dependencies
75
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.2-next.10 to 0.0.2-next.11
76
+ * @twin.org/api-core bumped from 0.0.2-next.10 to 0.0.2-next.11
77
+ * @twin.org/api-models bumped from 0.0.2-next.10 to 0.0.2-next.11
78
+
79
+ ## [0.0.2-next.10](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.2-next.9...api-auth-entity-storage-rest-client-v0.0.2-next.10) (2025-09-23)
80
+
81
+
82
+ ### Miscellaneous Chores
83
+
84
+ * **api-auth-entity-storage-rest-client:** Synchronize repo versions
85
+
86
+
87
+ ### Dependencies
88
+
89
+ * The following workspace dependencies were updated
90
+ * dependencies
91
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.2-next.9 to 0.0.2-next.10
92
+ * @twin.org/api-core bumped from 0.0.2-next.9 to 0.0.2-next.10
93
+ * @twin.org/api-models bumped from 0.0.2-next.9 to 0.0.2-next.10
94
+
3
95
  ## [0.0.2-next.9](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.2-next.8...api-auth-entity-storage-rest-client-v0.0.2-next.9) (2025-08-29)
4
96
 
5
97
 
@@ -1,4 +1,4 @@
1
- # Class: EntityStorageAuthenticationClient
1
+ # Class: EntityStorageAuthenticationRestClient
2
2
 
3
3
  The client to connect to the authentication service.
4
4
 
@@ -14,9 +14,9 @@ The client to connect to the authentication service.
14
14
 
15
15
  ### Constructor
16
16
 
17
- > **new EntityStorageAuthenticationClient**(`config`): `EntityStorageAuthenticationClient`
17
+ > **new EntityStorageAuthenticationRestClient**(`config`): `EntityStorageAuthenticationRestClient`
18
18
 
19
- Create a new instance of EntityStorageAuthenticationClient.
19
+ Create a new instance of EntityStorageAuthenticationRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -28,7 +28,7 @@ The configuration for the client.
28
28
 
29
29
  #### Returns
30
30
 
31
- `EntityStorageAuthenticationClient`
31
+ `EntityStorageAuthenticationRestClient`
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
- `IAuthenticationComponent.CLASS_NAME`
61
+ `IAuthenticationComponent.className`
48
62
 
49
- ## Methods
63
+ ***
50
64
 
51
65
  ### login()
52
66
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## Classes
4
4
 
5
- - [EntityStorageAuthenticationClient](classes/EntityStorageAuthenticationClient.md)
5
+ - [EntityStorageAuthenticationRestClient](classes/EntityStorageAuthenticationRestClient.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-auth-entity-storage-rest-client",
3
- "version": "0.0.2-next.9",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Perform REST authentication using entity storage.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,28 +14,42 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-auth-entity-storage-models": "0.0.2-next.9",
18
- "@twin.org/api-core": "0.0.2-next.9",
19
- "@twin.org/api-models": "0.0.2-next.9",
17
+ "@twin.org/api-auth-entity-storage-models": "0.0.3-next.1",
18
+ "@twin.org/api-core": "0.0.3-next.1",
19
+ "@twin.org/api-models": "0.0.3-next.1",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/nameof": "next",
22
22
  "@twin.org/web": "next"
23
23
  },
24
- "main": "./dist/cjs/index.cjs",
25
- "module": "./dist/esm/index.mjs",
24
+ "main": "./dist/es/index.js",
26
25
  "types": "./dist/types/index.d.ts",
27
26
  "exports": {
28
27
  ".": {
29
28
  "types": "./dist/types/index.d.ts",
30
- "require": "./dist/cjs/index.cjs",
31
- "import": "./dist/esm/index.mjs"
29
+ "import": "./dist/es/index.js",
30
+ "default": "./dist/es/index.js"
32
31
  }
33
32
  },
34
33
  "files": [
35
- "dist/cjs",
36
- "dist/esm",
34
+ "dist/es",
37
35
  "dist/types",
38
36
  "locales",
39
37
  "docs"
40
- ]
38
+ ],
39
+ "keywords": [
40
+ "twin",
41
+ "trade",
42
+ "iota",
43
+ "framework",
44
+ "blockchain",
45
+ "api",
46
+ "entity",
47
+ "storage",
48
+ "persistence",
49
+ "database"
50
+ ],
51
+ "bugs": {
52
+ "url": "git+https://github.com/twinfoundation/api/issues"
53
+ },
54
+ "homepage": "https://twindev.org"
41
55
  }
@@ -1,84 +0,0 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { Guards } from '@twin.org/core';
3
-
4
- /**
5
- * The client to connect to the authentication service.
6
- */
7
- class EntityStorageAuthenticationClient extends BaseRestClient {
8
- /**
9
- * Runtime name for the class.
10
- */
11
- CLASS_NAME = "EntityStorageAuthenticationClient";
12
- /**
13
- * Create a new instance of EntityStorageAuthenticationClient.
14
- * @param config The configuration for the client.
15
- */
16
- constructor(config) {
17
- super("EntityStorageAuthenticationClient", config, "authentication");
18
- }
19
- /**
20
- * Perform a login for the user.
21
- * @param email The email address for the user.
22
- * @param password The password for the user.
23
- * @returns The authentication token for the user, if it uses a mechanism with public access.
24
- */
25
- async login(email, password) {
26
- Guards.stringValue(this.CLASS_NAME, "email", email);
27
- Guards.stringValue(this.CLASS_NAME, "password", password);
28
- const response = await this.fetch("/login", "POST", {
29
- body: {
30
- email,
31
- password
32
- }
33
- });
34
- return response.body;
35
- }
36
- /**
37
- * Logout the current user.
38
- * @param token The token to logout, if it uses a mechanism with public access.
39
- * @returns Nothing.
40
- */
41
- async logout(token) {
42
- await this.fetch("/logout", "GET", {
43
- query: {
44
- token
45
- }
46
- });
47
- }
48
- /**
49
- * Refresh the token.
50
- * @param token The token to refresh, if it uses a mechanism with public access.
51
- * @returns The refreshed token, if it uses a mechanism with public access.
52
- */
53
- async refresh(token) {
54
- const response = await this.fetch("/refresh", "GET", {
55
- query: {
56
- token
57
- }
58
- });
59
- return response.body;
60
- }
61
- /**
62
- * Update the user's password.
63
- * @param email The email address of the user to update.
64
- * @param currentPassword The current password for the user.
65
- * @param newPassword The new password for the user.
66
- * @returns Nothing.
67
- */
68
- async updatePassword(email, currentPassword, newPassword) {
69
- Guards.stringValue(this.CLASS_NAME, "email", email);
70
- Guards.stringValue(this.CLASS_NAME, "currentPassword", currentPassword);
71
- Guards.stringValue(this.CLASS_NAME, "newPassword", newPassword);
72
- await this.fetch("/:email/password", "PUT", {
73
- pathParams: {
74
- email
75
- },
76
- body: {
77
- currentPassword,
78
- newPassword
79
- }
80
- });
81
- }
82
- }
83
-
84
- export { EntityStorageAuthenticationClient };