@credenza3/partner-sdk 0.0.1-alpha.0 → 0.0.1-alpha.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.
@@ -0,0 +1,12 @@
1
+ export declare function getCurrentClientInfo(): Promise<{
2
+ id: string;
3
+ name: string;
4
+ callbackUris: string[];
5
+ confidential: boolean;
6
+ ownerId: string;
7
+ accessTokenTTLMinutes: number;
8
+ availableLoginTypes: string[];
9
+ admins: string[];
10
+ apiPermissions: string[];
11
+ logoUri?: string;
12
+ }>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentClientInfo = getCurrentClientInfo;
4
+ const credentials_1 = require("../../lib/credentials");
5
+ const accounts_1 = require("../../accounts");
6
+ const logging_1 = require("../../lib/logging");
7
+ async function getCurrentClientInfo() {
8
+ const response = await fetch(`${(0, accounts_1.getOAuthApiUrl)()}/clients/current`, {
9
+ headers: {
10
+ Authorization: (0, credentials_1.getBasicToken)(),
11
+ 'Content-Type': 'application/json',
12
+ },
13
+ });
14
+ const json = await response.json();
15
+ (0, logging_1.log)(getCurrentClientInfo.name, json);
16
+ return {
17
+ id: json._id,
18
+ name: json.name,
19
+ callbackUris: json.callback_uris,
20
+ confidential: json.confidential,
21
+ ownerId: json.owner_id,
22
+ accessTokenTTLMinutes: json.access_token_ttl_minutes,
23
+ availableLoginTypes: json.available_login_types,
24
+ admins: json.admins,
25
+ apiPermissions: json.api_permissions,
26
+ logoUri: json.logo_uri ?? null,
27
+ };
28
+ }
@@ -0,0 +1 @@
1
+ export * from './client';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client"), exports);
@@ -1,2 +1,3 @@
1
1
  export * from './accounts';
2
2
  export * from './oauth-account';
3
+ export * from './client';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./accounts"), exports);
18
18
  __exportStar(require("./oauth-account"), exports);
19
+ __exportStar(require("./client"), exports);
package/dist/api/api.js CHANGED
@@ -20,9 +20,9 @@ function getGeneralApiUrl() {
20
20
  function getGeneralWsUrl() {
21
21
  switch ((0, sdk_env_1.getSdkEnv)()) {
22
22
  case sdk_env_1.SDK_ENV.PROD:
23
- return 'wss://api.credenza3.com';
23
+ return 'wss://general-prod-prod.up.railway.app';
24
24
  case sdk_env_1.SDK_ENV.STAGING:
25
- return 'wss://api.staging.credenza.com';
25
+ return 'wss://general-staging-staging.up.railway.app';
26
26
  case sdk_env_1.SDK_ENV.LOCAL:
27
27
  return 'ws://localhost:8084';
28
28
  }
@@ -37,6 +37,7 @@ async function getWsConnection() {
37
37
  },
38
38
  });
39
39
  await new Promise((resolve, reject) => {
40
+ socket.once('connect_error', (err) => reject(err));
40
41
  socket.once('connect', () => resolve(socket));
41
42
  setTimeout(() => reject(new Error('Cannot connect to websocket server')), 5000);
42
43
  });
@@ -1,2 +1,3 @@
1
1
  export * from './api';
2
+ export * from './nfc-id';
2
3
  export * from './passport-id';
