@compilot/js-sdk 2.0.40-dev
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/compilot-js-sdk.cjs.d.ts +2 -0
- package/dist/compilot-js-sdk.cjs.dev.js +1376 -0
- package/dist/compilot-js-sdk.cjs.js +7 -0
- package/dist/compilot-js-sdk.cjs.prod.js +1376 -0
- package/dist/compilot-js-sdk.esm.js +1360 -0
- package/dist/declarations/src/actions/attachCustomerInformation.d.ts +47 -0
- package/dist/declarations/src/actions/attachCustomerInformation.d.ts.map +1 -0
- package/dist/declarations/src/actions/createWeb2Session.d.ts +63 -0
- package/dist/declarations/src/actions/createWeb2Session.d.ts.map +1 -0
- package/dist/declarations/src/actions/createWeb3Challenge.d.ts +63 -0
- package/dist/declarations/src/actions/createWeb3Challenge.d.ts.map +1 -0
- package/dist/declarations/src/actions/getCustomerStatusByCustomerId.d.ts +29 -0
- package/dist/declarations/src/actions/getCustomerStatusByCustomerId.d.ts.map +1 -0
- package/dist/declarations/src/actions/getCustomerStatusByExternalCustomerId.d.ts +29 -0
- package/dist/declarations/src/actions/getCustomerStatusByExternalCustomerId.d.ts.map +1 -0
- package/dist/declarations/src/actions/getCustomerStatusByWallet.d.ts +29 -0
- package/dist/declarations/src/actions/getCustomerStatusByWallet.d.ts.map +1 -0
- package/dist/declarations/src/actions/getCustomerWallets.d.ts +31 -0
- package/dist/declarations/src/actions/getCustomerWallets.d.ts.map +1 -0
- package/dist/declarations/src/actions/getTxAuthDataSignature.d.ts +58 -0
- package/dist/declarations/src/actions/getTxAuthDataSignature.d.ts.map +1 -0
- package/dist/declarations/src/actions/validateWebhookEvent.d.ts +21 -0
- package/dist/declarations/src/actions/validateWebhookEvent.d.ts.map +1 -0
- package/dist/declarations/src/configuration/createSdk.d.ts +22 -0
- package/dist/declarations/src/configuration/createSdk.d.ts.map +1 -0
- package/dist/declarations/src/configuration/index.d.ts +2 -0
- package/dist/declarations/src/configuration/index.d.ts.map +1 -0
- package/dist/declarations/src/errors/ApiKeyNotProvidedError.d.ts +7 -0
- package/dist/declarations/src/errors/ApiKeyNotProvidedError.d.ts.map +1 -0
- package/dist/declarations/src/errors/WebhookEventDataNotSupportedByThisSdkVersion.d.ts +7 -0
- package/dist/declarations/src/errors/WebhookEventDataNotSupportedByThisSdkVersion.d.ts.map +1 -0
- package/dist/declarations/src/errors/WebhookSecretNotProvidedError.d.ts +7 -0
- package/dist/declarations/src/errors/WebhookSecretNotProvidedError.d.ts.map +1 -0
- package/dist/declarations/src/errors/WebhookSignatureInvalid.d.ts +7 -0
- package/dist/declarations/src/errors/WebhookSignatureInvalid.d.ts.map +1 -0
- package/dist/declarations/src/errors/index.d.ts +5 -0
- package/dist/declarations/src/errors/index.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +5 -0
- package/dist/declarations/src/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/index.d.ts +2 -0
- package/dist/declarations/src/utils/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/internal.d.ts +17 -0
- package/dist/declarations/src/utils/internal.d.ts.map +1 -0
- package/dist/package.json +60 -0
- package/package.json +59 -0
- package/readme.md +69 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@compilot/js-sdk",
|
|
3
|
+
"version": "2.0.40-dev",
|
|
4
|
+
"description": "ComPilot JS SDK",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"author": "",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/compilot-js-sdk.esm.js",
|
|
11
|
+
"require": "./dist/compilot-js-sdk.cjs.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/compilot-js-sdk.cjs.js",
|
|
15
|
+
"module": "dist/compilot-js-sdk.esm.js",
|
|
16
|
+
"types": "dist/compilot-js-sdk.cjs.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"/dist"
|
|
19
|
+
],
|
|
20
|
+
"eslintConfig": {
|
|
21
|
+
"extends": [
|
|
22
|
+
"@unblokttechnology/eslint-config/base"
|
|
23
|
+
],
|
|
24
|
+
"root": true
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"pino": "^9.4.0",
|
|
28
|
+
"svix": "1.21.0",
|
|
29
|
+
"zod": "^3.23.8",
|
|
30
|
+
"@nexeraid/api-client": "1.10.2-dev",
|
|
31
|
+
"@nexeraid/identity-api-client": "1.3.215-dev",
|
|
32
|
+
"@nexeraid/identity-schemas": "1.12.38-dev",
|
|
33
|
+
"@nexeraid/logger": "0.1.2-dev"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"prettier": "^3.3.3",
|
|
37
|
+
"typescript": "^5.6.2",
|
|
38
|
+
"@unblokttechnology/eslint-config": "0.1.1"
|
|
39
|
+
},
|
|
40
|
+
"preconstruct": {
|
|
41
|
+
"entrypoints": [
|
|
42
|
+
"index.ts"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "preconstruct build && npm run copy-package-json-to-dist",
|
|
47
|
+
"copy-package-json-to-dist": "copyfiles package.json dist/",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"lint:fix": "pnpm lint --fix",
|
|
50
|
+
"prepare:release": "sed -i 's/.*\"postinstall\":.*//' package.json",
|
|
51
|
+
"prepare:release:mac": "sed -i '' 's/.*\"postinstall\":.*//' package.json",
|
|
52
|
+
"prettier": "prettier 'src/' --check",
|
|
53
|
+
"prettier:fix": "prettier 'src/' --write",
|
|
54
|
+
"publish:public": "pnpm run prepare:release && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
|
|
55
|
+
"publish:public:mac": "pnpm run prepare:release:mac && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
|
|
56
|
+
"test": "vitest --config ./vitest.config.ts",
|
|
57
|
+
"type-check": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# ComPilot JS SDK
|
|
2
|
+
|
|
3
|
+
- ComPilot JS SDK, use anywhere JS runs.
|
|
4
|
+
|
|
5
|
+
## How to install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @compilot/js-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### First steps
|
|
12
|
+
|
|
13
|
+
- Access your ComPilot Application's Settings > API page and get the API key.
|
|
14
|
+
|
|
15
|
+
### How to use
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
/**
|
|
19
|
+
* Create an API client and authenticate with your API key
|
|
20
|
+
*/
|
|
21
|
+
const apiClient = createApiClient({
|
|
22
|
+
apiKey: API_KEY,
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Self-provided authentication
|
|
27
|
+
|
|
28
|
+
If you already have your own authentication system, you can create a user session like so:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
/*
|
|
32
|
+
* Get access token
|
|
33
|
+
* This has to be done from secured server, to avoid leaking API_KEY
|
|
34
|
+
*/
|
|
35
|
+
const sessionRes = await apiClient.createSession({
|
|
36
|
+
/**
|
|
37
|
+
* The workflow id that this session will be bound to.
|
|
38
|
+
* You can find this id in compilot's dashboard.
|
|
39
|
+
*/
|
|
40
|
+
workflowId: WORKFLOW_ID,
|
|
41
|
+
/**
|
|
42
|
+
* The unique identifier to associate this used to.
|
|
43
|
+
* This id is used to differenciate users on ComPilot and will be
|
|
44
|
+
* given back to you on every webhook we send.
|
|
45
|
+
*/
|
|
46
|
+
externalUserId: "35194",
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Please find below an example endpoint using express:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
const apiClient = createApiClient({
|
|
54
|
+
apiKey: API_KEY,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
app.get('/my-compilot-auth', (req, res) => {
|
|
58
|
+
const userId = req.userId;
|
|
59
|
+
const authSession = await apiClient.createSession({
|
|
60
|
+
workflowId: WORKFLOW_ID,
|
|
61
|
+
externalUserId: userId,
|
|
62
|
+
});
|
|
63
|
+
res.json(authSession);
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Web3 auth
|
|
68
|
+
|
|
69
|
+
TODO
|