spaps-sdk 1.1.0 → 1.1.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.
- package/README.md +26 -14
- package/dist/index.js +3 -0
- package/dist/index.mjs +9 -0
- package/package.json +20 -7
package/README.md
CHANGED
|
@@ -71,17 +71,29 @@ See [PERMISSIONS.md](./PERMISSIONS.md) for React examples and complete documenta
|
|
|
71
71
|
## Installation
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
|
-
npm install
|
|
74
|
+
npm install spaps-sdk
|
|
75
75
|
# or
|
|
76
|
-
yarn add
|
|
76
|
+
yarn add spaps-sdk
|
|
77
|
+
# or
|
|
78
|
+
pnpm add spaps-sdk
|
|
77
79
|
```
|
|
78
80
|
|
|
81
|
+
### Compatibility
|
|
82
|
+
|
|
83
|
+
- ✅ **Node.js**: Fully supported (v14+) with automatic fetch polyfill
|
|
84
|
+
- ✅ **Browser**: Works in all modern browsers
|
|
85
|
+
- ✅ **TypeScript**: Full type definitions included
|
|
86
|
+
- ✅ **Next.js**: Server and client components supported
|
|
87
|
+
- ✅ **React Native**: Compatible with proper setup
|
|
88
|
+
|
|
89
|
+
The SDK automatically includes a `cross-fetch` polyfill for Node.js environments that don't have native fetch support.
|
|
90
|
+
|
|
79
91
|
## Quick Start
|
|
80
92
|
|
|
81
93
|
```javascript
|
|
82
|
-
import { SPAPSClient } from '
|
|
94
|
+
import { SPAPSClient } from 'spaps-sdk';
|
|
83
95
|
// or
|
|
84
|
-
const { SPAPSClient } = require('
|
|
96
|
+
const { SPAPSClient } = require('spaps-sdk');
|
|
85
97
|
|
|
86
98
|
// Auto-detects local mode - no API key needed for localhost!
|
|
87
99
|
const spaps = new SPAPSClient({
|
|
@@ -149,7 +161,7 @@ await spaps.recordUsage('api-call', 1);
|
|
|
149
161
|
### Production Mode
|
|
150
162
|
```javascript
|
|
151
163
|
const spaps = new SPAPSClient({
|
|
152
|
-
apiUrl: 'https://api.sweetpotato.
|
|
164
|
+
apiUrl: 'https://api.sweetpotato.dev',
|
|
153
165
|
apiKey: 'spaps_your_api_key_here',
|
|
154
166
|
timeout: 10000 // Optional timeout in ms
|
|
155
167
|
});
|
|
@@ -164,11 +176,11 @@ const spaps = new SPAPSClient();
|
|
|
164
176
|
### Environment Variables
|
|
165
177
|
```bash
|
|
166
178
|
# .env
|
|
167
|
-
SPAPS_API_URL=https://api.sweetpotato.
|
|
179
|
+
SPAPS_API_URL=https://api.sweetpotato.dev
|
|
168
180
|
SPAPS_API_KEY=spaps_your_api_key_here
|
|
169
181
|
|
|
170
182
|
# Next.js
|
|
171
|
-
NEXT_PUBLIC_SPAPS_API_URL=https://api.sweetpotato.
|
|
183
|
+
NEXT_PUBLIC_SPAPS_API_URL=https://api.sweetpotato.dev
|
|
172
184
|
```
|
|
173
185
|
|
|
174
186
|
## Helper Methods
|
|
@@ -195,16 +207,16 @@ await spaps.health()
|
|
|
195
207
|
All these work:
|
|
196
208
|
```javascript
|
|
197
209
|
// ES6 Import
|
|
198
|
-
import { SPAPSClient } from '
|
|
199
|
-
import SPAPSClient from '
|
|
210
|
+
import { SPAPSClient } from 'spaps-sdk';
|
|
211
|
+
import SPAPSClient from 'spaps-sdk';
|
|
200
212
|
|
|
201
213
|
// CommonJS
|
|
202
|
-
const { SPAPSClient } = require('
|
|
203
|
-
const SPAPSClient = require('
|
|
214
|
+
const { SPAPSClient } = require('spaps-sdk');
|
|
215
|
+
const SPAPSClient = require('spaps-sdk');
|
|
204
216
|
|
|
205
217
|
// Alternative names
|
|
206
|
-
import { SPAPS } from '
|
|
207
|
-
import { SweetPotatoSDK } from '
|
|
218
|
+
import { SPAPS } from 'spaps-sdk';
|
|
219
|
+
import { SweetPotatoSDK } from 'spaps-sdk';
|
|
208
220
|
```
|
|
209
221
|
|
|
210
222
|
## Admin API Methods
|
|
@@ -296,4 +308,4 @@ try {
|
|
|
296
308
|
|
|
297
309
|
## License
|
|
298
310
|
|
|
299
|
-
MIT
|
|
311
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -212,6 +212,9 @@ __export(index_exports, {
|
|
|
212
212
|
module.exports = __toCommonJS(index_exports);
|
|
213
213
|
var import_axios = __toESM(require("axios"));
|
|
214
214
|
init_permissions();
|
|
215
|
+
if (typeof globalThis.fetch === "undefined") {
|
|
216
|
+
require("cross-fetch/polyfill");
|
|
217
|
+
}
|
|
215
218
|
var SPAPSClient = class {
|
|
216
219
|
client;
|
|
217
220
|
apiKey;
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,12 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
5
11
|
var __esm = (fn, res) => function __init() {
|
|
6
12
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
13
|
};
|
|
@@ -183,6 +189,9 @@ var init_permissions = __esm({
|
|
|
183
189
|
// src/index.ts
|
|
184
190
|
init_permissions();
|
|
185
191
|
import axios from "axios";
|
|
192
|
+
if (typeof globalThis.fetch === "undefined") {
|
|
193
|
+
__require("cross-fetch/polyfill");
|
|
194
|
+
}
|
|
186
195
|
var SPAPSClient = class {
|
|
187
196
|
client;
|
|
188
197
|
apiKey;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spaps-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Sweet Potato Authentication & Payment Service SDK - Zero-config client with built-in permission checking and role-based access control",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
21
21
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
22
|
"test": "echo \"No tests yet\"",
|
|
23
|
-
"
|
|
23
|
+
"smoke-test": "npm run build && node smoke-test.js",
|
|
24
|
+
"prepublishOnly": "npm run build && npm run smoke-test"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
26
27
|
"authentication",
|
|
@@ -36,11 +37,16 @@
|
|
|
36
37
|
"license": "MIT",
|
|
37
38
|
"repository": {
|
|
38
39
|
"type": "git",
|
|
39
|
-
"url": "https://github.com/
|
|
40
|
+
"url": "https://github.com/buildooor/sweet-potato",
|
|
41
|
+
"directory": "packages/sdk"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/buildooor/sweet-potato/tree/main/packages/sdk",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/buildooor/sweet-potato/issues"
|
|
40
46
|
},
|
|
41
|
-
"homepage": "https://sweetpotato.dev",
|
|
42
47
|
"dependencies": {
|
|
43
|
-
"axios": "^1.6.0"
|
|
48
|
+
"axios": "^1.6.0",
|
|
49
|
+
"cross-fetch": "^4.0.0"
|
|
44
50
|
},
|
|
45
51
|
"devDependencies": {
|
|
46
52
|
"@types/node": "^20.10.0",
|
|
@@ -58,5 +64,12 @@
|
|
|
58
64
|
"files": [
|
|
59
65
|
"dist",
|
|
60
66
|
"README.md"
|
|
61
|
-
]
|
|
62
|
-
|
|
67
|
+
],
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public",
|
|
70
|
+
"registry": "https://registry.npmjs.org/"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=14.0.0"
|
|
74
|
+
}
|
|
75
|
+
}
|