@credenza3/partner-sdk 0.0.0-alpha.2 → 0.0.1-alpha.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/README.md +6 -2
- package/dist/accounts/accounts.d.ts +1 -0
- package/dist/accounts/accounts.js +14 -0
- package/dist/accounts/index.d.ts +2 -0
- package/dist/accounts/index.js +18 -0
- package/dist/accounts/oauth-account/index.d.ts +1 -0
- package/dist/accounts/oauth-account/index.js +17 -0
- package/dist/accounts/oauth-account/oauth-account.d.ts +8 -0
- package/dist/accounts/oauth-account/oauth-account.js +17 -0
- package/dist/{common → api}/index.d.ts +1 -1
- package/dist/{common → api}/index.js +1 -1
- package/dist/{common → api}/passport-id/passport-id.d.ts +1 -4
- package/dist/{common → api}/passport-id/passport-id.js +8 -3
- package/dist/credenza-partner-sdk.d.ts +1 -0
- package/dist/credenza-partner-sdk.js +5 -0
- package/dist/evm/account/account.js +2 -0
- package/dist/lib/logging/index.d.ts +1 -0
- package/dist/lib/logging/index.js +17 -0
- package/dist/lib/logging/logging.d.ts +2 -0
- package/dist/lib/logging/logging.js +13 -0
- package/dist/sui/account/account.js +2 -0
- package/dist/sui/index.d.ts +1 -0
- package/dist/sui/index.js +1 -0
- package/dist/sui/zk/account/account.js +2 -0
- package/package.json +6 -2
- /package/dist/{common/common.d.ts → api/api.d.ts} +0 -0
- /package/dist/{common/common.js → api/api.js} +0 -0
- /package/dist/{common → api}/passport-id/index.d.ts +0 -0
- /package/dist/{common → api}/passport-id/index.js +0 -0
package/README.md
CHANGED
|
@@ -9,7 +9,9 @@ npm install @credenza3/partner-sdk
|
|
|
9
9
|
```
|
|
10
10
|
import { useAuth, useEnv } from '@credenza3/partner-sdk'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
debug(true) // Defaults to false
|
|
13
|
+
|
|
14
|
+
useEnv('prod' | 'staging' | 'local') // Defaults to 'prod'
|
|
13
15
|
|
|
14
16
|
useAuth({
|
|
15
17
|
clientId: string,
|
|
@@ -19,7 +21,9 @@ useAuth({
|
|
|
19
21
|
|
|
20
22
|
## MODULES
|
|
21
23
|
|
|
22
|
-
[
|
|
24
|
+
[api](./src/api/README.md)
|
|
25
|
+
|
|
26
|
+
[accounts](./src/accounts/README.md)
|
|
23
27
|
|
|
24
28
|
[evm](./src/evm/README.md)
|
|
25
29
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getOAuthApiUrl(): "https://accounts.credenza3.com" | "https://accounts.staging.credenza.com" | "http://localhost:8081";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOAuthApiUrl = getOAuthApiUrl;
|
|
4
|
+
const sdk_env_1 = require("../lib/sdk-env");
|
|
5
|
+
function getOAuthApiUrl() {
|
|
6
|
+
switch ((0, sdk_env_1.getSdkEnv)()) {
|
|
7
|
+
case sdk_env_1.SDK_ENV.PROD:
|
|
8
|
+
return 'https://accounts.credenza3.com';
|
|
9
|
+
case sdk_env_1.SDK_ENV.STAGING:
|
|
10
|
+
return 'https://accounts.staging.credenza.com';
|
|
11
|
+
case sdk_env_1.SDK_ENV.LOCAL:
|
|
12
|
+
return 'http://localhost:8081';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -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("./accounts"), exports);
|
|
18
|
+
__exportStar(require("./oauth-account"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './oauth-account';
|
|
@@ -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("./oauth-account"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccountInfo = getAccountInfo;
|
|
4
|
+
const credentials_1 = require("../../lib/credentials");
|
|
5
|
+
const accounts_1 = require("../../accounts");
|
|
6
|
+
const logging_1 = require("../../lib/logging");
|
|
7
|
+
async function getAccountInfo(sub) {
|
|
8
|
+
const response = await fetch(`${(0, accounts_1.getOAuthApiUrl)()}/accounts/${sub}`, {
|
|
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)(getAccountInfo.name, json);
|
|
16
|
+
return json;
|
|
17
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './api';
|
|
2
2
|
export * from './passport-id';
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
18
|
__exportStar(require("./passport-id"), exports);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requestPassportIdSignature = requestPassportIdSignature;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
const logging_1 = require("../../lib/logging");
|
|
5
6
|
async function requestPassportIdSignature(sub, message) {
|
|
6
7
|
if (!sub)
|
|
7
8
|
throw new Error('"Sub is required"');
|
|
8
9
|
if (!message)
|
|
9
10
|
throw new Error('"Message is required"');
|
|
10
|
-
const socket = await (0,
|
|
11
|
+
const socket = await (0, api_1.getWsConnection)();
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
12
|
-
socket.once(`passport_id/signed/${sub}`, (data) =>
|
|
13
|
+
socket.once(`passport_id/signed/${sub}`, (data) => {
|
|
14
|
+
(0, logging_1.log)(requestPassportIdSignature.name, 'Received', data);
|
|
15
|
+
resolve(data.payload);
|
|
16
|
+
});
|
|
13
17
|
socket.emit('passport_id/request_signature', {
|
|
14
18
|
payload: { sub, message },
|
|
15
19
|
}, (data) => {
|
|
@@ -19,6 +23,7 @@ async function requestPassportIdSignature(sub, message) {
|
|
|
19
23
|
if (data.error) {
|
|
20
24
|
reject(new Error(data.error.message));
|
|
21
25
|
}
|
|
26
|
+
(0, logging_1.log)(requestPassportIdSignature.name, 'Requested', data);
|
|
22
27
|
});
|
|
23
28
|
});
|
|
24
29
|
}
|
|
@@ -2,3 +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;
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAuth = useAuth;
|
|
4
4
|
exports.useEnv = useEnv;
|
|
5
|
+
exports.debug = debug;
|
|
5
6
|
const credentials_1 = require("./lib/credentials");
|
|
6
7
|
const sdk_env_1 = require("./lib/sdk-env");
|
|
8
|
+
const logging_1 = require("./lib/logging");
|
|
7
9
|
function useAuth(credentials) {
|
|
8
10
|
(0, credentials_1.setCredentials)(credentials);
|
|
9
11
|
}
|
|
10
12
|
function useEnv(sdkEnv) {
|
|
11
13
|
(0, sdk_env_1.setSdkEnv)(sdkEnv);
|
|
12
14
|
}
|
|
15
|
+
function debug(enableDebug) {
|
|
16
|
+
(0, logging_1.enableSdkDebug)(enableDebug);
|
|
17
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEvmAddress = getEvmAddress;
|
|
4
4
|
const credentials_1 = require("../../lib/credentials");
|
|
5
5
|
const evm_1 = require("../../evm");
|
|
6
|
+
const logging_1 = require("../../lib/logging");
|
|
6
7
|
async function getEvmAddress(sub) {
|
|
7
8
|
const response = await fetch(`${(0, evm_1.getEvmApiUrl)()}/accounts/${sub}/address`, {
|
|
8
9
|
headers: {
|
|
@@ -11,5 +12,6 @@ async function getEvmAddress(sub) {
|
|
|
11
12
|
},
|
|
12
13
|
});
|
|
13
14
|
const json = await response.json();
|
|
15
|
+
(0, logging_1.log)(getEvmAddress.name, json);
|
|
14
16
|
return json;
|
|
15
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logging';
|
|
@@ -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("./logging"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.log = log;
|
|
4
|
+
exports.enableSdkDebug = enableSdkDebug;
|
|
5
|
+
let debugEnabled = false;
|
|
6
|
+
function log(methodName, ...args) {
|
|
7
|
+
if (!debugEnabled)
|
|
8
|
+
return;
|
|
9
|
+
console.log(`[CREDENZA_PARTNER_SDK#${methodName}]:`, ...args);
|
|
10
|
+
}
|
|
11
|
+
function enableSdkDebug(enableDebug) {
|
|
12
|
+
debugEnabled = enableDebug;
|
|
13
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSuiAddress = getSuiAddress;
|
|
4
4
|
const credentials_1 = require("../../lib/credentials");
|
|
5
5
|
const sui_1 = require("../../sui");
|
|
6
|
+
const logging_1 = require("../../lib/logging");
|
|
6
7
|
async function getSuiAddress(sub) {
|
|
7
8
|
const response = await fetch(`${(0, sui_1.getSuiApiUrl)()}/accounts/${sub}/address`, {
|
|
8
9
|
headers: {
|
|
@@ -11,5 +12,6 @@ async function getSuiAddress(sub) {
|
|
|
11
12
|
},
|
|
12
13
|
});
|
|
13
14
|
const json = await response.json();
|
|
15
|
+
(0, logging_1.log)(getSuiAddress.name, json);
|
|
14
16
|
return json;
|
|
15
17
|
}
|
package/dist/sui/index.d.ts
CHANGED
package/dist/sui/index.js
CHANGED
|
@@ -28,4 +28,5 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.zk = void 0;
|
|
30
30
|
__exportStar(require("./sui"), exports);
|
|
31
|
+
__exportStar(require("./account"), exports);
|
|
31
32
|
exports.zk = __importStar(require("./zk"));
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSuiZkAddress = getSuiZkAddress;
|
|
4
4
|
const credentials_1 = require("../../../lib/credentials");
|
|
5
5
|
const sui_1 = require("../../../sui");
|
|
6
|
+
const logging_1 = require("../../../lib/logging");
|
|
6
7
|
async function getSuiZkAddress(sub) {
|
|
7
8
|
const response = await fetch(`${(0, sui_1.getSuiApiUrl)()}/accounts/zk/${sub}/address`, {
|
|
8
9
|
headers: {
|
|
@@ -11,5 +12,6 @@ async function getSuiZkAddress(sub) {
|
|
|
11
12
|
},
|
|
12
13
|
});
|
|
13
14
|
const json = await response.json();
|
|
15
|
+
(0, logging_1.log)(getSuiZkAddress.name, json);
|
|
14
16
|
return json;
|
|
15
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@credenza3/partner-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
4
|
"description": "Credenza partner sdk",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,10 +18,14 @@
|
|
|
18
18
|
"node": "./dist/evm/index.js",
|
|
19
19
|
"types": "./dist/evm/index.d.ts"
|
|
20
20
|
},
|
|
21
|
-
"./
|
|
21
|
+
"./api": {
|
|
22
22
|
"node": "./dist/common/index.js",
|
|
23
23
|
"types": "./dist/common/index.d.ts"
|
|
24
24
|
},
|
|
25
|
+
"./accounts": {
|
|
26
|
+
"node": "./dist/accounts/index.js",
|
|
27
|
+
"types": "./dist/accounts/index.d.ts"
|
|
28
|
+
},
|
|
25
29
|
".": {
|
|
26
30
|
"node": "./dist/index.js",
|
|
27
31
|
"types": "./dist/index.d.ts"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|