@dainprotocol/service-sdk 2.0.94 → 2.1.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 +29 -0
- package/dist/client/api-sdk.d.ts +7 -1
- package/dist/client/api-sdk.js +2 -2
- package/dist/client/api-sdk.js.map +1 -1
- package/dist/client/client-auth.d.ts +38 -0
- package/dist/client/client-auth.js +131 -2
- package/dist/client/client-auth.js.map +1 -1
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.js +92 -25
- package/dist/client/client.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +252 -0
- package/dist/client/types.js +159 -31
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/crypto-plugin.d.ts +26 -0
- package/dist/plugins/crypto-plugin.js +44 -4
- package/dist/plugins/crypto-plugin.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/index.js.map +1 -1
- package/dist/protocol/account.d.ts +91 -0
- package/dist/protocol/account.js +3 -0
- package/dist/protocol/account.js.map +1 -0
- package/dist/protocol/grants.d.ts +34 -0
- package/dist/protocol/grants.js +3 -0
- package/dist/protocol/grants.js.map +1 -0
- package/dist/protocol/index.d.ts +8 -0
- package/dist/protocol/index.js +12 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/payments.d.ts +53 -0
- package/dist/protocol/payments.js +3 -0
- package/dist/protocol/payments.js.map +1 -0
- package/dist/protocol/permissions.d.ts +21 -0
- package/dist/protocol/permissions.js +3 -0
- package/dist/protocol/permissions.js.map +1 -0
- package/dist/protocol/programs.d.ts +44 -0
- package/dist/protocol/programs.js +46 -0
- package/dist/protocol/programs.js.map +1 -0
- package/dist/protocol/registry.d.ts +43 -0
- package/dist/protocol/registry.js +3 -0
- package/dist/protocol/registry.js.map +1 -0
- package/dist/protocol/runtime.d.ts +15 -0
- package/dist/protocol/runtime.js +3 -0
- package/dist/protocol/runtime.js.map +1 -0
- package/dist/protocol/transactions.d.ts +63 -0
- package/dist/protocol/transactions.js +3 -0
- package/dist/protocol/transactions.js.map +1 -0
- package/dist/service/auth.d.ts +15 -1
- package/dist/service/auth.js +156 -35
- package/dist/service/auth.js.map +1 -1
- package/dist/service/core.js +9 -0
- package/dist/service/core.js.map +1 -1
- package/dist/service/index.d.ts +1 -0
- package/dist/service/index.js +1 -0
- package/dist/service/index.js.map +1 -1
- package/dist/service/nodeService.js +30 -2
- package/dist/service/nodeService.js.map +1 -1
- package/dist/service/server.js +733 -242
- package/dist/service/server.js.map +1 -1
- package/dist/service/service.js +6 -8
- package/dist/service/service.js.map +1 -1
- package/dist/service/types.d.ts +48 -34
- package/package.json +20 -7
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { DainActionGrant } from "./grants";
|
|
2
|
+
import type { SMART_ACCOUNT_MEMBER_CATEGORY_BITS, SMART_ACCOUNT_MEMBER_PERMISSION_BITS } from "./programs";
|
|
3
|
+
export type DainAccountType = "dain_account" | "dain_group";
|
|
4
|
+
export type DainAccountState = "reserved" | "funded" | "creating" | "created" | "migration_required" | "suspended";
|
|
5
|
+
export type DainNetwork = "mainnet" | "devnet" | "testnet" | "localnet";
|
|
6
|
+
export type DainSmartAccountPermission = keyof typeof SMART_ACCOUNT_MEMBER_PERMISSION_BITS;
|
|
7
|
+
export type DainSmartAccountMemberCategory = keyof typeof SMART_ACCOUNT_MEMBER_CATEGORY_BITS;
|
|
8
|
+
export interface DainSmartAccountVaultDelegation {
|
|
9
|
+
vaultId: number;
|
|
10
|
+
expirationUnixSeconds: number | string;
|
|
11
|
+
}
|
|
12
|
+
export interface DainSmartAccountMember {
|
|
13
|
+
key: string;
|
|
14
|
+
permissions: DainSmartAccountPermission[];
|
|
15
|
+
categories: DainSmartAccountMemberCategory[];
|
|
16
|
+
permissionMask?: number;
|
|
17
|
+
categoryMask?: number;
|
|
18
|
+
vaultDelegations?: DainSmartAccountVaultDelegation[];
|
|
19
|
+
}
|
|
20
|
+
export interface DainSmartAccountDataPermission {
|
|
21
|
+
organizationId?: number | string;
|
|
22
|
+
agentId?: number;
|
|
23
|
+
key?: string;
|
|
24
|
+
permissionMask: string;
|
|
25
|
+
}
|
|
26
|
+
export type DainLinkedWalletKind = "smart_account_vault" | "privy_extension" | "session_signer" | "external_wallet" | "agent_wallet";
|
|
27
|
+
export interface DainSmartAccountRef {
|
|
28
|
+
chain: "solana";
|
|
29
|
+
network: DainNetwork;
|
|
30
|
+
programId: string;
|
|
31
|
+
pda: string;
|
|
32
|
+
ephemeralKey?: string;
|
|
33
|
+
threshold?: number;
|
|
34
|
+
timeLockSeconds?: number;
|
|
35
|
+
transactionId?: number | string;
|
|
36
|
+
vaults?: Record<string, string>;
|
|
37
|
+
members?: DainSmartAccountMember[];
|
|
38
|
+
dataPermissions?: DainSmartAccountDataPermission[];
|
|
39
|
+
}
|
|
40
|
+
export interface DainLinkedWallet {
|
|
41
|
+
id?: string;
|
|
42
|
+
kind: DainLinkedWalletKind;
|
|
43
|
+
chain: string;
|
|
44
|
+
address: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
capabilities?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface DainAccountCapabilities {
|
|
49
|
+
solanaSmartAccount?: boolean;
|
|
50
|
+
externalWallets?: boolean;
|
|
51
|
+
externalSessionSigners?: boolean;
|
|
52
|
+
solanaAgentGrants?: boolean;
|
|
53
|
+
groupExternalActions?: boolean;
|
|
54
|
+
registryDiscovery?: boolean;
|
|
55
|
+
dataPermissions?: boolean;
|
|
56
|
+
payments?: boolean;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface DainAccountContext {
|
|
60
|
+
id: string;
|
|
61
|
+
type: DainAccountType;
|
|
62
|
+
state: DainAccountState;
|
|
63
|
+
username?: string;
|
|
64
|
+
smartAccount?: DainSmartAccountRef;
|
|
65
|
+
linkedWallets?: DainLinkedWallet[];
|
|
66
|
+
capabilities?: DainAccountCapabilities;
|
|
67
|
+
}
|
|
68
|
+
export interface DainGroupMemberRef {
|
|
69
|
+
id: string;
|
|
70
|
+
kind: "passkey" | "key" | "user" | "nft" | "agent" | "organization";
|
|
71
|
+
label?: string;
|
|
72
|
+
address?: string;
|
|
73
|
+
weight?: number;
|
|
74
|
+
permissions?: DainSmartAccountPermission[];
|
|
75
|
+
categories?: DainSmartAccountMemberCategory[];
|
|
76
|
+
}
|
|
77
|
+
export interface DainGroupContext extends DainAccountContext {
|
|
78
|
+
type: "dain_group";
|
|
79
|
+
members?: DainGroupMemberRef[];
|
|
80
|
+
threshold?: number;
|
|
81
|
+
}
|
|
82
|
+
export interface DainAuthContext {
|
|
83
|
+
subject: string;
|
|
84
|
+
issuer?: string;
|
|
85
|
+
sessionId?: string;
|
|
86
|
+
scopes?: string[];
|
|
87
|
+
roles?: string[];
|
|
88
|
+
permissions?: string[];
|
|
89
|
+
grants?: DainActionGrant[];
|
|
90
|
+
source?: "dain_id" | "dain_client" | "service" | "api_key";
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/protocol/account.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DainDataPermissionGrant } from "./permissions";
|
|
2
|
+
import type { DainAgentRegistryRef } from "./registry";
|
|
3
|
+
export type DainGrantStatus = "draft" | "active" | "paused" | "revoked" | "expired";
|
|
4
|
+
export type DainGrantScope = "services.interact" | "data.read" | "data.write" | "tx.build" | "tx.relay" | "wallets.read" | "wallets.sign" | "payments.create" | "payments.claim" | string;
|
|
5
|
+
export interface DainGrantLimit {
|
|
6
|
+
kind: "spend" | "calls" | "period" | "chains" | "tools";
|
|
7
|
+
value: string | number | string[];
|
|
8
|
+
periodSeconds?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface DainGrantPolicy {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
scopes: DainGrantScope[];
|
|
16
|
+
limits?: DainGrantLimit[];
|
|
17
|
+
toolIds?: string[];
|
|
18
|
+
dataFieldIds?: string[];
|
|
19
|
+
paymentOfferIds?: string[];
|
|
20
|
+
expiresInSeconds?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface DainActionGrant {
|
|
23
|
+
id: string;
|
|
24
|
+
accountId: string;
|
|
25
|
+
smartAccountPDA?: string;
|
|
26
|
+
status: DainGrantStatus;
|
|
27
|
+
scopes: DainGrantScope[];
|
|
28
|
+
agent?: DainAgentRegistryRef;
|
|
29
|
+
serviceUrl?: string;
|
|
30
|
+
dataPermissions?: DainDataPermissionGrant[];
|
|
31
|
+
limits?: DainGrantLimit[];
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
expiresAt?: string;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/protocol/grants.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./account"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./grants"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./payments"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./permissions"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./programs"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./registry"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./runtime"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./transactions"), exports);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,mDAAyB;AACzB,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,qDAA2B;AAC3B,oDAA0B;AAC1B,yDAA+B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DainAgentRegistryRef } from "./registry";
|
|
2
|
+
import type { SMART_ACCOUNT_PAYMENT_STATUS_BITS, SMART_ACCOUNT_PAYMENT_TYPE } from "./programs";
|
|
3
|
+
export type DainPaymentKind = "one_time" | "pure_subscription" | "hybrid_subscription" | "pay_as_you_go";
|
|
4
|
+
export type DainPaymentState = "draft" | "active" | "pending_cancellation" | "cancelled" | "expired" | "terminated" | "reviewed";
|
|
5
|
+
export type DainPaymentStatusFlag = keyof typeof SMART_ACCOUNT_PAYMENT_STATUS_BITS;
|
|
6
|
+
export type DainPaymentProgramType = keyof typeof SMART_ACCOUNT_PAYMENT_TYPE;
|
|
7
|
+
export interface DainPaymentProgramStatus {
|
|
8
|
+
mask: number;
|
|
9
|
+
flags?: DainPaymentStatusFlag[];
|
|
10
|
+
}
|
|
11
|
+
export interface DainPaymentMint {
|
|
12
|
+
chain: "solana";
|
|
13
|
+
mint: string;
|
|
14
|
+
decimals?: number;
|
|
15
|
+
symbol?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DainPaymentOffer {
|
|
18
|
+
id: string;
|
|
19
|
+
kind: DainPaymentKind;
|
|
20
|
+
agent?: DainAgentRegistryRef;
|
|
21
|
+
organizationId?: number | string;
|
|
22
|
+
agentId?: number;
|
|
23
|
+
vaultId?: number;
|
|
24
|
+
mint: DainPaymentMint;
|
|
25
|
+
amount: string;
|
|
26
|
+
baseAmount?: string;
|
|
27
|
+
periodSeconds?: number;
|
|
28
|
+
trialSeconds?: number;
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DainPaymentSubscription {
|
|
32
|
+
id: string;
|
|
33
|
+
state: DainPaymentState;
|
|
34
|
+
programStatus?: DainPaymentProgramStatus;
|
|
35
|
+
programType?: DainPaymentProgramType;
|
|
36
|
+
offerId?: string;
|
|
37
|
+
accountId: string;
|
|
38
|
+
smartAccountPDA: string;
|
|
39
|
+
agent?: DainAgentRegistryRef;
|
|
40
|
+
organizationId?: number | string;
|
|
41
|
+
agentId?: number;
|
|
42
|
+
vaultId?: number;
|
|
43
|
+
mint?: string;
|
|
44
|
+
paymentAccount?: string;
|
|
45
|
+
ephemeralKey?: string;
|
|
46
|
+
currentPeriodStart?: string;
|
|
47
|
+
currentPeriodEnd?: string;
|
|
48
|
+
remainingAmount?: string;
|
|
49
|
+
amount?: string;
|
|
50
|
+
baseAmount?: string;
|
|
51
|
+
baseAmountPaid?: string;
|
|
52
|
+
scheduledTerminationTime?: string;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/protocol/payments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type DainDataAccessMode = "read" | "write";
|
|
2
|
+
export type DainDataSensitivity = "public" | "personal" | "financial" | "credential" | "secret";
|
|
3
|
+
export interface DainDataFieldRequirement {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
mode: DainDataAccessMode;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
sensitivity?: DainDataSensitivity;
|
|
10
|
+
purpose?: string;
|
|
11
|
+
retention?: "none" | "session" | "automation" | "service";
|
|
12
|
+
}
|
|
13
|
+
export interface DainDataPermissionGrant {
|
|
14
|
+
id: string;
|
|
15
|
+
serviceId?: string;
|
|
16
|
+
agentId?: string;
|
|
17
|
+
accountId?: string;
|
|
18
|
+
fields: DainDataFieldRequirement[];
|
|
19
|
+
expiresAt?: string;
|
|
20
|
+
revokedAt?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/protocol/permissions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const DAIN_PROGRAM_IDS: {
|
|
2
|
+
readonly registry: "4Phn622SNGS2oA9B2uJzDwFSMdKmBe1JzFeWB37b4XuQ";
|
|
3
|
+
readonly smartAccount: "21ZvHhaFLsTGkEWZmyyt7NrY8XQQJjArgCwwEgJ8NXdr";
|
|
4
|
+
};
|
|
5
|
+
export declare const DAIN_PROGRAM_SEEDS: {
|
|
6
|
+
readonly registry: "registry";
|
|
7
|
+
readonly organization: "organization";
|
|
8
|
+
readonly agent: "agent";
|
|
9
|
+
readonly smartAccount: "smart_account";
|
|
10
|
+
readonly vault: "vault";
|
|
11
|
+
readonly payments: "payments";
|
|
12
|
+
readonly passkey: "passkey";
|
|
13
|
+
};
|
|
14
|
+
export declare const SMART_ACCOUNT_MEMBER_PERMISSION_BITS: {
|
|
15
|
+
readonly initiate: number;
|
|
16
|
+
readonly vote: number;
|
|
17
|
+
readonly execute: number;
|
|
18
|
+
readonly review: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const SMART_ACCOUNT_MEMBER_CATEGORY_BITS: {
|
|
21
|
+
readonly user: number;
|
|
22
|
+
readonly agent: number;
|
|
23
|
+
readonly organization: number;
|
|
24
|
+
readonly passkey: number;
|
|
25
|
+
readonly nft: number;
|
|
26
|
+
};
|
|
27
|
+
export declare const SMART_ACCOUNT_PAYMENT_STATUS_BITS: {
|
|
28
|
+
readonly active: number;
|
|
29
|
+
readonly cancelled: number;
|
|
30
|
+
readonly terminated: number;
|
|
31
|
+
readonly expired: number;
|
|
32
|
+
readonly reviewed: number;
|
|
33
|
+
readonly activated: number;
|
|
34
|
+
readonly pendingCancellation: number;
|
|
35
|
+
readonly baseClaimed: number;
|
|
36
|
+
};
|
|
37
|
+
export declare const SMART_ACCOUNT_PAYMENT_TYPE: {
|
|
38
|
+
readonly oneTime: 0;
|
|
39
|
+
readonly pureSubscription: 1;
|
|
40
|
+
readonly hybridSubscription: 2;
|
|
41
|
+
readonly payAsYouGo: 3;
|
|
42
|
+
};
|
|
43
|
+
export type SmartAccountProgramInstruction = "smart_account_create" | "proposal_activate" | "proposal_approve" | "proposal_reject" | "proposal_cancel" | "vault_transaction_create" | "vault_transaction_create_from_buffer" | "vault_transaction_execute" | "batch_create" | "batch_add_transaction" | "batch_execute_transaction" | "transaction_buffer_create" | "transaction_buffer_extend" | "transaction_buffer_close" | "internal_transaction_create" | "internal_transaction_execute" | "internal_spending_limit_usage" | "payments_transaction_create" | "payments_transaction_execute" | "payments_claim" | "payments_claim_rent" | "payments_submit_review" | "payments_terminate";
|
|
44
|
+
export type RegistryProgramInstruction = "registry_initialize" | "registry_update" | "registry_update_base_fees" | "registry_update_vip_levels_agent" | "registry_update_vip_levels_organization" | "registry_add_new_admin" | "registry_accept_new_admin" | "registry_remove_pending_new_admin" | "registry_lock" | "organization_reserve" | "organization_create" | "organization_update" | "organization_verify" | "organization_add_provider" | "organization_remove_provider" | "organization_freeze_agent" | "organization_defreeze_agent" | "organization_children_create" | "organization_child_update" | "organization_child_freeze" | "organization_child_defreeze" | "organization_claim_tokens" | "organization_children_claim_tokens" | "agent_reserve" | "agent_create" | "agent_update" | "agent_update_business_data" | "agent_verify" | "agent_add_payment_mint" | "agent_claim_tokens" | "reputation_create_agent" | "reputation_submit_review" | "reputation_claim_payment";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SMART_ACCOUNT_PAYMENT_TYPE = exports.SMART_ACCOUNT_PAYMENT_STATUS_BITS = exports.SMART_ACCOUNT_MEMBER_CATEGORY_BITS = exports.SMART_ACCOUNT_MEMBER_PERMISSION_BITS = exports.DAIN_PROGRAM_SEEDS = exports.DAIN_PROGRAM_IDS = void 0;
|
|
4
|
+
exports.DAIN_PROGRAM_IDS = {
|
|
5
|
+
registry: "4Phn622SNGS2oA9B2uJzDwFSMdKmBe1JzFeWB37b4XuQ",
|
|
6
|
+
smartAccount: "21ZvHhaFLsTGkEWZmyyt7NrY8XQQJjArgCwwEgJ8NXdr",
|
|
7
|
+
};
|
|
8
|
+
exports.DAIN_PROGRAM_SEEDS = {
|
|
9
|
+
registry: "registry",
|
|
10
|
+
organization: "organization",
|
|
11
|
+
agent: "agent",
|
|
12
|
+
smartAccount: "smart_account",
|
|
13
|
+
vault: "vault",
|
|
14
|
+
payments: "payments",
|
|
15
|
+
passkey: "passkey",
|
|
16
|
+
};
|
|
17
|
+
exports.SMART_ACCOUNT_MEMBER_PERMISSION_BITS = {
|
|
18
|
+
initiate: 1 << 0,
|
|
19
|
+
vote: 1 << 1,
|
|
20
|
+
execute: 1 << 2,
|
|
21
|
+
review: 1 << 3,
|
|
22
|
+
};
|
|
23
|
+
exports.SMART_ACCOUNT_MEMBER_CATEGORY_BITS = {
|
|
24
|
+
user: 1 << 0,
|
|
25
|
+
agent: 1 << 1,
|
|
26
|
+
organization: 1 << 2,
|
|
27
|
+
passkey: 1 << 3,
|
|
28
|
+
nft: 1 << 4,
|
|
29
|
+
};
|
|
30
|
+
exports.SMART_ACCOUNT_PAYMENT_STATUS_BITS = {
|
|
31
|
+
active: 1 << 0,
|
|
32
|
+
cancelled: 1 << 1,
|
|
33
|
+
terminated: 1 << 2,
|
|
34
|
+
expired: 1 << 3,
|
|
35
|
+
reviewed: 1 << 4,
|
|
36
|
+
activated: 1 << 5,
|
|
37
|
+
pendingCancellation: 1 << 6,
|
|
38
|
+
baseClaimed: 1 << 7,
|
|
39
|
+
};
|
|
40
|
+
exports.SMART_ACCOUNT_PAYMENT_TYPE = {
|
|
41
|
+
oneTime: 0,
|
|
42
|
+
pureSubscription: 1,
|
|
43
|
+
hybridSubscription: 2,
|
|
44
|
+
payAsYouGo: 3,
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=programs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"programs.js","sourceRoot":"","sources":["../../src/protocol/programs.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,8CAA8C;IACxD,YAAY,EAAE,8CAA8C;CACpD,CAAC;AAEE,QAAA,kBAAkB,GAAG;IAChC,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,eAAe;IAC7B,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC;AAEE,QAAA,oCAAoC,GAAG;IAClD,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,IAAI,CAAC;IACZ,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,MAAM,EAAE,CAAC,IAAI,CAAC;CACN,CAAC;AAEE,QAAA,kCAAkC,GAAG;IAChD,IAAI,EAAE,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,CAAC,IAAI,CAAC;IACb,YAAY,EAAE,CAAC,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,GAAG,EAAE,CAAC,IAAI,CAAC;CACH,CAAC;AAEE,QAAA,iCAAiC,GAAG;IAC/C,MAAM,EAAE,CAAC,IAAI,CAAC;IACd,SAAS,EAAE,CAAC,IAAI,CAAC;IACjB,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,CAAC,IAAI,CAAC;IACjB,mBAAmB,EAAE,CAAC,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,IAAI,CAAC;CACX,CAAC;AAEE,QAAA,0BAA0B,GAAG;IACxC,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,CAAC;IACnB,kBAAkB,EAAE,CAAC;IACrB,UAAU,EAAE,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DainDataFieldRequirement } from "./permissions";
|
|
2
|
+
import type { DainPaymentOffer } from "./payments";
|
|
3
|
+
import type { DAIN_PROGRAM_IDS } from "./programs";
|
|
4
|
+
import type { DainGrantPolicy, DainGrantScope } from "./grants";
|
|
5
|
+
export type DainRegistryId = number | string;
|
|
6
|
+
export type DainRegistryProgramId = typeof DAIN_PROGRAM_IDS.registry;
|
|
7
|
+
export type DainSmartAccountProgramId = typeof DAIN_PROGRAM_IDS.smartAccount;
|
|
8
|
+
export interface DainRegistryRef {
|
|
9
|
+
programId: string;
|
|
10
|
+
network: "mainnet" | "devnet" | "testnet" | "localnet";
|
|
11
|
+
address?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DainOrganizationRegistryRef {
|
|
14
|
+
id: DainRegistryId;
|
|
15
|
+
address?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
uri?: string;
|
|
19
|
+
verified?: boolean;
|
|
20
|
+
statusMask?: number;
|
|
21
|
+
reputationAddress?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface DainAgentRegistryRef {
|
|
24
|
+
organizationId: DainRegistryId;
|
|
25
|
+
agentId: number;
|
|
26
|
+
address?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
endpoint?: string;
|
|
30
|
+
verified?: boolean;
|
|
31
|
+
statusMask?: number;
|
|
32
|
+
signatories?: string[];
|
|
33
|
+
reputationAddress?: string;
|
|
34
|
+
organization?: DainOrganizationRegistryRef;
|
|
35
|
+
}
|
|
36
|
+
export interface DainServiceRegistryPolicy {
|
|
37
|
+
registry?: DainRegistryRef;
|
|
38
|
+
agent?: DainAgentRegistryRef;
|
|
39
|
+
requiredDataFields?: DainDataFieldRequirement[];
|
|
40
|
+
paymentOffers?: DainPaymentOffer[];
|
|
41
|
+
requiredScopes?: DainGrantScope[];
|
|
42
|
+
grantPolicies?: DainGrantPolicy[];
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/protocol/registry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DainAccountContext, DainAuthContext, DainGroupContext } from "./account";
|
|
2
|
+
import type { DainActionGrant } from "./grants";
|
|
3
|
+
import type { DainDataPermissionGrant } from "./permissions";
|
|
4
|
+
import type { DainServiceRegistryPolicy } from "./registry";
|
|
5
|
+
export interface DainRuntimeContext {
|
|
6
|
+
dainAccountId?: string;
|
|
7
|
+
dainGroupId?: string;
|
|
8
|
+
smartAccountPDA?: string;
|
|
9
|
+
account?: DainAccountContext;
|
|
10
|
+
group?: DainGroupContext;
|
|
11
|
+
auth?: DainAuthContext;
|
|
12
|
+
grants?: DainActionGrant[];
|
|
13
|
+
dataPermissions?: DainDataPermissionGrant[];
|
|
14
|
+
registryPolicy?: DainServiceRegistryPolicy;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/protocol/runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DainActionGrant } from "./grants";
|
|
2
|
+
import type { DainDataPermissionGrant } from "./permissions";
|
|
3
|
+
export type DainExecutionModel = "solana_smart_account" | "solana_agent_grant" | "external_session_signer" | "external_user_signature" | "offchain_typed_data";
|
|
4
|
+
export interface SmartAccountExecutionContext {
|
|
5
|
+
accountId: string;
|
|
6
|
+
smartAccountPDA: string;
|
|
7
|
+
registrySmartAccountPDA?: string;
|
|
8
|
+
vaultPDA?: string;
|
|
9
|
+
vaultId?: number;
|
|
10
|
+
proposalPDA?: string;
|
|
11
|
+
transactionPDA?: string;
|
|
12
|
+
transactionId?: number | string;
|
|
13
|
+
batchPDA?: string;
|
|
14
|
+
batchId?: number | string;
|
|
15
|
+
programId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DainOptionalPasskeyInput {
|
|
18
|
+
optionalClientDataJson: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DainSmartAccountCompiledInstruction {
|
|
21
|
+
programIdIndex: number;
|
|
22
|
+
accountIndexes: number[];
|
|
23
|
+
data: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DainSmartAccountMessageAlt {
|
|
26
|
+
accountKey: string;
|
|
27
|
+
writableIndexes: number[];
|
|
28
|
+
readonlyIndexes: number[];
|
|
29
|
+
}
|
|
30
|
+
export interface DainVaultTransactionMessage {
|
|
31
|
+
numSigners: number;
|
|
32
|
+
numWritableSigners: number;
|
|
33
|
+
numWritableNonSigners: number;
|
|
34
|
+
accountKeys: string[];
|
|
35
|
+
instructions: DainSmartAccountCompiledInstruction[];
|
|
36
|
+
alts?: DainSmartAccountMessageAlt[];
|
|
37
|
+
}
|
|
38
|
+
export interface DainTransactionAction {
|
|
39
|
+
id?: string;
|
|
40
|
+
chain: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
encodedTx?: string;
|
|
43
|
+
solanaMessage?: DainVaultTransactionMessage;
|
|
44
|
+
smartAccountInstruction?: "vault_transaction_create" | "vault_transaction_execute" | "batch_create" | "batch_execute_transaction" | "payments_transaction_create" | "payments_transaction_execute";
|
|
45
|
+
optionalPasskeyInput?: DainOptionalPasskeyInput;
|
|
46
|
+
typedData?: unknown;
|
|
47
|
+
target?: string;
|
|
48
|
+
value?: string;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface DainTransactionEnvelope {
|
|
52
|
+
id: string;
|
|
53
|
+
executionModel: DainExecutionModel;
|
|
54
|
+
accountAuthority?: string;
|
|
55
|
+
signatureProvider?: "passkey" | "smart_account" | "session_signer" | "user_wallet";
|
|
56
|
+
payer?: string;
|
|
57
|
+
smartAccount?: SmartAccountExecutionContext;
|
|
58
|
+
actions: DainTransactionAction[];
|
|
59
|
+
grants?: DainActionGrant[];
|
|
60
|
+
dataPermissions?: DainDataPermissionGrant[];
|
|
61
|
+
ui?: unknown;
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/protocol/transactions.ts"],"names":[],"mappings":""}
|
package/dist/service/auth.d.ts
CHANGED
|
@@ -26,8 +26,22 @@ export interface JWTVerificationResult {
|
|
|
26
26
|
error?: string;
|
|
27
27
|
}
|
|
28
28
|
export declare function extractBearerToken(authHeader: string | undefined): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Verify a JWT against the supplied PEM key or JWKS URL.
|
|
31
|
+
*
|
|
32
|
+
* `options.issuer` accepts a string or array of strings. During the
|
|
33
|
+
* dainid → dain-client cutover, callers should pass both issuers
|
|
34
|
+
* (`["dainid-oauth", "dain-client-oauth"]`) for the dual-acceptance
|
|
35
|
+
* window so in-flight tokens minted by either issuer continue to verify.
|
|
36
|
+
*
|
|
37
|
+
* When `publicKeyPEMOrUrl` is a URL, this function reads the JWT header
|
|
38
|
+
* `kid` and selects the matching key from the JWKS. If no `kid` is
|
|
39
|
+
* present in either the header or the JWKS, it falls back to trying
|
|
40
|
+
* every key in turn — supports both single-key (legacy) and multi-key
|
|
41
|
+
* (rotation overlap) JWKS shapes.
|
|
42
|
+
*/
|
|
29
43
|
export declare function verifyJWT(token: string, publicKeyPEMOrUrl: string, options?: {
|
|
30
|
-
issuer?: string;
|
|
44
|
+
issuer?: string | string[];
|
|
31
45
|
audience?: string | string[];
|
|
32
46
|
}): Promise<JWTVerificationResult>;
|
|
33
47
|
export interface ParsedAPIKey {
|