@nexus-cross/pop 1.3.10-beta.2

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,102 @@
1
+ import { S as SafeDropChainPort, a as SafeDropApiPort, C as CryptoPort, D as DepositParams, b as DepositResult, B as BatchClaimParams, c as BatchClaimResult, d as ClaimSignerPort, W as WithdrawParams, e as WithdrawResult, R as RefundParams, f as RefundResult, A as Address, g as Secret } from './createSafeDrop-qoNG59jB.js';
2
+ export { h as BatchClaimSignature, i as DropInbox, j as DropSender, k as DropState, E as Envelope, H as Hex, l as HistoryEntry, m as HistoryPage, I as Id, L as LeaderboardEntry, O as OAuthProof, P as PendingDrop, n as PopEventName, o as SafeDrop, p as SafeDropConfig, q as SafeDropDeps, r as SafeDropError, s as SafeDropErrorCode, t as SecretHash, u as SocialIdentifier, v as SocialProvider, X as XConnection, w as createSafeDrop } from './createSafeDrop-qoNG59jB.js';
3
+ export { X as XAuthPort, a as XTokenResult } from './XAuthPort-BNJePosj.js';
4
+
5
+ /**
6
+ * 예치: 임시 claim 지갑 생성 → secretHash 커밋 → (permit | approve) → deposit →
7
+ * 수령 링크 생성. chain 어댑터가 depositWithPermit을 구현하면 approve tx를 생략한다.
8
+ * secret은 링크 fragment에만 담기고 어떤 포트로도 전송되지 않는다.
9
+ * (expiry/salt는 컨트랙트가 결정.)
10
+ */
11
+ declare class DepositUseCase {
12
+ private readonly chain;
13
+ private readonly api;
14
+ private readonly crypto;
15
+ /** 수령 링크 base URL. */
16
+ private readonly claimBaseUrl;
17
+ constructor(chain: SafeDropChainPort, api: SafeDropApiPort, crypto: CryptoPort,
18
+ /** 수령 링크 base URL. */
19
+ claimBaseUrl: string);
20
+ execute(params: DepositParams): Promise<DepositResult>;
21
+ /** permit 미지원 배포본: ERC20 approve tx → deposit tx. */
22
+ private approveThenDeposit;
23
+ }
24
+
25
+ /**
26
+ * 일괄 수령: 한 id에 쌓인 드롭 전부를 validator 서명 1건으로 회수한다.
27
+ * 개별 수령과 달리 secret이 필요 없다 — 게이트는 validator 서명이다.
28
+ *
29
+ * 흐름 (온체인 계약이 정한 순서 그대로):
30
+ * 1. nonce = validatorNonceById(keccak256(utf8(id))) ← id를 **해시**로 키잉
31
+ * 2. 백엔드에 (id, nonce, deadline) + X 토큰으로 서명 요청
32
+ * → recipient는 **응답값**을 쓴다(SIWE 주소에 바인딩되어 서명됨)
33
+ * 3. digest = validatorClaimDigest(recipient, id, nonce, deadline) ← 온체인 값
34
+ * recover(digest, signature) == validator() 인지 **가스 전에** 검증
35
+ * 4. liveDropCountById(id)이 0이 될 때까지 withdrawByValidator(..., maxCount, sig)
36
+ * 반복. maxCount는 서명 대상이 아니라 페이지 크기 → **서명 재사용**.
37
+ *
38
+ * 3번이 이 usecase의 존재 이유다: 백엔드가 다른 domain/type/nonce/recipient로
39
+ * 서명하면 온체인에서는 `ECDSAInvalidSignature`로만 드러나 원인을 못 찾는다.
40
+ */
41
+ declare class BatchClaimUseCase {
42
+ private readonly chain;
43
+ private readonly api;
44
+ private readonly crypto;
45
+ /** 테스트 주입용 시계. 기본 Date.now(). */
46
+ private readonly now;
47
+ constructor(chain: SafeDropChainPort, api: SafeDropApiPort, crypto: CryptoPort,
48
+ /** 테스트 주입용 시계. 기본 Date.now(). */
49
+ now?: () => number);
50
+ execute(params: BatchClaimParams): Promise<BatchClaimResult>;
51
+ /**
52
+ * 일괄 수령의 목적지가 **개별 수령으로 이미 확정된 주소**인지 온체인에서 확인한다.
53
+ * `claimedRecipientOf(id)`가 zero면 이 id는 아직 개별 수령을 하지 않은 상태 —
54
+ * API의 `has_claimed_before` 게이트와 같은 조건이다(첫 수령은 개별로).
55
+ * 어댑터가 이 read를 지원하지 않으면 검사를 생략한다(플로우는 유지).
56
+ */
57
+ private assertRecipientPinnedOnChain;
58
+ /**
59
+ * 사전 검증. `recoverAddress`가 없는 CryptoPort면 조용히 건너뛴다 — 최종 관문은
60
+ * 어차피 컨트랙트이고, 이 검사는 "가스 쓰기 전에 원인을 알려주는" 용도다.
61
+ */
62
+ private assertSignedByValidator;
63
+ private liveCount;
64
+ }
65
+
66
+ /**
67
+ * 수령: drops(claimAddr)에서 id·salt 조회 → claimDigest 읽기 → 임시 키로 digest
68
+ * raw 서명 → withdraw tx(임시 지갑이 직접 전송, 가스 대납). id/salt는 온체인
69
+ * 드롭 값을 그대로 써서 IdMismatch/SaltMismatch를 원천 차단한다.
70
+ */
71
+ declare class WithdrawUseCase {
72
+ private readonly chain;
73
+ private readonly signer;
74
+ constructor(chain: SafeDropChainPort, signer: ClaimSignerPort);
75
+ execute(params: WithdrawParams): Promise<WithdrawResult>;
76
+ }
77
+
78
+ /** 환불: 만료 후 sponsor(msg.sender)만 호출 가능. 만료/권한 검증은 컨트랙트가 최종 강제. */
79
+ declare class RefundUseCase {
80
+ private readonly chain;
81
+ constructor(chain: SafeDropChainPort);
82
+ execute(params: RefundParams): Promise<RefundResult>;
83
+ }
84
+
85
+ declare function buildWithdrawLink(params: {
86
+ /** claim 페이지 base URL. 예: https://one-pop.example/claim */
87
+ baseUrl: string;
88
+ sender: Address;
89
+ secret: Secret;
90
+ }): string;
91
+ declare function parseWithdrawLink(href: string): {
92
+ sender: Address | null;
93
+ secret: Secret | null;
94
+ };
95
+ /** X DM 안내 문구. */
96
+ declare function buildDmText(claimUrl: string): string;
97
+ /** X DM 작성창 URL. recipientId가 있으면 대상 지정, 없으면 수신자 선택 화면. */
98
+ declare function buildComposeUrl(text: string, recipientId?: string): string;
99
+
100
+ declare function normalizeHandle(handle: string): string;
101
+
102
+ export { Address, BatchClaimParams, BatchClaimResult, BatchClaimUseCase, ClaimSignerPort, CryptoPort, DepositParams, DepositResult, DepositUseCase, RefundParams, RefundResult, RefundUseCase, SafeDropApiPort, SafeDropChainPort, Secret, WithdrawParams, WithdrawResult, WithdrawUseCase, buildComposeUrl, buildDmText, buildWithdrawLink, normalizeHandle, parseWithdrawLink };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a as r,b as e,c as o,d as t,e as p,f as a,g as s,h as i,i as f,j as m,k as n}from"./chunk-KEW4FB4S.js";export{i as BatchClaimUseCase,s as DepositUseCase,m as RefundUseCase,r as SafeDropError,f as WithdrawUseCase,a as buildComposeUrl,p as buildDmText,o as buildWithdrawLink,n as createSafeDrop,e as normalizeHandle,t as parseWithdrawLink};
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { o as SafeDrop } from '../createSafeDrop-qoNG59jB.js';
4
+
5
+ interface SafeDropProviderProps {
6
+ client: SafeDrop;
7
+ children?: ReactNode;
8
+ }
9
+ declare function SafeDropProvider({ client, children }: SafeDropProviderProps): react.FunctionComponentElement<react.ProviderProps<SafeDrop | null>>;
10
+ declare function useSafeDrop(): SafeDrop;
11
+
12
+ export { SafeDropProvider, type SafeDropProviderProps, useSafeDrop };
@@ -0,0 +1 @@
1
+ import{createContext as t,createElement as p,useContext as a}from"react";var r=t(null);function f({client:e,children:o}){return p(r.Provider,{value:e},o)}function i(){let e=a(r);if(!e)throw new Error("useSafeDrop must be used within <SafeDropProvider>");return e}export{f as SafeDropProvider,i as useSafeDrop};
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@nexus-cross/pop",
3
+ "version": "1.3.10-beta.2",
4
+ "description": "pop — framework-agnostic core + React adapter.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./react": {
14
+ "types": "./dist/react/index.d.ts",
15
+ "import": "./dist/react/index.js"
16
+ },
17
+ "./adapters": {
18
+ "types": "./dist/adapters/index.d.ts",
19
+ "import": "./dist/adapters/index.js"
20
+ },
21
+ "./AGENTS.md": "./AGENTS.md",
22
+ "./openapi.json": "./src/infrastructure/openapi.json"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "AGENTS.md",
27
+ "src/infrastructure/openapi.json"
28
+ ],
29
+ "sideEffects": false,
30
+ "publishConfig": {
31
+ "registry": "https://registry.npmjs.org",
32
+ "access": "public"
33
+ },
34
+ "peerDependencies": {
35
+ "react": "^18.0.0 || ^19.0.0",
36
+ "viem": "^2.0.0"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "react": {
40
+ "optional": true
41
+ },
42
+ "viem": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@types/react": "^19.0.0",
48
+ "react": "^19.0.0",
49
+ "tsup": "^8.4.0",
50
+ "typescript": "^5.7.0",
51
+ "viem": "^2.21.0"
52
+ },
53
+ "license": "MIT",
54
+ "scripts": {
55
+ "build": "tsup",
56
+ "dev": "tsup --watch",
57
+ "test": "vitest run",
58
+ "typecheck": "tsc --noEmit"
59
+ }
60
+ }