@boundlessfi/identity-sdk 0.1.3 → 0.1.4

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.
@@ -30,7 +30,6 @@ var import_zod = require("zod");
30
30
  var boundlessStellarPlugin = () => {
31
31
  return {
32
32
  id: "boundless-stellar",
33
- // Extend the User table to store Stellar data
34
33
  schema: {
35
34
  user: {
36
35
  fields: {
@@ -41,7 +40,6 @@ var boundlessStellarPlugin = () => {
41
40
  }
42
41
  },
43
42
  endpoints: {
44
- // Endpoint to link a deployed wallet to a session
45
43
  linkStellarAccount: (0, import_api.createAuthEndpoint)(
46
44
  "/stellar/link",
47
45
  {
@@ -52,7 +50,9 @@ var boundlessStellarPlugin = () => {
52
50
  })
53
51
  },
54
52
  async (ctx) => {
55
- if (!ctx.context.session) {
53
+ const session = await (0, import_api.getSessionFromCtx)(ctx);
54
+ console.log(session);
55
+ if (!session) {
56
56
  return ctx.json(
57
57
  { success: false, error: "Unauthorized" },
58
58
  { status: 401 }
@@ -61,7 +61,7 @@ var boundlessStellarPlugin = () => {
61
61
  const { stellarAddress, credentialId } = ctx.body;
62
62
  await ctx.context.adapter.update({
63
63
  model: "user",
64
- where: [{ field: "id", value: ctx.context.session.user.id }],
64
+ where: [{ field: "id", value: session.user.id }],
65
65
  update: {
66
66
  stellarAddress,
67
67
  credentialId
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/index.ts","../../src/server/stellar-plugin.ts"],"sourcesContent":["export { boundlessStellarPlugin } from \"./stellar-plugin\";\n","import type { BetterAuthPlugin } from \"better-auth\";\nimport { createAuthEndpoint } from \"better-auth/api\";\nimport { z } from \"zod\";\n\nexport const boundlessStellarPlugin = () => {\n return {\n id: \"boundless-stellar\",\n // Extend the User table to store Stellar data\n schema: {\n user: {\n fields: {\n stellarAddress: { type: \"string\", required: false, input: false },\n credentialId: { type: \"string\", required: false, input: false }, // From WebAuthn\n },\n },\n },\n endpoints: {\n // Endpoint to link a deployed wallet to a session\n linkStellarAccount: createAuthEndpoint(\n \"/stellar/link\",\n {\n method: \"POST\",\n body: z.object({\n stellarAddress: z\n .string()\n .min(56)\n .max(56)\n .regex(/^C[A-Z0-9]{55}$/, \"Invalid Stellar address format\"),\n credentialId: z.string().min(1, \"Credential ID is required\"),\n }),\n },\n async (ctx) => {\n if (!ctx.context.session) {\n return ctx.json(\n { success: false, error: \"Unauthorized\" },\n { status: 401 },\n );\n }\n\n const { stellarAddress, credentialId } = ctx.body;\n\n // Logic to update the authenticated user's record in the DB\n\n await ctx.context.adapter.update({\n model: \"user\",\n where: [{ field: \"id\", value: ctx.context.session.user.id }],\n update: {\n stellarAddress,\n credentialId,\n },\n });\n return ctx.json({ success: true });\n },\n ),\n },\n } satisfies BetterAuthPlugin;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAAmC;AACnC,iBAAkB;AAEX,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,IAAI;AAAA;AAAA,IAEJ,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ;AAAA,UACN,gBAAgB,EAAE,MAAM,UAAU,UAAU,OAAO,OAAO,MAAM;AAAA,UAChE,cAAc,EAAE,MAAM,UAAU,UAAU,OAAO,OAAO,MAAM;AAAA;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW;AAAA;AAAA,MAET,wBAAoB;AAAA,QAClB;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,MAAM,aAAE,OAAO;AAAA,YACb,gBAAgB,aACb,OAAO,EACP,IAAI,EAAE,EACN,IAAI,EAAE,EACN,MAAM,mBAAmB,gCAAgC;AAAA,YAC5D,cAAc,aAAE,OAAO,EAAE,IAAI,GAAG,2BAA2B;AAAA,UAC7D,CAAC;AAAA,QACH;AAAA,QACA,OAAO,QAAQ;AACb,cAAI,CAAC,IAAI,QAAQ,SAAS;AACxB,mBAAO,IAAI;AAAA,cACT,EAAE,SAAS,OAAO,OAAO,eAAe;AAAA,cACxC,EAAE,QAAQ,IAAI;AAAA,YAChB;AAAA,UACF;AAEA,gBAAM,EAAE,gBAAgB,aAAa,IAAI,IAAI;AAI7C,gBAAM,IAAI,QAAQ,QAAQ,OAAO;AAAA,YAC/B,OAAO;AAAA,YACP,OAAO,CAAC,EAAE,OAAO,MAAM,OAAO,IAAI,QAAQ,QAAQ,KAAK,GAAG,CAAC;AAAA,YAC3D,QAAQ;AAAA,cACN;AAAA,cACA;AAAA,YACF;AAAA,UACF,CAAC;AACD,iBAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/server/index.ts","../../src/server/stellar-plugin.ts"],"sourcesContent":["export { boundlessStellarPlugin } from \"./stellar-plugin\";\n","import type { BetterAuthPlugin } from \"better-auth\";\nimport { createAuthEndpoint, getSessionFromCtx } from \"better-auth/api\";\nimport { z } from \"zod\";\n\nexport const boundlessStellarPlugin = () => {\n return {\n id: \"boundless-stellar\",\n\n schema: {\n user: {\n fields: {\n stellarAddress: { type: \"string\", required: false, input: false },\n credentialId: { type: \"string\", required: false, input: false }, // From WebAuthn\n },\n },\n },\n endpoints: {\n linkStellarAccount: createAuthEndpoint(\n \"/stellar/link\",\n {\n method: \"POST\",\n body: z.object({\n stellarAddress: z\n .string()\n .min(56)\n .max(56)\n .regex(/^C[A-Z0-9]{55}$/, \"Invalid Stellar address format\"),\n credentialId: z.string().min(1, \"Credential ID is required\"),\n }),\n },\n async (ctx) => {\n const session = await getSessionFromCtx(ctx);\n console.log(session);\n if (!session) {\n return ctx.json(\n { success: false, error: \"Unauthorized\" },\n { status: 401 },\n );\n }\n\n const { stellarAddress, credentialId } = ctx.body;\n\n await ctx.context.adapter.update({\n model: \"user\",\n where: [{ field: \"id\", value: session.user.id }],\n update: {\n stellarAddress,\n credentialId,\n },\n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AC;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,10 +1,9 @@
1
1
  // src/server/stellar-plugin.ts
2
- import { createAuthEndpoint } from "better-auth/api";
2
+ import { createAuthEndpoint, getSessionFromCtx } from "better-auth/api";
3
3
  import { z } from "zod";
4
4
  var boundlessStellarPlugin = () => {
5
5
  return {
6
6
  id: "boundless-stellar",
7
- // Extend the User table to store Stellar data
8
7
  schema: {
9
8
  user: {
10
9
  fields: {
@@ -15,7 +14,6 @@ var boundlessStellarPlugin = () => {
15
14
  }
16
15
  },
17
16
  endpoints: {
18
- // Endpoint to link a deployed wallet to a session
19
17
  linkStellarAccount: createAuthEndpoint(
20
18
  "/stellar/link",
21
19
  {
@@ -26,7 +24,9 @@ var boundlessStellarPlugin = () => {
26
24
  })
27
25
  },
28
26
  async (ctx) => {
29
- if (!ctx.context.session) {
27
+ const session = await getSessionFromCtx(ctx);
28
+ console.log(session);
29
+ if (!session) {
30
30
  return ctx.json(
31
31
  { success: false, error: "Unauthorized" },
32
32
  { status: 401 }
@@ -35,7 +35,7 @@ var boundlessStellarPlugin = () => {
35
35
  const { stellarAddress, credentialId } = ctx.body;
36
36
  await ctx.context.adapter.update({
37
37
  model: "user",
38
- where: [{ field: "id", value: ctx.context.session.user.id }],
38
+ where: [{ field: "id", value: session.user.id }],
39
39
  update: {
40
40
  stellarAddress,
41
41
  credentialId
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/stellar-plugin.ts"],"sourcesContent":["import type { BetterAuthPlugin } from \"better-auth\";\nimport { createAuthEndpoint } from \"better-auth/api\";\nimport { z } from \"zod\";\n\nexport const boundlessStellarPlugin = () => {\n return {\n id: \"boundless-stellar\",\n // Extend the User table to store Stellar data\n schema: {\n user: {\n fields: {\n stellarAddress: { type: \"string\", required: false, input: false },\n credentialId: { type: \"string\", required: false, input: false }, // From WebAuthn\n },\n },\n },\n endpoints: {\n // Endpoint to link a deployed wallet to a session\n linkStellarAccount: createAuthEndpoint(\n \"/stellar/link\",\n {\n method: \"POST\",\n body: z.object({\n stellarAddress: z\n .string()\n .min(56)\n .max(56)\n .regex(/^C[A-Z0-9]{55}$/, \"Invalid Stellar address format\"),\n credentialId: z.string().min(1, \"Credential ID is required\"),\n }),\n },\n async (ctx) => {\n if (!ctx.context.session) {\n return ctx.json(\n { success: false, error: \"Unauthorized\" },\n { status: 401 },\n );\n }\n\n const { stellarAddress, credentialId } = ctx.body;\n\n // Logic to update the authenticated user's record in the DB\n\n await ctx.context.adapter.update({\n model: \"user\",\n where: [{ field: \"id\", value: ctx.context.session.user.id }],\n update: {\n stellarAddress,\n credentialId,\n },\n });\n return ctx.json({ success: true });\n },\n ),\n },\n } satisfies BetterAuthPlugin;\n};\n"],"mappings":";AACA,SAAS,0BAA0B;AACnC,SAAS,SAAS;AAEX,IAAM,yBAAyB,MAAM;AAC1C,SAAO;AAAA,IACL,IAAI;AAAA;AAAA,IAEJ,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ;AAAA,UACN,gBAAgB,EAAE,MAAM,UAAU,UAAU,OAAO,OAAO,MAAM;AAAA,UAChE,cAAc,EAAE,MAAM,UAAU,UAAU,OAAO,OAAO,MAAM;AAAA;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW;AAAA;AAAA,MAET,oBAAoB;AAAA,QAClB;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,MAAM,EAAE,OAAO;AAAA,YACb,gBAAgB,EACb,OAAO,EACP,IAAI,EAAE,EACN,IAAI,EAAE,EACN,MAAM,mBAAmB,gCAAgC;AAAA,YAC5D,cAAc,EAAE,OAAO,EAAE,IAAI,GAAG,2BAA2B;AAAA,UAC7D,CAAC;AAAA,QACH;AAAA,QACA,OAAO,QAAQ;AACb,cAAI,CAAC,IAAI,QAAQ,SAAS;AACxB,mBAAO,IAAI;AAAA,cACT,EAAE,SAAS,OAAO,OAAO,eAAe;AAAA,cACxC,EAAE,QAAQ,IAAI;AAAA,YAChB;AAAA,UACF;AAEA,gBAAM,EAAE,gBAAgB,aAAa,IAAI,IAAI;AAI7C,gBAAM,IAAI,QAAQ,QAAQ,OAAO;AAAA,YAC/B,OAAO;AAAA,YACP,OAAO,CAAC,EAAE,OAAO,MAAM,OAAO,IAAI,QAAQ,QAAQ,KAAK,GAAG,CAAC;AAAA,YAC3D,QAAQ;AAAA,cACN;AAAA,cACA;AAAA,YACF;AAAA,UACF,CAAC;AACD,iBAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/server/stellar-plugin.ts"],"sourcesContent":["import type { BetterAuthPlugin } from \"better-auth\";\nimport { createAuthEndpoint, getSessionFromCtx } from \"better-auth/api\";\nimport { z } from \"zod\";\n\nexport const boundlessStellarPlugin = () => {\n return {\n id: \"boundless-stellar\",\n\n schema: {\n user: {\n fields: {\n stellarAddress: { type: \"string\", required: false, input: false },\n credentialId: { type: \"string\", required: false, input: false }, // From WebAuthn\n },\n },\n },\n endpoints: {\n linkStellarAccount: createAuthEndpoint(\n \"/stellar/link\",\n {\n method: \"POST\",\n body: z.object({\n stellarAddress: z\n .string()\n .min(56)\n .max(56)\n .regex(/^C[A-Z0-9]{55}$/, \"Invalid Stellar address format\"),\n credentialId: z.string().min(1, \"Credential ID is required\"),\n }),\n },\n async (ctx) => {\n const session = await getSessionFromCtx(ctx);\n console.log(session);\n if (!session) {\n return ctx.json(\n { success: false, error: \"Unauthorized\" },\n { status: 401 },\n );\n }\n\n const { stellarAddress, credentialId } = ctx.body;\n\n await ctx.context.adapter.update({\n model: \"user\",\n where: [{ field: \"id\", value: session.user.id }],\n update: {\n stellarAddress,\n credentialId,\n },\n });\n return ctx.json({ success: true });\n },\n ),\n },\n } satisfies BetterAuthPlugin;\n};\n"],"mappings":";AACA,SAAS,oBAAoB,yBAAyB;AACtD,SAAS,SAAS;AAEX,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"0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,11 +1,11 @@
1
1
  import type { BetterAuthPlugin } from "better-auth";
2
- import { createAuthEndpoint } from "better-auth/api";
2
+ import { createAuthEndpoint, getSessionFromCtx } from "better-auth/api";
3
3
  import { z } from "zod";
4
4
 
5
5
  export const boundlessStellarPlugin = () => {
6
6
  return {
7
7
  id: "boundless-stellar",
8
- // Extend the User table to store Stellar data
8
+
9
9
  schema: {
10
10
  user: {
11
11
  fields: {
@@ -15,7 +15,6 @@ export const boundlessStellarPlugin = () => {
15
15
  },
16
16
  },
17
17
  endpoints: {
18
- // Endpoint to link a deployed wallet to a session
19
18
  linkStellarAccount: createAuthEndpoint(
20
19
  "/stellar/link",
21
20
  {
@@ -30,7 +29,9 @@ export const boundlessStellarPlugin = () => {
30
29
  }),
31
30
  },
32
31
  async (ctx) => {
33
- if (!ctx.context.session) {
32
+ const session = await getSessionFromCtx(ctx);
33
+ console.log(session);
34
+ if (!session) {
34
35
  return ctx.json(
35
36
  { success: false, error: "Unauthorized" },
36
37
  { status: 401 },
@@ -39,11 +40,9 @@ export const boundlessStellarPlugin = () => {
39
40
 
40
41
  const { stellarAddress, credentialId } = ctx.body;
41
42
 
42
- // Logic to update the authenticated user's record in the DB
43
-
44
43
  await ctx.context.adapter.update({
45
44
  model: "user",
46
- where: [{ field: "id", value: ctx.context.session.user.id }],
45
+ where: [{ field: "id", value: session.user.id }],
47
46
  update: {
48
47
  stellarAddress,
49
48
  credentialId,