package/dist/api/index.js CHANGED
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api"), exports);
18
+ __exportStar(require("./nfc-id"), exports);
18
19
  __exportStar(require("./passport-id"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './nfc-id';
2
+ export * from './nfc-id.types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./nfc-id"), exports);
18
+ __exportStar(require("./nfc-id.types"), exports);
@@ -0,0 +1,5 @@
1
+ import { TNfcId, TUpdateNfcId } from './nfc-id.types';
2
+ export declare function addNfcId(params: TNfcId): Promise<TNfcId>;
3
+ export declare function updateNfcId(serialNumber: string, params: TUpdateNfcId): Promise<boolean>;
4
+ export declare function removeNfcId(serialNumber: string): Promise<boolean>;
5
+ export declare function getNfcId(serialNumber: string): Promise<Omit<TNfcId, 'serialNumber'>>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addNfcId = addNfcId;
4
+ exports.updateNfcId = updateNfcId;
5
+ exports.removeNfcId = removeNfcId;
6
+ exports.getNfcId = getNfcId;
7
+ const logging_1 = require("../../lib/logging");
8
+ const api_1 = require("../../api");
9
+ const credentials_1 = require("../../lib/credentials");
10
+ async function addNfcId(params) {
11
+ const response = await fetch(`${(0, api_1.getGeneralApiUrl)()}/nfc-id`, {
12
+ method: 'POST',
13
+ headers: {
14
+ Authorization: (0, credentials_1.getBasicToken)(),
15
+ 'Content-Type': 'application/json',
16
+ },
17
+ body: JSON.stringify({
18
+ serial_number: params.serialNumber,
19
+ sub: params.sub,
20
+ ...(params.text ? { text: params.text } : {}),
21
+ }),
22
+ });
23
+ const json = await response.json();
24
+ (0, logging_1.log)(addNfcId.name, json);
25
+ return {
26
+ sub: json.sub,
27
+ serialNumber: json.serial_number,
28
+ text: json.text ?? null,
29
+ };
30
+ }
31
+ async function updateNfcId(serialNumber, params) {
32
+ const response = await fetch(`${(0, api_1.getGeneralApiUrl)()}/nfc-id/${serialNumber}`, {
33
+ method: 'PATCH',
34
+ headers: {
35
+ Authorization: (0, credentials_1.getBasicToken)(),
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ body: JSON.stringify({
39
+ ...(params.text ? { text: params.text } : {}),
40
+ ...(params.sub ? { sub: params.sub } : {}),
41
+ }),
42
+ });
43
+ const json = await response.json();
44
+ (0, logging_1.log)(updateNfcId.name, json);
45
+ return json;
46
+ }
47
+ async function removeNfcId(serialNumber) {
48
+ const response = await fetch(`${(0, api_1.getGeneralApiUrl)()}/nfc-id/${serialNumber}`, {
49
+ method: 'DELETE',
50
+ headers: {
51
+ Authorization: (0, credentials_1.getBasicToken)(),
52
+ 'Content-Type': 'application/json',
53
+ },
54
+ });
55
+ const json = await response.json();
56
+ (0, logging_1.log)(removeNfcId.name, json);
57
+ return json;
58
+ }
59
+ async function getNfcId(serialNumber) {
60
+ const response = await fetch(`${(0, api_1.getGeneralApiUrl)()}/nfc-id/${serialNumber}`, {
61
+ headers: {
62
+ Authorization: (0, credentials_1.getBasicToken)(),
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ });
66
+ const json = await response.json();
67
+ (0, logging_1.log)(getNfcId.name, json);
68
+ return { sub: json.sub, text: json.text ?? null };
69
+ }
@@ -0,0 +1,9 @@
1
+ export type TNfcId = {
2
+ sub: string;
3
+ serialNumber: string;
4
+ text?: string;
5
+ };
6
+ export type TUpdateNfcId = {
7
+ sub?: string;
8
+ text?: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,4 +2,4 @@ import { TCredentials } from './lib/credentials';
2
2
  import { TSdkEnv } from './lib/sdk-env';
3
3
  export declare function useAuth(credentials: TCredentials): void;
4
4
  export declare function useEnv(sdkEnv: TSdkEnv): void;
5
- export declare function debug(enableDebug: boolean): void;
5
+ export declare function useDebug(enableDebug: boolean): void;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuth = useAuth;
4
4
  exports.useEnv = useEnv;
5
- exports.debug = debug;
5
+ exports.useDebug = useDebug;
6
6
  const credentials_1 = require("./lib/credentials");
7
7
  const sdk_env_1 = require("./lib/sdk-env");
8
8
  const logging_1 = require("./lib/logging");
@@ -12,6 +12,6 @@ function useAuth(credentials) {
12
12
  function useEnv(sdkEnv) {
13
13
  (0, sdk_env_1.setSdkEnv)(sdkEnv);
14
14
  }
15
- function debug(enableDebug) {
15
+ function useDebug(enableDebug) {
16
16
  (0, logging_1.enableSdkDebug)(enableDebug);
17
17
  }
@@ -14,7 +14,7 @@ function setCredentials(credentialsInput) {
14
14
  }
15
15
  function getCredentials() {
16
16
  if (!credentials.clientId || !credentials.clientSecret)
17
- throw new Error('Credentials not set');
17
+ throw new Error('Credentials are not set');
18
18
  return credentials;
19
19
  }
20
20
  function getBasicToken() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credenza3/partner-sdk",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1-alpha.1",
4
4
  "description": "Credenza partner sdk",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "types": "./dist/evm/index.d.ts"
20
20
  },
21
21
  "./api": {
22
- "node": "./dist/common/index.js",
23
- "types": "./dist/common/index.d.ts"
22
+ "node": "./dist/api/index.js",
23
+ "types": "./dist/api/index.d.ts"
24
24
  },
25
25
  "./accounts": {
26
26
  "node": "./dist/accounts/index.js",
@@ -56,7 +56,6 @@
56
56
  "lint": "eslint \"src/**/*.ts\" --fix --max-warnings 0",
57
57
  "test": "echo \"Error: no test specified\"",
58
58
  "pre-commit-lint": "lint-staged",
59
- "demo": "pnpm run build && cd ./demo && pnpm run start",
60
- "demo:install": "cd ./demo && pnpm install"
59
+ "demo": "pnpm run build && cd ./demo && pnpm i && pnpm run start"
61
60
  }
62
61
  }