@keyringnetwork/keyring-connect-sdk 0.0.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 @@
1
+ export declare const EXTENSION_ID = "dadlipjhdmhncgadnfhbebmpgfkmhhhk";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXTENSION_ID = void 0;
4
+ exports.EXTENSION_ID = 'dadlipjhdmhncgadnfhbebmpgfkmhhhk';
package/dist/env.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const ENV: {
2
+ EXTENSION_ID: string;
3
+ };
package/dist/env.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENV = void 0;
4
+ exports.ENV = {
5
+ EXTENSION_ID: 'dadlipjhdmhncgadnfhbebmpgfkmhhhk',
6
+ };
@@ -0,0 +1,2 @@
1
+ export { default as KeyringConnectSDK } from './main';
2
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.KeyringConnectSDK = void 0;
21
+ var main_1 = require("./main");
22
+ Object.defineProperty(exports, "KeyringConnectSDK", { enumerable: true, get: function () { return __importDefault(main_1).default; } });
23
+ __exportStar(require("./types"), exports);
package/dist/main.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { ExtensionStatusData, LaunchKeyringConnectData } from './types';
2
+ export default class KeyringConnectSDK {
3
+ static launchKeyringConnect(data: LaunchKeyringConnectData): Promise<void>;
4
+ static isKeyringConnectInstalled(): Promise<boolean>;
5
+ static getExtensionState(): Promise<ExtensionStatusData>;
6
+ }
package/dist/main.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const env_1 = require("./env");
13
+ const types_1 = require("./types");
14
+ class KeyringConnectSDK {
15
+ static launchKeyringConnect(data) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const keyringConnectAvailable = yield this.isKeyringConnectInstalled();
18
+ if (!keyringConnectAvailable) {
19
+ throw new Error('Keyring Connect is not installed');
20
+ }
21
+ console.log('launching keyring connect');
22
+ window.postMessage({ type: types_1.EVENT_ACTIONS.LAUNCH_KEYRING_CONNECT, data }, '*');
23
+ });
24
+ }
25
+ static isKeyringConnectInstalled() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const url = `chrome-extension://${env_1.ENV.EXTENSION_ID}/icon/16.png`;
29
+ const { statusText } = yield fetch(url);
30
+ if (statusText === 'OK') {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+ catch (error) {
36
+ return false;
37
+ }
38
+ });
39
+ }
40
+ static getExtensionState() {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ return new Promise((resolve) => {
43
+ window.addEventListener('message', (event) => {
44
+ if (event.data.type === types_1.EVENT_ACTIONS.KEYRING_CONNECT_STATUS) {
45
+ resolve(event.data.data);
46
+ }
47
+ });
48
+ window.postMessage({ type: types_1.EVENT_ACTIONS.GET_STATUS }, '*');
49
+ });
50
+ });
51
+ }
52
+ }
53
+ exports.default = KeyringConnectSDK;
@@ -0,0 +1,54 @@
1
+ export declare enum EVENT_ACTIONS {
2
+ LAUNCH_KEYRING_CONNECT = "LAUNCH_KEYRING_CONNECT",
3
+ GET_STATUS = "GET_STATUS",
4
+ KEYRING_CONNECT_STATUS = "KEYRING_CONNECT_STATUS"
5
+ }
6
+ export type LaunchKeyringConnectData = {
7
+ /**
8
+ * The name of the client.
9
+ */
10
+ client_name: string;
11
+ /**
12
+ * The URL of the client app which the chrome extension will communicate with.
13
+ */
14
+ client_app_url: string;
15
+ /**
16
+ * The URL of the client logo.
17
+ */
18
+ client_logo_url: string;
19
+ /**
20
+ * The policy ID of the client.
21
+ */
22
+ client_policy_id: number;
23
+ };
24
+ export type ExtensionStatus = 'idle' | 'mounted' | 'proving' | 'prove_success' | 'error';
25
+ export type AttestationStatus = 'onboarding_required' | 'onboarding_pending' | 'attestation_ready' | 'non_compliant';
26
+ export type CredentialStatus = 'expired' | 'valid' | 'none';
27
+ export type UserState = {
28
+ /**
29
+ * Off-chain attestation status.
30
+ */
31
+ attestation_status: AttestationStatus;
32
+ /**
33
+ * On-chain keyring credential status.
34
+ */
35
+ credential_status: CredentialStatus;
36
+ /**
37
+ * Connected wallet address of the user.
38
+ */
39
+ wallet_address: string;
40
+ /**
41
+ * Keyring User ID.
42
+ */
43
+ user_id: string;
44
+ /**
45
+ * Keyring Entity ID.
46
+ */
47
+ entity_id: string;
48
+ };
49
+ export interface ExtensionStatusData {
50
+ status: ExtensionStatus;
51
+ manifest?: any;
52
+ error?: string;
53
+ user?: UserState;
54
+ }
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EVENT_ACTIONS = void 0;
4
+ var EVENT_ACTIONS;
5
+ (function (EVENT_ACTIONS) {
6
+ EVENT_ACTIONS["LAUNCH_KEYRING_CONNECT"] = "LAUNCH_KEYRING_CONNECT";
7
+ EVENT_ACTIONS["GET_STATUS"] = "GET_STATUS";
8
+ EVENT_ACTIONS["KEYRING_CONNECT_STATUS"] = "KEYRING_CONNECT_STATUS";
9
+ })(EVENT_ACTIONS || (exports.EVENT_ACTIONS = EVENT_ACTIONS = {}));
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@keyringnetwork/keyring-connect-sdk",
3
+ "version": "0.0.1",
4
+ "description": "An SDK for interacting with Keyring Connect browser extension",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "dev": "tsc --watch"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "ts-node": "^10.9.2",
19
+ "typescript": "^5.6.3"
20
+ }
21
+ }